提交 ecfb702b 编写于 作者: V vben

fix: type error

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