Commit 165026cc authored by Chunchi Che's avatar Chunchi Che

finish onCopy

parent f04069c0
......@@ -26,6 +26,7 @@ export const CustomRoomContent: React.FC = () => {
const { message } = App.useApp();
const user = useSnapshot(accountStore).user;
const { options } = useSnapshot(mcCustomRoomStore);
const privateRoomID = getPrivateRoomID(user?.external_id ?? 0);
useEffect(() => {
if (!user) {
......@@ -33,7 +34,20 @@ export const CustomRoomContent: React.FC = () => {
}
}, [user]);
const onCopy = async () => {};
const onCopy = async () => {
if (navigator.clipboard) {
await navigator.clipboard
.writeText(String(privateRoomID))
.then(() => {
message.info("房间密码复制成功!");
})
.catch((err) => {
message.error("复制到剪贴板失败:", err);
});
} else {
message.error("浏览器不支持 Clipboard API");
}
};
const onChangeStartLP = (event: ChangeEvent<HTMLInputElement>) => {
mcCustomRoomStore.options.start_lp = Number(event.target.value);
};
......@@ -72,7 +86,7 @@ export const CustomRoomContent: React.FC = () => {
</div>
<Input
className={styles.input}
value={getPrivateRoomID(user?.external_id ?? 0)}
value={privateRoomID}
type="number"
readOnly
/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment