From 637d596a5561e109c1b55bf9163b0f39dddd1b9f Mon Sep 17 00:00:00 2001 From: fangyunong Date: Sun, 6 Jul 2025 16:08:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- auto-imports.d.ts | 5 +++-- src/api/loginApi.ts | 10 ---------- src/api/userApi.ts | 10 ++++++++++ src/utils/request.ts | 2 +- src/views/login/OauthCallBack.vue | 3 +++ src/views/login/index.vue | 1 - vite.config.ts | 6 +++--- 8 files changed, 21 insertions(+), 18 deletions(-) delete mode 100644 src/api/loginApi.ts create mode 100644 src/api/userApi.ts diff --git a/.env b/.env index 2ae3c1c..6ea3487 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -VITE_API_BASE_URL=http://localhost:3000 \ No newline at end of file +VITE_API_BASE_URL=http://47.94.224.191:8080 \ No newline at end of file diff --git a/auto-imports.d.ts b/auto-imports.d.ts index 8c26771..5d39540 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -17,12 +17,13 @@ declare global { const getCurrentScope: typeof import('vue')['getCurrentScope'] const h: typeof import('vue')['h'] const inject: typeof import('vue')['inject'] + const isNewUser: typeof import('./src/api/userApi')['isNewUser'] const isProxy: typeof import('vue')['isProxy'] const isReactive: typeof import('vue')['isReactive'] const isReadonly: typeof import('vue')['isReadonly'] const isRef: typeof import('vue')['isRef'] - const login: typeof import('./src/api/loginApi')['login'] - const loginApiTest: typeof import('./src/api/loginApi')['loginApiTest'] + const login: typeof import('./src/api/userApi')['login'] + const loginApiTest: typeof import('./src/api/userApi')['loginApiTest'] const markRaw: typeof import('vue')['markRaw'] const nextTick: typeof import('vue')['nextTick'] const onActivated: typeof import('vue')['onActivated'] diff --git a/src/api/loginApi.ts b/src/api/loginApi.ts deleted file mode 100644 index 331132c..0000000 --- a/src/api/loginApi.ts +++ /dev/null @@ -1,10 +0,0 @@ -import http from "@/utils/request"; - -//demo -export const loginApiTest = () => { - return http({ - url:'/search', - method:'get' - }) -} - diff --git a/src/api/userApi.ts b/src/api/userApi.ts new file mode 100644 index 0000000..20e6f0f --- /dev/null +++ b/src/api/userApi.ts @@ -0,0 +1,10 @@ +import http from "@/utils/request"; + +//demo +export const isNewUser = () => { + return http({ + url:'/api/UserInfo/IsNewUser', + method:'GET' + }) +} + diff --git a/src/utils/request.ts b/src/utils/request.ts index 2f82c7f..d098725 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -9,7 +9,7 @@ interface ApiResponse { } const instance = axios.create({ - baseURL: `${import.meta.env.VITE_API_BASE_URL as string}/api`, // 从 Vite 环境变量获取 baseURL + baseURL: import.meta.env.VITE_API_BASE_URL as string, // 从 Vite 环境变量获取 baseURL timeout: 10000, // 请求超时时间 headers: { "Content-Type": "application/json", diff --git a/src/views/login/OauthCallBack.vue b/src/views/login/OauthCallBack.vue index 0051db1..7dda357 100644 --- a/src/views/login/OauthCallBack.vue +++ b/src/views/login/OauthCallBack.vue @@ -8,6 +8,7 @@ import { setToken } from '@/utils/auth'; import { useAuth0 } from '@auth0/auth0-vue'; import { useMessage } from 'naive-ui'; +import { isNewUser } from '@/api/userApi'; const { getAccessTokenSilently } = useAuth0(); const router = useRouter(); @@ -16,6 +17,8 @@ const oSomethingWithToken = async () => { try { const token = await getAccessTokenSilently(); setToken(token); + const res = await isNewUser(); + console.log(res,'res'); message.success('登录成功!'); router.push('/layout'); } catch (error) { diff --git a/src/views/login/index.vue b/src/views/login/index.vue index ef7806b..dbd6d20 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -206,7 +206,6 @@ import { ChevronForward, GitCompare, BarChartSharp, Server } from '@vicons/ionicons5'; import { useAuth0 } from '@auth0/auth0-vue'; import { useDialog, useMessage } from 'naive-ui'; -// import { loginApiTest } from '@/api/loginApi' const dialog = useDialog(); const message = useMessage(); const handleDemo = async () => { diff --git a/vite.config.ts b/vite.config.ts index 664a141..f83b1b4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,7 +3,7 @@ import vue from "@vitejs/plugin-vue"; import { fileURLToPath, URL } from "url"; import AutoImport from "unplugin-auto-import/vite"; import { createSvgIconsPlugin } from "vite-plugin-svg-icons"; -import path from 'path'; +import path from "path"; // https://vite.dev/config/ export default defineConfig({ @@ -28,9 +28,9 @@ export default defineConfig({ server: { proxy: { "/api": { - target: "http://localhost:3000/api", + target: "http://47.94.224.191:8080", // 去掉末尾的 /api changeOrigin: true, - rewrite: (path) => path.replace(/^\api/, ""), + rewrite: (path) => path.replace(/^\/api/, ""), // 修正正则表达式 }, }, },