feat: 发布 v0.4.0 桌面端

This commit is contained in:
SkyJourney
2026-07-27 20:56:39 +08:00
parent 92a5bfd016
commit 4d60741f5a
90 changed files with 10431 additions and 223 deletions
+8 -26
View File
@@ -1,13 +1,11 @@
import { useEffect, useState } from "react";
import {
getThemeCss,
listThemes,
type ThemeSummary
} from "./application-backend";
export interface ThemeSummary {
id: string;
name: string;
version: string;
description: string;
bundled: boolean;
source: "bundled" | "local";
}
export type { ThemeSummary } from "./application-backend";
export function useThemeResources(
themeId: string,
@@ -21,15 +19,7 @@ export function useThemeResources(
useEffect(() => {
const controller = new AbortController();
void fetch("/api/themes", {
signal: controller.signal
})
.then(async (response) => {
if (!response.ok) {
throw new Error("无法加载主题清单");
}
return response.json() as Promise<{ themes: ThemeSummary[] }>;
})
void listThemes(controller.signal)
.then(({ themes: availableThemes }) => {
setThemes(availableThemes);
setCatalogError("");
@@ -51,15 +41,7 @@ export function useThemeResources(
setThemeCss("");
setCssError("");
void fetch(`/api/themes/${encodeURIComponent(themeId)}/css`, {
signal: controller.signal
})
.then(async (response) => {
if (!response.ok) {
throw new Error("无法加载主题");
}
return response.text();
})
void getThemeCss(themeId, controller.signal)
.then(setThemeCss)
.catch((reason: unknown) => {
if (!controller.signal.aborted) {