refactor(core): 重构访问控制和插件实例化逻辑

- 修改访问控制和插件注册方式,使用异步函数统一实例化逻辑
- 更新相关组件和控制器以适应新的异步实例化方式
- 优化 DNS 提供商选择器,增加访问类型支持
This commit is contained in:
xiaojunnuo
2025-04-12 01:21:50 +08:00
parent c4fb138ae8
commit 3d8a5196a0
15 changed files with 79 additions and 39 deletions
@@ -5,6 +5,6 @@ const apiPrefix = "/pi/dnsProvider";
export async function GetList() {
return await request({
url: apiPrefix + "/list",
method: "post"
method: "post",
});
}
@@ -11,10 +11,10 @@ export default {
props: {
modelValue: {
type: String,
default: undefined
}
default: undefined,
},
},
emits: ["update:modelValue"],
emits: ["update:modelValue", "selected-change"],
setup(props: any, ctx: any) {
const options = ref<any[]>([]);
@@ -25,24 +25,36 @@ export default {
array.push({
value: item.name,
label: item.title,
icon: item.icon
icon: item.icon,
accessType: item.accessType,
});
}
options.value = array;
// if (props.modelValue == null && options.value.length > 0) {
// ctx.emit("update:modelValue", options.value[0].value);
// }
onSelectedChange(props.modelValue);
}
onCreate();
function onChanged(value: any) {
ctx.emit("update:modelValue", value);
onSelectedChange(value);
}
function onSelectedChange(value: any) {
if (value) {
const option = options.value.find(item => item.value == value);
if (option) {
ctx.emit("selected-change", option);
return;
}
}
}
return {
options,
onChanged
onChanged,
};
}
},
};
</script>