mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-05-21 05:25:45 +08:00
🚸 首页活动组件(用户)分享图生成
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
|
<!-- 近期活动卡片组件(用户)-->
|
||||||
<template>
|
<template>
|
||||||
<div class="ph-pos-user-card">
|
<div class="ph-pos-user-card" ref="posRef">
|
||||||
<div class="ph-puc-top">
|
<div class="ph-puc-top">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<v-icon title="已完成" color="var(--tgc-od-green)" v-if="props.pos.is_finished">
|
<v-icon title="已完成" color="var(--tgc-od-green)" v-if="props.pos.is_finished">
|
||||||
mdi-checkbox-marked-circle-outline
|
mdi-checkbox-marked-circle-outline
|
||||||
</v-icon>
|
</v-icon>
|
||||||
<v-icon v-else title="未完成" color="var(--tgc-od-white)">mdi-circle</v-icon>
|
<v-icon v-else title="未完成" color="var(--tgc-od-white)">mdi-circle</v-icon>
|
||||||
<span>{{ props.pos.name }}</span>
|
<span @click="sharePos()" title="点击分享">{{ props.pos.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="subtitle">
|
<div class="subtitle">
|
||||||
<!-- 处理幽境危战 -->
|
<!-- 处理幽境危战 -->
|
||||||
@@ -63,7 +64,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="ph-puc-duration">
|
<div class="ph-puc-duration">
|
||||||
<template v-if="isStart">
|
<template v-if="isStart">
|
||||||
<span title="剩余时间">{{ stamp2LastTime(restTs * 1000) }}</span>
|
<span title="剩余时间" data-html2canvas-ignore>{{ stamp2LastTime(restTs * 1000) }}</span>
|
||||||
<span title="活动时间">
|
<span title="活动时间">
|
||||||
{{ timestampToDate(Number(props.pos.start_timestamp) * 1000) }} ~
|
{{ timestampToDate(Number(props.pos.start_timestamp) * 1000) }} ~
|
||||||
{{ timestampToDate(Number(props.pos.end_timestamp) * 1000) }}
|
{{ timestampToDate(Number(props.pos.end_timestamp) * 1000) }}
|
||||||
@@ -92,8 +93,9 @@
|
|||||||
import TMiImg from "@comp/app/t-mi-img.vue";
|
import TMiImg from "@comp/app/t-mi-img.vue";
|
||||||
import { ActCalendarTypeEnum } from "@enum/game.js";
|
import { ActCalendarTypeEnum } from "@enum/game.js";
|
||||||
import { getHardChallengeDesc } from "@Sql/utils/transUserRecord.js";
|
import { getHardChallengeDesc } from "@Sql/utils/transUserRecord.js";
|
||||||
|
import { generateShareImg } from "@utils/TGShare.js";
|
||||||
import { stamp2LastTime, timestampToDate } from "@utils/toolFunc.js";
|
import { stamp2LastTime, timestampToDate } from "@utils/toolFunc.js";
|
||||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
import { computed, onMounted, onUnmounted, ref, useTemplateRef } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
|
||||||
type PhCompPositionUserProps = { pos: TGApp.Game.ActCalendar.ActItem };
|
type PhCompPositionUserProps = { pos: TGApp.Game.ActCalendar.ActItem };
|
||||||
@@ -105,6 +107,7 @@ const router = useRouter();
|
|||||||
|
|
||||||
const props = defineProps<PhCompPositionUserProps>();
|
const props = defineProps<PhCompPositionUserProps>();
|
||||||
const emits = defineEmits<PhCompPositionUserEmits>();
|
const emits = defineEmits<PhCompPositionUserEmits>();
|
||||||
|
const posEl = useTemplateRef<HTMLDivElement>("posRef");
|
||||||
|
|
||||||
const endTs = ref<number>(0);
|
const endTs = ref<number>(0);
|
||||||
const restTs = ref<number>(0);
|
const restTs = ref<number>(0);
|
||||||
@@ -159,6 +162,11 @@ function getCombatStat(detail: TGApp.Game.ActCalendar.ActRoleCombat): string {
|
|||||||
if (detail.difficulty_id < 5) return `第${detail.max_round_id}幕`;
|
if (detail.difficulty_id < 5) return `第${detail.max_round_id}幕`;
|
||||||
return `月谕模式·第${detail.max_round_id}幕·圣牌${detail.tarot_finished_cnt}`;
|
return `月谕模式·第${detail.max_round_id}幕·圣牌${detail.tarot_finished_cnt}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function sharePos(): Promise<void> {
|
||||||
|
if (!posEl.value) return;
|
||||||
|
await generateShareImg(`活动-${props.pos.name}.png`, posEl.value, 2);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.ph-pos-user-card {
|
.ph-pos-user-card {
|
||||||
@@ -191,6 +199,10 @@ function getCombatStat(detail: TGApp.Game.ActCalendar.ActRoleCombat): string {
|
|||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
column-gap: 4px;
|
column-gap: 4px;
|
||||||
font-family: var(--font-title);
|
font-family: var(--font-title);
|
||||||
|
|
||||||
|
span {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtitle {
|
.subtitle {
|
||||||
@@ -268,6 +280,7 @@ function getCombatStat(detail: TGApp.Game.ActCalendar.ActRoleCombat): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
width: 40px;
|
width: 40px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file utils/TGShare.ts
|
* @file utils/TGShare.ts
|
||||||
* @description 生成分享截图并保存到本地
|
* @description 生成分享截图并保存到本地
|
||||||
* @since Beta v0.8.2
|
* @since Beta v0.8.3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import showSnackbar from "@comp/func/snackbar.js";
|
import showSnackbar from "@comp/func/snackbar.js";
|
||||||
@@ -86,7 +86,7 @@ function getShareImgBgColor(): string {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 生成分享截图
|
* @description 生成分享截图
|
||||||
* @since Beta v0.8.2
|
* @since Beta v0.8.3
|
||||||
* @param {string} fileName - 文件名
|
* @param {string} fileName - 文件名
|
||||||
* @param {HTMLElement} element - 元素
|
* @param {HTMLElement} element - 元素
|
||||||
* @param {number} scale - 缩放比例
|
* @param {number} scale - 缩放比例
|
||||||
@@ -114,7 +114,7 @@ export async function generateShareImg(
|
|||||||
height,
|
height,
|
||||||
useCORS: true,
|
useCORS: true,
|
||||||
canvas,
|
canvas,
|
||||||
x: -10,
|
x: -15,
|
||||||
y: -15,
|
y: -15,
|
||||||
dpi: 350,
|
dpi: 350,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user