Skip to content

Commit

Permalink
💩 分享图生成错误
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Nov 25, 2023
1 parent b1424fb commit 5f3f664
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 8 deletions.
21 changes: 18 additions & 3 deletions src/components/devCharacter/duc-detail-olb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,30 @@
</div>
</template>
<script lang="ts" setup>
import { computed } from "vue";
import { onMounted, onUpdated, reactive } from "vue";
import { saveImgLocal } from "../../utils/TGShare";
interface DucDetailOlbProps {
modelValue: TGApp.Sqlite.Character.RoleConstellation[];
}
const props = defineProps<DucDetailOlbProps>();
const constellations = computed(() => {
return props.modelValue ?? [];
let constellations = reactive<TGApp.Sqlite.Character.RoleConstellation[]>([]);
function loadData() {
constellations = props.modelValue;
constellations.map(
async (constellation) => (constellation.icon = await saveImgLocal(constellation.icon)),
);
}
onMounted(() => {
loadData();
});
onUpdated(() => {
loadData();
});
</script>
<style>
Expand Down
2 changes: 1 addition & 1 deletion src/components/devCharacter/duc-detail-olt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const getTitle = computed(() => {
}, "");
}
});
const boxData = computed<TItemBoxData>(() => {
const boxData = computed(() => {
if (props.mode === "avatar") {
return {
bg: `/icon/bg/${props.data.star}-Star.webp`,
Expand Down
28 changes: 25 additions & 3 deletions src/components/devCharacter/duc-detail-ort.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
<template>
<div class="duc-dort-box">
<div :title="talent.name" v-for="talent in talents" :key="talent.pos" class="duc-dort-item">
<span>{{ talent.name }}</span>
<img :src="talent.icon" alt="talent" />
<span>Lv.{{ talent.level }}</span>
</div>
</div>
</template>
<script lang="ts" setup>
import { computed } from "vue";
import { onMounted, onUpdated, reactive } from "vue";
import { saveImgLocal } from "../../utils/TGShare";
interface DucDetailOrtProps {
modelValue: TGApp.Sqlite.Character.RoleTalent[];
}
const props = defineProps<DucDetailOrtProps>();
const talents = computed(() => {
return props.modelValue ?? [];
let talents = reactive<TGApp.Sqlite.Character.RoleTalent[]>([]);
async function loadData(): Promise<void> {
talents = props.modelValue;
for (const talent of talents) {
talent.icon = await saveImgLocal(talent.icon);
}
}
onMounted(async () => {
await loadData();
});
onUpdated(async () => {
await loadData();
});
</script>
<style lang="css" scoped>
Expand All @@ -27,6 +43,7 @@ const talents = computed(() => {
.duc-dort-item {
display: flex;
justify-content: flex-end;
column-gap: 10px;
}
Expand All @@ -47,4 +64,9 @@ const talents = computed(() => {
font-size: 16px;
text-shadow: 0 0 5px rgba(0 0 0/40%);
}
.duc-dort-item :nth-last-child(1) {
width: 48px;
justify-content: flex-start;
}
</style>
24 changes: 23 additions & 1 deletion src/components/devCharacter/duc-detail-overlay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
<div class="duc-doc-lt">
<DucDetailOlt :data="props.dataVal" mode="avatar" />
<DucDetailOlt :data="JSON.parse(props.dataVal.weapon)" mode="weapon" />
<!-- todo cors -->
<v-btn
class="duc-doc-btn"
@click="share"
variant="outlined"
:loading="loading"
data-html2canvas-ignore
>
<v-icon>mdi-share-variant</v-icon>
<span>分享</span>
</v-btn>
</div>
<!-- 右侧天赋 -->
<div class="duc-doc-rt">
Expand All @@ -37,6 +48,8 @@ import DucDetailOlb from "./duc-detail-olb.vue";
import DucDetailOlt from "./duc-detail-olt.vue";
import DucDetailOrt from "./duc-detail-ort.vue";
import TGSqlite from "../../plugins/Sqlite";
import { generateShareImg } from "../../utils/TGShare";
import showSnackbar from "../func/snackbar";

Check warning on line 52 in src/components/devCharacter/duc-detail-overlay.vue

View workflow job for this annotation

GitHub Actions / qodana

Unused import

Unused import showSnackbar from "../func/snackbar";
import TOverlay from "../main/t-overlay.vue";
interface DucDetailOverlayProps {
Expand All @@ -61,6 +74,8 @@ const visible = computed({
// 渲染数据
const nameCard = ref<string | false>(false);
// 加载
const loading = ref<boolean>(false);
function onOverlayCancel() {
visible.value = false;
Expand All @@ -84,7 +99,14 @@ async function loadData(): Promise<void> {
const role = await TGSqlite.getAppCharacter(props.dataVal.cid);
nameCard.value = `/source/nameCard/profile/${role.nameCard}.webp`;
}
// resetData();
}
async function share(): Promise<void> {
const detailBox = <HTMLElement>document.querySelector(".duc-do-container");
const fileName = `【角色详情】-${props.dataVal.name}`;
loading.value = true;
await generateShareImg(fileName, detailBox);
loading.value = false;
}
</script>
<style lang="css" scoped>
Expand Down

0 comments on commit 5f3f664

Please sign in to comment.