mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-12-28 18:55:59 +08:00
fix: fix berry copy token (#2041)
* [bugfix]修复copy问题 * [update]两阶段编译代码 --------- Co-authored-by: zicorn <a24395@autel.com>
This commit is contained in:
@@ -107,8 +107,7 @@ export async function onOidcClicked(auth_url, client_id, openInNewTab = false) {
|
||||
const url = `${auth_url}?client_id=${client_id}&redirect_uri=${redirect_uri}&response_type=${response_type}&scope=${scope}&state=${state}`;
|
||||
if (openInNewTab) {
|
||||
window.open(url);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
@@ -210,6 +209,7 @@ export function removeTrailingSlash(url) {
|
||||
}
|
||||
|
||||
let channelModels = undefined;
|
||||
|
||||
export async function loadChannelModels() {
|
||||
const res = await API.get('/api/models');
|
||||
const {success, data} = res.data;
|
||||
@@ -236,12 +236,25 @@ export function getChannelModels(type) {
|
||||
}
|
||||
|
||||
export function copy(text, name = '') {
|
||||
try {
|
||||
navigator.clipboard.writeText(text);
|
||||
} catch (error) {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
showNotice(`复制${name}成功!`, true);
|
||||
}, () => {
|
||||
text = `复制${name}失败,请手动复制:<br /><br />${text}`;
|
||||
enqueueSnackbar(<SnackbarHTMLContent htmlContent={text}/>, getSnackbarOptions('COPY'));
|
||||
});
|
||||
} else {
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.value = text;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
showNotice(`复制${name}成功!`, true);
|
||||
} catch (err) {
|
||||
text = `复制${name}失败,请手动复制:<br /><br />${text}`;
|
||||
enqueueSnackbar(<SnackbarHTMLContent htmlContent={text}/>, getSnackbarOptions('COPY'));
|
||||
return;
|
||||
}
|
||||
showSuccess(`复制${name}成功!`);
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user