dlzn-ui 1.38.0 → 1.40.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("src/plugins/element-plus/theme-chalk/*.css", { cwd: root });
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 } from "node:path";
3
+ import { globSync } from "tinyglobby";
4
+ //#region node/autoImportStores.ts
5
+ var autoImportStores_default = (root) => {
6
+ const piniaStoreKeys = [];
7
+ globSync("src/store/modules/*.ts", { cwd: root }).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,22 @@
1
+ declare const _default: (options: {
2
+ isProduction: boolean;
3
+ root: string;
4
+ }) => ({
5
+ resolve: (name: string) => {
6
+ from: string;
7
+ name: string;
8
+ as?: undefined;
9
+ } | {
10
+ as: string;
11
+ from: string;
12
+ name: string;
13
+ } | undefined;
14
+ type: "component";
15
+ } | {
16
+ resolve: (name: string) => {
17
+ from: string;
18
+ name: string;
19
+ } | undefined;
20
+ type: "directive";
21
+ })[];
22
+ export default _default;
@@ -0,0 +1,63 @@
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 tDesignResolve_default = (options) => {
6
+ const { isProduction, root } = options;
7
+ const tDesignResetComponentsSubFolderName = globSync("src/components/tDesignReset/*/Index.vue", { cwd: root }).map((file) => {
8
+ return path.basename(path.dirname(file));
9
+ });
10
+ const autoImportComponentsSubFolderName = globSync("src/components/autoImport/*/Index.vue", { cwd: root }).map((file) => {
11
+ return path.basename(path.dirname(file));
12
+ });
13
+ return [{
14
+ resolve: (name) => {
15
+ if (["TCard"].includes(name)) return {
16
+ from: "dlzn-ui",
17
+ name
18
+ };
19
+ if ([
20
+ "Icon",
21
+ "TBaseTable",
22
+ "TDateRangePicker",
23
+ "TEnhancedTable",
24
+ "TPrimaryTable"
25
+ ].includes(name)) return;
26
+ if (tDesignResetComponentsSubFolderName.includes(name)) return {
27
+ from: `@/components/tDesignReset/${name}/Index.vue`,
28
+ name: "default"
29
+ };
30
+ if (autoImportComponentsSubFolderName.includes(name)) return {
31
+ from: `@/components/autoImport/${name}/Index.vue`,
32
+ name: "default"
33
+ };
34
+ if (tDesignResetComponentsSubFolderName.map((n) => {
35
+ const sliceName = n.slice(1);
36
+ return `_${sliceName === "Table" ? "EnhancedTable" : sliceName}`;
37
+ }).includes(name)) return {
38
+ as: name,
39
+ from: isProduction ? "tdesign-vue-next" : "@/plugins/tdesign-vue-next-for-dev",
40
+ name: name.slice(1)
41
+ };
42
+ const result = TDesignResolver({
43
+ library: "vue-next",
44
+ resolveIcons: false
45
+ }).resolve(name);
46
+ if (result !== void 0) return {
47
+ from: isProduction ? result.from : "@/plugins/tdesign-vue-next-for-dev",
48
+ name: result.name
49
+ };
50
+ },
51
+ type: "component"
52
+ }, {
53
+ resolve: (name) => {
54
+ if (name === "Loading") return {
55
+ from: isProduction ? "tdesign-vue-next" : "@/plugins/tdesign-vue-next-for-dev",
56
+ name: "LoadingDirective"
57
+ };
58
+ },
59
+ type: "directive"
60
+ }];
61
+ };
62
+ //#endregion
63
+ 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 };
@@ -2,8 +2,8 @@ import { ConfigEnv, UserConfig } from 'vite';
2
2
  import { default as AutoImport } from 'unplugin-auto-import/vite';
3
3
  type Arrayable<T> = Array<T> | T;
4
4
  interface Options {
5
- autoImportResolvers: Array<UnwrapArrayable<UnwrapArrayable<NonNullable<Parameters<typeof AutoImport>[0]['resolvers']>>>>;
6
- autoImports: NonNullable<UnwrapArrayable<Parameters<typeof AutoImport>[0]['imports']>>;
5
+ autoImportResolvers?: Array<UnwrapArrayable<UnwrapArrayable<NonNullable<Parameters<typeof AutoImport>[0]['resolvers']>>>>;
6
+ autoImports?: Array<NonNullable<UnwrapArrayable<Parameters<typeof AutoImport>[0]['imports']>>>;
7
7
  root: string;
8
8
  }
9
9
  type UnwrapArrayable<T> = T extends Arrayable<infer U> ? U : never;
@@ -1,4 +1,8 @@
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";
@@ -174,15 +178,26 @@ var vite_config_default = (_env, options) => {
174
178
  imports: ["PageListProps"],
175
179
  type: true
176
180
  },
177
- options.autoImports
181
+ autoImportStores_default(options.root),
182
+ ...options.autoImports ?? []
178
183
  ],
179
- resolvers: [...options.autoImportResolvers],
184
+ resolvers: [...options.autoImportResolvers ?? [], ...tDesignResolve_default({
185
+ isProduction,
186
+ root: options.root
187
+ })],
180
188
  vueTemplate: true
181
189
  }),
182
190
  Components({
183
191
  deep: false,
184
192
  dts: "types/components.d.ts",
185
- resolvers: [...options.autoImportResolvers]
193
+ resolvers: [...options.autoImportResolvers ?? [], ...tDesignResolve_default({
194
+ isProduction,
195
+ root: options.root
196
+ })]
197
+ }),
198
+ ...vitePlugins_default({
199
+ isProduction,
200
+ root: options.root
186
201
  })
187
202
  ],
188
203
  resolve: {
@@ -198,7 +213,8 @@ var vite_config_default = (_env, options) => {
198
213
  ...isProduction ? [] : [{
199
214
  find: /^.*tdesign-vue-next[/\\]es[/\\].*\.css$/,
200
215
  replacement: resolvePath("src/plugins/tdesign-vue-next-for-dev/empty.css")
201
- }]
216
+ }],
217
+ ...aliasElementPlus_default(options.root)
202
218
  ],
203
219
  extensions: [
204
220
  ".ts",
@@ -206,6 +222,7 @@ var vite_config_default = (_env, options) => {
206
222
  ".js"
207
223
  ]
208
224
  },
225
+ root: options.root,
209
226
  server: {
210
227
  host: "0.0.0.0",
211
228
  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,9 +61,11 @@
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",
@@ -59,6 +81,7 @@
59
81
  "postcss-markdown": "^2.0.0",
60
82
  "prettier": "^3.9.6",
61
83
  "prettier-plugin-tailwindcss": "^0.8.1",
84
+ "rollup-plugin-visualizer": "^7.1.1",
62
85
  "stylelint": "^17.14.1",
63
86
  "stylelint-config-recess-order": "^7.7.0",
64
87
  "stylelint-config-recommended-vue": "^2.0.0",
@@ -67,13 +90,17 @@
67
90
  "stylelint-use-nesting": "^6.0.2",
68
91
  "tailwindcss": "^4.3.3",
69
92
  "tdesign-vue-next": "^1.20.5",
93
+ "tinyglobby": "^0.2.17",
70
94
  "typescript": "^6.0.3",
71
95
  "unplugin-auto-import": "^21.1.0",
72
96
  "unplugin-element-plus": "^0.11.2",
73
97
  "unplugin-vue-components": "^32.1.0",
74
98
  "vite": "^8.2.0",
99
+ "vite-plugin-compression2": "^2.5.3",
75
100
  "vite-plugin-env-parse": "^1.0.15",
76
101
  "vite-plugin-html": "^3.2.2",
102
+ "vite-plugin-imagemin": "^0.6.1",
103
+ "vite-plugin-vue-devtools": "^8.2.1",
77
104
  "vite-plugin-vue-tailwind-auto-reference": "^2.0.2",
78
105
  "vue": "^3.5.41",
79
106
  "vue-router": "^5.2.0",
@@ -83,6 +110,6 @@
83
110
  "**/*.css"
84
111
  ],
85
112
  "type": "module",
86
- "version": "1.38.0",
113
+ "version": "1.40.0",
87
114
  "scripts": {}
88
115
  }