Browse Source

添加vue3模板

pull/1/head
wanggang 1 year ago
parent
commit
5c43818876
  1. 13
      code/WebApp/vue3/.editorconfig
  2. 3
      code/WebApp/vue3/.eslintignore
  3. 51
      code/WebApp/vue3/.eslintrc.js
  4. 10
      code/WebApp/vue3/.gitignore
  5. 4
      code/WebApp/vue3/.husky/pre-commit
  6. 3
      code/WebApp/vue3/.markdownlint.json
  7. 2
      code/WebApp/vue3/.markdownlintignore
  8. 1
      code/WebApp/vue3/.npmrc
  9. 6
      code/WebApp/vue3/.prettierignore
  10. 21
      code/WebApp/vue3/.prettierrc.js
  11. 2
      code/WebApp/vue3/.stylelintignore
  12. 20
      code/WebApp/vue3/.stylelintrc.js
  13. 12
      code/WebApp/vue3/.vscode/extensions.json
  14. 39
      code/WebApp/vue3/.vscode/settings.json
  15. 7
      code/WebApp/vue3/README.md
  16. 51
      code/WebApp/vue3/eslintrc.js
  17. 13
      code/WebApp/vue3/index.html
  18. 10
      code/WebApp/vue3/jsconfig.json
  19. 13541
      code/WebApp/vue3/package-lock.json
  20. 113
      code/WebApp/vue3/package.json
  21. 1
      code/WebApp/vue3/public/vite.svg
  22. 46
      code/WebApp/vue3/src/App.vue
  23. 1
      code/WebApp/vue3/src/assets/vue.svg
  24. 51
      code/WebApp/vue3/src/components/HelloWorld.vue
  25. 7
      code/WebApp/vue3/src/main.js
  26. 83
      code/WebApp/vue3/src/style.css
  27. 62
      code/WebApp/vue3/vite.config.js

13
code/WebApp/vue3/.editorconfig

@ -0,0 +1,13 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

3
code/WebApp/vue3/.eslintignore

@ -0,0 +1,3 @@
package-lock.json
node_modules
dist

51
code/WebApp/vue3/.eslintrc.js

@ -0,0 +1,51 @@
const { readGitignoreFiles } = require('eslint-gitignore');
module.exports = {
root: true,
ignorePatterns: [...readGitignoreFiles()],
env: {
browser: true,
node: true,
},
plugins: ['simple-import-sort'],
extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:vue/vue3-recommended',
'plugin:vue-scoped-css/vue3-recommended',
'airbnb-base',
'plugin:prettier/recommended',
// vite 启动时自动生成
'./.eslintrc-auto-import.json',
],
parser: 'vue-eslint-parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
rules: {
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
// import 可以从 devDependencies 中导入
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'import/no-unresolved': 'off',
'import/extensions': 'off',
'func-names': 'off',
'prefer-regex-literals': 'off',
'no-console': 'off',
'no-alert': 'off',
'no-return-assign': 'off',
'no-unused-expressions': 'off',
'no-param-reassign': 'off',
'no-unused-vars': 'warn',
'no-empty': 'warn',
'vue/multi-word-component-names': 'off',
'vue/no-v-html': 'off',
},
globals: {
defineOptions: 'readonly',
},
};

10
code/WebApp/vue3/.gitignore

@ -0,0 +1,10 @@
node_modules
dist
dist-ssr
.vite-inspect
# vscode local history plugin
*.local
# macOS
.DS_Store
# vite auto import plugin
.eslintrc-auto-import.json

4
code/WebApp/vue3/.husky/pre-commit

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged

3
code/WebApp/vue3/.markdownlint.json

@ -0,0 +1,3 @@
{
"MD013": false
}

2
code/WebApp/vue3/.markdownlintignore

@ -0,0 +1,2 @@
**/node_modules
**/dist

1
code/WebApp/vue3/.npmrc

@ -0,0 +1 @@
engine-strict = true

6
code/WebApp/vue3/.prettierignore

@ -0,0 +1,6 @@
node_modules
dist
package-lock.json
**/*.svg
index.html
/*.json

21
code/WebApp/vue3/.prettierrc.js

@ -0,0 +1,21 @@
module.exports = {
printWidth: 120,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
quoteProps: 'as-needed',
jsxSingleQuote: false,
trailingComma: 'all',
bracketSpacing: true,
arrowParens: 'always',
rangeStart: 0,
rangeEnd: Infinity,
requirePragma: false,
insertPragma: false,
proseWrap: 'preserve',
htmlWhitespaceSensitivity: 'css',
vueIndentScriptAndStyle: false,
singleAttributePerLine: true,
endOfLine: 'lf',
};

2
code/WebApp/vue3/.stylelintignore

@ -0,0 +1,2 @@
node_modules
dist

20
code/WebApp/vue3/.stylelintrc.js

@ -0,0 +1,20 @@
module.exports = {
extends: [
'stylelint-config-standard-scss',
'stylelint-config-html',
'stylelint-config-recommended-vue',
'stylelint-config-rational-order',
'stylelint-config-prettier-scss',
],
defaultSeverity: 'warning',
plugins: ['stylelint-order'],
rules: {
'at-rule-no-unknown': null,
'selector-class-pattern': [
'^[a-z0-9-_]+$',
{
message: 'Expected class selector to be kebab-case',
},
],
},
};

12
code/WebApp/vue3/.vscode/extensions.json

@ -0,0 +1,12 @@
{
"recommendations": [
"howardzuo.vscode-npm-dependency",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"rvest.vs-code-prettier-eslint",
"stylelint.vscode-stylelint",
"davidanson.vscode-markdownlint",
"vue.volar"
]
}

39
code/WebApp/vue3/.vscode/settings.json

@ -0,0 +1,39 @@
{
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.formatOnPaste": false,
"editor.formatOnType": false,
"files.autoSave": "onFocusChange",
"eslint.alwaysShowStatus": true,
"eslint.probe": ["javascript", "javascriptreact", "typescript", "typescriptreact", "json", "vue", "jsx"],
"css.validate": false,
"less.validate": false,
"scss.validate": false,
"stylelint.validate": ["css", "less", "sass", "postcss", "vue"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
},
"[html]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[javascript]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[json]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[css]": {
"editor.defaultFormatter": "stylelint.vscode-stylelint"
},
"[scss]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[markdown]": {
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
},
"[vue]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"prettier.printWidth": 120
}

7
code/WebApp/vue3/README.md

@ -0,0 +1,7 @@
# Vue 3 + Vite
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
## Recommended IDE Setup
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).

51
code/WebApp/vue3/eslintrc.js

@ -0,0 +1,51 @@
const { readGitignoreFiles } = require('eslint-gitignore');
module.exports = {
root: true,
ignorePatterns: [...readGitignoreFiles()],
env: {
browser: true,
node: true,
},
plugins: ['simple-import-sort'],
extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:vue/vue3-recommended',
'plugin:vue-scoped-css/vue3-recommended',
'airbnb-base',
'plugin:prettier/recommended',
// vite 启动时自动生成
'./.eslintrc-auto-import.json',
],
parser: 'vue-eslint-parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
rules: {
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
// import 可以从 devDependencies 中导入
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'import/no-unresolved': 'off',
'import/extensions': 'off',
'func-names': 'off',
'prefer-regex-literals': 'off',
'no-console': 'off',
'no-alert': 'off',
'no-return-assign': 'off',
'no-unused-expressions': 'off',
'no-param-reassign': 'off',
'no-unused-vars': 'warn',
'no-empty': 'warn',
'vue/multi-word-component-names': 'off',
'vue/no-v-html': 'off',
},
globals: {
defineOptions: 'readonly',
},
};

13
code/WebApp/vue3/index.html

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

10
code/WebApp/vue3/jsconfig.json

@ -0,0 +1,10 @@
{
"exclude": ["node_modules"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["src/*"]
},
"jsx": "preserve"
}
}

13541
code/WebApp/vue3/package-lock.json

File diff suppressed because it is too large

113
code/WebApp/vue3/package.json

@ -0,0 +1,113 @@
{
"name": "web-template-vue",
"private": true,
"version": "0.1.0",
"engineStrict": true,
"engines": {
"node": ">=16",
"npm": ">=8"
},
"scripts": {
"dev": "vite",
"dev:mock": "vite --mode mock",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint . --ext .js,.jsx,.vue && stylelint \"**/*.{css,scss,html,vue}\" && markdownlint \"**/*.md\"",
"lint:fix": "eslint --fix --ext .js,.jsx,.vue && stylelint \"**/*.{css,scss,html,vue}\" --fix && markdownlint \"**/*.md\" --fix && prettier --write .",
"lint-staged": "npx lint-staged",
"prepare": "cd ../../../&&husky install code/WebApp/vue3/.husky"
},
"lint-staged": {
"*.{js,ts,jsx,tsx}": [
"prettier --write",
"eslint --fix",
"git add ."
],
"*.vue": [
"stylelint --fix",
"prettier --write",
"eslint --fix",
"git add ."
],
"*.{css,less,scss}": [
"stylelint --fix",
"prettier --write",
"git add ."
],
"*.md": [
"markdownlint --fix",
"prettier --write",
"git add ."
]
},
"dependencies": {
"@ckeditor/ckeditor5-build-classic": "^38.0.1",
"@ckeditor/ckeditor5-upload": "^38.0.1",
"@ckeditor/ckeditor5-vue": "^5.1.0",
"@vueuse/core": "^10.2.0",
"async-validator": "^4.2.5",
"axios": "^1.4.0",
"better-mock": "^0.3.6",
"dayjs": "^1.11.8",
"echarts": "^5.4.2",
"element-plus": "^2.3.7",
"javascript-state-machine": "^3.1.0",
"jose": "^4.14.4",
"jsrsasign": "^10.8.6",
"linq": "^4.0.1",
"localforage": "^1.10.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"loglevel": "^1.8.1",
"mitt": "^3.0.0",
"mrmime": "^1.0.1",
"nprogress": "^0.2.0",
"pinia": "^2.1.4",
"qrcode.vue": "^3.4.0",
"qs": "^6.11.2",
"query-string": "^8.1.0",
"vant": "4.6.0",
"vue": "^3.3.4",
"vue-echarts": "^6.6.0",
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.2",
"wsmock-js": "^1.1.1"
},
"devDependencies": {
"@iconify/json": "^2.2.83",
"@unocss/preset-attributify": "^0.53.4",
"@unocss/preset-uno": "^0.53.4",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"eslint": "^8.43.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.8.0",
"eslint-gitignore": "^0.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-vue": "^9.15.1",
"eslint-plugin-vue-scoped-css": "^2.4.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"markdownlint-cli": "^0.35.0",
"prettier": "^2.8.8",
"sass": "^1.63.6",
"stylelint": "^15.9.0",
"stylelint-config-html": "^1.1.0",
"stylelint-config-prettier-scss": "^1.0.0",
"stylelint-config-rational-order": "^0.1.2",
"stylelint-config-recommended-vue": "^1.4.0",
"stylelint-config-standard-scss": "^9.0.0",
"stylelint-order": "^6.0.3",
"unocss": "^0.53.4",
"unplugin-auto-import": "^0.16.4",
"unplugin-icons": "^0.16.3",
"unplugin-vue-components": "^0.25.1",
"unplugin-vue-define-options": "^1.3.8",
"vite": "^4.3.9",
"vite-plugin-inspect": "^0.7.29",
"vite-svg-loader": "^4.0.0",
"vue-eslint-parser": "^9.3.1"
}
}

1
code/WebApp/vue3/public/vite.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

46
code/WebApp/vue3/src/App.vue

@ -0,0 +1,46 @@
<script setup>
import HelloWorld from './components/HelloWorld.vue';
</script>
<template>
<div>
<a
href="https://vitejs.dev"
target="_blank"
>
<img
src="/vite.svg"
class="logo"
alt="Vite logo"
/>
</a>
<a
href="https://vuejs.org/"
target="_blank"
>
<img
src="./assets/vue.svg"
class="logo vue"
alt="Vue logo"
/>
</a>
</div>
<HelloWorld msg="Vite + Vue" />
</template>
<style scoped>
.logo {
height: 6em;
padding: 1.5em;
transition: filter 300ms;
will-change: filter;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {
filter: drop-shadow(0 0 2em #42b883aa);
}
</style>

1
code/WebApp/vue3/src/assets/vue.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

After

Width:  |  Height:  |  Size: 496 B

51
code/WebApp/vue3/src/components/HelloWorld.vue

@ -0,0 +1,51 @@
<script setup>
import { ref } from 'vue';
defineProps({
msg: { type: String, default: '' },
});
const count = ref(0);
</script>
<template>
<h1>{{ msg }}</h1>
<div class="card">
<button
type="button"
@click="count++"
>
count is {{ count }}
</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test HMR
</p>
</div>
<p>
Check out
<a
href="https://vuejs.org/guide/quick-start.html#local"
target="_blank"
>create-vue</a
>, the official Vue + Vite starter
</p>
<p>
Install
<a
href="https://github.com/vuejs/language-tools"
target="_blank"
>Volar</a
>
in your IDE for a better DX
</p>
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
</template>
<style scoped>
.read-the-docs {
color: #888;
}
</style>

7
code/WebApp/vue3/src/main.js

@ -0,0 +1,7 @@
import './style.css';
import { createApp } from 'vue';
import App from './App.vue';
createApp(App).mount('#app');

83
code/WebApp/vue3/src/style.css

@ -0,0 +1,83 @@
:root {
color: rgb(255 255 255 / 87%);
font-weight: 400;
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
background-color: #242424;
color-scheme: light dark;
font-synthesis: none;
text-rendering: optimizelegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-size-adjust: 100%;
}
a {
color: #646cff;
font-weight: 500;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
display: flex;
min-width: 320px;
min-height: 100vh;
margin: 0;
place-items: center;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
padding: 0.6em 1.2em;
font-weight: 500;
font-size: 1em;
font-family: inherit;
background-color: #1a1a1a;
border: 1px solid transparent;
border-radius: 8px;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
.card {
padding: 2em;
}
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #fff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}

62
code/WebApp/vue3/vite.config.js

@ -0,0 +1,62 @@
import presetAttributify from '@unocss/preset-attributify';
import presetUno from '@unocss/preset-uno';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import unocss from 'unocss/vite';
import autoImport from 'unplugin-auto-import/vite';
import IconsResolver from 'unplugin-icons/resolver';
import icons from 'unplugin-icons/vite';
import { ElementPlusResolver, VantResolver } from 'unplugin-vue-components/resolvers';
import components from 'unplugin-vue-components/vite';
import DefineOptions from 'unplugin-vue-define-options/vite';
import { defineConfig } from 'vite';
import inspect from 'vite-plugin-inspect';
import svgLoader from 'vite-svg-loader';
const autoImportOptions = {
imports: ['vue', 'vue-router', 'pinia', '@vueuse/core'],
dirs: ['src/components'],
vueTemplate: true,
eslintrc: {
enabled: true,
},
};
const componentoptions = {
resolvers: [
IconsResolver({
enabledCollections: ['ep'],
}),
ElementPlusResolver(),
VantResolver(),
],
};
const unocssOptions = {
presets: [presetAttributify(), presetUno()],
};
export default defineConfig({
base: '/web-template-vue/',
build: {
target: 'esnext', // top await
module: 'esm',
},
resolve: {
alias: {
'~/': new URL('./src/', import.meta.url).pathname,
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
},
},
plugins: [
vue(),
vueJsx(),
DefineOptions(),
inspect(),
autoImport(autoImportOptions),
unocss(unocssOptions),
icons(),
svgLoader(),
components(componentoptions),
],
});
Loading…
Cancel
Save