add router

This commit is contained in:
2024-10-15 18:53:09 +08:00
parent 6b5eec89ed
commit 175e685480
6 changed files with 67 additions and 113 deletions

View File

@@ -2,11 +2,13 @@ import { useConfig } from '@abearxiong/use-config';
const { resources, api } = useConfig<{
resources: string;
api: { host: string };
api: { host: string; path: string };
ƒ;
}>();
const apiPath = api.path || '/api/router';
export const fetchTest = async (id: string) => {
const fetchUrl = 'http://' + api.host + '/api/router';
const fetchUrl = 'http://' + api.host + apiPath;
const fetchRes = await fetch(fetchUrl, {
method: 'POST',
headers: {
@@ -22,7 +24,7 @@ export const fetchTest = async (id: string) => {
};
export const fetchDomain = async (domain: string) => {
const fetchUrl = 'http://' + api.host + '/api/router';
const fetchUrl = 'http://' + api.host + apiPath;
const fetchRes = await fetch(fetchUrl, {
method: 'POST',
headers: {
@@ -38,3 +40,22 @@ export const fetchDomain = async (domain: string) => {
}).then((res) => res.json());
return fetchRes;
};
export const fetchApp = async ({ user, app }) => {
const fetchUrl = 'http://' + api.host + apiPath;
const fetchRes = await fetch(fetchUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
path: 'app',
key: 'getApp',
data: {
user,
key: app,
},
}),
}).then((res) => res.json());
return fetchRes;
};