Skip to content

Commit

Permalink
chore: upgrade deps & lint config
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Jun 29, 2022
1 parent a779f73 commit e574f0e
Show file tree
Hide file tree
Showing 10 changed files with 1,186 additions and 1,129 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"sourceMaps": true
}
]
}
}
47 changes: 28 additions & 19 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
{
"typescript.tsdk": "./node_modules/typescript/lib",
"volar.tsPlugin": true,
"volar.tsPluginStatus": false,
"npm.packageManager": "yarn",
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.eol": "\n",
"eslint.probe": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"html",
"vue",
"markdown",
"json",
"jsonc"
],
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"html",
"vue",
"markdown",
"json",
"jsonc"
],
"search.exclude": {
"**/node_modules": true,
"**/*.log": true,
Expand Down Expand Up @@ -83,28 +104,16 @@
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"[vue]": {
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"i18n-ally.localesPaths": [
"src/locales/lang"
],
"i18n-ally.localesPaths": ["src/locales/lang"],
"i18n-ally.keystyle": "nested",
"i18n-ally.sortKeys": true,
"i18n-ally.namespace": true,
"i18n-ally.pathMatcher": "{locale}/{namespaces}.{ext}",
"i18n-ally.enabledParsers": [
"ts"
],
"i18n-ally.enabledParsers": ["ts"],
"i18n-ally.sourceLanguage": "en",
"i18n-ally.displayLanguage": "zh-CN",
"i18n-ally.enabledFrameworks": [
"vue",
"react"
]
"i18n-ally.enabledFrameworks": ["vue", "react"]
}
56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"clean:lib": "npx rimraf node_modules",
"deploy": "npm run build && npx gh-pages -d dist",
"dev:debug": "cross-env DEBUG_ANTDV=true npm run serve",
"lint": "vue-cli-service lint",
"format": "prettier --write .",
"lint": "eslint . --ext .vue,.js,.ts,.jsx,.tsx,.md,.json --max-warnings 0 && pretty-quick --check --branch dev",
"lint:fix": "eslint --fix . --ext .vue,.js,.ts,.jsx,.tsx,.md,.json && pretty-quick --branch dev",
"lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,tsx}\" --fix",
"lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"",
"lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
Expand All @@ -32,18 +34,18 @@
},
"dependencies": {
"@ant-design/icons-vue": "^6.1.0",
"@vueuse/core": "^8.6.0",
"ant-design-vue": "3.2.6",
"@vueuse/core": "^8.7.5",
"ant-design-vue": "3.2.9",
"axios": "^0.27.2",
"core-js": "^3.22.8",
"core-js": "^3.23.3",
"dayjs": "^1.11.3",
"file-saver": "^2.0.5",
"lodash-es": "^4.17.21",
"mitt": "^3.0.0",
"mockjs": "^1.1.0",
"nprogress": "^1.0.0-1",
"pinia": "2.0.14",
"qs": "^6.10.5",
"qs": "^6.11.0",
"socket.io-client": "4.5.1",
"sortablejs": "^1.15.0",
"vue": "3.2.37",
Expand All @@ -53,37 +55,38 @@
"xlsx": "^0.18.5"
},
"devDependencies": {
"@commitlint/cli": "^17.0.2",
"@commitlint/config-conventional": "^17.0.2",
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@types/lodash-es": "^4.17.6",
"@types/node": "^17.0.42",
"@types/node": "^18.0.0",
"@types/webpack-env": "^1.17.0",
"@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1",
"@vue/cli-plugin-babel": "^5.0.4",
"@vue/cli-plugin-eslint": "^5.0.4",
"@vue/cli-plugin-router": "^5.0.4",
"@vue/cli-plugin-typescript": "^5.0.4",
"@vue/cli-service": "^5.0.4",
"@vue/eslint-config-typescript": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^5.30.0",
"@typescript-eslint/parser": "^5.30.0",
"@vue/cli-plugin-babel": "^5.0.6",
"@vue/cli-plugin-eslint": "^5.0.6",
"@vue/cli-plugin-router": "^5.0.6",
"@vue/cli-plugin-typescript": "^5.0.6",
"@vue/cli-service": "^5.0.6",
"@vue/eslint-config-typescript": "^11.0.0",
"babel-plugin-import": "^1.13.5",
"commitizen": "^4.2.4",
"conventional-changelog-cli": "^2.2.2",
"cross-env": "^7.0.3",
"cz-git": "^1.2.8",
"eslint": "^8.17.0",
"cz-git": "^1.3.8",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-prettier": "^4.1.0",
"eslint-plugin-vue": "^9.1.1",
"husky": "^8.0.1",
"less": "^4.1.3",
"less-loader": "10.2.0",
"lint-staged": "^13.0.1",
"less-loader": "11.0.0",
"lint-staged": "^13.0.3",
"path-browserify": "^1.0.1",
"postcss-html": "^1.4.1",
"postcss-less": "^6.0.0",
"prettier": "^2.6.2",
"prettier": "^2.7.1",
"pretty-quick": "^3.1.3",
"regenerator-runtime": "^0.13.9",
"speed-measure-webpack-plugin": "^1.5.0",
"stylelint": "^14.9.1",
Expand All @@ -94,10 +97,10 @@
"stylelint-config-standard": "^26.0.0",
"stylelint-order": "^5.0.0",
"svg-sprite-loader": "^6.0.11",
"typescript": "^4.7.3",
"typescript": "^4.7.4",
"unplugin-vue-define-options": "^0.6.1",
"vue-cli-plugin-windicss": "^1.1.4",
"vue-eslint-parser": "^9.0.2"
"vue-eslint-parser": "^9.0.3"
},
"__npminstall_done": false,
"repository": {
Expand All @@ -123,10 +126,7 @@
"eslint --fix",
"prettier --write"
],
"{!(package)*.json,*.code-snippets,.!(browserslist)*rc}": [
"prettier --write--parser json"
],
"package.json": [
"*.json": [
"prettier --write"
],
"*.vue": [
Expand Down
15 changes: 7 additions & 8 deletions src/components/core/schema-form/src/schema-form-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</template>

<script setup lang="tsx">
import { computed, unref, toRefs, onMounted, isVNode } from 'vue';
import { computed, unref, toRefs, isVNode } from 'vue';
import { useVModel, isFunction } from '@vueuse/core';
import { cloneDeep } from 'lodash-es';
import { Form, Col, Spin, Divider } from 'ant-design-vue';
Expand Down Expand Up @@ -378,20 +378,19 @@
return rules;
});
onMounted(async () => {
requestIdleCallback(async () => {
if (getComponentProps.value?.request) {
const compProps = getComponentProps.value;
const { componentProps, component } = schema.value;
const { componentProps, component } = unref(schema);
schema.value.loading = true;
schema.value.field === 'field35' && console.log('compProps', compProps, formPropsRef.value);
Reflect.set(schema.value, 'loading', true);
// schema.value.field === 'field35' && console.log('compProps', getComponentProps.value, formPropsRef.value);
try {
const result = await getComponentProps.value?.request(unref(getValues));
if (['Select', 'RadioGroup', 'CheckBoxGroup'].some((n) => n === component)) {
compProps.options = result;
getComponentProps.value.options = result;
} else if (['TreeSelect', 'Tree'].some((n) => n === component)) {
compProps.treeData = result;
getComponentProps.value.treeData = result;
}
if (componentProps) {
componentProps.requestResult = result;
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/useBattery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const useBattery = () => {
level: 100,
});

// 当前浏览器是否支持Battery API
const isSupported = navigator && 'getBattery' in navigator;

// 更新电池使用状态
const updateBattery = (target) => {
for (const key in battery) {
Expand Down Expand Up @@ -44,7 +47,7 @@ export const useBattery = () => {
});

onMounted(async () => {
const BatteryManager: Battery = await (window.navigator as any).getBattery();
const BatteryManager: Battery = (await (window.navigator as any).getBattery?.()) || {};
updateBattery(BatteryManager);
console.log(BatteryManager, '电池');

Expand Down Expand Up @@ -82,6 +85,7 @@ export const useBattery = () => {

return {
battery,
isSupported,
batteryStatus,
calcDischargingTime,
} as const;
Expand Down
33 changes: 13 additions & 20 deletions src/router/generator-router.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { type RouteRecordRaw } from 'vue-router';
import { Result } from 'ant-design-vue';
import { notFound, errorRoute } from './staticModules/error';
import { REDIRECT_ROUTE } from './staticModules/besidesLayout';
import outsideLayout from './outsideLayout';
import type { PermissionType } from '@/core/permission/modules/types';
import type { RouteRecordRaw } from 'vue-router';
import RouterView from '@/layout/routerView/index.vue';
import { isUrl } from '@/utils/is';
import { uniqueSlash } from '@/utils/urlUtils';
import { constantRouterComponents } from '@/router/asyncModules';
import common from '@/router/staticModules';
import router, { routes } from '@/router';
import NotFound from '@/views/error/404.vue';
import { type PermissionType } from '@/core/permission/modules/types';

// 需要放在所有路由之后的路由
const endRoutes: RouteRecordRaw[] = [REDIRECT_ROUTE, errorRoute, notFound];
Expand All @@ -25,7 +25,7 @@ export function filterAsyncRoute(
.map((item) => {
const { router, viewPath, name, icon, orderNum, keepalive } = item;
let fullPath = '';
const pathPrefix = lastNamePath.slice(-1)[0] || '';
const pathPrefix = lastNamePath.at(-1) || '';
if (isUrl(router)) {
fullPath = router;
} else {
Expand Down Expand Up @@ -57,8 +57,8 @@ export function filterAsyncRoute(
},
};

// 如果是目录
if (item.type === 0) {
// 如果是目录
const children = filterAsyncRoute(routes, item, lastNamePath.concat(fullPath));
if (children?.length) {
route.component = RouterView;
Expand All @@ -74,8 +74,8 @@ export function filterAsyncRoute(
);
}
return route;
} else if (item.type === 1) {
// 如果是页面
} else if (item.type === 1) {
const Component = constantRouterComponents[viewPath] || NotFound;
route.component = Component;

Expand Down Expand Up @@ -148,23 +148,16 @@ export const generatorNamePath = (
parent?: RouteRecordRaw,
) => {
routes.forEach((item) => {
if (item.children?.length) {
if (item.meta && typeof item.name === 'string') {
item.meta.namePath = Array.isArray(namePath) ? namePath.concat(item.name) : [item.name];
item.meta.fullPath = parent?.meta?.fullPath
? [parent.meta.fullPath, item.path].join('/')
: item.path;
item.meta.fullPath = uniqueSlash(item.meta.fullPath);
if (item.meta && typeof item.name === 'string') {
item.meta.namePath = Array.isArray(namePath) ? namePath.concat(item.name) : [item.name];
item.meta.fullPath = parent?.meta?.fullPath
? [parent.meta.fullPath, item.path].join('/')
: item.path;
item.meta.fullPath = uniqueSlash(item.meta.fullPath);

if (item.children?.length) {
generatorNamePath(item.children, item.meta.namePath, item);
}
} else {
if (item.meta && typeof item.name === 'string') {
item.meta.namePath = Array.isArray(namePath) ? namePath.concat(item.name) : [item.name];
item.meta.fullPath = parent?.meta?.fullPath
? [parent.meta.fullPath, item.path].join('/')
: item.path;
item.meta.fullPath = uniqueSlash(item.meta.fullPath);
}
}
});
};
2 changes: 1 addition & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'nprogress/css/nprogress.css'; // 进度条样式
import { type App } from 'vue';
import { createRouter, createWebHashHistory } from 'vue-router';

import { createRouterGuards } from './router-guards';

import outsideLayout from './outsideLayout';
import { whiteNameList } from './constant';
import type { App } from 'vue';
import type { RouteRecordRaw } from 'vue-router';

export const routes: Array<RouteRecordRaw> = [
Expand Down
2 changes: 1 addition & 1 deletion src/router/outsideLayout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type RouteRecordRaw } from 'vue-router';
import type { RouteRecordRaw } from 'vue-router';
import { LOGIN_NAME } from '@/router/constant';

/**
Expand Down
24 changes: 5 additions & 19 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,14 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"experimentalDecorators": true,
"lib": [
"dom",
"esnext"
],
"lib": ["dom", "esnext"],
"noImplicitAny": false,
"skipLibCheck": true,
"removeComments": true,
"types": [
"webpack-env",
"unplugin-vue-define-options"
],
"types": ["webpack-env", "unplugin-vue-define-options"],
"paths": {
"@/*": [
"src/*"
]
},
"@/*": ["src/*"]
}
},
"include": [
"mock/**/*",
Expand All @@ -43,11 +35,5 @@
"types/**/*.d.ts",
"types/**/*.ts"
],
"exclude": [
"node_modules",
"dist",
"**/*.js",
"**/*.md",
"src/**/*.md",
]
"exclude": ["node_modules", "dist", "**/*.js", "**/*.md", "src/**/*.md"]
}
Loading

1 comment on commit e574f0e

@vercel
Copy link

@vercel vercel bot commented on e574f0e Jun 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vue3-antd-admin – ./

vue3-antd-admin-buqiyuan.vercel.app
vue3-antd-admin-git-main-buqiyuan.vercel.app
vue3-antd-admin.vercel.app

Please sign in to comment.