-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_theme.sh
More file actions
executable file
·206 lines (195 loc) · 13.6 KB
/
update_theme.sh
File metadata and controls
executable file
·206 lines (195 loc) · 13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/bash
# 批量更新 docs 页面,添加主题切换功能
DIR="/home/lchch/Desktop/walminer_web/docs"
# docs 页面通用的 CSS 样式(添加到 <style> 标签内)
CSS_VARS='
:root {
--bg-primary: #0a0a0a;
--bg-secondary: rgba(20, 20, 20, 0.9);
--bg-sidebar: rgba(10, 10, 10, 0.5);
--bg-card: rgba(255, 255, 255, 0.03);
--bg-code: #1a1a1a;
--bg-output: #0d0d0d;
--border-color: rgba(255, 255, 255, 0.08);
--border-light: rgba(255, 255, 255, 0.1);
--text-primary: #e4e4e7;
--text-secondary: #a1a1aa;
--text-muted: #71717a;
--text-title: #f4f4f5;
--text-gradient-start: #fafafa;
--text-gradient-end: #a1a1aa;
--grid-opacity: 0.08;
}
body.light-mode {
--bg-primary: #ffffff;
--bg-secondary: rgba(255, 255, 255, 0.95);
--bg-sidebar: rgba(245, 245, 245, 0.8);
--bg-card: rgba(0, 0, 0, 0.02);
--bg-code: #f5f5f5;
--bg-output: #fafafa;
--border-color: rgba(0, 0, 0, 0.08);
--border-light: rgba(0, 0, 0, 0.1);
--text-primary: #18181b;
--text-secondary: #52525b;
--text-muted: #71717a;
--text-title: #27272a;
--text-gradient-start: #18181b;
--text-gradient-end: #52525b;
--grid-opacity: 0.04;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, '\''Segoe UI'\'', '\''PingFang SC'\'', sans-serif; background: var(--bg-primary); color: var(--text-primary); line-height: 1.7; transition: background 0.3s, color 0.3s; }
.grid-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-image: linear-gradient(rgba(120, 119, 198, var(--grid-opacity)) 1px, transparent 1px), linear-gradient(90deg, rgba(120, 119, 198, var(--grid-opacity)) 1px, transparent 1px); background-size: 50px 50px; pointer-events: none; z-index: 0; }
nav { position: fixed; top: 0; left: 0; right: 0; z-index: 100; padding: 20px 50px; display: flex; justify-content: space-between; align-items: center; background: var(--bg-secondary); backdrop-filter: blur(20px); border-bottom: 1px solid var(--border-light); transition: background 0.3s; }
.logo { font-size: 1.5rem; font-weight: 700; background: linear-gradient(135deg, #6366f1, #8b5cf6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; text-decoration: none; }
.nav-links { display: flex; gap: 30px; align-items: center; }
.nav-links a { color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; transition: color 0.3s; }
.nav-links a:hover { color: var(--text-primary); }
.theme-toggle { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-light); background: var(--bg-card); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; transition: all 0.3s; }
.theme-toggle:hover { background: rgba(99, 102, 241, 0.1); transform: scale(1.05); }
.layout { display: flex; position: relative; z-index: 10; margin-top: 80px; min-height: calc(100vh - 80px); }
.sidebar { width: 280px; position: fixed; left: 0; top: 80px; bottom: 0; background: var(--bg-sidebar); border-right: 1px solid var(--border-color); padding: 30px 20px; overflow-y: auto; transition: background 0.3s; }
.sidebar-title { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid var(--border-light); }
.sidebar-nav { list-style: none; }
.sidebar-nav li { margin-bottom: 5px; }
.sidebar-nav a { display: block; padding: 10px 15px; color: var(--text-secondary); text-decoration: none; border-radius: 8px; transition: all 0.3s; font-size: 0.95rem; }
.sidebar-nav a:hover { background: rgba(99, 102, 241, 0.1); color: var(--text-primary); }
.sidebar-nav a.active { background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2)); color: #a5b4fc; border-left: 3px solid #6366f1; }
.main-content { flex: 1; margin-left: 280px; padding: 40px 50px 80px; max-width: 900px; }
.breadcrumb { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 30px; }
.breadcrumb a { color: #818cf8; text-decoration: none; }
h1 { font-size: 2.5rem; font-weight: 700; margin-bottom: 20px; background: linear-gradient(135deg, var(--text-gradient-start), var(--text-gradient-end)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.description { color: var(--text-secondary); font-size: 1.1rem; margin-bottom: 50px; line-height: 1.8; }
.section { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px; padding: 35px; margin-bottom: 30px; }
.section h2 { font-size: 1.5rem; color: var(--text-title); margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid var(--border-light); }
.section h3 { font-size: 1.1rem; color: var(--text-primary); margin: 25px 0 15px; }
.section p, .section li { color: var(--text-secondary); margin-bottom: 10px; }
.section ul, .section ol { margin-left: 20px; margin-bottom: 20px; }
.section code { background: rgba(99, 102, 241, 0.1); padding: 3px 8px; border-radius: 4px; font-family: '\''SF Mono'\'', Monaco, monospace; font-size: 0.9rem; color: #a5b4fc; }
.code-block { background: var(--bg-code); border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; margin: 20px 0; }
.code-header { display: flex; gap: 8px; padding: 12px 15px; background: rgba(255, 255, 255, 0.03); border-bottom: 1px solid var(--border-color); }
.code-dot { width: 12px; height: 12px; border-radius: 50%; }
.code-dot.red { background: #ef4444; } .code-dot.yellow { background: #f59e0b; } .code-dot.green { background: #10b981; }
.code-body { padding: 20px; font-family: '\''SF Mono'\'', Monaco, monospace; font-size: 0.85rem; line-height: 1.6; overflow-x: auto; color: var(--text-primary); }
.code-keyword { color: #c084fc; } .code-string { color: #10b981; } .code-comment { color: #52525b; } .code-param { color: #60a5fa; }
.param-table { width: 100%; border-collapse: collapse; margin: 20px 0; }
.param-table th { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; padding: 12px; text-align: left; font-weight: 600; border-bottom: 1px solid var(--border-light); }
.param-table td { padding: 12px; border-bottom: 1px solid var(--border-color); color: var(--text-secondary); }
.note { background: rgba(245, 158, 11, 0.1); border-left: 3px solid #f59e0b; padding: 15px 20px; margin: 20px 0; border-radius: 0 8px 8px 0; }
.note p { color: #fbbf24; font-size: 0.95rem; margin: 0; }
.output-box { background: var(--bg-output); border: 1px solid var(--border-light); border-radius: 12px; padding: 20px; margin: 15px 0; font-family: '\''SF Mono'\'', monospace; font-size: 0.85rem; color: var(--text-secondary); }
.feature-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin: 20px 0; }
.feature-item { background: rgba(99, 102, 241, 0.1); border: 1px solid rgba(99, 102, 241, 0.2); border-radius: 10px; padding: 15px; text-align: center; }
.feature-item h4 { color: #a5b4fc; font-size: 1rem; margin-bottom: 5px; }
.feature-item p { color: #71717a; font-size: 0.85rem; margin: 0; }
footer { border-top: 1px solid var(--border-light); padding: 30px 20px; text-align: center; color: var(--text-muted); margin-left: 280px; }
@media (max-width: 1024px) { .sidebar { display: none; } .main-content { margin-left: 0; padding: 40px 30px 80px; } footer { margin-left: 0; } }
@media (max-width: 768px) { nav { padding: 15px 20px; } .main-content { padding: 30px 20px 60px; } h1 { font-size: 1.8rem; } .section { padding: 25px; } }'
# JavaScript 代码
JS_CODE=' <script>
(function() {
const themeToggle = document.getElementById('\''themeToggle'\'');
const prefersDarkScheme = window.matchMedia('\'(prefers-color-scheme: dark)'\'');
const currentTheme = localStorage.getItem('\''theme'\'');
let isDark = currentTheme === '\''dark'\'' || (!currentTheme && prefersDarkScheme.matches);
function applyTheme(dark) {
if (dark) {
document.body.classList.remove('\''light-mode'\'');
themeToggle.textContent = '\''🌙'\'';
localStorage.setItem('\''theme'\'', '\''dark'\'');
} else {
document.body.classList.add('\''light-mode'\'');
themeToggle.textContent = '\''☀️'\'';
localStorage.setItem('\''theme'\'', '\''light'\'');
}
}
applyTheme(isDark);
themeToggle.addEventListener('\''click'\'', function() { isDark = !isDark; applyTheme(isDark); });
})();
</script>'
for file in builtdic.html pgto.html search.html blockrecovery.html installation.html; do
echo "Processing $file..."
# 1. 更新 CSS
sed -i 's/background: #0a0a0a;/background: var(--bg-primary);/' "$file"
sed -i 's/color: #e4e4e7;/color: var(--text-primary);/' "$file"
sed -i 's/background: rgba(10, 10, 10, 0.9);/background: var(--bg-secondary);/' "$file"
sed -i 's/color: #a1a1aa;/color: var(--text-secondary);/' "$file"
sed -i 's/color: #71717a;/color: var(--text-muted);/' "$file"
sed -i 's/color: #f4f4f5;/color: var(--text-title);/' "$file"
sed -i 's/background: rgba(255, 255, 255, 0.03);/background: var(--bg-card);/' "$file"
sed -i 's/border: 1px solid rgba(255, 255, 255, 0.08);/border: 1px solid var(--border-color);/' "$file"
sed -i 's/border: 1px solid rgba(255,255,255,0.1);/border: 1px solid var(--border-light);/g' "$file"
sed -i 's/border-bottom: 1px solid rgba(255, 255, 255, 0.1);/border-bottom: 1px solid var(--border-light);/g' "$file"
sed -i 's/background: rgba(10, 10, 10, 0.5);/background: var(--bg-sidebar);/' "$file"
sed -i 's/background: #1a1a1a;/background: var(--bg-code);/g' "$file"
sed -i 's/background: #0d0d0d;/background: var(--bg-output);/g' "$file"
# 2. 添加主题切换按钮到导航栏
sed -i 's|<a href="../faq.html">常见问题</a>|<a href="../faq.html">常见问题</a>\n <button class="theme-toggle" id="themeToggle" title="切换主题">🌙</button>|' "$file"
# 3. 添加 CSS 变量和主题切换样式
sed -i '/<style>/a\
:root {\
--bg-primary: #0a0a0a;\
--bg-secondary: rgba(20, 20, 20, 0.9);\
--bg-sidebar: rgba(10, 10, 10, 0.5);\
--bg-card: rgba(255, 255, 255, 0.03);\
--bg-code: #1a1a1a;\
--bg-output: #0d0d0d;\
--border-color: rgba(255, 255, 255, 0.08);\
--border-light: rgba(255, 255, 255, 0.1);\
--text-primary: #e4e4e7;\
--text-secondary: #a1a1aa;\
--text-muted: #71717a;\
--text-title: #f4f4f5;\
--text-gradient-start: #fafafa;\
--text-gradient-end: #a1a1aa;\
--grid-opacity: 0.08;\
}\
body.light-mode {\
--bg-primary: #ffffff;\
--bg-secondary: rgba(255, 255, 255, 0.95);\
--bg-sidebar: rgba(245, 245, 245, 0.8);\
--bg-card: rgba(0, 0, 0, 0.02);\
--bg-code: #f5f5f5;\
--bg-output: #fafafa;\
--border-color: rgba(0, 0, 0, 0.08);\
--border-light: rgba(0, 0, 0, 0.1);\
--text-primary: #18181b;\
--text-secondary: #52525b;\
--text-muted: #71717a;\
--text-title: #27272a;\
--text-gradient-start: #18181b;\
--text-gradient-end: #52525b;\
--grid-opacity: 0.04;\
}\
body { transition: background 0.3s, color 0.3s; }\
nav, .sidebar { transition: background 0.3s; }\
.nav-links { display: flex; gap: 30px; align-items: center; }\
.theme-toggle { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-light); background: var(--bg-card); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; transition: all 0.3s; }\
.theme-toggle:hover { background: rgba(99, 102, 241, 0.1); transform: scale(1.05); }' "$file"
# 4. 添加 JavaScript
sed -i '/<\/footer>/a\
<script>\
(function() {\
const themeToggle = document.getElementById('"'"'themeToggle'"'"');\
const prefersDarkScheme = window.matchMedia('"'"'(prefers-color-scheme: dark)'"'"');\
const currentTheme = localStorage.getItem('"'"'theme'"'"');\
let isDark = currentTheme === '"'"'dark'"'"' || (!currentTheme && prefersDarkScheme.matches);\
function applyTheme(dark) {\
if (dark) {\
document.body.classList.remove('"'"'light-mode'"'"');\
themeToggle.textContent = '"'"'🌙'"'"';\
localStorage.setItem('"'"'theme'"'"', '"'"'dark'"'"');\
} else {\
document.body.classList.add('"'"'light-mode'"'"');\
themeToggle.textContent = '"'"'☀️'"'"';\
localStorage.setItem('"'"'theme'"'"', '"'"'light'"'"');\
}\
}\
applyTheme(isDark);\
themeToggle.addEventListener('"'"'click'"'"', function() { isDark = !isDark; applyTheme(isDark); });\
})();\
<\/script>' "$file"
echo "✓ $file updated"
done
echo ""
echo "All docs pages have been updated with theme toggle!"