Update Shell

This commit is contained in:
Bruce
2025-11-21 12:55:08 +08:00
parent 1674f2c35b
commit ae3771bfdb
33 changed files with 972 additions and 78 deletions

View File

@@ -12,7 +12,13 @@
isIe10: function() { return ext.IEFrame.Version === 10; },
isIe11: function() { return ext.IEFrame.Version === 11; }
},
UI: {},
UI: {
Splash: {
show: function() { ext.System.UI.ShowSplash(); },
fadeAway: function() { ext.System.UI.FadeAwaySplash(); },
fadeOut: function() { ext.System.UI.FadeOutSplash(); }
}
},
String: {
trim: function(str) { return ext.String.Trim(str); },
tolower: function(str) { return ext.String.ToLower(str); },
@@ -23,8 +29,14 @@
compare: function(str1, str2) { return ext.String.NString.Compare(str1, str2); },
empty: function(str) { return ext.String.NString.Empty(str); },
length: function(str) { return ext.String.NString.Length(str); },
},
Resources: {
byname: function(resname) { return ext.System.Resources.GetByName(resname); },
byid: function(resid) { return ext.System.Resources.GetById(resid); },
nameToId: function(resname) { return ext.System.Resources.ToId(resname); },
idToName: function(resid) { return ext.System.Resources.ToName(resid); },
}
}
};
Object.defineProperty(global.Bridge.Frame, "scale", {
get: function() { return ext.IEFrame.Scale; },
set: function(value) { ext.IEFrame.Scale = value; return ext.IEFrame.Scale; }
@@ -32,10 +44,24 @@
Object.defineProperty(global.Bridge.Frame, "version", {
get: function() { return ext.IEFrame.Version; },
});
Object.defineProperty(global.Bridge.Frame, "WindowSize", {
get: function() { return ext.System.UI.WndSize; },
});
Object.defineProperty(global.Bridge.Frame, "ClientSize", {
get: function() { return ext.System.UI.ClientSize; },
});
Object.defineProperty(global.Bridge.UI, "dpiPercent", {
get: function() { return ext.System.UI.DPIPercent; }
});
Object.defineProperty(global.Bridge.UI, "dpi", {
get: function() { return ext.System.UI.DPI; }
});
Object.defineProperty(global.Bridge.UI.Splash, "backcolor", {
get: function() { return ext.System.UI.SplashBackgroundColor; },
});
Object.defineProperty(global.Bridge.UI.Splash, "imageurl", {
get: function() { return ext.System.UI.SplashImage; },
});
})(this);

View File

@@ -24,21 +24,21 @@
break;
}
var images = document.getElementsByTagName('img');
for (var i = 0; i < images.length; i++) {
var img = images[i];
var parent = img.parentElement;
if (!parent) continue;
var parentWidth = parent.offsetWidth;
var parentHeight = parent.offsetHeight;
var scaledWidth = img.naturalWidth * dpiValue;
var scaledHeight = img.naturalHeight * dpiValue;
if (scaledWidth > parentWidth || scaledHeight > parentHeight) {
img.style.transform = 'none';
} else {
img.style.transform = 'scale(' + dpiValue + ')';
}
// console.log('Image:', img, 'Parent Size:', parentWidth, parentHeight, 'Scaled:', scaledWidth, scaledHeight, 'Transform:', img.style.transform);
}
/* for (var i = 0; i < images.length; i++) {
var img = images[i];
var parent = img.parentElement;
if (!parent) continue;
var parentWidth = parent.offsetWidth;
var parentHeight = parent.offsetHeight;
var scaledWidth = img.naturalWidth * dpiValue;
var scaledHeight = img.naturalHeight * dpiValue;
if (scaledWidth > parentWidth || scaledHeight > parentHeight) {
img.style.transform = 'none';
} else {
img.style.transform = 'scale(' + dpiValue + ')';
}
// console.log('Image:', img, 'Parent Size:', parentWidth, parentHeight, 'Scaled:', scaledWidth, scaledHeight, 'Transform:', img.style.transform);
} */
if (IsIeVersionElder && IsIeVersionElder()) {
var contentElements = document.getElementsByClassName('content');
var controlElements = document.getElementsByClassName('control-column-bottom');

11
shared/html/js/init.js Normal file
View File

@@ -0,0 +1,11 @@
(function(global) {
"use strict";
function ready(e) {
function nextstep() {
Resources.processAll();
}
WinJS.UI.processAll().done(nextstep);
}
OnLoad.add(ready);
})(this);

40
shared/html/js/load.js Normal file
View File

@@ -0,0 +1,40 @@
(function() {
"use strict";
var loaddelegate = [];
loaddelegate.push(window.onload);
var elderload = loaddelegate[0];
function onLoad(e) {
for (var i = 0; i < loaddelegate.length; i++) {
if (typeof loaddelegate[i] === "function") {
loaddelegate[i](e);
}
}
}
window.onload = onLoad;
module.exports = {
OnLoad: {
add: function(func) {
if (typeof func === "function") {
for (var i = 0; i < loaddelegate.length; i++) {
if (!i) continue; // 第一个元素必须保留,因为其为原生的 onload 事件
if (loaddelegate[i] === func) {
return;
}
}
loaddelegate.push(func);
}
},
remove: function(func) {
if (!func) return;
for (var i = 0; i < loaddelegate.length; i++) {
if (!i) continue;
if (loaddelegate[i] === func) {
loaddelegate.splice(i, 1);
return;
}
}
}
}
};
})();

View File

@@ -9,6 +9,7 @@
}
var supportPageList = [
"splash",
"loading",
"select",
"preinstall",
"installing",
@@ -22,6 +23,8 @@
"installfailed"
];
var splashBackColor = "";
function setPage(swPageLabel, bIsMulti) {
var page = getPage();
swPageLabel = ("" + (swPageLabel || ""));
@@ -32,6 +35,13 @@
if (page.classList.contains(supportPageList[i])) page.classList.remove(supportPageList[i]);
}
}
if (Bridge.NString.equals(swPageLabel, "splash")) {
if (splashBackColor) {
page.style.backgroundColor = splashBackColor;
}
} else {
page.style.backgroundColor = "";
}
if (page.classList.contains("multiple")) page.classList.remove("multiple");
for (var j = 0; j < supportMulPageList.length; j++) {
if (Bridge.NString.equals(swPageLabel, supportMulPageList[j]) && bIsMulti) {
@@ -60,6 +70,40 @@
setPage(getPageLabel(), bIsMulti);
}
function getSplashPage() {
var page = document.querySelector(".page.splash");
if (!page) return null;
var ret = {};
Object.defineProperty(ret, "background", {
get: function() {
var page = document.querySelector(".page.splash");
return page.style.backgroundColor || splashBackColor;
},
set: function(value) {
splashBackColor = value;
var page = document.querySelector(".page.splash");
if (page) page.style.backgroundColor = value;
}
});
Object.defineProperty(ret, "imagesrc", {
get: function() {
var splashimg = page.querySelector("img.splash");
return splashimg.src;
},
set: function(value) {
var splashimg = page.querySelector("img.splash");
splashimg.src = value;
}
});
Object.defineProperty(ret, "content", {
get: function() {
var content = page.querySelector(".content.splash");
return content;
},
});
return ret;
}
module.exports = {
Page: {}
};
@@ -71,4 +115,7 @@
get: function() { return isMultiPage(); },
set: function(bIsMulti) { setPage(getPageLabel(), bIsMulti); }
});
Object.defineProperty(Page, "splash", {
get: function() { return getSplashPage(); }
});
})(this);

View File

@@ -0,0 +1,40 @@
(function() {
"use strict";
function getAllNodesHasResource() {
var allElements = document.body.getElementsByTagName('*');
var result = [];
for (var i = 0; i < allElements.length; i++) {
var el = allElements[i];
var tag = el.tagName.toLowerCase();
if (tag === 'script' || tag === 'style' || tag === 'link') {
continue;
}
var byName = el.getAttribute('data-res-byname');
var byId = el.getAttribute('data-res-byid');
if ((byName && !Bridge.NString.empty(byName)) || (byId && parseInt(byId, 10) > 0)) {
result.push(el);
}
}
return result; // 返回符合条件的元素数组
}
module.exports = {
Resources: {
processAll: function() {
var nodes = getAllNodesHasResource();
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].hasAttribute('data-res-byname')) {
var resName = nodes[i].getAttribute('data-res-byname');
nodes[i].textContent = Bridge.Resources.byname(resName);
} else if (nodes[i].hasAttribute('data-res-byid')) {
var resId = parseInt(nodes[i].getAttribute('data-res-byid'), 10);
nodes[i].textContent = Bridge.Resources.byid(resId);
} else {
nodes[i].textContent = "";
}
}
}
}
};
})();