diff --git a/src/main.js b/src/main.js index bb979a6..e56ea96 100644 --- a/src/main.js +++ b/src/main.js @@ -6,12 +6,14 @@ import 'element-plus/dist/index.css' import * as ElementPlusIconsVue from '@element-plus/icons-vue' // import 'reset-css'; import { createPinia } from 'pinia' +import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' import { useAppBridge } from './assets/js/useAppBridge.js' const { packageFun, fullClose } = useAppBridge() const app = createApp(App) const pinia = createPinia() +pinia.use(piniaPluginPersistedstate) for (const [key, component] of Object.entries(ElementPlusIconsVue)) { app.component(key, component) } diff --git a/src/store/emotion.ts b/src/store/emotion.ts index 117b3b7..f56f3b5 100644 --- a/src/store/emotion.ts +++ b/src/store/emotion.ts @@ -4,7 +4,25 @@ import { defineStore } from 'pinia'; export const useEmotionStore = defineStore('emotion', { state: () => ({ history: [] as HistoryItem[], // 历史记录数组 + stockList: [] as StockData[], // 当前显示的股票列表 + activeStockIndex: 0, // 当前激活的股票索引 + maxStocks: 10, // 最大股票数量限制 }), + persist: { + key: 'emotion-store', + storage: localStorage, + paths: ['history', 'stockList', 'activeStockIndex'] + }, + getters: { + // 获取当前激活的股票 + activeStock: (state) => { + return state.stockList[state.activeStockIndex] || null; + }, + // 获取股票数量 + stockCount: (state) => state.stockList.length, + // 是否达到最大股票数量 + isMaxStocks: (state) => state.stockList.length >= state.maxStocks, + }, actions: { // 添加历史记录 addHistory(item: HistoryItem) { @@ -14,6 +32,79 @@ export const useEmotionStore = defineStore('emotion', { clearHistory() { this.history = []; }, + // 添加新股票 + addStock(stockData: StockData) { + // 检查是否已存在相同的股票 + const existingIndex = this.stockList.findIndex( + stock => stock.stockInfo.code === stockData.stockInfo.code && + stock.stockInfo.market === stockData.stockInfo.market + ); + + if (existingIndex !== -1) { + // 如果股票已存在,更新数据并切换到该股票 + this.stockList[existingIndex] = stockData; + this.activeStockIndex = existingIndex; + } else { + // 如果达到最大数量,移除最旧的股票 + if (this.stockList.length >= this.maxStocks) { + this.stockList.shift(); + if (this.activeStockIndex > 0) { + this.activeStockIndex--; + } + } + // 添加新股票并设为当前激活 + this.stockList.push(stockData); + this.activeStockIndex = this.stockList.length - 1; + } + + // 同时添加到历史记录 + this.addHistory({ + queryText: stockData.queryText, + stockInfo: stockData.stockInfo, + apiData: stockData.apiData, + timestamp: stockData.timestamp + }); + }, + // 切换股票 + switchStock(index: number) { + if (index >= 0 && index < this.stockList.length) { + this.activeStockIndex = index; + } + }, + // 移除股票 + removeStock(index: number) { + if (index >= 0 && index < this.stockList.length) { + this.stockList.splice(index, 1); + // 调整激活索引 + if (this.activeStockIndex >= this.stockList.length) { + this.activeStockIndex = Math.max(0, this.stockList.length - 1); + } else if (this.activeStockIndex > index) { + this.activeStockIndex--; + } + } + }, + // 更新股票数据 + updateStockData(index: number, apiData: any) { + if (index >= 0 && index < this.stockList.length) { + this.stockList[index].apiData = apiData; + this.stockList[index].timestamp = new Date().toISOString(); + } + }, + // 清空所有股票 + clearAllStocks() { + this.stockList = []; + this.activeStockIndex = 0; + }, + // 从历史记录恢复股票 + restoreFromHistory(historyItem: HistoryItem) { + const stockData: StockData = { + queryText: historyItem.queryText, + stockInfo: historyItem.stockInfo, + apiData: historyItem.apiData, + timestamp: historyItem.timestamp + }; + this.addStock(stockData); + }, }, }); @@ -27,4 +118,16 @@ interface HistoryItem { }; apiData: any; // 接口返回的原始数据(包含图表数据) timestamp: string; // 记录时间 +} + +// 定义股票数据的类型 +interface StockData { + queryText: string; // 用户输入的查询文本 + stockInfo: { + name: string; // 股票名称 + code: string; // 股票代码 + market: string; // 市场 + }; + apiData: any; // API返回的完整数据 + timestamp: string; // 数据获取时间 } \ No newline at end of file diff --git a/src/views/AiEmotion.vue b/src/views/AiEmotion.vue index de46a41..a19cf0e 100644 --- a/src/views/AiEmotion.vue +++ b/src/views/AiEmotion.vue @@ -2,25 +2,14 @@
情绪监控-金融宇宙的【量子检测网络】核心任务:构建全市场情绪引力场雷达
-情绪解码-主力思维的【神经破译矩阵】核心任务:解构资金行为的量子密码
-情绪推演-未来战争的【时空推演舱】核心任务:情绪推演
-情绪套利-财富裂变的【粒子对撞机】核心任务:将情绪差转化为a收益粒子流
-情绪监控-金融宇宙的【量子检测网络】核心任务:构建全市场情绪引力场雷达
+情绪解码-主力思维的【神经破译矩阵】核心任务:解构资金行为的量子密码
+情绪推演-未来战争的【时空推演舱】核心任务:情绪推演
+情绪套利-财富裂变的【粒子对撞机】核心任务:将情绪差转化为a收益粒子流
+