Skip to content

Commit d249212

Browse files
committed
Small Update
1 parent 27257d6 commit d249212

25 files changed

+611
-442
lines changed

217/欢迎来到咱们217_jsp_files/nui.min.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

basis/NightTime.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

basis/NightTime.max.js

+68-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
"use strict";
2-
/**
3-
* 请将本 js 放在页面最末尾引用,否则可能不起作用。
4-
* 由于不带 min 的 js 路径已经被过多页面使用了,因此直接以“.js”结尾的便是压缩版了,而源文件就只好用 min 的反义词 max 来表示了。
5-
* 自定义参数方法,在页面中定义一个名为 NightTime 的对象,根据需要添加属性:
6-
* var NightTime = {
7-
* darkMode: Boolean - 若定义该属性,则页面始终保持颜色主题与设定的参数保持一致,
8-
* nightDo: Function - 自定义深色主题下额外执行的操作,
9-
* darkDo: Function - 同 nightDo,为了统一名称风格,
10-
* lightDo: Function - 自定义浅色主题下额外执行的操作,一般无需配置,只有在主动切换为浅色主题时才需要将 nightDo 执行的操作复原回去,
11-
* darkBackgroundColor: String - 设定深色主题的页面背景色,
12-
* lightBackgroundColor: String - 设定浅色主题的页面背景色,
13-
* darkCSS: String - 设定深色主题的层叠式样式表路径,
14-
* lightCSS: String - 设定浅色主题的层叠式样式表路径
15-
* }
2+
/** configuration description
3+
* <p>
4+
* <strong> 请将本 js 放在页面最末尾引用,否则可能不起作用。 </strong><br>
5+
* 由于不带 min 的 js 路径已经被过多页面使用了,因此直接以“.js”结尾的便是压缩版了,而源文件就只好用 min 的反义词 max 来表示了。 <br>
6+
* 自定义参数方法,在页面中定义一个名为 NightTime 的<b>对象</b>,根据需要添加属性。(注意是要在本 js 之前预先以对象形式配置参数,到本 js 运行的时候才会读取这些配置!)<br>
7+
* 书写格式:{@code
8+
* var NightTime = {
9+
* // 在这里填写参数,如 “darkMode: true”。以逗号分隔。
10+
* }
11+
* }
12+
* </p>
13+
* @see NightTime
14+
* @param darkMode: boolean - 若定义该属性,则页面始终保持颜色主题与设定的参数保持一致,
15+
* @param nightDo: function - 自定义深色主题下额外执行的操作,
16+
* @param darkDo: function - 同 nightDo,为了统一名称风格,
17+
* @param lightDo: function - 自定义浅色主题下额外执行的操作,一般无需配置,只有在主动切换为浅色主题时才需要将 nightDo 执行的操作复原回去,
18+
* @param darkBackgroundColor: string - 设定深色主题的页面背景色,
19+
* @param lightBackgroundColor: string - 设定浅色主题的页面背景色,
20+
* @param darkCSS: string - 设定深色主题的层叠式样式表路径,
21+
* @param lightCSS: string - 设定浅色主题的层叠式样式表路径
22+
* @return void - 只声明不返回值
1623
*/
1724

1825
{
@@ -38,13 +45,21 @@
3845
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches)
3946
_this.darkModeFact = true; //若浏览器开启了深色主题,也会启动深色主题
4047
_this.theme = "";
41-
_this.nightDo = _this.lightDo = () => { }
48+
_this.nightDo = _this.lightDo = () => {};
49+
/** method description
50+
* 切换到当前主题
51+
* @returns void - 切换到正常情况下配置而应该呈现的主题
52+
*/
4253
_this.CurrentModeStyle = () => {
4354
_this.css = document.getElementById("css");
4455
if (_this.css) _this.theme = _this.css.getAttribute("data-theme").toLowerCase();
4556
if (_this.darkModeFact) return _this.DarkModeStyle();
4657
else return _this.LightModeStyle();
4758
}
59+
/** method description
60+
* 切换到对立主题
61+
* @returns void - 切换到不是当前状态下的主题,即浅色深色模式互相切换
62+
*/
4863
_this.ToggleModeStyle = () => {
4964
_this.darkModeFact = !_this.darkModeFact;
5065
return _this.CurrentModeStyle();
@@ -66,10 +81,17 @@
6681
}
6782
_this.scrollbar = () => {
6883
_this.appendStyleByAjax(`css/scrollbar.css`, "scrollbar", {
69-
"$textColor": (_this.darkModeFact ? "255, 255, 255" : "0, 0, 0")
84+
"var(--text-color-parts)": (_this.darkModeFact ? "255, 255, 255" : "0, 0, 0")
7085
});
7186
}
7287
const notAvailableLog = "The ID you specified has been occupied by the other element, please try to use other ID!";
88+
/** method description
89+
* 输入 CSS 文本并添加到 style 标签
90+
* @param style: string | object - 必选,可以是模板字符串或对象,将会添加到 style 标签中
91+
* @param id?: string - 可选,添加到的 style 标签的 id 名称。如果留空,则直接添加而不配置 id 名称,这样做可能无法规定生命周期
92+
* @returns true - 添加成功
93+
* @exception false - 添加失败,输入的 id 名称被占用且不为 style 标签
94+
*/
7395
_this.appendStyle = (style, id = "") => {
7496
var css;
7597
if (type(style) == "Object") {
@@ -90,6 +112,13 @@
90112
styleTag.innerHTML = css;
91113
return true;
92114
}
115+
/** method description
116+
* 输入 CSS 文件链接并添加到 link 标签
117+
* @param href: string - 必选,CSS 文件的链接地址
118+
* @param id?: string - 可选,添加到的 link 标签的 id 名称。如果留空,则直接添加而不配置 id 名称,这样做可能无法规定生命周期
119+
* @returns true - 添加成功
120+
* @exception false - 添加失败,输入的 id 名称被占用且不为 link 标签
121+
*/
93122
_this.appendCSSLink = (href, id = "") => {
94123
var linkTag = document.getElementById(id);
95124
if (!linkTag) {
@@ -106,6 +135,14 @@
106135
linkTag.href = href;
107136
return true;
108137
}
138+
/** method description
139+
* 输入 CSS 文件链接并添加到 style 标签,通过异步实现
140+
* @param href: string - 必选,CSS 文件的链接地址
141+
* @param id?: string - 可选,添加到的 link 标签的 id 名称。如果留空,则直接添加而不配置 id 名称,这样做可能无法规定生命周期
142+
* @param variable?: object - 可选,变量名称,规定 CSS 文件的某些变量的替换值
143+
* @returns true - 添加成功
144+
* @exception false - 添加失败,输入的 id 名称被占用且不为 link 标签
145+
*/
109146
_this.appendStyleByAjax = (href, id = "", variable) => {
110147
var css = new XMLHttpRequest();
111148
css.onreadystatechange = () => {
@@ -134,13 +171,24 @@
134171
css.open("GET", path(href), true);
135172
return css.send();
136173
}
174+
/** method description
175+
* 移除样式或 CSS 链接标签
176+
* removeStyle 和 removeCSSLink 效果是一样的
177+
* @param id: string - 必选,要移除的 CSS 样式的 id 名称
178+
* @returns true - 移除成功
179+
* @exception false - 移除失败,移除的不是 style 或 link 标签
180+
*/
137181
_this.removeStyle = _this.removeCSSLink = id => {
138182
let el = document.getElementById(id);
139183
if (!el) return false;
140184
if (el.tagName != "STYLE" && el.tagName != "LINK") return false;
141185
el.remove();
142186
return true;
143187
}
188+
/** method description
189+
* 强制切换到深色主题
190+
* @returns void
191+
*/
144192
_this.DarkModeStyle = () => {
145193
_this.darkModeFact = true;
146194
if (_this.theme.includes("bootstrap")) {
@@ -167,6 +215,10 @@
167215
if (_this.DarkCSS) _this.appendCSSLink(_this.DarkCSS, "css");
168216
return true;
169217
}
218+
/** method description
219+
* 强制切换到浅色主题
220+
* @returns void
221+
*/
170222
_this.LightModeStyle = () => {
171223
_this.darkModeFact = false;
172224
if (_this.theme.includes("bootstrap")) {

basis/css/scrollbar.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
::-webkit-scrollbar-thumb {
88
border-radius: 5px;
9-
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
10-
background: rgba($textColor, 0.2);
9+
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
10+
background: rgba(var(--text-color-parts), 0.2);
1111
scrollbar-arrow-color: red;
1212
}
1313

1414
::-webkit-scrollbar-track {
15-
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
15+
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
1616
border-radius: 0;
17-
background: rgba($textColor, 0.1);
17+
background: rgba(var(--text-color-parts), 0.1);
1818
}

0 commit comments

Comments
 (0)