♻️ 更新5.5名片资源,重构名片数据结构

#147
This commit is contained in:
目棃
2025-03-27 11:02:09 +08:00
parent 3769859611
commit 082fe9dfab
19 changed files with 812 additions and 819 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -14,7 +14,7 @@
<span>{{ parseNameCard(props.data.desc) }}</span>
<span>获取途径{{ props.data.source }}</span>
</div>
<div class="ton-type">{{ getType }}</div>
<div class="ton-type">{{ props.data.type }}</div>
<v-btn
class="ton-share"
@click="shareNameCard"
@@ -32,7 +32,7 @@
</template>
<script setup lang="ts">
import showSnackbar from "@comp/func/snackbar.js";
import { computed, ref } from "vue";
import { ref } from "vue";
import TOverlay from "./t-overlay.vue";
@@ -42,20 +42,7 @@ type ToNameCardProps = { data?: TGApp.App.NameCard.Item };
const props = defineProps<ToNameCardProps>();
const visible = defineModel<boolean>();
const typeMap: Record<number, string> = {
0: "其他",
1: "成就",
2: "角色",
3: "纪行",
4: "活动",
5: "未知",
};
const loading = ref<boolean>(false);
const getType = computed<string>(() => {
if (!props.data) return typeMap[0];
if (!(props.data.type in typeMap)) return typeMap[5];
return typeMap[props.data.type];
});
function parseNameCard(desc: string): string {
let array = [];
@@ -89,7 +76,7 @@ function parseNameCard(desc: string): string {
function parseDesc(desc: string, inQuote: boolean = false): string[] {
let res = desc.replace(/。/g, "。\n");
res = res.replace(//g, "\n");
if (props?.data?.index !== 187) {
if (props?.data?.id !== 210187) {
res = res.replace(//g, "\n");
res = res.replace(//g, "\n");
} else {
@@ -118,7 +105,7 @@ async function shareNameCard(): Promise<void> {
showSnackbar.error("未找到名片内容");
return;
}
const fileName = `${getType.value}名片】-${props.data?.name}`;
const fileName = `${props.data?.type}名片】-${props.data?.name}`;
loading.value = true;
await generateShareImg(fileName, nameCardBox);
loading.value = false;

File diff suppressed because it is too large Load Diff

View File

@@ -48,7 +48,7 @@ const sortNameCardsData = shallowRef<Array<TGApp.App.NameCard.Item>>([]);
onMounted(() => sortData(AppNameCardsData));
function sortData(data: TGApp.App.NameCard.Item[]): void {
sortNameCardsData.value = data.sort((a, b) => a.type - b.type || a.index - b.index);
sortNameCardsData.value = data.sort((a, b) => a.type.localeCompare(b.type) || a.id - b.id);
curIndex.value = 0;
total.value = sortNameCardsData.value.length;
curNameCard.value = sortNameCardsData.value[curIndex.value];

View File

@@ -1,21 +1,20 @@
/**
* @file types/App/NameCard.d.ts
* @description 本应用的名片类型定义
* @since Beta v0.6.7
* @since Beta v0.7.2
*/
declare namespace TGApp.App.NameCard {
/**
* @description 名片数据
* @since Beta v0.6.7
* @since Beta v0.7.2
* @interface Item
* @property {string} name - 名片名称
* @property {number} index - 名片索引
* @property {string} desc - 名片描述
* @description 0: 其他1: 成就2角色3纪行4活动
* @property {number} type - 名片类型
* @property {string} source - 名片来源
* @property {number} id 编号
* @property {string} name 名称
* @property {string} type 类型
* @property {string} desc 描述
* @property {string} source 来源
* @return Item
*/
type Item = { name: string; index: number; desc: string; type: number; source: string };
type Item = { id: number; name: string; type: string; desc: string; source: string };
}