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

finish onCopy

parent f04069c0
Pipeline #25763 passed with stages
in 8 minutes and 46 seconds
...@@ -26,6 +26,7 @@ export const CustomRoomContent: React.FC = () => { ...@@ -26,6 +26,7 @@ export const CustomRoomContent: React.FC = () => {
const { message } = App.useApp(); const { message } = App.useApp();
const user = useSnapshot(accountStore).user; const user = useSnapshot(accountStore).user;
const { options } = useSnapshot(mcCustomRoomStore); const { options } = useSnapshot(mcCustomRoomStore);
const privateRoomID = getPrivateRoomID(user?.external_id ?? 0);
useEffect(() => { useEffect(() => {
if (!user) { if (!user) {
...@@ -33,7 +34,20 @@ export const CustomRoomContent: React.FC = () => { ...@@ -33,7 +34,20 @@ export const CustomRoomContent: React.FC = () => {
} }
}, [user]); }, [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>) => { const onChangeStartLP = (event: ChangeEvent<HTMLInputElement>) => {
mcCustomRoomStore.options.start_lp = Number(event.target.value); mcCustomRoomStore.options.start_lp = Number(event.target.value);
}; };
...@@ -72,7 +86,7 @@ export const CustomRoomContent: React.FC = () => { ...@@ -72,7 +86,7 @@ export const CustomRoomContent: React.FC = () => {
</div> </div>
<Input <Input
className={styles.input} className={styles.input}
value={getPrivateRoomID(user?.external_id ?? 0)} value={privateRoomID}
type="number" type="number"
readOnly 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