Skip to content

Commit f500b97

Browse files
committed
CAIS:improve:UI调整;new:pip窗口增加复制内容计数
1 parent d53724e commit f500b97

2 files changed

Lines changed: 61 additions & 27 deletions

File tree

CAIS/components/AppRoot.tsx

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
useState,
2020
Form,
2121
Navigation,
22+
useColorScheme,
2223
type ScenePhase,
2324
} from "scripting"
2425

@@ -77,16 +78,32 @@ function EmptyState(props: {
7778
message: string
7879
systemImage: string
7980
}) {
81+
const colorScheme = useColorScheme()
82+
const cardFill = colorScheme === "dark" ? "secondarySystemBackground" : "systemBackground"
83+
8084
return (
81-
<VStack
85+
<HStack
8286
frame={{ maxWidth: "infinity", alignment: "center" as any }}
83-
padding={{ top: 32, bottom: 32 }}
84-
spacing={10}
87+
listRowInsets={{ top: 5, bottom: 5, leading: 12, trailing: 12 }}
88+
listRowSeparator="hidden"
89+
listRowBackground={<EmptyView />}
8590
>
86-
<Image systemName={props.systemImage} font="largeTitle" foregroundStyle="secondaryLabel" />
87-
<Text font="headline">{props.title}</Text>
88-
<Text foregroundStyle="secondaryLabel" multilineTextAlignment="center">{props.message}</Text>
89-
</VStack>
91+
<VStack
92+
frame={{ maxWidth: "infinity", alignment: "center" as any }}
93+
padding={{ top: 40, bottom: 40, leading: 16, trailing: 16 }}
94+
spacing={12}
95+
background={{ style: cardFill, shape: { type: "rect", cornerRadius: 18 } }}
96+
shadow={{
97+
color: colorScheme === "dark" ? "rgba(0,0,0,0.20)" : "rgba(0,0,0,0.07)",
98+
radius: 10,
99+
y: 4,
100+
}}
101+
>
102+
<Image systemName={props.systemImage} font="largeTitle" foregroundStyle="secondaryLabel" />
103+
<Text font="headline">{props.title}</Text>
104+
<Text foregroundStyle="secondaryLabel" multilineTextAlignment="center">{props.message}</Text>
105+
</VStack>
106+
</HStack>
90107
)
91108
}
92109

@@ -383,6 +400,9 @@ export function AppRoot() {
383400
}
384401

385402
async function clearData(scope: ClearScope) {
403+
showToast("正在删除...")
404+
// Yield to let toast render before blocking on async work
405+
await new Promise((r) => (globalThis as any).setTimeout?.(r, 50))
386406
if (scope === "favorites") {
387407
await clearFavoriteClips()
388408
showToast("已清空收藏数据")
@@ -941,15 +961,20 @@ export function AppRoot() {
941961

942962
<Tab title="设置" systemImage="gearshape" value={TAB_SETTINGS}>
943963
<NavigationStack>
944-
<SettingsView
945-
value={settings}
946-
onChanged={updateSettings}
947-
onClearFavorites={() => void requestClear("favorites")}
948-
onClearClipboard={(range) => void requestClear(range)}
949-
addActionToken={addCustomActionToken}
950-
leadingToolbar={toolbarLeading()}
951-
trailingToolbar={settingsTrailingToolbar()}
952-
/>
964+
<VStack
965+
frame={{ maxWidth: "infinity", maxHeight: "infinity", alignment: "top" as any }}
966+
toast={toastOptions()}
967+
>
968+
<SettingsView
969+
value={settings}
970+
onChanged={updateSettings}
971+
onClearFavorites={() => void requestClear("favorites")}
972+
onClearClipboard={(range) => void requestClear(range)}
973+
addActionToken={addCustomActionToken}
974+
leadingToolbar={toolbarLeading()}
975+
trailingToolbar={settingsTrailingToolbar()}
976+
/>
977+
</VStack>
953978
</NavigationStack>
954979
</Tab>
955980
</TabView>

CAIS/components/SettingsView.tsx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,26 @@ export function SettingsView(props: {
436436
role="destructive"
437437
action={() => props.onClearFavorites?.()}
438438
/>
439-
<Menu title="清空剪贴板数据" systemImage="trash">
440-
{CLIPBOARD_CLEAR_OPTIONS.map((option) => (
441-
<Button
442-
key={option.range}
443-
title={option.title}
444-
systemImage="trash"
445-
role="destructive"
446-
action={() => props.onClearClipboard?.(option.range)}
447-
/>
448-
))}
449-
</Menu>
439+
<Button
440+
title="清空剪贴板数据"
441+
systemImage="trash"
442+
action={async () => {
443+
const actions = CLIPBOARD_CLEAR_OPTIONS.map((opt) => ({
444+
label: opt.title,
445+
destructive: true,
446+
}))
447+
const idx = await Dialog.actionSheet({
448+
title: "选择清理范围",
449+
actions,
450+
})
451+
if (idx != null) {
452+
const option = CLIPBOARD_CLEAR_OPTIONS[idx]
453+
if (option) {
454+
props.onClearClipboard?.(option.range)
455+
}
456+
}
457+
}}
458+
/>
450459
</Section>
451460

452461
<Section header={<Text>采集类型</Text>}>

0 commit comments

Comments
 (0)