fix: local import error and NModal not as expected (#938)

This commit is contained in:
KingTwinkle 2023-03-28 09:34:15 +08:00 committed by GitHub
parent 32ad20416c
commit e2eeee455a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -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') }}
</NButton>