|
|
|
@ -249,6 +249,7 @@ async function toggleWatch(symbol, name, event) {
|
|
|
|
const data = await response.json();
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
|
|
if (data.success) {
|
|
|
|
watchedSymbols = watchedSymbols.filter(s => s !== symbol);
|
|
|
|
watchedSymbols = watchedSymbols.filter(s => s !== symbol);
|
|
|
|
|
|
|
|
showToast('success', '已取消自选', `${symbol} 已从自选列表移除`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
const response = await fetch(`${API_BASE}/watched`, {
|
|
|
|
const response = await fetch(`${API_BASE}/watched`, {
|
|
|
|
@ -259,24 +260,28 @@ async function toggleWatch(symbol, name, event) {
|
|
|
|
const data = await response.json();
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
|
|
if (data.success) {
|
|
|
|
watchedSymbols.push(symbol);
|
|
|
|
watchedSymbols.push(symbol);
|
|
|
|
|
|
|
|
showToast('success', '已添加自选', `${name}(${symbol}) 已添加到自选列表`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.getElementById('count-watched').textContent = watchedSymbols.length;
|
|
|
|
document.getElementById('count-watched').textContent = watchedSymbols.length;
|
|
|
|
|
|
|
|
|
|
|
|
const activeTab = document.querySelector('.filter-tab.active');
|
|
|
|
// 重新渲染当前视图
|
|
|
|
if (activeTab && activeTab.dataset.category === 'watched') {
|
|
|
|
const activePill = document.querySelector('.pill.active');
|
|
|
|
|
|
|
|
const category = activePill ? activePill.dataset.category : 'all';
|
|
|
|
|
|
|
|
if (category === 'watched') {
|
|
|
|
filterByCategory('watched');
|
|
|
|
filterByCategory('watched');
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
renderFuturesGrid(getCurrentFilteredData());
|
|
|
|
renderFuturesGrid(getCurrentFilteredData());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.error('切换自选失败:', error);
|
|
|
|
console.error('切换自选失败:', error);
|
|
|
|
|
|
|
|
showToast('error', '操作失败', '网络错误,请稍后重试');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getCurrentFilteredData() {
|
|
|
|
function getCurrentFilteredData() {
|
|
|
|
const activeTab = document.querySelector('.filter-tab.active');
|
|
|
|
const activePill = document.querySelector('.pill.active');
|
|
|
|
const category = activeTab ? activeTab.dataset.category : 'all';
|
|
|
|
const category = activePill ? activePill.dataset.category : 'all';
|
|
|
|
return filterDataByCategory(allFuturesData, category);
|
|
|
|
return filterDataByCategory(allFuturesData, category);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -500,6 +505,10 @@ function renderFuturesGrid(data) {
|
|
|
|
const resistance = item.resistance ? formatNumber(item.resistance) : '--';
|
|
|
|
const resistance = item.resistance ? formatNumber(item.resistance) : '--';
|
|
|
|
const support = item.support ? formatNumber(item.support) : '--';
|
|
|
|
const support = item.support ? formatNumber(item.support) : '--';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isWatched = watchedSymbols.includes(item.symbol);
|
|
|
|
|
|
|
|
const watchIcon = isWatched ? 'fa-star' : 'fa-star-o';
|
|
|
|
|
|
|
|
const watchClass = isWatched ? 'active' : '';
|
|
|
|
|
|
|
|
|
|
|
|
return `
|
|
|
|
return `
|
|
|
|
<div class="card" onclick="showDetailView('${item.symbol}')">
|
|
|
|
<div class="card" onclick="showDetailView('${item.symbol}')">
|
|
|
|
<div class="card-header">
|
|
|
|
<div class="card-header">
|
|
|
|
@ -611,8 +620,8 @@ function filterByTrend(trend) {
|
|
|
|
|
|
|
|
|
|
|
|
function filterFuturesList(keyword) {
|
|
|
|
function filterFuturesList(keyword) {
|
|
|
|
keyword = keyword.toLowerCase();
|
|
|
|
keyword = keyword.toLowerCase();
|
|
|
|
const activeTab = document.querySelector('.filter-tab.active');
|
|
|
|
const activePill = document.querySelector('.pill.active');
|
|
|
|
const category = activeTab ? activeTab.dataset.category : 'all';
|
|
|
|
const category = activePill ? activePill.dataset.category : 'all';
|
|
|
|
|
|
|
|
|
|
|
|
let filtered = filterDataByCategory(allFuturesData, category);
|
|
|
|
let filtered = filterDataByCategory(allFuturesData, category);
|
|
|
|
|
|
|
|
|
|
|
|
|