Skip to content

Commit

Permalink
fix: type related errors
Browse files Browse the repository at this point in the history
  • Loading branch information
HoraceHuang-ui committed Jan 5, 2024
1 parent 85a6ad3 commit 604fa91
Show file tree
Hide file tree
Showing 10 changed files with 295 additions and 281 deletions.
357 changes: 181 additions & 176 deletions electron/main/index.ts

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/components/CustomUIDInput.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<script setup lang="ts">
defineProps(['modelValue'])
defineEmits(['submit', 'update:modelValue'])
const handleInputChange = (event: Event) => {
(event.target as HTMLInputElement).value
}
</script>

<template>
<div class="flex flex-row rounded-full border border-gray-400 h-10">
<input class="px-2 rounded-full" :placeholder="$t('uidInput_placeholder')" style="width: 16vw; margin: 1px;"
:value="modelValue" @input="$emit('update:modelValue', $event.target.value)"
:value="modelValue" @input="$emit('update:modelValue', handleInputChange($event))"
@keyup.native.enter="$emit('submit')"/>
<button
class="rounded-full bg-gray-100 px-3 hover:bg-gray-300 active:bg-gray-500 active:scale-90 transition-all"
Expand Down
15 changes: 8 additions & 7 deletions src/components/TemplateDialog.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import {inject, ref} from 'vue'
defineProps({
const props = defineProps({
width: {
type: String,
default: '50%'
Expand All @@ -25,19 +25,20 @@ const cShow = ref(show)
const closeDialog = (timeout: number) => {
cShow.value = false
setTimeout(unmount, timeout)
props.onClose()
}
const cancelClick = () => {
emit('onCancel')
closeDialog(500)
props.onCancel()
if (props.onCancel) {
props.onCancel()
}
}
const okClick = () => {
emit('onOk')
closeDialog(500)
props.onOk()
if (props.onOk) {
props.onOk()
}
}
defineExpose({
Expand All @@ -50,7 +51,7 @@ defineExpose({
<div v-if="cShow">
<div
class="outer absolute top-0 bottom-0 left-0 right-0 z-50 backdrop-blur-2xl"
@click="closeDialog(500)"
@click="cancelClick"
/>
<div class="bg-black bg-opacity-20 outer absolute top-0 bottom-0 left-0 right-0 z-40"/>
<div
Expand Down
106 changes: 53 additions & 53 deletions src/pages/GenshinPage/Components/GenshinInfoCard.vue

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/pages/GenshinPage/GenshinPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ onMounted(async () => {
if (timeDelta.value > 40) {
ElMessageBox.confirm(translate('general_gameUpdBoxText1', {
game: gameName,
beDays: translate('general_beDays', undefined, 42 - timeDelta.value)
beDays: translate('general_beDays', 42 - timeDelta.value)
}),
translate('general_gameUpdBoxTitle'),
{
Expand All @@ -80,7 +80,7 @@ onMounted(async () => {
} else if (timeDelta.value > 0 && timeDelta.value < 3) {
ElMessageBox.confirm(translate('general_gameUpdBoxText2', {
game: gameName,
days: translate('general_days', undefined, timeDelta.value)
days: translate('general_days', timeDelta.value)
}),
translate('general_gameUpdBoxTitle'),
{
Expand Down
26 changes: 10 additions & 16 deletions src/pages/Honkai3Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {computed, onMounted, ref} from 'vue'
import {useRouter} from 'vue-router'
import {translate} from '../i18n'
import {LauncherInfo, PostInfo} from "../types/launcher/launcherInfo";
const gameName = translate('general_hi3')
Expand All @@ -14,7 +15,7 @@ const timeNow = Date.now()
const timeDelta = computed(() =>
Math.ceil((timeNow - timeUpd6_8) / 1000 / 3600 / 24 - 0.5) % 42
)
const launcherInfo = ref({})
const launcherInfo = ref<LauncherInfo>({banner: [], icon: [], post: [], qq: []})
const launcherInfoReady = ref(false)
const launcherInfoFailed = ref(false)
const errMsg = ref('')
Expand All @@ -30,7 +31,7 @@ onMounted(async () => {
window.axios.post(translate('hi3_launcherContentsUrl'))
.then((value) => {
launcherInfo.value = value.data
launcherInfo.value.post.forEach(post => {
launcherInfo.value.post.forEach((post: PostInfo) => {
let tmp = postTypeMap.get(post.type)
if (tmp) {
tmp.push(post)
Expand All @@ -53,7 +54,7 @@ onMounted(async () => {
if (timeDelta.value > 40) {
ElMessageBox.confirm(translate('general_gameUpdBoxText1', {
game: gameName,
beDays: translate('general_beDays', undefined, 42 - timeDelta.value)
beDays: translate('general_beDays', 42 - timeDelta.value)
}),
translate('general_gameUpdBoxTitle'),
{
Expand All @@ -68,7 +69,7 @@ onMounted(async () => {
} else if (timeDelta.value > 0 && timeDelta.value < 3) {
ElMessageBox.confirm(translate('general_gameUpdBoxText2', {
game: gameName,
days: translate('general_days', undefined, timeDelta.value)
days: translate('general_days', timeDelta.value)
}),
translate('general_gameUpdBoxTitle'),
{
Expand Down Expand Up @@ -145,7 +146,7 @@ const hiLaunch = async () => {
}
}
const handleCommand = (command) => {
const handleCommand = (command: string) => {
switch (command) {
case 'openLauncher':
window.child.exec(hiLauncherPath.value)
Expand All @@ -169,16 +170,8 @@ const handleCommand = (command) => {
}
}
const handleScroll = ({scrollTop}) => {
if (scrollTop > 0) {
hideElements.value = true
if (displayConfirm.value) {
displayConfirm.value = false
path.value = ''
}
} else {
hideElements.value = false
}
const handleScroll = ({scrollTop}: Record<string, number>) => {
hideElements.value = scrollTop > 0;
}
const router = useRouter()
Expand Down Expand Up @@ -257,7 +250,8 @@ const onImportDialogClose = () => {
:class="{ 'scale-95': hideElements }">
<img class=" top-0 rounded-3xl transition-all"
:class="hideElements ? 'blur-md scale-125 brightness-75' : ''"
style="transition-duration: 500ms;" :src="launcherInfoReady ? launcherInfo.adv.background : ''"
style="transition-duration: 500ms;"
:src="launcherInfo.adv && launcherInfoReady ? launcherInfo.adv.background : ''"
@touchmove.prevent @mousewheel.prevent/>
</div>
<LauncherBanner class="absolute left-16 top-48 z-50 rounded-xl transition-all"
Expand Down
32 changes: 21 additions & 11 deletions src/pages/StarRailPage/Components/StarRailInfoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ import SRCharDetailsDialog from "./SRCharDetailsDialog.vue";
const apiUrl = 'https://raw.githubusercontent.com/Mar-7th/StarRailRes/master/'
const playerInfo = ref<FormattedApiInfo>({characters: [], player: undefined})
const playerInfo = ref<FormattedApiInfo>({
characters: [], player: {
uid: '',
nickname: '',
level: 0,
world_level: 0,
friend_count: 0,
signature: '',
is_display: false
}
})
const playerInfoReady = ref(false)
const playerInfoLoading = ref(false)
const playerInfoFailed = ref(false)
Expand Down Expand Up @@ -311,9 +321,9 @@ const showCharDetails = (index: number) => {
</div>
<!-- 角色详情卡片 -->
<div v-for="(character, index) in playerInfo.characters" class="z-0 relative w-full">
<div class="mt-4 w-full absolute top-0 left-0 right-0 transition-all" :class="{ 'opacity-0 translate-x-40 pointer-events-none': showcaseIdx < index },
{ 'opacity-100 pointer-events-auto': showcaseIdx == index },
{ 'opacity-0 -translate-x-40 pointer-events-none': showcaseIdx > index }"
<div class="mt-4 w-full absolute top-0 left-0 right-0 transition-all" :class="{ 'opacity-0 translate-x-40 pointer-events-none': showcaseIdx < index,
'opacity-100 pointer-events-auto': showcaseIdx == index,
'opacity-0 -translate-x-40 pointer-events-none': showcaseIdx > index }"
style="transition-duration: 300ms;">
<!-- absolute: 卡片元素背景、元素图标 -->
<img class="relative z-0 w-full" src="../../../assets/srBg.jpg" style="border-radius: 4.5vh;"/>
Expand Down Expand Up @@ -553,10 +563,10 @@ const showCharDetails = (index: number) => {
<div class=" w-full h-full relative">
<div class="text-gray-400 absolute right-0 top-1 flex flex-row">
{{ relic.name }}
<div :class="{ 'border-orange-400 bg-orange-900 text-orange-300': relic.rarity == 5 },
{ 'border-purple-400 bg-purple-900 text-purple-300': relic.rarity == 4 },
{ 'border-blue-400 bg-blue-900 text-blue-300': relic.rarity == 3 },
{ 'border-green-400 bg-green-900 text-green-300': relic.rarity == 2 }"
<div :class="{ 'border-orange-400 bg-orange-900 text-orange-300': relic.rarity == 5,
'border-purple-400 bg-purple-900 text-purple-300': relic.rarity == 4,
'border-blue-400 bg-blue-900 text-blue-300': relic.rarity == 3 ,
'border-green-400 bg-green-900 text-green-300': relic.rarity == 2 }"
class="h-full justify-end ml-2 font-sr-sans rounded-full border px-2">
+{{ relic.level }}
</div>
Expand All @@ -568,13 +578,13 @@ const showCharDetails = (index: number) => {
class="h-5 w-5 mr-2" style="margin-top: 6px;"/>
<el-text class="text-gray-200 text-lg" truncated style="max-width: 220px;">
{{
relic.main_affix['name']
relic.main_affix.name
}}
</el-text>
</div>
<div>
<span class="text-gray-200 text-3xl ml-2 font-sr-sans">{{
relic.main_affix['display']
relic.main_affix.display
}}</span>
</div>
</div>
Expand All @@ -587,7 +597,7 @@ const showCharDetails = (index: number) => {
class="h-5 w-5 mr-2"
style="margin-top: 4px;"/>
<span class="text-gray-200 font-sr-sans text-xl ml-2">{{
substat['display']
substat.display
}}</span>
</div>
<div class="flex flex-row mr-5">
Expand Down
19 changes: 6 additions & 13 deletions src/pages/StarRailPage/StarRailPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import StarRailInfoCard from "./Components/StarRailInfoCard.vue";
import {useDialog} from "../../utils/template-dialog";
import StarRailDialog from "./Components/StarRailDialog.vue";
import SRImportDialog from "./Components/SRImportDialog.vue";
import {LauncherInfo, PostInfo} from "../../types/launcher/launcherInfo";
const gameName = translate('general_sr')
Expand All @@ -19,7 +20,7 @@ const timeNow = Date.now()
const timeDelta = computed(() =>
Math.ceil((timeNow - timeUpd1_4) / 1000 / 3600 / 24 - 0.5) % 42
)
const launcherInfo = ref({})
const launcherInfo = ref<LauncherInfo>({banner: [], icon: [], post: [], qq: []})
const launcherInfoReady = ref(false)
const launcherInfoFailed = ref(false)
const errMsg = ref('')
Expand All @@ -32,7 +33,7 @@ onMounted(async () => {
window.axios.post(translate('sr_launcherContentsUrl'))
.then((value) => {
launcherInfo.value = value.data
launcherInfo.value.post.forEach(post => {
launcherInfo.value.post.forEach((post: PostInfo) => {
let tmp = postTypeMap.get(post.type)
if (tmp) {
tmp.push(post)
Expand Down Expand Up @@ -116,7 +117,7 @@ const srLaunch = async () => {
}
}
const handleCommand = (command) => {
const handleCommand = (command: string) => {
switch (command) {
case 'openLauncher':
window.child.exec(srLauncherPath.value)
Expand All @@ -135,16 +136,8 @@ const handleCommand = (command) => {
}
}
const handleScroll = ({scrollTop}) => {
if (scrollTop > 0) {
hideElements.value = true
if (displayConfirm.value) {
displayConfirm.value = false
path.value = ''
}
} else {
hideElements.value = false
}
const handleScroll = ({scrollTop}: Record<string, number>) => {
hideElements.value = scrollTop > 0;
}
const router = useRouter()
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tmpPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {useRoute, useRouter} from 'vue-router'
const router = useRouter()
const route = useRoute()
onMounted(() => {
router.push(route.query.from)
router.push(route.query.from as string)
})
</script>

Expand Down
9 changes: 8 additions & 1 deletion src/types/starrail/srPlayerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export interface PropertyInfo {
}

export interface SubAffixInfo {
type: string
field: string
name: string
icon: string
value: number
display: string
percent: boolean
count: number
step: number
}
Expand All @@ -78,7 +85,7 @@ export interface RelicInfo {
rarity: number
level: number
icon: string
main_affix: PropertyInfo[]
main_affix: PropertyInfo
sub_affix: SubAffixInfo[]
}

Expand Down

0 comments on commit 604fa91

Please sign in to comment.