refactor:基于 lint 处理排版(框架层面)

pull/80/head
YunaiV 2025-04-22 22:17:41 +08:00
parent fb785894b6
commit c0a92a5694
10 changed files with 59 additions and 39 deletions

View File

@ -7,7 +7,7 @@ body:
attributes:
value: |
感谢对项目的支持与关注。在提出问题之前,请确保你已查看相关开发或使用文档:
- http://vben-doc.x-surge.com/
- https://doc.iocoder.cn/
- type: checkboxes
attributes:
label: 这个问题是否已经存在?

View File

@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: 项目开发文档
url: http://vben-doc.x-surge.com/
url: https://doc.iocoder.cn/
about: 提供项目启动、开发的相关文档

View File

@ -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) => {

View File

@ -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页面

View File

@ -1,5 +1,7 @@
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,9 +44,14 @@ 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)
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

View File

@ -61,7 +61,7 @@ class RequestClient {
responseReturn: 'raw',
// 默认超时时间
timeout: 10_000,
paramsSerializer: 'repeat'
paramsSerializer: 'repeat',
};
const { ...axiosConfig } = options;
const requestConfig = merge(axiosConfig, defaultConfig);

View File

@ -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,
}),
});

View File

@ -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: [],
})
}),
});
// 解决热更新问题

View File

@ -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 };

View File

@ -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 };