mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 18:57:07 +08:00
feat: close #1994 add clipboard write api
This commit is contained in:
6
app/global.d.ts
vendored
6
app/global.d.ts
vendored
@@ -9,3 +9,9 @@ declare module "*.scss" {
|
||||
}
|
||||
|
||||
declare module "*.svg";
|
||||
|
||||
declare interface Window {
|
||||
__TAURI__?: {
|
||||
writeText(text: string): Promise<void>;
|
||||
};
|
||||
}
|
||||
|
@@ -8,7 +8,12 @@ export function trimTopic(topic: string) {
|
||||
|
||||
export async function copyToClipboard(text: string) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
if (window.__TAURI__) {
|
||||
window.__TAURI__.writeText(text);
|
||||
} else {
|
||||
await navigator.clipboard.writeText(text);
|
||||
}
|
||||
|
||||
showToast(Locale.Copy.Success);
|
||||
} catch (error) {
|
||||
const textArea = document.createElement("textarea");
|
||||
|
Reference in New Issue
Block a user