♻️ types 重构后的问题搞完了,累死

This commit is contained in:
BTMuli
2023-05-23 00:56:43 +08:00
parent 573eb8bbe4
commit caadb5df79
38 changed files with 362 additions and 408 deletions

View File

@@ -23,7 +23,7 @@
</template>
<script lang="ts" setup>
interface TMiniWeaponProps {
item: BTMuli.Genshin.Material.BriefInfo;
item: TGApp.App.Calendar.Material;
}
defineProps<TMiniWeaponProps>();
</script>

View File

@@ -102,12 +102,12 @@
</template>
<script lang="ts" setup>
// vue
import { onMounted, ref } from "vue";
import { computed, onMounted, ref } from "vue";
import TMiniAvatar from "./t-mini-avatar.vue";
import TMiniWeapon from "./t-mini-weapon.vue";
import TCalendarMaterial from "./t-calendar-material.vue";
// data
import { TGAppData } from "../data";
import { AppCalendarData } from "../data";
// interface
import { OBC_CONTENT_API } from "../plugins/Mys/interface/utils";
import { createTGWindow } from "../utils/TGWindow";
@@ -116,19 +116,19 @@ import { createTGWindow } from "../utils/TGWindow";
const loading = ref(true as boolean);
// data
const calendarData = ref(TGAppData.calendar);
const calendarData = computed(() => AppCalendarData);
const weekNow = ref(0 as number);
const btnNow = ref(0 as number);
const dateNow = ref(new Date().toLocaleDateString());
// calendar
const calendarNow = ref([] as BTMuli.Genshin.Calendar.Data[]);
const characterCards = ref([] as BTMuli.Genshin.Calendar.Data[]);
const weaponCards = ref([] as BTMuli.Genshin.Calendar.Data[]);
const calendarNow = ref([] as TGApp.App.Calendar.Item[]);
const characterCards = ref([] as TGApp.App.Calendar.Item[]);
const weaponCards = ref([] as TGApp.App.Calendar.Item[]);
// calendar item
const showItem = ref(false as boolean);
const selectedItem = ref({} as BTMuli.Genshin.Calendar.Data);
const selectedItem = ref({} as TGApp.App.Calendar.Item);
const selectedType = ref("character");
// snackbar
@@ -177,38 +177,38 @@ onMounted(() => {
weekNow.value = dayNow;
btnNow.value = dayNow;
calendarNow.value = getCalendar(dayNow);
characterCards.value = calendarNow.value.filter((item) => item.item_type === "character");
weaponCards.value = calendarNow.value.filter((item) => item.item_type === "weapon");
characterCards.value = calendarNow.value.filter((item) => item.itemType === "character");
weaponCards.value = calendarNow.value.filter((item) => item.itemType === "weapon");
loading.value = false;
});
// 获取当前日历
function getCalendar (day: number) {
return calendarData.value.filter((item) => item.drop_day.includes(day));
return calendarData.value.filter((item) => item.dropDays.includes(day));
}
function selectContent (item: BTMuli.Genshin.Calendar.Data, type: string) {
function selectContent (item: TGApp.App.Calendar.Item, type: string) {
selectedItem.value = item;
selectedType.value = type;
showItem.value = true;
}
function showDetail (item: BTMuli.Genshin.Calendar.Data) {
if (item.content_id === null) {
function showDetail (item: TGApp.App.Calendar.Item) {
if (item.contentId === 0) {
snackbarText.value = "暂无详情";
snackbarColor.value = "error";
snackbar.value = true;
return;
}
const url = OBC_CONTENT_API.replace("{content_id}", item.content_id.toString());
const url = OBC_CONTENT_API.replace("{content_id}", item.contentId.toString());
createTGWindow(url, "素材详情", item.name, 1200, 800, true);
}
function getContents (day: number) {
btnNow.value = day;
calendarNow.value = getCalendar(day);
characterCards.value = calendarNow.value.filter((item) => item.item_type === "character");
weaponCards.value = calendarNow.value.filter((item) => item.item_type === "weapon");
characterCards.value = calendarNow.value.filter((item) => item.itemType === "character");
weaponCards.value = calendarNow.value.filter((item) => item.itemType === "weapon");
}
</script>
<style lang="css" scoped>

View File

@@ -2,20 +2,20 @@
<div class="card-box">
<!-- 底层背景图 -->
<div class="card-bg">
<img :src="item.bg" alt="bg">
<img :src="props.modelValue.bg" alt="bg">
</div>
<!-- 中层角色图 -->
<div class="card-icon">
<img :src="item.icon" alt="icon">
<img :src="props.modelValue.icon" alt="icon">
</div>
<!-- 上层图标&内容 -->
<div class="card-cover">
<div class="card-element">
<img :src="item.element" alt="element">
<img :src="props.modelValue.elementIcon" alt="element">
</div>
<div class="card-name">
<img :src="item.weapon_type" alt="weapon">
<span>{{ item.name }}</span>
<img :src="props.modelValue.weaponIcon" alt="weapon">
<span>{{ props.modelValue.name }}</span>
</div>
</div>
</div>
@@ -24,7 +24,7 @@
import { computed } from "vue";
interface TMiniWeaponProps {
size: string;
modelValue: BTMuli.Genshin.Wiki.Character.BriefInfo | BTMuli.Genshin.Calendar.Data
modelValue: TGApp.App.Character.WikiBriefInfo | TGApp.App.Calendar.Item;
}
const props = defineProps<TMiniWeaponProps>();
@@ -32,29 +32,6 @@ const props = defineProps<TMiniWeaponProps>();
const getSize = computed(() => {
return props.size === "100px" ? "30px" : "40px";
});
const item = computed(() => {
let res;
if (props.modelValue.hasOwnProperty("weapon_type")) {
res = props.modelValue as BTMuli.Genshin.Wiki.Character.BriefInfo;
return {
bg: res.bg,
icon: res.icon,
element: res.element,
weapon_type: res.weapon_type,
name: res.name,
};
} else {
res = props.modelValue as BTMuli.Genshin.Calendar.Data;
return {
bg: res.bg,
icon: res.icon,
element: res.element,
weapon_type: res.weapon,
name: res.name,
};
}
});
</script>
<style lang="css" scoped>
.card-box {

View File

@@ -2,19 +2,19 @@
<div class="card-box">
<!-- 底层背景图 -->
<div class="card-bg">
<img :src="item.bg" alt="bg">
<img :src="props.modelValue.bg" alt="bg">
</div>
<!-- 中层武器图 -->
<div class="card-icon">
<img :src="item.icon" alt="icon">
<img :src="props.modelValue.icon" alt="icon">
</div>
<!-- 上层图标&内容 -->
<div class="card-cover">
<div class="card-weapon">
<img :src="item.weapon_type" alt="type">
<img :src="props.modelValue.weaponIcon" alt="type">
</div>
<div class="card-name">
<span>{{ item.name }}</span>
<span>{{ props.modelValue.name }}</span>
</div>
</div>
</div>
@@ -23,36 +23,13 @@
import { computed } from "vue";
interface TMiniWeaponProps {
size: string;
modelValue: BTMuli.Genshin.Wiki.Weapon.BriefInfo | BTMuli.Genshin.Calendar.Data
modelValue: TGApp.App.Weapon.WikiBriefInfo | TGApp.App.Calendar.Item
}
const props = defineProps<TMiniWeaponProps>();
const getSize = computed(() => {
return props.size === "100px" ? "30px" : "40px";
});
const item = computed(() => {
let res;
if (!props.modelValue.hasOwnProperty("weapon_type")) {
res = props.modelValue as BTMuli.Genshin.Wiki.Weapon.BriefInfo;
return {
bg: res.bg,
icon: res.icon,
element: res.element,
weapon_type: res.type,
name: res.name,
};
} else {
res = props.modelValue as BTMuli.Genshin.Calendar.Data;
return {
bg: res.bg,
icon: res.icon,
element: res.element,
weapon_type: res.weapon_type,
name: res.name,
};
}
});
</script>
<style lang="css" scoped>
.card-box {