refactor: 【web-ant】重构认证模块并移除未使用的组件和功能【0fed9472】(剩余 request、present)
parent
e65469b5ea
commit
c881a47ffd
|
@ -20,6 +20,17 @@ setupVbenVxeTable({
|
|||
// 全局禁用vxe-table的表单配置,使用formOptions
|
||||
enabled: false,
|
||||
},
|
||||
toolbarConfig: {
|
||||
import: true,
|
||||
export: true,
|
||||
refresh: true,
|
||||
print: true,
|
||||
zoom: true,
|
||||
custom: true,
|
||||
},
|
||||
customConfig: {
|
||||
mode: 'modal',
|
||||
},
|
||||
proxyConfig: {
|
||||
autoLoad: true,
|
||||
response: {
|
||||
|
@ -29,6 +40,12 @@ setupVbenVxeTable({
|
|||
showActiveMsg: true,
|
||||
showResponseMsg: false,
|
||||
},
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
},
|
||||
sortConfig: {
|
||||
multiple: true,
|
||||
},
|
||||
round: true,
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
|
|
|
@ -64,21 +64,21 @@ export async function logoutApi() {
|
|||
}
|
||||
|
||||
/** 获取权限信息 */
|
||||
export function getAuthPermissionInfoApi() {
|
||||
export async function getAuthPermissionInfoApi() {
|
||||
return requestClient.get<AuthPermissionInfo>(
|
||||
'/system/auth/get-permission-info',
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取租户列表 */
|
||||
export function getTenantSimpleList() {
|
||||
export async function getTenantSimpleList() {
|
||||
return requestClient.get<AuthApi.TenantResult[]>(
|
||||
`/system/tenant/simple-list`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 使用租户域名,获得租户信息 */
|
||||
export function getTenantByWebsite(website: string) {
|
||||
export async function getTenantByWebsite(website: string) {
|
||||
return requestClient.get<AuthApi.TenantResult>(`/system/tenant/get-by-website?website=${website}`);
|
||||
}
|
||||
|
||||
|
|
|
@ -125,10 +125,11 @@ watch(
|
|||
<template>
|
||||
<BasicLayout @clear-preferences-and-logout="handleLogout">
|
||||
<template #user-dropdown>
|
||||
<!-- TODO @芋艿:去掉 ann.vben@gmail.com -->
|
||||
<UserDropdown
|
||||
:avatar
|
||||
:menus
|
||||
:text="userStore.userInfo?.realName"
|
||||
:text="userStore.userInfo?.nickname"
|
||||
description="ann.vben@gmail.com"
|
||||
tag-text="Pro"
|
||||
@logout="handleLogout"
|
||||
|
|
|
@ -57,9 +57,9 @@ export const useAuthStore = defineStore('auth', () => {
|
|||
: await router.push(userInfo.homePath || DEFAULT_HOME_PATH);
|
||||
}
|
||||
|
||||
if (userInfo?.realName) {
|
||||
if (userInfo?.nickname) {
|
||||
notification.success({
|
||||
description: `${$t('authentication.loginSuccessDesc')}:${userInfo?.realName}`,
|
||||
description: `${$t('authentication.loginSuccessDesc')}:${userInfo?.nickname}`,
|
||||
duration: 3,
|
||||
message: $t('authentication.loginSuccess'),
|
||||
});
|
||||
|
@ -99,7 +99,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||
let authPermissionInfo: AuthPermissionInfo | null = null;
|
||||
authPermissionInfo = await getAuthPermissionInfoApi();
|
||||
// userStore
|
||||
userStore.setUserInfo(authPermissionInfo.user);
|
||||
userStore.setUserInfo(authPermissionInfo.user); // TODO @芋艿:这里有报错
|
||||
userStore.setUserRoles(authPermissionInfo.roles);
|
||||
// accessStore
|
||||
accessStore.setAccessMenus(authPermissionInfo.menus);
|
||||
|
|
|
@ -15,7 +15,7 @@ interface BasicUserInfo {
|
|||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
realName: string;
|
||||
nickname: string;
|
||||
/**
|
||||
* 用户角色
|
||||
*/
|
||||
|
|
|
@ -18,9 +18,10 @@ export function useAppConfig(
|
|||
const { VITE_APP_CAPTCHA_ENABLE, VITE_APP_TENANT_ENABLE, VITE_GLOB_API_URL } =
|
||||
config;
|
||||
|
||||
// TODO @芋艿:貌似 VITE_APP_CAPTCHA_ENABLE 读取的是字符串,所以这里暂时这么转换
|
||||
return {
|
||||
apiURL: VITE_GLOB_API_URL,
|
||||
captchaEnable: VITE_APP_CAPTCHA_ENABLE,
|
||||
tenantEnable: VITE_APP_TENANT_ENABLE,
|
||||
captchaEnable: VITE_APP_CAPTCHA_ENABLE === 'true',
|
||||
tenantEnable: VITE_APP_TENANT_ENABLE === 'true',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -22,9 +22,11 @@
|
|||
"dependencies": {
|
||||
"@vben/locales": "workspace:*",
|
||||
"@vben/utils": "workspace:*",
|
||||
"axios": "catalog:"
|
||||
"axios": "catalog:",
|
||||
"qs": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios-mock-adapter": "catalog:"
|
||||
"axios-mock-adapter": "catalog:",
|
||||
"@types/qs": "catalog:"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import type { RequestClientConfig, RequestClientOptions } from './types';
|
|||
import { bindMethods, merge } from '@vben/utils';
|
||||
|
||||
import axios from 'axios';
|
||||
import qs from 'qs';
|
||||
|
||||
import { FileDownloader } from './modules/downloader';
|
||||
import { InterceptorManager } from './modules/interceptor';
|
||||
|
@ -36,6 +37,10 @@ class RequestClient {
|
|||
responseReturn: 'raw',
|
||||
// 默认超时时间
|
||||
timeout: 10_000,
|
||||
// 处理请求参数 默认使用 qs 库处理
|
||||
paramsSerializer: (params) => {
|
||||
return qs.stringify(params, { arrayFormat: 'repeat' });
|
||||
},
|
||||
};
|
||||
const { ...axiosConfig } = options;
|
||||
const requestConfig = merge(axiosConfig, defaultConfig);
|
||||
|
|
|
@ -52,12 +52,25 @@ interface HttpResponse<T = any> {
|
|||
*/
|
||||
code: number;
|
||||
data: T;
|
||||
message: string;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
interface PageParam {
|
||||
[key: string]: any;
|
||||
pageNo: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
interface PageResult<T> {
|
||||
list: T[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export type {
|
||||
HttpResponse,
|
||||
MakeErrorMessageFn,
|
||||
PageParam,
|
||||
PageResult,
|
||||
RequestClientConfig,
|
||||
RequestClientOptions,
|
||||
RequestContentType,
|
||||
|
|
|
@ -55,6 +55,7 @@ export const useUserStore = defineStore('core-user', {
|
|||
userInfo: null,
|
||||
userRoles: [],
|
||||
}),
|
||||
// TODO @芋艿:pick: ['userInfo', 'userRoles'], 是否要持久化
|
||||
});
|
||||
|
||||
// 解决热更新问题
|
||||
|
|
|
@ -111,6 +111,9 @@ catalogs:
|
|||
'@types/qrcode':
|
||||
specifier: ^1.5.5
|
||||
version: 1.5.5
|
||||
'@types/qs':
|
||||
specifier: ^6.9.17
|
||||
version: 6.9.18
|
||||
'@types/sortablejs':
|
||||
specifier: ^1.15.8
|
||||
version: 1.15.8
|
||||
|
@ -369,6 +372,9 @@ catalogs:
|
|||
qrcode:
|
||||
specifier: ^1.5.4
|
||||
version: 1.5.4
|
||||
qs:
|
||||
specifier: ^6.13.1
|
||||
version: 6.14.0
|
||||
radix-vue:
|
||||
specifier: ^1.9.17
|
||||
version: 1.9.17
|
||||
|
@ -1714,7 +1720,13 @@ importers:
|
|||
axios:
|
||||
specifier: 'catalog:'
|
||||
version: 1.8.2
|
||||
qs:
|
||||
specifier: 'catalog:'
|
||||
version: 6.14.0
|
||||
devDependencies:
|
||||
'@types/qs':
|
||||
specifier: 'catalog:'
|
||||
version: 6.9.18
|
||||
axios-mock-adapter:
|
||||
specifier: 'catalog:'
|
||||
version: 2.1.0(axios@1.8.2)
|
||||
|
@ -4331,6 +4343,9 @@ packages:
|
|||
'@types/qrcode@1.5.5':
|
||||
resolution: {integrity: sha512-CdfBi/e3Qk+3Z/fXYShipBT13OJ2fDO2Q2w5CIP5anLTLIndQG9z6P1cnm+8zCWSpm5dnxMFd/uREtb0EXuQzg==}
|
||||
|
||||
'@types/qs@6.9.18':
|
||||
resolution: {integrity: sha512-kK7dgTYDyGqS+e2Q4aK9X3D7q234CIZ1Bv0q/7Z5IwRDoADNU81xXJK/YVyLbLTZCoIwUoDoffFeF+p/eIklAA==}
|
||||
|
||||
'@types/readdir-glob@1.1.5':
|
||||
resolution: {integrity: sha512-raiuEPUYqXu+nvtY2Pe8s8FEmZ3x5yAH4VkLdihcPdalvsHltomrRC9BzuStrJ9yk06470hS0Crw0f1pXqD+Hg==}
|
||||
|
||||
|
@ -8650,6 +8665,10 @@ packages:
|
|||
engines: {node: '>=10.13.0'}
|
||||
hasBin: true
|
||||
|
||||
qs@6.14.0:
|
||||
resolution: {integrity: sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==}
|
||||
engines: {node: '>=0.6'}
|
||||
|
||||
quansync@0.2.8:
|
||||
resolution: {integrity: sha512-4+saucphJMazjt7iOM27mbFCk+D9dd/zmgMDCzRZ8MEoBfYp7lAvoN38et/phRQF6wOPMy/OROBGgoWeSKyluA==}
|
||||
|
||||
|
@ -13160,6 +13179,8 @@ snapshots:
|
|||
dependencies:
|
||||
'@types/node': 22.13.10
|
||||
|
||||
'@types/qs@6.9.18': {}
|
||||
|
||||
'@types/readdir-glob@1.1.5':
|
||||
dependencies:
|
||||
'@types/node': 22.13.10
|
||||
|
@ -17949,6 +17970,10 @@ snapshots:
|
|||
pngjs: 5.0.0
|
||||
yargs: 15.4.1
|
||||
|
||||
qs@6.14.0:
|
||||
dependencies:
|
||||
side-channel: 1.1.0
|
||||
|
||||
quansync@0.2.8: {}
|
||||
|
||||
queue-microtask@1.2.3: {}
|
||||
|
|
|
@ -49,6 +49,7 @@ catalog:
|
|||
'@types/nprogress': ^0.2.3
|
||||
'@types/postcss-import': ^14.0.3
|
||||
'@types/qrcode': ^1.5.5
|
||||
'@types/qs': ^6.9.17
|
||||
'@types/sortablejs': ^1.15.8
|
||||
'@types/crypto-js': ^4.2.2
|
||||
'@typescript-eslint/eslint-plugin': ^8.26.0
|
||||
|
@ -139,6 +140,7 @@ catalog:
|
|||
prettier-plugin-tailwindcss: ^0.6.11
|
||||
publint: ^0.2.12
|
||||
qrcode: ^1.5.4
|
||||
qs: ^6.13.1
|
||||
radix-vue: ^1.9.17
|
||||
resolve.exports: ^2.0.3
|
||||
rimraf: ^6.0.1
|
||||
|
|
Loading…
Reference in New Issue