🐛 修复 Qodana 报错

This commit is contained in:
BTMuli
2023-07-29 14:15:26 +08:00
parent d1fa7348c8
commit 062e34e585
31 changed files with 216 additions and 162 deletions

View File

@@ -15,7 +15,7 @@ interface TurAvatarGridProps {
}
const props = defineProps<TurAvatarGridProps>();
const data = computed(() => JSON.parse(<string>props.modelValue) as TGApp.Sqlite.Record.Avatar[]);
const data = computed<TGApp.Sqlite.Record.Avatar[]>(() => JSON.parse(<string>props.modelValue));
</script>
<style lang="css" scoped>
.tur-ag-box {

View File

@@ -1,7 +1,7 @@
<template>
<div v-if="props.modelValue === undefined">暂无数据</div>
<div v-else class="tur-hg-box">
<TurHomeSub v-for="home in homes" :data="home" />
<TurHomeSub v-for="(home, index) in homes" :key="index" :data="home" />
</div>
</template>
<script lang="ts" setup>
@@ -14,11 +14,12 @@ interface TurHomeGridProps {
}
const props = defineProps<TurHomeGridProps>();
const homes = computed(() => {
const res = JSON.parse(props.modelValue || "[]") as TGApp.Sqlite.Record.Home[];
const homes = computed<TGApp.Sqlite.Record.Home[]>(() => {
const res = JSON.parse(props.modelValue ?? "[]");
if (res.length > 0) {
return res;
}
return [];
});
</script>
<style lang="css" scoped>

View File

@@ -28,7 +28,7 @@ interface TurOverviewGridProps {
}
const props = defineProps<TurOverviewGridProps>();
const data = computed(() => JSON.parse(<string>props.modelValue) as TGApp.Sqlite.Record.Stats);
const data = computed<TGApp.Sqlite.Record.Stats>(() => JSON.parse(<string>props.modelValue));
</script>
<style lang="css" scoped>
.tur-og-box {

View File

@@ -1,7 +1,7 @@
<template>
<div v-if="props.modelValue === undefined">暂无数据</div>
<div v-else class="tur-wg-box">
<TurWorldSub v-for="area in getData()" :data="area" :theme="theme" />
<TurWorldSub v-for="(area, index) in getData()" :key="index" :data="area" :theme="theme" />
</div>
</template>
<script lang="ts" setup>
@@ -23,8 +23,8 @@ const theme = computed(() => {
}
});
function getData() {
return JSON.parse(<string>props.modelValue) as TGApp.Sqlite.Record.WorldExplore[];
function getData(): TGApp.Sqlite.Record.WorldExplore[] {
return JSON.parse(<string>props.modelValue);
}
</script>
<style lang="css" scoped>

View File

@@ -69,9 +69,9 @@ onMounted(async () => {
: (getUrl.value.icon = getUrl.value.iconDark);
});
async function listenOnTheme() {
async function listenOnTheme(): Promise<void> {
await event.listen("readTheme", (e) => {
const theme = e.payload as string;
const theme = <string>e.payload;
if (theme === "dark") {
getUrl.value.icon = getUrl.value.iconLight;
} else {