-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runtime): Optimize Runtime Module Components (#7548)
- Loading branch information
1 parent
18321d6
commit c6346b7
Showing
17 changed files
with
358 additions
and
839 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<template> | ||
<el-form-item :label="$t('runtime.app')" prop="appID"> | ||
<el-row :gutter="20"> | ||
<el-col :span="12"> | ||
<el-select | ||
v-model="runtime.appID" | ||
:disabled="mode === 'edit'" | ||
@change="changeApp(runtime.appID)" | ||
class="p-w-200" | ||
> | ||
<el-option v-for="(app, index) in apps" :key="index" :label="app.name" :value="app.id"></el-option> | ||
</el-select> | ||
</el-col> | ||
<el-col :span="12"> | ||
<el-select | ||
v-model="runtime.version" | ||
:disabled="mode === 'edit'" | ||
@change="changeVersion()" | ||
class="p-w-200" | ||
> | ||
<el-option | ||
v-for="(version, index) in appVersions" | ||
:key="index" | ||
:label="version" | ||
:value="version" | ||
></el-option> | ||
</el-select> | ||
</el-col> | ||
</el-row> | ||
</el-form-item> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { App } from '@/api/interface/app'; | ||
import { GetApp, GetAppDetail, SearchApp } from '@/api/modules/app'; | ||
import { useVModel } from '@vueuse/core'; | ||
import { defineProps } from 'vue'; | ||
const props = defineProps({ | ||
mode: { | ||
type: String, | ||
required: true, | ||
}, | ||
appKey: { | ||
type: String, | ||
required: true, | ||
}, | ||
modelValue: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}); | ||
const apps = ref<App.App[]>([]); | ||
const appVersions = ref<string[]>([]); | ||
const emit = defineEmits(['update:modelValue']); | ||
const runtime = useVModel(props, 'modelValue', emit); | ||
const appReq = reactive({ | ||
type: props.appKey, | ||
page: 1, | ||
pageSize: 20, | ||
resource: 'remote', | ||
}); | ||
const changeApp = (appID: number) => { | ||
for (const app of apps.value) { | ||
if (app.id === appID) { | ||
getApp(app.key, props.mode); | ||
break; | ||
} | ||
} | ||
}; | ||
const changeVersion = async () => { | ||
try { | ||
const res = await GetAppDetail(runtime.value.appID, runtime.value.version, 'runtime'); | ||
runtime.value.appDetailID = res.data.id; | ||
} catch (error) {} | ||
}; | ||
const getApp = async (appkey: string, mode: string) => { | ||
try { | ||
const res = await GetApp(appkey); | ||
appVersions.value = res.data.versions || []; | ||
if (res.data.versions.length > 0) { | ||
if (mode === 'create') { | ||
runtime.value.version = res.data.versions[0]; | ||
changeVersion(); | ||
} | ||
} | ||
} catch (error) {} | ||
}; | ||
const searchApp = async (appID: number) => { | ||
try { | ||
const res = await SearchApp(appReq); | ||
apps.value = res.data.items || []; | ||
if (res.data && res.data.items && res.data.items.length > 0) { | ||
if (appID == null) { | ||
runtime.value.appID = res.data.items[0].id; | ||
getApp(res.data.items[0].key, props.mode); | ||
} else { | ||
res.data.items.forEach((item) => { | ||
if (item.id === appID) { | ||
getApp(item.key, props.mode); | ||
} | ||
}); | ||
} | ||
} | ||
} catch (error) {} | ||
}; | ||
onMounted(() => { | ||
if (props.mode === 'create') { | ||
searchApp(null); | ||
} else { | ||
searchApp(runtime.value.appID); | ||
} | ||
}); | ||
</script> |
Oops, something went wrong.