-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
618 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
## v0.4.0 | ||
|
||
- 新增:工单反馈功能,便于解决问题 | ||
- 新增:应用 loading 窗口 | ||
- 优化:请求异常时增加错误码 | ||
|
||
## v0.3.0 | ||
|
||
- 新增:支持设置投屏视频比特率和刷新率 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const icons = { | ||
success: '<svg t="1733817409678" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1488" width="1024" height="1024"><path d="M512 832c-176.448 0-320-143.552-320-320S335.552 192 512 192s320 143.552 320 320-143.552 320-320 320m0-704C300.256 128 128 300.256 128 512s172.256 384 384 384 384-172.256 384-384S723.744 128 512 128" fill="#FFF" p-id="1489"></path><path d="M619.072 429.088l-151.744 165.888-62.112-69.6a32 32 0 1 0-47.744 42.624l85.696 96a32 32 0 0 0 23.68 10.688h0.192c8.96 0 17.536-3.776 23.616-10.4l175.648-192a32 32 0 0 0-47.232-43.2" fill="#FFF" p-id="1490"></path></svg>', | ||
error: '<svg t="1733817396560" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1326" width="1024" height="1024"><path d="M512 128C300.8 128 128 300.8 128 512s172.8 384 384 384 384-172.8 384-384S723.2 128 512 128zM512 832c-179.2 0-320-140.8-320-320s140.8-320 320-320 320 140.8 320 320S691.2 832 512 832z" fill="#FFF" p-id="1327"></path><path d="M672 352c-12.8-12.8-32-12.8-44.8 0L512 467.2 396.8 352C384 339.2 364.8 339.2 352 352S339.2 384 352 396.8L467.2 512 352 627.2c-12.8 12.8-12.8 32 0 44.8s32 12.8 44.8 0L512 556.8l115.2 115.2c12.8 12.8 32 12.8 44.8 0s12.8-32 0-44.8L556.8 512l115.2-115.2C684.8 384 684.8 364.8 672 352z" fill="#FFF" p-id="1328"></path></svg>', | ||
info: '<svg t="1733992721464" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1357" width="1024" height="1024"><path d="M512 898.71874973C299.30468777 898.71874973 125.28125027 724.69531223 125.28125027 512S299.30468777 125.28125027 512 125.28125027s386.71874973 174.0234375 386.71874973 386.71874973-174.0234375 386.71874973-386.71874973 386.71874973z m0-696.09375c-170.15625027 0-309.37500027 139.21875-309.37500027 309.37500027 0 170.15625027 139.21875 309.37500027 309.37500027 309.37500027 170.15625027 0 309.37500027-139.21875 309.37500027-309.37500027 0-170.15625027-139.21875-309.37500027-309.37500027-309.37500027z" fill="#FFFFFF" p-id="1358"></path><path d="M512 746.59765652a37.96875 37.96875 0 0 1-38.67187473-38.67187554v-221.6953125c0-21.9375 16.76953125-38.67187473 38.67187473-38.67187473 21.90234348 0 38.67187473 16.73437473 38.67187473 38.67187473v221.6953125c0 21.9375-16.76953125 38.67187473-38.67187473 38.67187554zM512 390.81640625a37.96875 37.96875 0 0 1-38.67187473-38.67187473V316.07421902c0-21.9375 16.76953125-38.67187473 38.67187473-38.67187554 21.90234348 0 38.67187473 16.73437473 38.67187473 38.67187554v36.0703125c0 21.9375-18.03515625 38.67187473-38.67187473 38.67187473z" fill="#FFFFFF" p-id="1359"></path></svg>', | ||
loading: ` | ||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"> | ||
<rect fill="#FFFFFF" x="21.5" y="21.5" width="25" height="25" rx="3" ry="3"> | ||
<animate attributeName="x" calcMode="linear" values="21.5;53.5;53.5;53.5;53.5;21.5;21.5;21.5;21.5" keyTimes="0;0.083;0.25;0.333;0.5;0.583;0.75;0.833;1" dur="1.5" begin="-1.375s" repeatCount="indefinite"></animate> | ||
<animate attributeName="y" calcMode="linear" values="21.5;53.5;53.5;53.5;53.5;21.5;21.5;21.5;21.5" keyTimes="0;0.083;0.25;0.333;0.5;0.583;0.75;0.833;1" dur="1.5" begin="-1s" repeatCount="indefinite"></animate> | ||
</rect> | ||
<rect fill="#FFFFFF" x="21.5" y="53.5" width="25" height="25" rx="3" ry="3"> | ||
<animate attributeName="x" calcMode="linear" values="21.5;53.5;53.5;53.5;53.5;21.5;21.5;21.5;21.5" keyTimes="0;0.083;0.25;0.333;0.5;0.583;0.75;0.833;1" dur="1.5" begin="-0.875s" repeatCount="indefinite"></animate> | ||
<animate attributeName="y" calcMode="linear" values="21.5;53.5;53.5;53.5;53.5;21.5;21.5;21.5;21.5" keyTimes="0;0.083;0.25;0.333;0.5;0.583;0.75;0.833;1" dur="1.5" begin="-0.5s" repeatCount="indefinite"></animate> | ||
</rect> | ||
<rect fill="#FFFFFF" x="53.5" y="42.919" width="25" height="25" rx="3" ry="3"> | ||
<animate attributeName="x" calcMode="linear" values="21.5;53.5;53.5;53.5;53.5;21.5;21.5;21.5;21.5" keyTimes="0;0.083;0.25;0.333;0.5;0.583;0.75;0.833;1" dur="1.5" begin="-0.375s" repeatCount="indefinite"></animate> | ||
<animate attributeName="y" calcMode="linear" values="21.5;53.5;53.5;53.5;53.5;21.5;21.5;21.5;21.5" keyTimes="0;0.083;0.25;0.333;0.5;0.583;0.75;0.833;1" dur="1.5" begin="0s" repeatCount="indefinite"></animate> | ||
</rect> | ||
</svg>`, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
import {BrowserWindow} from "electron"; | ||
import {AppsMain} from "./main"; | ||
import {icons} from "./icons"; | ||
|
||
export const makeLoading = (msg: string, options?: { | ||
timeout?: number, | ||
percentAuto?: boolean, | ||
percentTotalSeconds?: number, | ||
}): { | ||
close: () => void, | ||
percent: (value: number) => void | ||
} => { | ||
|
||
options = Object.assign({ | ||
percentAuto: false, | ||
percentTotalSeconds: 30, | ||
timeout: 0 | ||
}, options) | ||
|
||
if (options.timeout === 0) { | ||
options.timeout = 60 * 10 * 1000 | ||
} | ||
// console.log('options', options) | ||
|
||
const display = AppsMain.getCurrentScreenDisplay() | ||
// console.log('xxxx', primaryDisplay); | ||
const width = display.workArea.width | ||
const height = 60 | ||
const icon = icons.loading | ||
|
||
const win = new BrowserWindow({ | ||
height, | ||
width, | ||
x: 0, | ||
y: 0, | ||
modal: false, | ||
frame: false, | ||
alwaysOnTop: true, | ||
center: false, | ||
transparent: true, | ||
hasShadow: false, | ||
show: false, | ||
focusable: false, | ||
skipTaskbar: true, | ||
}) | ||
const htmlContent = ` | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
html,body{ | ||
height: 100vh; | ||
margin: 0; | ||
padding: 0; | ||
background: rgba(0, 0, 0, 0.4); | ||
color: #FFFFFF; | ||
} | ||
.message-view { | ||
height: 100vh; | ||
display:flex; | ||
text-align:center; | ||
padding:0 10px; | ||
position:relative; | ||
} | ||
.message-view #message{ | ||
margin: auto; | ||
font-size: 16px; | ||
display: inline-block; | ||
line-height: 30px; | ||
white-space: nowrap; | ||
} | ||
.message-view #message .icon{ | ||
width: 30px; | ||
height: 30px; | ||
display:inline-block; | ||
margin-right: 5px; | ||
vertical-align: top; | ||
} | ||
.message-view #percent{ | ||
position: absolute; | ||
bottom: 5px; | ||
left: 5px; | ||
right: 5px; | ||
height: 5px; | ||
border-radius: 5px; | ||
background: rgba(255, 255, 255, 0.4); | ||
overflow: hidden; | ||
display:none; | ||
} | ||
.message-view #percent .value{ | ||
border-radius: 5px; | ||
height: 100%; | ||
width: 0%; | ||
background: #FFFFFF; | ||
} | ||
::-webkit-scrollbar { | ||
width: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="message-view"> | ||
<div id="message">${icon}${msg}</div> | ||
<div id="percent"> | ||
<div class="value"></div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
`; | ||
|
||
const encodedHTML = encodeURIComponent(htmlContent); | ||
let percentAutoTimer = null | ||
win.loadURL(`data:text/html;charset=UTF-8,${encodedHTML}`); | ||
win.on('ready-to-show', async () => { | ||
const width = Math.ceil(await win.webContents.executeJavaScript(`(()=>{ | ||
const message = document.getElementById('message'); | ||
const width = message.scrollWidth; | ||
return width; | ||
})()`)) | ||
win.setSize(width + 20, height) | ||
const x = display.workArea.x + (display.workArea.width / 2) - ((width + 20) / 2) | ||
const y = display.workArea.y + (display.workArea.height * 2 / 3) | ||
win.setPosition(Math.floor(x), Math.floor(y)) | ||
win.show() | ||
if (options.percentAuto) { | ||
let percent = 0 | ||
percentAutoTimer = setInterval(() => { | ||
percent += 0.01 | ||
if (percent >= 1) { | ||
clearInterval(percentAutoTimer) | ||
return | ||
} | ||
controller.percent(percent) | ||
}, options.percentTotalSeconds * 1000 / 100) | ||
} | ||
// win.webContents.openDevTools({ | ||
// mode: 'detach' | ||
// }) | ||
}) | ||
const winCloseTimer = setTimeout(() => { | ||
win.close() | ||
clearTimeout(winCloseTimer) | ||
}, options.timeout) | ||
const controller = { | ||
close: () => { | ||
win.close() | ||
clearTimeout(winCloseTimer) | ||
if (percentAutoTimer) { | ||
clearInterval(percentAutoTimer) | ||
} | ||
}, | ||
percent: (value: number) => { | ||
const percent = 100 * value | ||
win.webContents.executeJavaScript(`(()=>{ | ||
const percent = document.querySelector('#percent'); | ||
const percentValue = document.querySelector('#percent .value'); | ||
percent.style.display = 'block'; | ||
percentValue.style.width = '${percent}%'; | ||
})()`) | ||
} | ||
} | ||
return controller | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.