mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
@@ -66,7 +66,9 @@ function handleSelectW(val: SelectedWValue) {
|
|||||||
const reg = /\/icon\/weapon\/(.+?)\.webp/;
|
const reg = /\/icon\/weapon\/(.+?)\.webp/;
|
||||||
const filterW = AppWeaponData.filter((item) => {
|
const filterW = AppWeaponData.filter((item) => {
|
||||||
if (!val.star.includes(item.star)) return false;
|
if (!val.star.includes(item.star)) return false;
|
||||||
return val.weapon.includes(item.weaponIcon.match(reg)![1]);
|
const match = item.weaponIcon.match(reg);
|
||||||
|
if (match === null) return false;
|
||||||
|
return val.weapon.includes(match[1]);
|
||||||
});
|
});
|
||||||
if (filterW.length === 0) {
|
if (filterW.length === 0) {
|
||||||
showSnackbar({
|
showSnackbar({
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ import ToLoading from "../../components/overlay/to-loading.vue";
|
|||||||
import { useAppStore } from "../../store/modules/app";
|
import { useAppStore } from "../../store/modules/app";
|
||||||
import TGLogger from "../../utils/TGLogger";
|
import TGLogger from "../../utils/TGLogger";
|
||||||
import { createTGWindow } from "../../utils/TGWindow";
|
import { createTGWindow } from "../../utils/TGWindow";
|
||||||
import { SERVER } from "../../web/request/getAnno";
|
import { AnnoLang, AnnoServer } from "../../web/request/getAnno";
|
||||||
import TGRequest from "../../web/request/TGRequest";
|
import TGRequest from "../../web/request/TGRequest";
|
||||||
import TGUtils from "../../web/utils/TGUtils";
|
import TGUtils from "../../web/utils/TGUtils";
|
||||||
|
|
||||||
// 服务器名称-服务器对应
|
// 服务器名称-服务器对应
|
||||||
type AnnoServerMap = {
|
type AnnoServerMap = {
|
||||||
[key: string]: SERVER;
|
[key: string]: AnnoServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
const annoServerList: string[] = [
|
const annoServerList: string[] = [
|
||||||
@@ -79,15 +79,15 @@ const annoServerList: string[] = [
|
|||||||
"国际服-港澳台服",
|
"国际服-港澳台服",
|
||||||
];
|
];
|
||||||
const langList: string[] = ["简体中文", "繁体中文", "English", "日本語"];
|
const langList: string[] = ["简体中文", "繁体中文", "English", "日本語"];
|
||||||
export type AnnoLang = "zh-cn" | "zh-tw" | "en" | "ja";
|
|
||||||
// 服务器列表
|
// 服务器列表
|
||||||
const annoServerMap: AnnoServerMap = {
|
const annoServerMap: AnnoServerMap = {
|
||||||
"国服-官方服": SERVER.CN_ISLAND,
|
"国服-官方服": AnnoServer.CN_ISLAND,
|
||||||
"国服-渠道服": SERVER.CN_TREE,
|
"国服-渠道服": AnnoServer.CN_TREE,
|
||||||
"国际服-亚服": SERVER.OS_ASIA,
|
"国际服-亚服": AnnoServer.OS_ASIA,
|
||||||
"国际服-欧服": SERVER.OS_EURO,
|
"国际服-欧服": AnnoServer.OS_EURO,
|
||||||
"国际服-美服": SERVER.OS_USA,
|
"国际服-美服": AnnoServer.OS_USA,
|
||||||
"国际服-港澳台服": SERVER.OS_CHT,
|
"国际服-港澳台服": AnnoServer.OS_CHT,
|
||||||
};
|
};
|
||||||
const langMap: Record<string, AnnoLang> = {
|
const langMap: Record<string, AnnoLang> = {
|
||||||
简体中文: "zh-cn",
|
简体中文: "zh-cn",
|
||||||
@@ -115,7 +115,7 @@ const appStore = useAppStore();
|
|||||||
|
|
||||||
// 路由
|
// 路由
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const curRegion = ref<SERVER>(appStore.server);
|
const curRegion = ref<AnnoServer>(appStore.server);
|
||||||
const curRegionName = ref<string>(annoServerList[0]);
|
const curRegionName = ref<string>(annoServerList[0]);
|
||||||
const curLang = ref<AnnoLang>(appStore.lang);
|
const curLang = ref<AnnoLang>(appStore.lang);
|
||||||
const curLangName = ref<string>(langList[0]);
|
const curLangName = ref<string>(langList[0]);
|
||||||
@@ -127,11 +127,10 @@ const annoCards = ref<AnnoCard>({
|
|||||||
activity: [],
|
activity: [],
|
||||||
game: [],
|
game: [],
|
||||||
});
|
});
|
||||||
const annoData = ref<TGApp.BBS.Announcement.ListData>(<TGApp.BBS.Announcement.ListData>{});
|
|
||||||
|
|
||||||
watch(curRegionName, async (value) => {
|
watch(curRegionName, async (value) => {
|
||||||
appStore.server = annoServerMap[value] || SERVER.CN_ISLAND;
|
appStore.server = annoServerMap[value] || AnnoServer.CN_ISLAND;
|
||||||
curRegion.value = annoServerMap[value] || SERVER.CN_ISLAND;
|
curRegion.value = annoServerMap[value] || AnnoServer.CN_ISLAND;
|
||||||
await TGLogger.Info(`[Announcements][watch][curRegionName] 切换服务器:${value}`);
|
await TGLogger.Info(`[Announcements][watch][curRegionName] 切换服务器:${value}`);
|
||||||
await loadData();
|
await loadData();
|
||||||
});
|
});
|
||||||
@@ -163,13 +162,14 @@ onMounted(async () => {
|
|||||||
async function loadData(): Promise<void> {
|
async function loadData(): Promise<void> {
|
||||||
loadingTitle.value = "正在获取公告数据";
|
loadingTitle.value = "正在获取公告数据";
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
annoData.value = await TGRequest.Anno.getList(curRegion.value, curLang.value);
|
const annoData = await TGRequest.Anno.getList(curRegion.value, curLang.value);
|
||||||
const listCards = TGUtils.Anno.getCard(annoData.value);
|
const listCards = TGUtils.Anno.getCard(annoData);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
listCards.map(async (item) => {
|
listCards.map(async (item) => {
|
||||||
// if (item.typeLabel === AnnoType.game) return;
|
if (item.typeLabel === AnnoType.game) return;
|
||||||
const detail = await TGRequest.Anno.getContent(item.id, curRegion.value, "zh-cn");
|
const detail = await TGRequest.Anno.getContent(item.id, curRegion.value, "zh-cn");
|
||||||
item.timeStr = getAnnoTime(detail.content);
|
const timeStr = getAnnoTime(detail.content);
|
||||||
|
if (timeStr !== false) item.timeStr = timeStr;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
annoCards.value = {
|
annoCards.value = {
|
||||||
@@ -182,42 +182,46 @@ async function loadData(): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AnnoTimeRegex {
|
function getAnnoTime(content: string): string | false {
|
||||||
actPermanent: RegExp;
|
const regexes = [
|
||||||
actPersistent: RegExp;
|
/〓活动时间〓.*?\d\.\d版本期间持续开放/,
|
||||||
actTransient: RegExp;
|
/(?:〓活动时间〓|〓任务开放时间〓).*?\d\.\d版本更新(?:完成|)后永久开放/,
|
||||||
verUpdateTime: RegExp;
|
/(?:〓(?:活动|折扣)时间〓|祈愿时间|【上架时间】).*?(\d\.\d版本更新后).*?~.*?<t class="t_(?:gl|lc)".*?>(.*?)<\/t>/,
|
||||||
}
|
/(?:〓(?:活动|折扣)时间〓|祈愿时间|【上架时间】).*?<t class="t_(?:gl|lc)".*?>(.*?)<\/t>.*?~.*?<t class="t_(?:gl|lc)".*?>(.*?)<\/t>/,
|
||||||
|
/〓活动时间〓.*?(\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}).*?(\d\.\d版本结束)/,
|
||||||
const regexMap: AnnoTimeRegex = {
|
/〓更新时间〓.+?<t class=\"t_(?:gl|lc)\".*?>(.*?)&;lt;\/t>/,
|
||||||
actPermanent: /(?:〓活动时间〓|〓任务开放时间〓).*?\d\.\d版本更新(?:完成|)后永久开放/,
|
];
|
||||||
actPersistent: /〓活动时间〓.*?\d\.\d版本期间持续开放/,
|
if (content.match(regexes[0])) {
|
||||||
// (?:〓活动时间〓|祈愿时间|【上架时间】).*?(\d\.\d版本更新后).*?~.*?&lt;t class="t_(?:gl|lc)".*?&gt;(.*?)&lt;/t&gt;
|
const res = content.match(regexes[0]);
|
||||||
actTransient:
|
return res?.[0].replace(/.*?(\d\.\d版本期间持续开放)/, "$1") ?? false;
|
||||||
/(?:〓活动时间〓|祈愿时间|【上架时间】).*?(\d\.\d版本更新后).*?~.*?<t class="t_(?:gl|lc)".*?>(.*?)<\/t>/,
|
|
||||||
// 〓更新时间〓.+?&lt;t class=\"t_(?:gl|lc)\".*?&gt;(.*?)&lt;/t&gt;
|
|
||||||
verUpdateTime: /〓更新时间〓.+?<t class="t_(?:gl|lc)".*?>(.*?)<\/t>gt;/,
|
|
||||||
};
|
|
||||||
|
|
||||||
function getAnnoTime(content: string): string {
|
|
||||||
if (content.match(regexMap.actPermanent)) {
|
|
||||||
console.log("actPermanent");
|
|
||||||
return "永久开放";
|
|
||||||
}
|
}
|
||||||
if (content.match(regexMap.actPersistent)) {
|
if (content.match(regexes[1])) {
|
||||||
const res = content.match(regexMap.actPersistent);
|
console.log("actPermanently");
|
||||||
console.log("actPersistent", res?.[0]);
|
// todo 待处理
|
||||||
return res?.[0].replace(/.*?(\d\.\d版本期间持续开放)/, "$1") ?? "持续开放";
|
return false;
|
||||||
}
|
}
|
||||||
if (content.match(regexMap.actTransient)) {
|
if (content.match(regexes[2])) {
|
||||||
console.log("actTransient");
|
const res = content.match(regexes[2]);
|
||||||
return "临时开放";
|
return `${res?.[1]} ~ ${res?.[2]}`;
|
||||||
}
|
}
|
||||||
if (content.match(regexMap.verUpdateTime)) {
|
if (content.match(regexes[3])) {
|
||||||
|
const res = content.match(regexes[3]);
|
||||||
|
return `${res?.[1].split(" ")[0]} ~ ${res?.[2].split(" ")[0]}`;
|
||||||
|
}
|
||||||
|
if (content.match(regexes[4])) {
|
||||||
|
const res = content.match(regexes[4]);
|
||||||
|
if (res != null) {
|
||||||
|
const cnt = res[0].match(/〓/g);
|
||||||
|
if (cnt && cnt.length > 2) return false;
|
||||||
|
}
|
||||||
|
return `${res?.[1]} ~ ${res?.[2]}`;
|
||||||
|
}
|
||||||
|
if (content.match(regexes[5])) {
|
||||||
console.log("verUpdateTime");
|
console.log("verUpdateTime");
|
||||||
return "版本更新";
|
// todo 待处理
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return "未知时间";
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseTitle(title: string): string {
|
function parseTitle(title: string): string {
|
||||||
|
|||||||
@@ -8,9 +8,8 @@ import { path } from "@tauri-apps/api";
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { reactive, ref } from "vue";
|
import { reactive, ref } from "vue";
|
||||||
|
|
||||||
import type { AnnoLang } from "../../pages/common/Announcements.vue";
|
|
||||||
import { getInitDeviceInfo } from "../../utils/toolFunc";
|
import { getInitDeviceInfo } from "../../utils/toolFunc";
|
||||||
import { SERVER } from "../../web/request/getAnno";
|
import { type AnnoLang, AnnoServer } from "../../web/request/getAnno";
|
||||||
|
|
||||||
// 用于存储用户数据的路径
|
// 用于存储用户数据的路径
|
||||||
const userDataDir = `${await path.appLocalDataDir()}userData`;
|
const userDataDir = `${await path.appLocalDataDir()}userData`;
|
||||||
@@ -46,7 +45,7 @@ export const useAppStore = defineStore(
|
|||||||
// 设备信息
|
// 设备信息
|
||||||
const deviceInfo = ref<TGApp.App.Device.DeviceInfo>(getInitDeviceInfo());
|
const deviceInfo = ref<TGApp.App.Device.DeviceInfo>(getInitDeviceInfo());
|
||||||
// 服务器
|
// 服务器
|
||||||
const server = ref<SERVER>(SERVER.CN_ISLAND);
|
const server = ref<AnnoServer>(AnnoServer.CN_ISLAND);
|
||||||
// 语言
|
// 语言
|
||||||
const lang = ref<AnnoLang>("zh-cn");
|
const lang = ref<AnnoLang>("zh-cn");
|
||||||
// 最近的咨讯类型
|
// 最近的咨讯类型
|
||||||
@@ -59,7 +58,7 @@ export const useAppStore = defineStore(
|
|||||||
theme.value = "default";
|
theme.value = "default";
|
||||||
isLogin.value = false;
|
isLogin.value = false;
|
||||||
sidebar.collapse = true;
|
sidebar.collapse = true;
|
||||||
server.value = SERVER.CN_ISLAND;
|
server.value = AnnoServer.CN_ISLAND;
|
||||||
lang.value = "zh-cn";
|
lang.value = "zh-cn";
|
||||||
recentNewsType.value = "notice";
|
recentNewsType.value = "notice";
|
||||||
initDevice();
|
initDevice();
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ import { useRoute } from "vue-router";
|
|||||||
|
|
||||||
import TSwitchTheme from "../components/app/t-switchTheme.vue";
|
import TSwitchTheme from "../components/app/t-switchTheme.vue";
|
||||||
import ToLoading from "../components/overlay/to-loading.vue";
|
import ToLoading from "../components/overlay/to-loading.vue";
|
||||||
import { AnnoLang } from "../pages/common/Announcements.vue";
|
import { AnnoLang, AnnoServer } from "../web/request/getAnno";
|
||||||
import { SERVER } from "../web/request/getAnno";
|
|
||||||
import TGRequest from "../web/request/TGRequest";
|
import TGRequest from "../web/request/TGRequest";
|
||||||
|
|
||||||
// loading
|
// loading
|
||||||
@@ -28,7 +27,7 @@ const loadingEmpty = ref<boolean>(false);
|
|||||||
// 数据
|
// 数据
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const annoId = Number(route.params.anno_id);
|
const annoId = Number(route.params.anno_id);
|
||||||
const region = <SERVER>route.params.region;
|
const region = <AnnoServer>route.params.region;
|
||||||
const lang = <AnnoLang>route.params.lang;
|
const lang = <AnnoLang>route.params.lang;
|
||||||
let jsonList = reactive({});
|
let jsonList = reactive({});
|
||||||
let jsonContent = reactive({});
|
let jsonContent = reactive({});
|
||||||
|
|||||||
@@ -28,12 +28,11 @@ import { useRoute } from "vue-router";
|
|||||||
import TSwitchTheme from "../components/app/t-switchTheme.vue";
|
import TSwitchTheme from "../components/app/t-switchTheme.vue";
|
||||||
import TShareBtn from "../components/main/t-shareBtn.vue";
|
import TShareBtn from "../components/main/t-shareBtn.vue";
|
||||||
import ToLoading from "../components/overlay/to-loading.vue";
|
import ToLoading from "../components/overlay/to-loading.vue";
|
||||||
import { AnnoLang } from "../pages/common/Announcements.vue";
|
|
||||||
import { useAppStore } from "../store/modules/app";
|
import { useAppStore } from "../store/modules/app";
|
||||||
import TGLogger from "../utils/TGLogger";
|
import TGLogger from "../utils/TGLogger";
|
||||||
import { saveImgLocal } from "../utils/TGShare";
|
import { saveImgLocal } from "../utils/TGShare";
|
||||||
import { createTGWindow } from "../utils/TGWindow";
|
import { createTGWindow } from "../utils/TGWindow";
|
||||||
import { SERVER } from "../web/request/getAnno";
|
import { AnnoLang, AnnoServer } from "../web/request/getAnno";
|
||||||
import TGRequest from "../web/request/TGRequest";
|
import TGRequest from "../web/request/TGRequest";
|
||||||
import TGUtils from "../web/utils/TGUtils";
|
import TGUtils from "../web/utils/TGUtils";
|
||||||
|
|
||||||
@@ -51,7 +50,7 @@ const annoTitle = ref<string>("");
|
|||||||
// 数据
|
// 数据
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const annoId = Number(route.params.anno_id);
|
const annoId = Number(route.params.anno_id);
|
||||||
const region = <SERVER>route.params.region;
|
const region = <AnnoServer>route.params.region;
|
||||||
const lang = <AnnoLang>route.params.lang;
|
const lang = <AnnoLang>route.params.lang;
|
||||||
const annoData = ref<TGApp.BBS.Announcement.ContentItem>(<TGApp.BBS.Announcement.ContentItem>{});
|
const annoData = ref<TGApp.BBS.Announcement.ContentItem>(<TGApp.BBS.Announcement.ContentItem>{});
|
||||||
const annoHtml = ref<string>();
|
const annoHtml = ref<string>();
|
||||||
@@ -104,7 +103,7 @@ watch(loadShare, (value) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function createAnnoJson(annoId: number, region: SERVER, lang: AnnoLang) {
|
function createAnnoJson(annoId: number, region: AnnoServer, lang: AnnoLang) {
|
||||||
const jsonPath = `/anno_detail_json/${region}/${annoId}/${lang}`;
|
const jsonPath = `/anno_detail_json/${region}/${annoId}/${lang}`;
|
||||||
const jsonTitle = `Anno_${region}_${annoId}_${lang}_JSON`;
|
const jsonTitle = `Anno_${region}_${annoId}_${lang}_JSON`;
|
||||||
createTGWindow(jsonPath, "Dev_JSON", jsonTitle, 960, 720, false, false);
|
createTGWindow(jsonPath, "Dev_JSON", jsonTitle, 960, 720, false, false);
|
||||||
|
|||||||
@@ -5,9 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
import { http } from "@tauri-apps/api";
|
import { http } from "@tauri-apps/api";
|
||||||
|
|
||||||
import type { AnnoLang } from "../../pages/common/Announcements.vue";
|
export enum AnnoServer {
|
||||||
|
|
||||||
export enum SERVER {
|
|
||||||
CN_ISLAND = "cn_gf01",
|
CN_ISLAND = "cn_gf01",
|
||||||
CN_TREE = "cn_qd01",
|
CN_TREE = "cn_qd01",
|
||||||
OS_USA = "os_usa",
|
OS_USA = "os_usa",
|
||||||
@@ -16,14 +14,19 @@ export enum SERVER {
|
|||||||
OS_CHT = "os_cht",
|
OS_CHT = "os_cht",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type AnnoLang = "zh-cn" | "zh-tw" | "en" | "ja";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 获取游戏内公告参数
|
* @description 获取游戏内公告参数
|
||||||
* @since Beta v0.4.4
|
* @since Beta v0.4.4
|
||||||
* @param {SERVER} region 服务器
|
* @param {AnnoServer} region 服务器
|
||||||
* @param {string} lang 语言
|
* @param {string} lang 语言
|
||||||
* @returns {TGApp.BBS.Announcement.Params}
|
* @returns {TGApp.BBS.Announcement.Params}
|
||||||
*/
|
*/
|
||||||
function getAnnoParams(region: SERVER, lang: AnnoLang = "zh-cn"): TGApp.BBS.Announcement.Params {
|
function getAnnoParams(
|
||||||
|
region: AnnoServer = AnnoServer.CN_ISLAND,
|
||||||
|
lang: AnnoLang = "zh-cn",
|
||||||
|
): TGApp.BBS.Announcement.Params {
|
||||||
const params: TGApp.BBS.Announcement.Params = {
|
const params: TGApp.BBS.Announcement.Params = {
|
||||||
game: "hk4e",
|
game: "hk4e",
|
||||||
game_biz: "hk4e_cn",
|
game_biz: "hk4e_cn",
|
||||||
@@ -34,7 +37,7 @@ function getAnnoParams(region: SERVER, lang: AnnoLang = "zh-cn"): TGApp.BBS.Anno
|
|||||||
level: "55",
|
level: "55",
|
||||||
uid: "100000000",
|
uid: "100000000",
|
||||||
};
|
};
|
||||||
if (region === SERVER.CN_ISLAND || region === SERVER.CN_TREE) {
|
if (region === AnnoServer.CN_ISLAND || region === AnnoServer.CN_TREE) {
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
params.game_biz = "hk4e_global";
|
params.game_biz = "hk4e_global";
|
||||||
@@ -50,12 +53,12 @@ function getAnnoParams(region: SERVER, lang: AnnoLang = "zh-cn"): TGApp.BBS.Anno
|
|||||||
* @returns {Promise<TGApp.BBS.Announcement.ListData>}
|
* @returns {Promise<TGApp.BBS.Announcement.ListData>}
|
||||||
*/
|
*/
|
||||||
export async function getAnnoList(
|
export async function getAnnoList(
|
||||||
region: SERVER = SERVER.CN_ISLAND,
|
region: AnnoServer = AnnoServer.CN_ISLAND,
|
||||||
lang: AnnoLang = "zh-cn",
|
lang: AnnoLang = "zh-cn",
|
||||||
): Promise<TGApp.BBS.Announcement.ListData> {
|
): Promise<TGApp.BBS.Announcement.ListData> {
|
||||||
const params: TGApp.BBS.Announcement.Params = getAnnoParams(region, lang);
|
const params: TGApp.BBS.Announcement.Params = getAnnoParams(region, lang);
|
||||||
let url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnList";
|
let url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnList";
|
||||||
if (region !== SERVER.CN_ISLAND && region !== SERVER.CN_TREE) {
|
if (region !== AnnoServer.CN_ISLAND && region !== AnnoServer.CN_TREE) {
|
||||||
url = "https://hk4e-api-os.hoyoverse.com/common/hk4e_global/announcement/api/getAnnList";
|
url = "https://hk4e-api-os.hoyoverse.com/common/hk4e_global/announcement/api/getAnnList";
|
||||||
}
|
}
|
||||||
return await http
|
return await http
|
||||||
@@ -70,18 +73,18 @@ export async function getAnnoList(
|
|||||||
* @description 获取游戏内公告内容
|
* @description 获取游戏内公告内容
|
||||||
* @since Beta v0.4.3
|
* @since Beta v0.4.3
|
||||||
* @param {number} annId 公告 ID
|
* @param {number} annId 公告 ID
|
||||||
* @param {SERVER} region 服务器
|
* @param {AnnoServer} region 服务器
|
||||||
* @param {AnnoLang} lang 语言
|
* @param {AnnoLang} lang 语言
|
||||||
* @returns {Promise<TGApp.BBS.Announcement.ContentItem>}
|
* @returns {Promise<TGApp.BBS.Announcement.ContentItem>}
|
||||||
*/
|
*/
|
||||||
export async function getAnnoContent(
|
export async function getAnnoContent(
|
||||||
annId: number,
|
annId: number,
|
||||||
region: SERVER,
|
region: AnnoServer = AnnoServer.CN_ISLAND,
|
||||||
lang: AnnoLang = "zh-cn",
|
lang: AnnoLang = "zh-cn",
|
||||||
): Promise<TGApp.BBS.Announcement.ContentItem> {
|
): Promise<TGApp.BBS.Announcement.ContentItem> {
|
||||||
const params: TGApp.BBS.Announcement.Params = getAnnoParams(region, lang);
|
const params: TGApp.BBS.Announcement.Params = getAnnoParams(region, lang);
|
||||||
let url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnContent";
|
let url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnContent";
|
||||||
if (region !== SERVER.CN_ISLAND && region !== SERVER.CN_TREE) {
|
if (region !== AnnoServer.CN_ISLAND && region !== AnnoServer.CN_TREE) {
|
||||||
url = "https://hk4e-api-os.hoyoverse.com/common/hk4e_global/announcement/api/getAnnContent";
|
url = "https://hk4e-api-os.hoyoverse.com/common/hk4e_global/announcement/api/getAnnContent";
|
||||||
}
|
}
|
||||||
const annoContents: TGApp.BBS.Announcement.ContentItem[] = await http
|
const annoContents: TGApp.BBS.Announcement.ContentItem[] = await http
|
||||||
|
|||||||
@@ -1,12 +1,34 @@
|
|||||||
/**
|
/**
|
||||||
* @file web utils transAnno.ts
|
* @file web utils transAnno.ts
|
||||||
* @description 公告数据转换工具
|
* @description 公告数据转换工具
|
||||||
* @since Beta v0.3.3
|
* @since Beta v0.4.4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 默认封面图
|
// 默认封面图
|
||||||
const defaultCover = "/source/UI/defaultCover.webp";
|
const defaultCover = "/source/UI/defaultCover.webp";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取公告标签
|
||||||
|
* @since Beta v0.4.4
|
||||||
|
* @param {string} tag 标签
|
||||||
|
* @returns {string} 标签
|
||||||
|
*/
|
||||||
|
function getAnnoTag(tag: string): string {
|
||||||
|
switch (tag) {
|
||||||
|
case "1":
|
||||||
|
case "11":
|
||||||
|
case "重要":
|
||||||
|
return "公告";
|
||||||
|
case "2":
|
||||||
|
case "扭蛋":
|
||||||
|
return "祈愿";
|
||||||
|
case "3":
|
||||||
|
return "活动";
|
||||||
|
default:
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 将获取到的数据转为渲染用的卡片
|
* @description 将获取到的数据转为渲染用的卡片
|
||||||
* @since Beta v0.4.3
|
* @since Beta v0.4.3
|
||||||
@@ -25,11 +47,11 @@ export function getAnnoCard(
|
|||||||
return cards.push({
|
return cards.push({
|
||||||
id: anno.ann_id,
|
id: anno.ann_id,
|
||||||
title: anno.title,
|
title: anno.title,
|
||||||
subtitle: anno.subtitle,
|
subtitle: anno.subtitle.replace(/<br \/>/g, " "),
|
||||||
banner: anno.banner || defaultCover,
|
banner: anno.banner || defaultCover,
|
||||||
typeLabel: anno.type === 2 ? "游戏公告" : "活动公告",
|
typeLabel: anno.type === 2 ? "游戏公告" : "活动公告",
|
||||||
tagIcon: anno.tag_icon,
|
tagIcon: anno.tag_icon,
|
||||||
tagLabel: anno.tag_label,
|
tagLabel: getAnnoTag(anno.tag_label),
|
||||||
timeStr: time,
|
timeStr: time,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user