Skip to content

Commit

Permalink
fix:修复live2d报错,去掉了模型自带的切换按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
kanoqwq committed Oct 31, 2024
1 parent 2ee90b4 commit b0a27f2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
36 changes: 20 additions & 16 deletions src/components/Live2D/Live2DSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
v-for="(item, index) in l2DList"
:key="item"
@click="selected(index)"
:class="{ active: item.active }">
:class="{ active: item.active }"
>
{{ item.message }}
</li>
</ul>
Expand All @@ -17,18 +18,18 @@
</template>

<script lang="ts" setup>
import { ref, onMounted, nextTick } from 'vue';
import useStore from '@/store';
import { Toast } from '../Toast';
import Button from '../Button/Button.vue';
import { ref, onMounted, nextTick } from "vue";
import useStore from "@/store";
import { Toast } from "../Toast";
import Button from "../Button/Button.vue";
const l2DList = ref<any>({});
const selectedIndex = ref<number>(0);
const Configs = useStore.Configs();
const scrollList = ref();
const getL2DList = async () => {
try {
let { messages } = await (
await fetch('./assets/Live2d/model_list.json')
await fetch("./assets/Live2d/model_list.json")
).json();
l2DList.value = messages.map((item: any) => ({
Expand All @@ -38,10 +39,10 @@ const getL2DList = async () => {
l2DList.value[Configs.modId].active = true;
} catch {
Toast({
value: '获取Live2d列表失败',
color: 'yellow',
value: "获取Live2d列表失败",
color: "yellow",
duration: 2000,
background: '#00000099',
background: "#00000099",
});
}
};
Expand All @@ -63,9 +64,9 @@ const save = () => {
Configs.setModelId(selectedIndex.value);
Toast({
value: `保存成功!1秒后自动刷新页面!`,
color: 'green',
color: "green",
duration: 1000,
background: '#00000099',
background: "#00000099",
success() {
location.reload();
},
Expand All @@ -76,11 +77,14 @@ onMounted(() => {
getL2DList().then(() => {
nextTick(() => {
setTimeout(() => {
scrollList.value.children && scrollList.value.children[Configs.modId].scrollIntoView({
behavior: 'smooth',
block: 'start',
inline: 'nearest',
});
try {
scrollList.value.children &&
scrollList.value.children[Configs.modId].scrollIntoView({
behavior: "smooth",
block: "start",
inline: "nearest",
});
} catch {}
}, 300);
});
});
Expand Down
1 change: 0 additions & 1 deletion src/components/Live2D/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ onMounted(() => {
tools: !isMobile() ? [
"hitokoto",
"asteroids",
"switch-model",
"switch-texture",
"photo",
"info",
Expand Down

0 comments on commit b0a27f2

Please sign in to comment.