diff --git a/.env.development b/.env.development index b5f2a83..80cc26b 100644 --- a/.env.development +++ b/.env.development @@ -5,5 +5,5 @@ VITE_APP_TITLE=里派基础框架 VITE_APP_ENV='development' # 开发环境 -VITE_API_BASE='https://demo.leapy.cn/admin/' +VITE_API_BASE='https://demo.leapy.cn' VITE_WS_URL='wss://demo.leapy.cn/ws' diff --git a/.env.production b/.env.production index 0f9bf18..70bd6a7 100644 --- a/.env.production +++ b/.env.production @@ -5,5 +5,5 @@ VITE_APP_TITLE=里派基础框架 VITE_APP_ENV='production' # 生产环境 -VITE_API_BASE='https://demo.leapy.cn/admin/' +VITE_API_BASE='https://demo.leapy.cn' VITE_WS_URL='wss://demo.leapy.cn/ws' diff --git a/package.json b/package.json index 50ab859..3a51a85 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "eslint": "^9.27.0", "sass": "^1.89.0", "typescript": "^5.8.3", - "vite": "7.1.5" + "vite": "7.1.11" }, "license": "MIT" } diff --git a/src/api/model/system.ts b/src/api/model/system.ts index e9c539c..3832215 100644 --- a/src/api/model/system.ts +++ b/src/api/model/system.ts @@ -129,5 +129,10 @@ export default { empty: async function (data = {}) { return await http.delete("crontab_log/remove_all", data); }, + }, + swagger: { + list: async function (data = {}) { + return await http.get("swagger/json", data); + }, } } diff --git a/src/assets/icons/CloudDown.vue b/src/assets/icons/CloudDown.vue new file mode 100644 index 0000000..1bd4c7d --- /dev/null +++ b/src/assets/icons/CloudDown.vue @@ -0,0 +1,3 @@ + + + diff --git a/src/components/piApiDocShow/index.vue b/src/components/piApiDocShow/index.vue new file mode 100644 index 0000000..9f3c003 --- /dev/null +++ b/src/components/piApiDocShow/index.vue @@ -0,0 +1,237 @@ + + + + + + + + ^K + + + + + + + + + {{ node.label }} + + + GET + POST + PUT + DELETE + {{ data.method }} + + + + + + + 里派提供技术支持 + + + + + + + + {{ project.info.title }} + {{ item }} + {{ data.name }} + + + + v{{ project.info.version }} + OAS {{ project.json.openapi }} + 导出 + + + + {{ project.info.title }} + + + + + + {{ item.info.title }} + + + + + + + + + + {{ data.summary }} + + + + {{ server.description }} + + + + + + + {{ item.description }} + + + + + + + GET + POST + PUT + DELETE + {{data.method}} + {{server.url}}{{data.path}} + + + + + + + + + + + + + + + + diff --git a/src/components/piApiDocShow/jsonParse.ts b/src/components/piApiDocShow/jsonParse.ts new file mode 100644 index 0000000..7d1f457 --- /dev/null +++ b/src/components/piApiDocShow/jsonParse.ts @@ -0,0 +1,35 @@ +export function parseSwagger(swaggerJson) { + const result: any[] = [] + let first: Object = {} + for (const [path, methods] of Object.entries(swaggerJson.paths)) { + for (const [method, api] of Object.entries(methods)) { + let currentLevel = result + api.tags.forEach((level, index) => { + let node = currentLevel.find(item => item.name === level) + if (!node) { + node = { name: level, children: []} + currentLevel.push(node) + } + if (index === api.tags.length - 1) { + node.children.push({ + path, + method: method.toUpperCase(), + name: api.summary || '', + ...api + }) + if (first) { + first = { + path, + method: method.toUpperCase(), + name: api.summary || '', + ...api + } + } + } else { + currentLevel = node.children + } + }) + } + } + return [result, first] +} diff --git a/src/config/index.ts b/src/config/index.ts index 0bf866b..b680265 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -5,6 +5,8 @@ export default { API_URL: import.meta.env.VITE_APP_ENV === 'development' ? "/api" : import.meta.env.VITE_API_BASE, // websocket WS_URL: import.meta.env.VITE_WS_URL, + // 接口前缀 + API_PREFIX: '/admin/', //请求超时 TIMEOUT: 10000, //请求是否开启缓存 diff --git a/src/router/index.ts b/src/router/index.ts index de926f3..1afc60b 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -57,9 +57,11 @@ router.beforeEach(async (to, from, next) => { // 动态加载菜单 /* @ts-ignore */ const res = await api.auth.menu() - + /* @ts-ignore */ tools.data.set("MENU", tools.makeMenu(res.data.menus, 0)) + /* @ts-ignore */ tools.data.set("PERMISSIONS", res.data.buttons) + /* @ts-ignore */ tools.data.set("ROLE", res.data.roles) let apiMenu = tools.data.get("MENU") || [] diff --git a/src/utils/request.ts b/src/utils/request.ts index 5bbe4b8..0ac447d 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -5,7 +5,7 @@ import tools from '@/utils/tools'; import router from '@/router'; // 请求地址 -axios.defaults.baseURL = sConfig.API_URL +axios.defaults.baseURL = sConfig.API_URL + sConfig.API_PREFIX // 超时时间 axios.defaults.timeout = sConfig.TIMEOUT // 请求拦截 diff --git a/src/views/tool/doc/index.vue b/src/views/tool/doc/index.vue new file mode 100644 index 0000000..97e54f4 --- /dev/null +++ b/src/views/tool/doc/index.vue @@ -0,0 +1,33 @@ + + + + + + + + +