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