mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-08 08:48:11 +08:00
♻️ 路径优化
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
<template>
|
||||
<h1>测试页</h1>
|
||||
</template>
|
||||
<script lang="ts" setup></script>
|
||||
<style lang="css" scoped></style>
|
||||
@@ -18,7 +18,7 @@
|
||||
<v-btn prepend-icon="mdi-export" class="ms-2 top-btn" @click="exportJson"> 导出 </v-btn>
|
||||
</template>
|
||||
</v-app-bar>
|
||||
<TOLoading v-model="loading" :title="loadingTitle" />
|
||||
<ToLoading v-model="loading" :title="loadingTitle" />
|
||||
<div class="wrap">
|
||||
<!-- 左侧菜单 -->
|
||||
<div class="left-wrap">
|
||||
@@ -117,26 +117,26 @@
|
||||
<script lang="ts" setup>
|
||||
// vue
|
||||
import { onMounted, ref, onBeforeMount, computed } from "vue";
|
||||
import TOLoading from "../components/overlay/to-loading.vue";
|
||||
import ToLoading from "../../components/overlay/to-loading.vue";
|
||||
// tauri
|
||||
import { dialog, fs } from "@tauri-apps/api";
|
||||
// Store
|
||||
import { useAchievementsStore } from "../store/modules/achievements";
|
||||
import { useAchievementsStore } from "../../store/modules/achievements";
|
||||
// Utils
|
||||
import { createTGWindow } from "../utils/TGWindow";
|
||||
import { getUiafHeader, readUiafData, verifyUiafData } from "../utils/UIAF";
|
||||
import TGSqlite from "../plugins/Sqlite";
|
||||
import { createTGWindow } from "../../utils/TGWindow";
|
||||
import { getUiafHeader, readUiafData, verifyUiafData } from "../../utils/UIAF";
|
||||
import TGSqlite from "../../plugins/Sqlite";
|
||||
|
||||
// Store
|
||||
const achievementsStore = useAchievementsStore();
|
||||
|
||||
// loading
|
||||
const loading = ref(true as boolean);
|
||||
const loadingTitle = ref("正在加载数据" as string);
|
||||
const loading = ref<boolean>(true);
|
||||
const loadingTitle = ref<string>("正在加载数据");
|
||||
|
||||
// data
|
||||
const title = ref(achievementsStore.title as string);
|
||||
const getCardInfo = ref({} as TGApp.Sqlite.NameCard.SingleTable);
|
||||
const title = ref(achievementsStore.title);
|
||||
const getCardInfo = ref<TGApp.Sqlite.NameCard.SingleTable>(<TGApp.Sqlite.NameCard.SingleTable>{});
|
||||
const getCardImg = computed(() => {
|
||||
return {
|
||||
profile: `/source/nameCard/profile/${getCardInfo.value.name}.webp`,
|
||||
@@ -145,26 +145,26 @@ const getCardImg = computed(() => {
|
||||
};
|
||||
});
|
||||
// series
|
||||
const seriesList = ref([] as TGApp.Sqlite.Achievement.SeriesTable[]);
|
||||
const selectedSeries = ref(-1 as number);
|
||||
const selectedAchievement = ref([] as TGApp.Sqlite.Achievement.SingleTable[]);
|
||||
const seriesList = ref<TGApp.Sqlite.Achievement.SeriesTable[]>([]);
|
||||
const selectedSeries = ref<number>(-1);
|
||||
const selectedAchievement = ref<TGApp.Sqlite.Achievement.SingleTable[]>([]);
|
||||
const renderAchievement = computed(() => {
|
||||
return selectedAchievement.value.slice(start.value, start.value + itemCount.value + 1);
|
||||
});
|
||||
// virtual list
|
||||
const start = ref(0 as number);
|
||||
const start = ref<number>(0);
|
||||
const itemCount = computed(() => {
|
||||
return Math.ceil((window.innerHeight - 100) / 76);
|
||||
});
|
||||
const emptyHeight = computed(() => {
|
||||
return selectedAchievement.value.length * 76;
|
||||
});
|
||||
const translateY = ref("0px" as string);
|
||||
const translateY = ref<string>("0px");
|
||||
// render
|
||||
const search = ref("" as string);
|
||||
const snackbar = ref(false as boolean);
|
||||
const snackbarText = ref("" as string);
|
||||
const snackbarColor = ref("#F5810A" as string);
|
||||
const search = ref<string>("");
|
||||
const snackbar = ref<boolean>(false);
|
||||
const snackbarText = ref<string>("");
|
||||
const snackbarColor = ref<string>("#F5810A");
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const { total, fin } = await TGSqlite.getAchievementsOverview();
|
||||
@@ -181,12 +181,10 @@ onMounted(async () => {
|
||||
loading.value = false;
|
||||
});
|
||||
|
||||
function handleScroll(e: Event) {
|
||||
function handleScroll(e: Event): void {
|
||||
const target: HTMLElement = <HTMLElement>e.target;
|
||||
// 如果 scrollTop 到底部了
|
||||
if (
|
||||
(e.target as HTMLElement).scrollTop + (e.target as HTMLElement).offsetHeight >=
|
||||
(e.target as HTMLElement).scrollHeight
|
||||
) {
|
||||
if (target.scrollTop + target.offsetHeight >= target.scrollHeight) {
|
||||
// 如果 selectedAchievement 的长度小于 itemCount,不进行偏移
|
||||
if (selectedAchievement.value.length <= itemCount.value) {
|
||||
window.requestAnimationFrame(() => {
|
||||
@@ -201,9 +199,9 @@ function handleScroll(e: Event) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
const scrollTop = target.scrollTop;
|
||||
if (selectedSeries.value !== 0 && selectedSeries.value !== 17 && selectedSeries.value !== -1) {
|
||||
window.requestAnimationFrame(() => {
|
||||
const { scrollTop } = e.target as HTMLElement;
|
||||
if (scrollTop < 86.8) {
|
||||
start.value = 0;
|
||||
translateY.value = "0px";
|
||||
@@ -214,7 +212,6 @@ function handleScroll(e: Event) {
|
||||
});
|
||||
} else {
|
||||
window.requestAnimationFrame(() => {
|
||||
const { scrollTop } = e.target as HTMLElement;
|
||||
start.value = Math.floor(scrollTop / 76);
|
||||
translateY.value = `${scrollTop}px`;
|
||||
});
|
||||
@@ -222,7 +219,7 @@ function handleScroll(e: Event) {
|
||||
}
|
||||
|
||||
// 渲染选中的成就系列
|
||||
async function selectSeries(index: number) {
|
||||
async function selectSeries(index: number): Promise<void> {
|
||||
// 如果选中的是已经选中的系列,则不进行操作
|
||||
if (selectedSeries.value === index) {
|
||||
snackbarText.value = "已经选中该系列";
|
||||
@@ -241,11 +238,11 @@ async function selectSeries(index: number) {
|
||||
}
|
||||
|
||||
// 打开图片
|
||||
function openImg() {
|
||||
function openImg(): void {
|
||||
createTGWindow(getCardImg.value.profile, "nameCard", getCardInfo.value.name, 840, 400, false);
|
||||
}
|
||||
|
||||
async function searchCard() {
|
||||
async function searchCard(): Promise<void> {
|
||||
if (search.value === "") {
|
||||
snackbarColor.value = "#F5810A";
|
||||
snackbarText.value = "请输入搜索内容";
|
||||
@@ -264,7 +261,7 @@ async function searchCard() {
|
||||
loading.value = false;
|
||||
}
|
||||
// 导入 UIAF 数据,进行数据合并、刷新
|
||||
async function importJson() {
|
||||
async function importJson(): Promise<void> {
|
||||
const selectedFile = await dialog.open({
|
||||
multiple: false,
|
||||
filters: [
|
||||
@@ -293,7 +290,7 @@ async function importJson() {
|
||||
}
|
||||
|
||||
// 导出
|
||||
async function exportJson() {
|
||||
async function exportJson(): Promise<void> {
|
||||
// 判断是否有数据
|
||||
if (achievementsStore.finAchievements === 0) {
|
||||
snackbarColor.value = "#F5810A";
|
||||
@@ -34,7 +34,7 @@
|
||||
</v-card-subtitle>
|
||||
<v-card-subtitle v-show="appStore.devMode"> id: {{ item.id }} </v-card-subtitle>
|
||||
<v-btn v-show="appStore.devMode" class="anno-dev-btn" @click="toJson(item)">
|
||||
<img src="../assets/icons/arrow-right.svg" alt="right" />
|
||||
<img src="../../assets/icons/arrow-right.svg" alt="right" />
|
||||
<span>查看数据</span>
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
@@ -61,7 +61,7 @@
|
||||
</v-card-subtitle>
|
||||
<v-card-subtitle v-show="appStore.devMode"> id: {{ item.id }} </v-card-subtitle>
|
||||
<v-btn v-show="appStore.devMode" class="anno-dev-btn" @click="toJson(item)">
|
||||
<img src="../assets/icons/arrow-right.svg" alt="right" />
|
||||
<img src="../../assets/icons/arrow-right.svg" alt="right" />
|
||||
<span>查看数据</span>
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
@@ -75,13 +75,13 @@
|
||||
// vue
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import ToLoading from "../components/overlay/to-loading.vue";
|
||||
import ToLoading from "../../components/overlay/to-loading.vue";
|
||||
// store
|
||||
import { useAppStore } from "../store/modules/app";
|
||||
import { useAppStore } from "../../store/modules/app";
|
||||
// utils
|
||||
import TGRequest from "../web/request/TGRequest";
|
||||
import TGUtils from "../web/utils/TGUtils";
|
||||
import { createTGWindow } from "../utils/TGWindow";
|
||||
import TGRequest from "../../web/request/TGRequest";
|
||||
import TGUtils from "../../web/utils/TGUtils";
|
||||
import { createTGWindow } from "../../utils/TGWindow";
|
||||
|
||||
// store
|
||||
const appStore = useAppStore();
|
||||
@@ -95,10 +95,10 @@ const router = useRouter();
|
||||
// 数据
|
||||
const tab = ref<string>("");
|
||||
const annoCards = ref({
|
||||
activity: [] as TGApp.App.Announcement.ListCard[],
|
||||
game: [] as TGApp.App.Announcement.ListCard[],
|
||||
activity: <TGApp.App.Announcement.ListCard[]>[],
|
||||
game: <TGApp.App.Announcement.ListCard[]>[],
|
||||
});
|
||||
const annoData = ref<TGApp.BBS.Announcement.ListData>({} as TGApp.BBS.Announcement.ListData);
|
||||
const annoData = ref<TGApp.BBS.Announcement.ListData>(<TGApp.BBS.Announcement.ListData>{});
|
||||
|
||||
onMounted(async () => {
|
||||
loadingTitle.value = "正在获取公告数据";
|
||||
@@ -119,26 +119,24 @@ onMounted(async () => {
|
||||
loading.value = false;
|
||||
});
|
||||
|
||||
async function switchNews() {
|
||||
async function switchNews(): Promise<void> {
|
||||
await router.push("/news/2");
|
||||
}
|
||||
|
||||
async function toPost(item: TGApp.App.Announcement.ListCard) {
|
||||
async function toPost(item: TGApp.App.Announcement.ListCard): Promise<void> {
|
||||
const path = router.resolve({
|
||||
name: "游戏内公告",
|
||||
params: {
|
||||
// eslint-disable-next-line camelcase
|
||||
anno_id: item.id,
|
||||
},
|
||||
}).href;
|
||||
createTGWindow(path, "游戏内公告", item.title, 960, 720, false, false);
|
||||
}
|
||||
|
||||
async function toJson(item: TGApp.App.Announcement.ListCard) {
|
||||
async function toJson(item: TGApp.App.Announcement.ListCard): Promise<void> {
|
||||
const path = router.resolve({
|
||||
name: "游戏内公告(JSON)",
|
||||
params: {
|
||||
// eslint-disable-next-line camelcase
|
||||
anno_id: item.id,
|
||||
},
|
||||
}).href;
|
||||
@@ -31,7 +31,7 @@
|
||||
</v-list-item>
|
||||
<v-list-item title="成就版本">
|
||||
<template #prepend>
|
||||
<img class="config-icon" src="../assets/icons/achievements.svg" alt="Achievements" />
|
||||
<img class="config-icon" src="../../assets/icons/achievements.svg" alt="Achievements" />
|
||||
</template>
|
||||
<template #append>
|
||||
<v-list-item-subtitle>{{ achievementsStore.lastVersion }}</v-list-item-subtitle>
|
||||
@@ -50,7 +50,7 @@
|
||||
<template #append>
|
||||
<v-btn class="card-btn" @click="tryConfirm('refreshUser')">
|
||||
<template #prepend>
|
||||
<img src="../assets/icons/circle-check.svg" alt="check" />
|
||||
<img src="../../assets/icons/circle-check.svg" alt="check" />
|
||||
刷新数据
|
||||
</template>
|
||||
</v-btn>
|
||||
@@ -112,7 +112,7 @@
|
||||
<template #append>
|
||||
<v-btn class="card-btn" @click="submitHome">
|
||||
<template #prepend>
|
||||
<img src="../assets/icons/circle-check.svg" alt="check" />
|
||||
<img src="../../assets/icons/circle-check.svg" alt="check" />
|
||||
确定
|
||||
</template>
|
||||
</v-btn>
|
||||
@@ -194,21 +194,21 @@
|
||||
<script lang="ts" setup>
|
||||
// vue
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import ToLoading from "../components/overlay/to-loading.vue";
|
||||
import ToConfirm from "../components/overlay/to-confirm.vue";
|
||||
import ToLoading from "../../components/overlay/to-loading.vue";
|
||||
import ToConfirm from "../../components/overlay/to-confirm.vue";
|
||||
// tauri
|
||||
import { app, fs, os } from "@tauri-apps/api";
|
||||
// store
|
||||
import { useAppStore } from "../store/modules/app";
|
||||
import { useHomeStore } from "../store/modules/home";
|
||||
import { useAchievementsStore } from "../store/modules/achievements";
|
||||
import { useUserStore } from "../store/modules/user";
|
||||
import { useAppStore } from "../../store/modules/app";
|
||||
import { useHomeStore } from "../../store/modules/home";
|
||||
import { useAchievementsStore } from "../../store/modules/achievements";
|
||||
import { useUserStore } from "../../store/modules/user";
|
||||
// utils
|
||||
import { backupUiafData, restoreUiafData } from "../utils/UIAF";
|
||||
import { backupAbyssData, backupCookieData } from "../web/utils/backupData";
|
||||
import { restoreAbyssData, restoreCookieData } from "../web/utils/restoreData";
|
||||
import TGSqlite from "../plugins/Sqlite";
|
||||
import TGRequest from "../web/request/TGRequest";
|
||||
import { backupUiafData, restoreUiafData } from "../../utils/UIAF";
|
||||
import { backupAbyssData, backupCookieData } from "../../web/utils/backupData";
|
||||
import { restoreAbyssData, restoreCookieData } from "../../web/utils/restoreData";
|
||||
import TGSqlite from "../../plugins/Sqlite";
|
||||
import TGRequest from "../../web/request/TGRequest";
|
||||
|
||||
// Store
|
||||
const appStore = useAppStore();
|
||||
@@ -6,33 +6,33 @@
|
||||
<script lang="ts" setup>
|
||||
// vue
|
||||
import { markRaw, onBeforeMount, onMounted, onUnmounted, onUpdated, ref } from "vue";
|
||||
import ToLoading from "../components/overlay/to-loading.vue";
|
||||
import TPool from "../components/main/t-pool.vue";
|
||||
import TPosition from "../components/main/t-position.vue";
|
||||
import TCalendar from "../components/main/t-calendar.vue";
|
||||
import ToLoading from "../../components/overlay/to-loading.vue";
|
||||
import TPool from "../../components/main/t-pool.vue";
|
||||
import TPosition from "../../components/main/t-position.vue";
|
||||
import TCalendar from "../../components/main/t-calendar.vue";
|
||||
// store
|
||||
import { useHomeStore } from "../store/modules/home";
|
||||
import { useAppStore } from "../store/modules/app";
|
||||
import { useUserStore } from "../store/modules/user";
|
||||
import { useHomeStore } from "../../store/modules/home";
|
||||
import { useAppStore } from "../../store/modules/app";
|
||||
import { useUserStore } from "../../store/modules/user";
|
||||
// utils
|
||||
import { getBuildTime } from "../utils/TGBuild";
|
||||
import TGSqlite from "../plugins/Sqlite";
|
||||
import { getBuildTime } from "../../utils/TGBuild";
|
||||
import TGSqlite from "../../plugins/Sqlite";
|
||||
|
||||
// store
|
||||
const appStore = useAppStore();
|
||||
const homeStore = useHomeStore();
|
||||
|
||||
// loading
|
||||
const loading = ref(true as boolean);
|
||||
const loadingTitle = ref("正在加载首页");
|
||||
const loadingSubtitle = ref("");
|
||||
const loading = ref<boolean>(true);
|
||||
const loadingTitle = ref<string>("正在加载首页");
|
||||
const loadingSubtitle = ref<string>("");
|
||||
|
||||
// data
|
||||
const components = ref([] as any[]);
|
||||
const itemRefs = ref([] as any[]);
|
||||
const components = ref<any[]>([]);
|
||||
const itemRefs = ref<any[]>([]);
|
||||
|
||||
// 定时器
|
||||
const timer = ref(null as any);
|
||||
const timer = ref<any>(null);
|
||||
|
||||
function readLoading(): void {
|
||||
if (!loading.value) return;
|
||||
@@ -82,7 +82,7 @@ onMounted(async () => {
|
||||
timer.value = setInterval(readLoading, 100);
|
||||
});
|
||||
|
||||
function setItemRef(item: any) {
|
||||
function setItemRef(item: any): void {
|
||||
if (itemRefs.value.includes(item)) return;
|
||||
itemRefs.value.push(item);
|
||||
}
|
||||
3
src/pages/common/Test.vue
Normal file
3
src/pages/common/Test.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<h1>测试页</h1>
|
||||
</template>
|
||||
@@ -2,18 +2,18 @@
|
||||
* @file router modules main.ts
|
||||
* @description 主路由模块
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.6
|
||||
* @since Alpha v0.2.2
|
||||
*/
|
||||
|
||||
// 信息展示
|
||||
import Announcements from "../../pages/Announcements.vue";
|
||||
import Home from "../../pages/Home.vue";
|
||||
import Announcements from "../../pages/common/Announcements.vue";
|
||||
import Home from "../../pages/common/Home.vue";
|
||||
// 数据交互
|
||||
import Achievements from "../../pages/Achievements.vue";
|
||||
import Achievements from "../../pages/common/Achievements.vue";
|
||||
// 应用配置相关
|
||||
import Config from "../../pages/Config.vue";
|
||||
import Config from "../../pages/common/Config.vue";
|
||||
// 测试页
|
||||
import Test from "../../pages/Test.vue";
|
||||
import Test from "../../pages/common/Test.vue";
|
||||
|
||||
const mainRoutes = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user