mirror of
https://github.com/modernw/App-Installer-For-Windows-8.x-Reset.git
synced 2026-06-14 03:16:38 +10:00
Update
This commit is contained in:
+1499
-1685
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,21 @@ var MBRET = {
|
||||
Object.freeze(MBFLAGS);
|
||||
Object.freeze(MBRET);
|
||||
|
||||
function GetLocaleStringFromResId(resId) { return Bridge.Resources.byid(resId); }
|
||||
(function(global) {
|
||||
try {
|
||||
var storage = Bridge.External.Storage;
|
||||
var path = storage.path;
|
||||
var root = path.getDir(path.program);
|
||||
var respath = path.combine(root, "reslib.dll");
|
||||
var res = Bridge.Resources;
|
||||
global.respath = respath;
|
||||
global.getPublicRes = function(resId) {
|
||||
return res.fromfile(respath, resId);
|
||||
}
|
||||
} catch (e) {}
|
||||
})(this);
|
||||
|
||||
function GetLocaleStringFromResId(resId) { try { return getPublicRes(resId); } catch (e) {} }
|
||||
var msgboxResult = {};
|
||||
|
||||
function MessageBox(_lpText, _lpCaption, _uType, _objColor) {
|
||||
@@ -115,9 +129,29 @@ function MessageBoxForJS(_lpText, _lpCaption, _uType, _objColor, _callback) {
|
||||
msgcaption.appendChild(msgtitle);
|
||||
}
|
||||
}
|
||||
if (_lpText instanceof HTMLElement) {
|
||||
_lpText.classList.add("notice-text");
|
||||
msgcontent.appendChild(_lpText);
|
||||
if (_lpText instanceof HTMLElement || _lpText instanceof HTMLDivElement || typeof _lpText !== "string") {
|
||||
try {
|
||||
_lpText.classList.add("notice-text");
|
||||
msgcontent.appendChild(_lpText);
|
||||
} catch (e) {
|
||||
if (!IsBlackLabel(_lpText)) {
|
||||
var msgtext = document.createElement("p");
|
||||
msgtext.textContent = _lpText;
|
||||
msgtext.classList.add("notice-text");
|
||||
if (IsBlackLabel(_lpCaption)) {
|
||||
msgtext.style.marginTop = "0";
|
||||
}
|
||||
msgcontent.appendChild(msgtext);
|
||||
} else {
|
||||
var msgtext = document.createElement("p");
|
||||
msgtext.innerText = "";
|
||||
msgtext.classList.add("notice-text");
|
||||
if (IsBlackLabel(_lpCaption)) {
|
||||
msgtext.style.marginTop = "0";
|
||||
}
|
||||
msgcontent.appendChild(msgtext);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!IsBlackLabel(_lpText)) {
|
||||
var msgtext = document.createElement("p");
|
||||
@@ -330,7 +364,7 @@ MsgBoxObj.prototype._internalCallback = function(returnValue) {
|
||||
* @param {string} swTitle 标题
|
||||
* @param {MBFLAGS} uType 标志,使用 MBFLAGS 常量
|
||||
* @param {string} swColor 背景颜色文本。
|
||||
* @returns
|
||||
* @returns {Promise}
|
||||
*/
|
||||
function messageBoxAsync(swText, swTitle, uType, swColor, pfCallback) {
|
||||
if (typeof Promise === "undefined") {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
max-height: 19px !important;
|
||||
position: relative;
|
||||
display: block;
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.toggle-switch>input[type="checkbox"] {
|
||||
|
||||
@@ -29,6 +29,34 @@
|
||||
<script type="text/javascript" src="appinstaller/preinit.js"></script>
|
||||
<script type="text/javascript" src="appinstaller/items.js"></script>
|
||||
<script type="text/javascript" src="appinstaller/init.js"></script>
|
||||
<style>
|
||||
.markdown-style {
|
||||
font-weight: normal;
|
||||
font-size: 16px;
|
||||
-ms-user-select: element;
|
||||
}
|
||||
|
||||
.markdown-style h1 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.markdown-style h2 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.markdown-style p {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.markdown-style ul {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.markdown-style li {
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="../subpage.css">
|
||||
<script type="text/javascript" src="preinit.js"></script>
|
||||
<script type="text/javascript" src="initsame.js"></script>
|
||||
<script type="text/javascript" src="../../libs/markdown.js"></script>
|
||||
<script>
|
||||
try {
|
||||
window.parent.setItemHighlight("about");
|
||||
@@ -53,6 +54,243 @@
|
||||
}
|
||||
document.getElementById("current-version").textContent = window.currver;
|
||||
</script>
|
||||
<p id="about-copyright"></p>
|
||||
<script>
|
||||
(function() {
|
||||
var storage = Bridge.External.Storage;
|
||||
var path = storage.path;
|
||||
var verinfo = JSON.parse(Bridge.External.getVersionInfoToJSON(exepath));
|
||||
var aboutCopyright = document.getElementById("about-copyright");
|
||||
aboutCopyright.textContent = verinfo.LegalCopyright;
|
||||
})();
|
||||
</script>
|
||||
<p data-res-fromfile="publicRes (133)"></p>
|
||||
<p>
|
||||
<a href="https://github.com/modernw/App-Installer-For-Windows-8.x-Reset" target="_blank" data-res-fromfile="publicRes (134)"></a>
|
||||
</p>
|
||||
<p>
|
||||
<a id="about-project-description" data-res-fromfile="publicRes(135)"></a>
|
||||
</p>
|
||||
<p>
|
||||
<a id="about-update-log" data-res-fromfile="publicRes(136)"></a>
|
||||
</p>
|
||||
<p>
|
||||
<a id="about-eula" data-res-fromfile="publicRes(137)"></a>
|
||||
</p>
|
||||
<p data-res-fromfile="publicRes (138)"></p>
|
||||
<ul>
|
||||
<li><a href="https://github.com/chausner/PriTools" target="_blank">chausner/PriTools</a></li>
|
||||
<li><a href="https://pugixml.org/" target="_blank">pugixml</a></li>
|
||||
<li><a href="https://rapidjson.org/" target="_blank">RapidJSON</a></li>
|
||||
<li><a href="https://github.com/winjs/winjs" target="_blank">WinJS</a></li>
|
||||
<li><a href="https://github.com/evilstreak/markdown-js" target="_blank">markdown.js</a></li>
|
||||
</ul>
|
||||
<script>
|
||||
(function() {
|
||||
var aboutUpdateLog = document.getElementById("about-update-log");
|
||||
var aboutEula = document.getElementById("about-eula");
|
||||
var aboutProjectDescription = document.getElementById("about-project-description");
|
||||
var eventutil = Windows.UI.Event.Util;
|
||||
var storage = Bridge.External.Storage;
|
||||
var path = storage.path;
|
||||
var strres = Bridge.External.StringResources;
|
||||
var jslist = [
|
||||
"js\\module.js",
|
||||
"js\\polyfill-ie.js",
|
||||
"js\\bridge.js",
|
||||
"js\\dpimodes.js"
|
||||
];
|
||||
var libroot = path.combine(path.root, "html");
|
||||
/**
|
||||
* 异步显示消息框,返回一个 Promise 对象。
|
||||
* @param {string | HTMLElement} swText 内容
|
||||
* @param {string} swTitle 标题
|
||||
* @param {MBFLAGS} uType 标志,使用 MBFLAGS 常量
|
||||
* @param {string} swColor 背景颜色文本。
|
||||
* @returns
|
||||
*/
|
||||
var msgbox = function() {};
|
||||
var MsgBox = function() {};
|
||||
if (typeof window.parent !== "undefined") {
|
||||
msgbox = window.parent.messageBoxAsync;
|
||||
MsgBox = window.parent.MsgBoxObj;
|
||||
} else {
|
||||
msgbox = messageBoxAsync;
|
||||
MsgBox = MsgBoxObj;
|
||||
}
|
||||
eventutil.addEvent(aboutUpdateLog, "click", function() {
|
||||
var content = document.createElement("div");
|
||||
var progressDisplay = document.createElement("div");
|
||||
var progress = document.createElement("progress");
|
||||
var retryBtn = document.createElement("button");
|
||||
retryBtn.textContent = getPublicRes(132);
|
||||
retryBtn.style.display = "none";
|
||||
retryBtn.style.margin = "10px 0";
|
||||
progress.classList.add("win-ring");
|
||||
progress.style.color = "white";
|
||||
var state = document.createElement("span");
|
||||
progress.style.marginRight = "5px";
|
||||
progressDisplay.appendChild(progress);
|
||||
progressDisplay.appendChild(state);
|
||||
progressDisplay.setAttribute("style", "display: flex; flex-direction: row;");
|
||||
content.appendChild(progressDisplay);
|
||||
content.appendChild(retryBtn);
|
||||
content.style.margin = "10px 0";
|
||||
content.style.maxHeight = "100%";
|
||||
content.style.width = "100%";
|
||||
progressDisplay.style.width = "100%";
|
||||
content.style.boxSizing = "border-box";
|
||||
progressDisplay.style.boxSizing = "border-box";
|
||||
content.classList.add("markdown-style");
|
||||
msgbox(content, getPublicRes(136));
|
||||
var fetchFunc = function() {
|
||||
retryBtn.style.display = "none";
|
||||
state.textContent = getPublicRes(139);
|
||||
progress.style.display = "";
|
||||
WinJS.xhr({
|
||||
url: "https://api.github.com/repos/modernw/App-Installer-For-Windows-8.x-Reset/releases/tags/" + currver,
|
||||
}).done(
|
||||
function(resp) {
|
||||
var json = JSON.parse(resp.responseText);
|
||||
var body = json.body;
|
||||
content.innerHTML = markdown.toHTML(body);
|
||||
content.style.height = "300px";
|
||||
content.style.maxHeight = "100%";
|
||||
},
|
||||
function(err) {
|
||||
progress.style.display = "none";
|
||||
retryBtn.style.display = "block";
|
||||
var msg = {
|
||||
message: ""
|
||||
};
|
||||
try {
|
||||
msg = JSON.parse(err.responseText);
|
||||
} catch (e) {
|
||||
msg = err.responseText;
|
||||
}
|
||||
state.textContent = getPublicRes(140) + (msg.message.length > 0 ? ": " + msg.message : "");
|
||||
}
|
||||
);
|
||||
};
|
||||
retryBtn.addEventListener("click", function() {
|
||||
fetchFunc();
|
||||
});
|
||||
fetchFunc();
|
||||
});
|
||||
eventutil.addEvent(aboutProjectDescription, "click", function() {
|
||||
function decodeBase64(base64) {
|
||||
// GitHub 的 content 有换行,必须清理
|
||||
base64 = base64.replace(/\s/g, "");
|
||||
return atob(base64);
|
||||
}
|
||||
var content = document.createElement("div");
|
||||
var progressDisplay = document.createElement("div");
|
||||
var progress = document.createElement("progress");
|
||||
var retryBtn = document.createElement("button");
|
||||
retryBtn.textContent = getPublicRes(132);
|
||||
retryBtn.style.display = "none";
|
||||
retryBtn.style.margin = "10px 0";
|
||||
progress.classList.add("win-ring");
|
||||
progress.style.color = "white";
|
||||
var state = document.createElement("span");
|
||||
progress.style.marginRight = "5px";
|
||||
progressDisplay.appendChild(progress);
|
||||
progressDisplay.appendChild(state);
|
||||
progressDisplay.setAttribute("style", "display: flex; flex-direction: row;");
|
||||
content.appendChild(progressDisplay);
|
||||
content.appendChild(retryBtn);
|
||||
content.style.margin = "10px 0";
|
||||
content.style.maxHeight = "100%";
|
||||
content.style.whiteSpace = "normal";
|
||||
content.style.width = "100%";
|
||||
progressDisplay.style.width = "100%";
|
||||
content.style.boxSizing = "border-box";
|
||||
content.classList.add("markdown-style");
|
||||
progressDisplay.style.boxSizing = "border-box";
|
||||
msgbox(content, getPublicRes(135));
|
||||
var fetchFunc = function() {
|
||||
retryBtn.style.display = "none";
|
||||
state.textContent = getPublicRes(141);
|
||||
progress.style.display = "";
|
||||
WinJS.xhr({
|
||||
url: "https://api.github.com/repos/modernw/App-Installer-For-Windows-8.x-Reset/readme",
|
||||
}).done(
|
||||
function(resp) {
|
||||
var json = JSON.parse(resp.responseText);
|
||||
var decoderesult = decodeBase64(json.content);
|
||||
content.innerHTML = decoderesult;
|
||||
},
|
||||
function(err) {
|
||||
progress.style.display = "none";
|
||||
retryBtn.style.display = "block";
|
||||
var msg = {
|
||||
message: ""
|
||||
};
|
||||
try {
|
||||
msg = JSON.parse(err.responseText);
|
||||
} catch (e) {
|
||||
msg = err.responseText;
|
||||
}
|
||||
state.textContent = getPublicRes(142) + (msg.message.length > 0 ? ": " + msg.message : "");
|
||||
}
|
||||
);
|
||||
};
|
||||
retryBtn.addEventListener("click", function() {
|
||||
fetchFunc();
|
||||
});
|
||||
fetchFunc();
|
||||
});
|
||||
eventutil.addEvent(aboutEula, "click", function() {
|
||||
var eulaFilePath = path.combine(path.root, "license");
|
||||
eulaFilePath = path.combine(eulaFilePath, strres.getString("license"))
|
||||
var content = document.createElement("iframe");
|
||||
content.onload = function() {
|
||||
try {
|
||||
var winjsurl = path.combine(libroot, "libs\\winjs\\1.0\\css\\ui-light.css");
|
||||
var style = document.createElement("link");
|
||||
style.rel = "stylesheet";
|
||||
style.href = winjsurl;
|
||||
content.contentWindow.document.head.insertBefore(style, content.contentWindow.document.head.firstChild);
|
||||
for (var i = 0; i < jslist.length; i++) {
|
||||
var jsfile = path.combine(libroot, jslist[i]);
|
||||
var script = document.createElement("script");
|
||||
script.src = jsfile;
|
||||
content.contentWindow.document.head.appendChild(script);
|
||||
}
|
||||
content.contentWindow.document.body.style.overflowY = "auto";
|
||||
content.contentWindow.Windows.UI.DPI.mode = 1;
|
||||
} catch (e) {}
|
||||
};
|
||||
content.src = eulaFilePath;
|
||||
content.style.margin = "10px 0";
|
||||
var text = document.createElement("div");
|
||||
text.style.width = "100%";
|
||||
text.style.height = "300px";
|
||||
text.style.overflowY = "hidden";
|
||||
content.style.width = "100%";
|
||||
content.style.height = "100%";
|
||||
content.style.maxHeight = "100%";
|
||||
text.appendChild(content);
|
||||
var dlg = new MsgBox();
|
||||
dlg.text = text;
|
||||
dlg.title = getPublicRes(143);
|
||||
dlg.show();
|
||||
setTimeout(function() {
|
||||
var element = dlg.getElement();
|
||||
var body = element.querySelector(".notice-body");
|
||||
var title = element.querySelector(".notice-title");
|
||||
var content = element.querySelector(".notice-text");
|
||||
var ctrls = element.querySelector(".notice-controls");
|
||||
element.classList.remove("win-ui-dark");
|
||||
element.classList.add("win-ui-light");
|
||||
title.style.color = "black";
|
||||
content.style.color = "black";
|
||||
body.style.backgroundColor = "white";
|
||||
body.style.color = "black";
|
||||
}, 0);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -159,6 +159,28 @@
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
<div class="win-settings-section">
|
||||
<br>
|
||||
<label class="win-label" for="check-app-has-installed" id="check-app-has-installed-label" data-res-fromfile="publicRes (144)"></label>
|
||||
<script>
|
||||
(function() {
|
||||
"use strict";
|
||||
var label = document.getElementById("check-app-has-installed-label");
|
||||
var toggle = new Toggle();
|
||||
toggle.create();
|
||||
toggle.parent = label.parentNode;
|
||||
toggle.showlabel = true;
|
||||
var winjsres = Bridge.External.WinJsStringRes;
|
||||
toggle.setStatusText(winjsres.getString("ms-resource://Microsoft.WinJS.1.0/ui/on"), winjsres.getString("ms-resource://Microsoft.WinJS.1.0/ui/off"));
|
||||
toggle.inputId = "check-app-has-installed";
|
||||
var ini = Bridge.External.Config.GetConfig();
|
||||
toggle.addEventListener("change", function() {
|
||||
ini.set("Settings", "AppInstaller:CheckPackageIsIntalled", toggle.checked);
|
||||
});
|
||||
toggle.checked = parseBool(ini.getSection("Settings").getKey("AppInstaller:CheckPackageIsIntalled").value);
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -81,7 +81,8 @@
|
||||
}
|
||||
|
||||
#newversion-desc {
|
||||
white-space: pre-wrap;
|
||||
/*white-space: pre-wrap;*/
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
#newversion-desc img {
|
||||
@@ -313,6 +314,13 @@
|
||||
var newVersionDescShowOrHide = document.getElementById("newversion-desc-showall-hide");
|
||||
var checkUpdateLoading = document.getElementById("loading-amine");
|
||||
var stopProcess = false;
|
||||
var tbpFlags = {
|
||||
error: 4,
|
||||
indeterminate: 1,
|
||||
noProgress: 0,
|
||||
normal: 2,
|
||||
paused: 8
|
||||
};
|
||||
|
||||
function newVersionBlockSizeChanged() {
|
||||
if (stopProcess) return;
|
||||
@@ -426,20 +434,22 @@
|
||||
var path = storage.path;
|
||||
stopProcess = true;
|
||||
newVersionBlock.parentNode.style.height = "0px";
|
||||
checkUpdateText.textContent = getPublicRes(117);
|
||||
checkUpdateText.textContent = getPublicRes(118);
|
||||
progress.style.display = "";
|
||||
checkUpdateBlock.style.height = checkUpdateBlock.scrollHeight + "px";
|
||||
var anime = Windows.UI.Animation;
|
||||
var strutil = Bridge.External.String;
|
||||
var tbputil = Bridge.External;
|
||||
|
||||
function setError(error) {
|
||||
//console.error("download error", error);
|
||||
checkUpdateText.textContent = strutil.format(getPublicRes(119), error.reason);
|
||||
progress.style.display = "none";
|
||||
self.disabled = false;
|
||||
self.textContent = "重试";
|
||||
self.textContent = getPublicRes(132);
|
||||
window.parent.setDisabledForOperation(false);
|
||||
checkUpdateBlock.style.height = checkUpdateBlock.scrollHeight + "px";
|
||||
tbputil.tbState = tbpFlags.error;
|
||||
}
|
||||
|
||||
function setException(e) {
|
||||
@@ -447,6 +457,7 @@
|
||||
checkUpdateText.textContent = strutil.format(getPublicRes(119), e.message);
|
||||
window.parent.setDisabledForOperation(false);
|
||||
checkUpdateBlock.style.height = checkUpdateBlock.scrollHeight + "px";
|
||||
tbputil.tbState = tbpFlags.error;
|
||||
}
|
||||
|
||||
function setComplete(complete) {
|
||||
@@ -457,16 +468,18 @@
|
||||
var settingsapppath = path.combine(path.root, "settings.exe");
|
||||
window.parent.setDisabledForOperation(false);
|
||||
var process = Bridge.External.Process;
|
||||
process.kill(appinstallerpath, true, false);
|
||||
checkUpdateBlock.style.height = checkUpdateBlock.scrollHeight + "px";
|
||||
tbputil.tbState = tbpFlags.noProgress;
|
||||
process.kill(appinstallerpath, true, false);
|
||||
createProcess(cmdline, tempfile, wndDisplayMode.showNormal, false);
|
||||
process.kill(settingsapppath, true, false);
|
||||
//Bridge.External.closeWindow();
|
||||
}
|
||||
progress.value = 0;
|
||||
anime.loading(checkUpdateLoading, true);
|
||||
var tempdir = path.expand("%temp%");
|
||||
var tempfile = path.combine(tempdir, "InstallerSetup.exe");
|
||||
tbputil.tbProgress = 0;
|
||||
tbputil.tbState = tbpFlags.normal;
|
||||
downloadFile(downloadUrl, tempfile).done(
|
||||
function(complete) {
|
||||
anime.loading(checkUpdateLoading, false);
|
||||
@@ -482,6 +495,7 @@
|
||||
progress.value = prog.progress;
|
||||
checkUpdateText.textContent = strutil.format(getPublicRes(121), Math.floor(prog.progress), formatBytesSize(prog.received), formatBytesSize(prog.total));
|
||||
checkUpdateBlock.style.height = checkUpdateBlock.scrollHeight + "px";
|
||||
tbputil.tbProgress = prog.progress;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user