forked from XiaoMo/ChatGPT-Next-Web
feat: close #1994 add clipboard write api
This commit is contained in:
parent
ea6926cad3
commit
98afd5516b
6
app/global.d.ts
vendored
6
app/global.d.ts
vendored
@ -9,3 +9,9 @@ declare module "*.scss" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare module "*.svg";
|
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) {
|
export async function copyToClipboard(text: string) {
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(text);
|
if (window.__TAURI__) {
|
||||||
|
window.__TAURI__.writeText(text);
|
||||||
|
} else {
|
||||||
|
await navigator.clipboard.writeText(text);
|
||||||
|
}
|
||||||
|
|
||||||
showToast(Locale.Copy.Success);
|
showToast(Locale.Copy.Success);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const textArea = document.createElement("textarea");
|
const textArea = document.createElement("textarea");
|
||||||
|
@ -17,7 +17,7 @@ tauri-build = { version = "1.3.0", features = [] }
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
tauri = { version = "1.3.0", features = ["clipboard-all", "shell-open", "updater", "window-close", "window-hide", "window-maximize", "window-minimize", "window-set-icon", "window-set-ignore-cursor-events", "window-set-resizable", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
|
tauri = { version = "1.3.0", features = ["clipboard-all", "dialog-all", "shell-open", "updater", "window-close", "window-hide", "window-maximize", "window-minimize", "window-set-icon", "window-set-ignore-cursor-events", "window-set-resizable", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
|
||||||
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
"beforeBuildCommand": "yarn export",
|
"beforeBuildCommand": "yarn export",
|
||||||
"beforeDevCommand": "yarn export:dev",
|
"beforeDevCommand": "yarn export:dev",
|
||||||
"devPath": "http://localhost:3000",
|
"devPath": "http://localhost:3000",
|
||||||
"distDir": "../out"
|
"distDir": "../out",
|
||||||
|
"withGlobalTauri": true
|
||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "chatgpt-next-web",
|
"productName": "chatgpt-next-web",
|
||||||
"version": "2.8.4"
|
"version": "2.8.5"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
@ -17,8 +18,18 @@
|
|||||||
"all": false,
|
"all": false,
|
||||||
"open": true
|
"open": true
|
||||||
},
|
},
|
||||||
|
"dialog": {
|
||||||
|
"all": true,
|
||||||
|
"ask": true,
|
||||||
|
"confirm": true,
|
||||||
|
"message": true,
|
||||||
|
"open": true,
|
||||||
|
"save": true
|
||||||
|
},
|
||||||
"clipboard": {
|
"clipboard": {
|
||||||
"all": true
|
"all": true,
|
||||||
|
"writeText": true,
|
||||||
|
"readText": true
|
||||||
},
|
},
|
||||||
"window": {
|
"window": {
|
||||||
"all": false,
|
"all": false,
|
||||||
|
Loading…
Reference in New Issue
Block a user