feature: 优化添加空方法的apiPath

This commit is contained in:
pixelMax(奇淼
2024-07-26 11:22:30 +08:00
parent 7ad6b9c32a
commit bb3a54a312
5 changed files with 33 additions and 15 deletions
+24 -11
View File
@@ -20,15 +20,15 @@
</el-form-item>
<el-form-item label="API分组">
<el-select
v-model="searchInfo.apiGroup"
clearable
placeholder="请选择"
v-model="searchInfo.apiGroup"
clearable
placeholder="请选择"
>
<el-option
v-for="item in apiGroupOptions"
:key="item.value"
:label="item.label"
:value="item.value"
v-for="item in apiGroupOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
@@ -207,6 +207,7 @@
:before-close="closeSyncDialog"
:show-close="false"
>
<warning-bar title="同步API,不输入路由分组将不会被自动同步" />
<template #header>
<div class="flex justify-between items-center">
<span class="text-lg">同步路由</span>
@@ -215,8 +216,9 @@
取 消
</el-button>
<el-button
type="primary"
@click="enterSyncDialog"
type="primary"
:loading="syncing"
@click="enterSyncDialog"
>
确 定
</el-button>
@@ -546,12 +548,14 @@ const pageSize = ref(10)
const tableData = ref([])
const searchInfo = ref({})
const apiGroupOptions = ref([])
const apiGroupMap = ref({})
const getGroup = async() => {
const res = await getApiGroups()
if (res.code === 0) {
apiGroupOptions.value = res.data.map(item => ({ label: item, value: item }))
const groups = res.data.groups
apiGroupOptions.value = groups.map(item => ({ label: item, value: item }))
apiGroupMap.value = res.data.apiGroupMap
}
}
@@ -576,9 +580,13 @@ const closeSyncDialog = () => {
syncApiFlag.value = false
}
const syncing = ref(false)
const enterSyncDialog = async() => {
syncing.value = true
const res = await enterSyncApi(syncApiData.value)
syncing.value = false
if (res.code === 0) {
ElMessage({
type: 'success',
@@ -688,6 +696,11 @@ const syncApiFlag = ref(false)
const onSync = async() => {
const res = await syncApi()
if (res.code === 0) {
res.data.newApis.forEach(item => {
item.apiGroup = apiGroupMap.value[item.path.split('/')[1]]
console.log(apiGroupMap.value)
})
syncApiData.value = res.data
syncApiFlag.value = true
}
@@ -190,6 +190,10 @@
/>
</el-select>
</el-form-item>
<el-form-item label="路由path:">
<el-input v-model="autoFunc.router" placeholder="路由path" />
<div>API路径: [{{ autoFunc.method }}] /{{ autoFunc.abbreviation }}/{{ autoFunc.router }}</div>
</el-form-item>
</el-form>
</div>
</el-drawer>