Commit 04c3cdf372fa5a473d777fc453b53e8400685843

Authored by YunaiV
1 parent 70a10b26

增加 swagger、druid、skywalking、admin 的自定义路径

yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/config/ConfigController.java
... ... @@ -73,7 +73,7 @@ public class ConfigController {
73 73 public CommonResult<String> getConfigKey(@RequestParam("key") String key) {
74 74 ConfigDO config = configService.getConfigByKey(key);
75 75 if (config == null) {
76   - return null;
  76 + return success(null);
77 77 }
78 78 if (!config.getVisible()) {
79 79 throw exception(ErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_VISIBLE);
... ...
yudao-ui-admin/src/api/infra/redis.js
... ... @@ -7,48 +7,3 @@ export function getCache() {
7 7 method: 'get'
8 8 })
9 9 }
10   -
11   -// 获取模块
12   -export function getKeyDefineList() {
13   - return request({
14   - url: '/infra/redis/get-key-define-list',
15   - method: 'get'
16   - })
17   -}
18   -
19   -// 获取键名列表
20   -export function getKeyList(keyTemplate) {
21   - return request({
22   - url: '/infra/redis/get-key-list',
23   - method: 'get',
24   - params: {
25   - keyTemplate
26   - }
27   - })
28   -}
29   -
30   -// 获取缓存内容
31   -export function getKeyValue(key) {
32   - return request({
33   - url: '/infra/redis/get-key-value?key=' + key,
34   - method: 'get'
35   - })
36   -}
37   -
38   -// 根据键名删除缓存
39   -export function deleteKey(key) {
40   - return request({
41   - url: '/infra/redis/delete-key?key=' + key,
42   - method: 'delete'
43   - })
44   -}
45   -
46   -export function deleteKeys(keyTemplate) {
47   - return request({
48   - url: '/infra/redis/delete-keys?',
49   - method: 'delete',
50   - params: {
51   - keyTemplate
52   - }
53   - })
54   -}
... ...
yudao-ui-admin/src/views/infra/druid/index.vue
... ... @@ -2,18 +2,31 @@
2 2 <div>
3 3 <doc-alert title="数据库 MyBatis" url="https://doc.iocoder.cn/mybatis/" />
4 4 <doc-alert title="多数据源(读写分离)" url="https://doc.iocoder.cn/dynamic-datasource/" />
5   - <i-frame :src="url" />
  5 +
  6 + <i-frame v-if="!loading" :src="url" />
6 7 </div>
7 8 </template>
8 9 <script>
9 10 import iFrame from "@/components/iFrame/index";
  11 +import { getConfigKey } from "@/api/infra/config";
10 12 export default {
11 13 name: "Druid",
12 14 components: { iFrame },
13 15 data() {
14 16 return {
15   - url: process.env.VUE_APP_BASE_API + "/druid/index.html"
  17 + url: process.env.VUE_APP_BASE_API + "/druid/index.html",
  18 + loading: true
16 19 };
17 20 },
  21 + created() {
  22 + getConfigKey("url.druid").then(response => {
  23 + if (!response.data || response.data.length === 0) {
  24 + return
  25 + }
  26 + this.url = response.data;
  27 + }).finally(() => {
  28 + this.loading = false;
  29 + })
  30 + }
18 31 };
19 32 </script>
... ...
yudao-ui-admin/src/views/infra/redis/index.vue
... ... @@ -65,77 +65,11 @@
65 65 </el-card>
66 66 </el-col>
67 67 </el-row>
68   -
69   - <el-table v-loading="keyDefineListLoad" :data="keyDefineList" row-key="id" @row-click="openKeyTemplate">
70   - <el-table-column prop="keyTemplate" label="Key 模板" width="200" />
71   - <el-table-column prop="keyType" label="Key 类型" width="100" />
72   - <el-table-column prop="valueType" label="Value 类型" />
73   - <el-table-column prop="timeoutType" label="超时时间" width="200">
74   - <template v-slot="scope">
75   - <dict-tag
76   - :type="DICT_TYPE.INFRA_REDIS_TIMEOUT_TYPE"
77   - :value="scope.row.timeoutType"
78   - />
79   - <span v-if="scope.row.timeout > 0"
80   - >({{ scope.row.timeout / 1000 }} 秒)</span
81   - >
82   - </template>
83   - </el-table-column>
84   - <el-table-column prop="memo" label="备注" />
85   - </el-table>
86   -
87   - <!-- 缓存模块信息框 -->
88   - <el-dialog :title="keyTemplate + ' 模板'" :visible.sync="open" width="70vw" append-to-body>
89   - <el-row :gutter="10">
90   - <el-col :span="14" class="card-box">
91   - <el-card style="height: 70vh; overflow: scroll">
92   - <div slot="header">
93   - <span>键名列表</span>
94   - <el-button style="float: right; padding: 3px 0" type="text" icon="el-icon-refresh-right" @click="refreshKeys" />
95   - </div>
96   - <el-table :data="cacheKeys" style="width: 100%" @row-click="handleKeyValue">
97   - <el-table-column label="缓存键名" align="center" :show-overflow-tooltip="true">
98   - <template v-slot="scope">{{ scope.row }}</template>
99   - </el-table-column>
100   - <el-table-column label="操作" width="60" align="center" class-name="small-padding fixed-width">
101   - <template v-slot="scope">
102   - <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDeleteKey(scope.row)" />
103   - </template>
104   - </el-table-column>
105   - </el-table>
106   - </el-card>
107   - </el-col>
108   -
109   - <el-col :span="10">
110   - <el-card :bordered="false" style="height: 70vh">
111   - <div slot="header">
112   - <span>缓存内容</span>
113   - <el-button style="float: right; padding: 3px 0" type="text" icon="el-icon-refresh-right"
114   - @click="handleDeleteKeys(keyTemplate)">清理全部</el-button>
115   - </div>
116   - <el-form :model="cacheForm">
117   - <el-row :gutter="32">
118   - <el-col :offset="1" :span="22">
119   - <el-form-item label="缓存键名:" prop="key">
120   - <el-input v-model="cacheForm.key" :readOnly="true" />
121   - </el-form-item>
122   - </el-col>
123   - <el-col :offset="1" :span="22">
124   - <el-form-item label="缓存内容:" prop="value">
125   - <el-input v-model="cacheForm.value" type="textarea" :rows="12" :readOnly="true"/>
126   - </el-form-item>
127   - </el-col>
128   - </el-row>
129   - </el-form>
130   - </el-card>
131   - </el-col>
132   - </el-row>
133   - </el-dialog>
134 68 </div>
135 69 </template>
136 70  
137 71 <script>
138   -import {getCache, getKeyDefineList, getKeyList, getKeyValue, deleteKey, deleteKeys} from "@/api/infra/redis";
  72 +import { getCache } from "@/api/infra/redis";
139 73 import * as echarts from 'echarts'
140 74 require('echarts/theme/macarons') // echarts theme
141 75 export default {
... ... @@ -147,15 +81,7 @@ export default {
147 81 // 使用内存
148 82 usedmemory: null,
149 83 // cache 信息
150   - cache: [],
151   - // key 列表
152   - keyDefineListLoad: true,
153   - keyDefineList: [],
154   - // 模块弹出框
155   - open: false,
156   - keyTemplate: "",
157   - cacheKeys: [],
158   - cacheForm: {}
  84 + cache: []
159 85 };
160 86 },
161 87 created () {
... ... @@ -220,61 +146,12 @@ export default {
220 146 ],
221 147 });
222 148 });
223   -
224   - // 查询 Redis Key 列表
225   - getKeyDefineList().then(response => {
226   - this.keyDefineList = response.data;
227   - this.keyDefineListLoad = false;
228   - });
229 149 },
230 150  
231 151 // 打开加载层
232 152 openLoading () {
233 153 this.$modal.loading("正在加载缓存监控数据,请稍后!");
234   - },
235   -
236   - // 打开缓存弹窗
237   - openKeyTemplate (keyDefine) {
238   - this.open = true;
239   - // 加载键名列表
240   - this.keyTemplate = keyDefine.keyTemplate;
241   - this.doGetKeyList(this.keyTemplate);
242   - },
243   -
244   - // 获取键名列表
245   - doGetKeyList (keyTemplate) {
246   - getKeyList(keyTemplate).then(response => {
247   - this.cacheKeys = response.data
248   - this.cacheForm = {}
249   - })
250   - },
251   -
252   - // 获取缓存值
253   - handleKeyValue (key) {
254   - getKeyValue(key).then(response => {
255   - this.cacheForm = response.data
256   - })
257   - },
258   -
259   - // 刷新键名列表
260   - refreshKeys() {
261   - this.$modal.msgSuccess("刷新键名列表成功");
262   - this.doGetKeyList(this.keyTemplate);
263   - },
264   -
265   - // 删除缓存
266   - handleDeleteKey(key){
267   - deleteKey(key).then(response => {
268   - this.$modal.msgSuccess("清理缓存键名[" + key + "]成功");
269   - this.doGetKeyList(this.keyTemplate);
270   - })
271   - },
272   - handleDeleteKeys(keyTemplate){
273   - deleteKeys(keyTemplate).then(response => {
274   - this.$modal.msgSuccess("清空[" + keyTemplate + "]成功");
275   - this.doGetKeyList(this.keyTemplate);
276   - })
277   - },
  154 + }
278 155 },
279 156 };
280 157 </script>
... ...
yudao-ui-admin/src/views/infra/server/index.vue
1 1 <template>
2 2 <div>
3 3 <doc-alert title="服务监控" url="https://doc.iocoder.cn/server-monitor/" />
4   - <i-frame :src="url" />
  4 + <i-frame v-if="!loading" :src="url" />
5 5 </div>
6 6 </template>
7 7 <script>
8 8 import iFrame from "@/components/iFrame/index";
  9 +import { getConfigKey } from "@/api/infra/config";
9 10 export default {
10 11 name: "Druid",
11 12 components: { iFrame },
12 13 data() {
13 14 return {
14   - url: process.env.VUE_APP_BASE_API + "/admin/applications"
  15 + url: process.env.VUE_APP_BASE_API + "/admin/applications",
  16 + loading: true
15 17 };
16 18 },
  19 + created() {
  20 + getConfigKey("url.spring-boot-admin").then(response => {
  21 + if (!response.data || response.data.length === 0) {
  22 + return
  23 + }
  24 + this.url = response.data;
  25 + }).finally(() => {
  26 + this.loading = false;
  27 + })
  28 + }
17 29 };
18 30 </script>
... ...
yudao-ui-admin/src/views/infra/skywalking/index.vue
1 1 <template>
2 2 <div>
3 3 <doc-alert title="服务监控" url="https://doc.iocoder.cn/server-monitor/" />
4   - <i-frame :src="url" />
  4 + <i-frame v-if="!loading" :src="url" />
5 5 </div>
6 6 </template>
7 7 <script>
8 8 import iFrame from "@/components/iFrame/index";
  9 +import { getConfigKey } from "@/api/infra/config";
9 10 export default {
10 11 name: "Druid",
11 12 components: { iFrame },
12 13 data() {
13 14 return {
14   - url: "http://skywalking.shop.iocoder.cn", // TODO 芋艿,后续改成配置读取
  15 + url: "http://skywalking.shop.iocoder.cn",
  16 + loading: true
15 17 };
16 18 },
  19 + created() {
  20 + getConfigKey("url.skywalking").then(response => {
  21 + if (!response.data || response.data.length === 0) {
  22 + return
  23 + }
  24 + this.url = response.data;
  25 + }).finally(() => {
  26 + this.loading = false;
  27 + })
  28 + }
17 29 };
18 30 </script>
... ...
yudao-ui-admin/src/views/infra/swagger/index.vue
1 1 <template>
2 2 <div>
3 3 <doc-alert title="接口文档" url="https://doc.iocoder.cn/api-doc/" />
4   - <i-frame :src="url" />
  4 + <i-frame v-if="!loading" :src="url" />
5 5 </div>
6 6 </template>
7 7 <script>
8 8 import iFrame from "@/components/iFrame/index";
  9 +import { getConfigKey } from "@/api/infra/config";
9 10 export default {
10 11 name: "Druid",
11 12 components: { iFrame },
12 13 data() {
13 14 return {
14   - // url: process.env.VUE_APP_BASE_API + "/doc.html"
15   - url: process.env.VUE_APP_BASE_API + "/swagger-ui"
  15 + url: process.env.VUE_APP_BASE_API + "/doc.html", // Knife4j UI
  16 + // url: process.env.VUE_APP_BASE_API + "/swagger-ui", // Swagger UI
  17 + loading: true
16 18 };
17 19 },
  20 + created() {
  21 + getConfigKey("url.swagger").then(response => {
  22 + if (!response.data || response.data.length === 0) {
  23 + return
  24 + }
  25 + this.url = response.data;
  26 + }).finally(() => {
  27 + this.loading = false;
  28 + })
  29 + }
18 30 };
19 31 </script>
... ...