fix:修复添加自选股没反应
This commit is contained in:
@@ -188,6 +188,22 @@ export const accountHandlers = [
|
||||
|
||||
mockWatchlist.push(newItem);
|
||||
|
||||
// 同步添加到 mockRealtimeQuotes(导航栏自选股菜单使用此数组)
|
||||
mockRealtimeQuotes.push({
|
||||
stock_code: stock_code,
|
||||
stock_name: stock_name,
|
||||
current_price: null,
|
||||
change_percent: 0,
|
||||
change: 0,
|
||||
volume: 0,
|
||||
turnover: 0,
|
||||
high: 0,
|
||||
low: 0,
|
||||
open: 0,
|
||||
prev_close: 0,
|
||||
update_time: new Date().toTimeString().slice(0, 8)
|
||||
});
|
||||
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
message: '添加成功',
|
||||
@@ -210,9 +226,20 @@ export const accountHandlers = [
|
||||
const { id } = params;
|
||||
console.log('[Mock] 删除自选股:', id);
|
||||
|
||||
const index = mockWatchlist.findIndex(item => item.id === parseInt(id));
|
||||
// 支持按 stock_code 或 id 匹配删除
|
||||
const index = mockWatchlist.findIndex(item =>
|
||||
item.stock_code === id || item.id === parseInt(id)
|
||||
);
|
||||
|
||||
if (index !== -1) {
|
||||
const stockCode = mockWatchlist[index].stock_code;
|
||||
mockWatchlist.splice(index, 1);
|
||||
|
||||
// 同步从 mockRealtimeQuotes 移除
|
||||
const quotesIndex = mockRealtimeQuotes.findIndex(item => item.stock_code === stockCode);
|
||||
if (quotesIndex !== -1) {
|
||||
mockRealtimeQuotes.splice(quotesIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return HttpResponse.json({
|
||||
|
||||
Reference in New Issue
Block a user