mirror of https://github.com/halo-dev/halo-admin
parent
5f8f8c6c29
commit
44f09fd2c1
|
@ -0,0 +1 @@
|
||||||
|
VITE_API_URL=http://localhost:8090
|
|
@ -0,0 +1 @@
|
||||||
|
VITE_API_URL=/
|
|
@ -12,14 +12,15 @@ import {
|
||||||
CoreHaloRunV1alpha1LinkGroupApi,
|
CoreHaloRunV1alpha1LinkGroupApi,
|
||||||
} from "@halo-dev/api-client";
|
} from "@halo-dev/api-client";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import type { AxiosInstance } from "axios";
|
||||||
|
|
||||||
const baseUrl = "http://localhost:8090";
|
let apiUrl: string | undefined;
|
||||||
|
|
||||||
const axiosInstance = axios.create({
|
const axiosInstance = axios.create({
|
||||||
baseURL: "http://localhost:8090",
|
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let apiClient = setupApiClient(axiosInstance);
|
||||||
|
|
||||||
axiosInstance.interceptors.response.use(
|
axiosInstance.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
return response;
|
return response;
|
||||||
|
@ -33,38 +34,38 @@ axiosInstance.interceptors.response.use(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const apiClient = {
|
const setApiUrl = (url: string) => {
|
||||||
extension: {
|
axiosInstance.defaults.baseURL = url;
|
||||||
configMap: new V1alpha1ConfigMapApi(undefined, baseUrl, axiosInstance),
|
apiUrl = url;
|
||||||
personalAccessToken: new V1alpha1PersonalAccessTokenApi(
|
apiClient = setupApiClient(axiosInstance);
|
||||||
undefined,
|
|
||||||
baseUrl,
|
|
||||||
axiosInstance
|
|
||||||
),
|
|
||||||
roleBinding: new V1alpha1RoleBindingApi(undefined, baseUrl, axiosInstance),
|
|
||||||
role: new V1alpha1RoleApi(undefined, baseUrl, axiosInstance),
|
|
||||||
setting: new V1alpha1SettingApi(undefined, baseUrl, axiosInstance),
|
|
||||||
reverseProxy: new PluginHaloRunV1alpha1ReverseProxyApi(
|
|
||||||
undefined,
|
|
||||||
baseUrl,
|
|
||||||
axiosInstance
|
|
||||||
),
|
|
||||||
plugin: new PluginHaloRunV1alpha1PluginApi(
|
|
||||||
undefined,
|
|
||||||
baseUrl,
|
|
||||||
axiosInstance
|
|
||||||
),
|
|
||||||
user: new V1alpha1UserApi(undefined, baseUrl, axiosInstance),
|
|
||||||
|
|
||||||
// TODO optional
|
|
||||||
link: new CoreHaloRunV1alpha1LinkApi(undefined, baseUrl, axiosInstance),
|
|
||||||
linkGroup: new CoreHaloRunV1alpha1LinkGroupApi(
|
|
||||||
undefined,
|
|
||||||
baseUrl,
|
|
||||||
axiosInstance
|
|
||||||
),
|
|
||||||
},
|
|
||||||
user: new ApiHaloRunV1alpha1UserApi(undefined, baseUrl, axiosInstance),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export { apiClient };
|
function setupApiClient(axios: AxiosInstance) {
|
||||||
|
return {
|
||||||
|
extension: {
|
||||||
|
configMap: new V1alpha1ConfigMapApi(undefined, apiUrl, axios),
|
||||||
|
personalAccessToken: new V1alpha1PersonalAccessTokenApi(
|
||||||
|
undefined,
|
||||||
|
apiUrl,
|
||||||
|
axios
|
||||||
|
),
|
||||||
|
roleBinding: new V1alpha1RoleBindingApi(undefined, apiUrl, axios),
|
||||||
|
role: new V1alpha1RoleApi(undefined, apiUrl, axios),
|
||||||
|
setting: new V1alpha1SettingApi(undefined, apiUrl, axios),
|
||||||
|
reverseProxy: new PluginHaloRunV1alpha1ReverseProxyApi(
|
||||||
|
undefined,
|
||||||
|
apiUrl,
|
||||||
|
axios
|
||||||
|
),
|
||||||
|
plugin: new PluginHaloRunV1alpha1PluginApi(undefined, apiUrl, axios),
|
||||||
|
user: new V1alpha1UserApi(undefined, apiUrl, axios),
|
||||||
|
|
||||||
|
// TODO optional
|
||||||
|
link: new CoreHaloRunV1alpha1LinkApi(undefined, apiUrl, axios),
|
||||||
|
linkGroup: new CoreHaloRunV1alpha1LinkGroupApi(undefined, apiUrl, axios),
|
||||||
|
},
|
||||||
|
user: new ApiHaloRunV1alpha1UserApi(undefined, apiUrl, axios),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export { apiClient, setApiUrl };
|
||||||
|
|
|
@ -8,7 +8,7 @@ import type {
|
||||||
MenuItemType,
|
MenuItemType,
|
||||||
Plugin,
|
Plugin,
|
||||||
} from "@halo-dev/admin-shared";
|
} from "@halo-dev/admin-shared";
|
||||||
import { apiClient } from "@halo-dev/admin-shared";
|
import { apiClient, setApiUrl } from "@halo-dev/admin-shared";
|
||||||
import { menus, minimenus, registerMenu } from "./router/menus.config";
|
import { menus, minimenus, registerMenu } from "./router/menus.config";
|
||||||
// setup
|
// setup
|
||||||
import "./setup/setupStyles";
|
import "./setup/setupStyles";
|
||||||
|
@ -25,6 +25,7 @@ import { useRoleStore } from "@/stores/role";
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
setupComponents(app);
|
setupComponents(app);
|
||||||
|
setApiUrl(import.meta.env.VITE_API_URL);
|
||||||
|
|
||||||
app.use(createPinia());
|
app.use(createPinia());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue