feat(frontend): 添加 AI 分析开关功能

- 在全局配置中获取 openAiEnable 状态
- 根据 openAiEnable 状态控制 AI 分析按钮的显示- 优化了组件的初始化逻辑,确保配置信息及时加载
This commit is contained in:
spark 2025-01-22 12:21:43 +08:00
parent dadfe1cf54
commit 3f024faf82

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import {computed, onBeforeMount, onBeforeUnmount, onMounted, reactive, ref} from 'vue' import {computed, onBeforeMount, onBeforeUnmount, onMounted, reactive, ref} from 'vue'
import { import {
Follow, Follow, GetConfig,
GetFollowList, GetFollowList,
GetStockList, GetStockList,
Greet, NewChat, NewChatStream, Greet, NewChat, NewChatStream,
@ -50,6 +50,7 @@ const data = reactive({
resultText: "Please enter your name below 👇", resultText: "Please enter your name below 👇",
fullscreen: false, fullscreen: false,
airesult: "", airesult: "",
openAiEnable: false,
}) })
const sortedResults = computed(() => { const sortedResults = computed(() => {
@ -82,6 +83,11 @@ onBeforeMount(()=>{
monitor() monitor()
message.destroyAll message.destroyAll
}) })
GetConfig().then(result => {
if (result.openAiEnable) {
data.openAiEnable = true
}
})
}) })
onMounted(() => { onMounted(() => {
@ -437,7 +443,7 @@ function getHeight() {
<n-button size="tiny" secondary type="primary" @click="removeMonitor(result['股票代码'],result['股票名称'],result.key)"> <n-button size="tiny" secondary type="primary" @click="removeMonitor(result['股票代码'],result['股票名称'],result.key)">
取消关注 取消关注
</n-button>&nbsp; </n-button>&nbsp;
<n-button size="tiny" secondary type="warning" @click="aiCheckStock(result['股票名称'])"> AI分析 </n-button> <n-button size="tiny" v-if="data.openAiEnable" secondary type="warning" @click="aiCheckStock(result['股票名称'])"> AI分析 </n-button>
</template> </template>
<template #footer> <template #footer>