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