diff --git a/build/cool/demo.ts b/build/cool/demo.ts new file mode 100644 index 0000000..0afcf30 --- /dev/null +++ b/build/cool/demo.ts @@ -0,0 +1,46 @@ +import type { Plugin } from "vite"; +import { glob } from "glob"; +import path from "path"; +import { readFileSync } from "fs"; + +export function demo(enable?: boolean): Plugin { + const virtualModuleIds = ["virtual:demo"]; + + return { + name: "vite-cool-demo", + enforce: "pre", + resolveId(id) { + if (virtualModuleIds.includes(id)) { + return "\0" + id; + } + }, + async load(id) { + if (id === "\0virtual:demo") { + const demo = {}; + + if (enable) { + const files = await glob("./src/modules/demo/views/crud/components/**", { + stat: true, + withFileTypes: true + }); + + for (const file of files) { + if (file.isFile()) { + const p = path.join(file.path, file.name); + + demo[ + p + .replace(/\\/g, "/") + .split("src/modules/demo/views/crud/components/")[1] + ] = readFileSync(p, "utf-8"); + } + } + } + + return ` + export const demo = ${JSON.stringify(demo)}; + `; + } + } + }; +} diff --git a/build/cool/index.ts b/build/cool/index.ts index 6013f1a..8c41ac1 100644 --- a/build/cool/index.ts +++ b/build/cool/index.ts @@ -1,6 +1,14 @@ import { base } from "./base"; import { virtual } from "./virtual"; +import { demo } from "./demo"; export function cool() { - return [base(), virtual()]; + return [ + // 基础 + base(), + // 虚拟模块 + virtual(), + // demo 官方示例,代码片段 + demo(true) + ]; } diff --git a/build/cool/svg/index.ts b/build/cool/svg/index.ts index 2b752e7..7be8179 100644 --- a/build/cool/svg/index.ts +++ b/build/cool/svg/index.ts @@ -42,7 +42,7 @@ function findFiles(dir: string): string[] { } export function createSvg(html: string) { - const res = findFiles("./src/modules/"); + const res = findFiles("./src/"); return html.replace( "
", diff --git a/package.json b/package.json index ce2925d..9f82875 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cool-admin", - "version": "7.0.0", + "version": "7.1.0", "scripts": { "dev": "vite --host", "build": "vite build", @@ -9,7 +9,7 @@ "lint:eslint": "eslint \"./src/**/*.{vue,ts,tsx}\" --fix" }, "dependencies": { - "@cool-vue/crud": "^7.1.3", + "@cool-vue/crud": "^7.1.10", "@element-plus/icons-vue": "^2.1.0", "@vueuse/core": "^10.4.0", "@wangeditor/editor": "^5.1.23", @@ -22,6 +22,7 @@ "element-plus": "^2.4.3", "file-saver": "^2.0.5", "lodash-es": "^4.17.21", + "marked": "^11.1.1", "mitt": "^3.0.1", "mockjs": "^1.1.0", "monaco-editor": "0.36.0", @@ -53,6 +54,7 @@ "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.0", "eslint-plugin-vue": "^9.17.0", + "glob": "^10.3.10", "lodash": "^4.17.21", "magic-string": "^0.30.3", "prettier": "^3.1.0", diff --git a/packages/crud/index.d.ts b/packages/crud/index.d.ts index 27e69f7..6b44a00 100644 --- a/packages/crud/index.d.ts +++ b/packages/crud/index.d.ts @@ -82,39 +82,6 @@ declare type Browser = { isMini: boolean; }; -// hook -declare namespace Hook { - interface Options { - form: obj; - prop: string; - method: "submit" | "bind"; - } - - type fn = (value: any, options: Options) => any; - - type FormPipe = - | "number" - | "string" - | "split" - | "join" - | "boolean" - | "booleanNumber" - | "datetimeRange" - | "splitJoin" - | "json" - | "empty" - | fn; - - type FormPipes = FormPipe | FormPipe[]; - - type Form = - | string - | { - bind?: FormPipes; - submit?: FormPipes; - }; -} - // render declare namespace Render { type OpButton = @@ -473,6 +440,26 @@ declare namespace ClForm { [key: string]: any; } + type HookFn = ( + value: any, + options: { form: obj; prop: string; method: "submit" | "bind" } + ) => any; + + type HookKey = + | "number" + | "string" + | "split" + | "join" + | "boolean" + | "booleanNumber" + | "datetimeRange" + | "splitJoin" + | "json" + | "empty" + | (string & {}); + + type HookPipe = HookKey | HookFn; + interface Item# {{ b.label }}
+ +选择头像
+