33 NInputNumber ,
44 NSwitch ,
55 NSelect ,
6- NAutoComplete ,
76 NInput ,
87 NFlex ,
98 NText ,
@@ -15,6 +14,7 @@ import {
1514} from 'naive-ui'
1615import { useForm , useFormHooks , useModalHooks } from '@baota/naive-ui/hooks'
1716import { useStore } from '@components/FlowChart/useStore'
17+ import { useRoute } from '@baota/router'
1818import { $t } from '@locales/index'
1919import rules from './verify'
2020import DnsProviderSelect from '@components/DnsProviderSelect'
@@ -54,20 +54,26 @@ export default defineComponent({
5454 } ,
5555 setup ( props ) {
5656 const { updateNodeConfig, advancedOptions, isRefreshNode } = useStore ( )
57+ // 获取路由信息
58+ const route = useRoute ( )
5759 // 弹窗辅助
5860 const { confirm } = useModalHooks ( )
5961 // 获取表单助手函数
6062 const { useFormInput, useFormSelect, useFormMore, useFormHelp, useFormSwitch } = useFormHooks ( )
6163 // 表单参数
6264 const param = ref ( deepClone ( props . node . config ) )
6365
66+ // 获取路由参数
67+ const isEdit = computed ( ( ) => route . query . isEdit === 'true' )
68+ const routeEmail = computed ( ( ) => ( route . query . email as string ) || '' )
69+
6470 // CA选项状态
6571 const caOptions = ref < Array < { label : string ; value : string ; icon : string } > > ( [ ] )
6672 const emailOptions = ref < string [ ] > ( [ ] )
6773 const isLoadingCA = ref ( false )
6874 const isLoadingEmails = ref ( false )
6975 const showEmailDropdown = ref ( false )
70- const emailInputRef = ref < any > ( null )
76+ const emailInputRef = ref < InstanceType < typeof NInput > | null > ( null )
7177
7278 // 加载CA选项
7379 const loadCAOptions = async ( ) => {
@@ -121,12 +127,20 @@ export default defineComponent({
121127 try {
122128 const { data } = await getEabList ( { ca, p : 1 , limit : 1000 } ) . fetch ( )
123129 emailOptions . value = data ?. map ( ( item ) => item . email ) . filter ( Boolean ) || [ ]
124- if ( ! emailOptions . value . length ) {
125- param . value . email = ''
126- }
127- // 如果邮箱数组有内容且当前邮箱为空,自动填充第一个邮箱地址
128- if ( emailOptions . value . length > 0 && emailOptions . value [ 0 ] ) {
129- param . value . email = emailOptions . value [ 0 ]
130+
131+ // 检查是否为编辑模式且有外部传入的邮箱
132+ if ( isEdit . value && routeEmail . value ) {
133+ // 编辑模式:使用外部传入的邮箱地址
134+ param . value . email = routeEmail . value
135+ } else {
136+ // 非编辑模式:保持原有逻辑
137+ if ( ! emailOptions . value . length ) {
138+ param . value . email = ''
139+ }
140+ // 如果邮箱数组有内容且当前邮箱为空,自动填充第一个邮箱地址
141+ if ( emailOptions . value . length > 0 && emailOptions . value [ 0 ] && ! param . value . email ) {
142+ param . value . email = emailOptions . value [ 0 ]
143+ }
130144 }
131145 } catch ( error ) {
132146 console . error ( '加载邮件选项失败:' , error )
@@ -138,7 +152,8 @@ export default defineComponent({
138152 // 处理CA选择变化
139153 const handleCAChange = ( value : string ) => {
140154 param . value . ca = value
141- loadEmailOptions ( value )
155+ // 移除直接调用 loadEmailOptions,让 watch 监听器统一处理
156+ // 这样避免了用户切换CA时的重复 API 请求
142157 }
143158
144159 // 跳转到CA管理页面
@@ -157,7 +172,7 @@ export default defineComponent({
157172 }
158173
159174 // 渲染CA选择器单选标签
160- const renderSingleSelectTag = ( { option } : { option : any } ) => {
175+ const renderSingleSelectTag = ( { option } : any ) => {
161176 return (
162177 < NFlex align = "center" >
163178 { option . label ? renderLabel ( option ) : < NText class = "text-[#aaa]" > { $t ( 't_0_1747990228780' ) } </ NText > }
@@ -472,10 +487,14 @@ export default defineComponent({
472487 onMounted ( async ( ) => {
473488 advancedOptions . value = false
474489 await loadCAOptions ( )
475- // 如果初始化时已有CA值,加载对应的邮箱选项
476- if ( param . value . ca ) {
477- await loadEmailOptions ( param . value . ca )
490+
491+ // 如果是编辑模式且有外部传入的邮箱,直接设置邮箱值
492+ if ( isEdit . value && routeEmail . value ) {
493+ param . value . email = routeEmail . value
478494 }
495+
496+ // 移除重复调用,让 watch 监听器处理 CA 值变化
497+ // 这样避免了 onMounted 和 watch 同时调用 loadEmailOptions 导致的重复请求
479498 } )
480499
481500 // 确认事件触发
0 commit comments