import { reactive, watch, onMounted } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'; export default { props: ['isOpen', 'config'], // 接收当前的配置 emits: ['close', 'update:config'], // 更新配置传回给父组件 setup(props, { emit }) { const localConfig = reactive({ endpoint: '', key: '', model: '' }); // 初始化时同步 watch(() => props.config, (newVal) => { Object.assign(localConfig, newVal); }, { deep: true, immediate: true }); const save = () => { emit('update:config', { ...localConfig }); // 把修改发回给主程序 alert("API 配置已保存!"); emit('close'); }; return { localConfig, save, close: () => emit('close') }; }, template: `