Skip to content

Commit

Permalink
feat(spine): read config from torappu
Browse files Browse the repository at this point in the history
  • Loading branch information
daflyinbed committed Sep 17, 2023
1 parent 99646b4 commit 5773c3a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
30 changes: 20 additions & 10 deletions src/entries/SpineViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,25 @@ import { Spine } from "../widgets/Spine/spine";
// @ts-expect-error
window.SpineApi = Spine;
window.dispatchEvent(new Event("spine_api_ready"));
async function main() {
const ele = document.getElementById("spine-root");
let spineData: Props;
if (ele?.dataset.id) {
const resp = await fetch(
`https://torappu.prts.wiki/assets/charSpine/${ele.dataset.id}/meta.json`,
);
spineData = await resp.json();
//
} else {
spineData = JSON.parse(document.getElementById("SPINEDATA")!.innerHTML);
spineData.prefix = spineData.prefix.replace(
"https://static.prts.wiki/spine/",
"https://static.prts.wiki/spine38/",
);
}

const spineData: Props = JSON.parse(
document.getElementById("SPINEDATA")!.innerHTML,
);
spineData.prefix = spineData.prefix.replace(
"https://static.prts.wiki/spine/",
"https://static.prts.wiki/spine38/",
);
if (ele && spineData) createApp(SpineVue, { ...spineData }).mount(ele);
else console.error("SPINEDATA or ele not found", ele);
}

const ele = document.getElementById("spine-root");
if (ele && spineData) createApp(SpineVue, { ...spineData }).mount(ele);
else console.error("SPINEDATA or ele not found", ele);
main();
2 changes: 1 addition & 1 deletion templates/SpineViewer.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<includeonly><span style="display:none" id="SPINEDATA" type="json" class="navigation-not-searchable"><!--{$data}--></span><div id="spine-root"></div>__CSS_CONTENT__<script type="module" src="__SCRIPT_PATH__"></script></includeonly><noinclude>{{Documentation}}[[分类:由机器人维护的小部件]]</noinclude>
<includeonly><span style="display:none" id="SPINEDATA" type="json" class="navigation-not-searchable"><!--{$data}--></span><div id="spine-root" data-id="<!--{$id}-->"></div>__CSS_CONTENT__<script type="module" src="__SCRIPT_PATH__"></script></includeonly><noinclude>{{Documentation}}[[分类:由机器人维护的小部件]]</noinclude>

0 comments on commit 5773c3a

Please sign in to comment.