feat: 新增鉴权
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// app/utils/clipboard.ts - 剪贴板操作工具
|
||||
|
||||
const legacyCopy = (text: string) => {
|
||||
const input = document.createElement("input");
|
||||
input.value = text;
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(input);
|
||||
};
|
||||
|
||||
/** 复制文本,优先使用 Clipboard API,降级使用 execCommand */
|
||||
export const copy = (text: string): void => {
|
||||
try {
|
||||
void navigator.clipboard.writeText(text);
|
||||
} catch {
|
||||
legacyCopy(text);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user