Widen settings forms and fix Token clipboard copy fallback.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -150,6 +150,39 @@ export default function SettingsPage() {
|
||||
}
|
||||
}
|
||||
|
||||
async function copyToken(text: string) {
|
||||
setErr("");
|
||||
setOk("");
|
||||
try {
|
||||
if (navigator.clipboard?.writeText) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
setOk("已复制到剪贴板");
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
/* fall through to legacy copy */
|
||||
}
|
||||
try {
|
||||
const ta = document.createElement("textarea");
|
||||
ta.value = text;
|
||||
ta.setAttribute("readonly", "");
|
||||
ta.style.position = "fixed";
|
||||
ta.style.left = "-9999px";
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
ta.setSelectionRange(0, text.length);
|
||||
const okCopy = document.execCommand("copy");
|
||||
document.body.removeChild(ta);
|
||||
if (okCopy) {
|
||||
setOk("已复制到剪贴板");
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
setErr("复制失败,请手动选中 Token 复制");
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>系统设置</h2>
|
||||
@@ -297,10 +330,7 @@ export default function SettingsPage() {
|
||||
<button
|
||||
type="button"
|
||||
className="btn ghost"
|
||||
onClick={() => {
|
||||
void navigator.clipboard.writeText(lastToken.token);
|
||||
setOk("已复制到剪贴板");
|
||||
}}
|
||||
onClick={() => void copyToken(lastToken.token)}
|
||||
>
|
||||
复制
|
||||
</button>
|
||||
|
||||
@@ -277,7 +277,8 @@ input {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin: 16px 0;
|
||||
max-width: 520px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
@@ -315,6 +316,16 @@ td {
|
||||
gap: 8px;
|
||||
margin: 12px 0;
|
||||
word-break: break-all;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.token-box code {
|
||||
user-select: all;
|
||||
display: block;
|
||||
padding: 8px;
|
||||
background: #0d1520;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.settings-tabs {
|
||||
|
||||
Reference in New Issue
Block a user