1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| import { defineStore } from "pinia";
|
| export const useCurrencyStore = defineStore("currency", {
| // state 持久化,存储在了storage里面
| persist: true,
| state: () => {
| return {
| etfCurrency: [], //币种
| usStocksCurrency: [],
| coinCurrency: [],
| forexCurrency: [],
| cnStocksCurrency: [],
| hkStocksCurrency: [],
| twStocksCurrency: [],
| };
| },
|
| actions: {
| updateCurrency(val, type) {
| // type 是自定义的
| switch (type) {
| case "etf":
| this.etfCurrency = val;
| break;
| case "usStocks":
| this.usStocksCurrency = val;
| break;
| case "twStocks":
| this.twStocksCurrency = val;
| break;
| case "coin":
| this.coinCurrency = val;
| break;
| case "hkStocks":
| this.hkStocksCurrency = val;
| break;
| case "cnStocks":
| this.cnStocksCurrency = val;
| break;
| default:
| this.forexCurrency = val;
| }
| },
| },
| });
|
|