@allbluecn/web-app 0.27.9 → 0.27.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,6 +25,7 @@ import {
25
25
  type ReactNode,
26
26
  } from "react";
27
27
  import { useTheme } from "next-themes";
28
+ import { getDesktopBridge } from "@/lib/desktop-bridge-types";
28
29
  import {
29
30
  DEFAULT_MODE,
30
31
  MODE_STORAGE_KEY,
@@ -95,7 +96,14 @@ export function ThemeModeProvider({ children }: { children: ReactNode }) {
95
96
  // 应用:auto 由「系统外观 + 深色时段」共同决定(手动模式直接落值)
96
97
  useEffect(() => {
97
98
  if (!mounted) return;
98
- setTheme(resolveTheme(mode, systemPrefersDark, new Date()));
99
+ const resolved = resolveTheme(mode, systemPrefersDark, new Date());
100
+ setTheme(resolved);
101
+ // 同步 macOS 原生外观(nativeTheme.themeSource):vibrancy 材质默认跟随
102
+ // 系统外观——App 切暗色而系统浅色时,透明 body 露出的毛玻璃仍是浅色材质
103
+ // (用户截图的外圈浅色边框)。旧壳无此方法则降级为跟随系统。
104
+ if (resolved === "dark" || resolved === "light") {
105
+ getDesktopBridge()?.setNativeTheme?.(resolved);
106
+ }
99
107
  }, [mode, mounted, systemPrefersDark, setTheme]);
100
108
 
101
109
  // auto 模式:每分钟 + 窗口回到前台时重算(跨过时段边界自动翻转)。
@@ -120,8 +120,10 @@ export const createStoryFn = createServerFn({ method: "POST" })
120
120
  // 发号 + 建单事务段已提取为共享导出(convertBugToStoryFn 复用,任务 6 DRY)
121
121
  return withSequenceNumberRetry(
122
122
  () =>
123
- prisma.$transaction((tx) =>
124
- createStoryInternal(tx, { ...data, projectId: resolvedProjectId }, userId),
123
+ prisma.$transaction(
124
+ (tx) =>
125
+ createStoryInternal(tx, { ...data, projectId: resolvedProjectId }, userId),
126
+ STORY_TX_OPTIONS,
125
127
  ),
126
128
  { exhaustedMessage: "创建需求失败:编号冲突,请重试" },
127
129
  );
@@ -196,6 +198,16 @@ function storyDescriptionToContent(description: string): { html: string; markdow
196
198
  return { html: description, markdown: description };
197
199
  }
198
200
 
201
+ /**
202
+ * 交互式事务超时选项。Prisma 缺省 5s:桌面端(PGlite)单连接,事务语句与
203
+ * 并发查询(PeekPanel 十余个并行 serverFn / 列表分页 / presence / 同步引擎)
204
+ * 在 PGlite 内部队列串行排队,排队等待计入事务计时——列表页繁忙时轻松击穿
205
+ * 5s 报 P2028「A query cannot be executed on an expired transaction」(实测
206
+ * 5005ms)。放宽到 30s(maxWait 同步放宽兜事务启动排队);云端连接池下
207
+ * 事务本体 <100ms,放宽无副作用——只影响真正拥塞时的等待上限。
208
+ */
209
+ const STORY_TX_OPTIONS = { maxWait: 10_000, timeout: 30_000 } as const;
210
+
199
211
  export const updateStoryFn = createServerFn({ method: "POST" })
200
212
  .middleware([authContextMiddleware])
201
213
  .validator(updateSchema)
@@ -504,7 +516,7 @@ export const updateStoryFn = createServerFn({ method: "POST" })
504
516
  ? { ...castStoryUsers(updated), description: data.description }
505
517
  : castStoryUsers(updated);
506
518
  return { story: echo, activities: [] as ActivityItem[] };
507
- });
519
+ }, STORY_TX_OPTIONS);
508
520
  });
509
521
 
510
522
  const deleteSchema = z.object({ storyId: z.string() });