1 Star 1 Fork 1

balabala/sys-shim

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
page.html 3.06 KB
一键复制 编辑 原始数据 按行查看 历史
balabala 提交于 2023-10-07 14:15 . refactor: Remove hwndObj
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style type="text/css">
</style>
<title>sys-shim page</title>
<script type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/rpc-websockets@7.6.0/dist/index.browser-bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14"></script>
</head>
<body>
<div id="box">
<h2>sys-shim</h2>
<button @click="msgBox">msgBox</button>
<button @click="exit">exit</button>
<button @click="exitHwnd">exitHwnd {{ hwnd }}</button>
</div>
</body>
<script>
let ws
let main
let tray
let hwnd
let msg
window.vm = new Vue({
el: `#box`,
data: {
hwnd: ``,
},
async created() {
hwnd = window.hwnd = await window.ext.hwnd
ws = window.ws = new RPCWebSocket.Client(await window.ext.wsUrl)
main = window.main = await new Sys(ws)
await ws.call(`forms.callFn`, [`${hwnd}.show`])
await ws.call(`view.setIcon`, [hwnd, `https://www.baidu.com/favicon.ico`])
msg = window.msg = await new main.Msg()
tray = window.tray = await new main.Tray()
this.hwnd = tray.hwnd
await tray.icon(`https://www.hongqiye.com/favicon.ico`)
await ws.call(`forms.setVal`, [`${tray.hwnd}.tray.tip`, `tiptiptip`])
await ws.call(`forms.callFn`, [`${tray.hwnd}.tray.pop`, `traytray`, `msgmsgmsg`, 1])
tray.on(`_WM_RBUTTONUP`, async (arg) => {
const [, {bottom, right}] = await ws.call(`win.callFn`, [`getClientRect`, hwnd])
const [, x, y] = await ws.call(`mouse.callFn`, [`getPos`])
console.log(`_WM_RBUTTONUP`, {
bottom,
right,
x,
y,
})
const [newX, newY] = [x - right, y - bottom]
console.log({newX, newY})
await ws.call(`forms.callFn`, [`${hwnd}.show`])
await ws.call(`forms.callFn`, [`${hwnd}.setPos`, newX, newY])
await ws.call(`win.callFn`, [`setActive`, hwnd])
await ws.call(`win.callFn`, [`setForeground`, hwnd])
await ws.call(`win.callFn`, [`setFocus`, hwnd])
await ws.call(`win.callFn`, [`setTopmost`, hwnd, true])
await ws.call(`forms.callFn`, [`${hwnd}.wb.focus`])
})
tray.on(`_WM_LBUTTONUP`, () => {
console.log(`_WM_LBUTTONUP`, )
})
msg.on(`hello`, (...arg) => {
console.log(`hello`, ...arg)
})
msg.emit(`hello`, `ace`)
window.addEventListener('blur', async () => {
document.body.append(`blur`)
await ws.call(`win.callFn`, [`setTopmost`, hwnd, false])
});
window.addEventListener('focus', function() {
document.body.append(`focus`)
});
},
methods: {
msgBox () {
main.msgBox(`hello`, `title`)
},
exit () {
main.exit()
},
exitHwnd () {
tray.exit()
},
},
});
</script>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wll8/sys-shim.git
git@gitee.com:wll8/sys-shim.git
wll8
sys-shim
sys-shim
dev

搜索帮助