🌱 添加 wiki 武器类型相关

This commit is contained in:
BTMuli
2023-12-15 18:27:55 +08:00
parent dffb1475f8
commit a9f80da053
7 changed files with 143 additions and 12 deletions

View File

@@ -33,6 +33,10 @@ export async function getWikiData(
dir: "Character",
name: string,
): Promise<{ default: TGApp.App.Character.WikiItem } | undefined>;
export async function getWikiData(
dir: "Weapon",
name: string,
): Promise<{ default: TGApp.App.Weapon.WikiItem } | undefined>;
export async function getWikiData(dir: string, name: string): Promise<any> {
return await wikiFiles[`./wiki/${dir}/${name}.json`]();
}

View File

@@ -13,18 +13,25 @@ import { ref, computed } from "vue";
import TibWikiWeapon from "../../components/itembox/tib-wiki-weapon.vue";
import { AppWeaponData } from "../../data";
import Mys from "../../plugins/Mys";
import { createTGWindow } from "../../utils/TGWindow";
import { useAppStore } from "../../store/modules/app";
import { createTGWindow, createWiki } from "../../utils/TGWindow";
// snackbar
const snackbar = ref<boolean>(false);
// data
const cardsInfo = computed(() => AppWeaponData);
const appStore = useAppStore();
function toOuter(item: TGApp.App.Weapon.WikiBriefInfo): void {
if (item.contentId === 0) {
snackbar.value = true;
return;
}
// 如果是调试环境,打开 wiki 页面
if (appStore.devMode) {
createWiki("Weapon", item.id.toString());
return;
}
const url = Mys.Api.Obc.replace("{contentId}", item.contentId.toString());
createTGWindow(url, "Sub_window", `Content_${item.contentId} ${item.name}`, 1200, 800, true);
}

0
src/plugins/Hutao/types/Material.d.ts vendored Normal file
View File

68
src/plugins/Hutao/types/Weapon.d.ts vendored Normal file
View File

@@ -0,0 +1,68 @@
/**
* @file plugins/Hutao/types/Weapon.d.ts
* @description 武器组件类型定义
* @since Beta v0.3.8
*/
/**
* @description 武器类型 namespace
* @since Beta v0.3.8
* @namespace TGApp.Plugins.Hutao.Weapon
* @memberof TGApp.Plugins.Hutao
*/
declare namespace TGApp.Plugins.Hutao.Weapon {
/**
* @description 元数据-胡桃
* @since Beta v0.3.8
* @memberof TGApp.Plugins.Hutao.Weapon
* @description RawHutaoItem => Rhi
* @property {number} Id 角色编号
* @property {number} PromoteId 未知
* @property {TGApp.Plugins.Hutao.Base.WeaponType} WeaponType 武器类型
* @property {number} RankLevel 武器星级
* @property {string} Name 武器名称
* @property {string} Description 武器简介
* @property {string} Icon 武器图标
* @property {string} AwakenIcon 武器觉醒图标
* @property {number} GrowCurves.InitValue 未知
* @property {number} GrowCurves.Type 未知
* @property {number} GrowCurves.Value 未知
* @property {RhiAffix} Affix 精炼描述
* @property {number[]} CultivationItems 武器培养材料
* @return RawHutaoItem
*/
interface RawHutaoItem {
Id: number;
PromoteId: number;
WeaponType: TGApp.Plugins.Hutao.Base.WeaponType;
RankLevel: number;
Name: string;
Description: string;
Icon: string;
AwakenIcon: string;
GrowCurves: {
InitValue: number;
Type: number;
Value: number;
};
Affix: RhiAffix;
CultivationItems: number[];
}
/**
* @description 精炼描述
* @since Beta v0.3.8
* @memberof TGApp.Plugins.Hutao.Weapon
* @interface RhiAffix
* @property {string} Name 精炼名称
* @property {Array<{Level: number; Description: string}>} Description 精炼描述
* @return RhiAffix
*/
interface RhiAffix {
Name: string;
Description: Array<{
Level: number;
Description: string;
}>;
}
}

View File

@@ -1,8 +1,7 @@
/**
* @file types App Weapon.d.ts
* @file types/App/Weapon.d.ts
* @description 本应用的武器类型定义文件
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha v0.1.5
* @since Beta v0.3.8
*/
declare namespace TGApp.App.Weapon {
@@ -28,4 +27,30 @@ declare namespace TGApp.App.Weapon {
weaponIcon: string;
icon: string;
}
/**
* @description 转换后的武器数据
* @since Beta v0.3.8
* @interface WikiItem
* @memberof TGApp.App.Weapon
* @property {number} id 武器 id
* @property {string} name 武器名称
* @property {string} description 武器简介
* @property {number} star 武器星级
* @property {string} weapon 武器类型
* @property {TGApp.App.Calendar.Material[]} materials 武器培养材料
* @property {TGACore.Components.Weapon.RhiAffix} affix 精炼描述
* @property {string} story 武器故事
* @return WikiItem
*/
interface WikiItem {
id: number;
name: string;
description: string;
star: number;
weapon: string;
materials: TGApp.App.Calendar.Material[];
affix: TGACore.Components.Weapon.RhiAffix;
story: string;
}
}

View File

@@ -127,7 +127,6 @@ export function createAnno(item: TGApp.App.Announcement.ListCard): void {
* @returns {void}
*/
export function createWiki(dir: string, name: string): void {
// if(dir !== "Character") return;
const dirName = dir === "GCG" ? dir : dir.toLowerCase();
const wikiPath = `/wiki/detail/${dirName}/${name}`;
createTGWindow(wikiPath, "Sub_window", `Wiki_${dirName}_${name}`, 960, 720, false, false);

View File

@@ -1,25 +1,53 @@
<template></template>
<template>
<ToLoading v-model="loading" :empty="loadingEmpty" :title="loadingTitle" :subtitle="loadingSub" />
<div class="ww-box">
{{ data }}
</div>
</template>
<script lang="ts" setup>
import { appWindow } from "@tauri-apps/api/window";
import { onMounted, ref } from "vue";
import { useRoute } from "vue-router";
import showSnackbar from "../../components/func/snackbar";
import ToLoading from "../../components/overlay/to-loading.vue";
import { getWikiData } from "../../data";
// 路由数据
const id = <string>useRoute().params.id;
const data = ref<any>();
// 加载
const loading = ref<boolean>(true);
const loadingEmpty = ref<boolean>(false);
const loadingTitle = ref<string>("正在加载");
const loadingSub = ref<string>();
// 数据
const data = ref<TGApp.App.Weapon.WikiItem>();
onMounted(async () => {
await appWindow.show();
try {
const res = await getWikiData("Weapon", id);
data.value = res.default;
} catch (e) {
console.error(e);
if (res !== undefined) {
data.value = res.default;
}
loading.value = false;
} catch (error) {
loadingEmpty.value = true;
if (error instanceof Error) {
loadingTitle.value = error.name;
loadingSub.value = error.message;
} else {
loadingTitle.value = "未知错误";
loadingSub.value = <string>error;
}
showSnackbar({
text: "Wiki 数据获取失败",
text: "Wiki 数据获取失败,即将关闭窗口",
color: "error",
});
history.back();
// setTimeout(() => {
// appWindow.close();
// }, 3000);
}
});
</script>