Skip to content
This repository was archived by the owner on Oct 31, 2026. It is now read-only.

Commit 3406985

Browse files
authored
Merge pull request #11 from OxygenNine/ui-redesign
全站UI重构
2 parents 8ce6b72 + 5d875db commit 3406985

59 files changed

Lines changed: 3709 additions & 2192 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.env.example‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ SMTP_PASS=
1717

1818
WIKIDOT_BOT_USER=
1919
WIKIDOT_BOT_PASS=
20+
21+
# 开发环境身份切换开关(/api/dev/login)
22+
# 该接口能直接签发任意角色的 JWT,默认关闭。
23+
# 本地调试时设为 1,并先执行 node scripts/dev-seed.js 造账号。
24+
# 生产环境即使误设也不会生效(NODE_ENV=production 时无条件 404)。
25+
ENABLE_DEV_LOGIN=
26+
27+
# dev-seed.js 写入的测试账号口令(可选,未设置时用内置默认值)
28+
DEV_SEED_PASSWORD=

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ WikitDB-Server/
198198
- **白然** — WikitDB LOGO 设计师
199199
- **Kakushi** - Wikit创始人,Wikit API运维
200200
- **UMOU** - 贡献者
201+
- **OxygenNine** - ui-redesign
201202
- 每一位为 Wikidot 社区贡献原创内容的创作者
202203

203204
## 许可证

‎components/AuthorActivityChart.js‎

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@ import React, { useEffect, useRef, useState } from 'react';
22
// 核心修复:直接使用 auto 全自动注册,彻底解决漏引组件导致的致命闪退
33
import Chart from 'chart.js/auto';
44

5+
const isDark = () => typeof document !== 'undefined' && document.documentElement.classList.contains('dark');
6+
7+
// canvas 无法读取 CSS 变量,按当前主题返回具体色值
8+
const getChartColors = () => {
9+
if (isDark()) {
10+
return {
11+
bar: 'rgba(139, 92, 246, 0.85)',
12+
barBorder: 'rgb(139, 92, 246)',
13+
tooltipBg: 'rgba(24, 24, 27, 0.96)',
14+
tooltipTitle: '#f4f4f5',
15+
tooltipBody: '#a1a1aa',
16+
tooltipBorder: 'rgba(63, 63, 70, 1)',
17+
grid: 'rgba(255, 255, 255, 0.05)',
18+
ticks: '#a1a1aa',
19+
};
20+
}
21+
return {
22+
bar: 'rgba(139, 92, 246, 0.85)',
23+
barBorder: 'rgb(139, 92, 246)',
24+
tooltipBg: 'rgba(255, 255, 255, 0.96)',
25+
tooltipTitle: '#18181b',
26+
tooltipBody: '#52525b',
27+
tooltipBorder: 'rgba(228, 228, 231, 1)',
28+
grid: 'rgba(0, 0, 0, 0.06)',
29+
ticks: '#52525b',
30+
};
31+
};
32+
533
export default function AuthorActivityChart({ data = [] }) {
634
const canvasRef = useRef(null);
735
const chartInstance = useRef(null);
@@ -55,6 +83,8 @@ export default function AuthorActivityChart({ data = [] }) {
5583

5684
const ctx = canvasRef.current.getContext('2d');
5785

86+
const colors = getChartColors();
87+
5888
chartInstance.current = new Chart(ctx, {
5989
type: 'bar',
6090
data: {
@@ -63,8 +93,8 @@ export default function AuthorActivityChart({ data = [] }) {
6393
{
6494
label: '发布页面数',
6595
data: pagesData,
66-
backgroundColor: 'rgba(99, 102, 241, 0.85)',
67-
borderColor: 'rgb(99, 102, 241)',
96+
backgroundColor: colors.bar,
97+
borderColor: colors.barBorder,
6898
borderWidth: 1,
6999
barPercentage: 0.9,
70100
categoryPercentage: 1.0,
@@ -77,10 +107,10 @@ export default function AuthorActivityChart({ data = [] }) {
77107
plugins: {
78108
legend: { display: false },
79109
tooltip: {
80-
backgroundColor: 'rgba(23,23,23,0.96)',
81-
titleColor: '#fff',
82-
bodyColor: 'rgb(200,200,200)',
83-
borderColor: 'rgba(255,255,255,0.1)',
110+
backgroundColor: colors.tooltipBg,
111+
titleColor: colors.tooltipTitle,
112+
bodyColor: colors.tooltipBody,
113+
borderColor: colors.tooltipBorder,
84114
borderWidth: 1,
85115
callbacks: {
86116
label: function(context) {
@@ -98,16 +128,38 @@ export default function AuthorActivityChart({ data = [] }) {
98128
scales: {
99129
x: {
100130
grid: { display: false },
101-
ticks: { color: 'rgb(110, 118, 129)', maxRotation: 45 }
131+
ticks: { color: colors.ticks, maxRotation: 45 }
102132
},
103133
y: {
104134
beginAtZero: true,
105-
grid: { color: 'rgba(255, 255, 255, 0.05)' },
106-
ticks: { color: 'rgb(110, 118, 129)', stepSize: 1 }
135+
grid: { color: colors.grid },
136+
ticks: { color: colors.ticks, stepSize: 1 }
107137
}
108138
}
109139
}
110140
});
141+
142+
// 亮暗主题切换时重设 canvas 配色(canvas 不支持 CSS 变量,需 JS 侧感知)
143+
const applyThemeColors = () => {
144+
const chart = chartInstance.current;
145+
if (!chart) return;
146+
const c = getChartColors();
147+
chart.data.datasets[0].backgroundColor = c.bar;
148+
chart.data.datasets[0].borderColor = c.barBorder;
149+
chart.options.plugins.tooltip.backgroundColor = c.tooltipBg;
150+
chart.options.plugins.tooltip.titleColor = c.tooltipTitle;
151+
chart.options.plugins.tooltip.bodyColor = c.tooltipBody;
152+
chart.options.plugins.tooltip.borderColor = c.tooltipBorder;
153+
chart.options.scales.x.ticks.color = c.ticks;
154+
chart.options.scales.y.ticks.color = c.ticks;
155+
chart.options.scales.y.grid.color = c.grid;
156+
chart.update('none');
157+
};
158+
159+
const themeObserver = new MutationObserver(applyThemeColors);
160+
themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
161+
162+
return () => themeObserver.disconnect();
111163
} catch (err) {
112164
console.error("图表引擎渲染异常:", err);
113165
setChartError(err.message);
@@ -118,7 +170,7 @@ export default function AuthorActivityChart({ data = [] }) {
118170
return (
119171
<div className="w-full h-full relative min-h-[260px]">
120172
{chartError && (
121-
<div className="absolute inset-0 flex items-center justify-center text-sm text-red-400 bg-gray-900/50 rounded-lg">
173+
<div className="absolute inset-0 flex items-center justify-center text-sm text-red-400 bg-sunken rounded-lg">
122174
图表渲染失败: {chartError}
123175
</div>
124176
)}

‎components/ErrorBoundary.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ export default class ErrorBoundary extends React.Component {
2121
if (this.state.hasError) {
2222
return (
2323
<div className="min-h-[60vh] flex items-center justify-center p-6">
24-
<div className="text-center max-w-md bg-gray-800/50 rounded-2xl border border-red-500/30 p-8">
24+
<div className="text-center max-w-md bg-panel rounded-2xl border border-red-500/30 p-8">
2525
<i className="fa-solid fa-triangle-exclamation text-red-500 text-4xl mb-4"></i>
26-
<h2 className="text-xl font-bold text-white mb-2">页面渲染出现异常</h2>
27-
<p className="text-gray-400 text-sm mb-4 break-all">{this.state.message}</p>
26+
<h2 className="text-xl font-bold text-fg mb-2">页面渲染出现异常</h2>
27+
<p className="text-fg-3 text-sm mb-4 break-all">{this.state.message}</p>
2828
<button
2929
type="button"
3030
onClick={() => window.location.reload()}
31-
className="px-5 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition-colors text-sm font-medium"
31+
className="px-5 py-2 bg-accent-solid text-accent-fg rounded-lg hover:bg-accent-solid-hover transition-colors text-sm font-medium"
3232
>
3333
<i className="fa-solid fa-rotate mr-1.5"></i>刷新页面
3434
</button>

‎components/Footer.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const Footer = () => {
99

1010
return (
1111
<>
12-
<footer className="relative bg-gray-800/50 py-8 text-sm font-medium text-gray-300 text-center">
12+
<footer className="relative bg-sunken border-t border-line py-8 text-sm font-medium text-fg-3 text-center">
1313
{`© ${copyrightDate} - `}{config.SITE_AUTHOR}
1414
</footer>
1515
</>

0 commit comments

Comments
 (0)