自动升级: - 版本变量注入 (-ldflags -X main.version) - 远程 version.json 检查 + 弹窗提示(非强制右下角/强制居中) - updater.exe 嵌入主程序, 运行时释放到临时目录 - 下载+SHA256校验+备份+替换+回滚 全流程 - 托盘菜单"检查更新" 稳定性: - WorkerW 重建自动检测(每10s)并重新嵌入 - 左键托盘点击防抖 - 设置窗口已打开时正确前置 优化: - 知识卡片prompt改为面向开发者的硬核内容 - 配置目录统一到 ~/.u-desktop/ - 设置窗口WebView2数据目录改为configDir下
127 lines
2.9 KiB
HTML
127 lines
2.9 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: "Microsoft YaHei", sans-serif;
|
|
background: transparent;
|
|
color: #e0e0e0;
|
|
overflow: hidden;
|
|
user-select: none;
|
|
}
|
|
.container {
|
|
background: rgba(30, 30, 46, 0.95);
|
|
backdrop-filter: blur(20px);
|
|
border-radius: 12px;
|
|
border: 1px solid rgba(255,255,255,0.08);
|
|
padding: 20px 24px;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.version-tag {
|
|
color: #89b4fa;
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
margin-bottom: 12px;
|
|
}
|
|
.notes {
|
|
font-size: 13px;
|
|
color: #a0a0b8;
|
|
line-height: 1.8;
|
|
white-space: pre-line;
|
|
flex: 1;
|
|
margin-bottom: 16px;
|
|
}
|
|
.meta {
|
|
font-size: 12px;
|
|
color: #666;
|
|
margin-bottom: 14px;
|
|
}
|
|
.btn-row {
|
|
display: flex;
|
|
gap: 10px;
|
|
justify-content: flex-end;
|
|
}
|
|
.btn {
|
|
padding: 7px 20px;
|
|
border-radius: 8px;
|
|
border: none;
|
|
font-size: 13px;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-family: inherit;
|
|
}
|
|
.btn-primary {
|
|
background: #89b4fa;
|
|
color: #1e1e2e;
|
|
font-weight: 600;
|
|
}
|
|
.btn-primary:hover { background: #74c7ec; }
|
|
.btn-secondary {
|
|
background: rgba(255,255,255,0.06);
|
|
color: #a0a0b8;
|
|
border: 1px solid rgba(255,255,255,0.1);
|
|
}
|
|
.btn-secondary:hover { background: rgba(255,255,255,0.1); }
|
|
.force-layout {
|
|
justify-content: center;
|
|
text-align: center;
|
|
}
|
|
.force-layout .version-tag { font-size: 18px; }
|
|
.force-layout .btn-row { justify-content: center; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container" id="app">
|
|
<div class="version-tag" id="versionTag"></div>
|
|
<div class="notes" id="notes"></div>
|
|
<div class="meta" id="meta"></div>
|
|
<div class="btn-row" id="btnRow"></div>
|
|
</div>
|
|
<script>
|
|
const info = JSON.parse(window.getUpdateInfo());
|
|
const container = document.getElementById('app');
|
|
const versionTag = document.getElementById('versionTag');
|
|
const notes = document.getElementById('notes');
|
|
const meta = document.getElementById('meta');
|
|
const btnRow = document.getElementById('btnRow');
|
|
|
|
versionTag.textContent = '发现新版本 v' + info.version;
|
|
notes.textContent = info.releaseNotes || '';
|
|
|
|
function formatSize(bytes) {
|
|
if (!bytes) return '';
|
|
if (bytes >= 1048576) return (bytes / 1048576).toFixed(1) + 'MB';
|
|
if (bytes >= 1024) return (bytes / 1024).toFixed(1) + 'KB';
|
|
return bytes + 'B';
|
|
}
|
|
|
|
if (info.force) {
|
|
container.classList.add('force-layout');
|
|
if (info.size) {
|
|
const sec = info.size > 5242880 ? '~30秒' : '~10秒';
|
|
meta.textContent = '大小: ' + formatSize(info.size) + ' | 预计用时: ' + sec;
|
|
}
|
|
btnRow.innerHTML = '<button class="btn btn-primary" onclick="doUpdate()">立即升级</button>';
|
|
} else {
|
|
btnRow.innerHTML =
|
|
'<button class="btn btn-secondary" onclick="skip()">稍后</button>' +
|
|
'<button class="btn btn-primary" onclick="doUpdate()">立即升级</button>';
|
|
}
|
|
|
|
function doUpdate() {
|
|
window.startUpdate();
|
|
window.close();
|
|
}
|
|
|
|
function skip() {
|
|
window.skipUpdate();
|
|
window.close();
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|