From dce10d37ad35efe8ed1d39d6e5fcf7e4904381df Mon Sep 17 00:00:00 2001
From: 李凌 <344137771@qq.com>
Date: Fri, 12 Jun 2026 13:19:53 +0800
Subject: [PATCH] 1
---
src/store/modules/home.store.js | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/store/modules/home.store.js b/src/store/modules/home.store.js
index f6626d3..29c05aa 100644
--- a/src/store/modules/home.store.js
+++ b/src/store/modules/home.store.js
@@ -18,15 +18,16 @@
},
mutations: {
[SET_COIN_LIST](state, list) {
- state.coinList = list;
+ state.coinList = list && Array.isArray(list) ? list : [];
},
[SET_CURRENCY](state, currency) {
state.currency = currency;
},
- [SET_COIN_SYMBOL_ARR](state, list = []) {
+ [SET_COIN_SYMBOL_ARR](state, list) {
+ const safeList = list && Array.isArray(list) ? list : []
const arr = []
const hots = []
- list.map(item => {
+ safeList.map(item => {
arr.push(item.symbol)
if (item.isTop === '1') { // 热门
hots.push(item.symbol)
@@ -38,11 +39,15 @@
},
actions: {
async [SET_COIN_LIST]({ commit }, data) { // 获取配置的币种
- const list = await _getCoins({ type: data }).catch(err => { Promise.reject(err) })
- commit(SET_COIN_SYMBOL_ARR, list) // 原数据
- commit(SET_COIN_LIST, list) // 拆分的单个数据
- Promise.resolve(list)
-
+ let list = []
+ try {
+ const res = await _getCoins({ type: data })
+ list = res && Array.isArray(res) ? res : []
+ } catch (err) {
+ list = []
+ }
+ commit(SET_COIN_SYMBOL_ARR, list)
+ commit(SET_COIN_LIST, list)
},
async [SET_CURRENCY]({ commit }) { // 设置汇率
const currency = await _getExchangeRate().catch(err => Promise.reject(err))
--
Gitblit v1.9.3