befly-admin 3.4.26 → 3.4.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.html CHANGED
@@ -8,6 +8,6 @@
8
8
  </head>
9
9
  <body>
10
10
  <div id="app"></div>
11
- <script type="module" src="/src/main.ts"></script>
11
+ <script type="module" src="/src/main.js"></script>
12
12
  </body>
13
13
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "befly-admin",
3
- "version": "3.4.26",
3
+ "version": "3.4.28",
4
4
  "description": "Befly Admin - 基于 Vue3 + OpenTiny Vue 的后台管理系统",
5
5
  "type": "module",
6
6
  "private": false,
@@ -12,7 +12,7 @@
12
12
  "src",
13
13
  "public",
14
14
  "index.html",
15
- "vite.config.ts",
15
+ "vite.config.js",
16
16
  "tsconfig.json",
17
17
  ".env",
18
18
  ".env.development",
@@ -36,7 +36,7 @@
36
36
  "vue-router": "^4.6.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@befly-addon/admin": "1.0.29",
39
+ "@befly-addon/admin": "1.0.30",
40
40
  "@iconify-json/lucide": "^1.2.72",
41
41
  "@opentiny/unplugin-tiny-vue": "^1.0.0",
42
42
  "@unocss/preset-attributify": "^66.5.6",
@@ -49,7 +49,7 @@
49
49
  "unplugin-auto-import": "^20.2.0",
50
50
  "unplugin-icons": "^22.5.0",
51
51
  "unplugin-vue-components": "^30.0.0",
52
- "unplugin-vue-router": "^0.16.2",
52
+ "unplugin-vue-router": "^0.17.0",
53
53
  "vite": "^7.2.2",
54
54
  "vite-plugin-vue-devtools": "^8.0.3",
55
55
  "vue-tsc": "^3.1.3"
@@ -58,5 +58,5 @@
58
58
  "node": ">=24.0.0",
59
59
  "pnpm": ">=10.0.0"
60
60
  },
61
- "gitHead": "5cb110dfdbc9dda0f85729ee51173a7122decb50"
61
+ "gitHead": "178b2045d0a76ba734ec623b7e478b3024a58e6d"
62
62
  }
@@ -1,16 +1,16 @@
1
- import axios, { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse } from 'axios';
1
+ import axios from 'axios';
2
2
  import { Modal } from '@opentiny/vue';
3
3
  import { $Storage } from './storage';
4
4
 
5
- // API 响应格式
6
- interface ApiResponse<T = any> {
7
- code: 0 | 1;
8
- msg: string;
9
- data: T;
10
- }
5
+ /**
6
+ * @typedef {Object} ApiResponse
7
+ * @property {0 | 1} code
8
+ * @property {string} msg
9
+ * @property {any} data
10
+ */
11
11
 
12
12
  // 创建 axios 实例
13
- const request: AxiosInstance = axios.create({
13
+ const request = axios.create({
14
14
  baseURL: import.meta.env.VITE_API_BASE_URL,
15
15
  timeout: 10000,
16
16
  headers: {
@@ -44,7 +44,7 @@ request.interceptors.request.use(
44
44
 
45
45
  // 响应拦截器
46
46
  request.interceptors.response.use(
47
- (response: AxiosResponse<ApiResponse>) => {
47
+ (response) => {
48
48
  const res = response.data;
49
49
 
50
50
  // 如果code不是0,说明业务失败
@@ -56,7 +56,7 @@ request.interceptors.response.use(
56
56
  return Promise.reject(res.data);
57
57
  }
58
58
 
59
- return res as any;
59
+ return res;
60
60
  },
61
61
  (error) => {
62
62
  Modal.message({ message: '网络连接失败', status: 'error' });
@@ -66,14 +66,15 @@ request.interceptors.response.use(
66
66
 
67
67
  /**
68
68
  * 统一的 HTTP 请求方法(仅支持 GET 和 POST)
69
- * @param url - 请求路径
70
- * @param data - 请求数据,默认为空对象
71
- * @param method - 请求方法,默认为 'post',可选 'get' | 'post'
72
- * @param config - axios 请求配置
73
- * @returns Promise<ApiResponse<T>>
69
+ * @template T
70
+ * @param {string} url - 请求路径
71
+ * @param {any} [data={}] - 请求数据,默认为空对象
72
+ * @param {'get' | 'post'} [method='post'] - 请求方法,默认为 'post',可选 'get' | 'post'
73
+ * @param {import('axios').AxiosRequestConfig} [config] - axios 请求配置
74
+ * @returns {Promise<ApiResponse>}
74
75
  */
75
- export function $Http<T = any>(url: string, data: any = {}, method: 'get' | 'post' = 'post', config?: AxiosRequestConfig): Promise<ApiResponse<T>> {
76
- const methodLower = method.toLowerCase() as 'get' | 'post';
76
+ export function $Http(url, data = {}, method = 'post', config) {
77
+ const methodLower = method.toLowerCase();
77
78
 
78
79
  // GET 请求将 data 作为 params
79
80
  if (methodLower === 'get') {
@@ -10,11 +10,10 @@ const NAMESPACE = import.meta.env.VITE_STORAGE_NAMESPACE || 'befly';
10
10
  * 存储操作类
11
11
  */
12
12
  class StorageManager {
13
- private localStorage: Storage;
14
- private sessionStorage: Storage;
15
- private namespace: string;
16
-
17
- constructor(namespace: string = NAMESPACE) {
13
+ /**
14
+ * @param {string} namespace
15
+ */
16
+ constructor(namespace = NAMESPACE) {
18
17
  this.localStorage = window.localStorage;
19
18
  this.sessionStorage = window.sessionStorage;
20
19
  this.namespace = namespace;
@@ -22,22 +21,26 @@ class StorageManager {
22
21
 
23
22
  /**
24
23
  * 生成带命名空间的key
24
+ * @param {string} key
25
+ * @returns {string}
25
26
  */
26
- private getKey(key: string): string {
27
+ getKey(key) {
27
28
  return `${this.namespace}:${key}`;
28
29
  }
29
30
 
30
31
  /**
31
32
  * 创建存储操作方法
33
+ * @param {Storage} storage
32
34
  */
33
- private createStorageOps(storage: Storage) {
35
+ createStorageOps(storage) {
34
36
  return {
35
37
  /**
36
38
  * 设置存储
37
- * @param key 键名
38
- * @param value 值(自动序列化)
39
+ * @param {string} key - 键名
40
+ * @param {any} value - 值(自动序列化)
41
+ * @returns {void}
39
42
  */
40
- set: (key: string, value: any): void => {
43
+ set: (key, value) => {
41
44
  try {
42
45
  const fullKey = this.getKey(key);
43
46
  const serializedValue = JSON.stringify(value);
@@ -49,18 +52,19 @@ class StorageManager {
49
52
 
50
53
  /**
51
54
  * 获取存储
52
- * @param key 键名
53
- * @param defaultValue 默认值
54
- * @returns 解析后的值
55
+ * @template T
56
+ * @param {string} key - 键名
57
+ * @param {T | null} [defaultValue=null] - 默认值
58
+ * @returns {T | null} 解析后的值
55
59
  */
56
- get: <T = any>(key: string, defaultValue: T | null = null): T | null => {
60
+ get: (key, defaultValue = null) => {
57
61
  try {
58
62
  const fullKey = this.getKey(key);
59
63
  const value = storage.getItem(fullKey);
60
64
  if (value === null) {
61
65
  return defaultValue;
62
66
  }
63
- return JSON.parse(value) as T;
67
+ return JSON.parse(value);
64
68
  } catch (error) {
65
69
  console.error(`Storage.get error for key "${key}":`, error);
66
70
  return defaultValue;
@@ -69,9 +73,10 @@ class StorageManager {
69
73
 
70
74
  /**
71
75
  * 删除存储
72
- * @param key 键名
76
+ * @param {string} key - 键名
77
+ * @returns {void}
73
78
  */
74
- remove: (key: string): void => {
79
+ remove: (key) => {
75
80
  try {
76
81
  const fullKey = this.getKey(key);
77
82
  storage.removeItem(fullKey);
@@ -82,8 +87,9 @@ class StorageManager {
82
87
 
83
88
  /**
84
89
  * 清空当前命名空间下的所有存储
90
+ * @returns {void}
85
91
  */
86
- clear: (): void => {
92
+ clear: () => {
87
93
  try {
88
94
  const keys = Object.keys(storage);
89
95
  const prefix = `${this.namespace}:`;
@@ -98,49 +104,41 @@ class StorageManager {
98
104
  },
99
105
 
100
106
  /**
101
- * 检查键是否存在
102
- * @param key 键名
103
- * @returns 是否存在
107
+ * 判断是否存在某个键
108
+ * @param {string} key - 键名
109
+ * @returns {boolean}
104
110
  */
105
- has: (key: string): boolean => {
106
- try {
107
- const fullKey = this.getKey(key);
108
- return storage.getItem(fullKey) !== null;
109
- } catch (error) {
110
- console.error(`Storage.has error for key "${key}":`, error);
111
- return false;
112
- }
111
+ has: (key) => {
112
+ const fullKey = this.getKey(key);
113
+ return storage.getItem(fullKey) !== null;
113
114
  },
114
115
 
115
116
  /**
116
- * 获取所有当前命名空间的键
117
- * @returns 键名数组(不含命名空间前缀)
117
+ * 获取所有键名
118
+ * @returns {string[]} 去除命名空间前缀的键名列表
118
119
  */
119
- keys: (): string[] => {
120
- try {
121
- const allKeys = Object.keys(storage);
122
- const prefix = `${this.namespace}:`;
123
- return allKeys.filter((key) => key.startsWith(prefix)).map((key) => key.replace(prefix, ''));
124
- } catch (error) {
125
- console.error('Storage.keys error:', error);
126
- return [];
127
- }
120
+ keys: () => {
121
+ const keys = Object.keys(storage);
122
+ const prefix = `${this.namespace}:`;
123
+ return keys.filter((key) => key.startsWith(prefix)).map((key) => key.substring(prefix.length));
128
124
  }
129
125
  };
130
126
  }
131
127
 
132
- /** localStorage 操作 */
128
+ /**
129
+ * localStorage 操作方法
130
+ */
133
131
  get local() {
134
132
  return this.createStorageOps(this.localStorage);
135
133
  }
136
134
 
137
- /** sessionStorage 操作 */
135
+ /**
136
+ * sessionStorage 操作方法
137
+ */
138
138
  get session() {
139
139
  return this.createStorageOps(this.sessionStorage);
140
140
  }
141
141
  }
142
142
 
143
- /**
144
- * 统一的存储操作对象(单例)
145
- */
143
+ // 导出单例
146
144
  export const $Storage = new StorageManager();
@@ -2,7 +2,6 @@ import { createRouter, createWebHashHistory } from 'vue-router';
2
2
  import { routes } from 'vue-router/auto-routes';
3
3
  import { $Storage } from '@/plugins/storage';
4
4
  import { Layouts } from '@befly-addon/admin/utils/layouts';
5
- import type { RouteRecordRaw } from 'vue-router';
6
5
 
7
6
  /**
8
7
  * @typedef {import('@befly-addon/admin/utils/layouts').LayoutConfig} LayoutConfig
@@ -11,8 +10,10 @@ import type { RouteRecordRaw } from 'vue-router';
11
10
  /**
12
11
  * 将布局配置转换为实际的路由配置
13
12
  * 在这里执行实际的布局组件导入
13
+ * @param {LayoutConfig[]} configs
14
+ * @returns {import('vue-router').RouteRecordRaw[]}
14
15
  */
15
- function applyLayouts(configs: LayoutConfig[]): RouteRecordRaw[] {
16
+ function applyLayouts(configs) {
16
17
  return configs.map((config) => {
17
18
  // 根据布局名称加载对应的布局组件
18
19
  const layoutComponent = config.layoutName === 'default' ? () => import('@/layouts/default.vue') : () => import(`@/layouts/${config.layoutName}.vue`);
@@ -37,7 +38,7 @@ function applyLayouts(configs: LayoutConfig[]): RouteRecordRaw[] {
37
38
  const layoutRoutes = applyLayouts(Layouts(routes));
38
39
 
39
40
  // 添加根路径重定向
40
- const finalRoutes: RouteRecordRaw[] = [
41
+ const finalRoutes = [
41
42
  {
42
43
  path: '/',
43
44
  redirect: '/addon/admin'
@@ -47,7 +48,7 @@ const finalRoutes: RouteRecordRaw[] = [
47
48
 
48
49
  /**
49
50
  * 创建并导出路由实例
50
- * 可直接在 main.ts 中使用 app.use(router)
51
+ * 可直接在 main.js 中使用 app.use(router)
51
52
  */
52
53
  export const router = createRouter({
53
54
  history: createWebHashHistory(import.meta.env.BASE_URL),
@@ -6,9 +6,9 @@
6
6
  // biome-ignore lint: disable
7
7
  export {}
8
8
  declare global {
9
- const $Config: typeof import('../config/index').$Config
10
- const $Http: typeof import('../plugins/http').$Http
11
- const $Storage: typeof import('../plugins/storage').$Storage
9
+ const $Config: typeof import('../config/index.js').$Config
10
+ const $Http: typeof import('../plugins/http.js').$Http
11
+ const $Storage: typeof import('../plugins/storage.js').$Storage
12
12
  const EffectScope: typeof import('vue').EffectScope
13
13
  const Loading: typeof import('@opentiny/vue').Loading
14
14
  const Message: typeof import('@opentiny/vue').Message
@@ -16,7 +16,7 @@ declare global {
16
16
  const Modal: typeof import('@opentiny/vue').Modal
17
17
  const Notify: typeof import('@opentiny/vue').Notify
18
18
  const acceptHMRUpdate: typeof import('pinia').acceptHMRUpdate
19
- const arrayToTree: typeof import('../utils/index').arrayToTree
19
+ const arrayToTree: typeof import('../utils/index.js').arrayToTree
20
20
  const computed: typeof import('vue').computed
21
21
  const createApp: typeof import('vue').createApp
22
22
  const createPinia: typeof import('pinia').createPinia
@@ -80,7 +80,7 @@ declare global {
80
80
  const useAttrs: typeof import('vue').useAttrs
81
81
  const useCssModule: typeof import('vue').useCssModule
82
82
  const useCssVars: typeof import('vue').useCssVars
83
- const useGlobal: typeof import('../plugins/global').useGlobal
83
+ const useGlobal: typeof import('../plugins/global.js').useGlobal
84
84
  const useId: typeof import('vue').useId
85
85
  const useModel: typeof import('vue').useModel
86
86
  const useRoute: typeof import('vue-router').useRoute
@@ -104,9 +104,9 @@ import { UnwrapRef } from 'vue'
104
104
  declare module 'vue' {
105
105
  interface GlobalComponents {}
106
106
  interface ComponentCustomProperties {
107
- readonly $Config: UnwrapRef<typeof import('../config/index')['$Config']>
108
- readonly $Http: UnwrapRef<typeof import('../plugins/http')['$Http']>
109
- readonly $Storage: UnwrapRef<typeof import('../plugins/storage')['$Storage']>
107
+ readonly $Config: UnwrapRef<typeof import('../config/index.js')['$Config']>
108
+ readonly $Http: UnwrapRef<typeof import('../plugins/http.js')['$Http']>
109
+ readonly $Storage: UnwrapRef<typeof import('../plugins/storage.js')['$Storage']>
110
110
  readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
111
111
  readonly Loading: UnwrapRef<typeof import('@opentiny/vue')['Loading']>
112
112
  readonly Message: UnwrapRef<typeof import('@opentiny/vue')['Message']>
@@ -114,7 +114,7 @@ declare module 'vue' {
114
114
  readonly Modal: UnwrapRef<typeof import('@opentiny/vue')['Modal']>
115
115
  readonly Notify: UnwrapRef<typeof import('@opentiny/vue')['Notify']>
116
116
  readonly acceptHMRUpdate: UnwrapRef<typeof import('pinia')['acceptHMRUpdate']>
117
- readonly arrayToTree: UnwrapRef<typeof import('../utils/index')['arrayToTree']>
117
+ readonly arrayToTree: UnwrapRef<typeof import('../utils/index.js')['arrayToTree']>
118
118
  readonly computed: UnwrapRef<typeof import('vue')['computed']>
119
119
  readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
120
120
  readonly createPinia: UnwrapRef<typeof import('pinia')['createPinia']>
@@ -177,7 +177,7 @@ declare module 'vue' {
177
177
  readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
178
178
  readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
179
179
  readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']>
180
- readonly useGlobal: UnwrapRef<typeof import('../plugins/global')['useGlobal']>
180
+ readonly useGlobal: UnwrapRef<typeof import('../plugins/global.js')['useGlobal']>
181
181
  readonly useId: UnwrapRef<typeof import('vue')['useId']>
182
182
  readonly useModel: UnwrapRef<typeof import('vue')['useModel']>
183
183
  readonly useRoute: UnwrapRef<typeof import('vue-router')['useRoute']>
@@ -17,9 +17,6 @@ declare module 'vue' {
17
17
  RouterLink: typeof import('vue-router')['RouterLink']
18
18
  RouterView: typeof import('vue-router')['RouterView']
19
19
  TinyButton: typeof import('@opentiny/vue-button')['default']
20
- TinyCol: typeof import('@opentiny/vue-col')['default']
21
- TinyDivider: typeof import('@opentiny/vue-divider')['default']
22
- TinyRow: typeof import('@opentiny/vue-row')['default']
23
20
  TinyTag: typeof import('@opentiny/vue-tag')['default']
24
21
  TinyTreeMenu: typeof import('@opentiny/vue-tree-menu')['default']
25
22
  }
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * 将一维数组转换为树形结构
3
- * @param items 一维数组
4
- * @param pid 父节点ID,默认为0
5
- * @returns 树形结构数组
3
+ * @template T
4
+ * @param {T[]} items - 一维数组
5
+ * @param {number} [pid=0] - 父节点ID,默认为0
6
+ * @returns {T[]} 树形结构数组
6
7
  */
7
- export function arrayToTree<T extends { id: number; pid: number; children?: T[] }>(items: T[], pid = 0): T[] {
8
- const tree: T[] = [];
8
+ export function arrayToTree(items, pid = 0) {
9
+ const tree = [];
9
10
 
10
11
  for (const item of items) {
11
12
  if (item.pid === pid) {
package/vite.config.js ADDED
@@ -0,0 +1,136 @@
1
+ import { defineConfig } from 'vite';
2
+ import vue from '@vitejs/plugin-vue';
3
+ import VueRouter from 'unplugin-vue-router/vite';
4
+ import { VueRouterAutoImports } from 'unplugin-vue-router';
5
+ import VueDevTools from 'vite-plugin-vue-devtools';
6
+ import AutoImport from 'unplugin-auto-import/vite';
7
+ import Components from 'unplugin-vue-components/vite';
8
+ import Icons from 'unplugin-icons/vite';
9
+ import IconsResolver from 'unplugin-icons/resolver';
10
+ import ReactivityTransform from '@vue-macros/reactivity-transform/vite';
11
+ import { TinyVueSingleResolver } from '@opentiny/unplugin-tiny-vue';
12
+ import UnoCSS from 'unocss/vite';
13
+ import { fileURLToPath, URL } from 'node:url';
14
+ import { scanBeflyAddonViews } from '@befly-addon/admin/utils/scanBeflyAddonViews';
15
+
16
+ export default defineConfig({
17
+ // 基础路径配置(支持二级目录部署)
18
+ base: './',
19
+
20
+ // 插件配置
21
+ plugins: [
22
+ // UnoCSS
23
+ UnoCSS(),
24
+
25
+ // Vue DevTools(仅开发环境)
26
+ VueDevTools(),
27
+
28
+ // VueRouter 必须在 Vue 插件之前
29
+ VueRouter({
30
+ routesFolder: scanBeflyAddonViews(),
31
+ dts: './src/types/typed-router.d.ts',
32
+ extensions: ['.vue'],
33
+ importMode: 'async',
34
+ // 全局排除 components 目录
35
+ exclude: ['**/components/**']
36
+ }),
37
+
38
+ // Vue 插件
39
+ vue({
40
+ script: {
41
+ defineModel: true,
42
+ propsDestructure: true
43
+ }
44
+ }),
45
+
46
+ // Vue Reactivity Transform 支持
47
+ ReactivityTransform(),
48
+
49
+ // API 自动导入
50
+ AutoImport({
51
+ imports: [
52
+ 'vue',
53
+ 'pinia',
54
+ VueRouterAutoImports,
55
+ {
56
+ '@opentiny/vue': ['Modal', 'Notify', 'Message', 'MessageBox', 'Loading']
57
+ }
58
+ ],
59
+ dts: 'src/types/auto-imports.d.ts',
60
+ dirs: ['src/utils', 'src/plugins', 'src/config'],
61
+ vueTemplate: true
62
+ }),
63
+
64
+ // 组件自动导入
65
+ Components({
66
+ resolvers: [TinyVueSingleResolver, IconsResolver({})],
67
+ dirs: ['src/components'],
68
+ deep: true,
69
+ dts: 'src/types/components.d.ts'
70
+ }),
71
+
72
+ // 图标
73
+ Icons({
74
+ compiler: 'vue3',
75
+ autoInstall: true,
76
+ defaultClass: 'icon-befly',
77
+ defaultStyle: 'margin-right: 8px; vertical-align: middle;'
78
+ })
79
+ ],
80
+
81
+ // 路径别名
82
+ resolve: {
83
+ alias: {
84
+ '@': fileURLToPath(new URL('./src', import.meta.url))
85
+ }
86
+ },
87
+
88
+ // 服务器配置
89
+ server: {
90
+ port: 5600,
91
+ host: '0.0.0.0',
92
+ strictPort: true,
93
+ open: false,
94
+ hmr: true
95
+ },
96
+
97
+ // 构建配置
98
+ build: {
99
+ target: 'es2020',
100
+ outDir: 'dist',
101
+ assetsDir: 'assets',
102
+ sourcemap: false,
103
+ minify: 'esbuild',
104
+ rollupOptions: {
105
+ output: {
106
+ chunkFileNames: 'assets/js/[name]-[hash].js',
107
+ entryFileNames: 'assets/js/[name]-[hash].js',
108
+ assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
109
+ manualChunks: {
110
+ // Vue 核心
111
+ 'vue-vendor': ['vue', 'vue-router', 'pinia'],
112
+ // UI 组件库
113
+ 'ui-vendor': ['@opentiny/vue'],
114
+ // 工具库
115
+ 'utils-vendor': ['axios']
116
+ }
117
+ }
118
+ }
119
+ },
120
+
121
+ // CSS 配置
122
+ css: {
123
+ preprocessorOptions: {
124
+ scss: {
125
+ api: 'modern-compiler',
126
+ // 自动导入全局 SCSS 变量
127
+ additionalData: `@use "@/styles/variables.scss" as *;`
128
+ }
129
+ }
130
+ },
131
+
132
+ // 优化配置
133
+ optimizeDeps: {
134
+ include: ['vue', 'vue-router', 'pinia', 'axios', '@opentiny/vue', 'vue-macros/macros']
135
+ }
136
+ });
package/vite.config.ts DELETED
@@ -1,337 +0,0 @@
1
- import { defineConfig } from 'vite';
2
- import vue from '@vitejs/plugin-vue';
3
- import VueRouter from 'unplugin-vue-router/vite';
4
- import { VueRouterAutoImports } from 'unplugin-vue-router';
5
- import VueDevTools from 'vite-plugin-vue-devtools';
6
- import AutoImport from 'unplugin-auto-import/vite';
7
- import Components from 'unplugin-vue-components/vite';
8
- import Icons from 'unplugin-icons/vite';
9
- import IconsResolver from 'unplugin-icons/resolver';
10
- import ReactivityTransform from '@vue-macros/reactivity-transform/vite';
11
- import { TinyVueSingleResolver } from '@opentiny/unplugin-tiny-vue';
12
- import UnoCSS from 'unocss/vite';
13
- import { fileURLToPath, URL } from 'node:url';
14
- import { scanBeflyAddonViews } from '@befly-addon/admin/utils/scanBeflyAddonViews';
15
-
16
- const routesFolders = scanBeflyAddonViews();
17
-
18
- export default defineConfig({
19
- // 插件配置
20
- plugins: [
21
- // UnoCSS
22
- UnoCSS(),
23
-
24
- // Vue DevTools(仅开发环境)
25
- VueDevTools(),
26
-
27
- // VueRouter 必须在 Vue 插件之前
28
- VueRouter({
29
- routesFolder: routesFolders,
30
- dts: './src/types/typed-router.d.ts',
31
- extensions: ['.vue'],
32
- importMode: 'async',
33
- // 全局排除 components 目录
34
- exclude: ['**/components/**']
35
- }),
36
-
37
- // Vue 插件
38
- vue({
39
- script: {
40
- defineModel: true,
41
- propsDestructure: true
42
- }
43
- }),
44
-
45
- // Vue Reactivity Transform 支持
46
- ReactivityTransform(),
47
-
48
- // API 自动导入
49
- AutoImport({
50
- imports: [
51
- 'vue',
52
- 'pinia',
53
- VueRouterAutoImports,
54
- {
55
- '@opentiny/vue': ['Modal', 'Notify', 'Message', 'MessageBox', 'Loading']
56
- }
57
- ],
58
- dts: 'src/types/auto-imports.d.ts',
59
- dirs: ['src/utils', 'src/plugins', 'src/config'],
60
- vueTemplate: true
61
- }),
62
-
63
- // 组件自动导入
64
- Components({
65
- resolvers: [TinyVueSingleResolver, IconsResolver({})],
66
- dirs: ['src/components'],
67
- deep: true,
68
- dts: 'src/types/components.d.ts'
69
- }),
70
-
71
- // 图标
72
- Icons({
73
- compiler: 'vue3',
74
- autoInstall: true,
75
- defaultClass: 'icon-befly',
76
- defaultStyle: 'margin-right: 8px; vertical-align: middle;'
77
- })
78
- ],
79
-
80
- // 路径别名
81
- resolve: {
82
- alias: {
83
- '@': fileURLToPath(new URL('./src', import.meta.url))
84
- }
85
- },
86
-
87
- // 服务器配置
88
- server: {
89
- port: 5600,
90
- host: '0.0.0.0',
91
- strictPort: true,
92
- open: false,
93
- hmr: true
94
- },
95
-
96
- // 构建配置
97
- build: {
98
- target: 'es2020',
99
- outDir: 'dist',
100
- assetsDir: 'assets',
101
- sourcemap: false,
102
- minify: 'esbuild',
103
- rollupOptions: {
104
- external: ['vue', 'vue-router', 'pinia', '@opentiny/vue', 'axios', 'vue-macros/macros'],
105
- output: {
106
- chunkFileNames: 'assets/[name]-[hash].js',
107
- entryFileNames: 'assets/[name]-[hash].js',
108
- assetFileNames: 'assets/[name]-[hash].[ext]'
109
- }
110
- }
111
- },
112
-
113
- // CSS 配置
114
- css: {
115
- preprocessorOptions: {
116
- scss: {
117
- api: 'modern-compiler',
118
- // 自动导入全局 SCSS 变量
119
- additionalData: `@use "@/styles/variables.scss" as *;`
120
- }
121
- }
122
- },
123
-
124
- // 定义全局变量
125
- define: {
126
- __DEV__: JSON.stringify(process.env.NODE_ENV !== 'production')
127
- },
128
-
129
- // 优化依赖预构建
130
- optimizeDeps: {
131
- include: [
132
- 'vue',
133
- 'vue-router',
134
- 'pinia',
135
- 'axios',
136
- // OpenTiny Vue 所有组件
137
- '@opentiny/vue',
138
- '@opentiny/vue-action-menu',
139
- '@opentiny/vue-action-sheet',
140
- '@opentiny/vue-alert',
141
- '@opentiny/vue-amount',
142
- '@opentiny/vue-anchor',
143
- '@opentiny/vue-area',
144
- '@opentiny/vue-async-flowchart',
145
- '@opentiny/vue-autocomplete',
146
- '@opentiny/vue-badge',
147
- '@opentiny/vue-base-select',
148
- '@opentiny/vue-breadcrumb',
149
- '@opentiny/vue-breadcrumb-item',
150
- '@opentiny/vue-bulletin-board',
151
- '@opentiny/vue-button',
152
- '@opentiny/vue-button-group',
153
- '@opentiny/vue-calendar',
154
- '@opentiny/vue-calendar-bar',
155
- '@opentiny/vue-calendar-view',
156
- '@opentiny/vue-card',
157
- '@opentiny/vue-card-group',
158
- '@opentiny/vue-card-template',
159
- '@opentiny/vue-carousel',
160
- '@opentiny/vue-carousel-item',
161
- '@opentiny/vue-cascader',
162
- '@opentiny/vue-cascader-menu',
163
- '@opentiny/vue-cascader-mobile',
164
- '@opentiny/vue-cascader-node',
165
- '@opentiny/vue-cascader-panel',
166
- '@opentiny/vue-cascader-select',
167
- '@opentiny/vue-cascader-view',
168
- '@opentiny/vue-cell',
169
- '@opentiny/vue-checkbox',
170
- '@opentiny/vue-checkbox-button',
171
- '@opentiny/vue-checkbox-group',
172
- '@opentiny/vue-col',
173
- '@opentiny/vue-collapse',
174
- '@opentiny/vue-collapse-item',
175
- '@opentiny/vue-collapse-transition',
176
- '@opentiny/vue-color-picker',
177
- '@opentiny/vue-color-select-panel',
178
- '@opentiny/vue-column-list-group',
179
- '@opentiny/vue-column-list-item',
180
- '@opentiny/vue-company',
181
- '@opentiny/vue-config-provider',
182
- '@opentiny/vue-container',
183
- '@opentiny/vue-country',
184
- '@opentiny/vue-crop',
185
- '@opentiny/vue-currency',
186
- '@opentiny/vue-date-panel',
187
- '@opentiny/vue-date-picker',
188
- '@opentiny/vue-date-picker-mobile-first',
189
- '@opentiny/vue-date-range',
190
- '@opentiny/vue-date-table',
191
- '@opentiny/vue-dept',
192
- '@opentiny/vue-dialog-box',
193
- '@opentiny/vue-dialog-select',
194
- '@opentiny/vue-divider',
195
- '@opentiny/vue-drawer',
196
- '@opentiny/vue-drop-roles',
197
- '@opentiny/vue-drop-times',
198
- '@opentiny/vue-dropdown',
199
- '@opentiny/vue-dropdown-item',
200
- '@opentiny/vue-dropdown-menu',
201
- '@opentiny/vue-dynamic-scroller',
202
- '@opentiny/vue-dynamic-scroller-item',
203
- '@opentiny/vue-espace',
204
- '@opentiny/vue-exception',
205
- '@opentiny/vue-fall-menu',
206
- '@opentiny/vue-file-upload',
207
- '@opentiny/vue-filter',
208
- '@opentiny/vue-filter-bar',
209
- '@opentiny/vue-filter-box',
210
- '@opentiny/vue-filter-panel',
211
- '@opentiny/vue-float-button',
212
- '@opentiny/vue-floatbar',
213
- '@opentiny/vue-floating-button',
214
- '@opentiny/vue-flowchart',
215
- '@opentiny/vue-fluent-editor',
216
- '@opentiny/vue-form',
217
- '@opentiny/vue-form-item',
218
- '@opentiny/vue-fullscreen',
219
- '@opentiny/vue-grid',
220
- '@opentiny/vue-grid-column',
221
- '@opentiny/vue-grid-manager',
222
- '@opentiny/vue-grid-select',
223
- '@opentiny/vue-grid-toolbar',
224
- '@opentiny/vue-guide',
225
- '@opentiny/vue-hrapprover',
226
- '@opentiny/vue-image',
227
- '@opentiny/vue-image-viewer',
228
- '@opentiny/vue-input',
229
- '@opentiny/vue-ip-address',
230
- '@opentiny/vue-layout',
231
- '@opentiny/vue-link',
232
- '@opentiny/vue-link-menu',
233
- '@opentiny/vue-load-list',
234
- '@opentiny/vue-loading',
235
- '@opentiny/vue-locales',
236
- '@opentiny/vue-logon-user',
237
- '@opentiny/vue-logout',
238
- '@opentiny/vue-menu',
239
- '@opentiny/vue-message',
240
- '@opentiny/vue-milestone',
241
- '@opentiny/vue-mind-map',
242
- '@opentiny/vue-modal',
243
- '@opentiny/vue-month-range',
244
- '@opentiny/vue-month-table',
245
- '@opentiny/vue-nav-menu',
246
- '@opentiny/vue-notify',
247
- '@opentiny/vue-number-animation',
248
- '@opentiny/vue-numeric',
249
- '@opentiny/vue-option',
250
- '@opentiny/vue-option-group',
251
- '@opentiny/vue-pager',
252
- '@opentiny/vue-pager-item',
253
- '@opentiny/vue-panel',
254
- '@opentiny/vue-picker',
255
- '@opentiny/vue-pop-upload',
256
- '@opentiny/vue-popconfirm',
257
- '@opentiny/vue-popeditor',
258
- '@opentiny/vue-popover',
259
- '@opentiny/vue-popup',
260
- '@opentiny/vue-progress',
261
- '@opentiny/vue-pull-refresh',
262
- '@opentiny/vue-qr-code',
263
- '@opentiny/vue-quarter-panel',
264
- '@opentiny/vue-query-builder',
265
- '@opentiny/vue-radio',
266
- '@opentiny/vue-radio-button',
267
- '@opentiny/vue-radio-group',
268
- '@opentiny/vue-rate',
269
- '@opentiny/vue-record',
270
- '@opentiny/vue-recycle-scroller',
271
- '@opentiny/vue-river',
272
- '@opentiny/vue-roles',
273
- '@opentiny/vue-row',
274
- '@opentiny/vue-scroll-text',
275
- '@opentiny/vue-scrollbar',
276
- '@opentiny/vue-search',
277
- '@opentiny/vue-select',
278
- '@opentiny/vue-select-dropdown',
279
- '@opentiny/vue-select-mobile',
280
- '@opentiny/vue-select-view',
281
- '@opentiny/vue-selected-box',
282
- '@opentiny/vue-signature',
283
- '@opentiny/vue-skeleton',
284
- '@opentiny/vue-skeleton-item',
285
- '@opentiny/vue-slider',
286
- '@opentiny/vue-slider-button',
287
- '@opentiny/vue-slider-button-group',
288
- '@opentiny/vue-space',
289
- '@opentiny/vue-split',
290
- '@opentiny/vue-standard-list-item',
291
- '@opentiny/vue-statistic',
292
- '@opentiny/vue-steps',
293
- '@opentiny/vue-sticky',
294
- '@opentiny/vue-switch',
295
- '@opentiny/vue-tab-item',
296
- '@opentiny/vue-tabbar',
297
- '@opentiny/vue-tabbar-item',
298
- '@opentiny/vue-table',
299
- '@opentiny/vue-tabs',
300
- '@opentiny/vue-tag',
301
- '@opentiny/vue-tag-group',
302
- '@opentiny/vue-text-popup',
303
- '@opentiny/vue-time',
304
- '@opentiny/vue-time-line',
305
- '@opentiny/vue-time-panel',
306
- '@opentiny/vue-time-picker',
307
- '@opentiny/vue-time-picker-mobile',
308
- '@opentiny/vue-time-range',
309
- '@opentiny/vue-time-select',
310
- '@opentiny/vue-time-spinner',
311
- '@opentiny/vue-timeline-item',
312
- '@opentiny/vue-toggle-menu',
313
- '@opentiny/vue-tooltip',
314
- '@opentiny/vue-top-box',
315
- '@opentiny/vue-transfer',
316
- '@opentiny/vue-transfer-panel',
317
- '@opentiny/vue-tree',
318
- '@opentiny/vue-tree-menu',
319
- '@opentiny/vue-tree-select',
320
- '@opentiny/vue-upload',
321
- '@opentiny/vue-upload-dragger',
322
- '@opentiny/vue-upload-list',
323
- '@opentiny/vue-user',
324
- '@opentiny/vue-user-account',
325
- '@opentiny/vue-user-contact',
326
- '@opentiny/vue-user-head',
327
- '@opentiny/vue-user-head-group',
328
- '@opentiny/vue-user-link',
329
- '@opentiny/vue-virtual-scroll-box',
330
- '@opentiny/vue-virtual-tree',
331
- '@opentiny/vue-watermark',
332
- '@opentiny/vue-wizard',
333
- '@opentiny/vue-year-range',
334
- '@opentiny/vue-year-table'
335
- ]
336
- }
337
- });
File without changes
File without changes
File without changes