Skip to content

Commit

Permalink
增加强制使用后台模型和材质id设置和功能 (#34)
Browse files Browse the repository at this point in the history
* 后台设置项新增【强制使用默认模型和材质】选项

* js增加强制使用默认模型和材质id的判断条件

* 增加页面强制使用默认模型和材质的功能

---------

Co-authored-by: LIlGG <[email protected]>
  • Loading branch information
stars-one and LIlGG authored Dec 27, 2023
1 parent 2ca8dce commit 25d88f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
12 changes: 11 additions & 1 deletion src/main/resources/extensions/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ spec:
name: modelTexturesId
validation: required|Number
value: 53
- $formkit: radio
name: isForceUseDefaultConfig
label: 强制使用默认模型和材质
help: 开启此项后,忽略前台用户自行切换模型和材质ID,固定使用上面默认模型和材质编号
value: false
options:
- value: true
label: 开启
- value: false
label: 关闭
- $formkit: radio
name: isTools
id: isTools
Expand Down Expand Up @@ -335,4 +345,4 @@ spec:
- value: defer
label: DOM 加载完成后,图片加载前
- value: async
label: 页面全部内容加载完成
label: 页面全部内容加载完成
9 changes: 5 additions & 4 deletions src/main/resources/static/js/live2d-autoload.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,14 @@ function Live2d() {
}

#initModel(model) {
let modelId = localStorage.getItem("modelId"),
modelTexturesId = localStorage.getItem("modelTexturesId");
if (modelId === null) {
// 首次访问加载 指定模型 的 指定材质
let modelId = localStorage.getItem("modelId");
let modelTexturesId = localStorage.getItem("modelTexturesId");
if (modelId === null || !!this.#config["isForceUseDefaultConfig"]) {
// 加载指定模型的指定材质
modelId = this.#config["modelId"] || 1; // 模型 ID
modelTexturesId = this.#config["modelTexturesId"] || 53; // 材质 ID
}

if (this.#config["consoleShowStatu"]) {
eval(
(function (p, a, c, k, e, r) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/js/live2d-autoload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 25d88f9

Please sign in to comment.