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