MediaWiki:Gadget-VectorThemeLoader.js:修订间差异

区分新旧版vector皮肤
(新的主题切换功能)
 
(区分新旧版vector皮肤)
//! https://github.com/mcbbs-wiki/mcbbs-wiki-widget-repo/tree/master/widget/VectorThemeLoader
addStyle(widget_t_default);
var isLegacy = document.body.classList.contains("skin-vector-legacy");
var themeMap = isLegacy ? {
book: {
name: "仿MCBBS书页风格",
common: "MediaWiki:Vector-Legacy-Book.css",
default: {
name: "夏季主题",
nether: { name: "下界主题", css: "MediaWiki:Vector-Book-Nether.css" },
winter: { name: "冬季主题", css: "MediaWiki:Vector-Book-Winter.css" }
},
legacy: {
name: "",
common: "MediaWiki:Vector-Legacy-Book.css",
default: { name: "夏季主题", css: "MediaWiki:Vector-Book-Summer.css" },
other: {
nether: { name: "下界主题", css: "MediaWiki:Vector-Book-Nether.css" },
winter: { name: "冬季主题", css: "MediaWiki:Vector-Book-Winter.css" }
}
}
},
} : {
otherv4: {
name: "仿MCBBS v4风格",
common: "MediaWiki:Vector-Legacy-BookV4.css",
default: { name: "夏季主题默认风格", css: "MediaWiki:Vector-Book-SummerV4.css" },
legacyother: {}
}
};
var defaultStyle = Object.keys(themeMap)[0];
var isLegacy = document.body.classList.contains("skin-vector-legacy");
var styleKey = isLegacy ? "mcbbs-wiki-skin-vector-legacy-style" : "mcbbs-wiki-skin-vector-style";
var themeKey = isLegacy ? "mcbbs-wiki-skin-vector-legacy-theme" : "mcbbs-wiki-skin-vector-theme";
var loadThemeStyle = (style, theme) => {
const _styleMapstyleMap = themeMap[style] || themeMap[defaultStyle];
const styleMap = isLegacy ? _styleMap.legacy || _styleMap : _styleMap;
const currentCommonStyle = styleMap.common;
loadWikiStyle(currentCommonStyle, "salt-wiki-style-common");
};
var initTheme = () => {
const current = { style: "book"defaultStyle, theme: "default" };
const [style] = readAndListen({
key: styleKey,
defaultValue: "book"defaultStyle,
listener: (ev) => {
if (ev.newValue) {