From a8f575fe6f4440ca62bb2ad850bbc0baf77ded5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E4=B8=AA=E4=B8=89?= <2029364173@qq.com> Date: Sun, 2 Jul 2023 07:29:28 +0000 Subject: [PATCH] =?UTF-8?q?!20=20=E7=BB=9F=E4=B8=80=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=8E=88=E6=9D=83=20*=20=E7=BB=9F=E4=B8=80=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E7=99=BB=E5=BD=95=20*=20=E5=AF=B9=E6=8E=A5=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=81=9A=E4=BA=86=E9=80=82=E9=85=8D=EF=BC=8C?= =?UTF-8?q?=20*=20=E5=89=8D=E7=AB=AF=E5=AE=9E=E7=8E=B0=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E9=80=89=E6=8B=A9=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E7=99=BB=E5=BD=95=EF=BC=8C=E5=92=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=AC=AC=E4=B8=89=E6=96=B9=E9=A1=B5=E9=9D=A2=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +- .env.production | 4 +- .gitignore | 1 + src/api/login.ts | 25 +- src/api/system/client/index.ts | 80 ++++ src/api/system/client/types.ts | 138 +++++++ src/api/system/social/auth.ts | 24 ++ src/api/types.ts | 13 +- src/assets/icons/svg/gitee.svg | 1 + src/layout/components/SocialLogin/index.vue | 82 +++++ src/permission.ts | 2 +- src/router/index.ts | 6 + src/store/modules/user.ts | 4 +- src/types/env.d.ts | 2 +- src/utils/auth.ts | 2 +- src/views/index.vue | 2 +- src/views/login.vue | 194 ++++++---- .../monitor/{xxljob => powerjob}/index.vue | 2 +- src/views/system/client/index.vue | 344 ++++++++++++++++++ src/views/system/menu/index.vue | 2 +- src/views/system/user/profile/index.vue | 16 +- src/views/system/user/profile/thirdParty.vue | 140 +++++++ 22 files changed, 992 insertions(+), 96 deletions(-) create mode 100644 src/api/system/client/index.ts create mode 100644 src/api/system/client/types.ts create mode 100644 src/api/system/social/auth.ts create mode 100644 src/assets/icons/svg/gitee.svg create mode 100644 src/layout/components/SocialLogin/index.vue rename src/views/monitor/{xxljob => powerjob}/index.vue (67%) create mode 100644 src/views/system/client/index.vue create mode 100644 src/views/system/user/profile/thirdParty.vue diff --git a/.env.development b/.env.development index 4ec5afb..6ca0e51 100644 --- a/.env.development +++ b/.env.development @@ -13,7 +13,7 @@ VITE_APP_CONTEXT_PATH = '/' # 监控地址 VITE_APP_MONITRO_ADMIN = 'http://localhost:9090/admin/applications' -# xxl-job 控制台地址 -VITE_APP_XXL_JOB_ADMIN = 'http://localhost:9100/xxl-job-admin' +# powerjob 控制台地址 +VITE_APP_POWERJOB_ADMIN = 'http://localhost:7700/' VITE_APP_PORT = 80 diff --git a/.env.production b/.env.production index 6e6510a..a5e77b3 100644 --- a/.env.production +++ b/.env.production @@ -10,8 +10,8 @@ VITE_APP_CONTEXT_PATH = '/' # 监控地址 VITE_APP_MONITRO_ADMIN = '/admin/applications' -# 监控地址 -VITE_APP_XXL_JOB_ADMIN = '/xxl-job-admin' +# powerjob 控制台地址 +VITE_APP_POWERJOB_ADMIN = '/powerjob' # 生产环境 VITE_APP_BASE_API = '/prod-api' diff --git a/.gitignore b/.gitignore index 79e7fd9..40df474 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +.history node_modules/ dist/ npm-debug.log* diff --git a/src/api/login.ts b/src/api/login.ts index b95a0c0..d4ceb49 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -2,6 +2,7 @@ import request from '@/utils/request'; import { AxiosPromise } from 'axios'; import { LoginData, LoginResult, VerifyCodeResult, TenantInfo } from './types'; import { UserInfo } from '@/api/system/user/types'; +import { da } from 'element-plus/es/locale'; /** * @param data {LoginData} @@ -9,11 +10,9 @@ import { UserInfo } from '@/api/system/user/types'; */ export function login(data: LoginData): AxiosPromise { const params = { - tenantId: data.tenantId, - username: data.username.trim(), - password: data.password, - code: data.code, - uuid: data.uuid + ...data, + clientId: data.clientId || 'e5cd7e4891bf95d1d19206ce24a7b32e', + grantType: data.grantType || 'password' }; return request({ url: '/auth/login', @@ -60,6 +59,22 @@ export function getCodeImg(): AxiosPromise { timeout: 20000 }); } +/** + * 第三方登录 + * @param source 第三方登录类型 + * */ +export function callback(data: LoginData): AxiosPromise { + const LoginData = { + ...data, + clientId: 'e5cd7e4891bf95d1d19206ce24a7b32e', + grantType: 'social' + }; + return request({ + url: '/auth/social/callback', + method: 'post', + data: LoginData + }); +} // 获取用户详细信息 export function getInfo(): AxiosPromise { diff --git a/src/api/system/client/index.ts b/src/api/system/client/index.ts new file mode 100644 index 0000000..06544da --- /dev/null +++ b/src/api/system/client/index.ts @@ -0,0 +1,80 @@ +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { ClientVO, ClientForm, ClientQuery } from '@/api/system/client/types'; + +/** + * 查询客户端管理列表 + * @param query + * @returns {*} + */ + +export const listClient = (query?: ClientQuery): AxiosPromise => { + return request({ + url: '/system/client/list', + method: 'get', + params: query + }); +}; + +/** + * 查询客户端管理详细 + * @param id + */ +export const getClient = (id: string | number): AxiosPromise => { + return request({ + url: '/system/client/' + id, + method: 'get' + }); +}; + +/** + * 新增客户端管理 + * @param data + */ +export const addClient = (data: ClientForm) => { + return request({ + url: '/system/client', + method: 'post', + data: data + }); +}; + +/** + * 修改客户端管理 + * @param data + */ +export const updateClient = (data: ClientForm) => { + return request({ + url: '/system/client', + method: 'put', + data: data + }); +}; + +/** + * 删除客户端管理 + * @param id + */ +export const delClient = (id: string | number | Array) => { + return request({ + url: '/system/client/' + id, + method: 'delete' + }); +}; + +/** + * 状态修改 + * @param id ID + * @param status 状态 + */ +export function changeStatus(id: number | string, status: string) { + const data = { + id, + status + }; + return request({ + url: '/system/client/changeStatus', + method: 'put', + data: data + }); +} diff --git a/src/api/system/client/types.ts b/src/api/system/client/types.ts new file mode 100644 index 0000000..e67f95f --- /dev/null +++ b/src/api/system/client/types.ts @@ -0,0 +1,138 @@ +export interface ClientVO { + /** + * id + */ + id: string | number; + + /** + * 客户端id + */ + clientId: string | number; + + /** + * 客户端key + */ + clientKey: string; + + /** + * 客户端秘钥 + */ + clientSecret: string; + + /** + * 授权类型 + */ + grantTypeList: string[]; + + /** + * 设备类型 + */ + deviceType: string; + + /** + * token活跃超时时间 + */ + activeTimeout: number; + + /** + * token固定超时 + */ + timeout: number; + + /** + * 状态(0正常 1停用) + */ + status: string; + +} + +export interface ClientForm extends BaseEntity { + /** + * id + */ + id?: string | number; + + /** + * 客户端id + */ + clientId?: string | number; + + /** + * 客户端key + */ + clientKey?: string; + + /** + * 客户端秘钥 + */ + clientSecret?: string; + + /** + * 授权类型 + */ + grantTypeList?: string[]; + + /** + * 设备类型 + */ + deviceType?: string; + + /** + * token活跃超时时间 + */ + activeTimeout?: number; + + /** + * token固定超时 + */ + timeout?: number; + + /** + * 状态(0正常 1停用) + */ + status?: string; + +} + +export interface ClientQuery extends PageQuery { + /** + * 客户端id + */ + clientId?: string | number; + + /** + * 客户端key + */ + clientKey?: string; + + /** + * 客户端秘钥 + */ + clientSecret?: string; + + /** + * 授权类型 + */ + grantType?: string; + + /** + * 设备类型 + */ + deviceType?: string; + + /** + * token活跃超时时间 + */ + activeTimeout?: number; + + /** + * token固定超时 + */ + timeout?: number; + + /** + * 状态(0正常 1停用) + */ + status?: string; + +} diff --git a/src/api/system/social/auth.ts b/src/api/system/social/auth.ts new file mode 100644 index 0000000..17a46d3 --- /dev/null +++ b/src/api/system/social/auth.ts @@ -0,0 +1,24 @@ +import request from '@/utils/request'; + +// 绑定账号 +export function authBinding(source: string) { + return request({ + url: '/auth/binding/' + source, + method: 'get' + }); +} + +// 解绑账号 +export function authUnlock(authId: string) { + return request({ + url: '/auth/unlock/' + authId, + method: 'delete' + }); +} +//获取授权列表 +export function getAuthList() { + return request({ + url: '/system/social/list', + method: 'get' + }); +} diff --git a/src/api/types.ts b/src/api/types.ts index 68fb427..e02e645 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -15,19 +15,24 @@ export type RegisterForm = { * 登录请求 */ export interface LoginData { - tenantId: string; - username: string; - password: string; + tenantId?: string; + username?: string; + password?: string; rememberMe?: boolean; + socialCode?: string, + socialState?: string, + source?: string, code?: string; uuid?: string; + clientId: string; + grantType: string; } /** * 登录响应 */ export interface LoginResult { - token: string; + access_token: string; } /** diff --git a/src/assets/icons/svg/gitee.svg b/src/assets/icons/svg/gitee.svg new file mode 100644 index 0000000..6324608 --- /dev/null +++ b/src/assets/icons/svg/gitee.svg @@ -0,0 +1 @@ + diff --git a/src/layout/components/SocialLogin/index.vue b/src/layout/components/SocialLogin/index.vue new file mode 100644 index 0000000..7656673 --- /dev/null +++ b/src/layout/components/SocialLogin/index.vue @@ -0,0 +1,82 @@ + + + diff --git a/src/permission.ts b/src/permission.ts index 4713383..c2743eb 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -10,7 +10,7 @@ import useSettingsStore from '@/store/modules/settings'; import usePermissionStore from '@/store/modules/permission'; NProgress.configure({ showSpinner: false }); -const whiteList = ['/login', '/register']; +const whiteList = ['/login', '/register', '/social-login']; router.beforeEach(async (to, from, next) => { NProgress.start(); diff --git a/src/router/index.ts b/src/router/index.ts index 9540ab2..dfd0547 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -37,6 +37,11 @@ export const constantRoutes: RouteOption[] = [ } ] }, + { + path: '/social-login', + hidden: true, + component: () => import('@/layout/components/SocialLogin/index.vue') + }, { path: '/login', component: () => import('@/views/login.vue'), @@ -176,4 +181,5 @@ const router = createRouter({ } }); + export default router; diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 6f30437..2593d1a 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -23,8 +23,8 @@ export const useUserStore = defineStore('user', () => { const [err, res] = await to(loginApi(userInfo)); if (res) { const data = res.data; - setToken(data.token); - token.value = data.token; + setToken(data.access_token); + token.value = data.access_token; return Promise.resolve(); } return Promise.reject(err); diff --git a/src/types/env.d.ts b/src/types/env.d.ts index 7e5134a..032f52b 100644 --- a/src/types/env.d.ts +++ b/src/types/env.d.ts @@ -65,7 +65,7 @@ interface ImportMetaEnv { VITE_APP_BASE_URL: string; VITE_APP_CONTEXT_PATH: string; VITE_APP_MONITRO_ADMIN: string; - VITE_APP_XXL_JOB_ADMIN: string; + VITE_APP_POWERJOB_ADMIN: string; VITE_APP_ENV: string; } interface ImportMeta { diff --git a/src/utils/auth.ts b/src/utils/auth.ts index 4020003..db50ac9 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -4,6 +4,6 @@ const tokenStorage = useStorage(TokenKey, null); export const getToken = () => tokenStorage.value; -export const setToken = (token: string) => (tokenStorage.value = token); +export const setToken = (access_token: string) => (tokenStorage.value = access_token); export const removeToken = () => (tokenStorage.value = null); diff --git a/src/views/index.vue b/src/views/index.vue index 70912af..4b3bebd 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -21,7 +21,7 @@ * 分布式锁 Lock4j 注解锁、工具锁 多种多样
* 分布式幂等 Lock4j 基于分布式锁实现
* 分布式链路追踪 SkyWalking 支持链路追踪、网格分析、度量聚合、可视化
- * 分布式任务调度 Xxl-Job 高性能 高可靠 易扩展
+ * 分布式任务调度 PowerJob 高性能 高可靠 易扩展
* 文件存储 Minio 本地存储
* 文件存储 七牛、阿里、腾讯 云存储
* 监控框架 SpringBoot-Admin 全方位服务监控
diff --git a/src/views/login.vue b/src/views/login.vue index 9559f9b..3234864 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -4,7 +4,8 @@

RuoYi-Vue-Plus多租户管理系统

- + @@ -14,12 +15,14 @@ - + - + +
+ + + + + + + + + + + + +