From 71bda8e9562f1d20f1e6f3f339d30cd478fb5805 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 27 Jun 2022 15:31:16 +0800 Subject: [PATCH] feat: admin shared package support api client Signed-off-by: Ryan Wang --- package.json | 1 - packages/shared/src/index.ts | 2 ++ packages/shared/src/layouts/UserProfileLayout.vue | 2 +- packages/shared/src/utils/api-client.ts | 4 ++-- pnpm-lock.yaml | 2 -- src/main.ts | 2 +- src/modules/system/plugins/PluginDetail.vue | 2 +- src/modules/system/plugins/PluginList.vue | 2 +- src/modules/system/users/UserList.vue | 2 +- src/utils/api-client.ts | 12 ------------ 10 files changed, 9 insertions(+), 22 deletions(-) delete mode 100644 src/utils/api-client.ts diff --git a/package.json b/package.json index d8ef42f95..6c54c2db1 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "@halo-dev/admin-shared": "workspace:*", "@halo-dev/components": "workspace:*", "@vueuse/core": "^8.7.5", - "axios": "^0.27.2", "filepond": "^4.30.4", "filepond-plugin-image-preview": "^4.6.11", "floating-vue": "2.0.0-beta.16", diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index c55f15927..7419e2938 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -6,3 +6,5 @@ export * from "./core/plugins"; export * from "./states/pages"; export * from "./types/extension"; export * from "./layouts"; + +export * from "./utils/api-client"; diff --git a/packages/shared/src/layouts/UserProfileLayout.vue b/packages/shared/src/layouts/UserProfileLayout.vue index 1769fcd35..6e7814051 100644 --- a/packages/shared/src/layouts/UserProfileLayout.vue +++ b/packages/shared/src/layouts/UserProfileLayout.vue @@ -4,7 +4,7 @@ import { IconUpload, VButton, VTabbar } from "@halo-dev/components"; import { onMounted, provide, ref } from "vue"; import { useRoute, useRouter } from "vue-router"; import { Starport } from "vue-starport"; -import axiosInstance from "@/utils/api-client"; +import { axiosInstance } from "@/utils/api-client"; import type { User } from "@/types/extension"; const tabs = [ diff --git a/packages/shared/src/utils/api-client.ts b/packages/shared/src/utils/api-client.ts index 03a96f162..87574484d 100644 --- a/packages/shared/src/utils/api-client.ts +++ b/packages/shared/src/utils/api-client.ts @@ -1,7 +1,7 @@ import axios from "axios"; const token = -"eyJhbGciOiJSUzUxMiJ9.eyJpc3MiOiJIYWxvIE93bmVyIiwic3ViIjoiYWRtaW4iLCJleHAiOjE2NTYxMzk1MzcsImlhdCI6MTY1NjA1MzEzNywic2NvcGUiOlsiUk9MRV9zdXBlci1yb2xlIl19.QUAe5lD2chY5NG_bXwqPxk2y4gxUifz-_H-dN_ZcggdQ0Nm2m5R168VUt33jJ4gCUW5HQx7hqJY_V60jDQ0nAP3VjrfeDNG7BvoaqLyoThg40f1oD-AUoB648b_TZga0oKtwkCyLYi_qkgmvF6UZumMsI9rTVHxef6O5vAbSrFFc2pZ90xNH9PN7ILJDimv_2I1IRpBtASJG1cM0yWYUmHWO-yW2UwUKGxJTf3TN_OvJqHcMRqD7Y5Fe1BVhZfzY8UX6KygG21eKd26hLNIQz6xx-O85HTj8HM5CJUR7jSp3Oo7rtQwIbEDTdGeTqmFM96ufL4nVYdpDuONm0zSxYQ" + "eyJhbGciOiJSUzUxMiJ9.eyJpc3MiOiJIYWxvIE93bmVyIiwic3ViIjoiYWRtaW4iLCJleHAiOjE2NTYzODYyODYsImlhdCI6MTY1NjI5OTg4Niwic2NvcGUiOlsiUk9MRV9zdXBlci1yb2xlIl19.uiBxplxctL3a8G_pNWJzEKEMD-a11VPygHh-yUmm3jaZadt5KWIonkuMl3bSASC96NJn3Lmo1OtSagWIkRWUrWqM4r4_sj3NDOiDpcjxy2msrpe8v9sp_BA4yGjAoaoMBEvdjZ3sQ7L9gJKHhL9bTNsXiSkjS5b7OJLujuF5VFJMp-fmzUDz8-EC5u43wz8MUF88bMk4gUg3nOJYnSTRlrU6759IggEM_0SjZu9wewcLxxa4Vhson_mN6hTObsOyWYjMjTbMlSBQiDfN9IXZ2cRZTnE2me0pT6J0AyP33qBp69B-K0cTaUO2Tcx5_BuWHGUCFUAFwE5FKchGgr6NuA" const axiosInstance = axios.create({ headers: { Authorization: `Bearer ${token}`, @@ -9,4 +9,4 @@ const axiosInstance = axios.create({ baseURL: "http://localhost:8090", }); -export default axiosInstance; +export { axiosInstance }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b9463f829..2a8dc0353 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,7 +21,6 @@ importers: '@vue/tsconfig': ^0.1.3 '@vueuse/core': ^8.7.5 autoprefixer: ^10.4.7 - axios: ^0.27.2 c8: ^7.11.3 cypress: ^9.7.0 eslint: ^8.18.0 @@ -61,7 +60,6 @@ importers: '@halo-dev/admin-shared': link:packages/shared '@halo-dev/components': link:packages/components '@vueuse/core': 8.7.5_vue@3.2.37 - axios: 0.27.2 filepond: 4.30.4 filepond-plugin-image-preview: 4.6.11_filepond@4.30.4 floating-vue: 2.0.0-beta.16_vue@3.2.37 diff --git a/src/main.ts b/src/main.ts index fdc48297a..636912517 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,7 +16,7 @@ import { setupComponents } from "./setup/setupComponents"; import { coreModules } from "./modules"; import { useScriptTag } from "@vueuse/core"; import { usePluginStore } from "@/stores/plugin"; -import axiosInstance from "@/utils/api-client"; +import { axiosInstance } from "@halo-dev/admin-shared"; const app = createApp(App); diff --git a/src/modules/system/plugins/PluginDetail.vue b/src/modules/system/plugins/PluginDetail.vue index f8e6967f5..7c39ffd14 100644 --- a/src/modules/system/plugins/PluginDetail.vue +++ b/src/modules/system/plugins/PluginDetail.vue @@ -12,7 +12,7 @@ import { import { useRoute } from "vue-router"; import { computed, ref } from "vue"; import type { Plugin } from "@/types/extension"; -import axiosInstance from "@/utils/api-client"; +import { axiosInstance } from "@halo-dev/admin-shared"; const pluginActiveId = ref("detail"); const plugin = ref(); diff --git a/src/modules/system/plugins/PluginList.vue b/src/modules/system/plugins/PluginList.vue index 247946bef..7078490c4 100644 --- a/src/modules/system/plugins/PluginList.vue +++ b/src/modules/system/plugins/PluginList.vue @@ -15,7 +15,7 @@ import { import { onMounted, ref } from "vue"; import { useRouter } from "vue-router"; import type { Plugin } from "@/types/extension"; -import axiosInstance from "@/utils/api-client"; +import { axiosInstance } from "@halo-dev/admin-shared"; const checkAll = ref(false); const plugins = ref([]); diff --git a/src/modules/system/users/UserList.vue b/src/modules/system/users/UserList.vue index 41d028515..92ec6e822 100644 --- a/src/modules/system/users/UserList.vue +++ b/src/modules/system/users/UserList.vue @@ -14,7 +14,7 @@ import { } from "@halo-dev/components"; import { ref } from "vue"; import { Starport } from "vue-starport"; -import axiosInstance from "@/utils/api-client"; +import { axiosInstance } from "@halo-dev/admin-shared"; import type { User } from "@/types/extension"; const checkAll = ref(false); diff --git a/src/utils/api-client.ts b/src/utils/api-client.ts deleted file mode 100644 index 03a96f162..000000000 --- a/src/utils/api-client.ts +++ /dev/null @@ -1,12 +0,0 @@ -import axios from "axios"; - -const token = -"eyJhbGciOiJSUzUxMiJ9.eyJpc3MiOiJIYWxvIE93bmVyIiwic3ViIjoiYWRtaW4iLCJleHAiOjE2NTYxMzk1MzcsImlhdCI6MTY1NjA1MzEzNywic2NvcGUiOlsiUk9MRV9zdXBlci1yb2xlIl19.QUAe5lD2chY5NG_bXwqPxk2y4gxUifz-_H-dN_ZcggdQ0Nm2m5R168VUt33jJ4gCUW5HQx7hqJY_V60jDQ0nAP3VjrfeDNG7BvoaqLyoThg40f1oD-AUoB648b_TZga0oKtwkCyLYi_qkgmvF6UZumMsI9rTVHxef6O5vAbSrFFc2pZ90xNH9PN7ILJDimv_2I1IRpBtASJG1cM0yWYUmHWO-yW2UwUKGxJTf3TN_OvJqHcMRqD7Y5Fe1BVhZfzY8UX6KygG21eKd26hLNIQz6xx-O85HTj8HM5CJUR7jSp3Oo7rtQwIbEDTdGeTqmFM96ufL4nVYdpDuONm0zSxYQ" -const axiosInstance = axios.create({ - headers: { - Authorization: `Bearer ${token}`, - }, - baseURL: "http://localhost:8090", -}); - -export default axiosInstance;