mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
fix(admin): 打开余额脚本弹窗时重置表单,避免跨账户残留配置
- 打开弹窗先重置表单字段(baseUrl/apiKey/extra 等),仅保留示例脚本\n- 若后端存在已保存配置,则加载后覆盖\n- 同步清理测试结果与 loading 状态,避免残留误导
This commit is contained in:
@@ -139,16 +139,6 @@ const saving = ref(false)
|
|||||||
const testing = ref(false)
|
const testing = ref(false)
|
||||||
const testResult = ref(null)
|
const testResult = ref(null)
|
||||||
|
|
||||||
const form = reactive({
|
|
||||||
baseUrl: '',
|
|
||||||
apiKey: '',
|
|
||||||
token: '',
|
|
||||||
extra: '',
|
|
||||||
timeoutSeconds: 10,
|
|
||||||
autoIntervalMinutes: 0,
|
|
||||||
scriptBody: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
const presetScript = `({
|
const presetScript = `({
|
||||||
request: {
|
request: {
|
||||||
url: "{{baseUrl}}/api/user/self",
|
url: "{{baseUrl}}/api/user/self",
|
||||||
@@ -178,8 +168,36 @@ const presetScript = `({
|
|||||||
}
|
}
|
||||||
})`
|
})`
|
||||||
|
|
||||||
|
const form = reactive({
|
||||||
|
baseUrl: '',
|
||||||
|
apiKey: '',
|
||||||
|
token: '',
|
||||||
|
extra: '',
|
||||||
|
timeoutSeconds: 10,
|
||||||
|
autoIntervalMinutes: 0,
|
||||||
|
scriptBody: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const buildDefaultForm = () => ({
|
||||||
|
baseUrl: '',
|
||||||
|
apiKey: '',
|
||||||
|
token: '',
|
||||||
|
extra: '',
|
||||||
|
timeoutSeconds: 10,
|
||||||
|
autoIntervalMinutes: 0,
|
||||||
|
// 默认给出示例脚本,字段保持清空,避免“上一个账户的配置污染当前账户”
|
||||||
|
scriptBody: presetScript
|
||||||
|
})
|
||||||
|
|
||||||
const emitClose = () => emit('close')
|
const emitClose = () => emit('close')
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
Object.assign(form, buildDefaultForm())
|
||||||
|
testResult.value = null
|
||||||
|
saving.value = false
|
||||||
|
testing.value = false
|
||||||
|
}
|
||||||
|
|
||||||
const loadConfig = async () => {
|
const loadConfig = async () => {
|
||||||
if (!props.account?.id || !props.account?.platform) return
|
if (!props.account?.id || !props.account?.platform) return
|
||||||
try {
|
try {
|
||||||
@@ -254,9 +272,8 @@ watch(
|
|||||||
() => props.show,
|
() => props.show,
|
||||||
(val) => {
|
(val) => {
|
||||||
if (val) {
|
if (val) {
|
||||||
applyPreset()
|
resetForm()
|
||||||
loadConfig()
|
loadConfig()
|
||||||
testResult.value = null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user