From 1ffc4237ca11c404e015af7c3bb89e269b86bdfe Mon Sep 17 00:00:00 2001
From: KuroSago
Date: Fri, 21 Jun 2024 09:18:53 +0800
Subject: [PATCH] feat: add a new feature
---
.vscode/extensions.json | 18 ++-
.vscode/settings.json | 242 +++++++++++++++++++++++++++----------
README.md | 13 ++
package.json | 5 +
src/App.vue | 6 +-
src/androidPrivacy.json | 6 +-
src/enums/appEnum.ts | 7 ++
src/enums/httpEnum.ts | 2 +-
src/main.ts | 4 +
src/pages/about/index.vue | 8 +-
src/router/guard.ts | 5 +-
src/stores/index.ts | 4 +-
src/stores/modules/user.ts | 118 +++++++++---------
src/utils/http/index.ts | 5 +-
tsconfig.json | 88 ++++++++------
vite.config.ts | 4 +
16 files changed, 358 insertions(+), 177 deletions(-)
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index ad1ba07..8c47a80 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -4,7 +4,23 @@
{
"recommendations": [
- "Vue.volar", // Vue语言支持扩展
+ "afzalsayed96.icones",
+ "antfu.iconify",
+ "antfu.unocss",
+ "dbaeumer.vscode-eslint",
+ "editorconfig.editorconfig",
+ "esbenp.prettier-vscode",
+ "formulahendry.auto-close-tag",
+ "formulahendry.auto-complete-tag",
+ "formulahendry.auto-rename-tag",
+ "lokalise.i18n-ally",
+ "mhutchie.git-graph",
+ "mikestead.dotenv",
+ "naumovs.color-highlight",
+ "pkief.material-icon-theme",
+ "sdras.vue-vscode-snippets",
+ "whtouche.vscode-js-console-utils",
+ "zhuangtongfa.material-theme",
"Vue.vscode-typescript-vue-plugin", // 一个TS服务器插件,使TS服务器知道*.vue文件。
"esbenp.prettier-vscode", // 代码格式化
"dbaeumer.vscode-eslint" // 代码质量检查
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 57425c6..aced40f 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,73 +1,185 @@
-////////////////////////////////////////////////////////////////////////////
-// vscode 编辑器和插件的配置 ////////////////////////////////////////////////
-// 参考:https://blog.csdn.net/weixin_46238462/article/details/125867532 //
-//////////////////////////////////////////////////////////////////////////
-
{
- "editor.defaultFormatter": "esbenp.prettier-vscode",
- "editor.detectIndentation": false,
- "editor.tabSize": 4,
- "files.eol": "auto",
- "eslint.enable": true,
-
- //////////////////////////////////////////////////////////////////
- // 官网参考:https://prettier.io/docs/en/options.html#tab-width //
- ////////////////////////////////////////////////////////////////
- "prettier.semi": true,
- "prettier.tabWidth": 4,
- "prettier.printWidth": 160,
- "prettier.endOfLine": "auto",
- "prettier.singleQuote": true,
- "prettier.ignorePath": ".prettierignore",
- // Enable the ESlint flat config support
- // (remove this if your ESLint extension above v3.0.5)
- "eslint.experimental.useFlatConfig": true,
-
- // Disable the default formatter, use eslint instead
- "prettier.enable": false,
- "editor.formatOnSave": false,
-
- // Auto fix
+ // "editor.codeActionsOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
-
- // Silent the stylistic rules in you IDE, but still auto fix them
- "eslint.rules.customizations": [
- { "rule": "style/*", "severity": "off" },
- { "rule": "format/*", "severity": "off" },
- { "rule": "*-indent", "severity": "off" },
- { "rule": "*-spacing", "severity": "off" },
- { "rule": "*-spaces", "severity": "off" },
- { "rule": "*-order", "severity": "off" },
- { "rule": "*-dangle", "severity": "off" },
- { "rule": "*-newline", "severity": "off" },
- { "rule": "*quotes", "severity": "off" },
- { "rule": "*semi", "severity": "off" }
+ "eslint.experimental.useFlatConfig": true,
+ "editor.formatOnSave": false,
+ "prettier.enable": false,
+ "unocss.root": ["./"],
+ "typescript.tsdk": "node_modules/typescript/lib",
+ "vue.server.hybridMode": true,
+ "eslint.validate": ["html", "css", "scss", "json", "jsonc"],
+ "i18n-ally.displayLanguage": "zh-cn",
+ "i18n-ally.enabledParsers": ["ts"],
+ "i18n-ally.enabledFrameworks": ["vue"],
+ "i18n-ally.editor.preferEditor": true,
+ "i18n-ally.keystyle": "nested",
+ "i18n-ally.localesPaths": ["src/locales/langs"],
+ "editor.fontLigatures": true,
+ "editor.quickSuggestions": {
+ "strings": true
+ },
+ "editor.tabSize": 2,
+ "files.associations": {
+ "*.env.*": "dotenv",
+ "*.svg": "html"
+ },
+ // "files.refactoring.autoSave": false,
+ "files.eol": "\n",
+ "path-intellisense.mappings": {
+ "@": "${workspaceFolder}/src",
+ "~@": "${workspaceFolder}/src"
+ },
+ "terminal.integrated.fontSize": 14,
+ "terminal.integrated.fontWeight": 500,
+ "terminal.integrated.tabs.enabled": true,
+ // "workbench.iconTheme": "material-icon-theme",
+ "workbench.colorTheme": "Visual Studio Light",
+ "css.lint.unknownAtRules": "ignore",
+ "psi-header.config": {
+ "forceToTop": true,
+ "blankLinesAfter": 3,
+ "license": "Custom"
+ },
+ "psi-header.changes-tracking": {
+ "isActive": true,
+ "modAuthor": "Modified By: ",
+ "modDate": "Last Modified: ",
+ "modDateFormat": "date",
+ "include": [],
+ "exclude": ["markdown", "json"],
+ "excludeGlob": ["out/**", "src/**/*.xyz", "components/**/*.mk"],
+ "autoHeader": "manualSave"
+ },
+ "psi-header.license-text": ["May the force be with you."],
+ "psi-header.variables": [
+ ["company", "self."]
+ // ["author", "你的名字 - 默认主机名"],
+ // ["authoremail", "xxxxx@gmail.com"],
+ // ["initials", "S.L"]
],
-
- // Enable eslint for all supported languages
- "eslint.validate": [
- "javascript",
- "javascriptreact",
- "typescript",
- "typescriptreact",
- "vue",
- "html",
- "markdown",
- "json",
- "jsonc",
- "yaml",
- "toml",
- "xml",
- "gql",
- "graphql",
- "astro",
- "css",
- "less",
- "scss",
- "pcss",
- "postcss"
+ "psi-header.lang-config": [
+ {
+ "language": "html",
+ "begin": "",
+ "prefix": " "
+ },
+ {
+ "language": "vue",
+ "begin": "",
+ "prefix": " "
+ },
+ {
+ "language": "lua",
+ "begin": "--[[",
+ "prefix": "--",
+ "end": "--]]",
+ "blankLinesAfter": 0
+ },
+ {
+ "language": "python",
+ "begin": "###",
+ "prefix": "# ",
+ "end": "###",
+ "blankLinesAfter": 0,
+ "beforeHeader": ["#!/usr/bin/env python", "# -*- coding:utf-8 -*-"]
+ },
+ {
+ "language": "javascript",
+ "begin": "/**",
+ "prefix": " * ",
+ "end": " */",
+ "blankLinesAfter": 0,
+ "forceToTop": true
+ },
+ {
+ "language": "typescript",
+ "mapTo": "javascript",
+ "begin": "/**",
+ "prefix": " * ",
+ "end": " */",
+ "blankLinesAfter": 0,
+ "forceToTop": true
+ }
+ ],
+ "psi-header.templates": [
+ {
+ "language": "javascript",
+ "template": [
+ "## File: <>",
+ "",
+ "Project: <>",
+ "",
+ "Created Date: <>",
+ "",
+ "Author: <>",
+ "",
+ "## Last Modified: <>",
+ "",
+ "Modified By: ",
+ "",
+ "## Copyright (c) <> <>",
+ "",
+ "Use To: "
+ ]
+ },
+ {
+ "language": "typescript",
+ "template": [
+ "## File: <>",
+ "",
+ "Project: <>",
+ "",
+ "Created Date: <>",
+ "",
+ "Author: <>",
+ "",
+ "## Last Modified: <>",
+ "",
+ "Modified By: ",
+ "",
+ "## Copyright (c) <> <>",
+ "",
+ "Use To: "
+ ]
+ },
+ {
+ "language": "html",
+ "begin": "",
+ "template": [
+ "## File: <>",
+ "",
+ "Project: <>",
+ "",
+ "Created Date: <>",
+ "",
+ "Author: <>",
+ "",
+ "## Last Modified: <>",
+ "",
+ "Modified By: ",
+ "",
+ "## Copyright (c) <> <>",
+ "",
+ "Use To: "
+ ]
+ },
+ {
+ "language": "typescript",
+ "mapTo": "javascript"
+ },
+ {
+ "language": "tsx",
+ "mapTo": "javascript"
+ },
+ {
+ "language": "vue",
+ "mapTo": "html"
+ }
]
}
diff --git a/README.md b/README.md
index ad94989..1e690bc 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,19 @@
+## appProvider 插件
+
+- ./vite/plugins/appProvider.ts
+- 本配置功能为扫描 @/pages/xx/index.vue 文件,通过覆盖一层 view 的方式注入 style 变量
+- 相关文件 `./src/layout/AppProvider.vue`
+
+## vite/plugins/build.unocss.config.ts - 构建 unocss 相关配置
+
+- 本配置通过读取 ./src/theme/theme.ts 文件中相关配置构建 **theme 变量 , **theme 即 AppProvider.vue 文件的 style 变量
+- 相关文件 `./src/theme/theme.ts`
+ `./src/stores/modules/system.ts`
+ `./src/mixins/theme.ts`
+
## 简介
- **uni-app Vue3 Vite4 pinia2 TypeScript 基础框架**
diff --git a/package.json b/package.json
index 14568e8..d2b2cf3 100644
--- a/package.json
+++ b/package.json
@@ -51,10 +51,14 @@
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-4010920240607001",
"@dcloudio/uni-quickapp-webview": "3.0.0-alpha-4010920240607001",
"@multiavatar/multiavatar": "^1.0.7",
+ "@unocss/transformer-directives": "^0.61.0",
"alova": "^2.21.3",
"crypto-js": "^4.2.0",
"lodash-es": "^4.17.21",
+ "normalize-path": "^3.0.0",
"pinia": "^2.1.7",
+ "pinia-plugin-persistedstate": "^3.2.1",
+ "unplugin-vue-components": "^0.27.0",
"vue": "^3.4.29"
},
"devDependencies": {
@@ -68,6 +72,7 @@
"@types/crypto-js": "^4.2.2",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.14.2",
+ "@types/normalize-path": "^3.0.0",
"@unocss/eslint-plugin": "^0.61.0",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/runtime-core": "^3.4.29",
diff --git a/src/App.vue b/src/App.vue
index 735c9d7..4dfb86b 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,13 +1,13 @@
-
-
+
+
{{ userInfo?.nickname }}
@@ -28,7 +28,7 @@ function handleLoginOut() {
log
-
+
登出
diff --git a/src/router/guard.ts b/src/router/guard.ts
index fc82141..c231f0a 100644
--- a/src/router/guard.ts
+++ b/src/router/guard.ts
@@ -1,5 +1,4 @@
import type { Router } from 'uni-mini-router/lib/interfaces';
-import { isLogin } from '@/utils/auth';
export function createRouterGuard(router: Router) {
createBeforeEachGuard(router);
@@ -9,7 +8,7 @@ export function createRouterGuard(router: Router) {
function createBeforeEachGuard(router: Router) {
router.beforeEach((to, _, next) => {
console.log('beforeEach', to);
- const _isLogin = isLogin();
+ const _isLogin = true;
if (to && to?.meta?.ignoreAuth) {
// 如果目标路由忽略验证直接跳转
next();
@@ -31,7 +30,7 @@ function createAfterEachGuard(router: Router) {
router.afterEach((to) => {
if (to && to?.meta?.ignoreAuth)
return;
- const _isLogin = isLogin();
+ const _isLogin = true;
if (!_isLogin && to && to.name !== 'Login') {
// 如果没有登录且目标路由不是登录页面则跳转到登录页面
router.push({ name: 'Login', params: { ...to.query } });
diff --git a/src/stores/index.ts b/src/stores/index.ts
index efaf6c9..79926b0 100644
--- a/src/stores/index.ts
+++ b/src/stores/index.ts
@@ -1,7 +1,9 @@
-import type { App } from 'vue';
import { createPinia } from 'pinia';
+import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
+import type { App } from 'vue';
const store = createPinia();
+store.use(piniaPluginPersistedstate);
export function setupStore(app: App) {
app.use(store);
diff --git a/src/stores/modules/user.ts b/src/stores/modules/user.ts
index cf78510..a289107 100644
--- a/src/stores/modules/user.ts
+++ b/src/stores/modules/user.ts
@@ -3,67 +3,75 @@ import { useRequest } from 'alova';
import { getUserInfoApi } from '@/services/api/user';
import type { UserInfoModel } from '@/services/model/userModel';
import { login as loginApi } from '@/services/api/auth';
-import { getToken, isLogin, setToken } from '@/utils/auth';
-import { removeCache } from '@/utils/cache';
-import { TOKEN_KEY } from '@/enums/cacheEnum';
-export const useUserStore = defineStore('UserStore', () => {
- const token = ref(null);
- const userInfo = ref(null);
+interface UserStore {
+ token: string | null
+ userInfo: UserInfoModel | null
+}
- // 初始化
- function initUserInfo() {
- if (isLogin()) {
- token.value = getToken();
- getUserInfo();
- }
- }
+export const useUserStore = defineStore({
+ id: 'UserStore',
+ state: (): UserStore => ({
+ token: null,
+ userInfo: null,
+ }),
+ getters: {
+ loginOrNot: state => !!state.token,
+ },
+ actions: {
- // 是否登录
- const loggedIn = computed(() => !!token.value);
+ // setToken
+ setToken(token: string) {
+ this.token = token;
+ },
- // 登录
- const { send: sendLogin } = useRequest(loginApi, { immediate: false });
- async function login(params: LoginParams) {
- try {
- const res = await sendLogin(params);
- token.value = res.token;
- setToken(res.token);
- await getUserInfo();
- } catch (error) {
- throw error;
- }
- }
+ // 登录
+ async login(params: LoginParams) {
+ const { send: sendLogin } = useRequest(loginApi, { immediate: false });
+ try {
+ const res = await sendLogin(params);
+ this.token = res.token;
+ this.setToken(res.token);
+ await this.getUserInfo();
+ } catch (error) {
+ throw error;
+ }
+ },
- // 获取用户信息
- const { send: _getUserInfo } = useRequest(getUserInfoApi, { initialData: null, immediate: false });
- async function getUserInfo() {
- try {
- userInfo.value = await _getUserInfo();
- } catch (error) {
- throw error;
- }
- }
+ // 获取用户信息
+ async getUserInfo() {
+ const { send: _getUserInfo } = useRequest(getUserInfoApi, { initialData: null, immediate: false });
+ try {
+ this.userInfo = await _getUserInfo();
+ } catch (error) {
+ throw error;
+ }
+ },
- // 登出
- // const { send: sendLogout } = useRequest(logoutApi, { immediate: false });
- async function logout() {
- try {
+ // 初始化
+ async initUserInfo() {
+ //
+ },
+
+ // 登出
+ async logout() {
+ // const { send: sendLogout } = useRequest(logoutApi, { immediate: false });
+ try {
// await sendLogout();
- removeCache(TOKEN_KEY);
- userInfo.value = null;
- token.value = null;
- } catch (err: any) {
- throw err;
- }
- }
+ this.userInfo = null;
+ this.token = null;
+ } catch (err: any) {
+ throw err;
+ }
+ },
+
+ },
+ persist: {
+ storage: {
+ setItem: uni.setStorageSync,
+ getItem: uni.getStorageSync,
+ },
+ paths: ['token', 'userInfo'],
+ },
- return {
- userInfo,
- loggedIn,
- login,
- logout,
- getUserInfo,
- initUserInfo,
- };
});
diff --git a/src/utils/http/index.ts b/src/utils/http/index.ts
index 5ec2d96..3f30927 100644
--- a/src/utils/http/index.ts
+++ b/src/utils/http/index.ts
@@ -6,7 +6,10 @@ import { getBaseUrl, isUseMock } from '@/utils/env';
import { mockAdapter } from '@/mock';
import { ContentTypeEnum, ResultEnum } from '@/enums/httpEnum';
import type { API } from '@/services/model/baseModel';
-import { getAuthorization } from '@/utils/auth';
+
+function getAuthorization() {
+ return '1';
+}
const BASE_URL = getBaseUrl();
diff --git a/tsconfig.json b/tsconfig.json
index 2ae6126..51a00f2 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,59 +1,67 @@
{ // 指定要从编译中排除的文件列表
- "compilerOptions": { // 为所有发出的文件指定一个输出文件夹
- "target": "ESNext", // 允许export=导出,由import from 导入
- "lib": ["ESNext", "DOM", "ScriptHost"], // 是否启用对装饰器的实验性支持,装饰器是一种语言特性,还没有完全被 JavaScript 规范批准
- "emitDecoratorMetadata": true, // 是否通过" . “(obj.key) 语法访问字段和"索引”( obj[“key”]), 以及在类型中声明属性的方式之间的一致性
-
+ "compilerOptions": {
+ "target": "ESNext", // 编译出目标语言版本
+ "jsx": "preserve",
+ "jsxImportSource": "vue",
+ "lib": ["ESNext", "DOM", "ScriptHost"], // TS需要引用的库
+ "emitDecoratorMetadata": true, // 为装饰器启用对发出类型元数据的实验性支持
/* 实验选项 */
- "experimentalDecorators": true,
- "baseUrl": "./", // 指定基目录以解析非相对模块名
- "rootDir": "./src", // 编译出目标语言版本
+ "experimentalDecorators": true, // 是否启用对装饰器的实验性支持,装饰器是一种语言特性,还没有完全被 JavaScript 规范批准
+ "baseUrl": ".", // 指定基目录以解析非相对模块名
"module": "ESNext", // 生成代码的模板标准
- "moduleResolution": "node", // 删除注释
- "paths": { "@/*": ["./src/*"] }, // 有错误时不进行编译
- "resolveJsonModule": true, // TS需要引用的库
- "types": ["@types/node"], // 在源文件中指定根文件夹
- /* 严格检查选项 */
- "strict": true, // 设置发出文件的换行符
+ "moduleResolution": "node", // 指定TypeScript如何从给定的模块说明符查找文件
+ // 指定一组条目,它们将导入重新映射到其他查找位置
+ "paths": {
+ "~/*": ["./*"],
+ "@/*": ["./src/*"]
+ },
+ "resolveJsonModule": true, // 是否解析 JSON 模块
+ "types": ["vite/client", "node"], // 指定要包含的类型包名,而不需要在源文件中引用
// "sourceMap": true, //为发出的JavaScript文件创建源映射文件。
// "declaration": true, // 从项目中的TypeScript和JavaScript文件生成.d.ts文件
// "declarationMap": true, // 为d.ts文件创建源地图
-
+ /* 严格检查选项 */
+ "strict": true, // 开启所有严格的类型检查
"strictBindCallApply": true, // 检查bind、call和apply方法的参数是否与原始函数匹配。
- "strictFunctionTypes": true, // 不允许this有隐式的any类型
- "strictNullChecks": true, // 在给函数赋值时,要确保参数和返回值是子类型兼容的。
- "strictPropertyInitialization": true, // 开启所有严格的类型检查
- "alwaysStrict": true, // 是否检查子类继承自基类时,其重载的函数命名与基类的函数不同步问题
- "noFallthroughCasesInSwitch": true, // 在代码中注入'use strict'
- "noImplicitAny": true, // 检查函数是否不含有隐式返回值
- "noImplicitOverride": true, // 是否检查未使用的参数
- "noImplicitReturns": true, // 不允许隐式的any类型
- "noImplicitThis": true, // 是否通过索引签名来描述对象上有未知键但已知值的对象
- "noPropertyAccessFromIndexSignature": false, // 检查switch中是否含有case没有使用break跳出
- "noUncheckedIndexedAccess": true, // 类的实例属性必须初始化
-
+ "strictFunctionTypes": true, // 在给函数赋值时,要确保参数和返回值是子类型兼容的。
+ "strictNullChecks": true, // 在进行类型检查时,请考虑null和undefined。
+ "strictPropertyInitialization": true, // 类的实例属性必须初始化
+ "alwaysStrict": true, // 在代码中注入'use strict'
+ "noFallthroughCasesInSwitch": true, // 检查switch中是否含有case没有使用break跳出
+ "noImplicitAny": false, // 不允许隐式的any类型
+ "noImplicitOverride": true, // 是否检查子类继承自基类时,其重载的函数命名与基类的函数不同步问题
+ "noImplicitReturns": true, // 检查函数是否不含有隐式返回值
+ "noImplicitThis": true, // 不允许this有隐式的any类型
+ "noPropertyAccessFromIndexSignature": false, // 是否通过" . “(obj.key) 语法访问字段和"索引”( obj[“key”]), 以及在类型中声明属性的方式之间的一致性
+ "noUncheckedIndexedAccess": true, // 是否通过索引签名来描述对象上有未知键但已知值的对象
/* 额外检查 */
"noUnusedLocals": true, // 是否检查未使用的局部变量
- "noUnusedParameters": true, // 在输出中启用颜色和格式,使编译器错误更容易阅读
- "newLine": "crlf", // 是否查看 TS 在编译时花费的时间
- "noEmitOnError": true, // 在进行类型检查时,请考虑null和undefined。
- "outDir": "./dist", // 指定要包含的类型包名,而不需要在源文件中引用
- "removeComments": true, // 指定TypeScript如何从给定的模块说明符查找文件
- "esModuleInterop": true, // 指定一组条目,它们将导入重新映射到其他查找位置
- "pretty": true, // 为装饰器启用对发出类型元数据的实验性支持
-
+ "noUnusedParameters": true, // 是否检查未使用的参数
+ "newLine": "crlf", // 设置发出文件的换行符
+ "noEmitOnError": true, // 有错误时不进行编译
+ "removeComments": true, // 删除注释
+ // "incremental": true // 增量编译
+ "allowSyntheticDefaultImports": true,
+ "esModuleInterop": true, // 允许export=导出,由import from 导入
/* 高级选项 */
"forceConsistentCasingInFileNames": true, // 是否区分文件系统大小写规则
- "extendedDiagnostics": false // 是否解析 JSON 模块
- // "incremental": true // 增量编译
+ "isolatedModules": true,
+ // "rootDir": "./src", // 在源文件中指定根文件夹
+ // "outDir": "./dist", // 为所有发出的文件指定一个输出文件夹
+ // "extendedDiagnostics": true, //是否查看 TS 在编译时花费的时间
+ "pretty": true // 在输出中启用颜色和格式,使编译器错误更容易阅读
},
"include": [
- "src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"vite.config.*",
- "typings/*.d.ts"
+ "typings/*.ts",
+ "typings/*.d.ts",
+ "./**/*.ts",
+ "./**/**/*.ts",
+ "./**/*.tsx",
+ "./**/*.vue"
], // 指定要包含在编译中的文件匹配列表
- "exclude": []
+ "exclude": ["node_modules", "dist"]
}
diff --git a/vite.config.ts b/vite.config.ts
index 9ca06fe..6f76ccc 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -14,6 +14,7 @@ import transformClass from 'unplugin-transform-class/vite';
import { visualizer } from 'rollup-plugin-visualizer';
import ViteRestart from 'vite-plugin-restart';
import AutoImport from 'unplugin-auto-import/vite';
+import { appProvider, buildThemeConfig, createComponents } from './vite/plugins/index';
export default defineConfig(async ({ mode }) => {
const root = process.cwd();
@@ -47,6 +48,9 @@ export default defineConfig(async ({ mode }) => {
},
},
plugins: [
+ appProvider(),
+ buildThemeConfig(),
+ createComponents(),
// @ts-expect-error TODO uni() 会报错:uni is not a function,暂时使用此方式解决
uni?.default(),
AutoImport({