|
|
/** @format */
import { defineStore } from "pinia";import { ref } from "vue";// 定义 Store
export const useMarketSituationStore = defineStore( "marketSituation", () => { const cardData = ref([ { market: "usa", stockName: "道琼斯", stockCode: "noCode", currentPrice: "45757.90", changeAmount: "-125.22", changePercent: "-0.27%", isRising: false, }, { market: "usa", stockName: "纳斯达克", stockCode: "noCode", currentPrice: "22333.96", changeAmount: "+125.22", changePercent: "+0.47%", isRising: true, }, { market: "usa", stockName: "标普500", stockCode: "noCode", currentPrice: "6606.08", changeAmount: "+125.22", changePercent: "+0.27%", isRising: true, }, { market: "cn", stockName: "上证指数", stockCode: "noCode", currentPrice: "3333.96", changeAmount: "+125.22", changePercent: "+0.27%", isRising: true, }, { market: "cn", stockName: "科创50", stockCode: "noCode", currentPrice: "757.90", changeAmount: "-25.22", changePercent: "-0.27%", isRising: false, }, ]);
// 记得 return
return { cardData }; }, // TODO: 持久化
{ // 网页端持久化
// persist: true,
// 小程序端持久化
persist: { storage: { getItem(key) { return uni.getStorageSync(key); }, setItem(key, value) { uni.setStorageSync(key, value); }, }, }, });
|