fix: 修复密钥页面重复请求问题

This commit is contained in:
tbphp
2025-07-13 21:18:17 +08:00
parent 469008acb0
commit 6ca84fc7e3
2 changed files with 16 additions and 3 deletions

View File

@@ -80,6 +80,8 @@ const formData = reactive<GroupFormData>({
const channelTypeOptions = ref<{ label: string; value: string }[]>([]);
const configOptions = ref<GroupConfigOption[]>([]);
const channelTypesFetched = ref(false);
const configOptionsFetched = ref(false);
// 表单验证规则
const rules: FormRules = {
@@ -124,6 +126,12 @@ watch(
() => props.show,
show => {
if (show) {
if (!channelTypesFetched.value) {
fetchChannelTypes();
}
if (!configOptionsFetched.value) {
fetchGroupConfigOptions();
}
resetForm();
if (props.group) {
loadGroupData();
@@ -174,7 +182,6 @@ function loadGroupData() {
});
}
fetchChannelTypes();
async function fetchChannelTypes() {
const options = (await settingsApi.getChannelTypes()) || [];
channelTypeOptions.value =
@@ -182,6 +189,7 @@ async function fetchChannelTypes() {
label: type,
value: type,
})) || [];
channelTypesFetched.value = true;
}
// 添加上游地址
@@ -199,10 +207,10 @@ function removeUpstream(index: number) {
}
}
fetchGroupConfigOptions();
async function fetchGroupConfigOptions() {
const options = await keysApi.getGroupConfigOptions();
configOptions.value = options || [];
configOptionsFetched.value = true;
}
// 添加配置项

View File

@@ -79,8 +79,13 @@ watch(
() => props.selectedGroup,
async newGroup => {
if (newGroup) {
// 检查重置页面是否会触发分页观察者。
const willWatcherTrigger = currentPage.value !== 1 || statusFilter.value !== "all";
resetPage();
await loadKeys();
// 如果分页观察者不触发,则手动加载。
if (!willWatcherTrigger) {
await loadKeys();
}
}
},
{ immediate: true }