Skip to content

Commit f2371ac

Browse files
YunaiV&wxr
authored andcommitted
增加 swagger、druid、skywalking、admin 的自定义路径
1 parent f20e1b4 commit f2371ac

File tree

6 files changed

+61
-180
lines changed

6 files changed

+61
-180
lines changed

src/api/infra/redis.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,3 @@ export function getCache() {
77
method: 'get'
88
})
99
}
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-
}

src/views/infra/druid/index.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,31 @@
22
<div>
33
<doc-alert title="数据库 MyBatis" url="https://doc.iocoder.cn/mybatis/" />
44
<doc-alert title="多数据源(读写分离)" url="https://doc.iocoder.cn/dynamic-datasource/" />
5-
<i-frame :src="url" />
5+
6+
<i-frame v-if="!loading" :src="url" />
67
</div>
78
</template>
89
<script>
910
import iFrame from "@/components/iFrame/index";
11+
import { getConfigKey } from "@/api/infra/config";
1012
export default {
1113
name: "Druid",
1214
components: { iFrame },
1315
data() {
1416
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
1619
};
1720
},
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+
}
1831
};
1932
</script>

src/views/infra/redis/index.vue

Lines changed: 3 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -65,77 +65,11 @@
6565
</el-card>
6666
</el-col>
6767
</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>
13468
</div>
13569
</template>
13670

13771
<script>
138-
import {getCache, getKeyDefineList, getKeyList, getKeyValue, deleteKey, deleteKeys} from "@/api/infra/redis";
72+
import { getCache } from "@/api/infra/redis";
13973
import * as echarts from 'echarts'
14074
require('echarts/theme/macarons') // echarts theme
14175
export default {
@@ -147,15 +81,7 @@ export default {
14781
// 使用内存
14882
usedmemory: null,
14983
// cache 信息
150-
cache: [],
151-
// key 列表
152-
keyDefineListLoad: true,
153-
keyDefineList: [],
154-
// 模块弹出框
155-
open: false,
156-
keyTemplate: "",
157-
cacheKeys: [],
158-
cacheForm: {}
84+
cache: []
15985
};
16086
},
16187
created () {
@@ -220,61 +146,12 @@ export default {
220146
],
221147
});
222148
});
223-
224-
// 查询 Redis Key 列表
225-
getKeyDefineList().then(response => {
226-
this.keyDefineList = response.data;
227-
this.keyDefineListLoad = false;
228-
});
229149
},
230150
231151
// 打开加载层
232152
openLoading () {
233153
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+
}
278155
},
279156
};
280157
</script>

src/views/infra/server/index.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
<template>
22
<div>
33
<doc-alert title="服务监控" url="https://doc.iocoder.cn/server-monitor/" />
4-
<i-frame :src="url" />
4+
<i-frame v-if="!loading" :src="url" />
55
</div>
66
</template>
77
<script>
88
import iFrame from "@/components/iFrame/index";
9+
import { getConfigKey } from "@/api/infra/config";
910
export default {
1011
name: "Druid",
1112
components: { iFrame },
1213
data() {
1314
return {
14-
url: process.env.VUE_APP_BASE_API + "/admin/applications"
15+
url: process.env.VUE_APP_BASE_API + "/admin/applications",
16+
loading: true
1517
};
1618
},
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+
}
1729
};
1830
</script>

src/views/infra/skywalking/index.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
<template>
22
<div>
33
<doc-alert title="服务监控" url="https://doc.iocoder.cn/server-monitor/" />
4-
<i-frame :src="url" />
4+
<i-frame v-if="!loading" :src="url" />
55
</div>
66
</template>
77
<script>
88
import iFrame from "@/components/iFrame/index";
9+
import { getConfigKey } from "@/api/infra/config";
910
export default {
1011
name: "Druid",
1112
components: { iFrame },
1213
data() {
1314
return {
14-
url: "http://skywalking.shop.iocoder.cn", // TODO 芋艿,后续改成配置读取
15+
url: "http://skywalking.shop.iocoder.cn",
16+
loading: true
1517
};
1618
},
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+
}
1729
};
1830
</script>

src/views/infra/swagger/index.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
<template>
22
<div>
33
<doc-alert title="接口文档" url="https://doc.iocoder.cn/api-doc/" />
4-
<i-frame :src="url" />
4+
<i-frame v-if="!loading" :src="url" />
55
</div>
66
</template>
77
<script>
88
import iFrame from "@/components/iFrame/index";
9+
import { getConfigKey } from "@/api/infra/config";
910
export default {
1011
name: "Druid",
1112
components: { iFrame },
1213
data() {
1314
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
1618
};
1719
},
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+
}
1830
};
1931
</script>

0 commit comments

Comments
 (0)