This commit is contained in:
Julian Freeman
2025-12-21 21:53:29 -04:00
parent 8067b5f19d
commit 45de3d9b3f

View File

@@ -2,7 +2,7 @@
<html lang="zh">
<head>
<base target="_top">
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<style>
/* --- 基础变量 --- */
:root {
@@ -21,7 +21,8 @@
font-size: 16px;
}
.dark-mode {
/* --- 暗黑模式变量 --- */
body.dark-mode {
--bg-color: #0f172a;
--card-bg: #1e293b;
--text-main: #f1f5f9;
@@ -109,6 +110,8 @@
padding: 0.5rem 0.75rem;
border-radius: 0.5rem;
cursor: pointer;
font-size: 1.2rem;
line-height: 1;
}
/* --- 表格样式 --- */
@@ -123,7 +126,7 @@
table {
width: 100%;
border-collapse: collapse;
table-layout: fixed; /* 固定布局确保宽度可控 */
table-layout: fixed;
}
th {
@@ -145,7 +148,6 @@
tr:hover { background: rgba(37, 99, 235, 0.02); }
/* 项目信息列 */
.item-cell { display: flex; align-items: center; gap: 1rem; }
.icon-box {
@@ -184,7 +186,6 @@
color: var(--text-muted);
}
/* 标签与文本 */
.type-label {
display: inline-block;
padding: 0.25rem 0.75rem;
@@ -196,7 +197,7 @@
}
.safety-text {
font-weight: 400; /* 取消加粗 */
font-weight: 400;
display: flex;
align-items: center;
gap: 0.4rem;
@@ -212,7 +213,7 @@
}
.date-val {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
font-family: monospace;
font-size: 0.85rem;
color: var(--text-muted);
}
@@ -234,13 +235,12 @@
color: white;
}
/* 移动端隐藏部分列 */
@media (max-width: 1024px) {
th:nth-child(3), td:nth-child(3), th:nth-child(5), td:nth-child(5) { display: none; }
}
</style>
</head>
<body :class="{ 'dark-mode': isDark }">
<body>
<div id="app" v-cloak class="container">
@@ -311,6 +311,9 @@
</tr>
</tbody>
</table>
<div v-if="loading" style="padding: 5rem; text-align: center; color: var(--text-muted);">
{{ ui[lang].syncing }}
</div>
</div>
</div>
@@ -327,9 +330,9 @@ createApp({
const defaultIcon = 'https://cdn-icons-png.flaticon.com/512/684/684831.png';
const ui = {
cn: { subtitle: '全球数据资源索引', searchPlaceholder: '搜索...', colName: '项目描述', colType: '类型', colPlat: '平台', colSafety: '安全性', colDate: '最近更新', colAction: '操作', linkBtn: '访问官网' },
en: { subtitle: 'GLOBAL INDEX', searchPlaceholder: 'Search...', colName: 'Description', colType: 'Type', colPlat: 'Platform', colSafety: 'Security', colDate: 'Updated', colAction: 'Action', linkBtn: 'VISIT' },
es: { subtitle: 'ÍNDICE GLOBAL', searchPlaceholder: 'Buscar...', colName: 'Descripción', colType: 'Tipo', colPlat: 'Plataforma', colSafety: 'Seguridad', colDate: 'Fecha', colAction: 'Acción', linkBtn: 'VISITAR' }
cn: { subtitle: '全球数据资源索引', searchPlaceholder: '搜索...', colName: '项目描述', colType: '类型', colPlat: '平台', colSafety: '安全性', colDate: '最近更新', colAction: '操作', linkBtn: '访问官网', syncing: '同步云端数据中...' },
en: { subtitle: 'GLOBAL INDEX', searchPlaceholder: 'Search...', colName: 'Description', colType: 'Type', colPlat: 'Platform', colSafety: 'Security', colDate: 'Updated', colAction: 'Action', linkBtn: 'VISIT', syncing: 'Syncing...' },
es: { subtitle: 'ÍNDICE GLOBAL', searchPlaceholder: 'Buscar...', colName: 'Descripción', colType: 'Tipo', colPlat: 'Plataforma', colSafety: 'Seguridad', colDate: 'Fecha', colAction: 'Acción', linkBtn: 'VISITAR', syncing: 'Sincronizando...' }
};
const staticMap = {
@@ -398,7 +401,15 @@ createApp({
return d.toISOString().split('T')[0].replace(/-/g, '/');
};
const toggleDark = () => isDark.value = !isDark.value;
// 修复切换逻辑:通过 JavaScript 直接操作 body 类名
const toggleDark = () => {
isDark.value = !isDark.value;
if (isDark.value) {
document.body.classList.add('dark-mode');
} else {
document.body.classList.remove('dark-mode');
}
};
onMounted(fetchData);