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

main
KingTwinkle 2 years ago committed by GitHub
parent 32ad20416c
commit e2eeee455a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -147,7 +147,7 @@ const clearPromptTemplate = () => {
message.success(t('common.clearSuccess')) message.success(t('common.clearSuccess'))
} }
const importPromptTemplate = () => { const importPromptTemplate = (from = 'online') => {
try { try {
const jsonData = JSON.parse(tempPromptValue.value) const jsonData = JSON.parse(tempPromptValue.value)
let key = '' let key = ''
@ -168,7 +168,7 @@ const importPromptTemplate = () => {
} }
for (const i of jsonData) { 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')) throw new Error(t('store.importError'))
let safe = true let safe = true
for (const j of promptList.value) { for (const j of promptList.value) {
@ -191,6 +191,8 @@ const importPromptTemplate = () => {
catch { catch {
message.error('JSON 格式错误,请检查 JSON 格式') message.error('JSON 格式错误,请检查 JSON 格式')
} }
if (from === 'local')
showModal.value = !showModal.value
} }
// //
@ -469,7 +471,7 @@ const dataSource = computed(() => {
block block
type="primary" type="primary"
:disabled="inputStatus" :disabled="inputStatus"
@click="() => { importPromptTemplate() }" @click="() => { importPromptTemplate('local') }"
> >
{{ t('common.import') }} {{ t('common.import') }}
</NButton> </NButton>

Loading…
Cancel
Save