From df4fad2c5ab23eb21383549a05d49aae9689d32d Mon Sep 17 00:00:00 2001 From: gushen610140 Date: Wed, 18 Feb 2026 01:08:26 +0800 Subject: [PATCH] feat: add login system backend --- .env.development | 2 +- src/apis/system/oauth.ts | 28 +++ src/apis/system/user.ts | 26 +++ src/apis/temp/auth-qrcode.ts | 17 ++ src/apis/user.ts | 19 -- src/components/button/UserAuthNavButton.vue | 49 ++++- src/components/dialog/AuthDialog.vue | 223 ++++++++++++++------ src/i18n/en_US.ts | 4 + src/i18n/index.ts | 4 + src/i18n/zh_CN.ts | 6 +- src/stores/UserStore.ts | 81 ++++++- src/style.css | 6 + src/utils/http.ts | 18 +- 13 files changed, 383 insertions(+), 100 deletions(-) create mode 100644 src/apis/system/oauth.ts create mode 100644 src/apis/system/user.ts create mode 100644 src/apis/temp/auth-qrcode.ts delete mode 100644 src/apis/user.ts diff --git a/.env.development b/.env.development index 0a2a4c2..90d54c2 100644 --- a/.env.development +++ b/.env.development @@ -1 +1 @@ -VITE_SERVER=http://localhost:8080 \ No newline at end of file +VITE_SERVER=http://localhost:48080 \ No newline at end of file diff --git a/src/apis/system/oauth.ts b/src/apis/system/oauth.ts new file mode 100644 index 0000000..6082ff8 --- /dev/null +++ b/src/apis/system/oauth.ts @@ -0,0 +1,28 @@ +import { httpWithCustomReturn } from "@/utils/http"; + +export const loginByEmailPasswordWithOauthApi = ({ email, password }) => { + return httpWithCustomReturn<{ + code: number; + msg: string; + data: { + scope: string; + access_token: string; + refresh_token: string; + token_type: string; + expires_in: number; + }; + }>({ + url: "/admin-api/system/oauth2/token", + method: "POST", + params: { + grant_type: "password", + username: email, + password, + client_id: "rc", + client_secret: "rc", + }, + headers: { + "tenant-id": 1, + }, + }); +}; diff --git a/src/apis/system/user.ts b/src/apis/system/user.ts new file mode 100644 index 0000000..789ab10 --- /dev/null +++ b/src/apis/system/user.ts @@ -0,0 +1,26 @@ +import { httpWithCustomReturn } from "@/utils/http"; + +export const getUserInfoApi = () => { + return httpWithCustomReturn<{ + code: number; + msg: string; + data: { + id: number; + username: string; + nickname: string; + email: string; + mobile: string; + sex: number; + avatar: string; + loginIp: string; + loginDate: null; + createTime: number; + roles: object[]; + dept: null; + posts: null; + }; + }>({ + url: "/admin-api/system/user/profile/get", + method: "GET", + }); +}; diff --git a/src/apis/temp/auth-qrcode.ts b/src/apis/temp/auth-qrcode.ts new file mode 100644 index 0000000..de297b5 --- /dev/null +++ b/src/apis/temp/auth-qrcode.ts @@ -0,0 +1,17 @@ +import { httpWithCustomReturn } from "@/utils/http"; + +/** + * + * @returns 直接返回图片二进制数据 + */ +export const getAuthQrcodeApi = () => { + return httpWithCustomReturn({ + url: "https://api.qrtool.cn", + method: "get", + responseType: "blob", + params: { + text: "测试", + size: 600, + }, + }); +}; diff --git a/src/apis/user.ts b/src/apis/user.ts deleted file mode 100644 index 51c890e..0000000 --- a/src/apis/user.ts +++ /dev/null @@ -1,19 +0,0 @@ -import http from "../utils/http"; - -/** - * This is an example, please remove if not needed - */ -export const getUserList = () => { - return http({ - url: "/user/list", - method: "get", - }); -}; - -export const insertUser = (data: { account: string; passowrd: string }) => { - return http({ - url: "/user/insert", - method: "post", - data, - }); -}; diff --git a/src/components/button/UserAuthNavButton.vue b/src/components/button/UserAuthNavButton.vue index dd0aa88..284a9eb 100644 --- a/src/components/button/UserAuthNavButton.vue +++ b/src/components/button/UserAuthNavButton.vue @@ -1,5 +1,9 @@