14 lines
510 B
TypeScript
14 lines
510 B
TypeScript
/**
|
|
* 复制文本反馈模型(module 13 task 247):非空给出「已复制 X」,失败/空值给降级文案。
|
|
*/
|
|
export const COPY_FEEDBACK_FALLBACK = '复制失败,请手动选择'
|
|
|
|
export function copyFeedback(text: string): string {
|
|
const t = typeof text === 'string' ? text.trim() : ''
|
|
return t ? `已复制 ${t}` : COPY_FEEDBACK_FALLBACK
|
|
}
|
|
|
|
export function isCopySupported(): boolean {
|
|
return typeof navigator !== 'undefined' && typeof navigator.clipboard?.writeText === 'function'
|
|
}
|