mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-11 21:12:50 +00:00
优化
This commit is contained in:
parent
07b07b9ad7
commit
0f440cae4c
@ -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"
|
||||
|
||||
@ -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 || ""}`);
|
||||
}
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
// 注册指令
|
||||
|
||||
@ -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<ClViewGroup.Options>) {
|
||||
const { ViewGroup } = useViewGroup({
|
||||
@ -1,2 +1,2 @@
|
||||
export * from "../components/view/group/hook";
|
||||
export * from "../components/dept/hook";
|
||||
export * from "./dept";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user