提交 ecfb702b 编写于 作者: V vben

fix: type error

上级 21e0548e
...@@ -25,7 +25,7 @@ export async function runPreserve() { ...@@ -25,7 +25,7 @@ export async function runPreserve() {
process.exit(1); process.exit(1);
} }
fs.mkdirp(resolve('build/.cache')); await fs.mkdirp(resolve('build/.cache'));
function checkPkgUpdate() { function checkPkgUpdate() {
const pkg = require('../../package.json'); const pkg = require('../../package.json');
const { dependencies, devDependencies } = pkg; const { dependencies, devDependencies } = pkg;
......
...@@ -33,7 +33,7 @@ const dynamicImportTransform = function (env: any = {}): Transform { ...@@ -33,7 +33,7 @@ const dynamicImportTransform = function (env: any = {}): Transform {
try { try {
const files = glob.sync('src/views/**/**.{vue,tsx}', { cwd: process.cwd() }); const files = glob.sync('src/views/**/**.{vue,tsx}', { cwd: process.cwd() });
const _code = ` return `
export default function (id) { export default function (id) {
switch (id) { switch (id) {
${files ${files
...@@ -47,7 +47,6 @@ const dynamicImportTransform = function (env: any = {}): Transform { ...@@ -47,7 +47,6 @@ const dynamicImportTransform = function (env: any = {}): Transform {
} }
}\n\n }\n\n
`; `;
return _code;
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return code; return code;
......
<template> <template>
<ConfigProvider :locale="zhCN" :transformCellText="transformCellText" v-bind="lockOn"> <ConfigProvider :locale="zhCN" :transform-cell-text="transformCellText" v-bind="lockOn">
<router-view /> <router-view />
</ConfigProvider> </ConfigProvider>
</template> </template>
......
...@@ -3,10 +3,10 @@ import { isClient } from '/@/utils/is'; ...@@ -3,10 +3,10 @@ import { isClient } from '/@/utils/is';
import { Options, Props } from './src/types'; import { Options, Props } from './src/types';
import { createVNode, render } from 'vue'; import { createVNode, render } from 'vue';
const menuManager: { const menuManager: {
doms: Element[]; domList: Element[];
resolve: Fn; resolve: Fn;
} = { } = {
doms: [], domList: [],
resolve: () => {}, resolve: () => {},
}; };
export const createContextMenu = function (options: Options) { 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) {
const bodyClick = function () { const bodyClick = function () {
menuManager.resolve(''); menuManager.resolve('');
}; };
menuManager.doms.push(container); menuManager.domList.push(container);
const remove = function () { const remove = function () {
menuManager.doms.forEach((dom: Element) => { menuManager.domList.forEach((dom: Element) => {
try { try {
document.body.removeChild(dom); document.body.removeChild(dom);
} catch (error) {} } catch (error) {}
...@@ -55,7 +55,7 @@ export const createContextMenu = function (options: Options) { ...@@ -55,7 +55,7 @@ export const createContextMenu = function (options: Options) {
export const unMountedContextMenu = function () { export const unMountedContextMenu = function () {
if (menuManager) { if (menuManager) {
menuManager.resolve(''); menuManager.resolve('');
menuManager.doms = []; menuManager.domList = [];
} }
}; };
......
...@@ -34,6 +34,7 @@ export default defineComponent({ ...@@ -34,6 +34,7 @@ export default defineComponent({
</> </>
)} )}
</Menu.Item>, </Menu.Item>,
// @ts-ignore
divider && <Menu.Divider key={`d-${index}`} />, divider && <Menu.Divider key={`d-${index}`} />,
]; ];
})} })}
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
// fix can't select the same excel // fix can't select the same excel
inputRefDom.value = ''; inputRefDom.value = '';
} }
readerData(rawFile); await readerData(rawFile);
} }
/** /**
......
...@@ -2,7 +2,7 @@ import type { PropType } from 'vue'; ...@@ -2,7 +2,7 @@ import type { PropType } from 'vue';
import type { FormProps } from './types/form'; import type { FormProps } from './types/form';
import type { FormSchema } from './types/form'; import type { FormSchema } from './types/form';
import type { ValidationRule } from 'ant-design-vue/lib/form/Form'; import type { ValidationRule } from 'ant-design-vue/lib/form/Form';
import type { TableActionType } from '../../Table/src/types/table'; import type { TableActionType } from '/@/components/Table';
import { defineComponent, computed, unref, toRef } from 'vue'; import { defineComponent, computed, unref, toRef } from 'vue';
import { Form, Col } from 'ant-design-vue'; 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';
import { useItemLabelWidth } from './hooks/useLabelWidth'; import { useItemLabelWidth } from './hooks/useLabelWidth';
import { ComponentType } from './types'; import { ComponentType } from './types';
import { isNumber } from '../../../utils/is'; import { isNumber } from '/@/utils/is';
export default defineComponent({ export default defineComponent({
name: 'BasicFormItem', name: 'BasicFormItem',
......
import type { FieldMapToTime, FormSchema } from './types/form'; import type { FieldMapToTime, FormSchema } from './types/form';
import type { PropType } from 'vue'; import type { PropType } from 'vue';
import type { ColEx } from './types'; import type { ColEx } from './types';
import { TableActionType } from '../../Table/src/types/table'; import { TableActionType } from '/@/components/Table';
export const basicProps = { export const basicProps = {
model: { model: {
......
...@@ -6,7 +6,7 @@ import { Menu } from 'ant-design-vue'; ...@@ -6,7 +6,7 @@ import { Menu } from 'ant-design-vue';
import SearchInput from './SearchInput.vue'; import SearchInput from './SearchInput.vue';
import MenuContent from './MenuContent'; import MenuContent from './MenuContent';
import { MenuModeEnum, MenuTypeEnum } from '/@/enums/menuEnum'; import { MenuModeEnum, MenuThemeEnum, MenuTypeEnum } from '/@/enums/menuEnum';
import { menuStore } from '/@/store/modules/menu'; import { menuStore } from '/@/store/modules/menu';
import { appStore } from '/@/store/modules/app'; import { appStore } from '/@/store/modules/app';
...@@ -255,7 +255,7 @@ export default defineComponent({ ...@@ -255,7 +255,7 @@ export default defineComponent({
{getSlot(slots, 'header')} {getSlot(slots, 'header')}
<SearchInput <SearchInput
class={!props.search ? 'hidden' : ''} class={!props.search ? 'hidden' : ''}
theme={props.theme} theme={props.theme as MenuThemeEnum}
onChange={handleInputChange} onChange={handleInputChange}
onClick={handleInputClick} onClick={handleInputClick}
collapsed={getCollapsedState} collapsed={getCollapsedState}
......
...@@ -22,6 +22,7 @@ export const BAR_MAP: BarMap = { ...@@ -22,6 +22,7 @@ export const BAR_MAP: BarMap = {
}, },
}; };
// @ts-ignore
export function renderThumbStyle({ move, size, bar }) { export function renderThumbStyle({ move, size, bar }) {
const style = {} as any; const style = {} as any;
const translate = `translate${bar.axis}(${move}%)`; const translate = `translate${bar.axis}(${move}%)`;
......
...@@ -2,7 +2,7 @@ import { defineComponent, PropType } from 'vue'; ...@@ -2,7 +2,7 @@ import { defineComponent, PropType } from 'vue';
import { Dropdown, Menu, Popconfirm } from 'ant-design-vue'; import { Dropdown, Menu, Popconfirm } from 'ant-design-vue';
import Icon from '/@/components/Icon/index'; import Icon from '/@/components/Icon/index';
import { DownOutlined } from '@ant-design/icons-vue'; import { DownOutlined } from '@ant-design/icons-vue';
import { ActionItem } from '../types/tableAction'; import { ActionItem } from '/@/components/Table';
import Button from '/@/components/Button/index.vue'; import Button from '/@/components/Button/index.vue';
const prefixCls = 'basic-table-action'; const prefixCls = 'basic-table-action';
export default defineComponent({ export default defineComponent({
...@@ -26,7 +26,14 @@ export default defineComponent({ ...@@ -26,7 +26,14 @@ export default defineComponent({
function renderButton(action: ActionItem, index: number) { function renderButton(action: ActionItem, index: number) {
const { disabled = false, label, icon, color = '', type = 'link' } = action; const { disabled = false, label, icon, color = '', type = 'link' } = action;
const button = ( const button = (
<Button type={type} size="small" disabled={disabled} color={color} {...action} key={index}> <Button
type={type as any}
size="small"
disabled={disabled}
color={color}
{...action}
key={index}
>
{() => ( {() => (
<> <>
{label} {label}
......
...@@ -22,7 +22,7 @@ export const FETCH_SETTING = { ...@@ -22,7 +22,7 @@ export const FETCH_SETTING = {
}; };
// 配置通用排序函数 // 配置通用排序函数
export function DEFAULT_SORT_FN(sortInfo: SorterResult<any>) { export function DEFAULT_SORT_FN(sortInfo: SorterResult) {
const { field, order } = sortInfo; const { field, order } = sortInfo;
return { return {
// 传给后台的排序字段你 // 传给后台的排序字段你
......
...@@ -8,7 +8,7 @@ import type { ...@@ -8,7 +8,7 @@ import type {
TableCustomRecord, TableCustomRecord,
TableRowSelection, TableRowSelection,
} from './types/table'; } from './types/table';
import type { FormProps } from '/@/components/Form/index'; import type { FormProps } from '/@/components/Form';
import { DEFAULT_SORT_FN, FETCH_SETTING } from './const'; import { DEFAULT_SORT_FN, FETCH_SETTING } from './const';
// 注释看 types/table // 注释看 types/table
......
import type { VNodeChild } from 'vue'; import type { VNodeChild } from 'vue';
import type { PaginationProps } from './pagination'; import type { PaginationProps } from './pagination';
import type { FormProps } from '/@/components/Form/index'; import type { FormProps } from '/@/components/Form';
import type { import type {
ColumnProps, ColumnProps,
TableRowSelection as ITableRowSelection, TableRowSelection as ITableRowSelection,
...@@ -125,7 +125,7 @@ export interface TableSetting { ...@@ -125,7 +125,7 @@ export interface TableSetting {
export interface BasicTableProps<T = any> { export interface BasicTableProps<T = any> {
// 自定义排序方法 // 自定义排序方法
sortFn?: (sortInfo: SorterResult<any>) => any; sortFn?: (sortInfo: SorterResult) => any;
// 显示表格设置 // 显示表格设置
showTableSetting?: boolean; showTableSetting?: boolean;
tableSetting?: TableSetting; tableSetting?: TableSetting;
......
...@@ -41,7 +41,7 @@ export function useEvent({ ...@@ -41,7 +41,7 @@ export function useEvent({
const removeWatch = watch( const removeWatch = watch(
element, element,
(v, ov, cleanUp) => { (v, _ov, cleanUp) => {
if (v) { if (v) {
!unref(isAddRef) && addEventListener(v); !unref(isAddRef) && addEventListener(v);
cleanUp(() => { cleanUp(() => {
......
import type { Fn } from './types';
import { tryOnMounted, tryOnUnmounted } from '/@/utils/helper/vueHelper'; import { tryOnMounted, tryOnUnmounted } from '/@/utils/helper/vueHelper';
import { ref } from 'vue'; import { ref } from 'vue';
......
import { createStorage } from '/@/utils/storage/index'; import { createStorage } from '/@/utils/storage';
export function useLocalStorage() { export function useLocalStorage() {
return createStorage(localStorage); return createStorage(localStorage);
......
import type { ModalFunc, ModalFuncProps } from 'ant-design-vue/lib/modal/Modal'; import type { ModalFunc, ModalFuncProps } from 'ant-design-vue/lib/modal/Modal';
import type { MessageApi } from 'ant-design-vue/lib/message/index'; import type { MessageApi } from 'ant-design-vue/lib/message';
import type { VNodeTypes, CSSProperties } from 'vue'; import type { VNodeTypes, CSSProperties } from 'vue';
import { Modal, message as Message, notification } from 'ant-design-vue'; import { Modal, message as Message, notification } from 'ant-design-vue';
......
import { appStore } from './../../store/modules/app'; import { appStore } from '/@/store/modules/app';
import { permissionStore } from '/@/store/modules/permission'; import { permissionStore } from '/@/store/modules/permission';
import { useTabs } from './useTabs'; import { useTabs } from './useTabs';
import { RoleEnum } from '/@/enums/roleEnum'; import { RoleEnum } from '/@/enums/roleEnum';
......
import { createStorage } from '/@/utils/storage/index'; import { createStorage } from '/@/utils/storage';
export function useSessionStorage() { export function useSessionStorage() {
return createStorage(sessionStorage); return createStorage(sessionStorage);
......
...@@ -21,7 +21,7 @@ import { useFullscreen } from '/@/hooks/web/useFullScreen'; ...@@ -21,7 +21,7 @@ import { useFullscreen } from '/@/hooks/web/useFullScreen';
import { useTabs } from '/@/hooks/web/useTabs'; import { useTabs } from '/@/hooks/web/useTabs';
import { useWindowSizeFn } from '/@/hooks/event/useWindowSize'; import { useWindowSizeFn } from '/@/hooks/event/useWindowSize';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useModal } from '/@/components/Modal/index'; import { useModal } from '/@/components/Modal';
import { appStore } from '/@/store/modules/app'; import { appStore } from '/@/store/modules/app';
import { errorStore } from '/@/store/modules/error'; import { errorStore } from '/@/store/modules/error';
......
...@@ -54,7 +54,7 @@ export default defineComponent({ ...@@ -54,7 +54,7 @@ export default defineComponent({
isLock: true, isLock: true,
pwd: password, pwd: password,
}); });
resetFields(); await resetFields();
} catch (error) {} } catch (error) {}
} }
// 账号密码登录 // 账号密码登录
......
...@@ -3,8 +3,8 @@ import { createApp } from 'vue'; ...@@ -3,8 +3,8 @@ import { createApp } from 'vue';
import router, { setupRouter } from '/@/router'; import router, { setupRouter } from '/@/router';
import { setupStore } from '/@/store'; import { setupStore } from '/@/store';
import { setupAntd } from '/@/setup/ant-design-vue'; import { setupAntd } from '/@/setup/ant-design-vue';
import { setupErrorHandle } from '/@/setup/error-handle/index'; import { setupErrorHandle } from '/@/setup/error-handle';
import { setupDirectives } from '/@/setup/directives/index'; import { setupDirectives } from '/@/setup/directives';
import { isDevMode, isProdMode, isUseMock } from '/@/utils/env'; import { isDevMode, isProdMode, isUseMock } from '/@/utils/env';
import { setupProdMockServer } from '../mock/_createProductionServer'; import { setupProdMockServer } from '../mock/_createProductionServer';
......
...@@ -91,9 +91,7 @@ function basicFilter(routes: RouteRecordNormalized[]) { ...@@ -91,9 +91,7 @@ function basicFilter(routes: RouteRecordNormalized[]) {
if (route.meta.carryParam) { if (route.meta.carryParam) {
return pathToRegexp(route.path).test(menu.path); return pathToRegexp(route.path).test(menu.path);
} }
if (route.meta.ignoreAuth) { if (route.meta.ignoreAuth) return false;
return false;
}
} }
return route.path === menu.path; return route.path === menu.path;
}); });
......
...@@ -73,9 +73,11 @@ export interface MenuModule { ...@@ -73,9 +73,11 @@ export interface MenuModule {
menu: Menu; menu: Menu;
} }
export interface AppRouteModule { interface RouteModule {
layout?: AppRouteRecordRaw; layout: AppRouteRecordRaw;
routes?: AppRouteRecordRaw[]; routes: AppRouteRecordRaw[];
children?: AppRouteRecordRaw[]; children?: AppRouteRecordRaw[];
component?: any; component?: any;
} }
export type AppRouteModule = RouteModule | AppRouteRecordRaw;
import { appStore } from './../../store/modules/app'; import { appStore } from '/@/store/modules/app';
import type { App } from 'vue'; import type { App } from 'vue';
import { usePermission } from '/@/hooks/web/usePermission'; import { usePermission } from '/@/hooks/web/usePermission';
import { PermissionModeEnum } from '/@/enums/appEnum'; import { PermissionModeEnum } from '/@/enums/appEnum';
......
...@@ -10,7 +10,7 @@ import { PermissionModeEnum } from '/@/enums/appEnum'; ...@@ -10,7 +10,7 @@ import { PermissionModeEnum } from '/@/enums/appEnum';
import { appStore } from '/@/store/modules/app'; import { appStore } from '/@/store/modules/app';
import { userStore } from '/@/store/modules/user'; import { userStore } from '/@/store/modules/user';
import { asyncRoutes } from '/@/router/routes/index'; import { asyncRoutes } from '/@/router/routes';
import { filter } from '/@/utils/helper/treeHelper'; import { filter } from '/@/utils/helper/treeHelper';
import { toRaw } from 'vue'; import { toRaw } from 'vue';
import { getMenuListById } from '/@/api/sys/menu'; import { getMenuListById } from '/@/api/sys/menu';
......
...@@ -93,10 +93,11 @@ export function useListenerNetWork() { ...@@ -93,10 +93,11 @@ export function useListenerNetWork() {
// Check network status // Check network status
useNetWork({ useNetWork({
onLineFn: () => { onLineFn: () => {
replace(PageEnum.BASE_HOME); replace(PageEnum.BASE_HOME).then(() => {
useTimeout(() => { useTimeout(() => {
appStore.commitPageLoadingState(false); appStore.commitPageLoadingState(false);
}, 300); }, 200);
});
}, },
offLineFn: () => { offLineFn: () => {
replace({ replace({
......
...@@ -14,10 +14,10 @@ export const isHexColor = function (color: string) { ...@@ -14,10 +14,10 @@ export const isHexColor = function (color: string) {
* RGB 颜色值转换为 十六进制颜色值. * RGB 颜色值转换为 十六进制颜色值.
* r, g, 和 b 需要在 [0, 255] 范围内 * r, g, 和 b 需要在 [0, 255] 范围内
* *
* @param Number r 红色色值
* @param Number g 绿色色值
* @param Number b 蓝色色值
* @return String 类似#ff00ff * @return String 类似#ff00ff
* @param r
* @param g
* @param b
*/ */
export const rgbToHex = function (r: number, g: number, b: number) { export const rgbToHex = function (r: number, g: number, b: number) {
// tslint:disable-next-line:no-bitwise // tslint:disable-next-line:no-bitwise
......
...@@ -17,7 +17,6 @@ export const prodMode = 'production'; ...@@ -17,7 +17,6 @@ export const prodMode = 'production';
/** /**
* @description: 获取环境变量 * @description: 获取环境变量
* @param {type}
* @returns: * @returns:
* @example: * @example:
*/ */
...@@ -25,7 +24,6 @@ export const getEnv = (): string => import.meta.env.MODE; ...@@ -25,7 +24,6 @@ export const getEnv = (): string => import.meta.env.MODE;
/** /**
* @description: 是否是开发模式 * @description: 是否是开发模式
* @param {type}
* @returns: * @returns:
* @example: * @example:
*/ */
...@@ -33,7 +31,6 @@ export const isDevMode = (): boolean => import.meta.env.DEV; ...@@ -33,7 +31,6 @@ export const isDevMode = (): boolean => import.meta.env.DEV;
/** /**
* @description: 是否是生产模式模式 * @description: 是否是生产模式模式
* @param {type}
* @returns: * @returns:
* @example: * @example:
*/ */
...@@ -41,7 +38,6 @@ export const isProdMode = (): boolean => import.meta.env.PROD; ...@@ -41,7 +38,6 @@ export const isProdMode = (): boolean => import.meta.env.PROD;
/** /**
* @description: 是否开启mock * @description: 是否开启mock
* @param {type}
* @returns: * @returns:
* @example: * @example:
*/ */
......
import { AppRouteModule } from '/@/router/types.d'; import { AppRouteModule, RouteModule } from '/@/router/types.d';
import type { MenuModule, Menu, AppRouteRecordRaw } from '/@/router/types'; import type { MenuModule, Menu, AppRouteRecordRaw } from '/@/router/types';
import { findPath, forEach, treeMap, treeToList } from './treeHelper'; 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[]) {
const cloneRouteModList = cloneDeep(routeModList); const cloneRouteModList = cloneDeep(routeModList);
const routeList: AppRouteRecordRaw[] = []; const routeList: AppRouteRecordRaw[] = [];
cloneRouteModList.forEach((item) => { cloneRouteModList.forEach((item) => {
const { layout, routes, children } = item; const { layout, routes, children } = item as RouteModule;
if (layout) { if (layout) {
layout.children = routes || children; layout.children = routes || children;
routeList.push(layout); routeList.push(layout);
......
import { createStorage } from '/@/utils/storage/index'; import { createStorage } from '/@/utils/storage';
import { isIeFn } from '/@/utils/browser'; import { isIeFn } from '/@/utils/browser';
import { BASE_LOCAL_CACHE_KEY, BASE_SESSION_CACHE_KEY } from '/@/enums/cacheEnum'; import { BASE_LOCAL_CACHE_KEY, BASE_SESSION_CACHE_KEY } from '/@/enums/cacheEnum';
......
import type { AppRouteModule, AppRouteRecordRaw } from '/@/router/types'; import type { AppRouteModule, AppRouteRecordRaw, RouteModule } from '/@/router/types';
import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router'; import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router';
import { createRouter, createWebHashHistory } from 'vue-router';
import { appStore } from '/@/store/modules/app'; import { appStore } from '/@/store/modules/app';
import { tabStore } from '/@/store/modules/tab'; import { tabStore } from '/@/store/modules/tab';
import { createRouter, createWebHashHistory } from 'vue-router';
import { toRaw } from 'vue'; import { toRaw } from 'vue';
import { PAGE_LAYOUT_COMPONENT } from '/@/router/constant'; import { PAGE_LAYOUT_COMPONENT } from '/@/router/constant';
// import { isDevMode } from '/@/utils/env'; // import { isDevMode } from '/@/utils/env';
...@@ -21,17 +21,17 @@ export function setCurrentTo(to: RouteLocationNormalized) { ...@@ -21,17 +21,17 @@ export function setCurrentTo(to: RouteLocationNormalized) {
} }
// 转化路由模块 // 转化路由模块
// 将多级转成2层。keepAlive问题 // 将多级转成2层。keepAlive问题
export function genRouteModule(moduleList: AppRouteModule[]) { export function genRouteModule(moduleList: AppRouteModule[] | AppRouteRecordRaw[]) {
const ret: AppRouteRecordRaw[] = []; const ret: AppRouteRecordRaw[] = [];
for (const routeMod of moduleList) { for (const routeMod of moduleList) {
let routes = []; let routes: RouteRecordRaw[] = [];
let layout: AppRouteRecordRaw | undefined; let layout: AppRouteRecordRaw | undefined;
if (Reflect.has(routeMod, 'routes')) { if (Reflect.has(routeMod, 'routes')) {
routes = routeMod.routes as any; routes = (routeMod as RouteModule).routes as any;
layout = routeMod.layout; layout = (routeMod as RouteModule).layout;
} else if (Reflect.has(routeMod, 'path')) { } else if (Reflect.has(routeMod, 'path')) {
layout = omit(routeMod, 'children') as any; layout = omit(routeMod, 'children') as any;
routes = routeMod.children || []; routes = (routeMod.children as RouteRecordRaw[]) || ([] as RouteRecordRaw[]);
} }
const router = createRouter({ routes, history: createWebHashHistory() }); const router = createRouter({ routes, history: createWebHashHistory() });
...@@ -66,20 +66,26 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) { ...@@ -66,20 +66,26 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) {
}); });
} }
function getLayoutComp(comp: string) {
return comp === 'PAGE_LAYOUT' ? PAGE_LAYOUT_COMPONENT : '';
}
// 将后台对象转成路由对象 // 将后台对象转成路由对象
export function transformObjToRoute(routeList: AppRouteModule[]) { export function transformObjToRoute<T = any>(routeList: AppRouteModule[]): T[] {
routeList.forEach((route) => { routeList.forEach((route) => {
asyncImportRoute(Reflect.has(route, 'routes') ? route.routes : route.children || []); asyncImportRoute(
if (route.layout) { Reflect.has(route, 'routes') ? (route as RouteModule).routes : route.children || []
route.layout.component = );
route.layout.component === 'PAGE_LAYOUT' ? PAGE_LAYOUT_COMPONENT : ''; if ((route as RouteModule).layout) {
(route as RouteModule).layout.component = getLayoutComp(
(route as RouteModule).layout.component
);
} else { } else {
route.component = route.component === 'PAGE_LAYOUT' ? PAGE_LAYOUT_COMPONENT : ''; route.component = getLayoutComp(route.component);
const _layout = omit(route, 'children') as any; (route as RouteModule).layout = omit(route, 'children') as any;
route.layout = _layout;
} }
}); });
return routeList; return (routeList as unknown) as T[];
} }
// //
......
...@@ -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) {
/** /**
* extends slots * extends slots
* @param slots * @param slots
* @param excludeKeys
*/ */
export function extendSlots(slots: Slots, excludeKeys: string[] = []) { export function extendSlots(slots: Slots, excludeKeys: string[] = []) {
const slotKeys = Object.keys(slots); const slotKeys = Object.keys(slots);
......
...@@ -17,7 +17,7 @@ export * from './axiosTransform'; ...@@ -17,7 +17,7 @@ export * from './axiosTransform';
*/ */
export class VAxios { export class VAxios {
private axiosInstance: AxiosInstance; private axiosInstance: AxiosInstance;
private options: CreateAxiosOptions; private readonly options: CreateAxiosOptions;
constructor(options: CreateAxiosOptions) { constructor(options: CreateAxiosOptions) {
this.options = options; this.options = options;
......
...@@ -92,7 +92,7 @@ export const createStorage = ({ prefixKey = '', storage = sessionStorage } = {}) ...@@ -92,7 +92,7 @@ export const createStorage = ({ prefixKey = '', storage = sessionStorage } = {})
* 添加cookie * 添加cookie
* @param name cookie名字 * @param name cookie名字
* @param value cookie内容 * @param value cookie内容
* @param day 过期时间 * @param expire
* 如果过期时间未设置,默认管理浏览器自动删除 * 如果过期时间未设置,默认管理浏览器自动删除
* 例子: * 例子:
* cookieData.set('name','value',) * cookieData.set('name','value',)
......
...@@ -10,7 +10,7 @@ export function buildUUID(): string { ...@@ -10,7 +10,7 @@ export function buildUUID(): string {
} else if (i === 15) { } else if (i === 15) {
uuid += 4; uuid += 4;
} else if (i === 20) { } else if (i === 20) {
uuid += hexList[(Math.random() * 4) | (0 + 8)]; uuid += hexList[(Math.random() * 4) | 8];
} else { } else {
uuid += hexList[(Math.random() * 16) | 0]; uuid += hexList[(Math.random() * 16) | 0];
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册