refactor:基于 lint 处理排版(框架层面)
parent
fb785894b6
commit
c0a92a5694
|
@ -7,7 +7,7 @@ body:
|
|||
attributes:
|
||||
value: |
|
||||
感谢对项目的支持与关注。在提出问题之前,请确保你已查看相关开发或使用文档:
|
||||
- http://vben-doc.x-surge.com/
|
||||
- https://doc.iocoder.cn/
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: 这个问题是否已经存在?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 项目开发文档
|
||||
url: http://vben-doc.x-surge.com/
|
||||
url: https://doc.iocoder.cn/
|
||||
about: 提供项目启动、开发的相关文档
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import { h } from 'vue';
|
||||
|
||||
import { IconifyIcon } from '@vben/icons';
|
||||
|
@ -6,12 +8,11 @@ import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
|
|||
import { isFunction, isString } from '@vben/utils';
|
||||
|
||||
import { Button, Image, Popconfirm, Switch } from 'ant-design-vue';
|
||||
|
||||
import { DictTag } from '#/components/dict-tag';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useVbenForm } from './form';
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import { $t } from '#/locales';
|
||||
|
||||
setupVbenVxeTable({
|
||||
configVxeTable: (vxeUI) => {
|
||||
|
@ -162,10 +163,10 @@ setupVbenVxeTable({
|
|||
return presets[opt]
|
||||
? { code: opt, ...presets[opt], ...defaultProps }
|
||||
: {
|
||||
code: opt,
|
||||
text: $te(`common.${opt}`) ? $t(`common.${opt}`) : opt,
|
||||
...defaultProps,
|
||||
};
|
||||
code: opt,
|
||||
text: $te(`common.${opt}`) ? $t(`common.${opt}`) : opt,
|
||||
...defaultProps,
|
||||
};
|
||||
} else {
|
||||
return { ...defaultProps, ...presets[opt.code], ...opt };
|
||||
}
|
||||
|
@ -188,10 +189,10 @@ setupVbenVxeTable({
|
|||
icon: undefined,
|
||||
onClick: listen
|
||||
? () =>
|
||||
attrs?.onClick?.({
|
||||
code: opt.code,
|
||||
row,
|
||||
})
|
||||
attrs?.onClick?.({
|
||||
code: opt.code,
|
||||
row,
|
||||
})
|
||||
: undefined,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -5,11 +5,11 @@ import type {
|
|||
|
||||
import { generateAccessible } from '@vben/access';
|
||||
import { preferences } from '@vben/preferences';
|
||||
|
||||
import { BasicLayout, IFrameView } from '#/layouts';
|
||||
import { useAccessStore } from '@vben/stores';
|
||||
import { convertServerMenuToRouteRecordStringComponent } from '@vben/utils';
|
||||
|
||||
import { BasicLayout, IFrameView } from '#/layouts';
|
||||
|
||||
const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
|
||||
|
||||
async function generateAccess(options: GenerateMenuAndRoutesOptions) {
|
||||
|
@ -26,6 +26,7 @@ async function generateAccess(options: GenerateMenuAndRoutesOptions) {
|
|||
fetchMenuListAsync: async () => {
|
||||
// 由于 yudao 通过 accessStore 读取,所以不在进行 message.loading 提示
|
||||
const accessMenus = accessStore.accessMenus;
|
||||
// TODO @芋艿:爆红!!!
|
||||
return convertServerMenuToRouteRecordStringComponent(accessMenus);
|
||||
},
|
||||
// 可以指定没有权限跳转403页面
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import type { AuthPermissionInfo, Recordable, UserInfo} from '@vben/types';
|
||||
import type { AuthPermissionInfo, Recordable, UserInfo } from '@vben/types';
|
||||
|
||||
import type { AuthApi } from '#/api';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
@ -9,7 +11,14 @@ import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores';
|
|||
import { notification } from 'ant-design-vue';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
import { type AuthApi, getAuthPermissionInfoApi, loginApi, logoutApi, smsLogin, register, socialLogin } from '#/api';
|
||||
import {
|
||||
getAuthPermissionInfoApi,
|
||||
loginApi,
|
||||
logoutApi,
|
||||
register,
|
||||
smsLogin,
|
||||
socialLogin,
|
||||
} from '#/api';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
export const useAuthStore = defineStore('auth', () => {
|
||||
|
@ -27,7 +36,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||
* @param onSuccess 登录成功后的回调函数
|
||||
*/
|
||||
async function authLogin(
|
||||
type: 'mobile' | 'username' | 'register' | 'social',
|
||||
type: 'mobile' | 'register' | 'social' | 'username',
|
||||
params: Recordable<any>,
|
||||
onSuccess?: () => Promise<void> | void,
|
||||
) {
|
||||
|
@ -35,10 +44,15 @@ export const useAuthStore = defineStore('auth', () => {
|
|||
let userInfo: null | UserInfo = null;
|
||||
try {
|
||||
loginLoading.value = true;
|
||||
const { accessToken, refreshToken } = type === 'mobile' ? await smsLogin(params as AuthApi.SmsLoginParams)
|
||||
: type === 'register' ? await register(params as AuthApi.RegisterParams)
|
||||
: type === 'social' ? await socialLogin(params as AuthApi.SocialLoginParams)
|
||||
: await loginApi(params);
|
||||
const { accessToken, refreshToken } =
|
||||
type === 'mobile'
|
||||
? await smsLogin(params as AuthApi.SmsLoginParams)
|
||||
: type === 'register'
|
||||
? await register(params as AuthApi.RegisterParams)
|
||||
: // eslint-disable-next-line unicorn/no-nested-ternary
|
||||
type === 'social'
|
||||
? await socialLogin(params as AuthApi.SocialLoginParams)
|
||||
: await loginApi(params);
|
||||
|
||||
// 如果成功获取到 accessToken
|
||||
if (accessToken) {
|
||||
|
|
|
@ -61,7 +61,7 @@ class RequestClient {
|
|||
responseReturn: 'raw',
|
||||
// 默认超时时间
|
||||
timeout: 10_000,
|
||||
paramsSerializer: 'repeat'
|
||||
paramsSerializer: 'repeat',
|
||||
};
|
||||
const { ...axiosConfig } = options;
|
||||
const requestConfig = merge(axiosConfig, defaultConfig);
|
||||
|
|
|
@ -88,7 +88,7 @@ export const useAccessStore = defineStore('core-access', {
|
|||
},
|
||||
setTenantId(tenantId: null | number) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
// 持久化
|
||||
|
@ -102,7 +102,7 @@ export const useAccessStore = defineStore('core-access', {
|
|||
isAccessChecked: false,
|
||||
loginExpired: false,
|
||||
refreshToken: null,
|
||||
tenantId: null
|
||||
tenantId: null,
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@ interface BasicUserInfo {
|
|||
* 头像
|
||||
*/
|
||||
avatar: string;
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
email?: string;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
|
@ -18,10 +22,6 @@ interface BasicUserInfo {
|
|||
* 用户名
|
||||
*/
|
||||
username: string;
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
email?: string;
|
||||
}
|
||||
|
||||
interface AccessState {
|
||||
|
@ -50,7 +50,7 @@ export const useUserStore = defineStore('core-user', {
|
|||
state: (): AccessState => ({
|
||||
userInfo: null,
|
||||
userRoles: [],
|
||||
})
|
||||
}),
|
||||
});
|
||||
|
||||
// 解决热更新问题
|
||||
|
|
|
@ -2,22 +2,18 @@ import type { AppRouteRecordRaw, BasicUserInfo } from '@vben-core/typings';
|
|||
|
||||
/** 用户信息 */
|
||||
interface UserInfo extends BasicUserInfo {
|
||||
|
||||
/**
|
||||
* 首页地址
|
||||
*/
|
||||
homePath: string;
|
||||
|
||||
}
|
||||
|
||||
/** 权限信息 */
|
||||
interface AuthPermissionInfo {
|
||||
|
||||
user: UserInfo;
|
||||
roles: string[];
|
||||
permissions: string[];
|
||||
menus: AppRouteRecordRaw[];
|
||||
|
||||
}
|
||||
|
||||
export type { UserInfo, AuthPermissionInfo };
|
||||
export type { AuthPermissionInfo, UserInfo };
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
import type { Router, RouteRecordRaw } from 'vue-router';
|
||||
|
||||
import type { ExRouteRecordRaw, MenuRecordRaw, RouteRecordStringComponent, AppRouteRecordRaw } from '@vben-core/typings';
|
||||
import type {
|
||||
AppRouteRecordRaw,
|
||||
ExRouteRecordRaw,
|
||||
MenuRecordRaw,
|
||||
RouteRecordStringComponent,
|
||||
} from '@vben-core/typings';
|
||||
|
||||
import { filterTree, mapTree, isHttpUrl } from '@vben-core/shared/utils';
|
||||
import { filterTree, isHttpUrl, mapTree } from '@vben-core/shared/utils';
|
||||
|
||||
/**
|
||||
* 根据 routes 生成菜单列表
|
||||
|
@ -142,7 +147,10 @@ function convertServerMenuToRouteRecordStringComponent(
|
|||
};
|
||||
|
||||
if (menu.children && menu.children.length > 0) {
|
||||
buildMenu.children = convertServerMenuToRouteRecordStringComponent(menu.children, menu.path);
|
||||
buildMenu.children = convertServerMenuToRouteRecordStringComponent(
|
||||
menu.children,
|
||||
menu.path,
|
||||
);
|
||||
}
|
||||
|
||||
menus.push(buildMenu);
|
||||
|
@ -150,4 +158,4 @@ function convertServerMenuToRouteRecordStringComponent(
|
|||
return menus;
|
||||
}
|
||||
|
||||
export { generateMenus, convertServerMenuToRouteRecordStringComponent };
|
||||
export { convertServerMenuToRouteRecordStringComponent, generateMenus };
|
||||
|
|
Loading…
Reference in New Issue