Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/components/common/PromptStore/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand All @@ -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) {
Expand All @@ -191,6 +191,8 @@ const importPromptTemplate = () => {
catch {
message.error('JSON 格式错误,请检查 JSON 格式')
}
if (from === 'local')
showModal.value = !showModal.value
}

// 模板导出
Expand Down Expand Up @@ -469,7 +471,7 @@ const dataSource = computed(() => {
block
type="primary"
:disabled="inputStatus"
@click="() => { importPromptTemplate() }"
@click="() => { importPromptTemplate('local') }"
>
{{ t('common.import') }}
</NButton>
Expand Down