mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-03-01 00:23:11 +08:00
optimize ts type
This commit is contained in:
@@ -22,7 +22,6 @@ module.exports = defineConfig({
|
|||||||
'plugin:@typescript-eslint/recommended',
|
'plugin:@typescript-eslint/recommended',
|
||||||
'prettier',
|
'prettier',
|
||||||
'plugin:prettier/recommended',
|
'plugin:prettier/recommended',
|
||||||
'plugin:jest/recommended',
|
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/ban-ts-ignore': 'off',
|
'@typescript-eslint/ban-ts-ignore': 'off',
|
||||||
|
|||||||
27
package.json
27
package.json
@@ -39,26 +39,25 @@
|
|||||||
"makeit-captcha": "^1.2.5",
|
"makeit-captcha": "^1.2.5",
|
||||||
"mitt": "^2.1.0",
|
"mitt": "^2.1.0",
|
||||||
"mockjs": "^1.1.0",
|
"mockjs": "^1.1.0",
|
||||||
"naive-ui": "^2.16.2",
|
"naive-ui": "^2.19.1",
|
||||||
"pinia": "^2.0.0-rc.4",
|
"pinia": "^2.0.0-rc.4",
|
||||||
"qs": "^6.10.1",
|
"qs": "^6.10.1",
|
||||||
"vfonts": "^0.1.0",
|
"vfonts": "^0.1.0",
|
||||||
"vue": "^3.2.2",
|
"vue": "^3.2.16",
|
||||||
"vue-router": "^4.0.11",
|
"vue-router": "^4.0.11",
|
||||||
"vue-types": "^4.0.0",
|
"vue-types": "^4.1.0",
|
||||||
"vuedraggable": "^4.0.3",
|
"vuedraggable": "^4.0.3"
|
||||||
"vuex": "^4.0.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^12.1.4",
|
"@commitlint/cli": "^12.1.4",
|
||||||
"@commitlint/config-conventional": "^12.1.4",
|
"@commitlint/config-conventional": "^12.1.4",
|
||||||
"@types/lodash": "^4.14.170",
|
"@types/lodash": "^4.14.170",
|
||||||
"@types/node": "^15.12.2",
|
"@types/node": "^15.12.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.29.1",
|
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
||||||
"@typescript-eslint/parser": "^4.29.1",
|
"@typescript-eslint/parser": "^4.31.2",
|
||||||
"@vitejs/plugin-vue": "^1.2.3",
|
"@vitejs/plugin-vue": "^1.9.1",
|
||||||
"@vitejs/plugin-vue-jsx": "^1.1.5",
|
"@vitejs/plugin-vue-jsx": "^1.1.8",
|
||||||
"@vue/compiler-sfc": "^3.2.2",
|
"@vue/compiler-sfc": "^3.2.16",
|
||||||
"@vue/eslint-config-typescript": "^7.0.0",
|
"@vue/eslint-config-typescript": "^7.0.0",
|
||||||
"autoprefixer": "^10.3.1",
|
"autoprefixer": "^10.3.1",
|
||||||
"commitizen": "^4.2.4",
|
"commitizen": "^4.2.4",
|
||||||
@@ -69,7 +68,7 @@
|
|||||||
"eslint-define-config": "^1.0.9",
|
"eslint-define-config": "^1.0.9",
|
||||||
"eslint-plugin-jest": "^24.4.0",
|
"eslint-plugin-jest": "^24.4.0",
|
||||||
"eslint-plugin-prettier": "^3.4.0",
|
"eslint-plugin-prettier": "^3.4.0",
|
||||||
"eslint-plugin-vue": "^7.11.1",
|
"eslint-plugin-vue": "^7.18.0",
|
||||||
"esno": "^0.7.3",
|
"esno": "^0.7.3",
|
||||||
"gh-pages": "^3.2.0",
|
"gh-pages": "^3.2.0",
|
||||||
"husky": "^6.0.0",
|
"husky": "^6.0.0",
|
||||||
@@ -87,13 +86,13 @@
|
|||||||
"stylelint-order": "^4.1.0",
|
"stylelint-order": "^4.1.0",
|
||||||
"stylelint-scss": "^3.19.0",
|
"stylelint-scss": "^3.19.0",
|
||||||
"tailwindcss": "^2.2.7",
|
"tailwindcss": "^2.2.7",
|
||||||
"typescript": "^4.3.5",
|
"typescript": "^4.4.3",
|
||||||
"vite": "2.4.4",
|
"vite": "^2.5.10",
|
||||||
"vite-plugin-compression": "^0.3.1",
|
"vite-plugin-compression": "^0.3.1",
|
||||||
"vite-plugin-html": "^2.0.7",
|
"vite-plugin-html": "^2.0.7",
|
||||||
"vite-plugin-mock": "^2.9.3",
|
"vite-plugin-mock": "^2.9.3",
|
||||||
"vite-plugin-style-import": "^1.0.1",
|
"vite-plugin-style-import": "^1.0.1",
|
||||||
"vue-eslint-parser": "^7.8.0"
|
"vue-eslint-parser": "^7.11.0"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{vue,js,ts,tsx}": "eslint --fix"
|
"*.{vue,js,ts,tsx}": "eslint --fix"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import type { FormProps, FormActionType, UseFormReturnType } from '../types/form';
|
import type { FormProps, FormActionType, UseFormReturnType } from '../types/form';
|
||||||
// @ts-ignore
|
|
||||||
import type { DynamicProps } from '/#/utils';
|
import type { DynamicProps } from '/#/utils';
|
||||||
|
|
||||||
import { ref, onUnmounted, unref, nextTick, watch } from 'vue';
|
import { ref, onUnmounted, unref, nextTick, watch } from 'vue';
|
||||||
|
|||||||
@@ -88,7 +88,6 @@
|
|||||||
VerticalRightOutlined,
|
VerticalRightOutlined,
|
||||||
VerticalLeftOutlined,
|
VerticalLeftOutlined,
|
||||||
} from '@vicons/antd';
|
} from '@vicons/antd';
|
||||||
// @ts-ignore
|
|
||||||
import Draggable from 'vuedraggable/src/vuedraggable';
|
import Draggable from 'vuedraggable/src/vuedraggable';
|
||||||
import { useDesignSetting } from '@/hooks/setting/useDesignSetting';
|
import { useDesignSetting } from '@/hooks/setting/useDesignSetting';
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ export function useColumns(propsRef: ComputedRef<BasicTableProps>) {
|
|||||||
const columns = cloneDeep(pageColumns);
|
const columns = cloneDeep(pageColumns);
|
||||||
return columns
|
return columns
|
||||||
.filter((column) => {
|
.filter((column) => {
|
||||||
// @ts-ignore
|
return hasPermission(column.auth as string[]) && isIfShow(column);
|
||||||
return hasPermission(column.auth) && isIfShow(column);
|
|
||||||
})
|
})
|
||||||
.map((column) => {
|
.map((column) => {
|
||||||
//默认 ellipsis 为true
|
//默认 ellipsis 为true
|
||||||
@@ -93,10 +92,10 @@ export function useColumns(propsRef: ComputedRef<BasicTableProps>) {
|
|||||||
function handleActionColumn(propsRef: ComputedRef<BasicTableProps>, columns: BasicColumn[]) {
|
function handleActionColumn(propsRef: ComputedRef<BasicTableProps>, columns: BasicColumn[]) {
|
||||||
const { actionColumn } = unref(propsRef);
|
const { actionColumn } = unref(propsRef);
|
||||||
if (!actionColumn) return;
|
if (!actionColumn) return;
|
||||||
// @ts-ignore
|
!columns.find((col) => col.key === 'action') &&
|
||||||
!columns.find((col) => col.key === 'action') && columns.push({
|
columns.push({
|
||||||
...actionColumn,
|
...(actionColumn as any),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//设置
|
//设置
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
// @ts-ignore
|
|
||||||
import { NButton } from 'naive-ui';
|
import { NButton } from 'naive-ui';
|
||||||
import { PermissionsEnum } from '@/enums/permissionsEnum';
|
import { PermissionsEnum } from '@/enums/permissionsEnum';
|
||||||
// @ts-ignore
|
|
||||||
export interface ActionItem extends NButton.props {
|
export interface ActionItem extends NButton.props {
|
||||||
onClick?: Fn;
|
onClick?: Fn;
|
||||||
label?: string;
|
label?: string;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { RedirectRoute } from '@/router/base';
|
|||||||
import { PageEnum } from '@/enums/pageEnum';
|
import { PageEnum } from '@/enums/pageEnum';
|
||||||
import { createRouterGuards } from './router-guards';
|
import { createRouterGuards } from './router-guards';
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const modules = import.meta.globEager('./modules/**/*.ts');
|
const modules = import.meta.globEager('./modules/**/*.ts');
|
||||||
|
|
||||||
const routeModuleList: RouteRecordRaw[] = [];
|
const routeModuleList: RouteRecordRaw[] = [];
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ export type Component<T extends any = any> =
|
|||||||
| (() => Promise<typeof import('*.vue')>)
|
| (() => Promise<typeof import('*.vue')>)
|
||||||
| (() => Promise<T>);
|
| (() => Promise<T>);
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
|
export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
|
||||||
name: string;
|
name: string;
|
||||||
meta: RouteMeta;
|
meta: RouteMeta;
|
||||||
@@ -33,4 +32,24 @@ export interface Meta {
|
|||||||
frameSrc?: string;
|
frameSrc?: string;
|
||||||
// 外链跳转地址
|
// 外链跳转地址
|
||||||
externalLink?: string;
|
externalLink?: string;
|
||||||
|
//隐藏
|
||||||
|
hidden?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Menu {
|
||||||
|
title: string;
|
||||||
|
label: string;
|
||||||
|
key: string;
|
||||||
|
meta: RouteMeta;
|
||||||
|
name: string;
|
||||||
|
component?: Component | string;
|
||||||
|
components?: Component;
|
||||||
|
children?: AppRouteRecordRaw[];
|
||||||
|
props?: Recordable;
|
||||||
|
fullPath?: string;
|
||||||
|
icon?: any;
|
||||||
|
path: string;
|
||||||
|
permissions?: string[];
|
||||||
|
redirect?: string;
|
||||||
|
sort?: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
//获取相关CSS属性
|
//获取相关CSS属性
|
||||||
const getCss = function (o, key) {
|
const getCss = function (o, key) {
|
||||||
// @ts-ignore
|
|
||||||
return o.currentStyle
|
return o.currentStyle
|
||||||
? o.currentStyle[key]
|
? o.currentStyle[key]
|
||||||
: document.defaultView?.getComputedStyle(o, null)[key];
|
: document.defaultView?.getComputedStyle(o, null)[key];
|
||||||
|
|||||||
@@ -14,16 +14,28 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"noUnusedParameters": false,
|
"noUnusedParameters": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"lib": ["dom", "esnext"],
|
"lib": [
|
||||||
"types": ["vite/client", "jest"],
|
"dom",
|
||||||
"typeRoots": ["./node_modules/@types/", "./types"],
|
"esnext"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"vite/client"
|
||||||
|
],
|
||||||
|
"typeRoots": [
|
||||||
|
"./node_modules/@types/",
|
||||||
|
"./types"
|
||||||
|
],
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["src/*"],
|
"@/*": [
|
||||||
"/#/*": ["types/*"]
|
"src/*"
|
||||||
|
],
|
||||||
|
"/#/*": [
|
||||||
|
"types/*"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
@@ -38,5 +50,9 @@
|
|||||||
"mock/**/*.ts",
|
"mock/**/*.ts",
|
||||||
"vite.config.ts"
|
"vite.config.ts"
|
||||||
],
|
],
|
||||||
"exclude": ["node_modules", "dist", "**/*.js"]
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"dist",
|
||||||
|
"**/*.js"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
5
types/config.d.ts
vendored
5
types/config.d.ts
vendored
@@ -17,6 +17,10 @@ export interface ProjectSettingState {
|
|||||||
permissionMode: string;
|
permissionMode: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IbodySetting {
|
||||||
|
fixed: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IheaderSetting {
|
export interface IheaderSetting {
|
||||||
bgColor: string;
|
bgColor: string;
|
||||||
fixed: boolean;
|
fixed: boolean;
|
||||||
@@ -28,6 +32,7 @@ export interface ImenuSetting {
|
|||||||
menuWidth: number;
|
menuWidth: number;
|
||||||
fixed: boolean;
|
fixed: boolean;
|
||||||
mixMenu: boolean;
|
mixMenu: boolean;
|
||||||
|
collapsed: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IcrumbsSetting {
|
export interface IcrumbsSetting {
|
||||||
|
|||||||
5
types/utils.d.ts
vendored
Normal file
5
types/utils.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import type { ComputedRef, Ref } from 'vue';
|
||||||
|
|
||||||
|
export type DynamicProps<T> = {
|
||||||
|
[P in keyof T]: Ref<T[P]> | T[P] | ComputedRef<T[P]>;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user