This commit is contained in:
2026-01-14 14:54:53 +08:00
parent 801a973801
commit 07bc8373cc
8 changed files with 26 additions and 14 deletions

View File

@@ -351,10 +351,13 @@
async getFavoriteData() {
this.userFavorites = [];
let item = await tradeApi.serverFavorite(this.token);
item.data[0].markets.map(v => {
this.userFavorites.push(v.symbol.toLowerCase());
});
return item.data;
if(item.data && item.data.length > 0 && item.data[0].markets) {
item.data[0].markets.map(v => {
this.userFavorites.push(v.symbol.toLowerCase());
});
return item.data;
}
return [];
},
_getDocuments() {
homeApi.getDoucments().then(res => {
@@ -435,9 +438,18 @@
this.$socket.subscribe(this.subscribePath(market), 'market-area');
this.$socket.on('market-area', (data) => {
// console.log("市场订阅",data.markets)
if (data.markets) {
let i = this.activeIndex;
this.marketList[i].markets = data.markets;
try {
let markets = data.markets;
// 如果是字符串,尝试解析
if(typeof markets === 'string') {
markets = JSON.parse(markets);
}
if (markets && Array.isArray(markets)) {
let i = this.activeIndex;
this.marketList[i].markets = markets;
}
} catch(e) {
console.error('解析市场数据失败:', e, data);
}
});
},