diff --git a/.env.development b/.env.development index 24a66be2..68e91e69 100644 --- a/.env.development +++ b/.env.development @@ -15,4 +15,7 @@ VITE_BASE = '/' VITE_OPEN_DEVTOOLS = false # 应用配置面板 -VITE_APP_SETTING = true \ No newline at end of file +VITE_APP_SETTING = true + +# 客户端ID +VITE_CLIENT_ID = 'ef51c9a3e9046c4f2ea45142c8a8344a' \ No newline at end of file diff --git a/.env.production b/.env.production index 80d2a415..debf2351 100644 --- a/.env.production +++ b/.env.production @@ -11,4 +11,7 @@ VITE_API_WS_URL = 'wss://api.continew.top' VITE_BASE = '/' # 应用配置面板 -VITE_APP_SETTING = true \ No newline at end of file +VITE_APP_SETTING = true + +# 客户端ID +VITE_CLIENT_ID = 'ef51c9a3e9046c4f2ea45142c8a8344a' \ No newline at end of file diff --git a/.env.test b/.env.test index 68c14e1b..782fac20 100644 --- a/.env.test +++ b/.env.test @@ -16,4 +16,7 @@ VITE_BASE = '/test' VITE_OPEN_DEVTOOLS = true # 应用配置面板 -VITE_APP_SETTING = false \ No newline at end of file +VITE_APP_SETTING = false + +# 客户端ID +VITE_CLIENT_ID = '8ed5c8f9-555a-4961-ab66-9b87ddc4e3d0' \ No newline at end of file diff --git a/src/apis/auth/index.ts b/src/apis/auth/index.ts index 61f09c9d..46957578 100644 --- a/src/apis/auth/index.ts +++ b/src/apis/auth/index.ts @@ -7,22 +7,22 @@ const BASE_URL = '/auth' /** @desc 账号登录 */ export function accountLogin(req: T.AccountLoginReq) { - return http.post(`${BASE_URL}/account`, req) + return http.post(`${BASE_URL}/login`, req) } /** @desc 手机号登录 */ export function phoneLogin(req: T.PhoneLoginReq) { - return http.post(`${BASE_URL}/phone`, req) + return http.post(`${BASE_URL}/login`, req) } /** @desc 邮箱登录 */ export function emailLogin(req: T.EmailLoginReq) { - return http.post(`${BASE_URL}/email`, req) + return http.post(`${BASE_URL}/login`, req) } /** @desc 三方账号登录 */ -export function socialLogin(source: string, req: any) { - return http.post(`/oauth/${source}`, req) +export function socialLogin(req: any) { + return http.post(`${BASE_URL}/login`, req) } /** @desc 三方账号登录授权 */ diff --git a/src/apis/auth/type.ts b/src/apis/auth/type.ts index 578010cd..a8a42e49 100644 --- a/src/apis/auth/type.ts +++ b/src/apis/auth/type.ts @@ -41,8 +41,20 @@ export interface RouteItem { affix: boolean } +/** 认证类型 */ +export enum AuthTypeEnum { + ACCOUNT = 'account', + PHONE = 'phone', + EMAIL = 'email', + SOCIAL_AUTH = 'socialAuth', +} +export interface AuthReq { + clientId: string + authType: string +} + /** 账号登录请求参数 */ -export interface AccountLoginReq { +export interface AccountLoginReq extends AuthReq { username: string password: string captcha: string @@ -50,13 +62,13 @@ export interface AccountLoginReq { } /** 手机号登录请求参数 */ -export interface PhoneLoginReq { +export interface PhoneLoginReq extends AuthReq { phone: string captcha: string } /** 邮箱登录请求参数 */ -export interface EmailLoginReq { +export interface EmailLoginReq extends AuthReq { email: string captcha: string } diff --git a/src/apis/system/client.ts b/src/apis/system/client.ts new file mode 100644 index 00000000..25b5fc2c --- /dev/null +++ b/src/apis/system/client.ts @@ -0,0 +1,77 @@ +import http from '@/utils/http' + +const BASE_URL = '/system/client' + +export interface ClientResp { + id: string + clientId: string + clientKey: string + clientSecret: string + authType: string + clientType: string + activeTimeout: string + timeout: string + status: string + createUser: string + createTime: string + updateUser: string + updateTime: string + createUserString: string + updateUserString: string +} +export interface ClientDetailResp { + id: string + clientId: string + clientKey: string + clientSecret: string + authType: string + clientType: string + activeTimeout: string + timeout: string + status: string + createUser: string + createTime: string + updateUser: string + updateTime: string + createUserString: string + updateUserString: string +} +export interface ClientQuery { + clientKey: string + clientSecret: string + authType: string[] + clientType: string + status: string + sort: Array +} +export interface ClientPageQuery extends ClientQuery, PageQuery {} + +/** @desc 查询系统授权列表 */ +export function listClient(query: ClientPageQuery) { + return http.get>(`${BASE_URL}`, query) +} + +/** @desc 查询系统授权详情 */ +export function getClient(id: string) { + return http.get(`${BASE_URL}/${id}`) +} + +/** @desc 新增系统授权 */ +export function addClient(data: any) { + return http.post(`${BASE_URL}`, data) +} + +/** @desc 修改系统授权 */ +export function updateClient(data: any, id: string) { + return http.put(`${BASE_URL}/${id}`, data) +} + +/** @desc 删除系统授权 */ +export function deleteClient(id: string) { + return http.del(`${BASE_URL}/${id}`) +} + +/** @desc 导出系统授权 */ +export function exportClient(query: ClientQuery) { + return http.download(`${BASE_URL}/export`, query) +} diff --git a/src/stores/modules/user.ts b/src/stores/modules/user.ts index 5463279d..c8e58954 100644 --- a/src/stores/modules/user.ts +++ b/src/stores/modules/user.ts @@ -3,6 +3,7 @@ import { computed, reactive, ref } from 'vue' import { resetRouter } from '@/router' import { type AccountLoginReq, + AuthTypeEnum, type EmailLoginReq, type PhoneLoginReq, type UserInfo, @@ -71,7 +72,7 @@ const storeSetup = () => { // 三方账号登录 const socialLogin = async (source: string, req: any) => { - const res = await socialLoginApi(source, req) + const res = await socialLoginApi({ ...req, source, clientId: import.meta.env.VITE_CLIENT_ID, authType: AuthTypeEnum.SOCIAL_AUTH }) setToken(res.data.token) token.value = res.data.token } diff --git a/src/types/components.d.ts b/src/types/components.d.ts index a9bab95c..89911ebc 100644 --- a/src/types/components.d.ts +++ b/src/types/components.d.ts @@ -13,7 +13,6 @@ declare module 'vue' { Chart: typeof import('./../components/Chart/index.vue')['default'] CronForm: typeof import('./../components/GenCron/CronForm/index.vue')['default'] CronModal: typeof import('./../components/GenCron/CronModal/index.vue')['default'] - CronModel: typeof import('./../components/GenCron/CronModel/index.vue')['default'] DateRangePicker: typeof import('./../components/DateRangePicker/index.vue')['default'] DayForm: typeof import('./../components/GenCron/CronForm/component/day-form.vue')['default'] FilePreview: typeof import('./../components/FilePreview/index.vue')['default'] diff --git a/src/types/env.d.ts b/src/types/env.d.ts index 97c8118b..acbbf80c 100644 --- a/src/types/env.d.ts +++ b/src/types/env.d.ts @@ -6,6 +6,7 @@ interface ImportMetaEnv { readonly VITE_API_BASE_URL: string readonly VITE_BASE: string readonly VITE_APP_SETTING: string + readonly VITE_CLIENT_ID: string } interface ImportMeta { diff --git a/src/views/login/components/account/index.vue b/src/views/login/components/account/index.vue index e6693d24..70aec322 100644 --- a/src/views/login/components/account/index.vue +++ b/src/views/login/components/account/index.vue @@ -43,6 +43,7 @@ import { useStorage } from '@vueuse/core' import { getImageCaptcha } from '@/apis/common' import { useTabsStore, useUserStore } from '@/stores' import { encryptByRsa } from '@/utils/encrypt' +import { AuthTypeEnum } from '@/apis' const loginConfig = useStorage('login-config', { rememberMe: true, @@ -119,6 +120,8 @@ const handleLogin = async () => { password: encryptByRsa(form.password) || '', captcha: form.captcha, uuid: form.uuid, + clientId: import.meta.env.VITE_CLIENT_ID, + authType: AuthTypeEnum.ACCOUNT, }) tabsStore.reset() const { redirect, ...othersQuery } = router.currentRoute.value.query @@ -132,6 +135,8 @@ const handleLogin = async () => { loginConfig.value.username = rememberMe ? form.username : '' Message.success('欢迎使用') } catch (error) { + console.log('error', error) + getCaptcha() form.captcha = '' } finally { diff --git a/src/views/login/components/email/index.vue b/src/views/login/components/email/index.vue index 55f7a888..17ef2844 100644 --- a/src/views/login/components/email/index.vue +++ b/src/views/login/components/email/index.vue @@ -40,7 +40,7 @@ + + diff --git a/src/views/system/client/ClientDetailDrawer.vue b/src/views/system/client/ClientDetailDrawer.vue new file mode 100644 index 00000000..046a3e1d --- /dev/null +++ b/src/views/system/client/ClientDetailDrawer.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/src/views/system/client/index.vue b/src/views/system/client/index.vue new file mode 100644 index 00000000..0c68e0fb --- /dev/null +++ b/src/views/system/client/index.vue @@ -0,0 +1,219 @@ + + + + +