AI设置
This commit is contained in:
parent
9ed84cf083
commit
8ea48632ee
@ -43,7 +43,7 @@
|
||||
<el-dialog
|
||||
v-model="positionOpen"
|
||||
title="机构持仓"
|
||||
width="1100px"
|
||||
width="70%"
|
||||
top="5vh"
|
||||
class="panel-dialog position-dialog"
|
||||
destroy-on-close
|
||||
|
||||
@ -16,12 +16,12 @@
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="额外关键词">
|
||||
<el-form-item label="额外关键字">
|
||||
<el-input
|
||||
v-model="localKeywords"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="用于新闻过滤与分析增强,多个词用逗号或换行分隔"
|
||||
:rows="4"
|
||||
placeholder="用于规定 AI 角色与分析增强,多个词用逗号或换行分隔"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@ -35,7 +35,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useSettingsStore } from '../../stores/settings'
|
||||
import { useSettingsStore, DEFAULT_KEYWORDS } from '../../stores/settings'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@ -56,15 +56,15 @@ watch(
|
||||
(open) => {
|
||||
if (open) {
|
||||
localKey.value = settings.apiKey
|
||||
localKeywords.value = settings.keywords
|
||||
localKeywords.value = settings.keywords || DEFAULT_KEYWORDS
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
function save() {
|
||||
settings.apiKey = localKey.value.trim()
|
||||
settings.keywords = localKeywords.value.trim()
|
||||
settings.keywords = localKeywords.value.trim() || DEFAULT_KEYWORDS
|
||||
ElMessage.success('设置已保存到本地')
|
||||
emit('update:modelValue', false)
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
@ -4,6 +4,10 @@ import type { AppSettings } from '../types'
|
||||
|
||||
const STORAGE_KEY = 'ai-trade-settings'
|
||||
|
||||
/** 额外关键字默认:规定 AI 角色与分析能力 */
|
||||
export const DEFAULT_KEYWORDS =
|
||||
'你是一名专业的国内期货交易员和分析员,精通机构操盘手法,能够根据持仓与交易数据分析当前走势。'
|
||||
|
||||
function load(): Partial<AppSettings> {
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(STORAGE_KEY) || '{}') as Partial<AppSettings>
|
||||
@ -15,7 +19,7 @@ function load(): Partial<AppSettings> {
|
||||
export const useSettingsStore = defineStore('settings', () => {
|
||||
const saved = load()
|
||||
const apiKey = ref(saved.apiKey || '')
|
||||
const keywords = ref(saved.keywords || '')
|
||||
const keywords = ref(saved.keywords || DEFAULT_KEYWORDS)
|
||||
|
||||
watch([apiKey, keywords], () => {
|
||||
const payload: AppSettings = {
|
||||
@ -23,7 +27,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
keywords: keywords.value,
|
||||
}
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(payload))
|
||||
})
|
||||
}, { immediate: true })
|
||||
|
||||
return { apiKey, keywords }
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user