From 7f6ed517a035c1c6cefb5ecbf7cc3bf87b9ff4ca Mon Sep 17 00:00:00 2001 From: purocean Date: Mon, 26 Oct 2020 20:11:29 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=88=B0=20Vue=203.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- .yarnrc | 1 + frontend/.browserslistrc | 2 +- frontend/.eslintrc.js | 36 +- frontend/.gitignore | 2 + frontend/.yarnrc | 1 + frontend/README.md | 12 +- frontend/babel.config.js | 2 +- frontend/package.json | 93 +- frontend/postcss.config.js | 5 - frontend/public/index.html | 2 + frontend/src/App.vue | 18 +- frontend/src/components/ContextMenu.vue | 118 +- frontend/src/components/Editor.vue | 354 +- frontend/src/components/FileTabs.vue | 161 +- frontend/src/components/Filter.vue | 84 +- frontend/src/components/Layout.vue | 162 +- frontend/src/components/Mask.vue | 36 +- frontend/src/components/ModalUi.vue | 132 +- frontend/src/components/MonacoEditor.vue | 493 +- frontend/src/components/Preview.vue | 495 +- frontend/src/components/QuickOpen.vue | 385 +- frontend/src/components/RepositorySwitch.vue | 108 +- frontend/src/components/StatusBar.vue | 101 +- frontend/src/components/SvgIcon.vue | 43 + frontend/src/components/Tabs.vue | 133 +- frontend/src/components/TitleBar.vue | 239 +- frontend/src/components/Toast.vue | 35 +- frontend/src/components/Tree.vue | 105 +- frontend/src/components/TreeNode.vue | 434 +- frontend/src/components/Xterm.vue | 147 +- frontend/src/contextMenu.js | 11 - frontend/src/lib/env.js | 26 - frontend/src/main.js | 27 - frontend/src/main.ts | 20 + frontend/src/modal.js | 11 - frontend/src/pages/Main.vue | 73 - .../{AppletPlugin.js => AppletPlugin.ts} | 30 +- frontend/src/plugins/CodePlugin.js | 12 - frontend/src/plugins/CodePlugin.ts | 14 + .../{DrawioPlugin.js => DrawioPlugin.ts} | 61 +- .../{EChartsPlugin.js => EChartsPlugin.ts} | 32 +- ...berPlugin.js => HightLightNumberPlugin.ts} | 20 +- frontend/src/plugins/LinkTargetPlugin.js | 13 - frontend/src/plugins/LinkTargetPlugin.ts | 13 + frontend/src/plugins/MermaidPlugin.js | 56 - frontend/src/plugins/MermaidPlugin.ts | 35 + frontend/src/plugins/PlantumlPlugin.js | 140 - frontend/src/plugins/PlantumlPlugin.ts | 138 + .../plugins/{RunPlugin.js => RunPlugin.ts} | 5 +- ...ourceLinePlugin.js => SourceLinePlugin.ts} | 11 +- .../plugins/{TocPlugin.js => TocPlugin.ts} | 141 +- frontend/src/router.js | 12 - frontend/src/router.ts | 17 + frontend/src/shims-vue.d.ts | 18 + frontend/src/store.js | 16 - frontend/src/{store/app.js => store.ts} | 32 +- frontend/src/store/index.js | 13 - frontend/src/toast.js | 11 - frontend/src/types.ts | 48 + frontend/src/useful/bus.ts | 30 + frontend/src/useful/context-menu.ts | 22 + frontend/src/useful/copy-text.ts | 23 + .../src/{lib/Crypto.js => useful/crypto.ts} | 18 +- frontend/src/useful/env.ts | 32 + .../extensions.js => useful/extensions.ts} | 2 +- frontend/src/{lib/file.js => useful/file.ts} | 53 +- .../fuzzyMatch.js => useful/fuzzy-match.ts} | 4 +- frontend/src/useful/global-args.ts | 3 + frontend/src/useful/modal.ts | 23 + frontend/src/useful/startup.ts | 22 + .../src/{lib/Storage.js => useful/storage.ts} | 4 +- frontend/src/useful/toast.ts | 22 + .../src/{lib/utils.js => useful/utils.ts} | 2 +- frontend/src/views/Main.vue | 66 + frontend/tests/unit/example.spec.ts | 13 + frontend/tsconfig.json | 41 + frontend/yarn.lock | 11250 +++++++++------- help/FEATURES.md | 74 +- 79 files changed, 9141 insertions(+), 7560 deletions(-) create mode 100644 .yarnrc create mode 100644 frontend/.yarnrc delete mode 100644 frontend/postcss.config.js create mode 100644 frontend/src/components/SvgIcon.vue delete mode 100644 frontend/src/contextMenu.js delete mode 100644 frontend/src/lib/env.js delete mode 100644 frontend/src/main.js create mode 100644 frontend/src/main.ts delete mode 100644 frontend/src/modal.js delete mode 100644 frontend/src/pages/Main.vue rename frontend/src/plugins/{AppletPlugin.js => AppletPlugin.ts} (82%) delete mode 100644 frontend/src/plugins/CodePlugin.js create mode 100644 frontend/src/plugins/CodePlugin.ts rename frontend/src/plugins/{DrawioPlugin.js => DrawioPlugin.ts} (71%) rename frontend/src/plugins/{EChartsPlugin.js => EChartsPlugin.ts} (64%) rename frontend/src/plugins/{HightLightNumberPlugin.js => HightLightNumberPlugin.ts} (87%) delete mode 100644 frontend/src/plugins/LinkTargetPlugin.js create mode 100644 frontend/src/plugins/LinkTargetPlugin.ts delete mode 100644 frontend/src/plugins/MermaidPlugin.js create mode 100644 frontend/src/plugins/MermaidPlugin.ts delete mode 100644 frontend/src/plugins/PlantumlPlugin.js create mode 100644 frontend/src/plugins/PlantumlPlugin.ts rename frontend/src/plugins/{RunPlugin.js => RunPlugin.ts} (95%) rename frontend/src/plugins/{SourceLinePlugin.js => SourceLinePlugin.ts} (56%) rename frontend/src/plugins/{TocPlugin.js => TocPlugin.ts} (77%) delete mode 100644 frontend/src/router.js create mode 100644 frontend/src/router.ts create mode 100644 frontend/src/shims-vue.d.ts delete mode 100644 frontend/src/store.js rename frontend/src/{store/app.js => store.ts} (80%) delete mode 100644 frontend/src/store/index.js delete mode 100644 frontend/src/toast.js create mode 100644 frontend/src/types.ts create mode 100644 frontend/src/useful/bus.ts create mode 100644 frontend/src/useful/context-menu.ts create mode 100644 frontend/src/useful/copy-text.ts rename frontend/src/{lib/Crypto.js => useful/crypto.ts} (76%) create mode 100644 frontend/src/useful/env.ts rename frontend/src/{lib/extensions.js => useful/extensions.ts} (97%) rename frontend/src/{lib/file.js => useful/file.ts} (73%) rename frontend/src/{lib/fuzzyMatch.js => useful/fuzzy-match.ts} (97%) create mode 100644 frontend/src/useful/global-args.ts create mode 100644 frontend/src/useful/modal.ts create mode 100644 frontend/src/useful/startup.ts rename frontend/src/{lib/Storage.js => useful/storage.ts} (70%) create mode 100644 frontend/src/useful/toast.ts rename frontend/src/{lib/utils.js => useful/utils.ts} (64%) create mode 100644 frontend/src/views/Main.vue create mode 100644 frontend/tests/unit/example.spec.ts create mode 100644 frontend/tsconfig.json diff --git a/.gitignore b/.gitignore index 14bf7101..47ad7f2f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,6 @@ dist vs out bin -.yarnrc +# .yarnrc b.bat *.pfx diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 00000000..b4a8ce4f --- /dev/null +++ b/.yarnrc @@ -0,0 +1 @@ +registry "https://registry.yarnpkg.com" diff --git a/frontend/.browserslistrc b/frontend/.browserslistrc index 9dee6464..214388fe 100644 --- a/frontend/.browserslistrc +++ b/frontend/.browserslistrc @@ -1,3 +1,3 @@ > 1% last 2 versions -not ie <= 8 +not dead diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 16be3646..9e01c2e2 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -3,16 +3,32 @@ module.exports = { env: { node: true }, - 'extends': [ - 'plugin:vue/essential', - '@vue/standard' + extends: [ + 'plugin:vue/vue3-essential', + '@vue/standard', + '@vue/typescript/recommended' ], - rules: { - 'comma-dangle': 'off', - 'no-console': 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' - }, parserOptions: { - parser: 'babel-eslint' - } + ecmaVersion: 2020 + }, + rules: { + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/camelcase': 'off', + '@typescript-eslint/no-namespace': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'comma-dangle': 'off', + }, + overrides: [ + { + files: [ + '**/__tests__/*.{j,t}s?(x)', + '**/tests/unit/**/*.spec.{j,t}s?(x)' + ], + env: { + mocha: true + } + } + ] } diff --git a/frontend/.gitignore b/frontend/.gitignore index a0dddc6f..403adbc1 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -2,6 +2,7 @@ node_modules /dist + # local env files .env.local .env.*.local @@ -10,6 +11,7 @@ node_modules npm-debug.log* yarn-debug.log* yarn-error.log* +pnpm-debug.log* # Editor directories and files .idea diff --git a/frontend/.yarnrc b/frontend/.yarnrc new file mode 100644 index 00000000..b4a8ce4f --- /dev/null +++ b/frontend/.yarnrc @@ -0,0 +1 @@ +registry "https://registry.yarnpkg.com" diff --git a/frontend/README.md b/frontend/README.md index e690f90a..a6ceac3f 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -1,4 +1,4 @@ -# frontend2 +# frontend-vue3 ## Project setup ``` @@ -7,22 +7,22 @@ yarn install ### Compiles and hot-reloads for development ``` -yarn run serve +yarn serve ``` ### Compiles and minifies for production ``` -yarn run build +yarn build ``` -### Run your tests +### Run your unit tests ``` -yarn run test +yarn test:unit ``` ### Lints and fixes files ``` -yarn run lint +yarn lint ``` ### Customize configuration diff --git a/frontend/babel.config.js b/frontend/babel.config.js index ba179669..e9558405 100644 --- a/frontend/babel.config.js +++ b/frontend/babel.config.js @@ -1,5 +1,5 @@ module.exports = { presets: [ - '@vue/app' + '@vue/cli-plugin-babel/preset' ] } diff --git a/frontend/package.json b/frontend/package.json index a6f0a3c9..9deb4e95 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,52 +1,77 @@ { - "name": "frontend", + "name": "yn-frontend", "version": "0.1.0", "private": true, "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", + "test:unit": "vue-cli-service test:unit", "lint": "vue-cli-service lint" }, "dependencies": { - "core-js": "^2.6.5", - "crypto-js": "^3.1.9-1", - "dayjs": "^1.8.12", - "echarts": "^4.2.1", - "github-markdown-css": "^3.0.1", - "highlight": "^0.2.4", - "highlight.js": "^9.15.6", + "core-js": "^3.6.5", + "crypto-js": "^4.0.0", + "dayjs": "^1.9.3", + "echarts": "^4.9.0", + "github-markdown-css": "^4.0.0", + "highlight.js": "^10.3.1", "katex": "^0.6.0", - "markdown-it": "^8.4.2", - "markdown-it-attrs": "^2.3.2", + "loadsh": "^0.0.4", + "markdown-it": "^12.0.1", + "markdown-it-attrs": "^3.0.3", "markdown-it-footnote": "^3.0.2", "markdown-it-katex": "^2.0.3", - "markdown-it-multimd-table": "^3.1.3", + "markdown-it-multimd-table": "^4.0.3", "markdown-it-task-lists": "^2.1.1", - "mermaid": "^8.2.6", - "mime-types": "^2.1.24", - "monaco-editor": "^0.17.1", + "mermaid": "^8.8.2", + "mime-types": "^2.1.27", + "mitt": "^2.1.0", + "monaco-editor": "^0.21.2", "normalize.css": "^8.0.1", - "socket.io-client": "^2.2.0", - "sortablejs": "^1.10.1", - "transliteration": "^2.1.3", - "turndown": "^5.0.3", - "vue": "^2.6.10", - "vue-awesome": "^3.5.4", - "vue-bus": "^1.2.1", - "vue-router": "^3.0.3", - "vuex": "^3.0.1", - "xterm": "^3.12.2" + "socket.io-client": "^2.3.1", + "sortablejs": "^1.12.0", + "transliteration": "^2.1.11", + "turndown": "^7.0.0", + "vue": "^3.0.0", + "vue-router": "^4.0.0-0", + "vuex": "^4.0.0-0", + "xterm": "^4.9.0", + "xterm-addon-fit": "^0.4.0" }, "devDependencies": { - "@vue/cli-plugin-babel": "^3.6.0", - "@vue/cli-plugin-eslint": "^3.6.0", - "@vue/cli-service": "^3.6.0", - "@vue/eslint-config-standard": "^4.0.0", - "babel-eslint": "^10.0.1", - "eslint": "^5.16.0", - "eslint-plugin-vue": "^5.0.0", - "less": "^3.0.4", - "less-loader": "^4.1.0", - "vue-template-compiler": "^2.5.21" + "@types/chai": "^4.2.11", + "@types/crypto-js": "^4.0.1", + "@types/echarts": "^4.8.3", + "@types/lodash": "^4.14.162", + "@types/markdown-it": "^10.0.2", + "@types/mermaid": "^8.2.1", + "@types/mime-types": "^2.1.0", + "@types/mocha": "^5.2.4", + "@types/socket.io-client": "^1.4.34", + "@types/sortablejs": "^1.10.6", + "@types/turndown": "^5.0.0", + "@typescript-eslint/eslint-plugin": "^2.33.0", + "@typescript-eslint/parser": "^2.33.0", + "@vue/cli-plugin-babel": "~4.5.0", + "@vue/cli-plugin-eslint": "~4.5.0", + "@vue/cli-plugin-router": "~4.5.0", + "@vue/cli-plugin-typescript": "~4.5.0", + "@vue/cli-plugin-unit-mocha": "~4.5.0", + "@vue/cli-plugin-vuex": "~4.5.0", + "@vue/cli-service": "~4.5.0", + "@vue/compiler-sfc": "^3.0.0", + "@vue/eslint-config-standard": "^5.1.2", + "@vue/eslint-config-typescript": "^5.0.2", + "@vue/test-utils": "^2.0.0-0", + "chai": "^4.1.2", + "eslint": "^6.7.2", + "eslint-plugin-import": "^2.20.2", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-standard": "^4.0.0", + "eslint-plugin-vue": "^7.0.0-0", + "sass": "^1.26.5", + "sass-loader": "^8.0.2", + "typescript": "~3.9.3" } } diff --git a/frontend/postcss.config.js b/frontend/postcss.config.js deleted file mode 100644 index 961986e2..00000000 --- a/frontend/postcss.config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - plugins: { - autoprefixer: {} - } -} diff --git a/frontend/public/index.html b/frontend/public/index.html index 86dff2a2..204dc82b 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -2,7 +2,9 @@ + + Yank Note - - diff --git a/frontend/src/components/Tabs.vue b/frontend/src/components/Tabs.vue index 5371a0d3..fe4ed310 100644 --- a/frontend/src/components/Tabs.vue +++ b/frontend/src/components/Tabs.vue @@ -1,5 +1,5 @@ - diff --git a/frontend/src/components/Toast.vue b/frontend/src/components/Toast.vue index d63c5d1c..7d0a11c3 100644 --- a/frontend/src/components/Toast.vue +++ b/frontend/src/components/Toast.vue @@ -2,24 +2,33 @@
{{toast.content}}
-