Skip to content

Commit 25d88f9

Browse files
stars-oneLIlGG
andauthored
增加强制使用后台模型和材质id设置和功能 (#34)
* 后台设置项新增【强制使用默认模型和材质】选项 * js增加强制使用默认模型和材质id的判断条件 * 增加页面强制使用默认模型和材质的功能 --------- Co-authored-by: LIlGG <[email protected]>
1 parent 2ca8dce commit 25d88f9

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/main/resources/extensions/settings.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ spec:
1919
name: modelTexturesId
2020
validation: required|Number
2121
value: 53
22+
- $formkit: radio
23+
name: isForceUseDefaultConfig
24+
label: 强制使用默认模型和材质
25+
help: 开启此项后,忽略前台用户自行切换模型和材质ID,固定使用上面默认模型和材质编号
26+
value: false
27+
options:
28+
- value: true
29+
label: 开启
30+
- value: false
31+
label: 关闭
2232
- $formkit: radio
2333
name: isTools
2434
id: isTools
@@ -335,4 +345,4 @@ spec:
335345
- value: defer
336346
label: DOM 加载完成后,图片加载前
337347
- value: async
338-
label: 页面全部内容加载完成
348+
label: 页面全部内容加载完成

src/main/resources/static/js/live2d-autoload.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,14 @@ function Live2d() {
203203
}
204204

205205
#initModel(model) {
206-
let modelId = localStorage.getItem("modelId"),
207-
modelTexturesId = localStorage.getItem("modelTexturesId");
208-
if (modelId === null) {
209-
// 首次访问加载 指定模型 的 指定材质
206+
let modelId = localStorage.getItem("modelId");
207+
let modelTexturesId = localStorage.getItem("modelTexturesId");
208+
if (modelId === null || !!this.#config["isForceUseDefaultConfig"]) {
209+
// 加载指定模型的指定材质
210210
modelId = this.#config["modelId"] || 1; // 模型 ID
211211
modelTexturesId = this.#config["modelTexturesId"] || 53; // 材质 ID
212212
}
213+
213214
if (this.#config["consoleShowStatu"]) {
214215
eval(
215216
(function (p, a, c, k, e, r) {

src/main/resources/static/js/live2d-autoload.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)