-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
178 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<template> | ||
<TOverlay v-model="visible" hide :to-click="onCancel" blur-val="20px"> | ||
<div class="tolc-box"> | ||
<div class="tolc-title">兑换码</div> | ||
<v-list-item v-for="(item, index) in props.data" :key="index"> | ||
<template #title> | ||
{{ item.code }} | ||
</template> | ||
<template #subtitle> | ||
<div v-html="item.title"></div> | ||
<span>{{ timestampToDate(Number(item.to_get_time) * 1000) }} 过期</span> | ||
</template> | ||
<template #prepend> | ||
<img :src="item.img" alt="icon" /> | ||
</template> | ||
<template #append> | ||
<v-btn @click="copy(item.code)" icon="mdi-content-copy" variant="outlined"></v-btn> | ||
</template> | ||
</v-list-item> | ||
</div> | ||
</TOverlay> | ||
</template> | ||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import { timestampToDate } from "../../utils/toolFunc.js"; | ||
import showSnackbar from "../func/snackbar.js"; | ||
import TOverlay from "../main/t-overlay.vue"; | ||
interface ToLiveCodeProps { | ||
data: TGApp.BBS.Navigator.CodeData[]; | ||
modelValue: boolean; | ||
} | ||
type ToLiveCodeEmits = (e: "update:modelValue", value: boolean) => void; | ||
const props = withDefaults(defineProps<ToLiveCodeProps>(), { | ||
data: <TGApp.BBS.Navigator.CodeData[]>[], | ||
modelValue: false, | ||
}); | ||
const emits = defineEmits<ToLiveCodeEmits>(); | ||
const visible = computed<boolean>({ | ||
get: () => props.modelValue, | ||
set: (value) => { | ||
emits("update:modelValue", value); | ||
}, | ||
}); | ||
function onCancel(): void { | ||
visible.value = false; | ||
} | ||
function copy(code: string): void { | ||
navigator.clipboard.writeText(code); | ||
showSnackbar({ text: "已复制到剪贴板", color: "success" }); | ||
} | ||
</script> | ||
<style lang="css" scoped> | ||
.tolc-box { | ||
padding: 10px; | ||
border-radius: 10px; | ||
background: var(--app-page-bg); | ||
} | ||
.tolc-title { | ||
color: var(--common-text-title); | ||
font-family: var(--font-title); | ||
font-size: 20px; | ||
text-align: center; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @file web/request/getCode.ts | ||
* @description 获取兑换码相关请求 | ||
* @since Beta v0.5.3 | ||
*/ | ||
|
||
import TGHttp from "../../utils/TGHttp.js"; | ||
|
||
/** | ||
* @description 获取兑换码请求 | ||
* @since Beta v0.5.3 | ||
* @param {string} act_id - 活动 id | ||
* @return {Promise<TGApp.BBS.Navigator.CodeData[]|TGApp.BBS.Response.Base>} | ||
*/ | ||
async function getCode( | ||
act_id: string, | ||
): Promise<TGApp.BBS.Navigator.CodeData[] | TGApp.BBS.Response.Base> { | ||
const url = "https://api-takumi-static.mihoyo.com/event/miyolive/refreshCode"; | ||
const header = { "x-rpc-act_id": act_id }; | ||
const res = await TGHttp<TGApp.BBS.Navigator.CodeResponse | TGApp.BBS.Response.Base>(url, { | ||
method: "GET", | ||
headers: header, | ||
}); | ||
if (res.retcode !== 0) return <TGApp.BBS.Response.Base>res; | ||
return res.data.code_list; | ||
} | ||
|
||
export default getCode; |