70 lines
1.8 KiB
Vue
70 lines
1.8 KiB
Vue
<template>
|
|
<el-dialog
|
|
:model-value="modelValue"
|
|
title="AI 设置"
|
|
width="480px"
|
|
destroy-on-close
|
|
@update:model-value="emit('update:modelValue', $event)"
|
|
>
|
|
<el-form label-position="top">
|
|
<el-form-item label="DeepSeek API Key">
|
|
<el-input
|
|
v-model="localKey"
|
|
type="password"
|
|
show-password
|
|
placeholder="sk-..."
|
|
autocomplete="off"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="额外关键字">
|
|
<el-input
|
|
v-model="localKeywords"
|
|
type="textarea"
|
|
:rows="4"
|
|
placeholder="用于规定 AI 角色与分析增强,多个词用逗号或换行分隔"
|
|
/>
|
|
</el-form-item>
|
|
</el-form>
|
|
<template #footer>
|
|
<el-button @click="emit('update:modelValue', false)">取消</el-button>
|
|
<el-button type="primary" @click="save">保存</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, watch } from 'vue'
|
|
import { ElMessage } from 'element-plus'
|
|
import { useSettingsStore, DEFAULT_KEYWORDS } from '../../stores/settings'
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
modelValue?: boolean
|
|
}>(),
|
|
{ modelValue: false },
|
|
)
|
|
const emit = defineEmits<{
|
|
'update:modelValue': [value: boolean]
|
|
}>()
|
|
|
|
const settings = useSettingsStore()
|
|
const localKey = ref('')
|
|
const localKeywords = ref('')
|
|
|
|
watch(
|
|
() => props.modelValue,
|
|
(open) => {
|
|
if (open) {
|
|
localKey.value = settings.apiKey
|
|
localKeywords.value = settings.keywords || DEFAULT_KEYWORDS
|
|
}
|
|
},
|
|
)
|
|
|
|
function save() {
|
|
settings.apiKey = localKey.value.trim()
|
|
settings.keywords = localKeywords.value.trim() || DEFAULT_KEYWORDS
|
|
ElMessage.success('设置已保存到本地')
|
|
emit('update:modelValue', false)
|
|
}
|
|
</script> |