From 2040500af14d277a79f01eba5eca2a440203cecf Mon Sep 17 00:00:00 2001 From: kailong321200875 <321200875@qq.com> Date: Sat, 11 Dec 2021 11:46:10 +0800 Subject: [PATCH] build(pinia): Add pinia build(vite-plugin-vue-setup-extend): Delete vite-plugin-vue-setup-extend build(unplugin-auto-import): Delete unplugin-auto-import build(unplugin-vue-components): Delete unplugin-vue-components build(vite-plugin-style-import): Add vite-plugin-style-import --- .eslintrc.js | 16 +- .pnpm-debug.log | 8 +- .vscode/settings.json | 9 +- log.md | 2 + package.json | 12 +- pnpm-lock.yaml | 404 ++++++++++++++++++++++++--- .prettierrc.js => prettier.config.js | 0 src/App.vue | 51 +--- src/components/Form/index.ts | 3 + src/components/Form/src/BfForm.vue | 10 + src/components/HelloWorld.vue | 50 ---- src/components/index.ts | 6 + src/main.ts | 8 + src/store/index.ts | 10 + src/store/modules/app.ts | 155 ++++++++++ src/types/auto-imports.d.ts | 194 ------------- src/types/components.d.ts | 15 - src/types/v-components.d.ts | 7 + src/utils/index.ts | 18 ++ src/utils/prop-types.ts | 20 -- src/utils/propTypes.ts | 31 ++ tsconfig.json | 8 +- vite.config.ts | 62 ++-- 23 files changed, 683 insertions(+), 416 deletions(-) rename .prettierrc.js => prettier.config.js (100%) create mode 100644 src/components/Form/index.ts create mode 100644 src/components/Form/src/BfForm.vue delete mode 100644 src/components/HelloWorld.vue create mode 100644 src/components/index.ts create mode 100644 src/store/index.ts create mode 100644 src/store/modules/app.ts delete mode 100644 src/types/auto-imports.d.ts delete mode 100644 src/types/components.d.ts create mode 100644 src/utils/index.ts delete mode 100644 src/utils/prop-types.ts create mode 100644 src/utils/propTypes.ts diff --git a/.eslintrc.js b/.eslintrc.js index c75fe03..bd65d17 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -37,20 +37,8 @@ module.exports = defineConfig({ '@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: '^_' - } - ], + '@typescript-eslint/no-unused-vars': 'error', + 'no-unused-vars': 'error', 'space-before-function-paren': 'off', 'vue/attributes-order': 'off', diff --git a/.pnpm-debug.log b/.pnpm-debug.log index 65e3d7e..bc5959c 100644 --- a/.pnpm-debug.log +++ b/.pnpm-debug.log @@ -5,15 +5,15 @@ "1 error pnpm": { "errno": 1, "code": "ELIFECYCLE", - "pkgid": "new-element-plus-admin@0.0.0", + "pkgid": "butterfly-admin@3.0.0", "stage": "clean", "script": "npx rimraf docs/node_modules && npx rimraf node_modules", - "pkgname": "new-element-plus-admin", + "pkgname": "butterfly-admin", "err": { "name": "pnpm", - "message": "new-element-plus-admin@0.0.0 clean: `npx rimraf docs/node_modules && npx rimraf node_modules`\nExit status 1", + "message": "butterfly-admin@3.0.0 clean: `npx rimraf docs/node_modules && npx rimraf node_modules`\nExit status 1", "code": "ELIFECYCLE", - "stack": "pnpm: new-element-plus-admin@0.0.0 clean: `npx rimraf docs/node_modules && npx rimraf node_modules`\nExit status 1\n at EventEmitter. (C:\\Users\\admin\\AppData\\Roaming\\nvm\\v16.0.0\\node_modules\\pnpm\\dist\\pnpm.cjs:103540:20)\n at EventEmitter.emit (node:events:365:28)\n at ChildProcess. (C:\\Users\\admin\\AppData\\Roaming\\nvm\\v16.0.0\\node_modules\\pnpm\\dist\\pnpm.cjs:91469:18)\n at ChildProcess.emit (node:events:365:28)\n at maybeClose (node:internal/child_process:1067:16)\n at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)" + "stack": "pnpm: butterfly-admin@3.0.0 clean: `npx rimraf docs/node_modules && npx rimraf node_modules`\nExit status 1\n at EventEmitter. (C:\\Users\\Saber\\AppData\\Roaming\\nvm\\v16.0.0\\node_modules\\pnpm\\dist\\pnpm.cjs:103540:20)\n at EventEmitter.emit (node:events:365:28)\n at ChildProcess. (C:\\Users\\Saber\\AppData\\Roaming\\nvm\\v16.0.0\\node_modules\\pnpm\\dist\\pnpm.cjs:91469:18)\n at ChildProcess.emit (node:events:365:28)\n at maybeClose (node:internal/child_process:1067:16)\n at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)" } } } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index a304eeb..2dffb99 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,5 +7,12 @@ "[vue]": { "editor.defaultFormatter": "johnsoncodehk.volar" }, - "i18n-ally.localesPaths": ["src/locales", "src/plugins/i18n"] + "i18n-ally.localesPaths": ["src/locales"], + "i18n-ally.keystyle": "nested", + "i18n-ally.sortKeys": true, + "i18n-ally.namespace": true, + "i18n-ally.enabledParsers": ["ts"], + "i18n-ally.sourceLanguage": "en", + "i18n-ally.displayLanguage": "zh-CN", + "i18n-ally.enabledFrameworks": ["vue", "react"] } diff --git a/log.md b/log.md index 1e72aff..c5bb2f3 100644 --- a/log.md +++ b/log.md @@ -1 +1,3 @@ vscode 安装 WindiCSS IntelliSense + +自动导入太慢了。所以暂时不使用这种方案 diff --git a/package.json b/package.json index beacf85..215e16e 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "serve:pro": "vite preview --mode pro", "serve:dev": "vite preview --mode dev", "serve:test": "vite preview --mode test", - "check": "npx npm-check-updates", + "npm:check": "npx npm-check-updates", "clean": "npx rimraf docs/node_modules && npx rimraf node_modules", "clean:cache": "npx rimraf node_modules/.cache", "lint:eslint": "eslint --fix --ext .js,.ts,.vue ./src", @@ -26,7 +26,8 @@ }, "dependencies": { "@vueuse/core": "^7.1.2", - "element-plus": "^1.2.0-beta.5", + "element-plus": "1.2.0-beta.6", + "pinia": "^2.0.6", "vue": "^3.2.24", "vue-i18n": "9.1.9", "vue-router": "^4.0.12", @@ -35,8 +36,9 @@ "devDependencies": { "@commitlint/cli": "^15.0.0", "@commitlint/config-conventional": "^15.0.0", - "@iconify-json/ep": "^1.0.1", + "@iconify/json": "^1.1.441", "@intlify/vite-plugin-vue-i18n": "^3.2.1", + "@types/node": "^16.11.12", "@typescript-eslint/eslint-plugin": "^5.6.0", "@typescript-eslint/parser": "^5.6.0", "@vitejs/plugin-vue": "^1.9.3", @@ -63,12 +65,10 @@ "stylelint-config-standard": "^24.0.0", "stylelint-order": "^5.0.0", "typescript": "4.5.2", - "unplugin-auto-import": "^0.5.1", "unplugin-icons": "^0.12.23", - "unplugin-vue-components": "^0.17.6", "vite": "2.6.14", "vite-plugin-eslint": "^1.3.0", - "vite-plugin-vue-setup-extend": "^0.1.0", + "vite-plugin-style-import": "^1.4.0", "vite-plugin-windicss": "^1.5.4", "vue-tsc": "^0.3.0", "windicss": "^3.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c29d6af..ba33f1f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3,8 +3,9 @@ lockfileVersion: 5.3 specifiers: '@commitlint/cli': ^15.0.0 '@commitlint/config-conventional': ^15.0.0 - '@iconify-json/ep': ^1.0.1 + '@iconify/json': ^1.1.441 '@intlify/vite-plugin-vue-i18n': ^3.2.1 + '@types/node': ^16.11.12 '@typescript-eslint/eslint-plugin': ^5.6.0 '@typescript-eslint/parser': ^5.6.0 '@vitejs/plugin-vue': ^1.9.3 @@ -12,7 +13,7 @@ specifiers: '@vueuse/core': ^7.1.2 autoprefixer: ^10.4.0 commitizen: ^4.2.4 - element-plus: ^1.2.0-beta.5 + element-plus: 1.2.0-beta.6 eslint: ^8.4.1 eslint-config-prettier: ^8.3.0 eslint-define-config: ^1.2.0 @@ -21,6 +22,7 @@ specifiers: husky: ^7.0.4 less: ^4.1.2 lint-staged: ^12.1.2 + pinia: ^2.0.6 postcss: ^8.4.4 postcss-html: ^1.3.0 postcss-less: ^5.0.0 @@ -38,6 +40,7 @@ specifiers: unplugin-vue-components: ^0.17.6 vite: 2.6.14 vite-plugin-eslint: ^1.3.0 + vite-plugin-style-import: ^1.4.0 vite-plugin-vue-setup-extend: ^0.1.0 vite-plugin-windicss: ^1.5.4 vue: ^3.2.24 @@ -50,7 +53,8 @@ specifiers: dependencies: '@vueuse/core': registry.npmmirror.com/@vueuse/core/7.1.2_vue@3.2.24 - element-plus: registry.npmmirror.com/element-plus/1.2.0-beta.5_vue@3.2.24 + element-plus: registry.npmmirror.com/element-plus/1.2.0-beta.6_vue@3.2.24 + pinia: registry.npmmirror.com/pinia/2.0.6_typescript@4.5.2+vue@3.2.24 vue: registry.npmmirror.com/vue/3.2.24 vue-i18n: registry.npmmirror.com/vue-i18n/9.1.9_vue@3.2.24 vue-router: registry.npmmirror.com/vue-router/4.0.12_vue@3.2.24 @@ -59,8 +63,9 @@ dependencies: devDependencies: '@commitlint/cli': registry.npmmirror.com/@commitlint/cli/15.0.0 '@commitlint/config-conventional': registry.npmmirror.com/@commitlint/config-conventional/15.0.0 - '@iconify-json/ep': registry.npmmirror.com/@iconify-json/ep/1.0.1 + '@iconify/json': registry.npmmirror.com/@iconify/json/1.1.441 '@intlify/vite-plugin-vue-i18n': registry.npmmirror.com/@intlify/vite-plugin-vue-i18n/3.2.1_vite@2.6.14+vue-i18n@9.1.9 + '@types/node': registry.npmmirror.com/@types/node/16.11.12 '@typescript-eslint/eslint-plugin': registry.npmmirror.com/@typescript-eslint/eslint-plugin/5.6.0_16d83f5c41c3abb1061a82b07c18e4f3 '@typescript-eslint/parser': registry.npmmirror.com/@typescript-eslint/parser/5.6.0_eslint@8.4.1+typescript@4.5.2 '@vitejs/plugin-vue': registry.npmmirror.com/@vitejs/plugin-vue/1.10.1_vite@2.6.14 @@ -92,6 +97,7 @@ devDependencies: unplugin-vue-components: registry.npmmirror.com/unplugin-vue-components/0.17.6_vite@2.6.14+vue@3.2.24 vite: registry.npmmirror.com/vite/2.6.14_less@4.1.2 vite-plugin-eslint: registry.nlark.com/vite-plugin-eslint/1.3.0_vite@2.6.14 + vite-plugin-style-import: registry.npmmirror.com/vite-plugin-style-import/1.4.0_vite@2.6.14 vite-plugin-vue-setup-extend: registry.npmmirror.com/vite-plugin-vue-setup-extend/0.1.0_vite@2.6.14 vite-plugin-windicss: registry.npmmirror.com/vite-plugin-windicss/1.5.4_vite@2.6.14 vue-tsc: registry.npmmirror.com/vue-tsc/0.3.0_typescript@4.5.2 @@ -736,6 +742,59 @@ packages: engines: { node: '>=6' } dev: true + registry.nlark.com/camel-case/4.1.2: + resolution: + { + integrity: sha1-lygHKpVPgFIoIlpt7qazhGHhvVo=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/camel-case/download/camel-case-4.1.2.tgz + } + name: camel-case + version: 4.1.2 + dependencies: + pascal-case: registry.nlark.com/pascal-case/3.1.2 + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + + registry.nlark.com/capital-case/1.0.4: + resolution: + { + integrity: sha1-nRMCkjU8kkn2sA+lhSvuOKcX5mk=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/capital-case/download/capital-case-1.0.4.tgz + } + name: capital-case + version: 1.0.4 + dependencies: + no-case: registry.nlark.com/no-case/3.0.4 + tslib: registry.nlark.com/tslib/2.3.1 + upper-case-first: registry.nlark.com/upper-case-first/2.0.2 + dev: true + + registry.nlark.com/change-case/4.1.2: + resolution: + { + integrity: sha1-/t/F8TYEXiOYwEEO5EH5VwRkHhI=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/change-case/download/change-case-4.1.2.tgz + } + name: change-case + version: 4.1.2 + dependencies: + camel-case: registry.nlark.com/camel-case/4.1.2 + capital-case: registry.nlark.com/capital-case/1.0.4 + constant-case: registry.npmmirror.com/constant-case/3.0.4 + dot-case: registry.nlark.com/dot-case/3.0.4 + header-case: registry.nlark.com/header-case/2.0.4 + no-case: registry.nlark.com/no-case/3.0.4 + param-case: registry.nlark.com/param-case/3.0.4 + pascal-case: registry.nlark.com/pascal-case/3.1.2 + path-case: registry.nlark.com/path-case/3.0.4 + sentence-case: registry.npmmirror.com/sentence-case/3.0.4 + snake-case: registry.npmmirror.com/snake-case/3.0.4 + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + registry.nlark.com/character-parser/2.2.0: resolution: { @@ -1147,6 +1206,17 @@ packages: engines: { node: '>=8' } dev: true + registry.nlark.com/dayjs/1.10.7: + resolution: + { + integrity: sha1-LPX5Gt0oEWdIRAhmoKHSbzps5Gg=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/dayjs/download/dayjs-1.10.7.tgz + } + name: dayjs + version: 1.10.7 + dev: false + registry.nlark.com/decamelize-keys/1.1.0: resolution: { @@ -1300,6 +1370,20 @@ packages: domhandler: registry.npmmirror.com/domhandler/4.3.0 dev: true + registry.nlark.com/dot-case/3.0.4: + resolution: + { + integrity: sha1-mytnDQCkMWZ6inW6Kc0bmICc51E=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/dot-case/download/dot-case-3.0.4.tgz + } + name: dot-case + version: 3.0.4 + dependencies: + no-case: registry.nlark.com/no-case/3.0.4 + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + registry.nlark.com/dot-prop/5.3.0: resolution: { @@ -2177,6 +2261,20 @@ packages: version: 2.0.0 dev: true + registry.nlark.com/header-case/2.0.4: + resolution: + { + integrity: sha1-WkLmO1UXc0nPQFvrjXdayruSwGM=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/header-case/download/header-case-2.0.4.tgz + } + name: header-case + version: 2.0.4 + dependencies: + capital-case: registry.nlark.com/capital-case/1.0.4 + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + registry.nlark.com/homedir-polyfill/1.0.3: resolution: { @@ -2940,6 +3038,7 @@ packages: } name: lodash version: 4.17.21 + dev: true registry.nlark.com/longest/2.0.1: resolution: @@ -2953,6 +3052,19 @@ packages: engines: { node: '>=0.10.0' } dev: true + registry.nlark.com/lower-case/2.0.2: + resolution: + { + integrity: sha1-b6I3xj29xKgsoP2ILkci3F5jTig=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/lower-case/download/lower-case-2.0.2.tgz + } + name: lower-case + version: 2.0.2 + dependencies: + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + registry.nlark.com/lru-cache/6.0.0: resolution: { @@ -3185,6 +3297,20 @@ packages: dev: true optional: true + registry.nlark.com/no-case/3.0.4: + resolution: + { + integrity: sha1-02H9XJgA9VhVGoNp/A3NRmK2Ek0=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/no-case/download/no-case-3.0.4.tgz + } + name: no-case + version: 3.0.4 + dependencies: + lower-case: registry.nlark.com/lower-case/2.0.2 + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + registry.nlark.com/normalize-package-data/2.5.0: resolution: { @@ -3420,6 +3546,20 @@ packages: p-limit: registry.nlark.com/p-limit/3.1.0 dev: true + registry.nlark.com/param-case/3.0.4: + resolution: + { + integrity: sha1-fRf+SqEr3jTUp32RrPtiGcqtAcU=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/param-case/download/param-case-3.0.4.tgz + } + name: param-case + version: 3.0.4 + dependencies: + dot-case: registry.nlark.com/dot-case/3.0.4 + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + registry.nlark.com/parse-passwd/1.0.0: resolution: { @@ -3468,6 +3608,34 @@ packages: engines: { node: '>= 0.8' } dev: true + registry.nlark.com/pascal-case/3.1.2: + resolution: + { + integrity: sha1-tI4O8rmOIF58Ha50fQsVCCN2YOs=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/pascal-case/download/pascal-case-3.1.2.tgz + } + name: pascal-case + version: 3.1.2 + dependencies: + no-case: registry.nlark.com/no-case/3.0.4 + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + + registry.nlark.com/path-case/3.0.4: + resolution: + { + integrity: sha1-kWhkUzTrlCZYN1xW+AtMDLX4LG8=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/path-case/download/path-case-3.0.4.tgz + } + name: path-case + version: 3.0.4 + dependencies: + dot-case: registry.nlark.com/dot-case/3.0.4 + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + registry.nlark.com/path-exists/4.0.0: resolution: { @@ -4771,6 +4939,32 @@ packages: engines: { node: '>=4' } dev: true + registry.nlark.com/upper-case-first/2.0.2: + resolution: + { + integrity: sha1-mSwyc/iCq9GdHgKJTMFHEX+EQyQ=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/upper-case-first/download/upper-case-first-2.0.2.tgz + } + name: upper-case-first + version: 2.0.2 + dependencies: + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + + registry.nlark.com/upper-case/2.0.2: + resolution: + { + integrity: sha1-2JgQgj+qsd8VSbfZenb4Ziuub3o=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.nlark.com/upper-case/download/upper-case-2.0.2.tgz + } + name: upper-case + version: 2.0.2 + dependencies: + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + registry.nlark.com/uri-js/4.4.1: resolution: { @@ -5710,7 +5904,7 @@ packages: dependencies: '@commitlint/top-level': registry.npmmirror.com/@commitlint/top-level/15.0.0 '@commitlint/types': registry.npmmirror.com/@commitlint/types/15.0.0 - fs-extra: registry.nlark.com/fs-extra/10.0.0 + fs-extra: registry.npmmirror.com/fs-extra/10.0.0 git-raw-commits: registry.nlark.com/git-raw-commits/2.0.10 dev: true @@ -5789,16 +5983,20 @@ packages: chalk: registry.npmmirror.com/chalk/4.1.2 dev: true - registry.npmmirror.com/@element-plus/icons/0.0.11: + registry.npmmirror.com/@element-plus/icons-vue/0.2.4_vue@3.2.24: resolution: { - integrity: sha1-mxh8ACd0VIuRGFDRf6X8L5pRX1c=, + integrity: sha512-RsJNyL58rwxtsjeMy34o8txkL6UlME1stWsUlRpTac6UE9Bx9gdJvnDXbIKhOJqBLX17fBjmposdrn6VTqim2w==, registry: https://registry.npm.taobao.org/, - tarball: https://registry.npmmirror.com/@element-plus/icons/download/@element-plus/icons-0.0.11.tgz + tarball: https://registry.npmmirror.com/@element-plus/icons-vue/download/@element-plus/icons-vue-0.2.4.tgz } - name: '@element-plus/icons' - version: 0.0.11 - deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. + id: registry.npmmirror.com/@element-plus/icons-vue/0.2.4 + name: '@element-plus/icons-vue' + version: 0.2.4 + peerDependencies: + vue: ^3.2.0 + dependencies: + vue: registry.npmmirror.com/vue/3.2.24 dev: false registry.npmmirror.com/@endemolshinegroup/cosmiconfig-typescript-loader/3.0.2_b67f536f129c730ed129a6d21d223ba9: @@ -5919,17 +6117,15 @@ packages: version: 1.2.1 dev: true - registry.npmmirror.com/@iconify-json/ep/1.0.1: + registry.npmmirror.com/@iconify/json/1.1.441: resolution: { - integrity: sha512-fvbjV9/XSZKzTJbtegB4hgAPV7QUu8LmqSo00ngpWaZxtvKYBAhykYfhtPtBASUJxpr5JacoH4+sITINdSh+9g==, + integrity: sha512-5tSDYjvCrpLET9cDvja/CK4YtrjfSQR05LHQaNCNPhRtth8j/h9b4ly1/kgEHTGGCGCi2qG/FjMWArDxi8uRDw==, registry: https://registry.npm.taobao.org/, - tarball: https://registry.npmmirror.com/@iconify-json/ep/download/@iconify-json/ep-1.0.1.tgz + tarball: https://registry.npmmirror.com/@iconify/json/download/@iconify/json-1.1.441.tgz } - name: '@iconify-json/ep' - version: 1.0.1 - dependencies: - '@iconify/types': registry.npmmirror.com/@iconify/types/1.0.12 + name: '@iconify/json' + version: 1.1.441 dev: true registry.npmmirror.com/@iconify/types/1.0.12: @@ -6204,6 +6400,17 @@ packages: version: 1.2.2 dev: true + registry.npmmirror.com/@types/node/16.11.12: + resolution: + { + integrity: sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw==, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.npmmirror.com/@types/node/download/@types/node-16.11.12.tgz + } + name: '@types/node' + version: 16.11.12 + dev: true + registry.npmmirror.com/@types/normalize-package-data/2.4.1: resolution: { @@ -6797,7 +7004,7 @@ packages: { integrity: sha1-/q7SVZc9LndVW4PbwIhRpsY1IPo=, registry: https://registry.npm.taobao.org/, - tarball: https://registry.npmmirror.com/acorn/download/acorn-7.4.1.tgz + tarball: https://registry.npmmirror.com/acorn/download/acorn-7.4.1.tgz?cache=0&sync_timestamp=1637225763269&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Facorn%2Fdownload%2Facorn-7.4.1.tgz } name: acorn version: 7.4.1 @@ -7141,6 +7348,21 @@ packages: strip-json-comments: registry.nlark.com/strip-json-comments/3.0.1 dev: true + registry.npmmirror.com/constant-case/3.0.4: + resolution: + { + integrity: sha1-O4Sprq9M8x7EXmv13pG9+wWJ+vE=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.npmmirror.com/constant-case/download/constant-case-3.0.4.tgz + } + name: constant-case + version: 3.0.4 + dependencies: + no-case: registry.nlark.com/no-case/3.0.4 + tslib: registry.nlark.com/tslib/2.3.1 + upper-case: registry.nlark.com/upper-case/2.0.2 + dev: true + registry.npmmirror.com/conventional-commits-parser/3.2.3: resolution: { @@ -7184,17 +7406,6 @@ packages: version: 2.6.19 dev: false - registry.npmmirror.com/dayjs/1.10.7: - resolution: - { - integrity: sha1-LPX5Gt0oEWdIRAhmoKHSbzps5Gg=, - registry: https://registry.npm.taobao.org/, - tarball: https://registry.npmmirror.com/dayjs/download/dayjs-1.10.7.tgz?cache=0&sync_timestamp=1632743415328&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fdayjs%2Fdownload%2Fdayjs-1.10.7.tgz - } - name: dayjs - version: 1.10.7 - dev: false - registry.npmmirror.com/debug/2.6.9: resolution: { @@ -7312,25 +7523,25 @@ packages: version: 1.4.12 dev: true - registry.npmmirror.com/element-plus/1.2.0-beta.5_vue@3.2.24: + registry.npmmirror.com/element-plus/1.2.0-beta.6_vue@3.2.24: resolution: { - integrity: sha512-8KNGsNZ6RjVJ7kmxq/WLeTBMhVxSjfaGdW2QdcdXz4km1MgxbyBfdiNGVQG4XH/n+hbtLFldCPw0mVT4vkncuA==, + integrity: sha512-8EdSIR/5/FHcSB8w1diAh+gJMHgxIvxuZoayY99k6taAR1QyEFHuPTgFccZLopJ1+iP4UEsZFz49l57qS08Utw==, registry: https://registry.npm.taobao.org/, - tarball: https://registry.npmmirror.com/element-plus/download/element-plus-1.2.0-beta.5.tgz + tarball: https://registry.npmmirror.com/element-plus/download/element-plus-1.2.0-beta.6.tgz } - id: registry.npmmirror.com/element-plus/1.2.0-beta.5 + id: registry.npmmirror.com/element-plus/1.2.0-beta.6 name: element-plus - version: 1.2.0-beta.5 + version: 1.2.0-beta.6 peerDependencies: vue: ^3.2.0 dependencies: - '@element-plus/icons': registry.npmmirror.com/@element-plus/icons/0.0.11 + '@element-plus/icons-vue': registry.npmmirror.com/@element-plus/icons-vue/0.2.4_vue@3.2.24 '@popperjs/core': registry.npmmirror.com/@popperjs/core/2.11.0 '@vueuse/core': registry.npmmirror.com/@vueuse/core/7.1.2_vue@3.2.24 async-validator: registry.npmmirror.com/async-validator/4.0.7 - dayjs: registry.npmmirror.com/dayjs/1.10.7 - lodash: registry.nlark.com/lodash/4.17.21 + dayjs: registry.nlark.com/dayjs/1.10.7 + lodash: registry.npmmirror.com/lodash/4.17.21 memoize-one: registry.npmmirror.com/memoize-one/6.0.0 normalize-wheel-es: registry.npmmirror.com/normalize-wheel-es/1.1.1 vue: registry.npmmirror.com/vue/3.2.24 @@ -7360,6 +7571,17 @@ packages: version: 9.2.2 dev: true + registry.npmmirror.com/es-module-lexer/0.9.3: + resolution: + { + integrity: sha1-bxPbAMw4QXE32vdDZvU1yOtDjxk=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.npmmirror.com/es-module-lexer/download/es-module-lexer-0.9.3.tgz + } + name: es-module-lexer + version: 0.9.3 + dev: true + registry.npmmirror.com/esbuild-android-arm64/0.13.15: resolution: { @@ -8082,6 +8304,22 @@ packages: version: 4.1.2 dev: true + registry.npmmirror.com/fs-extra/10.0.0: + resolution: + { + integrity: sha1-n/YbZV3eU/s0qC34S7IUzoAuF8E=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.npmmirror.com/fs-extra/download/fs-extra-10.0.0.tgz?cache=0&sync_timestamp=1632539314386&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Ffs-extra%2Fdownload%2Ffs-extra-10.0.0.tgz + } + name: fs-extra + version: 10.0.0 + engines: { node: '>=12' } + dependencies: + graceful-fs: registry.npmmirror.com/graceful-fs/4.2.8 + jsonfile: registry.nlark.com/jsonfile/6.1.0 + universalify: registry.nlark.com/universalify/2.0.0 + dev: true + registry.npmmirror.com/fsevents/2.3.2: resolution: { @@ -8492,6 +8730,17 @@ packages: mlly: registry.npmmirror.com/mlly/0.2.10 dev: true + registry.npmmirror.com/lodash/4.17.21: + resolution: + { + integrity: sha1-Z5WRxWTDv/quhFTPCz3zcMPWkRw=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.npmmirror.com/lodash/download/lodash-4.17.21.tgz + } + name: lodash + version: 4.17.21 + dev: false + registry.npmmirror.com/log-update/4.0.0: resolution: { @@ -8822,6 +9071,32 @@ packages: name: picocolors version: 1.0.0 + registry.npmmirror.com/pinia/2.0.6_typescript@4.5.2+vue@3.2.24: + resolution: + { + integrity: sha512-01mP4+KapIcTNSYLhQESy6GW0N8vY5wX3UqOwkC87e7DPjEusNJ8bENrKqdvZaRHbB2rDMOONeAbwMa3+n1/rw==, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.npmmirror.com/pinia/download/pinia-2.0.6.tgz + } + id: registry.npmmirror.com/pinia/2.0.6 + name: pinia + version: 2.0.6 + peerDependencies: + '@vue/composition-api': ^1.4.0 + typescript: '>=4.4.4' + vue: ^2.6.14 || ^3.2.0 + peerDependenciesMeta: + '@vue/composition-api': + optional: true + typescript: + optional: true + dependencies: + '@vue/devtools-api': registry.npmmirror.com/@vue/devtools-api/6.0.0-beta.20.1 + typescript: registry.npmmirror.com/typescript/4.5.2 + vue: registry.npmmirror.com/vue/3.2.24 + vue-demi: registry.npmmirror.com/vue-demi/0.12.1_vue@3.2.24 + dev: false + registry.npmmirror.com/postcss-html/1.3.0: resolution: { @@ -9010,6 +9285,21 @@ packages: tslib: registry.nlark.com/tslib/2.1.0 dev: true + registry.npmmirror.com/sentence-case/3.0.4: + resolution: + { + integrity: sha1-NkWnuMEXx4f96HAgViJbtipFEx8=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.npmmirror.com/sentence-case/download/sentence-case-3.0.4.tgz + } + name: sentence-case + version: 3.0.4 + dependencies: + no-case: registry.nlark.com/no-case/3.0.4 + tslib: registry.nlark.com/tslib/2.3.1 + upper-case-first: registry.nlark.com/upper-case-first/2.0.2 + dev: true + registry.npmmirror.com/signal-exit/3.0.6: resolution: { @@ -9037,6 +9327,20 @@ packages: totalist: registry.nlark.com/totalist/1.1.0 dev: true + registry.npmmirror.com/snake-case/3.0.4: + resolution: + { + integrity: sha1-Tyu9Vo6ZNavf1ZPzTGkdrbScRSw=, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.npmmirror.com/snake-case/download/snake-case-3.0.4.tgz + } + name: snake-case + version: 3.0.4 + dependencies: + dot-case: registry.nlark.com/dot-case/3.0.4 + tslib: registry.nlark.com/tslib/2.3.1 + dev: true + registry.npmmirror.com/source-map-js/1.0.1: resolution: { @@ -9632,6 +9936,30 @@ packages: webpack-virtual-modules: registry.nlark.com/webpack-virtual-modules/0.4.3 dev: true + registry.npmmirror.com/vite-plugin-style-import/1.4.0_vite@2.6.14: + resolution: + { + integrity: sha512-EGAx0zVGUkwAwvDaC66zxgzXyHE0CwAXp4O1xGKnpMcrDT9L1nlojiCjjLRQzL8C3zwY1jn9ilq+m0VABKiiLg==, + registry: https://registry.npm.taobao.org/, + tarball: https://registry.npmmirror.com/vite-plugin-style-import/download/vite-plugin-style-import-1.4.0.tgz + } + id: registry.npmmirror.com/vite-plugin-style-import/1.4.0 + name: vite-plugin-style-import + version: 1.4.0 + peerDependencies: + vite: '>=2.0.0' + dependencies: + '@rollup/pluginutils': registry.nlark.com/@rollup/pluginutils/4.1.1 + change-case: registry.nlark.com/change-case/4.1.2 + debug: registry.npmmirror.com/debug/4.3.3 + es-module-lexer: registry.npmmirror.com/es-module-lexer/0.9.3 + fs-extra: registry.npmmirror.com/fs-extra/10.0.0 + magic-string: registry.nlark.com/magic-string/0.25.7 + vite: registry.npmmirror.com/vite/2.6.14_less@4.1.2 + transitivePeerDependencies: + - supports-color + dev: true + registry.npmmirror.com/vite-plugin-vue-setup-extend/0.1.0_vite@2.6.14: resolution: { diff --git a/.prettierrc.js b/prettier.config.js similarity index 100% rename from .prettierrc.js rename to prettier.config.js diff --git a/src/App.vue b/src/App.vue index 742051c..d3b026f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,46 +1,11 @@ - - - + diff --git a/src/components/Form/index.ts b/src/components/Form/index.ts new file mode 100644 index 0000000..6aaa635 --- /dev/null +++ b/src/components/Form/index.ts @@ -0,0 +1,3 @@ +import BfFrom from './src/BfForm.vue' + +export { BfFrom } diff --git a/src/components/Form/src/BfForm.vue b/src/components/Form/src/BfForm.vue new file mode 100644 index 0000000..fb7545b --- /dev/null +++ b/src/components/Form/src/BfForm.vue @@ -0,0 +1,10 @@ + + + + + diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue deleted file mode 100644 index 19fe746..0000000 --- a/src/components/HelloWorld.vue +++ /dev/null @@ -1,50 +0,0 @@ - - - - - diff --git a/src/components/index.ts b/src/components/index.ts new file mode 100644 index 0000000..06b7b15 --- /dev/null +++ b/src/components/index.ts @@ -0,0 +1,6 @@ +import type { App } from 'vue' +import { BfFrom } from './Form' + +export function setupGlobCom(app: App) { + app.component('BfFrom', BfFrom) +} diff --git a/src/main.ts b/src/main.ts index d45b34c..d13161b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,8 +7,16 @@ const app = createApp(App) // 引入windi css import '@/plugins/windicss' +// 引入全局组件 +import { setupGlobCom } from '@/components' +setupGlobCom(app) + // 引入多语言 import { setupI18n } from '@/plugins/i18n' setupI18n(app) +// 引入状态管理 +import { setupStore } from '@/store' +setupStore(app) + app.mount('#app') diff --git a/src/store/index.ts b/src/store/index.ts new file mode 100644 index 0000000..4d393cb --- /dev/null +++ b/src/store/index.ts @@ -0,0 +1,10 @@ +import type { App } from 'vue' +import { createPinia } from 'pinia' + +const store = createPinia() + +export function setupStore(app: App) { + app.use(store) +} + +export { store } diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts new file mode 100644 index 0000000..d7ca63c --- /dev/null +++ b/src/store/modules/app.ts @@ -0,0 +1,155 @@ +import { defineStore } from 'pinia' + +import { store } from '../index' + +export type LayoutType = 'Classic' | 'LeftTop' | 'Top' | 'Test' + +export interface AppState { + collapsed: boolean + showTags: boolean + showLogo: boolean + showNavbar: boolean + fixedHeader: boolean + layout: LayoutType + showBreadcrumb: boolean + showHamburger: boolean + showScreenfull: boolean + showUserInfo: boolean + title: string + logoTitle: string + userInfo: string + greyMode: boolean + showBackTop: boolean + showMenuTab: boolean + requestTime: boolean +} + +export const useAppStore = defineStore({ + id: 'app', + state: (): AppState => ({ + collapsed: false, // 菜单栏是否栏缩收 + showLogo: true, // 是否显示logo + showTags: true, // 是否显示标签栏 + showNavbar: true, // 是否显示navbar + fixedHeader: true, // 是否固定header + layout: 'Classic', // layout布局 + showBreadcrumb: true, // 是否显示面包屑 + showHamburger: true, // 是否显示侧边栏缩收按钮 + showScreenfull: true, // 是否全屏按钮 + showUserInfo: true, // 是否显示用户头像 + title: 'butterfly-admin', // 标题 + logoTitle: 'butterfly-admin', // logo标题 + userInfo: 'userInfo', // 登录信息存储字段-建议每个项目换一个字段,避免与其他项目冲突 + greyMode: false, // 是否开始灰色模式,用于特殊悼念日 + showBackTop: true, // 是否显示回到顶部 + showMenuTab: false, // 是否固定一级菜单 + requestTime: false // 是否在接口调用时添加时间戳,避免IE缓存 + }), + getters: { + getCollapsed(): boolean { + return this.collapsed + }, + getShowLogo(): boolean { + return this.showLogo + }, + getShowTags(): boolean { + return this.showTags + }, + getShowNavbar(): boolean { + return this.showNavbar + }, + getFixedHeader(): boolean { + return this.fixedHeader + }, + getLayout(): LayoutType { + return this.layout + }, + getShowBreadcrumb(): boolean { + return this.showBreadcrumb + }, + getShowHamburger(): boolean { + return this.showHamburger + }, + getShowScreenfull(): boolean { + return this.showScreenfull + }, + getShowUserInfo(): boolean { + return this.showUserInfo + }, + getTitle(): string { + return this.title + }, + getLogoTitle(): string { + return this.logoTitle + }, + getUserInfo(): string { + return this.userInfo + }, + getGreyMode(): boolean { + return this.greyMode + }, + getShowBackTop(): boolean { + return this.showBackTop + }, + getShowMenuTab(): boolean { + return this.showMenuTab + }, + getRequestTime(): boolean { + return this.requestTime + } + }, + actions: { + setCollapsed(collapsed: boolean): void { + this.collapsed = collapsed + }, + setShowLogo(showLogo: boolean): void { + this.showLogo = showLogo + }, + setShowTags(showTags: boolean): void { + this.showTags = showTags + }, + setShowNavbar(showNavbar: boolean): void { + this.showNavbar = showNavbar + }, + setFixedHeader(fixedHeader: boolean): void { + this.fixedHeader = fixedHeader + }, + setLayout(layout: LayoutType): void { + this.layout = layout + }, + setBreadcrumb(showBreadcrumb: boolean): void { + this.showBreadcrumb = showBreadcrumb + }, + setHamburger(showHamburger: boolean): void { + this.showHamburger = showHamburger + }, + setScreenfull(showScreenfull: boolean): void { + this.showScreenfull = showScreenfull + }, + setUserInfo(showUserInfo: boolean): void { + this.showUserInfo = showUserInfo + }, + setTitle(title: string): void { + this.title = title + }, + setLogoTitle(logoTitle: string): void { + this.logoTitle = logoTitle + }, + setGreyMode(greyMode: boolean): void { + this.greyMode = greyMode + }, + setShowBackTop(showBackTop: boolean): void { + this.showBackTop = showBackTop + }, + setShowMenuTab(showMenuTab: boolean): void { + this.showMenuTab = showMenuTab + }, + setRequestTime(requestTime: boolean): void { + this.requestTime = requestTime + } + } +}) + +export function useAppStoreWithOut() { + return useAppStore(store) +} diff --git a/src/types/auto-imports.d.ts b/src/types/auto-imports.d.ts deleted file mode 100644 index fda9eb7..0000000 --- a/src/types/auto-imports.d.ts +++ /dev/null @@ -1,194 +0,0 @@ -// Generated by 'unplugin-auto-import' -// We suggest you to commit this file into source control -declare global { - const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] - const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] - const biSyncRef: typeof import('@vueuse/core')['biSyncRef'] - const computed: typeof import('vue')['computed'] - const computedInject: typeof import('@vueuse/core')['computedInject'] - const controlledComputed: typeof import('@vueuse/core')['controlledComputed'] - const controlledRef: typeof import('@vueuse/core')['controlledRef'] - const createApp: typeof import('vue')['createApp'] - const createEventHook: typeof import('@vueuse/core')['createEventHook'] - const createGlobalState: typeof import('@vueuse/core')['createGlobalState'] - const createReactiveFn: typeof import('@vueuse/core')['createReactiveFn'] - const createSharedComposable: typeof import('@vueuse/core')['createSharedComposable'] - const createUnrefFn: typeof import('@vueuse/core')['createUnrefFn'] - const customRef: typeof import('vue')['customRef'] - const debouncedRef: typeof import('@vueuse/core')['debouncedRef'] - const debouncedWatch: typeof import('@vueuse/core')['debouncedWatch'] - const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] - const defineComponent: typeof import('vue')['defineComponent'] - const eagerComputed: typeof import('@vueuse/core')['eagerComputed'] - const effectScope: typeof import('vue')['effectScope'] - const EffectScope: typeof import('vue')['EffectScope'] - const extendRef: typeof import('@vueuse/core')['extendRef'] - const getCurrentInstance: typeof import('vue')['getCurrentInstance'] - const getCurrentScope: typeof import('vue')['getCurrentScope'] - const h: typeof import('vue')['h'] - const ignorableWatch: typeof import('@vueuse/core')['ignorableWatch'] - const inject: typeof import('vue')['inject'] - const isDefined: typeof import('@vueuse/core')['isDefined'] - const isReadonly: typeof import('vue')['isReadonly'] - const isRef: typeof import('vue')['isRef'] - const makeDestructurable: typeof import('@vueuse/core')['makeDestructurable'] - const markRaw: typeof import('vue')['markRaw'] - const nextTick: typeof import('vue')['nextTick'] - const onActivated: typeof import('vue')['onActivated'] - const onBeforeMount: typeof import('vue')['onBeforeMount'] - const onBeforeUnmount: typeof import('vue')['onBeforeUnmount'] - const onBeforeUpdate: typeof import('vue')['onBeforeUpdate'] - const onClickOutside: typeof import('@vueuse/core')['onClickOutside'] - const onDeactivated: typeof import('vue')['onDeactivated'] - const onErrorCaptured: typeof import('vue')['onErrorCaptured'] - const onKeyStroke: typeof import('@vueuse/core')['onKeyStroke'] - const onMounted: typeof import('vue')['onMounted'] - const onRenderTracked: typeof import('vue')['onRenderTracked'] - const onRenderTriggered: typeof import('vue')['onRenderTriggered'] - const onScopeDispose: typeof import('vue')['onScopeDispose'] - const onServerPrefetch: typeof import('vue')['onServerPrefetch'] - const onStartTyping: typeof import('@vueuse/core')['onStartTyping'] - const onUnmounted: typeof import('vue')['onUnmounted'] - const onUpdated: typeof import('vue')['onUpdated'] - const pausableWatch: typeof import('@vueuse/core')['pausableWatch'] - const provide: typeof import('vue')['provide'] - const reactify: typeof import('@vueuse/core')['reactify'] - const reactifyObject: typeof import('@vueuse/core')['reactifyObject'] - const reactive: typeof import('vue')['reactive'] - const reactivePick: typeof import('@vueuse/core')['reactivePick'] - const readonly: typeof import('vue')['readonly'] - const ref: typeof import('vue')['ref'] - const refDefault: typeof import('@vueuse/core')['refDefault'] - const shallowReactive: typeof import('vue')['shallowReactive'] - const shallowReadonly: typeof import('vue')['shallowReadonly'] - const shallowRef: typeof import('vue')['shallowRef'] - const syncRef: typeof import('@vueuse/core')['syncRef'] - const templateRef: typeof import('@vueuse/core')['templateRef'] - const throttledRef: typeof import('@vueuse/core')['throttledRef'] - const throttledWatch: typeof import('@vueuse/core')['throttledWatch'] - const toRaw: typeof import('vue')['toRaw'] - const toReactive: typeof import('@vueuse/core')['toReactive'] - const toRef: typeof import('vue')['toRef'] - const toRefs: typeof import('vue')['toRefs'] - const triggerRef: typeof import('vue')['triggerRef'] - const tryOnBeforeUnmount: typeof import('@vueuse/core')['tryOnBeforeUnmount'] - const tryOnMounted: typeof import('@vueuse/core')['tryOnMounted'] - const tryOnScopeDispose: typeof import('@vueuse/core')['tryOnScopeDispose'] - const tryOnUnmounted: typeof import('@vueuse/core')['tryOnUnmounted'] - const unref: typeof import('vue')['unref'] - const unrefElement: typeof import('@vueuse/core')['unrefElement'] - const until: typeof import('@vueuse/core')['until'] - const useActiveElement: typeof import('@vueuse/core')['useActiveElement'] - const useAsyncQueue: typeof import('@vueuse/core')['useAsyncQueue'] - const useAsyncState: typeof import('@vueuse/core')['useAsyncState'] - const useAttrs: typeof import('vue')['useAttrs'] - const useBase64: typeof import('@vueuse/core')['useBase64'] - const useBattery: typeof import('@vueuse/core')['useBattery'] - const useBreakpoints: typeof import('@vueuse/core')['useBreakpoints'] - const useBrowserLocation: typeof import('@vueuse/core')['useBrowserLocation'] - const useClamp: typeof import('@vueuse/core')['useClamp'] - const useClipboard: typeof import('@vueuse/core')['useClipboard'] - const useConfirmDialog: typeof import('@vueuse/core')['useConfirmDialog'] - const useCounter: typeof import('@vueuse/core')['useCounter'] - const useCssModule: typeof import('vue')['useCssModule'] - const useCssVar: typeof import('@vueuse/core')['useCssVar'] - const useDark: typeof import('@vueuse/core')['useDark'] - const useDebounce: typeof import('@vueuse/core')['useDebounce'] - const useDebouncedRefHistory: typeof import('@vueuse/core')['useDebouncedRefHistory'] - const useDebounceFn: typeof import('@vueuse/core')['useDebounceFn'] - const useDeviceMotion: typeof import('@vueuse/core')['useDeviceMotion'] - const useDeviceOrientation: typeof import('@vueuse/core')['useDeviceOrientation'] - const useDevicePixelRatio: typeof import('@vueuse/core')['useDevicePixelRatio'] - const useDevicesList: typeof import('@vueuse/core')['useDevicesList'] - const useDisplayMedia: typeof import('@vueuse/core')['useDisplayMedia'] - const useDocumentVisibility: typeof import('@vueuse/core')['useDocumentVisibility'] - const useDraggable: typeof import('@vueuse/core')['useDraggable'] - const useElementBounding: typeof import('@vueuse/core')['useElementBounding'] - const useElementHover: typeof import('@vueuse/core')['useElementHover'] - const useElementSize: typeof import('@vueuse/core')['useElementSize'] - const useElementVisibility: typeof import('@vueuse/core')['useElementVisibility'] - const useEventBus: typeof import('@vueuse/core')['useEventBus'] - const useEventListener: typeof import('@vueuse/core')['useEventListener'] - const useEventSource: typeof import('@vueuse/core')['useEventSource'] - const useEyeDropper: typeof import('@vueuse/core')['useEyeDropper'] - const useFavicon: typeof import('@vueuse/core')['useFavicon'] - const useFetch: typeof import('@vueuse/core')['useFetch'] - const useFocus: typeof import('@vueuse/core')['useFocus'] - const useFps: typeof import('@vueuse/core')['useFps'] - const useFullscreen: typeof import('@vueuse/core')['useFullscreen'] - const useGeolocation: typeof import('@vueuse/core')['useGeolocation'] - const useI18n: typeof import('vue-i18n')['useI18n'] - const useIdle: typeof import('@vueuse/core')['useIdle'] - const useIntersectionObserver: typeof import('@vueuse/core')['useIntersectionObserver'] - const useInterval: typeof import('@vueuse/core')['useInterval'] - const useIntervalFn: typeof import('@vueuse/core')['useIntervalFn'] - const useKeyModifier: typeof import('@vueuse/core')['useKeyModifier'] - const useLastChanged: typeof import('@vueuse/core')['useLastChanged'] - const useLocalStorage: typeof import('@vueuse/core')['useLocalStorage'] - const useMagicKeys: typeof import('@vueuse/core')['useMagicKeys'] - const useManualRefHistory: typeof import('@vueuse/core')['useManualRefHistory'] - const useMediaControls: typeof import('@vueuse/core')['useMediaControls'] - const useMediaQuery: typeof import('@vueuse/core')['useMediaQuery'] - const useMemory: typeof import('@vueuse/core')['useMemory'] - const useMounted: typeof import('@vueuse/core')['useMounted'] - const useMouse: typeof import('@vueuse/core')['useMouse'] - const useMouseInElement: typeof import('@vueuse/core')['useMouseInElement'] - const useMousePressed: typeof import('@vueuse/core')['useMousePressed'] - const useMutationObserver: typeof import('@vueuse/core')['useMutationObserver'] - const useNetwork: typeof import('@vueuse/core')['useNetwork'] - const useNow: typeof import('@vueuse/core')['useNow'] - const useOnline: typeof import('@vueuse/core')['useOnline'] - const usePageLeave: typeof import('@vueuse/core')['usePageLeave'] - const useParallax: typeof import('@vueuse/core')['useParallax'] - const usePermission: typeof import('@vueuse/core')['usePermission'] - const usePointer: typeof import('@vueuse/core')['usePointer'] - const usePointerSwipe: typeof import('@vueuse/core')['usePointerSwipe'] - const usePreferredColorScheme: typeof import('@vueuse/core')['usePreferredColorScheme'] - const usePreferredDark: typeof import('@vueuse/core')['usePreferredDark'] - const usePreferredLanguages: typeof import('@vueuse/core')['usePreferredLanguages'] - const useRafFn: typeof import('@vueuse/core')['useRafFn'] - const useRefHistory: typeof import('@vueuse/core')['useRefHistory'] - const useResizeObserver: typeof import('@vueuse/core')['useResizeObserver'] - const useRoute: typeof import('vue-router')['useRoute'] - const useRouter: typeof import('vue-router')['useRouter'] - const useScriptTag: typeof import('@vueuse/core')['useScriptTag'] - const useScroll: typeof import('@vueuse/core')['useScroll'] - const useScrollLock: typeof import('@vueuse/core')['useScrollLock'] - const useSessionStorage: typeof import('@vueuse/core')['useSessionStorage'] - const useShare: typeof import('@vueuse/core')['useShare'] - const useSlots: typeof import('vue')['useSlots'] - const useSpeechRecognition: typeof import('@vueuse/core')['useSpeechRecognition'] - const useSpeechSynthesis: typeof import('@vueuse/core')['useSpeechSynthesis'] - const useStorage: typeof import('@vueuse/core')['useStorage'] - const useSwipe: typeof import('@vueuse/core')['useSwipe'] - const useTemplateRefsList: typeof import('@vueuse/core')['useTemplateRefsList'] - const useThrottle: typeof import('@vueuse/core')['useThrottle'] - const useThrottledRefHistory: typeof import('@vueuse/core')['useThrottledRefHistory'] - const useThrottleFn: typeof import('@vueuse/core')['useThrottleFn'] - const useTimeAgo: typeof import('@vueuse/core')['useTimeAgo'] - const useTimeout: typeof import('@vueuse/core')['useTimeout'] - const useTimeoutFn: typeof import('@vueuse/core')['useTimeoutFn'] - const useTimestamp: typeof import('@vueuse/core')['useTimestamp'] - const useTitle: typeof import('@vueuse/core')['useTitle'] - const useToggle: typeof import('@vueuse/core')['useToggle'] - const useTransition: typeof import('@vueuse/core')['useTransition'] - const useUrlSearchParams: typeof import('@vueuse/core')['useUrlSearchParams'] - const useUserMedia: typeof import('@vueuse/core')['useUserMedia'] - const useVirtualList: typeof import('@vueuse/core')['useVirtualList'] - const useVModel: typeof import('@vueuse/core')['useVModel'] - const useVModels: typeof import('@vueuse/core')['useVModels'] - const useWakeLock: typeof import('@vueuse/core')['useWakeLock'] - const useWebSocket: typeof import('@vueuse/core')['useWebSocket'] - const useWebWorker: typeof import('@vueuse/core')['useWebWorker'] - const useWebWorkerFn: typeof import('@vueuse/core')['useWebWorkerFn'] - const useWindowFocus: typeof import('@vueuse/core')['useWindowFocus'] - const useWindowScroll: typeof import('@vueuse/core')['useWindowScroll'] - const useWindowSize: typeof import('@vueuse/core')['useWindowSize'] - const watch: typeof import('vue')['watch'] - const watchAtMost: typeof import('@vueuse/core')['watchAtMost'] - const watchEffect: typeof import('vue')['watchEffect'] - const watchOnce: typeof import('@vueuse/core')['watchOnce'] - const watchWithFilter: typeof import('@vueuse/core')['watchWithFilter'] - const whenever: typeof import('@vueuse/core')['whenever'] -} -export {} diff --git a/src/types/components.d.ts b/src/types/components.d.ts deleted file mode 100644 index 1b2fd2a..0000000 --- a/src/types/components.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -// generated by unplugin-vue-components -// We suggest you to commit this file into source control -// Read more: https://github.com/vuejs/vue-next/pull/3399 - -declare module 'vue' { - export interface GlobalComponents { - ElButton: typeof import('element-plus/es')['ElButton'] - ElIcon: typeof import('element-plus/es')['ElIcon'] - ElRadio: typeof import('element-plus/es')['ElRadio'] - EpAddLocation: typeof import('~icons/ep/add-location')['default'] - HelloWorld: typeof import('./../components/HelloWorld.vue')['default'] - } -} - -export {} diff --git a/src/types/v-components.d.ts b/src/types/v-components.d.ts index e69de29..61fabdb 100644 --- a/src/types/v-components.d.ts +++ b/src/types/v-components.d.ts @@ -0,0 +1,7 @@ +declare module 'vue' { + export interface GlobalComponents { + BfFrom: typeof import('../components/Form/src/BfForm.vue')['default'] + } +} + +export {} diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..c329073 --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,18 @@ +import type { App, Plugin } from 'vue' + +/** + * + * @param component 需要注册的组件 + * @param alias 组件别名 + * @returns any + */ +export const withInstall = (component: T, alias?: string) => { + const comp = component as any + comp.install = (app: App) => { + app.component(comp.name || comp.displayName, component) + if (alias) { + app.config.globalProperties[alias] = component + } + } + return component as T & Plugin +} diff --git a/src/utils/prop-types.ts b/src/utils/prop-types.ts deleted file mode 100644 index 67c6220..0000000 --- a/src/utils/prop-types.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { createTypes, VueTypesInterface } from 'vue-types' - -// 自定义扩展vue-types -type PropTypes = VueTypesInterface & {} - -const propTypes: PropTypes = createTypes({ - func: undefined, - bool: undefined, - string: undefined, - number: undefined, - object: undefined, - integer: undefined, - array: undefined -}) - -// 需要自定义扩展的类型 -// see: https://dwightjack.github.io/vue-types/advanced/extending-vue-types.html#the-extend-method -propTypes.extend([]) - -export { propTypes } diff --git a/src/utils/propTypes.ts b/src/utils/propTypes.ts new file mode 100644 index 0000000..a5e8606 --- /dev/null +++ b/src/utils/propTypes.ts @@ -0,0 +1,31 @@ +import { createTypes, VueTypesInterface, VueTypeValidableDef } from 'vue-types' +import { CSSProperties } from 'vue' + +// 自定义扩展vue-types +type PropTypes = VueTypesInterface & { + readonly style: VueTypeValidableDef +} + +const propTypes = createTypes({ + func: undefined, + bool: undefined, + string: undefined, + number: undefined, + object: undefined, + integer: undefined +}) as PropTypes + +console.log(propTypes.array) + +// 需要自定义扩展的类型 +// see: https://dwightjack.github.io/vue-types/advanced/extending-vue-types.html#the-extend-method +propTypes.extend([ + { + name: 'style', + getter: true, + type: [String, Object], + default: undefined + } +]) + +export { propTypes } diff --git a/tsconfig.json b/tsconfig.json index 7a9cc81..177e56a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,7 +23,13 @@ "paths": { "@/*": ["src/*"] }, - "types": ["@intlify/vite-plugin-vue-i18n/client", "vite/client", "element-plus/global.d.ts"] + "types": [ + "@intlify/vite-plugin-vue-i18n/client", + "vite/client", + "./node_modules/element-plus/global", + "unplugin-icons/types/vue" + ], + "typeRoots": ["./node_modules/@types/", "./src/types"] }, "include": ["src/**/*"], "exclude": ["dist", "node_modules"] diff --git a/vite.config.ts b/vite.config.ts index 622cdff..3b42c52 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,15 +3,14 @@ import { loadEnv } from 'vite' import type { UserConfig, ConfigEnv } from 'vite' import Vue from '@vitejs/plugin-vue' import WindiCSS from 'vite-plugin-windicss' -import Components from 'unplugin-vue-components/vite' -import AutoImport from 'unplugin-auto-import/vite' +// import Components from 'unplugin-vue-components/vite' +// import AutoImport from 'unplugin-auto-import/vite' import VueJsx from '@vitejs/plugin-vue-jsx' -import VueSetupExtend from 'vite-plugin-vue-setup-extend' import EslintPlugin from 'vite-plugin-eslint' -import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' +// import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' import VueI18n from '@intlify/vite-plugin-vue-i18n' import Icons from 'unplugin-icons/vite' -import IconsResolver from 'unplugin-icons/resolver' +import StyleImport, { ElementPlusResolve } from 'vite-plugin-style-import' // https://vitejs.dev/config/ const root = process.cwd() @@ -36,41 +35,44 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { Vue(), VueJsx(), WindiCSS(), - VueSetupExtend(), - AutoImport({ - imports: [ - 'vue', - 'vue-router', - 'vue-i18n', - '@vueuse/core' - ], - dts: 'src/types/auto-imports.d.ts' + StyleImport({ + resolves: [ElementPlusResolve()] }), + // AutoImport({ + // imports: [ + // 'vue', + // 'vue-router', + // 'vue-i18n', + // '@vueuse/core' + // ], + // dts: 'src/types/auto-imports.d.ts' + // }), Icons({ compiler: 'vue3', autoInstall: true }), - Components({ - dirs: ['src/components'], - extensions: ['vue', 'md'], - include: [/\.vue$/, /\.vue\?vue/, /\.md$/], - // custom resolvers - resolvers: [ - ElementPlusResolver(), - IconsResolver({ - prefix: false, - enabledCollections : ['ep'] - }) - ], - dts: 'src/types/components.d.ts' - }), + // Components({ + // dirs: ['src/components'], + // extensions: ['vue', 'md'], + // include: [/\.vue$/, /\.vue\?vue/, /\.md$/], + // // custom resolvers + // resolvers: [ + // ElementPlusResolver(), + // IconsResolver({ + // prefix: false, + // enabledCollections : ['ep'] + // }) + // ], + // dts: 'src/types/components.d.ts' + // }), EslintPlugin({ + cache: false, include: ['src/**/*.vue', 'src/**/*.ts', 'src/**/*.tsx'] // 检查的文件 }), VueI18n({ runtimeOnly: true, compositionOnly: true, - include: [pathResolve(__dirname, 'src/locales/**')] + include: [resolve(__dirname, 'src/locales/**')] }) ], @@ -124,7 +126,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { include: [ 'vue', 'vue-router', - 'element-plus' + 'vue-types' ] } }