You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.7 KiB

  1. /** @format */
  2. import { defineStore } from "pinia";
  3. import { ref } from "vue";
  4. // 定义 Store
  5. export const useMarketSituationStore = defineStore(
  6. "marketSituation",
  7. () => {
  8. const cardData = ref([
  9. {
  10. market: "usa",
  11. stockName: "道琼斯",
  12. stockCode: "noCode",
  13. currentPrice: "45757.90",
  14. changeAmount: "-125.22",
  15. changePercent: "-0.27%",
  16. isRising: false,
  17. },
  18. {
  19. market: "usa",
  20. stockName: "纳斯达克",
  21. stockCode: "noCode",
  22. currentPrice: "22333.96",
  23. changeAmount: "+125.22",
  24. changePercent: "+0.47%",
  25. isRising: true,
  26. },
  27. {
  28. market: "usa",
  29. stockName: "标普500",
  30. stockCode: "noCode",
  31. currentPrice: "6606.08",
  32. changeAmount: "+125.22",
  33. changePercent: "+0.27%",
  34. isRising: true,
  35. },
  36. {
  37. market: "cn",
  38. stockName: "上证指数",
  39. stockCode: "noCode",
  40. currentPrice: "3333.96",
  41. changeAmount: "+125.22",
  42. changePercent: "+0.27%",
  43. isRising: true,
  44. },
  45. {
  46. market: "cn",
  47. stockName: "科创50",
  48. stockCode: "noCode",
  49. currentPrice: "757.90",
  50. changeAmount: "-25.22",
  51. changePercent: "-0.27%",
  52. isRising: false,
  53. },
  54. ]);
  55. // 记得 return
  56. return {
  57. cardData
  58. };
  59. },
  60. // TODO: 持久化
  61. {
  62. // 网页端持久化
  63. // persist: true,
  64. // 小程序端持久化
  65. persist: {
  66. storage: {
  67. getItem(key) {
  68. return uni.getStorageSync(key);
  69. },
  70. setItem(key, value) {
  71. uni.setStorageSync(key, value);
  72. },
  73. },
  74. },
  75. }
  76. );