feat(web): connect quick share flow
Signed-off-by: JustMe <mr.toing@outlook.com>
This commit is contained in:
1 parent
53768a195d
commit
e02e024605
138 files changed
+10614
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import type { Item } from '@/core-bridge/types';
|
||||
import type { IconName } from '@/ui/Icon';
|
||||
|
||||
const FILE_ICON = {
|
||||
image: 'image',
|
||||
video: 'video',
|
||||
audio: 'file',
|
||||
text: 'text',
|
||||
archive: 'archive',
|
||||
none: 'file',
|
||||
} as const satisfies Record<string, IconName>;
|
||||
|
||||
export function iconOf(item: Item): IconName {
|
||||
return item.kind === 'text' ? 'text' : FILE_ICON[item.preview];
|
||||
}
|
||||
|
||||
/** 列表里的一行标题:文件名,或文本的第一行 */
|
||||
export function titleOf(item: Item): string {
|
||||
if (item.kind === 'file') return item.name;
|
||||
return item.text.split('\n').find((l) => l.trim() !== '')?.trim() ?? '(空)';
|
||||
}
|
||||
|
||||
export function shortDevice(name: string | undefined): string {
|
||||
return (name ?? '未知设备').split(' · ')[0] ?? '未知设备';
|
||||
}
|
||||
|
||||
/** 当前版本号:旧版本数 + 1 */
|
||||
export function versionOf(item: Item): number {
|
||||
return item.kind === 'file' ? (item.versions?.length ?? 0) + 1 : 1;
|
||||
}
|
||||
Reference in new issue
Block a user