From 67db3cb1c333f9a137e45c7f2dbbc3046c3970cd Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Sat, 18 Sep 2021 12:44:31 +0800 Subject: [PATCH] refactor: use setup refactor --- .eslintrc.js | 14 + package.json | 2 +- src/utils/propTypes.ts | 1 + src/views/components/cropping/index.vue | 2 +- src/views/editor/index.vue | 4 +- src/views/flow-chart/index.vue | 3 +- src/views/system/dict/config.vue | 182 ++++----- src/views/system/dict/index.vue | 434 ++++++++++----------- src/views/system/user/index.vue | 488 ++++++++++++------------ tsconfig.json | 2 +- 10 files changed, 548 insertions(+), 584 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 44ebde3d5..d3376c526 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,6 +3,20 @@ module.exports = { env: { node: true }, + globals: { + // Ref sugar (take 2) + $: "readonly", + $$: "readonly", + $ref: "readonly", + $shallowRef: "readonly", + $computed: "readonly", + + // script setup + defineProps: "readonly", + defineEmits: "readonly", + defineExpose: "readonly", + withDefaults: "readonly" + }, extends: [ "plugin:vue/vue3-essential", "eslint:recommended", diff --git a/package.json b/package.json index e3dbeab9b..a442f2012 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "build": "rimraf dist && cross-env vite build", "preview": "vite preview", "preview:build": "yarn build && vite preview", - "clean:cache": "rm -rf node_modules && yarn cache clean && yarn install", + "clean:cache": "rm -rf node_modules && rm -rf .eslintcache && yarn cache clean && yarn install", "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,css,scss,postcss,less}\" --cache --cache-location node_modules/.cache/stylelint/", diff --git a/src/utils/propTypes.ts b/src/utils/propTypes.ts index 64d566e9c..403b78bc3 100644 --- a/src/utils/propTypes.ts +++ b/src/utils/propTypes.ts @@ -30,4 +30,5 @@ propTypes.extend([ type: undefined } ]); + export { propTypes }; diff --git a/src/views/components/cropping/index.vue b/src/views/components/cropping/index.vue index 20279a442..25cabf53c 100644 --- a/src/views/components/cropping/index.vue +++ b/src/views/components/cropping/index.vue @@ -4,7 +4,7 @@ import Cropper from "/@/components/ReCropper"; import img from "./picture.jpeg"; const instance = getCurrentInstance(); -let info = ref(""); +let info = ref(null); let cropperImg = ref(""); const onCropper = (): void => { diff --git a/src/views/editor/index.vue b/src/views/editor/index.vue index 2c7baddc0..940d13358 100644 --- a/src/views/editor/index.vue +++ b/src/views/editor/index.vue @@ -9,8 +9,8 @@ import { onMounted, onBeforeUnmount, ref, unref } from "vue"; import WangEditor from "wangeditor"; // eslint-disable-next-line no-undef -const editor = ref(null); -const html = ref(null); +const editor = ref(null); +const html = ref(null); let instance: WangEditor; onMounted(() => { diff --git a/src/views/flow-chart/index.vue b/src/views/flow-chart/index.vue index 15decea79..5018dc47c 100644 --- a/src/views/flow-chart/index.vue +++ b/src/views/flow-chart/index.vue @@ -9,8 +9,7 @@ import { toLogicflowData } from "/@/components/ReFlowChart/src/adpterForTurbo"; import { BpmnNode } from "/@/components/ReFlowChart/src/config"; import demoData from "./dataTurbo.json"; -// eslint-disable-next-line no-undef -let lf = ref(null); +let lf = ref(null); let graphData = ref(null); let dataVisible = ref(false); let config = ref({ diff --git a/src/views/system/dict/config.vue b/src/views/system/dict/config.vue index 7ca14427d..4d988f381 100644 --- a/src/views/system/dict/config.vue +++ b/src/views/system/dict/config.vue @@ -1,3 +1,79 @@ + + - - diff --git a/tsconfig.json b/tsconfig.json index 335bf5be0..d1c251b11 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,10 +2,10 @@ "compilerOptions": { "target": "esnext", "module": "esnext", + "moduleResolution": "node", "strict": false, "jsx": "preserve", "importHelpers": true, - "moduleResolution": "node", "experimentalDecorators": true, "strictFunctionTypes": false, "skipLibCheck": true,