diff --git a/src/components/common/PromptStore/index.vue b/src/components/common/PromptStore/index.vue index cbee4b051d..93bbe5a82b 100644 --- a/src/components/common/PromptStore/index.vue +++ b/src/components/common/PromptStore/index.vue @@ -147,7 +147,7 @@ const clearPromptTemplate = () => { message.success(t('common.clearSuccess')) } -const importPromptTemplate = () => { +const importPromptTemplate = (from = 'online') => { try { const jsonData = JSON.parse(tempPromptValue.value) let key = '' @@ -168,7 +168,7 @@ const importPromptTemplate = () => { } for (const i of jsonData) { - if (!('key' in i) || !('value' in i)) + if (!(key in i) || !(value in i)) throw new Error(t('store.importError')) let safe = true for (const j of promptList.value) { @@ -191,6 +191,8 @@ const importPromptTemplate = () => { catch { message.error('JSON 格式错误,请检查 JSON 格式') } + if (from === 'local') + showModal.value = !showModal.value } // 模板导出 @@ -469,7 +471,7 @@ const dataSource = computed(() => { block type="primary" :disabled="inputStatus" - @click="() => { importPromptTemplate() }" + @click="() => { importPromptTemplate('local') }" > {{ t('common.import') }}