Upload 3 files
Browse files- static/app.js +11 -3
- static/index.html +1 -1
- static/style.css +4 -4
static/app.js
CHANGED
|
@@ -34,6 +34,12 @@ const STATE = {
|
|
| 34 |
|
| 35 |
const DOM = {};
|
| 36 |
const HISTORY_KEY = "vomebook_search_history";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
const ICON_HTML = {
|
| 38 |
source: '<span class="ui-icon ui-icon-stack" aria-hidden="true"></span>',
|
| 39 |
folder: '<span class="ui-icon ui-icon-folder" aria-hidden="true"></span>',
|
|
@@ -347,12 +353,14 @@ function renderHistoryDropdown() {
|
|
| 347 |
|
| 348 |
function applyTheme() {
|
| 349 |
document.body.classList.toggle("light", !STATE.isDark);
|
|
|
|
|
|
|
|
|
|
| 350 |
const previewThemeBtn = DOM.previewPanel?.querySelector("[data-action='toggle-preview-theme']");
|
| 351 |
if (previewThemeBtn) {
|
| 352 |
previewThemeBtn.setAttribute("aria-label", STATE.isDark ? "切换到白天模式" : "切换到黑夜模式");
|
| 353 |
previewThemeBtn.title = STATE.isDark ? "白天模式" : "黑夜模式";
|
| 354 |
-
|
| 355 |
-
if (glyph) glyph.textContent = STATE.isDark ? "☾" : "☀";
|
| 356 |
}
|
| 357 |
}
|
| 358 |
|
|
@@ -558,7 +566,7 @@ async function openPreview(docId, keyword, options = {}) {
|
|
| 558 |
</div>
|
| 559 |
<div class="preview-tools">
|
| 560 |
<button type="button" class="icon-btn-sm" data-action="close-preview" aria-label="关闭预览">×</button>
|
| 561 |
-
<button type="button" class="icon-btn-sm preview-theme-btn" data-action="toggle-preview-theme" aria-label="${STATE.isDark ? "切换到白天模式" : "切换到黑夜模式"}" title="${STATE.isDark ? "白天模式" : "黑夜模式"}">
|
| 562 |
</div>
|
| 563 |
</div>
|
| 564 |
<pre class="preview-body">${text}</pre>`;
|
|
|
|
| 34 |
|
| 35 |
const DOM = {};
|
| 36 |
const HISTORY_KEY = "vomebook_search_history";
|
| 37 |
+
function themeIcon(isDark) {
|
| 38 |
+
const shape = isDark
|
| 39 |
+
? '<path d="M20 15.5A8 8 0 1 1 8.5 4 6.5 6.5 0 0 0 20 15.5Z"/>'
|
| 40 |
+
: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M4.93 4.93l1.42 1.42m11.3 11.3 1.42 1.42M2 12h2m16 0h2M4.93 19.07l1.42-1.42m11.3-11.3 1.42-1.42"/>';
|
| 41 |
+
return `<svg class="theme-icon-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">${shape}</svg>`;
|
| 42 |
+
}
|
| 43 |
const ICON_HTML = {
|
| 44 |
source: '<span class="ui-icon ui-icon-stack" aria-hidden="true"></span>',
|
| 45 |
folder: '<span class="ui-icon ui-icon-folder" aria-hidden="true"></span>',
|
|
|
|
| 353 |
|
| 354 |
function applyTheme() {
|
| 355 |
document.body.classList.toggle("light", !STATE.isDark);
|
| 356 |
+
DOM.themeBtn.innerHTML = themeIcon(STATE.isDark);
|
| 357 |
+
DOM.themeBtn.setAttribute("aria-label", STATE.isDark ? "切换到白天模式" : "切换到黑夜模式");
|
| 358 |
+
DOM.themeBtn.title = STATE.isDark ? "白天模式" : "黑夜模式";
|
| 359 |
const previewThemeBtn = DOM.previewPanel?.querySelector("[data-action='toggle-preview-theme']");
|
| 360 |
if (previewThemeBtn) {
|
| 361 |
previewThemeBtn.setAttribute("aria-label", STATE.isDark ? "切换到白天模式" : "切换到黑夜模式");
|
| 362 |
previewThemeBtn.title = STATE.isDark ? "白天模式" : "黑夜模式";
|
| 363 |
+
previewThemeBtn.innerHTML = themeIcon(STATE.isDark);
|
|
|
|
| 364 |
}
|
| 365 |
}
|
| 366 |
|
|
|
|
| 566 |
</div>
|
| 567 |
<div class="preview-tools">
|
| 568 |
<button type="button" class="icon-btn-sm" data-action="close-preview" aria-label="关闭预览">×</button>
|
| 569 |
+
<button type="button" class="icon-btn-sm preview-theme-btn" data-action="toggle-preview-theme" aria-label="${STATE.isDark ? "切换到白天模式" : "切换到黑夜模式"}" title="${STATE.isDark ? "白天模式" : "黑夜模式"}">${themeIcon(STATE.isDark)}</button>
|
| 570 |
</div>
|
| 571 |
</div>
|
| 572 |
<pre class="preview-body">${text}</pre>`;
|
static/index.html
CHANGED
|
@@ -30,7 +30,7 @@
|
|
| 30 |
<div class="header-right">
|
| 31 |
<button id="settings-btn" class="icon-btn" aria-label="搜索设置"><span class="ui-icon ui-icon-sliders" aria-hidden="true"></span></button>
|
| 32 |
<button id="mobile-toggle-btn" class="icon-btn" aria-label="切换手机或电脑模式" title="手机/电脑模式切换"><span id="mobile-toggle-icon" class="ui-icon ui-icon-devices" aria-hidden="true"></span></button>
|
| 33 |
-
<button id="theme-btn" class="icon-btn" aria-label="切换
|
| 34 |
</div>
|
| 35 |
</header>
|
| 36 |
|
|
|
|
| 30 |
<div class="header-right">
|
| 31 |
<button id="settings-btn" class="icon-btn" aria-label="搜索设置"><span class="ui-icon ui-icon-sliders" aria-hidden="true"></span></button>
|
| 32 |
<button id="mobile-toggle-btn" class="icon-btn" aria-label="切换手机或电脑模式" title="手机/电脑模式切换"><span id="mobile-toggle-icon" class="ui-icon ui-icon-devices" aria-hidden="true"></span></button>
|
| 33 |
+
<button id="theme-btn" class="icon-btn" aria-label="切换到白天模式" title="白天模式"><svg class="theme-icon-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M20 15.5A8 8 0 1 1 8.5 4 6.5 6.5 0 0 0 20 15.5Z"/></svg></button>
|
| 34 |
</div>
|
| 35 |
</header>
|
| 36 |
|
static/style.css
CHANGED
|
@@ -503,10 +503,10 @@ ul, li {
|
|
| 503 |
display: none;
|
| 504 |
}
|
| 505 |
|
| 506 |
-
.
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
}
|
| 511 |
|
| 512 |
.preview-title {
|
|
|
|
| 503 |
display: none;
|
| 504 |
}
|
| 505 |
|
| 506 |
+
.theme-icon-svg {
|
| 507 |
+
width: 20px;
|
| 508 |
+
height: 20px;
|
| 509 |
+
display: block;
|
| 510 |
}
|
| 511 |
|
| 512 |
.preview-title {
|