style(projects): format code

This commit is contained in:
Soybean
2023-12-14 21:45:29 +08:00
parent a176dc443e
commit a748166399
127 changed files with 2472 additions and 3006 deletions

15
src/typings/api.d.ts vendored
View File

@ -1,11 +1,13 @@
/**
* namespace Api
* @description all backend api type
* Namespace Api
*
* All backend api type
*/
declare namespace Api {
/**
* namespace Auth
* @description backend api module: "auth"
* Namespace Auth
*
* Backend api module: "auth"
*/
namespace Auth {
interface LoginToken {
@ -21,8 +23,9 @@ declare namespace Api {
}
/**
* namespace Route
* @description backend api module: "route"
* Namespace Route
*
* Backend api module: "route"
*/
namespace Route {
type ElegantConstRoute = import('@elegant-router/types').ElegantConstRoute;

310
src/typings/app.d.ts vendored
View File

@ -1,16 +1,10 @@
/**
* the global namespace for the app
*/
/** The global namespace for the app */
declare namespace App {
/**
* theme namespace
*/
/** Theme namespace */
namespace Theme {
type ColorPaletteNumber = import('@sa/color-palette').ColorPaletteNumber;
/**
* theme token
*/
/** Theme token */
type ThemeToken = {
colors: ThemeTokenColor;
boxShadow: {
@ -20,148 +14,83 @@ declare namespace App {
};
};
/**
* theme setting
*/
/** Theme setting */
interface ThemeSetting {
/**
* theme scheme
*/
/** Theme scheme */
themeScheme: UnionKey.ThemeScheme;
/**
* theme color
*/
/** Theme color */
themeColor: string;
/**
* other color
*/
/** Other color */
otherColor: OtherColor;
/**
* whether info color is followed by the primary color
*/
/** Whether info color is followed by the primary color */
isInfoFollowPrimary: boolean;
/**
* layout
*/
/** Layout */
layout: {
/**
* layout mode
*/
/** Layout mode */
mode: UnionKey.ThemeLayoutMode;
/**
* scroll mode
*/
/** Scroll mode */
scrollMode: UnionKey.ThemeScrollMode;
};
/**
* page
*/
/** Page */
page: {
/**
* whether to show the page transition
*/
/** Whether to show the page transition */
animate: boolean;
/**
* page animate mode
*/
/** Page animate mode */
animateMode: UnionKey.ThemePageAnimateMode;
};
/**
* header
*/
/** Header */
header: {
/**
* header height
*/
/** Header height */
height: number;
/**
* header breadcrumb
*/
/** Header breadcrumb */
breadcrumb: {
/**
* whether to show the breadcrumb
*/
/** Whether to show the breadcrumb */
visible: boolean;
/**
* whether to show the breadcrumb icon
*/
/** Whether to show the breadcrumb icon */
showIcon: boolean;
};
};
/**
* tab
*/
/** Tab */
tab: {
/**
* whether to show the tab
*/
/** Whether to show the tab */
visible: boolean;
/**
* whether to cache the tab
* @description if cache, the tabs will get from the local storage when the page is refreshed
* Whether to cache the tab
*
* If cache, the tabs will get from the local storage when the page is refreshed
*/
cache: boolean;
/**
* tab height
*/
/** Tab height */
height: number;
/**
* tab mode
*/
/** Tab mode */
mode: UnionKey.ThemeTabMode;
};
/**
* fixed header and tab
*/
/** Fixed header and tab */
fixedHeaderAndTab: boolean;
/**
* sider
*/
/** Sider */
sider: {
/**
* inverted sider
*/
/** Inverted sider */
inverted: boolean;
/**
* sider width
*/
/** Sider width */
width: number;
/**
* collapsed sider width
*/
/** Collapsed sider width */
collapsedWidth: number;
/**
* sider width when the layout is 'vertical-mix' or 'horizontal-mix'
*/
/** Sider width when the layout is 'vertical-mix' or 'horizontal-mix' */
mixWidth: number;
/**
* collapsed sider width when the layout is 'vertical-mix' or 'horizontal-mix'
*/
/** Collapsed sider width when the layout is 'vertical-mix' or 'horizontal-mix' */
mixCollapsedWidth: number;
/**
* child menu width when the layout is 'vertical-mix' or 'horizontal-mix'
*/
/** Child menu width when the layout is 'vertical-mix' or 'horizontal-mix' */
mixChildMenuWidth: number;
};
/**
* footer
*/
/** Footer */
footer: {
/**
* whether to show the footer
*/
/** Whether to show the footer */
visible: boolean;
/**
* whether fixed the footer
*/
/** Whether fixed the footer */
fixed: boolean;
/**
* footer height
*/
/** Footer height */
height: number;
/**
* whether float the footer to the right when the layout is 'horizontal-mix'
*/
/** Whether float the footer to the right when the layout is 'horizontal-mix' */
right: boolean;
};
}
@ -195,9 +124,7 @@ declare namespace App {
}
}
/**
* global namespace
*/
/** Global namespace */
namespace Global {
type VNode = import('vue').VNode;
type RouteLocationNormalizedLoaded = import('vue-router').RouteLocationNormalizedLoaded;
@ -206,56 +133,35 @@ declare namespace App {
type RoutePath = import('@elegant-router/types').RoutePath;
type LastLevelRouteKey = import('@elegant-router/types').LastLevelRouteKey;
/**
* the global header props
*/
/** The global header props */
interface HeaderProps {
/**
* whether to show the logo
*/
/** Whether to show the logo */
showLogo?: boolean;
/**
* whether to show the menu toggler
*/
/** Whether to show the menu toggler */
showMenuToggler?: boolean;
/**
* whether to show the menu
*/
/** Whether to show the menu */
showMenu?: boolean;
}
/**
* the global menu
*/
/** The global menu */
interface Menu {
/**
* the menu key
* @description equal to the route key
* The menu key
*
* Equal to the route key
*/
key: string;
/**
* the menu label
*/
/** The menu label */
label: string;
/**
* the menu i18n key
*/
/** The menu i18n key */
i18nKey?: I18n.I18nKey;
/**
* the route key
*/
/** The route key */
routeKey: RouteKey;
/**
* the route path
*/
/** The route path */
routePath: RoutePath;
/**
* the menu icon
*/
/** The menu icon */
icon?: () => VNode;
/**
* the menu children
*/
/** The menu children */
children?: Menu[];
}
@ -263,75 +169,57 @@ declare namespace App {
options?: Breadcrumb[];
};
/**
* tab route
*/
/** Tab route */
type TabRoute = Pick<RouteLocationNormalizedLoaded, 'name' | 'path' | 'meta'> &
Partial<Pick<RouteLocationNormalizedLoaded, 'fullPath' | 'query'>>;
/**
* the global tab
*/
/** The global tab */
type Tab = {
/**
* the tab id
*/
/** The tab id */
id: string;
/**
* the tab label
*/
/** The tab label */
label: string;
/**
* the new tab label
* @description if set, the tab label will be replaced by this value
* The new tab label
*
* If set, the tab label will be replaced by this value
*/
newLabel?: string;
/**
* the tab route key
*/
/** The tab route key */
routeKey: LastLevelRouteKey;
/**
* the tab route path
*/
/** The tab route path */
routePath: RouteMap[LastLevelRouteKey];
/**
* the tab route full path
*/
/** The tab route full path */
fullPath: string;
/**
* the tab fixed index
*/
/** The tab fixed index */
fixedIndex?: number;
/**
* tab icon
* @description iconify icon
* Tab icon
*
* Iconify icon
*/
icon?: string;
/**
* tab local icon
* @description local icon
* Tab local icon
*
* Local icon
*/
localIcon?: string;
/**
* i18n key
*/
/** I18n key */
i18nKey?: I18n.I18nKey;
};
/**
* form rule
*/
/** Form rule */
type FormRule = import('naive-ui').FormItemRule;
/**
* the global dropdown key
*/
/** The global dropdown key */
type DropdownKey = 'closeCurrent' | 'closeOther' | 'closeLeft' | 'closeRight' | 'closeAll';
}
/**
* i18n namespace
* @description locales type
* I18n namespace
*
* Locales type
*/
namespace I18n {
type RouteKey = import('@elegant-router/types').RouteKey;
@ -514,54 +402,32 @@ declare namespace App {
}
}
/**
* service namespace
*/
/** Service namespace */
namespace Service {
/**
* the backend service env type
*/
/** The backend service env type */
type EnvType = 'dev' | 'test' | 'prod';
/**
* other baseURL key
*/
/** Other baseURL key */
type OtherBaseURLKey = 'demo';
/**
* the backend service config
*/
/** The backend service config */
interface ServiceConfig<T extends OtherBaseURLKey = OtherBaseURLKey> {
/**
* the backend service base url
*/
/** The backend service base url */
baseURL: string;
/**
* other backend service base url map
*/
/** Other backend service base url map */
otherBaseURL: Record<T, string>;
}
/**
* the backend service config map
*/
/** The backend service config map */
type ServiceConfigMap = Record<EnvType, ServiceConfig>;
/**
* the backend service response data
*/
/** The backend service response data */
type Response<T = unknown> = {
/**
* the backend service response code
*/
/** The backend service response code */
code: string;
/**
* the backend service response message
*/
/** The backend service response message */
message: string;
/**
* the backend service response data
*/
/** The backend service response data */
data: T;
};
}

View File

@ -1,25 +1,18 @@
/**
* the common type namespace
*/
/** The common type namespace */
declare namespace Common {
/**
* the strategic pattern
*/
/** The strategic pattern */
interface StrategicPattern {
/**
* the condition
*/
/** The condition */
condition: boolean;
/**
* if the condition is true, then call the action function
*/
/** If the condition is true, then call the action function */
callback: () => void;
}
/**
* the option type
* @property value: the option value
* @property label: the option label
* The option type
*
* @property value: The option value
* @property label: The option label
*/
type Option<K> = { value: K; label: string };

75
src/typings/env.d.ts vendored
View File

@ -1,74 +1,65 @@
/**
* namespace Env
* @description it is used to declare the type of the import.meta object
* Namespace Env
*
* It is used to declare the type of the import.meta object
*/
declare namespace Env {
/**
* the router history mode
*/
/** The router history mode */
type RouterHistoryMode = 'hash' | 'history' | 'memory';
/**
* interface for import.meta
*/
/** Interface for import.meta */
interface ImportMeta extends ImportMetaEnv {
/**
* the base url of the application
*/
/** The base url of the application */
readonly VITE_BASE_URL: string;
/**
* the title of the application
*/
/** The title of the application */
readonly VITE_APP_TITLE: string;
/**
* the description of the application
*/
/** The description of the application */
readonly VITE_APP_DESC: string;
/**
* the router history mode
*/
/** The router history mode */
readonly VITE_ROUTER_HISTORY_MODE?: RouterHistoryMode;
/**
* the prefix of the iconify icon
*/
/** The prefix of the iconify icon */
readonly VITE_ICON_PREFIX: 'icon';
/**
* the prefix of the local icon
* @description this prefix is start with the icon prefix
* The prefix of the local icon
*
* This prefix is start with the icon prefix
*/
readonly VITE_ICON_LOCAL_PREFIX: 'local-icon';
/**
* whether to enable the http proxy
* @description only valid in the development environment
* Whether to enable the http proxy
*
* Only valid in the development environment
*/
readonly VITE_HTTP_PROXY?: Common.YesOrNo;
/**
* the back service env
*/
/** The back service env */
readonly VITE_SERVICE_ENV?: App.Service.EnvType;
/**
* the auth route mode
* - static: the auth routes is generated in front-end
* - dynamic: the auth routes is generated in back-end
* The auth route mode
*
* - Static: the auth routes is generated in front-end
* - Dynamic: the auth routes is generated in back-end
*/
readonly VITE_AUTH_ROUTE_MODE: 'static' | 'dynamic';
/**
* the home route key
* @description it only has effect when the auth route mode is static, if the route mode is dynamic, the home route key is defined in the back-end
* The home route key
*
* It only has effect when the auth route mode is static, if the route mode is dynamic, the home route key is
* defined in the back-end
*/
readonly VITE_ROUTE_HOME: import('@elegant-router/types').LastLevelRouteKey;
/**
* default menu icon if menu icon is not set
* @description iconify icon name
* Default menu icon if menu icon is not set
*
* Iconify icon name
*/
readonly VITE_MENU_ICON: string;
/**
* whether to build with sourcemap
*/
/** Whether to build with sourcemap */
readonly VITE_SOURCE_MAP?: Common.YesOrNo;
/**
* iconify api provider url
* @description if the project is deployed in intranet, you can set the api provider url to the local iconify server
* Iconify api provider url
*
* If the project is deployed in intranet, you can set the api provider url to the local iconify server
*
* @link https://docs.iconify.design/api/providers.html
*/
readonly VITE_ICONIFY_URL?: string;

View File

@ -1,23 +1,13 @@
interface Window {
/**
* NProgress instance
*/
/** NProgress instance */
NProgress?: import('nprogress').NProgress;
/**
* loading bar instance
*/
/** Loading bar instance */
$loadingBar?: import('naive-ui').LoadingBarProviderInst;
/**
* dialog instance
*/
/** Dialog instance */
$dialog?: import('naive-ui').DialogProviderInst;
/**
* message instance
*/
/** Message instance */
$message?: import('naive-ui').MessageProviderInst;
/**
* notification instance
*/
/** Notification instance */
$notification?: import('naive-ui').NotificationProviderInst;
}
@ -33,7 +23,5 @@ interface ImportMeta {
readonly env: Env.ImportMeta;
}
/**
* build time of the project
*/
/** Build time of the project */
declare const BUILD_TIME: string;

View File

@ -3,64 +3,61 @@ import 'vue-router';
declare module 'vue-router' {
interface RouteMeta {
/**
* title of the route
* @description it can be used in document title
* Title of the route
*
* It can be used in document title
*/
title: string;
/**
* i18n key of the route
* @description it's used in i18n, if it is set, the title will be ignored
* I18n key of the route
*
* It's used in i18n, if it is set, the title will be ignored
*/
i18nKey?: App.I18n.I18nKey;
/**
* roles of the route
* @description route can be accessed if the current user has at least one of the roles
* Roles of the route
*
* Route can be accessed if the current user has at least one of the roles
*/
roles?: string[];
/**
* whether to cache the route
*/
/** Whether to cache the route */
keepAlive?: boolean;
/**
* is constant route
* @description does not need to login, and the route is defined in the front-end
* Is constant route
*
* Does not need to login, and the route is defined in the front-end
*/
constant?: boolean;
/**
* iconify icon
* @description it can be used in the menu or breadcrumb
* Iconify icon
*
* It can be used in the menu or breadcrumb
*/
icon?: string;
/**
* local icon
* @description in "src/assets/svg-icon", if it is set, the icon will be ignored
* Local icon
*
* In "src/assets/svg-icon", if it is set, the icon will be ignored
*/
localIcon?: string;
/**
* router order
*/
/** Router order */
order?: number;
/**
* the outer link of the route
*/
/** The outer link of the route */
href?: string;
/**
* whether to hide the route in the menu
*/
/** Whether to hide the route in the menu */
hideInMenu?: boolean;
/**
* the menu key will be activated when entering the route
* @description the route is not in the menu
* @example the route is "user_detail", if it is set to "user_list", the menu "user_list" will be activated
* The menu key will be activated when entering the route
*
* The route is not in the menu
*
* @example
* the route is "user_detail", if it is set to "user_list", the menu "user_list" will be activated
*/
activeMenu?: import('@elegant-router/types').LastLevelRouteKey;
/**
* by default, the same route path will use one tab, if set to true, it will use multiple tabs
*/
/** By default, the same route path will use one tab, if set to true, it will use multiple tabs */
multiTab?: boolean;
/**
* if set, the route will be fixed in tabs, and the value is the order of fixed tabs
*/
/** If set, the route will be fixed in tabs, and the value is the order of fixed tabs */
fixedIndexInTab?: number;
}
}

View File

@ -1,11 +1,7 @@
/**
* the storage namespace
*/
/** The storage namespace */
declare namespace StorageType {
interface Session {
/**
* the theme color
*/
/** The theme color */
themeColor: string;
// /**
// * the theme settings
@ -14,38 +10,25 @@ declare namespace StorageType {
}
interface Local {
/**
* the i18n language
*/
/** The i18n language */
lang: App.I18n.LangType;
/**
* the token
*/
/** The token */
token: string;
/**
* the refresh token
*/
/** The refresh token */
refreshToken: string;
/**
* the user info
*/
/** The user info */
userInfo: Api.Auth.UserInfo;
/**
* the theme color
*/
/** The theme color */
themeColor: string;
/**
* the theme settings
*/
/** The theme settings */
themeSettings: App.Theme.ThemeSetting;
/**
* the override theme flags
* @description the value is the build time of the project
* The override theme flags
*
* The value is the build time of the project
*/
overrideThemeFlag: string;
/**
* the global tabs
*/
/** The global tabs */
globalTabs: App.Global.Tab[];
}
}

View File

@ -1,53 +1,49 @@
/**
* the union key namespace
*/
/** The union key namespace */
declare namespace UnionKey {
/**
* the login module
* - pwd-login: password login
* - code-login: phone code login
* - register: register
* - reset-pwd: reset password
* - bind-wechat: bind wechat
* The login module
*
* - Pwd-login: password login
* - Code-login: phone code login
* - Register: register
* - Reset-pwd: reset password
* - Bind-wechat: bind wechat
*/
type LoginModule = 'pwd-login' | 'code-login' | 'register' | 'reset-pwd' | 'bind-wechat';
/**
* theme scheme
*/
/** Theme scheme */
type ThemeScheme = 'light' | 'dark' | 'auto';
/**
* the layout mode
* - vertical: the vertical menu in left
* - horizontal: the horizontal menu in top
* - vertical-mix: two vertical mixed menus in left
* - horizontal-mix: the vertical menu in left and horizontal menu in top
* The layout mode
*
* - Vertical: the vertical menu in left
* - Horizontal: the horizontal menu in top
* - Vertical-mix: two vertical mixed menus in left
* - Horizontal-mix: the vertical menu in left and horizontal menu in top
*/
type ThemeLayoutMode = 'vertical' | 'horizontal' | 'vertical-mix' | 'horizontal-mix';
/**
* the scroll mode when content overflow
* - wrapper the wrapper component's root element overflow
* - content the content component overflow
* The scroll mode when content overflow
*
* - Wrapper the wrapper component's root element overflow
* - Content the content component overflow
*/
type ThemeScrollMode = import('@sa/materials').LayoutScrollMode;
/**
* page animate mode
*/
/** Page animate mode */
type ThemePageAnimateMode = 'fade' | 'fade-slide' | 'fade-bottom' | 'fade-scale' | 'zoom-fade' | 'zoom-out' | 'none';
/**
* tab mode
* - chrome: chrome style
* - button: button style
* Tab mode
*
* - Chrome: chrome style
* - Button: button style
*/
type ThemeTabMode = import('@sa/materials').PageTabMode;
/**
* unocss animate key
*/
/** Unocss animate key */
type UnoCssAnimateKey =
| 'pulse'
| 'bounce'