diff --git a/build/cool/eps/index.ts b/build/cool/eps/index.ts index 046b9dc..8fd7633 100644 --- a/build/cool/eps/index.ts +++ b/build/cool/eps/index.ts @@ -35,23 +35,23 @@ async function getData(temps?: Eps.Entity[]) { timeout: 5000 }) .then((res) => { - const { code, data, message } = res.data; + const { code, data } = res.data; if (code === 1000) { if (!isEmpty(data) && data) { merge(list, Object.values(data).flat() as Eps.Entity[]); } - } else { - error(`[eps] ${message}`); } }) .catch(() => { - error(`[eps] ${url} 服务未启动!!!`); + error(`[eps] 服务未启动 ➜ ${url}`); }); // 合并其他数据 if (isArray(temps)) { temps.forEach((e) => { + e.isLocal = true; + const d = list.find((a) => e.prefix === a.prefix); if (d) { @@ -67,19 +67,21 @@ async function getData(temps?: Eps.Entity[]) { // 创建 json 文件 function createJson() { - const d = list.map((e) => { - return { - prefix: e.prefix, - name: e.name || "", - api: e.api.map((e) => { - return { - name: e.name, - method: e.method, - path: e.path - }; - }) - }; - }); + const d = list + .filter((e) => !e.isLocal) + .map((e) => { + return { + prefix: e.prefix, + name: e.name || "", + api: e.api.map((e) => { + return { + name: e.name, + method: e.method, + path: e.path + }; + }) + }; + }); createWriteStream(join(DistPath, "eps.json"), { flags: "w" diff --git a/build/cool/utils/index.ts b/build/cool/utils/index.ts index 3dcd36c..4d7c088 100644 --- a/build/cool/utils/index.ts +++ b/build/cool/utils/index.ts @@ -1,5 +1,6 @@ import fs from "fs"; import { join } from "path"; +import dayjs from "dayjs"; // 首字母大写 export function firstUpperCase(value: string): string { @@ -70,5 +71,5 @@ export function mkdirs(path: string) { } export function error(message: string) { - console.log("\x1B[31m%s\x1B[0m", message); + console.log("\x1B[31m%s\x1B[0m", `${dayjs().format("HH:mm:ss")} ${message || ""}`); } diff --git a/build/cool/virtual.ts b/build/cool/virtual.ts index d747754..b108ee9 100644 --- a/build/cool/virtual.ts +++ b/build/cool/virtual.ts @@ -5,6 +5,9 @@ import { createModule } from "./module"; export function virtual(): Plugin { const virtualModuleIds = ["virtual:eps", "virtual:module"]; + // 首次启动加载 Eps + createEps(); + return { name: "vite-cool-virtual", enforce: "pre", diff --git a/src/cool/bootstrap/module.ts b/src/cool/bootstrap/module.ts index 3a13580..e611c4f 100644 --- a/src/cool/bootstrap/module.ts +++ b/src/cool/bootstrap/module.ts @@ -80,7 +80,10 @@ export function createModule(app: App) { e.components?.forEach(async (c: any) => { const v = await (isFunction(c) ? c() : c); const n = v.default || v; - app.component(n.name, n); + + if (n.name) { + app.component(n.name, n); + } }); // 注册指令 diff --git a/src/modules/base/components/dept/hook.tsx b/src/modules/base/hooks/dept.tsx similarity index 94% rename from src/modules/base/components/dept/hook.tsx rename to src/modules/base/hooks/dept.tsx index cbe8287..a72cfbf 100644 --- a/src/modules/base/components/dept/hook.tsx +++ b/src/modules/base/hooks/dept.tsx @@ -2,7 +2,7 @@ import { TreeData } from "element-plus/es/components/tree/src/tree.type"; import { ClViewGroup, useViewGroup } from "/$/base"; import { service } from "/@/cool"; import Node from "element-plus/es/components/tree/src/model/node"; -import ClAvatar from "../avatar/index"; +import ClAvatar from "../components/avatar/index"; export function useDeptViewGroup(options: DeepPartial) { const { ViewGroup } = useViewGroup({ diff --git a/src/modules/base/hooks/index.ts b/src/modules/base/hooks/index.ts index 498c348..8fd5674 100644 --- a/src/modules/base/hooks/index.ts +++ b/src/modules/base/hooks/index.ts @@ -1,2 +1,2 @@ export * from "../components/view/group/hook"; -export * from "../components/dept/hook"; +export * from "./dept";