Skip to content

Commit

Permalink
fix: type error
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Nov 12, 2020
1 parent 21e0548 commit ecfb702
Show file tree
Hide file tree
Showing 37 changed files with 83 additions and 73 deletions.
2 changes: 1 addition & 1 deletion build/script/preserve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions build/vite/plugin/dynamicImport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -47,7 +47,6 @@ const dynamicImportTransform = function (env: any = {}): Transform {
}
}\n\n
`;
return _code;
} catch (error) {
console.error(error);
return code;
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<ConfigProvider :locale="zhCN" :transformCellText="transformCellText" v-bind="lockOn">
<ConfigProvider :locale="zhCN" :transform-cell-text="transformCellText" v-bind="lockOn">
<router-view />
</ConfigProvider>
</template>
Expand Down
10 changes: 5 additions & 5 deletions src/components/ContextMenu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {}
Expand All @@ -55,7 +55,7 @@ export const createContextMenu = function (options: Options) {
export const unMountedContextMenu = function () {
if (menuManager) {
menuManager.resolve('');
menuManager.doms = [];
menuManager.domList = [];
}
};

Expand Down
1 change: 1 addition & 0 deletions src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default defineComponent({
</>
)}
</Menu.Item>,
// @ts-ignore
divider && <Menu.Divider key={`d-${index}`} />,
];
})}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Excel/src/ImportExcel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
// fix can't select the same excel
inputRefDom.value = '';
}
readerData(rawFile);
await readerData(rawFile);
}
/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/Form/src/FormItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/src/props.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Menu/src/BasicMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions src/components/Scrollbar/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}%)`;
Expand Down
11 changes: 9 additions & 2 deletions src/components/Table/src/components/TableAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
// 传给后台的排序字段你
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/components/Table/src/types/table.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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,
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/event/useEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function useEvent({

const removeWatch = watch(
element,
(v, ov, cleanUp) => {
(v, _ov, cleanUp) => {
if (v) {
!unref(isAddRef) && addEventListener(v);
cleanUp(() => {
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/event/useWindowSize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { Fn } from './types';

import { tryOnMounted, tryOnUnmounted } from '/@/utils/helper/vueHelper';
import { ref } from 'vue';

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/web/useLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createStorage } from '/@/utils/storage/index';
import { createStorage } from '/@/utils/storage';

export function useLocalStorage() {
return createStorage(localStorage);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/web/useMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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';
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/web/usePermission.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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';
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/web/useSessionStorage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createStorage } from '/@/utils/storage/index';
import { createStorage } from '/@/utils/storage';

export function useSessionStorage() {
return createStorage(sessionStorage);
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/default/header/LayoutHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/default/header/LockActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default defineComponent({
isLock: true,
pwd: password,
});
resetFields();
await resetFields();
} catch (error) {}
}
// 账号密码登录
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 1 addition & 3 deletions src/router/menus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
8 changes: 5 additions & 3 deletions src/router/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion src/setup/directives/permission.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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';
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
9 changes: 5 additions & 4 deletions src/useApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions src/utils/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,27 @@ export const prodMode = 'production';

/**
* @description: 获取环境变量
* @param {type}
* @returns:
* @example:
*/
export const getEnv = (): string => import.meta.env.MODE;

/**
* @description: 是否是开发模式
* @param {type}
* @returns:
* @example:
*/
export const isDevMode = (): boolean => import.meta.env.DEV;

/**
* @description: 是否是生产模式模式
* @param {type}
* @returns:
* @example:
*/
export const isProdMode = (): boolean => import.meta.env.PROD;

/**
* @description: 是否开启mock
* @param {type}
* @returns:
* @example:
*/
Expand Down
4 changes: 2 additions & 2 deletions src/utils/helper/menuHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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';
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helper/persistent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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';
Expand Down
Loading

0 comments on commit ecfb702

Please sign in to comment.