Commit ecfb702b09e296efd5bf095d65840147d47b7923
1 parent
21e0548e
fix: type error
Showing
37 changed files
with
83 additions
and
73 deletions
build/script/preserve.ts
... | ... | @@ -25,7 +25,7 @@ export async function runPreserve() { |
25 | 25 | process.exit(1); |
26 | 26 | } |
27 | 27 | |
28 | - fs.mkdirp(resolve('build/.cache')); | |
28 | + await fs.mkdirp(resolve('build/.cache')); | |
29 | 29 | function checkPkgUpdate() { |
30 | 30 | const pkg = require('../../package.json'); |
31 | 31 | const { dependencies, devDependencies } = pkg; | ... | ... |
build/vite/plugin/dynamicImport/index.ts
... | ... | @@ -33,7 +33,7 @@ const dynamicImportTransform = function (env: any = {}): Transform { |
33 | 33 | try { |
34 | 34 | const files = glob.sync('src/views/**/**.{vue,tsx}', { cwd: process.cwd() }); |
35 | 35 | |
36 | - const _code = ` | |
36 | + return ` | |
37 | 37 | export default function (id) { |
38 | 38 | switch (id) { |
39 | 39 | ${files |
... | ... | @@ -47,7 +47,6 @@ const dynamicImportTransform = function (env: any = {}): Transform { |
47 | 47 | } |
48 | 48 | }\n\n |
49 | 49 | `; |
50 | - return _code; | |
51 | 50 | } catch (error) { |
52 | 51 | console.error(error); |
53 | 52 | return code; | ... | ... |
src/App.vue
src/components/ContextMenu/index.ts
... | ... | @@ -3,10 +3,10 @@ import { isClient } from '/@/utils/is'; |
3 | 3 | import { Options, Props } from './src/types'; |
4 | 4 | import { createVNode, render } from 'vue'; |
5 | 5 | const menuManager: { |
6 | - doms: Element[]; | |
6 | + domList: Element[]; | |
7 | 7 | resolve: Fn; |
8 | 8 | } = { |
9 | - doms: [], | |
9 | + domList: [], | |
10 | 10 | resolve: () => {}, |
11 | 11 | }; |
12 | 12 | export const createContextMenu = function (options: Options) { |
... | ... | @@ -32,9 +32,9 @@ export const createContextMenu = function (options: Options) { |
32 | 32 | const bodyClick = function () { |
33 | 33 | menuManager.resolve(''); |
34 | 34 | }; |
35 | - menuManager.doms.push(container); | |
35 | + menuManager.domList.push(container); | |
36 | 36 | const remove = function () { |
37 | - menuManager.doms.forEach((dom: Element) => { | |
37 | + menuManager.domList.forEach((dom: Element) => { | |
38 | 38 | try { |
39 | 39 | document.body.removeChild(dom); |
40 | 40 | } catch (error) {} |
... | ... | @@ -55,7 +55,7 @@ export const createContextMenu = function (options: Options) { |
55 | 55 | export const unMountedContextMenu = function () { |
56 | 56 | if (menuManager) { |
57 | 57 | menuManager.resolve(''); |
58 | - menuManager.doms = []; | |
58 | + menuManager.domList = []; | |
59 | 59 | } |
60 | 60 | }; |
61 | 61 | ... | ... |
src/components/Dropdown/Dropdown.tsx
src/components/Excel/src/ImportExcel.vue
src/components/Form/src/FormItem.tsx
... | ... | @@ -2,7 +2,7 @@ import type { PropType } from 'vue'; |
2 | 2 | import type { FormProps } from './types/form'; |
3 | 3 | import type { FormSchema } from './types/form'; |
4 | 4 | import type { ValidationRule } from 'ant-design-vue/lib/form/Form'; |
5 | -import type { TableActionType } from '../../Table/src/types/table'; | |
5 | +import type { TableActionType } from '/@/components/Table'; | |
6 | 6 | |
7 | 7 | import { defineComponent, computed, unref, toRef } from 'vue'; |
8 | 8 | import { Form, Col } from 'ant-design-vue'; |
... | ... | @@ -16,7 +16,7 @@ import { upperFirst, cloneDeep } from 'lodash-es'; |
16 | 16 | |
17 | 17 | import { useItemLabelWidth } from './hooks/useLabelWidth'; |
18 | 18 | import { ComponentType } from './types'; |
19 | -import { isNumber } from '../../../utils/is'; | |
19 | +import { isNumber } from '/@/utils/is'; | |
20 | 20 | |
21 | 21 | export default defineComponent({ |
22 | 22 | name: 'BasicFormItem', | ... | ... |
src/components/Form/src/props.ts
1 | 1 | import type { FieldMapToTime, FormSchema } from './types/form'; |
2 | 2 | import type { PropType } from 'vue'; |
3 | 3 | import type { ColEx } from './types'; |
4 | -import { TableActionType } from '../../Table/src/types/table'; | |
4 | +import { TableActionType } from '/@/components/Table'; | |
5 | 5 | |
6 | 6 | export const basicProps = { |
7 | 7 | model: { | ... | ... |
src/components/Menu/src/BasicMenu.tsx
... | ... | @@ -6,7 +6,7 @@ import { Menu } from 'ant-design-vue'; |
6 | 6 | import SearchInput from './SearchInput.vue'; |
7 | 7 | import MenuContent from './MenuContent'; |
8 | 8 | |
9 | -import { MenuModeEnum, MenuTypeEnum } from '/@/enums/menuEnum'; | |
9 | +import { MenuModeEnum, MenuThemeEnum, MenuTypeEnum } from '/@/enums/menuEnum'; | |
10 | 10 | |
11 | 11 | import { menuStore } from '/@/store/modules/menu'; |
12 | 12 | import { appStore } from '/@/store/modules/app'; |
... | ... | @@ -255,7 +255,7 @@ export default defineComponent({ |
255 | 255 | {getSlot(slots, 'header')} |
256 | 256 | <SearchInput |
257 | 257 | class={!props.search ? 'hidden' : ''} |
258 | - theme={props.theme} | |
258 | + theme={props.theme as MenuThemeEnum} | |
259 | 259 | onChange={handleInputChange} |
260 | 260 | onClick={handleInputClick} |
261 | 261 | collapsed={getCollapsedState} | ... | ... |
src/components/Scrollbar/src/util.ts
src/components/Table/src/components/TableAction.tsx
... | ... | @@ -2,7 +2,7 @@ import { defineComponent, PropType } from 'vue'; |
2 | 2 | import { Dropdown, Menu, Popconfirm } from 'ant-design-vue'; |
3 | 3 | import Icon from '/@/components/Icon/index'; |
4 | 4 | import { DownOutlined } from '@ant-design/icons-vue'; |
5 | -import { ActionItem } from '../types/tableAction'; | |
5 | +import { ActionItem } from '/@/components/Table'; | |
6 | 6 | import Button from '/@/components/Button/index.vue'; |
7 | 7 | const prefixCls = 'basic-table-action'; |
8 | 8 | export default defineComponent({ |
... | ... | @@ -26,7 +26,14 @@ export default defineComponent({ |
26 | 26 | function renderButton(action: ActionItem, index: number) { |
27 | 27 | const { disabled = false, label, icon, color = '', type = 'link' } = action; |
28 | 28 | const button = ( |
29 | - <Button type={type} size="small" disabled={disabled} color={color} {...action} key={index}> | |
29 | + <Button | |
30 | + type={type as any} | |
31 | + size="small" | |
32 | + disabled={disabled} | |
33 | + color={color} | |
34 | + {...action} | |
35 | + key={index} | |
36 | + > | |
30 | 37 | {() => ( |
31 | 38 | <> |
32 | 39 | {label} | ... | ... |
src/components/Table/src/const.ts
... | ... | @@ -22,7 +22,7 @@ export const FETCH_SETTING = { |
22 | 22 | }; |
23 | 23 | |
24 | 24 | // 配置通用排序函数 |
25 | -export function DEFAULT_SORT_FN(sortInfo: SorterResult<any>) { | |
25 | +export function DEFAULT_SORT_FN(sortInfo: SorterResult) { | |
26 | 26 | const { field, order } = sortInfo; |
27 | 27 | return { |
28 | 28 | // 传给后台的排序字段你 | ... | ... |
src/components/Table/src/props.ts
... | ... | @@ -8,7 +8,7 @@ import type { |
8 | 8 | TableCustomRecord, |
9 | 9 | TableRowSelection, |
10 | 10 | } from './types/table'; |
11 | -import type { FormProps } from '/@/components/Form/index'; | |
11 | +import type { FormProps } from '/@/components/Form'; | |
12 | 12 | import { DEFAULT_SORT_FN, FETCH_SETTING } from './const'; |
13 | 13 | |
14 | 14 | // 注释看 types/table | ... | ... |
src/components/Table/src/types/table.ts
1 | 1 | import type { VNodeChild } from 'vue'; |
2 | 2 | import type { PaginationProps } from './pagination'; |
3 | -import type { FormProps } from '/@/components/Form/index'; | |
3 | +import type { FormProps } from '/@/components/Form'; | |
4 | 4 | import type { |
5 | 5 | ColumnProps, |
6 | 6 | TableRowSelection as ITableRowSelection, |
... | ... | @@ -125,7 +125,7 @@ export interface TableSetting { |
125 | 125 | |
126 | 126 | export interface BasicTableProps<T = any> { |
127 | 127 | // 自定义排序方法 |
128 | - sortFn?: (sortInfo: SorterResult<any>) => any; | |
128 | + sortFn?: (sortInfo: SorterResult) => any; | |
129 | 129 | // 显示表格设置 |
130 | 130 | showTableSetting?: boolean; |
131 | 131 | tableSetting?: TableSetting; | ... | ... |
src/hooks/event/useEvent.ts
src/hooks/event/useWindowSize.ts
src/hooks/web/useLocalStorage.ts
src/hooks/web/useMessage.tsx
1 | 1 | import type { ModalFunc, ModalFuncProps } from 'ant-design-vue/lib/modal/Modal'; |
2 | -import type { MessageApi } from 'ant-design-vue/lib/message/index'; | |
2 | +import type { MessageApi } from 'ant-design-vue/lib/message'; | |
3 | 3 | import type { VNodeTypes, CSSProperties } from 'vue'; |
4 | 4 | |
5 | 5 | import { Modal, message as Message, notification } from 'ant-design-vue'; | ... | ... |
src/hooks/web/usePermission.ts
src/hooks/web/useSessionStorage.ts
src/layouts/default/header/LayoutHeader.tsx
... | ... | @@ -21,7 +21,7 @@ import { useFullscreen } from '/@/hooks/web/useFullScreen'; |
21 | 21 | import { useTabs } from '/@/hooks/web/useTabs'; |
22 | 22 | import { useWindowSizeFn } from '/@/hooks/event/useWindowSize'; |
23 | 23 | import { useRouter } from 'vue-router'; |
24 | -import { useModal } from '/@/components/Modal/index'; | |
24 | +import { useModal } from '/@/components/Modal'; | |
25 | 25 | |
26 | 26 | import { appStore } from '/@/store/modules/app'; |
27 | 27 | import { errorStore } from '/@/store/modules/error'; | ... | ... |
src/layouts/default/header/LockActionItem.tsx
src/main.ts
... | ... | @@ -3,8 +3,8 @@ import { createApp } from 'vue'; |
3 | 3 | import router, { setupRouter } from '/@/router'; |
4 | 4 | import { setupStore } from '/@/store'; |
5 | 5 | import { setupAntd } from '/@/setup/ant-design-vue'; |
6 | -import { setupErrorHandle } from '/@/setup/error-handle/index'; | |
7 | -import { setupDirectives } from '/@/setup/directives/index'; | |
6 | +import { setupErrorHandle } from '/@/setup/error-handle'; | |
7 | +import { setupDirectives } from '/@/setup/directives'; | |
8 | 8 | |
9 | 9 | import { isDevMode, isProdMode, isUseMock } from '/@/utils/env'; |
10 | 10 | import { setupProdMockServer } from '../mock/_createProductionServer'; | ... | ... |
src/router/menus/index.ts
... | ... | @@ -91,9 +91,7 @@ function basicFilter(routes: RouteRecordNormalized[]) { |
91 | 91 | if (route.meta.carryParam) { |
92 | 92 | return pathToRegexp(route.path).test(menu.path); |
93 | 93 | } |
94 | - if (route.meta.ignoreAuth) { | |
95 | - return false; | |
96 | - } | |
94 | + if (route.meta.ignoreAuth) return false; | |
97 | 95 | } |
98 | 96 | return route.path === menu.path; |
99 | 97 | }); | ... | ... |
src/router/types.d.ts
... | ... | @@ -73,9 +73,11 @@ export interface MenuModule { |
73 | 73 | menu: Menu; |
74 | 74 | } |
75 | 75 | |
76 | -export interface AppRouteModule { | |
77 | - layout?: AppRouteRecordRaw; | |
78 | - routes?: AppRouteRecordRaw[]; | |
76 | +interface RouteModule { | |
77 | + layout: AppRouteRecordRaw; | |
78 | + routes: AppRouteRecordRaw[]; | |
79 | 79 | children?: AppRouteRecordRaw[]; |
80 | 80 | component?: any; |
81 | 81 | } |
82 | + | |
83 | +export type AppRouteModule = RouteModule | AppRouteRecordRaw; | ... | ... |
src/setup/directives/permission.ts
src/store/modules/permission.ts
... | ... | @@ -10,7 +10,7 @@ import { PermissionModeEnum } from '/@/enums/appEnum'; |
10 | 10 | import { appStore } from '/@/store/modules/app'; |
11 | 11 | import { userStore } from '/@/store/modules/user'; |
12 | 12 | |
13 | -import { asyncRoutes } from '/@/router/routes/index'; | |
13 | +import { asyncRoutes } from '/@/router/routes'; | |
14 | 14 | import { filter } from '/@/utils/helper/treeHelper'; |
15 | 15 | import { toRaw } from 'vue'; |
16 | 16 | import { getMenuListById } from '/@/api/sys/menu'; | ... | ... |
src/useApp.ts
... | ... | @@ -93,10 +93,11 @@ export function useListenerNetWork() { |
93 | 93 | // Check network status |
94 | 94 | useNetWork({ |
95 | 95 | onLineFn: () => { |
96 | - replace(PageEnum.BASE_HOME); | |
97 | - useTimeout(() => { | |
98 | - appStore.commitPageLoadingState(false); | |
99 | - }, 300); | |
96 | + replace(PageEnum.BASE_HOME).then(() => { | |
97 | + useTimeout(() => { | |
98 | + appStore.commitPageLoadingState(false); | |
99 | + }, 200); | |
100 | + }); | |
100 | 101 | }, |
101 | 102 | offLineFn: () => { |
102 | 103 | replace({ | ... | ... |
src/utils/color.ts
... | ... | @@ -14,10 +14,10 @@ export const isHexColor = function (color: string) { |
14 | 14 | * RGB 颜色值转换为 十六进制颜色值. |
15 | 15 | * r, g, 和 b 需要在 [0, 255] 范围内 |
16 | 16 | * |
17 | - * @param Number r 红色色值 | |
18 | - * @param Number g 绿色色值 | |
19 | - * @param Number b 蓝色色值 | |
20 | 17 | * @return String 类似#ff00ff |
18 | + * @param r | |
19 | + * @param g | |
20 | + * @param b | |
21 | 21 | */ |
22 | 22 | export const rgbToHex = function (r: number, g: number, b: number) { |
23 | 23 | // tslint:disable-next-line:no-bitwise | ... | ... |
src/utils/env.ts
... | ... | @@ -17,7 +17,6 @@ export const prodMode = 'production'; |
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @description: 获取环境变量 |
20 | - * @param {type} | |
21 | 20 | * @returns: |
22 | 21 | * @example: |
23 | 22 | */ |
... | ... | @@ -25,7 +24,6 @@ export const getEnv = (): string => import.meta.env.MODE; |
25 | 24 | |
26 | 25 | /** |
27 | 26 | * @description: 是否是开发模式 |
28 | - * @param {type} | |
29 | 27 | * @returns: |
30 | 28 | * @example: |
31 | 29 | */ |
... | ... | @@ -33,7 +31,6 @@ export const isDevMode = (): boolean => import.meta.env.DEV; |
33 | 31 | |
34 | 32 | /** |
35 | 33 | * @description: 是否是生产模式模式 |
36 | - * @param {type} | |
37 | 34 | * @returns: |
38 | 35 | * @example: |
39 | 36 | */ |
... | ... | @@ -41,7 +38,6 @@ export const isProdMode = (): boolean => import.meta.env.PROD; |
41 | 38 | |
42 | 39 | /** |
43 | 40 | * @description: 是否开启mock |
44 | - * @param {type} | |
45 | 41 | * @returns: |
46 | 42 | * @example: |
47 | 43 | */ | ... | ... |
src/utils/helper/menuHelper.ts
1 | -import { AppRouteModule } from '/@/router/types.d'; | |
1 | +import { AppRouteModule, RouteModule } from '/@/router/types.d'; | |
2 | 2 | import type { MenuModule, Menu, AppRouteRecordRaw } from '/@/router/types'; |
3 | 3 | |
4 | 4 | import { findPath, forEach, treeMap, treeToList } from './treeHelper'; |
... | ... | @@ -48,7 +48,7 @@ export function transformRouteToMenu(routeModList: AppRouteModule[]) { |
48 | 48 | const cloneRouteModList = cloneDeep(routeModList); |
49 | 49 | const routeList: AppRouteRecordRaw[] = []; |
50 | 50 | cloneRouteModList.forEach((item) => { |
51 | - const { layout, routes, children } = item; | |
51 | + const { layout, routes, children } = item as RouteModule; | |
52 | 52 | if (layout) { |
53 | 53 | layout.children = routes || children; |
54 | 54 | routeList.push(layout); | ... | ... |
src/utils/helper/persistent.ts
src/utils/helper/routeHelper.ts
1 | -import type { AppRouteModule, AppRouteRecordRaw } from '/@/router/types'; | |
1 | +import type { AppRouteModule, AppRouteRecordRaw, RouteModule } from '/@/router/types'; | |
2 | 2 | import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router'; |
3 | +import { createRouter, createWebHashHistory } from 'vue-router'; | |
3 | 4 | |
4 | 5 | import { appStore } from '/@/store/modules/app'; |
5 | 6 | import { tabStore } from '/@/store/modules/tab'; |
6 | -import { createRouter, createWebHashHistory } from 'vue-router'; | |
7 | 7 | import { toRaw } from 'vue'; |
8 | 8 | import { PAGE_LAYOUT_COMPONENT } from '/@/router/constant'; |
9 | 9 | // import { isDevMode } from '/@/utils/env'; |
... | ... | @@ -21,17 +21,17 @@ export function setCurrentTo(to: RouteLocationNormalized) { |
21 | 21 | } |
22 | 22 | // 转化路由模块 |
23 | 23 | // 将多级转成2层。keepAlive问题 |
24 | -export function genRouteModule(moduleList: AppRouteModule[]) { | |
24 | +export function genRouteModule(moduleList: AppRouteModule[] | AppRouteRecordRaw[]) { | |
25 | 25 | const ret: AppRouteRecordRaw[] = []; |
26 | 26 | for (const routeMod of moduleList) { |
27 | - let routes = []; | |
27 | + let routes: RouteRecordRaw[] = []; | |
28 | 28 | let layout: AppRouteRecordRaw | undefined; |
29 | 29 | if (Reflect.has(routeMod, 'routes')) { |
30 | - routes = routeMod.routes as any; | |
31 | - layout = routeMod.layout; | |
30 | + routes = (routeMod as RouteModule).routes as any; | |
31 | + layout = (routeMod as RouteModule).layout; | |
32 | 32 | } else if (Reflect.has(routeMod, 'path')) { |
33 | 33 | layout = omit(routeMod, 'children') as any; |
34 | - routes = routeMod.children || []; | |
34 | + routes = (routeMod.children as RouteRecordRaw[]) || ([] as RouteRecordRaw[]); | |
35 | 35 | } |
36 | 36 | |
37 | 37 | const router = createRouter({ routes, history: createWebHashHistory() }); |
... | ... | @@ -66,20 +66,26 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) { |
66 | 66 | }); |
67 | 67 | } |
68 | 68 | |
69 | +function getLayoutComp(comp: string) { | |
70 | + return comp === 'PAGE_LAYOUT' ? PAGE_LAYOUT_COMPONENT : ''; | |
71 | +} | |
72 | + | |
69 | 73 | // 将后台对象转成路由对象 |
70 | -export function transformObjToRoute(routeList: AppRouteModule[]) { | |
74 | +export function transformObjToRoute<T = any>(routeList: AppRouteModule[]): T[] { | |
71 | 75 | routeList.forEach((route) => { |
72 | - asyncImportRoute(Reflect.has(route, 'routes') ? route.routes : route.children || []); | |
73 | - if (route.layout) { | |
74 | - route.layout.component = | |
75 | - route.layout.component === 'PAGE_LAYOUT' ? PAGE_LAYOUT_COMPONENT : ''; | |
76 | + asyncImportRoute( | |
77 | + Reflect.has(route, 'routes') ? (route as RouteModule).routes : route.children || [] | |
78 | + ); | |
79 | + if ((route as RouteModule).layout) { | |
80 | + (route as RouteModule).layout.component = getLayoutComp( | |
81 | + (route as RouteModule).layout.component | |
82 | + ); | |
76 | 83 | } else { |
77 | - route.component = route.component === 'PAGE_LAYOUT' ? PAGE_LAYOUT_COMPONENT : ''; | |
78 | - const _layout = omit(route, 'children') as any; | |
79 | - route.layout = _layout; | |
84 | + route.component = getLayoutComp(route.component); | |
85 | + (route as RouteModule).layout = omit(route, 'children') as any; | |
80 | 86 | } |
81 | 87 | }); |
82 | - return routeList; | |
88 | + return (routeList as unknown) as T[]; | |
83 | 89 | } |
84 | 90 | |
85 | 91 | // | ... | ... |
src/utils/helper/tsxHelper.tsx
... | ... | @@ -20,6 +20,7 @@ export function getSlot(slots: Slots, slot = 'default', data?: any) { |
20 | 20 | /** |
21 | 21 | * extends slots |
22 | 22 | * @param slots |
23 | + * @param excludeKeys | |
23 | 24 | */ |
24 | 25 | export function extendSlots(slots: Slots, excludeKeys: string[] = []) { |
25 | 26 | const slotKeys = Object.keys(slots); | ... | ... |
src/utils/http/axios/Axios.ts
... | ... | @@ -17,7 +17,7 @@ export * from './axiosTransform'; |
17 | 17 | */ |
18 | 18 | export class VAxios { |
19 | 19 | private axiosInstance: AxiosInstance; |
20 | - private options: CreateAxiosOptions; | |
20 | + private readonly options: CreateAxiosOptions; | |
21 | 21 | |
22 | 22 | constructor(options: CreateAxiosOptions) { |
23 | 23 | this.options = options; | ... | ... |
src/utils/storage/Storage.ts
... | ... | @@ -92,7 +92,7 @@ export const createStorage = ({ prefixKey = '', storage = sessionStorage } = {}) |
92 | 92 | * 添加cookie |
93 | 93 | * @param name cookie名字 |
94 | 94 | * @param value cookie内容 |
95 | - * @param day 过期时间 | |
95 | + * @param expire | |
96 | 96 | * 如果过期时间未设置,默认管理浏览器自动删除 |
97 | 97 | * 例子: |
98 | 98 | * cookieData.set('name','value',) | ... | ... |
src/utils/uuid.ts
... | ... | @@ -10,7 +10,7 @@ export function buildUUID(): string { |
10 | 10 | } else if (i === 15) { |
11 | 11 | uuid += 4; |
12 | 12 | } else if (i === 20) { |
13 | - uuid += hexList[(Math.random() * 4) | (0 + 8)]; | |
13 | + uuid += hexList[(Math.random() * 4) | 8]; | |
14 | 14 | } else { |
15 | 15 | uuid += hexList[(Math.random() * 16) | 0]; |
16 | 16 | } | ... | ... |