File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -118,11 +118,16 @@ async function copy() {
118
118
' text/html' : new Blob ([temp ], { type: ` text/html ` }),
119
119
' text/plain' : new Blob ([plainText ], { type: ` text/plain ` }),
120
120
})
121
- await navigator .clipboard .write ([clipboardItem ])
121
+ // FIX: https://stackoverflow.com/questions/62327358/javascript-clipboard-api-safari-ios-notallowederror-message
122
+ // NotAllowedError: the request is not allowed by the user agent or the platform in the current context,
123
+ // possibly because the user denied permission.
124
+ setTimeout (async () => {
125
+ await navigator .clipboard .write ([clipboardItem ])
126
+ }, 0 )
122
127
}
123
128
catch (error ) {
124
- console . warn ( ` Clipboard API 失败,回退到传统方式: ` , error )
125
- toast . error ( ` 复制失败,请联系开发者。 ` )
129
+ toast . error ( ` 复制失败,请联系开发者。${ error } ` )
130
+ return
126
131
}
127
132
}
128
133
You can’t perform that action at this time.
0 commit comments