From 2077481d89b2fdc3d3c0b46edac4ed2ad4aacb35 Mon Sep 17 00:00:00 2001 From: bqy_fe <1743369777@qq.com> Date: Sun, 6 Jun 2021 21:54:49 +0800 Subject: [PATCH] style: code style --- .eslintrc.js | 16 +-- .vscode/settings.json | 61 +--------- package.json | 18 +-- .../left-aside/components/page-tree/index.vue | 2 +- .../right-attribute-panel/index.tsx | 40 +++--- .../simulator-editor/simulator-editor.vue | 8 +- src/visual-editor/hooks/useVisualData.ts | 15 ++- src/visual-editor/index.vue | 41 ++----- stylelint.config.js | 2 +- yarn.lock | 114 +++++++++--------- 10 files changed, 115 insertions(+), 202 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5b9ecfc..2c555f4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,26 +22,14 @@ module.exports = { 'plugin:prettier/recommended' ], rules: { + '@typescript-eslint/no-unused-vars': 'off', + 'no-unused-vars': 'off', 'vue/require-default-prop': 'off', '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/ban-types': 'off', '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-unused-vars': [ - 'error', - { - argsIgnorePattern: '^_', - varsIgnorePattern: '^_' - } - ], - 'no-unused-vars': [ - 'error', - { - argsIgnorePattern: '^_', - varsIgnorePattern: '^_' - } - ], 'vue/html-self-closing': [ 'error', { diff --git a/.vscode/settings.json b/.vscode/settings.json index bf4724d..9ed484d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { + "cSpell.words": ["windi"], "typescript.tsdk": "./node_modules/typescript/lib", "volar.tsPlugin": true, "volar.tsPluginStatus": false, @@ -7,23 +8,9 @@ //=========================================== "explorer.openEditors.visible": 0, "editor.tabSize": 2, - "editor.renderControlCharacters": true, - "editor.minimap.renderCharacters": false, - "editor.minimap.maxColumn": 300, - "editor.minimap.showSlider": "always", - "editor.cursorBlinking": "phase", - "editor.cursorSmoothCaretAnimation": true, - "editor.detectIndentation": false, "editor.defaultFormatter": "esbenp.prettier-vscode", "diffEditor.ignoreTrimWhitespace": false, - "javascript.format.insertSpaceBeforeFunctionParenthesis": true, - "editor.suggestSelection": "first", "editor.trimAutoWhitespace": true, - "editor.quickSuggestions": { - "other": true, - "comments": true, - "strings": true - }, //=========================================== //============= Other ======================= //=========================================== @@ -34,17 +21,6 @@ //=========================================== "emmet.triggerExpansionOnTab": true, "emmet.showAbbreviationSuggestions": true, - "emmet.showExpandedAbbreviation": "always", - "emmet.syntaxProfiles": { - "vue-html": "html", - "vue": "html", - "xml": { - "attr_quotes": "single" - } - }, - "emmet.includeLanguages": { - "jsx-sublime-babel-tags": "javascriptreact" - }, //=========================================== //============= files ======================= //=========================================== @@ -97,52 +73,22 @@ }, "stylelint.enable": true, "stylelint.packageManager": "yarn", - // ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ - // =========================================== - // ================ Eslint =================== - // =========================================== - "eslint.alwaysShowStatus": true, - "eslint.options": { - "plugins": ["html", "vue", "javascript", "jsx", "typescript"], - "extensions": [".js", ".jsx", ".ts", ".tsx", ".vue"] - }, - "eslint.validate": [ - "javascript", - "typescript", - "reacttypescript", - "reactjavascript", - "html", - "vue" - ], // =========================================== // ================ Vetur ==================== // =========================================== "vetur.experimental.templateInterpolationService": true, "vetur.format.options.tabSize": 2, - "vetur.format.defaultFormatter.html": "js-beautify-html", - "vetur.format.defaultFormatter.scss": "prettier", - "vetur.format.defaultFormatter.css": "prettier", - "vetur.format.defaultFormatter.ts": "prettier-tslint", - "vetur.format.defaultFormatter.js": "prettier", "vetur.languageFeatures.codeActions": false, "vetur.format.defaultFormatterOptions": { "js-beautify-html": { "wrap_attributes": "force-expand-multiline" - }, - "prettier": { - "eslintIntegration": true, - "arrowParens": "always", - "semi": false, - "singleQuote": true } }, "liveServer.settings.donotShowInfoMsg": true, - "terminal.integrated.rendererType": "dom", "telemetry.enableCrashReporter": false, - "telemetry.enableTelemetry": false, "workbench.settings.enableNaturalLanguageSearch": false, "path-intellisense.mappings": { - "/@/": "${workspaceRoot}/src" + "@/": "${workspaceRoot}/src" }, "prettier.requireConfig": true, "typescript.updateImportsOnFileMove.enabled": "always", @@ -177,8 +123,7 @@ }, "[vue]": { "editor.codeActionsOnSave": { - "source.fixAll.eslint": false, - "source.fixAll.stylelint": true + "source.fixAll.eslint": false } }, "i18n-ally.localesPaths": ["src/locales/lang"], diff --git a/package.json b/package.json index 2d7569f..399d3ec 100644 --- a/package.json +++ b/package.json @@ -26,13 +26,13 @@ "axios": "^0.21.1", "dayjs": "^1.10.5", "dexie": "^3.0.3", - "element-plus": "^1.0.2-beta.45", + "element-plus": "^1.0.2-beta.46", "lodash": "^4.17.21", "monaco-editor": "^0.24.0", "normalize.css": "^8.0.1", "nprogress": "^1.0.0-1", "qrcode": "^1.4.4", - "vant": "^3.0.17", + "vant": "^3.0.18", "vue": "3.0.11", "vue-router": "^4.0.8", "vuedraggable": "^4.0.1", @@ -41,7 +41,7 @@ "devDependencies": { "@commitlint/cli": "^12.1.4", "@commitlint/config-conventional": "^12.1.4", - "@types/node": "^15.6.1", + "@types/node": "^15.12.1", "@typescript-eslint/eslint-plugin": "^4.26.0", "@typescript-eslint/parser": "^4.26.0", "@vitejs/plugin-legacy": "^1.4.1", @@ -51,7 +51,7 @@ "commitizen": "^4.2.4", "cz-conventional-changelog": "^3.3.0", "cz-customizable": "^6.3.0", - "eslint": "^7.27.0", + "eslint": "^7.28.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.23.4", "eslint-plugin-prettier": "^3.4.0", @@ -59,21 +59,21 @@ "gh-pages": "^3.2.0", "husky": "^6.0.0", "lint-staged": "^11.0.0", - "prettier": "^2.3.0", + "prettier": "^2.3.1", "pretty-quick": "^3.1.0", - "sass": "1.34.0", + "sass": "1.34.1", "stylelint": "^13.13.1", "stylelint-config-prettier": "^8.0.2", "stylelint-config-standard": "^22.0.0", "stylelint-order": "^4.1.0", "typescript": "^4.3.2", - "vite": "2.3.5", + "vite": "2.3.6", "vite-plugin-components": "^0.10.4", "vite-plugin-style-import": "^0.10.1", - "vite-plugin-windicss": "^0.16.7", + "vite-plugin-windicss": "^1.0.1", "vue-eslint-parser": "^7.6.0", "vue-tsc": "^0.1.7", - "windicss": "^3.0.12" + "windicss": "^3.1.1" }, "repository": { "type": "git", diff --git a/src/visual-editor/components/left-aside/components/page-tree/index.vue b/src/visual-editor/components/left-aside/components/page-tree/index.vue index 467aa67..c15059c 100644 --- a/src/visual-editor/components/left-aside/components/page-tree/index.vue +++ b/src/visual-editor/components/left-aside/components/page-tree/index.vue @@ -153,8 +153,8 @@ export default defineComponent({ return { ...toRefs(state), - setCurrentPage, pages, + setCurrentPage, onSubmit, setDefaultPage, handleNodeClick, diff --git a/src/visual-editor/components/right-attribute-panel/index.tsx b/src/visual-editor/components/right-attribute-panel/index.tsx index 9e2f411..0e1c76c 100644 --- a/src/visual-editor/components/right-attribute-panel/index.tsx +++ b/src/visual-editor/components/right-attribute-panel/index.tsx @@ -5,7 +5,7 @@ * @description:属性编辑器 * @update: 2021/4/28 16:59 */ -import { defineComponent, PropType, reactive } from 'vue' +import { defineComponent, reactive } from 'vue' import styles from './index.module.scss' import './index.common.scss' import { @@ -23,28 +23,22 @@ import { } from 'element-plus' import { VisualEditorProps, VisualEditorPropsType } from '@/visual-editor/visual-editor.props' import { TablePropEditor } from './components/' -import { VisualEditorBlockData } from '@/visual-editor/visual-editor.utils' import MonacoEditor from '../common/monaco-editor/MonacoEditor' -import { useVModel } from '@vueuse/core' import { useDotProp } from '@/visual-editor/hooks/useDotProp' import { useVisualData } from '@/visual-editor/hooks/useVisualData' export default defineComponent({ name: 'RightAttributePanel', - props: { - block: { type: Object as PropType, default: () => ({}) } - }, - setup(props, { emit }) { - const { visualConfig } = useVisualData() + setup() { + const { visualConfig, currentBlock } = useVisualData() const state = reactive({ activeName: 'attr', - isOpen: true, - editData: useVModel(props, 'block', emit) + isOpen: true }) const renderEditor = (propName: string, propConfig: VisualEditorProps) => { - const { propObj, prop } = useDotProp(state.editData.props, propName) + const { propObj, prop } = useDotProp(currentBlock.value.props, propName) return { [VisualEditorPropsType.input]: () => ( @@ -71,28 +65,28 @@ export default defineComponent({ return () => { const content: JSX.Element[] = [] - if (!props.block) { + if (!currentBlock.value) { content.push( <> - + - + ) } else { - const { componentKey } = props.block + const { componentKey } = currentBlock.value const component = visualConfig.componentMap[componentKey] - console.log('props.block:', props.block) + console.log('props.block:', currentBlock.value) content.push( - {props.block._vid} + {currentBlock.value._vid} {{ reference: () => ( @@ -105,9 +99,9 @@ export default defineComponent({ if (!!component) { if (!!component.props) { content.push( - Object.entries(component.props || {}).map(([propName, propConfig]) => ( + ...Object.entries(component.props || {}).map(([propName, propConfig]) => ( propConfig.tips ? ( @@ -135,7 +129,7 @@ export default defineComponent({ const handleSchemaChange = (val) => { try { const newObj = JSON.parse(val) - Object.assign(state.editData, newObj) + Object.assign(currentBlock.value, newObj) } catch (e) { console.log('JSON格式有误:', e) } @@ -156,9 +150,9 @@ export default defineComponent({ diff --git a/src/visual-editor/components/simulator-editor/simulator-editor.vue b/src/visual-editor/components/simulator-editor/simulator-editor.vue index 9c54049..74ab89b 100644 --- a/src/visual-editor/components/simulator-editor/simulator-editor.vue +++ b/src/visual-editor/components/simulator-editor/simulator-editor.vue @@ -36,7 +36,7 @@