mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2024-11-09 09:41:17 +08:00
feat(Device): sync clipboard from device
This commit is contained in:
parent
e845a2355f
commit
928e5ff5d9
@ -60,6 +60,8 @@ let deviceWaitForMetadataTask: ((deviceName: string) => void) | null = null;
|
||||
let deviceWaitForScreenSizeTask: ((w: number, h: number) => void) | null = null;
|
||||
|
||||
let unlisten: UnlistenFn | undefined;
|
||||
let lastClipboard = "";
|
||||
|
||||
onMounted(async () => {
|
||||
unlisten = await listen("device-reply", (event) => {
|
||||
try {
|
||||
@ -69,7 +71,17 @@ onMounted(async () => {
|
||||
deviceWaitForMetadataTask?.(payload.deviceName);
|
||||
break;
|
||||
case "ClipboardChanged":
|
||||
console.log("ClipboardChanged", payload.clipboard);
|
||||
if (payload.clipboard === lastClipboard) break;
|
||||
lastClipboard = payload.clipboard;
|
||||
navigator.clipboard
|
||||
.writeText(payload.clipboard)
|
||||
.then(() => {
|
||||
message.info("Device clipboard synced");
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
message.error("Device clipboard sync failed");
|
||||
});
|
||||
break;
|
||||
case "ClipboardSetAck":
|
||||
console.log("ClipboardSetAck", payload.sequence);
|
||||
@ -222,7 +234,7 @@ function onMenuClickoutside() {
|
||||
async function deviceControl() {
|
||||
let curClientInfo = await getCurClientInfo();
|
||||
if (curClientInfo) {
|
||||
message.warning(t("pages.Device.alreadyControled"));
|
||||
message.error(t("pages.Device.alreadyControled"));
|
||||
store.controledDevice = {
|
||||
scid: curClientInfo.scid,
|
||||
deviceName: curClientInfo.device_name,
|
||||
@ -236,12 +248,6 @@ async function deviceControl() {
|
||||
port.value = 27183;
|
||||
}
|
||||
|
||||
if (store.controledDevice) {
|
||||
message.error(t("pages.Device.deviceControl.closeCurDevice"));
|
||||
store.hideLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
message.info(t("pages.Device.deviceControl.controlInfo"));
|
||||
|
||||
const device = devices.value[rowIndex];
|
||||
|
@ -14,7 +14,6 @@
|
||||
"screen": "Get screen size"
|
||||
},
|
||||
"deviceControl": {
|
||||
"closeCurDevice": "Please close the current control device first",
|
||||
"controlInfo": "The control service is starting. Please keep the device screen on.",
|
||||
"connectTimeout": "Device connection timeout"
|
||||
},
|
||||
|
@ -13,7 +13,6 @@
|
||||
"screen": "获取屏幕尺寸"
|
||||
},
|
||||
"deviceControl": {
|
||||
"closeCurDevice": "请先关闭当前控制设备",
|
||||
"controlInfo": "正在启动控制服务,请保持设备亮屏",
|
||||
"connectTimeout": "设备连接超时"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user