dlzn-ui 1.36.0 → 1.39.0

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.
@@ -0,0 +1,5 @@
1
+ declare const _default: (root: string) => {
2
+ find: string;
3
+ replacement: string;
4
+ }[];
5
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import { basename, resolve } from "node:path";
2
+ import { globSync } from "tinyglobby";
3
+ //#region node/aliasElementPlus.ts
4
+ var aliasElementPlus_default = (root) => {
5
+ const elementPlusCss = globSync(resolve(root, "src/plugins/element-plus/theme-chalk/*.css"));
6
+ const arr = [];
7
+ elementPlusCss.forEach((file) => {
8
+ const _basename = basename(file);
9
+ arr.push({
10
+ find: `element-plus/theme-chalk/${_basename}`,
11
+ replacement: resolve(root, `src/plugins/element-plus/theme-chalk/${_basename}`)
12
+ });
13
+ });
14
+ return arr;
15
+ };
16
+ //#endregion
17
+ export { aliasElementPlus_default as default };
@@ -0,0 +1,2 @@
1
+ declare const _default: (root: string) => Record<string, [string, string][]>;
2
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import { upperFirst } from "./utils/index.mjs";
2
+ import { basename, resolve } from "node:path";
3
+ import { globSync } from "tinyglobby";
4
+ //#region node/autoImportStores.ts
5
+ var autoImportStores_default = (root) => {
6
+ const piniaStoreKeys = [];
7
+ globSync(resolve(root, "src/store/modules/*.ts")).forEach((p) => {
8
+ piniaStoreKeys.push(basename(p, ".ts"));
9
+ });
10
+ const customerImport = {};
11
+ piniaStoreKeys.forEach((key) => {
12
+ customerImport[`@/store/modules/${key}`] = [["default", `use${upperFirst(key)}Store`]];
13
+ });
14
+ return customerImport;
15
+ };
16
+ //#endregion
17
+ export { autoImportStores_default as default };
@@ -0,0 +1,3 @@
1
+ import { Plugin } from 'vite';
2
+ /** 开发环境将 getRouters 转为 folder-alias.json 并写入项目根目录 */
3
+ export default function devSaveFolderAlias(root: string): Plugin;
@@ -0,0 +1,94 @@
1
+ import { resolve } from "node:path";
2
+ import fs from "node:fs/promises";
3
+ //#region node/devSaveFolderAlias.ts
4
+ var ENDPOINT = "/__dev__/save-folder-alias";
5
+ var OUTPUT_FILE_WATCH_IGNORE = "**/folder-alias.json";
6
+ var SKIP_COMPONENTS = /* @__PURE__ */ new Set(["Layout", "ParentView"]);
7
+ /** 开发环境将 getRouters 转为 folder-alias.json 并写入项目根目录 */
8
+ function devSaveFolderAlias(root) {
9
+ const OUTPUT_FILE = resolve(root, "folder-alias.json");
10
+ return {
11
+ apply: "serve",
12
+ config() {
13
+ return { server: { watch: { ignored: [OUTPUT_FILE_WATCH_IGNORE] } } };
14
+ },
15
+ configureServer(server) {
16
+ server.middlewares.use(ENDPOINT, (req, res, next) => {
17
+ handleSaveFolderAlias(req, res, next, server, OUTPUT_FILE);
18
+ });
19
+ },
20
+ name: "dev-save-folder-alias"
21
+ };
22
+ }
23
+ async function handleSaveFolderAlias(req, res, next, server, outPutFilePath) {
24
+ try {
25
+ const body = await readBody(req);
26
+ const data = JSON.parse(body);
27
+ const content = `${JSON.stringify(toFolderAlias(data), null, 2)}\n`;
28
+ const resSuccess = () => {
29
+ res.statusCode = 200;
30
+ res.setHeader("Content-Type", "application/json");
31
+ res.end(JSON.stringify({
32
+ file: outPutFilePath,
33
+ ok: true
34
+ }));
35
+ };
36
+ try {
37
+ if (await fs.readFile(outPutFilePath, "utf8") === content) {
38
+ resSuccess();
39
+ return;
40
+ }
41
+ } catch {}
42
+ await fs.writeFile(outPutFilePath, content, "utf8");
43
+ server.config.logger.info(`[dev-save-folder-alias] written → ${outPutFilePath}`);
44
+ resSuccess();
45
+ } catch (error) {
46
+ const message = error instanceof Error ? error.message : String(error);
47
+ res.statusCode = 500;
48
+ res.setHeader("Content-Type", "application/json");
49
+ res.end(JSON.stringify({
50
+ message,
51
+ ok: false
52
+ }));
53
+ server.config.logger.error(`[dev-save-folder-alias] ${message}`);
54
+ }
55
+ }
56
+ function readBody(req) {
57
+ return new Promise((resolve, reject) => {
58
+ const chunks = [];
59
+ req.setEncoding("utf8");
60
+ req.on("data", (chunk) => {
61
+ chunks.push(chunk);
62
+ });
63
+ req.on("end", () => {
64
+ resolve(chunks.join(""));
65
+ });
66
+ req.on("error", reject);
67
+ });
68
+ }
69
+ function toFolderAlias(routers) {
70
+ const result = {};
71
+ const walk = (items, level = 0) => {
72
+ for (const item of items) {
73
+ const title = item.meta.title;
74
+ if (title !== "") {
75
+ const component = item.component;
76
+ if (!SKIP_COMPONENTS.has(component)) {
77
+ result[`src/views/${component.split("___")[0]}.vue`] = { description: title };
78
+ const arr = component.split("/");
79
+ arr.forEach((_, index) => {
80
+ if (index === arr.length - 1) return;
81
+ const key = `src/views/${arr.slice(0, index + 1).join("/")}`;
82
+ const description = [...new Set([result[key]?.description, title].filter(Boolean))].join("、");
83
+ result[key] = { description: index === 0 ? routers.find((r) => r.path === arr[0])?.meta.title ?? description : description };
84
+ });
85
+ }
86
+ }
87
+ if (item.children !== void 0 && item.children.length > 0) walk(item.children, level + 1);
88
+ }
89
+ };
90
+ walk(routers);
91
+ return result;
92
+ }
93
+ //#endregion
94
+ export { devSaveFolderAlias as default };
@@ -0,0 +1,19 @@
1
+ declare const _default: (isProduction: boolean) => ({
2
+ resolve: (name: string) => {
3
+ from: string;
4
+ name: string;
5
+ as?: undefined;
6
+ } | {
7
+ as: string;
8
+ from: string;
9
+ name: string;
10
+ } | undefined;
11
+ type: "component";
12
+ } | {
13
+ resolve: (name: string) => {
14
+ from: string;
15
+ name: string;
16
+ } | undefined;
17
+ type: "directive";
18
+ })[];
19
+ export default _default;
@@ -0,0 +1,62 @@
1
+ import path from "node:path";
2
+ import { globSync } from "tinyglobby";
3
+ import { TDesignResolver } from "@tdesign-vue-next/auto-import-resolver";
4
+ //#region node/tDesignResolve.ts
5
+ var tDesignResetComponentsSubFolderName = globSync("src/components/tDesignReset/*/Index.vue").map((file) => {
6
+ return path.basename(path.dirname(file));
7
+ });
8
+ var autoImportComponentsSubFolderName = globSync("src/components/autoImport/*/Index.vue").map((file) => {
9
+ return path.basename(path.dirname(file));
10
+ });
11
+ var tDesignResolve_default = (isProduction) => {
12
+ return [{
13
+ resolve: (name) => {
14
+ if (["TCard"].includes(name)) return {
15
+ from: "dlzn-ui",
16
+ name
17
+ };
18
+ if ([
19
+ "Icon",
20
+ "TBaseTable",
21
+ "TDateRangePicker",
22
+ "TEnhancedTable",
23
+ "TPrimaryTable"
24
+ ].includes(name)) return;
25
+ if (tDesignResetComponentsSubFolderName.includes(name)) return {
26
+ from: `@/components/tDesignReset/${name}/Index.vue`,
27
+ name: "default"
28
+ };
29
+ if (autoImportComponentsSubFolderName.includes(name)) return {
30
+ from: `@/components/autoImport/${name}/Index.vue`,
31
+ name: "default"
32
+ };
33
+ if (tDesignResetComponentsSubFolderName.map((n) => {
34
+ const sliceName = n.slice(1);
35
+ return `_${sliceName === "Table" ? "EnhancedTable" : sliceName}`;
36
+ }).includes(name)) return {
37
+ as: name,
38
+ from: isProduction ? "tdesign-vue-next" : "@/plugins/tdesign-vue-next-for-dev",
39
+ name: name.slice(1)
40
+ };
41
+ const result = TDesignResolver({
42
+ library: "vue-next",
43
+ resolveIcons: false
44
+ }).resolve(name);
45
+ if (result !== void 0) return {
46
+ from: isProduction ? result.from : "@/plugins/tdesign-vue-next-for-dev",
47
+ name: result.name
48
+ };
49
+ },
50
+ type: "component"
51
+ }, {
52
+ resolve: (name) => {
53
+ if (name === "Loading") return {
54
+ from: isProduction ? "tdesign-vue-next" : "@/plugins/tdesign-vue-next-for-dev",
55
+ name: "LoadingDirective"
56
+ };
57
+ },
58
+ type: "directive"
59
+ }];
60
+ };
61
+ //#endregion
62
+ export { tDesignResolve_default as default };
@@ -1,2 +1,3 @@
1
1
  export declare function needPort(target: string): boolean;
2
2
  export declare function resolveOneFromSelf(metaUrl: string, paths: string[]): string;
3
+ export declare function upperFirst(str: string): string;
@@ -1,5 +1,5 @@
1
- import { existsSync } from "node:fs";
2
1
  import { dirname, resolve } from "node:path";
2
+ import { existsSync } from "node:fs";
3
3
  import { fileURLToPath } from "node:url";
4
4
  //#region node/utils/index.ts
5
5
  function needPort(target) {
@@ -12,5 +12,8 @@ function resolveOneFromSelf(metaUrl, paths) {
12
12
  if (result === -1) throw new Error(`${here}:resolveOneFromSelf: path not found: ${paths.join(", ")}`);
13
13
  return arr[result];
14
14
  }
15
+ function upperFirst(str) {
16
+ return str.charAt(0).toUpperCase() + str.slice(1);
17
+ }
15
18
  //#endregion
16
- export { needPort, resolveOneFromSelf };
19
+ export { needPort, resolveOneFromSelf, upperFirst };
@@ -1,7 +1,12 @@
1
1
  import { ConfigEnv, UserConfig } from 'vite';
2
+ import { default as AutoImport } from 'unplugin-auto-import/vite';
3
+ type Arrayable<T> = Array<T> | T;
2
4
  interface Options {
5
+ autoImportResolvers?: Array<UnwrapArrayable<UnwrapArrayable<NonNullable<Parameters<typeof AutoImport>[0]['resolvers']>>>>;
6
+ autoImports?: Array<NonNullable<UnwrapArrayable<Parameters<typeof AutoImport>[0]['imports']>>>;
3
7
  root: string;
4
8
  }
9
+ type UnwrapArrayable<T> = T extends Arrayable<infer U> ? U : never;
5
10
  export declare function commonConfig(_env: ConfigEnv): UserConfig;
6
11
  declare const _default: (_env: ConfigEnv, options: Options) => UserConfig;
7
12
  export default _default;
@@ -1,18 +1,27 @@
1
+ import aliasElementPlus_default from "./aliasElementPlus.mjs";
1
2
  import { needPort } from "./utils/index.mjs";
3
+ import autoImportStores_default from "./autoImportStores.mjs";
4
+ import tDesignResolve_default from "./tDesignResolve.mjs";
5
+ import vitePlugins_default from "./vitePlugins.mjs";
2
6
  import { posix, resolve } from "node:path";
3
7
  import tailwindcss from "@tailwindcss/vite";
4
8
  import vue from "@vitejs/plugin-vue";
9
+ import vueJsx from "@vitejs/plugin-vue-jsx";
5
10
  import browserslist from "browserslist";
6
11
  import { browserslistToTargets } from "lightningcss";
12
+ import AutoImport from "unplugin-auto-import/vite";
13
+ import ElementPlus from "unplugin-element-plus/vite";
14
+ import Components from "unplugin-vue-components/vite";
7
15
  import { loadEnv, mergeConfig } from "vite";
8
16
  import { parseLoadedEnv } from "vite-plugin-env-parse";
9
17
  import { createHtmlPlugin } from "vite-plugin-html";
10
18
  import tailwindAutoReference from "vite-plugin-vue-tailwind-auto-reference";
19
+ import VueRouter from "vue-router/vite";
11
20
  //#region node/vite-config.ts
12
21
  function commonConfig(_env) {
13
22
  return {
14
23
  clearScreen: false,
15
- plugins: [vue({})]
24
+ plugins: [vue({}), vueJsx()]
16
25
  };
17
26
  }
18
27
  function bypass(req, res, options) {
@@ -24,8 +33,7 @@ function bypass(req, res, options) {
24
33
  }
25
34
  var vite_config_default = (_env, options) => {
26
35
  const { command, mode } = _env;
27
- const { root } = options;
28
- const resolvePath = (p) => resolve(root, p);
36
+ const resolvePath = (p) => resolve(options.root, p);
29
37
  const { VITE_API_PROXY_PORT_ARRAY, VITE_APP_ID, VITE_APP_NAME = "", VITE_BASE_URL = "/", VITE_FORCE_PWD_CHANGE = true, VITE_PROXY_TARGET: viteProxyTarget, VITE_USE_LOGIN_CAPTCHA = true } = parseLoadedEnv(loadEnv(mode, "build/env"));
30
38
  const VITE_PROXY_TARGET = Array.isArray(viteProxyTarget) ? viteProxyTarget : [viteProxyTarget];
31
39
  console.log({
@@ -113,7 +121,78 @@ var vite_config_default = (_env, options) => {
113
121
  template: "node_modules/dlzn-ui/build/index.html"
114
122
  }),
115
123
  tailwindAutoReference("node_modules/dlzn-ui/assets/css/tailwindcss-entry.css"),
116
- tailwindcss()
124
+ tailwindcss(),
125
+ VueRouter({ dts: "types/typed-router.d.ts" }),
126
+ vueJsx(),
127
+ ElementPlus({}),
128
+ AutoImport({
129
+ dirs: [
130
+ "src/plugins/autoImport",
131
+ "src/bus/autoImport",
132
+ "src/hooks"
133
+ ],
134
+ dirsScanOptions: { types: false },
135
+ dts: "types/auto-imports.d.ts",
136
+ imports: [
137
+ "vue",
138
+ "vue-router",
139
+ "pinia",
140
+ "@vueuse/core",
141
+ {
142
+ from: "alova/client",
143
+ imports: [
144
+ "useRequest",
145
+ "useWatcher",
146
+ "usePagination"
147
+ ]
148
+ },
149
+ {
150
+ from: "@/plugins/others/directive.ts",
151
+ imports: ["checkPermissions"]
152
+ },
153
+ {
154
+ from: "dlzn-ui/utils",
155
+ imports: [
156
+ "formatNumber",
157
+ "isFalsy",
158
+ "stringDisplay"
159
+ ]
160
+ },
161
+ { "@/plugins/alova/index.ts": [["default", "alovaInst"]] },
162
+ {
163
+ from: "@/components/tDesignReset/TForm/index.ts",
164
+ imports: [
165
+ "FormItem",
166
+ "FormInstance",
167
+ "FormExposed"
168
+ ],
169
+ type: true
170
+ },
171
+ {
172
+ from: "@/components/tDesignReset/TTable/index.ts",
173
+ imports: ["TableCol", "CellRenderContext"],
174
+ type: true
175
+ },
176
+ {
177
+ from: "@/components/autoImport/TPageList/index.ts",
178
+ imports: ["PageListProps"],
179
+ type: true
180
+ },
181
+ autoImportStores_default(options.root),
182
+ ...options.autoImports ?? []
183
+ ],
184
+ resolvers: [...options.autoImportResolvers ?? [], ...tDesignResolve_default(isProduction)],
185
+ vueTemplate: true
186
+ }),
187
+ Components({
188
+ deep: false,
189
+ dts: "types/components.d.ts",
190
+ resolvers: [...options.autoImportResolvers ?? [], ...tDesignResolve_default(isProduction)]
191
+ }),
192
+ ...vitePlugins_default({
193
+ isProduction,
194
+ root: options.root
195
+ })
117
196
  ],
118
197
  resolve: {
119
198
  alias: [
@@ -128,7 +207,8 @@ var vite_config_default = (_env, options) => {
128
207
  ...isProduction ? [] : [{
129
208
  find: /^.*tdesign-vue-next[/\\]es[/\\].*\.css$/,
130
209
  replacement: resolvePath("src/plugins/tdesign-vue-next-for-dev/empty.css")
131
- }]
210
+ }],
211
+ ...aliasElementPlus_default(options.root)
132
212
  ],
133
213
  extensions: [
134
214
  ".ts",
@@ -136,6 +216,7 @@ var vite_config_default = (_env, options) => {
136
216
  ".js"
137
217
  ]
138
218
  },
219
+ root: options.root,
139
220
  server: {
140
221
  host: "0.0.0.0",
141
222
  open: false,
@@ -0,0 +1,6 @@
1
+ import { Plugin } from 'vite';
2
+ declare const _default: (options: {
3
+ isProduction: boolean;
4
+ root: string;
5
+ }) => Plugin[];
6
+ export default _default;
@@ -0,0 +1,58 @@
1
+ import devSaveFolderAlias from "./devSaveFolderAlias.mjs";
2
+ import { webUpdateNotice } from "@plugin-web-update-notification/vite";
3
+ import { visualizer } from "rollup-plugin-visualizer";
4
+ import { compression } from "vite-plugin-compression2";
5
+ import viteImagemin from "vite-plugin-imagemin";
6
+ //#region node/vitePlugins.ts
7
+ var vitePlugins_default = (options) => {
8
+ const { isProduction, root } = options;
9
+ if (isProduction) return [
10
+ viteImagemin({
11
+ gifsicle: {
12
+ colors: 256,
13
+ interlaced: false,
14
+ optimizationLevel: 2
15
+ },
16
+ mozjpeg: { quality: 50 },
17
+ optipng: { optimizationLevel: 3 },
18
+ pngquant: {
19
+ quality: [.65, .8],
20
+ speed: 4
21
+ },
22
+ svgo: {
23
+ datauri: "base64",
24
+ js2svg: {
25
+ indent: 4,
26
+ pretty: false
27
+ },
28
+ multipass: false,
29
+ plugins: [{ name: "preset-default" }]
30
+ },
31
+ webp: { quality: 80 }
32
+ }),
33
+ compression(),
34
+ visualizer({
35
+ filename: "build/.cache/visualizer/report.html",
36
+ open: true
37
+ }),
38
+ webUpdateNotice({
39
+ hiddenDefaultNotification: true,
40
+ logVersion: false
41
+ })
42
+ ];
43
+ else return [{
44
+ configureServer(server) {
45
+ const { printUrls } = server;
46
+ server.printUrls = () => {
47
+ if (server.resolvedUrls !== null) {
48
+ server.resolvedUrls.local = [];
49
+ server.resolvedUrls.network = server.resolvedUrls.network.filter((url) => url.includes("192.168."));
50
+ }
51
+ printUrls();
52
+ };
53
+ },
54
+ name: "filter-vite-server-urls"
55
+ }, devSaveFolderAlias(root)];
56
+ };
57
+ //#endregion
58
+ export { vitePlugins_default as default };
package/package.json CHANGED
@@ -15,6 +15,18 @@
15
15
  "import": "./const/index.mjs",
16
16
  "types": "./const/index.d.ts"
17
17
  },
18
+ "./aliasElementPlus": {
19
+ "import": "./node/aliasElementPlus.mjs",
20
+ "types": "./node/aliasElementPlus.d.ts"
21
+ },
22
+ "./autoImportStores": {
23
+ "import": "./node/autoImportStores.mjs",
24
+ "types": "./node/autoImportStores.d.ts"
25
+ },
26
+ "./devSaveFolderAlias": {
27
+ "import": "./node/devSaveFolderAlias.mjs",
28
+ "types": "./node/devSaveFolderAlias.d.ts"
29
+ },
18
30
  "./eslint-config": {
19
31
  "import": "./node/eslint-config.mjs",
20
32
  "types": "./node/eslint-config.d.ts"
@@ -27,10 +39,18 @@
27
39
  "import": "./node/stylelint-config.mjs",
28
40
  "types": "./node/stylelint-config.d.ts"
29
41
  },
42
+ "./tDesignResolve": {
43
+ "import": "./node/tDesignResolve.mjs",
44
+ "types": "./node/tDesignResolve.d.ts"
45
+ },
30
46
  "./vite-config": {
31
47
  "import": "./node/vite-config.mjs",
32
48
  "types": "./node/vite-config.d.ts"
33
49
  },
50
+ "./vitePlugins": {
51
+ "import": "./node/vitePlugins.mjs",
52
+ "types": "./node/vitePlugins.d.ts"
53
+ },
34
54
  "./utils": {
35
55
  "import": "./utils/index.mjs",
36
56
  "types": "./utils/index.d.ts"
@@ -41,12 +61,15 @@
41
61
  "name": "dlzn-ui",
42
62
  "peerDependencies": {
43
63
  "@antfu/eslint-config": "^9.3.0",
64
+ "@plugin-web-update-notification/vite": "^2.1.3",
44
65
  "@prettier/plugin-xml": "^3.4.2",
45
66
  "@stylistic/stylelint-config": "^5.0.0",
46
67
  "@tailwindcss/vite": "^4.3.3",
68
+ "@tdesign-vue-next/auto-import-resolver": "^0.1.7",
47
69
  "@tsconfig/node-lts": "^24.0.0",
48
70
  "@types/node": "^26.1.2",
49
71
  "@vitejs/plugin-vue": "^6.0.8",
72
+ "@vitejs/plugin-vue-jsx": "^5.1.6",
50
73
  "@vue/tsconfig": "^0.9.1",
51
74
  "browserslist": "^4.28.8",
52
75
  "eslint": "^10.8.1",
@@ -58,6 +81,7 @@
58
81
  "postcss-markdown": "^2.0.0",
59
82
  "prettier": "^3.9.6",
60
83
  "prettier-plugin-tailwindcss": "^0.8.1",
84
+ "rollup-plugin-visualizer": "^7.1.1",
61
85
  "stylelint": "^17.14.1",
62
86
  "stylelint-config-recess-order": "^7.7.0",
63
87
  "stylelint-config-recommended-vue": "^2.0.0",
@@ -66,18 +90,26 @@
66
90
  "stylelint-use-nesting": "^6.0.2",
67
91
  "tailwindcss": "^4.3.3",
68
92
  "tdesign-vue-next": "^1.20.5",
93
+ "tinyglobby": "^0.2.17",
69
94
  "typescript": "^6.0.3",
95
+ "unplugin-auto-import": "^21.1.0",
96
+ "unplugin-element-plus": "^0.11.2",
97
+ "unplugin-vue-components": "^32.1.0",
70
98
  "vite": "^8.2.0",
99
+ "vite-plugin-compression2": "^2.5.3",
71
100
  "vite-plugin-env-parse": "^1.0.15",
72
101
  "vite-plugin-html": "^3.2.2",
102
+ "vite-plugin-imagemin": "^0.6.1",
103
+ "vite-plugin-vue-devtools": "^8.2.1",
73
104
  "vite-plugin-vue-tailwind-auto-reference": "^2.0.2",
74
105
  "vue": "^3.5.41",
106
+ "vue-router": "^5.2.0",
75
107
  "vue-tsc": "^3.3.9"
76
108
  },
77
109
  "sideEffects": [
78
110
  "**/*.css"
79
111
  ],
80
112
  "type": "module",
81
- "version": "1.36.0",
113
+ "version": "1.39.0",
82
114
  "scripts": {}
83
115
  }