diff --git a/auto-imports.d.ts b/auto-imports.d.ts new file mode 100644 index 0000000..918aad8 --- /dev/null +++ b/auto-imports.d.ts @@ -0,0 +1,8 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// Generated by unplugin-auto-import +export {} +declare global { + +} diff --git a/components.d.ts b/components.d.ts new file mode 100644 index 0000000..7f689c4 --- /dev/null +++ b/components.d.ts @@ -0,0 +1,26 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// Generated by unplugin-vue-components +// Read more: https://github.com/vuejs/core/pull/3399 +import '@vue/runtime-core' + +export {} + +declare module '@vue/runtime-core' { + export interface GlobalComponents { + ChangeLocal: typeof import('./src/components/set/preference/ChangeLocal.vue')['default'] + ElDialog: typeof import('element-plus/es')['ElDialog'] + ElForm: typeof import('element-plus/es')['ElForm'] + ElFormItem: typeof import('element-plus/es')['ElFormItem'] + ElOption: typeof import('element-plus/es')['ElOption'] + ElSelect: typeof import('element-plus/es')['ElSelect'] + ElTabPane: typeof import('element-plus/es')['ElTabPane'] + ElTabs: typeof import('element-plus/es')['ElTabs'] + GeneralSetting: typeof import('./src/components/set/GeneralSetting.vue')['default'] + PublishIndex: typeof import('./src/components/publish/PublishIndex.vue')['default'] + RouterLink: typeof import('vue-router')['RouterLink'] + RouterView: typeof import('vue-router')['RouterView'] + SetIndex: typeof import('./src/components/set/SetIndex.vue')['default'] + } +} diff --git a/package.json b/package.json index 0e2907f..2baa196 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,8 @@ "rollup-plugin-livereload": "^2.0.5", "ts-node": "^10.9.1", "typescript": "^5.0.4", + "unplugin-auto-import": "^0.16.2", + "unplugin-vue-components": "^0.24.1", "vercel": "^29.4.0", "vite": "^4.3.2", "vite-plugin-html": "^3.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7f5f341..efae38e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -66,6 +66,12 @@ devDependencies: typescript: specifier: ^5.0.4 version: 5.0.4 + unplugin-auto-import: + specifier: ^0.16.2 + version: 0.16.2(@vueuse/core@10.1.2) + unplugin-vue-components: + specifier: ^0.24.1 + version: 0.24.1(vue@3.2.47) vercel: specifier: ^29.4.0 version: 29.4.0(@types/node@18.16.14)(ts-node@10.9.1) @@ -89,6 +95,10 @@ packages: '@jridgewell/trace-mapping': 0.3.18 dev: true + /@antfu/utils@0.7.2: + resolution: {integrity: sha512-vy9fM3pIxZmX07dL+VX1aZe7ynZ+YyB0jY+jE6r3hOK6GNY2t6W8rzpFC4tgpbXUYABkFQwgJq2XYXlxbXAI0g==} + dev: true + /@astrojs/compiler@1.4.2: resolution: {integrity: sha512-xoRp7JpiMZPK/beUcZEM5kM44Z/h20wwwQcl54duPqQMyySG9vZ5xMM6dYiQmn7b3XzpZs0cT6TRDoJJ5gwHAQ==} dev: true @@ -1952,7 +1962,7 @@ packages: resolution: {integrity: sha512-8KG5RD0GVP4ydEzRn/I4BNDuxDtqVbOdm8675T49OIG/NGhaK0pjPX7ZcDlvKYbA+ulvVK3ztfcF4uBdOxuJbQ==} dependencies: '@gar/promisify': 1.1.3 - semver: 7.3.8 + semver: 7.5.1 dev: true /@npmcli/move-file@1.1.2: @@ -2264,7 +2274,6 @@ packages: /@types/web-bluetooth@0.0.17: resolution: {integrity: sha512-4p9vcSmxAayx72yn70joFoL44c9MO/0+iVEBIQXe3v2h2SiAsEIo/G5v6ObFWvNKRFjbrVadNf9LqEEZeQPzdA==} - dev: false /@typescript-eslint/eslint-plugin@5.59.7(@typescript-eslint/parser@5.59.7)(eslint@8.41.0)(typescript@4.9.5): resolution: {integrity: sha512-BL+jYxUFIbuYwy+4fF86k5vdT9lT0CNJ6HtwrIvGh0PhH8s0yy5rjaKH2fDCrz5ITHy07WCzVGNvAmjJh4IJFA==} @@ -2749,7 +2758,7 @@ packages: recast: 0.21.5 remark-frontmatter: 4.0.1 remark-mdx-frontmatter: 1.1.1 - semver: 7.3.8 + semver: 7.5.1 sort-package-json: 1.57.0 tar-fs: 2.1.1 tsconfig-paths: 4.2.0 @@ -3014,7 +3023,6 @@ packages: transitivePeerDependencies: - '@vue/composition-api' - vue - dev: false /@vueuse/core@9.13.0(vue@3.2.47): resolution: {integrity: sha512-pujnclbeHWxxPRqXWmdkKV5OX4Wk4YeK7wusHqRwU0Q7EFusHoqNA/aPhB6KCh9hEqJkLAJo7bb0Lh9b+OIVzw==} @@ -3030,7 +3038,6 @@ packages: /@vueuse/metadata@10.1.2: resolution: {integrity: sha512-3mc5BqN9aU2SqBeBuWE7ne4OtXHoHKggNgxZR2K+zIW4YLsy6xoZ4/9vErQs6tvoKDX6QAqm3lvsrv0mczAwIQ==} - dev: false /@vueuse/metadata@9.13.0: resolution: {integrity: sha512-gdU7TKNAUVlXXLbaF+ZCfte8BjRJQWPCa2J55+7/h+yDtzw3vOoGQDRXzI6pyKyo6bXFT5/QoPE4hAknExjRLQ==} @@ -3043,7 +3050,6 @@ packages: transitivePeerDependencies: - '@vue/composition-api' - vue - dev: false /@vueuse/shared@9.13.0(vue@3.2.47): resolution: {integrity: sha512-UrnhU+Cnufu4S6JLCPZnkWh0WwZGUp72ktOF2DFptMlOs3TOdVv8xJN53zhHGARmVOsz5KqOls09+J1NR6sBKw==} @@ -4409,6 +4415,11 @@ packages: engines: {node: '>=10'} dev: true + /escape-string-regexp@5.0.0: + resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==} + engines: {node: '>=12'} + dev: true + /escodegen@1.14.3: resolution: {integrity: sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==} engines: {node: '>=4.0'} @@ -5706,6 +5717,11 @@ packages: engines: {node: '>= 12.13.0'} dev: true + /local-pkg@0.4.3: + resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==} + engines: {node: '>=14'} + dev: true + /locate-path@6.0.0: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} @@ -6316,6 +6332,13 @@ packages: brace-expansion: 2.0.1 dev: true + /minimatch@7.4.6: + resolution: {integrity: sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + dev: true + /minimatch@9.0.1: resolution: {integrity: sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==} engines: {node: '>=16 || 14 >=14.17'} @@ -7368,6 +7391,10 @@ packages: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} dev: true + /scule@1.0.0: + resolution: {integrity: sha512-4AsO/FrViE/iDNEPaAQlb77tf0csuq27EsVpy6ett584EcRTp6pTDLoGWVxCD77y5iU5FauOvhsI4o1APwPoSQ==} + dev: true + /semver@6.1.1: resolution: {integrity: sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==} hasBin: true @@ -7622,6 +7649,12 @@ packages: engines: {node: '>=8'} dev: true + /strip-literal@1.0.1: + resolution: {integrity: sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==} + dependencies: + acorn: 8.8.2 + dev: true + /style-to-object@0.4.1: resolution: {integrity: sha512-HFpbb5gr2ypci7Qw+IOhnP2zOU7e77b+rzM+wTzXzfi1PrtBCX0E7Pk4wL4iTLnhzZ+JgEGAhX81ebTg/aYjQw==} dependencies: @@ -7973,6 +8006,24 @@ packages: vfile: 5.3.7 dev: true + /unimport@3.0.7: + resolution: {integrity: sha512-2dVQUxJEGcrSZ0U4qtwJVODrlfyGcwmIOoHVqbAFFUx7kPoEN5JWr1cZFhLwoAwTmZOvqAm3YIkzv1engIQocg==} + dependencies: + '@rollup/pluginutils': 5.0.2 + escape-string-regexp: 5.0.0 + fast-glob: 3.2.12 + local-pkg: 0.4.3 + magic-string: 0.30.0 + mlly: 1.3.0 + pathe: 1.1.0 + pkg-types: 1.0.3 + scule: 1.0.0 + strip-literal: 1.0.1 + unplugin: 1.3.1 + transitivePeerDependencies: + - rollup + dev: true + /unique-filename@1.1.1: resolution: {integrity: sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ==} dependencies: @@ -8056,6 +8107,68 @@ packages: engines: {node: '>= 0.8'} dev: true + /unplugin-auto-import@0.16.2(@vueuse/core@10.1.2): + resolution: {integrity: sha512-t5f+xArJZRsfgF8Zftc2JFTJJTo7BPkPSeLQUXt6xxambnwWBer8vpEgwaCYrR50MIm5mjmhjebt33OZXIW0uQ==} + engines: {node: '>=14'} + peerDependencies: + '@nuxt/kit': ^3.2.2 + '@vueuse/core': '*' + peerDependenciesMeta: + '@nuxt/kit': + optional: true + '@vueuse/core': + optional: true + dependencies: + '@antfu/utils': 0.7.2 + '@rollup/pluginutils': 5.0.2 + '@vueuse/core': 10.1.2(vue@3.2.47) + local-pkg: 0.4.3 + magic-string: 0.30.0 + minimatch: 9.0.1 + unimport: 3.0.7 + unplugin: 1.3.1 + transitivePeerDependencies: + - rollup + dev: true + + /unplugin-vue-components@0.24.1(vue@3.2.47): + resolution: {integrity: sha512-T3A8HkZoIE1Cja95xNqolwza0yD5IVlgZZ1PVAGvVCx8xthmjsv38xWRCtHtwl+rvZyL9uif42SRkDGw9aCfMA==} + engines: {node: '>=14'} + peerDependencies: + '@babel/parser': ^7.15.8 + '@nuxt/kit': ^3.2.2 + vue: 2 || 3 + peerDependenciesMeta: + '@babel/parser': + optional: true + '@nuxt/kit': + optional: true + dependencies: + '@antfu/utils': 0.7.2 + '@rollup/pluginutils': 5.0.2 + chokidar: 3.5.3 + debug: 4.3.4 + fast-glob: 3.2.12 + local-pkg: 0.4.3 + magic-string: 0.30.0 + minimatch: 7.4.6 + resolve: 1.22.2 + unplugin: 1.3.1 + vue: 3.2.47 + transitivePeerDependencies: + - rollup + - supports-color + dev: true + + /unplugin@1.3.1: + resolution: {integrity: sha512-h4uUTIvFBQRxUKS2Wjys6ivoeofGhxzTe2sRWlooyjHXVttcVfV/JiavNd3d4+jty0SVV0dxGw9AkY9MwiaCEw==} + dependencies: + acorn: 8.8.2 + chokidar: 3.5.3 + webpack-sources: 3.2.3 + webpack-virtual-modules: 0.5.0 + dev: true + /untildify@4.0.0: resolution: {integrity: sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==} engines: {node: '>=8'} @@ -8254,7 +8367,6 @@ packages: optional: true dependencies: vue: 3.2.47 - dev: false /vue-eslint-parser@9.3.0(eslint@8.41.0): resolution: {integrity: sha512-48IxT9d0+wArT1+3wNIy0tascRoywqSUe2E1YalIC1L8jsUGe5aJQItWfRok7DVFGz3UYvzEI7n5wiTXsCMAcQ==} @@ -8338,6 +8450,15 @@ packages: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} dev: true + /webpack-sources@3.2.3: + resolution: {integrity: sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==} + engines: {node: '>=10.13.0'} + dev: true + + /webpack-virtual-modules@0.5.0: + resolution: {integrity: sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==} + dev: true + /whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} dependencies: diff --git a/src/main.ts b/src/main.ts index b347251..6553984 100644 --- a/src/main.ts +++ b/src/main.ts @@ -60,7 +60,9 @@ import { AppInstance } from "~/src/appInstance.ts" app.provide(InjectKeys.APP_INSTANCE, appInstance) // ElementPlus - app.use(ElementPlus) + // 包太大,需要改成按需引入 + // https://element-plus.org/zh-CN/guide/quickstart.html#%E6%8C%89%E9%9C%80%E5%AF%BC%E5%85%A5 + // app.use(ElementPlus) // 挂载 vue app app.mount("#app") diff --git a/vite.config.ts b/vite.config.ts index aeb3e31..2aecb55 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,6 +6,9 @@ import fg from "fast-glob" import { createHtmlPlugin } from "vite-plugin-html" import path from "path" import commonjs from "@rollup/plugin-commonjs" +import AutoImport from "unplugin-auto-import/vite" +import Components from "unplugin-vue-components/vite" +import { ElementPlusResolver } from "unplugin-vue-components/resolvers" const getAppBase = (isSiyuanBuild: boolean, isStaticBuild: boolean): string => { if (isSiyuanBuild) { @@ -42,6 +45,13 @@ export default defineConfig({ plugins: [ vue(), + AutoImport({ + resolvers: [ElementPlusResolver()], + }), + Components({ + resolvers: [ElementPlusResolver()], + }), + createHtmlPlugin({ minify: !isDev, inject: { @@ -149,6 +159,21 @@ export default defineConfig({ // console.log("id=>", id) // console.log("dep=>", dep) if (dep !== "") { + // if (dep === "element-plus") { + // let element_dep = dep + // const componentPath = id + // const componentRegex = /\/node_modules\/([^/]+)\/.*\/components\/([^/]+)/ + // const matches = componentPath.match(componentRegex) + // + // if (matches !== null) { + // element_dep = matches[2] + // // console.log("element_dep=>", element_dep) + // } else { + // // console.log(`Could not match component name from ${componentPath}`) + // } + // + // return "vendor_element_plus_" + element_dep + // } return "vendor_" + dep } return "vendor"