feat: Refactor service management scripts to use a unified dev script

- Added package.json to manage development scripts.
- Updated restart-services.ps1 to call the new dev script for starting services.
- Refactored start-admin.ps1, start-backend.ps1, start-frontend.ps1, and start-mcp.ps1 to utilize the dev script for starting respective services.
- Enhanced stop-services.ps1 to improve process termination logic by matching command patterns.
This commit is contained in:
2026-03-29 21:36:13 +08:00
parent 84f82c2a7e
commit 92a85eef20
137 changed files with 14181 additions and 2691 deletions

View File

@@ -121,7 +121,7 @@ const i18nPayload = JSON.stringify({ locale, messages });
}
@media (prefers-color-scheme: dark) {
:root:not(.light) {
:root:not(.light):not(.dark) {
--primary: #00ff9d;
--primary-rgb: 0 255 157;
--primary-light: #00ff9d33;
@@ -193,12 +193,84 @@ const i18nPayload = JSON.stringify({ locale, messages });
<script is:inline>
(function() {
const theme = localStorage.getItem('theme');
const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (theme === 'dark' || (!theme && systemDark)) {
document.documentElement.classList.add('dark');
} else if (theme === 'light') {
document.documentElement.classList.add('light');
const STORAGE_KEY = 'theme';
const VALID_THEMES = new Set(['light', 'dark', 'system']);
const root = document.documentElement;
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
function readThemeMode() {
try {
const savedMode = localStorage.getItem(STORAGE_KEY);
return VALID_THEMES.has(savedMode) ? savedMode : 'system';
} catch {
return 'system';
}
}
function resolveTheme(mode) {
return mode === 'dark' || (mode === 'system' && mediaQuery.matches) ? 'dark' : 'light';
}
function applyTheme(mode, options = {}) {
const { persist = false, notify = true } = options;
const safeMode = VALID_THEMES.has(mode) ? mode : 'system';
const resolvedTheme = resolveTheme(safeMode);
root.dataset.themeMode = safeMode;
root.dataset.themeResolved = resolvedTheme;
root.classList.toggle('dark', resolvedTheme === 'dark');
root.classList.toggle('light', resolvedTheme === 'light');
if (persist) {
try {
localStorage.setItem(STORAGE_KEY, safeMode);
} catch {
// Ignore storage write failures and keep the UI responsive.
}
}
if (notify) {
window.dispatchEvent(
new CustomEvent('termi:theme-change', {
detail: { mode: safeMode, resolved: resolvedTheme },
})
);
}
return { mode: safeMode, resolved: resolvedTheme };
}
function syncThemeFromStorage(notify = false) {
return applyTheme(readThemeMode(), { notify });
}
window.__termiTheme = {
getMode: readThemeMode,
resolveTheme,
applyTheme(mode) {
return applyTheme(mode, { persist: true, notify: true });
},
syncTheme() {
return syncThemeFromStorage(true);
},
};
syncThemeFromStorage(false);
if (!window.__termiThemeMediaBound) {
const handleSystemThemeChange = () => {
if (readThemeMode() === 'system') {
syncThemeFromStorage(true);
}
};
if (typeof mediaQuery.addEventListener === 'function') {
mediaQuery.addEventListener('change', handleSystemThemeChange);
} else {
mediaQuery.onchange = handleSystemThemeChange;
}
window.__termiThemeMediaBound = true;
}
})();
</script>