mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
⚡️ 优化,存在 bug
This commit is contained in:
@@ -51,7 +51,7 @@
|
|||||||
<slot name="right"></slot>
|
<slot name="right"></slot>
|
||||||
</div>
|
</div>
|
||||||
</TOverlay>
|
</TOverlay>
|
||||||
<ToPostSearch gid="2" v-model="showSearch" :keyword="search" />
|
<ToPostSearch gid="2" v-model="showSearch" v-model:keyword="search" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, onMounted, ref, watch } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
@@ -103,7 +103,7 @@ function onCancel() {
|
|||||||
visible.value = false;
|
visible.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找
|
// todo 存在 bug,点击成就标题时可能会没有效果
|
||||||
async function searchDirect(word: string): Promise<void> {
|
async function searchDirect(word: string): Promise<void> {
|
||||||
await TGLogger.Info(`[ToAchiInfo][${props.data?.id}][Search] 查询 ${word}`);
|
await TGLogger.Info(`[ToAchiInfo][${props.data?.id}][Search] 查询 ${word}`);
|
||||||
search.value = word;
|
search.value = word;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<div class="tops-top">查找:{{ search }}</div>
|
<div class="tops-top">查找:{{ search }}</div>
|
||||||
<div class="tops-act">
|
<div class="tops-act">
|
||||||
<span>分区:{{ getGidLabel() }}</span>
|
<span>分区:{{ getGidLabel() }}</span>
|
||||||
<v-btn size="small" class="tops-btn" @click="searchPosts()" rounded>
|
<v-btn :loading="load" size="small" class="tops-btn" @click="searchPosts()" rounded>
|
||||||
加载更多({{ results.length }})
|
加载更多({{ results.length }})
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
@@ -20,15 +20,17 @@
|
|||||||
import { computed, onMounted, ref, watch } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
|
|
||||||
import Mys from "../../plugins/Mys";
|
import Mys from "../../plugins/Mys";
|
||||||
|
import showSnackbar from "../func/snackbar";
|
||||||
import TOverlay from "../main/t-overlay.vue";
|
import TOverlay from "../main/t-overlay.vue";
|
||||||
import TPostCard from "../main/t-postcard.vue";
|
import TPostCard from "../main/t-postcard.vue";
|
||||||
|
|
||||||
// data
|
// data
|
||||||
const search = ref("");
|
const search = ref("");
|
||||||
const game = ref("2");
|
|
||||||
const lastId = ref("");
|
const lastId = ref("");
|
||||||
|
const game = ref("2");
|
||||||
const isLast = ref(false);
|
const isLast = ref(false);
|
||||||
const results = ref<TGApp.Plugins.Mys.Post.FullData[]>([]);
|
const results = ref<TGApp.Plugins.Mys.Post.FullData[]>([]);
|
||||||
|
const load = ref(false);
|
||||||
|
|
||||||
interface ToPostSearchProps {
|
interface ToPostSearchProps {
|
||||||
modelValue: boolean;
|
modelValue: boolean;
|
||||||
@@ -38,7 +40,6 @@ interface ToPostSearchProps {
|
|||||||
|
|
||||||
interface ToPostSearchEmits {
|
interface ToPostSearchEmits {
|
||||||
(e: "update:modelValue", value: boolean): void;
|
(e: "update:modelValue", value: boolean): void;
|
||||||
|
|
||||||
(e: "cancel"): void;
|
(e: "cancel"): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,18 +86,52 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
() => props.keyword,
|
() => props.keyword,
|
||||||
async (value) => {
|
async (value) => {
|
||||||
search.value = value;
|
if (search.value === "" && value !== "") {
|
||||||
results.value = [];
|
search.value = value;
|
||||||
lastId.value = "";
|
await searchPosts();
|
||||||
isLast.value = false;
|
} else if (search.value !== value && value !== "") {
|
||||||
|
search.value = value;
|
||||||
|
results.value = [];
|
||||||
|
lastId.value = "";
|
||||||
|
isLast.value = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.gid,
|
||||||
|
async (value) => {
|
||||||
|
if (game.value !== value) {
|
||||||
|
game.value = value;
|
||||||
|
results.value = [];
|
||||||
|
lastId.value = "";
|
||||||
|
isLast.value = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
async function searchPosts() {
|
async function searchPosts() {
|
||||||
|
if (load.value) return;
|
||||||
|
load.value = true;
|
||||||
if (!props.gid || !props.keyword) {
|
if (!props.gid || !props.keyword) {
|
||||||
|
showSnackbar({
|
||||||
|
text: "参数错误",
|
||||||
|
});
|
||||||
|
load.value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isLast.value) {
|
if (isLast.value) {
|
||||||
|
showSnackbar({
|
||||||
|
text: "没有更多了",
|
||||||
|
});
|
||||||
|
load.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (search.value === "") {
|
||||||
|
showSnackbar({
|
||||||
|
text: "请输入搜索关键词",
|
||||||
|
});
|
||||||
|
load.value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const res = await Mys.Posts.search(game.value, search.value, lastId.value);
|
const res = await Mys.Posts.search(game.value, search.value, lastId.value);
|
||||||
@@ -107,6 +142,7 @@ async function searchPosts() {
|
|||||||
}
|
}
|
||||||
lastId.value = res.last_id;
|
lastId.value = res.last_id;
|
||||||
isLast.value = res.is_last;
|
isLast.value = res.is_last;
|
||||||
|
load.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGidLabel(): string {
|
function getGidLabel(): string {
|
||||||
|
|||||||
@@ -356,14 +356,14 @@ async function confirmDelCache(): Promise<void> {
|
|||||||
for (const dir of CacheDir) {
|
for (const dir of CacheDir) {
|
||||||
await fs.removeDir(dir, { recursive: true });
|
await fs.removeDir(dir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
await TGLogger.Info("[Config][confirmDelCache] 缓存清除完成");
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
showSnackbar({
|
showSnackbar({
|
||||||
text: "缓存已清除!即将退出应用!",
|
text: "缓存已清除!即将退出应用!",
|
||||||
});
|
});
|
||||||
await TGLogger.Info("[Config][confirmDelCache] 缓存清除完成");
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await TauriProcess.exit();
|
await TauriProcess.exit();
|
||||||
}, 3000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 恢复默认设置
|
// 恢复默认设置
|
||||||
|
|||||||
Reference in New Issue
Block a user