mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-16 09:58:13 +08:00
🐛 修复 Qodana 报错
This commit is contained in:
@@ -13,7 +13,7 @@ const scrollTop = ref(0); // 滚动条距离顶部的距离
|
||||
const canTop = ref(false); // 默认不显示
|
||||
|
||||
// 监听滚动事件
|
||||
function handleScroll() {
|
||||
function handleScroll(): void {
|
||||
scrollTop.value = document.documentElement.scrollTop || document.body.scrollTop;
|
||||
// 超过500px显示回到顶部按钮
|
||||
canTop.value = scrollTop.value > 500;
|
||||
@@ -26,7 +26,7 @@ function handleScroll() {
|
||||
}
|
||||
|
||||
// 点击回到顶部
|
||||
function handleScrollTop() {
|
||||
function handleScrollTop(): void {
|
||||
let timer = 0;
|
||||
cancelAnimationFrame(timer);
|
||||
timer = requestAnimationFrame(function fn() {
|
||||
@@ -42,7 +42,6 @@ function handleScrollTop() {
|
||||
}
|
||||
|
||||
// 监听滚动事件
|
||||
// @ts-ignore
|
||||
onMounted(() => {
|
||||
window.addEventListener("scroll", handleScroll);
|
||||
});
|
||||
|
||||
@@ -1,32 +1,91 @@
|
||||
<template>
|
||||
<div class="tib-box">
|
||||
<div class="tib-bg">
|
||||
<div
|
||||
class="tib-box"
|
||||
:style="{
|
||||
width: modelValue.size,
|
||||
height: modelValue.height,
|
||||
cursor: modelValue.clickable ? 'pointer' : 'default',
|
||||
}"
|
||||
>
|
||||
<div
|
||||
class="tib-bg"
|
||||
:style="{
|
||||
width: modelValue.size,
|
||||
height: modelValue.size,
|
||||
}"
|
||||
>
|
||||
<slot name="bg">
|
||||
<img :src="modelValue.bg" alt="bg" />
|
||||
</slot>
|
||||
</div>
|
||||
<div class="tib-icon">
|
||||
<div
|
||||
class="tib-icon"
|
||||
:style="{
|
||||
width: modelValue.size,
|
||||
height: modelValue.size,
|
||||
}"
|
||||
>
|
||||
<slot name="icon">
|
||||
<img :src="modelValue.icon" alt="icon" />
|
||||
</slot>
|
||||
</div>
|
||||
<div class="tib-cover">
|
||||
<div class="tib-lt">
|
||||
<div
|
||||
class="tib-cover"
|
||||
:style="{
|
||||
width: modelValue.size,
|
||||
height: modelValue.size,
|
||||
}"
|
||||
>
|
||||
<div
|
||||
class="tib-lt"
|
||||
:style="{
|
||||
width: modelValue.ltSize,
|
||||
height: modelValue.ltSize,
|
||||
}"
|
||||
>
|
||||
<img :src="modelValue.lt" alt="lt" />
|
||||
</div>
|
||||
<div v-show="modelValue.rt" class="tib-rt">
|
||||
<div
|
||||
v-show="modelValue.rt"
|
||||
class="tib-rt"
|
||||
:style="{
|
||||
width: modelValue.rtSize,
|
||||
height: modelValue.rtSize,
|
||||
}"
|
||||
>
|
||||
{{ modelValue.rt }}
|
||||
</div>
|
||||
<div class="tib-inner">
|
||||
<div
|
||||
class="tib-inner"
|
||||
:style="{
|
||||
height: `${props.modelValue.innerHeight ?? 0}px`,
|
||||
fontSize: `${props.modelValue.innerHeight ? props.modelValue.innerHeight / 2 : 0}px`,
|
||||
}"
|
||||
>
|
||||
<slot name="inner-icon">
|
||||
<img v-show="modelValue.innerIcon" :src="modelValue.innerIcon" alt="inner-icon" />
|
||||
<img
|
||||
v-show="modelValue.innerIcon"
|
||||
:src="modelValue.innerIcon"
|
||||
alt="inner-icon"
|
||||
:style="{
|
||||
width: `${props.modelValue.innerHeight ?? 0}px`,
|
||||
height: `${props.modelValue.innerHeight ?? 0}px`,
|
||||
}"
|
||||
/>
|
||||
</slot>
|
||||
<slot name="inner-text">
|
||||
<span>{{ modelValue.innerText }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="modelValue.display === 'outer'" class="tib-outer">
|
||||
<div
|
||||
v-if="modelValue.display === 'outer'"
|
||||
class="tib-outer"
|
||||
:style="{
|
||||
height: `${props.modelValue.outerHeight ?? 0}px`,
|
||||
fontSize: `${props.modelValue.outerHeight ? props.modelValue.outerHeight / 2 : 0}px`,
|
||||
}"
|
||||
>
|
||||
<slot name="outer-text">
|
||||
<span>{{ modelValue.outerText }}</span>
|
||||
</slot>
|
||||
@@ -34,8 +93,6 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { computed } from "vue";
|
||||
|
||||
export interface TItemBoxData {
|
||||
bg: string;
|
||||
icon: string;
|
||||
@@ -59,19 +116,10 @@ interface TItemBoxProps {
|
||||
}
|
||||
|
||||
const props = defineProps<TItemBoxProps>();
|
||||
|
||||
const getCursor = computed(() => (props.modelValue.clickable ? "pointer" : "default"));
|
||||
const getInnerHeight = computed(() => `${props.modelValue.innerHeight}px`);
|
||||
const getInnerFont = computed(() => `${props.modelValue.innerHeight / 2}px`);
|
||||
const getOuterHeight = computed(() => `${props.modelValue.outerHeight}px`);
|
||||
const getOuterFont = computed(() => `${props.modelValue.outerHeight / 2}px`);
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
.tib-box {
|
||||
position: relative;
|
||||
width: v-bind(modelValue[ "size"]);
|
||||
height: v-bind(modelValue[ "height"]);
|
||||
cursor: v-bind(getCursor);
|
||||
}
|
||||
|
||||
.tib-bg {
|
||||
@@ -79,8 +127,6 @@ const getOuterFont = computed(() => `${props.modelValue.outerHeight / 2}px`);
|
||||
top: 0;
|
||||
left: 0;
|
||||
overflow: hidden;
|
||||
width: v-bind(modelValue[ "size"]);
|
||||
height: v-bind(modelValue[ "size"]);
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
@@ -93,8 +139,6 @@ const getOuterFont = computed(() => `${props.modelValue.outerHeight / 2}px`);
|
||||
.tib-icon {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
width: v-bind(modelValue[ "size"]);
|
||||
height: v-bind(modelValue[ "size"]);
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
@@ -109,8 +153,6 @@ const getOuterFont = computed(() => `${props.modelValue.outerHeight / 2}px`);
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
width: v-bind(modelValue[ "size"]);
|
||||
height: v-bind(modelValue[ "size"]);
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -122,8 +164,6 @@ const getOuterFont = computed(() => `${props.modelValue.outerHeight / 2}px`);
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
width: v-bind(modelValue[ "ltSize"]);
|
||||
height: v-bind(modelValue[ "ltSize"]);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 5px;
|
||||
@@ -140,8 +180,6 @@ const getOuterFont = computed(() => `${props.modelValue.outerHeight / 2}px`);
|
||||
top: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
width: v-bind(modelValue[ "rtSize"]);
|
||||
height: v-bind(modelValue[ "rtSize"]);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgb(0 0 0 / 40%);
|
||||
@@ -157,7 +195,6 @@ const getOuterFont = computed(() => `${props.modelValue.outerHeight / 2}px`);
|
||||
left: 0;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: v-bind(getInnerHeight);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgb(20 20 20 / 40%);
|
||||
@@ -165,12 +202,9 @@ const getOuterFont = computed(() => `${props.modelValue.outerHeight / 2}px`);
|
||||
border-bottom-right-radius: 5px;
|
||||
color: var(--common-color-white);
|
||||
font-family: var(--font-title);
|
||||
font-size: v-bind(getInnerFont);
|
||||
}
|
||||
|
||||
.tib-inner img {
|
||||
width: v-bind(getInnerHeight);
|
||||
height: v-bind(getInnerHeight);
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
@@ -178,9 +212,7 @@ const getOuterFont = computed(() => `${props.modelValue.outerHeight / 2}px`);
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: v-bind(getOuterHeight);
|
||||
color: var(--common-text-title);
|
||||
font-size: v-bind(getOuterFont);
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -92,7 +92,7 @@ defineExpose({
|
||||
loading,
|
||||
});
|
||||
|
||||
function poolLastInterval(postId: number) {
|
||||
function poolLastInterval(postId: number): void {
|
||||
const pool = poolCards.value.find((pool) => pool.postId === postId);
|
||||
if (!pool) return;
|
||||
if (poolTimeGet.value[postId] === "未开始") {
|
||||
@@ -156,7 +156,7 @@ onMounted(async () => {
|
||||
});
|
||||
|
||||
// 检测新卡池
|
||||
function checkCover(data: TGApp.Plugins.Mys.Gacha.Data[]) {
|
||||
function checkCover(data: TGApp.Plugins.Mys.Gacha.Data[]): boolean {
|
||||
// 如果没有缓存
|
||||
if (!homeStore.poolCover || Object.keys(homeStore.poolCover).length === 0) {
|
||||
return false;
|
||||
@@ -180,7 +180,7 @@ function checkCover(data: TGApp.Plugins.Mys.Gacha.Data[]) {
|
||||
});
|
||||
}
|
||||
|
||||
async function toOuter(url: string, title: string) {
|
||||
async function toOuter(url: string, title: string): Promise<void> {
|
||||
if (!url) {
|
||||
barText.value = "链接为空!";
|
||||
barColor.value = "error";
|
||||
@@ -190,14 +190,14 @@ async function toOuter(url: string, title: string) {
|
||||
createTGWindow(url, "祈愿", title, 1200, 800, true, true);
|
||||
}
|
||||
|
||||
function getLastPoolTime(time: number) {
|
||||
function getLastPoolTime(time: number): string {
|
||||
const hour = Math.floor(time / 1000 / 60 / 60);
|
||||
const minute = Math.floor((time / 1000 / 60 / 60 - hour) * 60);
|
||||
const second = Math.floor(((time / 1000 / 60 / 60 - hour) * 60 - minute) * 60);
|
||||
return `${hour}:${minute.toFixed(0).padStart(2, "0")}:${second.toFixed(0).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
function toPost(pool: TGApp.Plugins.Mys.Gacha.RenderCard) {
|
||||
function toPost(pool: TGApp.Plugins.Mys.Gacha.RenderCard): void {
|
||||
const path = router.resolve({
|
||||
name: "帖子详情",
|
||||
params: {
|
||||
|
||||
@@ -68,7 +68,7 @@ defineExpose({
|
||||
loading,
|
||||
});
|
||||
|
||||
function positionLastInterval(postId: number) {
|
||||
function positionLastInterval(postId: number): void {
|
||||
const timeGet = positionTimeGet.value[postId];
|
||||
if (timeGet === "未知" || timeGet === "已结束") {
|
||||
clearInterval(positionTimer.value[postId]);
|
||||
@@ -104,7 +104,7 @@ onMounted(async () => {
|
||||
loading.value = false;
|
||||
});
|
||||
|
||||
function getLastPositionTime(time: number) {
|
||||
function getLastPositionTime(time: number): string {
|
||||
const day = Math.floor(time / (24 * 3600 * 1000));
|
||||
const hour = Math.floor((time % (24 * 3600 * 1000)) / (3600 * 1000));
|
||||
const minute = Math.floor((time % (3600 * 1000)) / (60 * 1000));
|
||||
@@ -114,7 +114,7 @@ function getLastPositionTime(time: number) {
|
||||
.padStart(2, "0")}:${second.toFixed(0).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
async function toPost(card: TGApp.Plugins.Mys.Position.RenderCard) {
|
||||
async function toPost(card: TGApp.Plugins.Mys.Position.RenderCard): Promise<void> {
|
||||
// 获取路由路径
|
||||
const path = router.resolve({
|
||||
name: "帖子详情",
|
||||
|
||||
@@ -163,7 +163,7 @@ const open = computed({
|
||||
},
|
||||
});
|
||||
|
||||
function collapse() {
|
||||
function collapse(): void {
|
||||
rail.value = !rail.value;
|
||||
appStore.sidebar.collapse = rail.value;
|
||||
}
|
||||
@@ -172,14 +172,14 @@ onMounted(async () => {
|
||||
await listenOnTheme();
|
||||
});
|
||||
|
||||
async function listenOnTheme() {
|
||||
async function listenOnTheme(): Promise<void> {
|
||||
await event.listen("readTheme", (e) => {
|
||||
const theme = e.payload as string;
|
||||
const theme = <string>e.payload;
|
||||
themeGet.value = theme === "default" ? "default" : "dark";
|
||||
});
|
||||
}
|
||||
|
||||
async function switchTheme() {
|
||||
async function switchTheme(): Promise<void> {
|
||||
await event.emit("readTheme", themeGet.value === "default" ? "dark" : "default");
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -2,16 +2,14 @@
|
||||
<div class="tsl-box">
|
||||
<img src="/src/assets/icons/arrow-right.svg" alt="right" />
|
||||
<slot>
|
||||
{{ title }}
|
||||
{{ props.title }}
|
||||
</slot>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
const props = defineProps<{
|
||||
title: string;
|
||||
}>();
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
.tsl-box {
|
||||
|
||||
@@ -31,14 +31,14 @@ onMounted(async () => {
|
||||
await listenOnTheme();
|
||||
});
|
||||
|
||||
async function switchTheme() {
|
||||
async function switchTheme(): Promise<void> {
|
||||
appStore.changeTheme();
|
||||
await event.emit("readTheme", themeGet.value);
|
||||
}
|
||||
|
||||
async function listenOnTheme() {
|
||||
async function listenOnTheme(): Promise<void> {
|
||||
await event.listen("readTheme", (e) => {
|
||||
const theme = e.payload as string;
|
||||
const theme = <string>e.payload;
|
||||
themeGet.value = theme === "default" ? "default" : "dark";
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user