Compare commits

...

1 Commits

2 changed files with 171 additions and 26 deletions

76
app.js
View File

@@ -681,6 +681,10 @@ class CLIProxyManager {
} }
// 顶栏标题动画与状态 // 顶栏标题动画与状态
isMobileViewport() {
return typeof window !== 'undefined' ? window.innerWidth <= 768 : false;
}
setupBrandTitleAnimation() { setupBrandTitleAnimation() {
const mainPage = document.getElementById('main-page'); const mainPage = document.getElementById('main-page');
if (mainPage && mainPage.style.display === 'none') { if (mainPage && mainPage.style.display === 'none') {
@@ -703,13 +707,45 @@ class CLIProxyManager {
toggle.addEventListener('click', this.brandToggleHandler); toggle.addEventListener('click', this.brandToggleHandler);
} }
if (!this.brandResizeHandler) { if (!this.brandResizeHandler) {
this.brandResizeHandler = () => this.updateBrandTextWidths({ immediate: true }); this.brandResizeHandler = () => this.handleBrandResize();
window.addEventListener('resize', this.brandResizeHandler); window.addEventListener('resize', this.brandResizeHandler);
} }
if (this.isMobileViewport()) {
this.applyMobileBrandState();
} else {
this.enableBrandAnimation();
}
}
enableBrandAnimation() {
const { toggle } = this.brandElements || {};
if (toggle) {
toggle.removeAttribute('aria-disabled');
toggle.style.pointerEvents = '';
}
this.brandAnimationReady = true; this.brandAnimationReady = true;
} }
applyMobileBrandState() {
const { toggle, wrapper, shortText } = this.brandElements || {};
if (!toggle || !wrapper || !shortText) {
return;
}
this.clearBrandCollapseTimer();
this.brandIsCollapsed = true;
this.brandAnimationReady = false;
toggle.classList.add('collapsed');
toggle.classList.remove('expanded');
toggle.setAttribute('aria-disabled', 'true');
toggle.style.pointerEvents = 'none';
const targetWidth = this.getBrandTextWidth(shortText);
this.applyBrandWidth(targetWidth, { animate: false });
}
getBrandTextWidth(element) { getBrandTextWidth(element) {
if (!element) { if (!element) {
return 0; return 0;
@@ -762,6 +798,27 @@ class CLIProxyManager {
toggle.classList.toggle('expanded', !collapsed); toggle.classList.toggle('expanded', !collapsed);
} }
handleBrandResize() {
if (!this.brandElements?.wrapper) {
return;
}
if (this.isMobileViewport()) {
this.applyMobileBrandState();
return;
}
if (!this.brandAnimationReady) {
this.enableBrandAnimation();
this.brandIsCollapsed = false;
this.setBrandCollapsed(false, { animate: false });
this.scheduleBrandCollapse(this.brandCollapseDelayMs);
return;
}
this.updateBrandTextWidths({ immediate: true });
}
scheduleBrandCollapse(delayMs = this.brandCollapseDelayMs) { scheduleBrandCollapse(delayMs = this.brandCollapseDelayMs) {
this.clearBrandCollapseTimer(); this.clearBrandCollapseTimer();
this.brandCollapseTimer = window.setTimeout(() => { this.brandCollapseTimer = window.setTimeout(() => {
@@ -779,6 +836,12 @@ class CLIProxyManager {
startBrandCollapseCycle() { startBrandCollapseCycle() {
this.setupBrandTitleAnimation(); this.setupBrandTitleAnimation();
if (this.isMobileViewport()) {
this.applyMobileBrandState();
return;
}
if (!this.brandAnimationReady) { if (!this.brandAnimationReady) {
return; return;
} }
@@ -792,6 +855,12 @@ class CLIProxyManager {
resetBrandTitleState() { resetBrandTitleState() {
this.clearBrandCollapseTimer(); this.clearBrandCollapseTimer();
const mainPage = document.getElementById('main-page'); const mainPage = document.getElementById('main-page');
if (this.isMobileViewport()) {
this.applyMobileBrandState();
return;
}
if (!this.brandAnimationReady || (mainPage && mainPage.style.display === 'none')) { if (!this.brandAnimationReady || (mainPage && mainPage.style.display === 'none')) {
this.brandIsCollapsed = false; this.brandIsCollapsed = false;
return; return;
@@ -802,6 +871,11 @@ class CLIProxyManager {
} }
refreshBrandTitleAfterTextChange() { refreshBrandTitleAfterTextChange() {
if (this.isMobileViewport()) {
this.applyMobileBrandState();
return;
}
if (!this.brandAnimationReady) { if (!this.brandAnimationReady) {
return; return;
} }

View File

@@ -267,6 +267,8 @@
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
height: 36px; height: 36px;
min-width: 36px;
justify-content: center;
} }
/* 登录页面的按钮样式优化 */ /* 登录页面的按钮样式优化 */
@@ -916,6 +918,26 @@ body {
position: relative; position: relative;
} }
@media (max-width: 768px) {
.top-navbar-brand-toggle {
pointer-events: none;
cursor: default;
}
.brand-texts {
transition: none;
}
.top-navbar-brand-toggle .brand-text-full {
display: none;
}
.top-navbar-brand-toggle .brand-text-short {
position: relative;
opacity: 1;
}
}
.top-navbar-actions { .top-navbar-actions {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -926,63 +948,99 @@ body {
.top-navbar-actions>* { .top-navbar-actions>* {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center;
height: 36px; height: 36px;
min-width: 44px;
} }
.top-navbar .header-controls { .top-navbar .header-controls {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
height: 100%; height: auto;
} }
.top-navbar .language-btn, .top-navbar .language-btn,
.top-navbar .theme-btn { .top-navbar .theme-btn {
width: 36px;
height: 36px; height: 36px;
min-height: 36px; min-height: 36px;
padding: 0; min-width: 44px;
padding: 0 12px;
justify-content: center; justify-content: center;
line-height: 1;
} }
.top-navbar-actions .btn { .top-navbar-actions .btn {
height: 36px; height: 36px;
min-height: 36px; min-height: 36px;
min-width: 44px;
padding: 0 12px;
justify-content: center;
line-height: 1;
} }
@media (max-width: 768px) { @media (max-width: 768px) {
.top-navbar {
flex-direction: column;
align-items: stretch;
gap: 8px;
height: auto;
min-height: var(--navbar-height, 69px);
}
.top-navbar-left {
width: 100%;
justify-content: flex-start;
}
.top-navbar-actions { .top-navbar-actions {
width: 100%;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: flex-end; justify-content: flex-end;
gap: 8px; gap: 8px;
margin-left: 0;
align-items: center;
} }
.top-navbar .header-controls { .top-navbar .header-controls {
width: 100%; width: auto;
order: 0;
justify-content: flex-end; justify-content: flex-end;
order: 99;
gap: 8px; gap: 8px;
height: auto;
align-items: center;
} }
.top-navbar-actions>* { .top-navbar-actions>* {
height: 34px; height: 36px;
min-height: 34px; min-height: 36px;
min-width: 44px;
justify-content: center;
} }
.top-navbar .language-btn, .top-navbar .language-btn,
.top-navbar .theme-btn { .top-navbar .theme-btn {
width: 34px; height: 36px;
height: 34px; min-height: 36px;
min-width: 44px;
padding: 0 12px;
justify-content: center;
line-height: 1;
} }
.top-navbar-actions .btn { .top-navbar-actions .btn {
height: 34px; height: 36px;
min-height: 34px; min-height: 36px;
padding: 0 10px; min-width: 44px;
padding: 0 12px;
justify-content: center;
line-height: 1;
} }
.top-navbar-actions .btn span { .top-navbar .language-btn i,
display: none; .top-navbar .theme-btn i,
.top-navbar-actions .btn i {
margin: 0;
} }
} }
@@ -3048,38 +3106,51 @@ input:checked+.slider:before {
@media (max-width: 768px) { @media (max-width: 768px) {
.top-navbar { .top-navbar {
padding: 12px 16px; padding: 12px 16px;
flex-direction: column;
align-items: stretch;
gap: 8px;
height: auto;
min-height: var(--navbar-height, 69px);
} }
.top-navbar-title { .top-navbar-title {
font-size: 18px; font-size: 18px;
} }
.top-navbar-left {
width: 100%;
justify-content: flex-start;
}
.top-navbar-actions { .top-navbar-actions {
gap: 6px; gap: 6px;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: flex-end; justify-content: flex-end;
width: 100%;
margin-left: 0;
} }
.top-navbar-actions>* { .top-navbar-actions>* {
height: 34px; height: 36px;
min-height: 34px; min-height: 36px;
min-width: 44px;
} }
.top-navbar .header-controls { .top-navbar .header-controls {
height: 34px; height: 36px;
gap: 6px; gap: 8px;
width: auto;
order: 0;
justify-content: flex-end;
} }
.top-navbar-actions .btn, .top-navbar-actions .btn,
.top-navbar .language-btn, .top-navbar .language-btn,
.top-navbar .theme-btn { .top-navbar .theme-btn {
height: 34px; height: 36px;
min-height: 34px; min-height: 36px;
padding: 0 10px; min-width: 44px;
} padding: 8px 12px;
.top-navbar-actions .btn span {
display: none;
} }
.btn { .btn {