diff --git a/src/assets/default-avatar.png b/src/assets/default-avatar.png
deleted file mode 100644
index 1ede40f..0000000
Binary files a/src/assets/default-avatar.png and /dev/null differ
diff --git a/src/cool/module/index.ts b/src/cool/module/index.ts
index 5570f9c..13c6fe2 100644
--- a/src/cool/module/index.ts
+++ b/src/cool/module/index.ts
@@ -1,9 +1,8 @@
+import { App } from "vue";
import modules from "/@/modules";
import { router, addViews } from "../router";
-import { filename } from "../utils";
+import { filename, module } from "../utils";
import { isFunction, isObject } from "lodash";
-import { App } from "vue";
-import module from "../utils/module";
// 扫描文件
const files = import.meta.globEager("/src/modules/**/*");
diff --git a/src/cool/service/eps.ts b/src/cool/service/eps.ts
index 4deff12..0db0f0a 100644
--- a/src/cool/service/eps.ts
+++ b/src/cool/service/eps.ts
@@ -66,7 +66,7 @@ export function useEps(service: Service) {
// 获取 eps
function getEps() {
- if (isDev) {
+ if (isDev && test.eps) {
service
.request({
url: "/admin/base/open/eps"
@@ -183,30 +183,28 @@ export function useEps(service: Service) {
}
}
- // 获取
- if (isDev) {
- // 缓存数据
- set(storage.get("eps"));
+ // 解析
+ try {
+ const eps =
+ storage.get("eps") ||
+ JSON.parse(__EPS__ || "[]").map(([prefix, api]: any[]) => {
+ return {
+ prefix,
+ api: api.map(([method, path, name]: string[]) => {
+ return {
+ method,
+ path,
+ name
+ };
+ })
+ };
+ });
- // 接口数据
- if (test.eps) {
- getEps();
- }
- } else {
- const eps = JSON.parse(__EPS__).map(([prefix, api]: any[]) => {
- return {
- prefix,
- api: api.map(([method, path, name]: string[]) => {
- return {
- method,
- path,
- name
- };
- })
- };
- });
-
- // 文件数据
set({ eps });
+ } catch (err) {
+ console.error("[Eps] 解析失败!", err);
}
+
+ // 获取
+ getEps();
}
diff --git a/src/cool/service/index.ts b/src/cool/service/index.ts
index ec25f75..438ef81 100644
--- a/src/cool/service/index.ts
+++ b/src/cool/service/index.ts
@@ -1,20 +1,20 @@
-import { deepFiles, deepMerge } from "../utils";
+import { deepFiles, deepMerge, module } from "../utils";
import { BaseService } from "./base";
import { useEps } from "./eps";
-// 服务
+// 基础服务
export const service: Service = {
request: new BaseService().request
};
export function useService() {
+ // 接口内容
useEps(service);
- if (window.__modules__) {
- window.__modules__.forEach((e: any) => {
- deepMerge(service, deepFiles(e.service || []));
- });
- }
+ // 模块内容
+ module.list.forEach((e) => {
+ deepMerge(service, deepFiles(e.service || []));
+ });
return service;
}
diff --git a/src/cool/service/request.ts b/src/cool/service/request.ts
index 542a1d8..9c52786 100644
--- a/src/cool/service/request.ts
+++ b/src/cool/service/request.ts
@@ -115,40 +115,30 @@ axios.interceptors.response.use(
if (error.response) {
const { status, config } = error.response;
+ const message = `${config.url} ${status}`;
- switch (status) {
- case 401:
- href("/401");
- break;
+ console.error(message);
- case 403:
- if (isDev) {
- ElMessage.error(`${config.url} 无权限访问!!`);
- } else {
+ if (isDev) {
+ ElMessage.error(message);
+ } else {
+ switch (status) {
+ case 401:
+ href("/401");
+ break;
+
+ case 403:
href("/403");
- }
- break;
+ break;
- case 404:
- break;
-
- case 500:
- if (!isDev) {
+ case 500:
href("/500");
- }
- break;
+ break;
- case 502:
- if (isDev) {
- ElMessage.error(`${config.url} 服务异常!!`);
- } else {
+ case 502:
href("/502");
- }
- break;
-
- default:
- console.error(status, config.url);
- break;
+ break;
+ }
}
}
diff --git a/src/cool/utils/module.ts b/src/cool/utils/module.ts
index 5e836b4..4a290e0 100644
--- a/src/cool/utils/module.ts
+++ b/src/cool/utils/module.ts
@@ -1,7 +1,25 @@
// @ts-nocheck
+interface Item {
+ name: string;
+ options: {
+ [key: string]: any;
+ };
+ value: any;
+ service?: any[];
+ pages?: any[];
+ views?: any[];
+ components?: {
+ [key: string]: any;
+ };
+}
+
const module = {
- set(list: any[]) {
+ get list(): Item[] {
+ return window.__modules__ || [];
+ },
+
+ set(list: Item[]) {
window.__modules__ = list;
},
diff --git a/src/env.d.ts b/src/env.d.ts
index 7ec8820..f8da03d 100644
--- a/src/env.d.ts
+++ b/src/env.d.ts
@@ -1,2 +1,5 @@
///
///
+
+declare const __PROXY_LIST__: any[];
+declare const __EPS__: string;
diff --git a/src/modules/demo/service/test.ts b/src/modules/demo/service/test.ts
index e69de29..5b6aa7b 100644
--- a/src/modules/demo/service/test.ts
+++ b/src/modules/demo/service/test.ts
@@ -0,0 +1,6 @@
+import { BaseService, Service } from "/@/cool";
+
+@Service("test")
+class Test extends BaseService {}
+
+export default Test;
diff --git a/src/shims-vue.d.ts b/src/shims-vue.d.ts
index 1d84172..39981b8 100644
--- a/src/shims-vue.d.ts
+++ b/src/shims-vue.d.ts
@@ -7,7 +7,3 @@ declare module "*.vue" {
export default component;
}
-
-declare const __PROXY_LIST__: any[];
-declare const __EPS__: string;
-declare const __modules__: any[];