👽️ 更新依赖,调整公告Api

https://github.com/Scighost/Starward/issues/1089
This commit is contained in:
目棃
2024-09-13 16:03:19 +08:00
parent 611ae19c5e
commit 3740cea15b
7 changed files with 548 additions and 549 deletions

View File

@@ -31,7 +31,7 @@
</template>
<script lang="ts" setup>
import { nextTick, onMounted, reactive, ref, watch } from "vue";
import { nextTick, onMounted, reactive, ref, watch, useTemplateRef } from "vue";
interface ConfirmProps {
title: string;
@@ -56,7 +56,7 @@ const showOuter = ref<boolean>(false);
const showInner = ref<boolean>(false);
const confirmVal = ref<boolean | string | undefined>();
const inputVal = ref<string>("");
const inputRef = ref<HTMLInputElement>();
const inputEl = useTemplateRef<HTMLInputElement>("inputRef");
watch(show, () => {
if (show.value) {
@@ -95,7 +95,7 @@ async function displayBox(
if (data.mode === "input") {
// 等待确认框打开,聚焦输入框
setTimeout(() => {
inputRef.value?.focus();
inputEl.value?.focus();
}, 100);
}
});

View File

@@ -15,13 +15,13 @@
</transition>
</template>
<script setup lang="ts">
import { ref, watch } from "vue";
import { ref, watch, useTemplateRef } from "vue";
const show = ref<boolean>(false);
const showOuter = ref<boolean>(false);
const showInner = ref<boolean>(false);
const geetestRef = ref<HTMLElement>(<HTMLElement>document.getElementById("geetest"));
const geetestEl = useTemplateRef<HTMLDivElement>("geetestRef");
watch(show, () => {
if (show.value) {
@@ -55,7 +55,8 @@ async function displayBox(
width: "250px",
},
(captchaObj: TGApp.Plugins.Mys.Geetest.GeetestCaptcha) => {
geetestRef.value.innerHTML = "";
if (geetestEl.value === null) return;
geetestEl.value.innerHTML = "";
captchaObj.appendTo("#geetest");
captchaObj.onReady(() => {
show.value = true;

View File

@@ -1,7 +1,7 @@
/**
* @file web/request/getAnnouncement.ts
* @description 获取游戏内公告
* @since Beta v0.5.0
* @since Beta v0.5.5
*/
import TGHttp from "../../utils/TGHttp.js";
@@ -17,6 +17,9 @@ export enum AnnoServer {
export type AnnoLang = "zh-cn" | "zh-tw" | "en" | "ja";
const AnnoApi = "https://hk4e-ann-api.mihoyo.com/common/hk4e_cn/announcement/api";
const AnnoApiGlobal = "https://hk4e-api-os.hoyoverse.com/common/hk4e_global/announcement/api";
/**
* @description 获取游戏内公告参数
* @since Beta v0.4.4
@@ -48,7 +51,7 @@ function getAnnoParams(
/**
* @description 获取游戏内公告列表
* @since Beta v0.5.0
* @since Beta v0.5.5
* @param {string} region 服务器
* @param {AnnoLang} lang 语言
* @returns {Promise<TGApp.BBS.Announcement.ListData>}
@@ -58,9 +61,9 @@ export async function getAnnoList(
lang: AnnoLang = "zh-cn",
): Promise<TGApp.BBS.Announcement.ListData> {
const params: TGApp.BBS.Announcement.Params = getAnnoParams(region, lang);
let url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnList";
let url = `${AnnoApi}/getAnnList`;
if (region !== AnnoServer.CN_ISLAND && region !== AnnoServer.CN_TREE) {
url = "https://hk4e-api-os.hoyoverse.com/common/hk4e_global/announcement/api/getAnnList";
url = `${AnnoApiGlobal}/getAnnList`;
}
const resp = await TGHttp<TGApp.BBS.Announcement.ListResponse>(url, {
method: "GET",
@@ -71,7 +74,7 @@ export async function getAnnoList(
/**
* @description 获取游戏内公告内容
* @since Beta v0.5.0
* @since Beta v0.5.5
* @param {number} annId 公告 ID
* @param {AnnoServer} region 服务器
* @param {AnnoLang} lang 语言
@@ -83,9 +86,9 @@ export async function getAnnoContent(
lang: AnnoLang = "zh-cn",
): Promise<TGApp.BBS.Announcement.ContentItem> {
const params: TGApp.BBS.Announcement.Params = getAnnoParams(region, lang);
let url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnnContent";
let url = `${AnnoApi}/getAnnContent`;
if (region !== AnnoServer.CN_ISLAND && region !== AnnoServer.CN_TREE) {
url = "https://hk4e-api-os.hoyoverse.com/common/hk4e_global/announcement/api/getAnnContent";
url = `${AnnoApiGlobal}/getAnnContent`;
}
const annoResp = await TGHttp<TGApp.BBS.Announcement.ContentResponse>(url, {
method: "GET",