mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-06 08:32:51 +08:00
🎨 一些优化
* 优化公告解析逻辑 * 咨讯页loading显示版块名称 * 移除无用文件
This commit is contained in:
@@ -10,10 +10,7 @@ const tsConfigRules = {
|
||||
"@typescript-eslint/no-import-type-side-effects": "error",
|
||||
"@typescript-eslint/strict-boolean-expressions": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-unused-expressions": [
|
||||
"error",
|
||||
{ allowShortCircuit: false },
|
||||
],
|
||||
"@typescript-eslint/no-unused-expressions": ["error", { allowShortCircuit: false }],
|
||||
"import/order": [
|
||||
"error",
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ import { useAppStore } from "../../store/modules/app.js";
|
||||
import TGLogger from "../../utils/TGLogger.js";
|
||||
import { AnnoLang, AnnoServer } from "../../web/request/getAnno.js";
|
||||
import TGRequest from "../../web/request/TGRequest.js";
|
||||
import TGUtils from "../../web/utils/TGUtils.js";
|
||||
import { getAnnoCard } from "../../web/utils/getAnnoCard.js";
|
||||
import { decodeRegExp } from "../../web/utils/tools.js";
|
||||
|
||||
type AnnoSelect = { text: string; value: string };
|
||||
@@ -145,7 +145,7 @@ async function loadData(): Promise<void> {
|
||||
`服务器:${getRegionName(curRegion.value)},语言:${getLangName(curLang.value)}`,
|
||||
);
|
||||
const annoData = await TGRequest.Anno.getList(curRegion.value, curLang.value);
|
||||
const listCards = TGUtils.Anno.getCard(annoData);
|
||||
const listCards = getAnnoCard(annoData);
|
||||
await Promise.all(
|
||||
listCards.map(async (item) => {
|
||||
if (item.typeLabel === AnnoType.game) return;
|
||||
|
||||
@@ -69,6 +69,7 @@ import Mys from "../../plugins/Mys/index.js";
|
||||
import { useAppStore } from "../../store/modules/app.js";
|
||||
import TGLogger from "../../utils/TGLogger.js";
|
||||
import { createPost } from "../../utils/TGWindow.js";
|
||||
import { getGameName } from "../../web/utils/tools.js";
|
||||
|
||||
// 类型定义
|
||||
enum NewsType {
|
||||
@@ -92,6 +93,7 @@ type RawData = {
|
||||
// 路由
|
||||
const router = useRouter();
|
||||
const gid = <string>useRoute().params.gid;
|
||||
const gameName = getGameName(Number(gid));
|
||||
// loading
|
||||
const loading = ref<boolean>(false);
|
||||
|
||||
@@ -146,12 +148,12 @@ async function firstLoad(key: NewsKey, refresh: boolean = false): Promise<void>
|
||||
postData.value[key] = [];
|
||||
rawData.value[key].lastId = 0;
|
||||
}
|
||||
showLoading.start(`正在获取${rawData.value[key].name}数据...`);
|
||||
showLoading.start(`正在获取${gameName}${rawData.value[key].name}数据...`);
|
||||
const getData = await Mys.Painter.getNewsList(gid, NewsType[key]);
|
||||
rawData.value[key].isLast = getData.is_last;
|
||||
rawData.value[key].lastId = getData.list.length;
|
||||
postData.value[key] = getData.list;
|
||||
showLoading.update(`正在渲染${rawData.value[key].name}数据...`);
|
||||
showLoading.update(`正在渲染${gameName}${rawData.value[key].name}数据...`);
|
||||
await nextTick(() => showLoading.end());
|
||||
await TGLogger.Info(`[News][${gid}][firstLoad] 获取${rawData.value[key].name}数据成功`);
|
||||
}
|
||||
@@ -169,7 +171,7 @@ async function loadMore(key: NewsKey): Promise<void> {
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
showLoading.start(`正在获取${rawData.value[key].name}数据...`);
|
||||
showLoading.start(`正在获取${gameName}${rawData.value[key].name}数据...`);
|
||||
const getData = await Mys.Painter.getNewsList(gid, NewsType[key], 20, rawData.value[key].lastId);
|
||||
rawData.value[key].lastId = rawData.value[key].lastId + getData.list.length;
|
||||
rawData.value[key].isLast = getData.is_last;
|
||||
|
||||
@@ -73,6 +73,7 @@ import ToPostSearch from "../../components/post/to-postSearch.vue";
|
||||
import Mys from "../../plugins/Mys/index.js";
|
||||
import TGLogger from "../../utils/TGLogger.js";
|
||||
import { createPost } from "../../utils/TGWindow.js";
|
||||
import { getGameName } from "../../web/utils/tools.js";
|
||||
|
||||
type SortSelect = {
|
||||
text: string;
|
||||
@@ -184,9 +185,9 @@ const search = ref<string>("");
|
||||
const showSearch = ref<boolean>(false);
|
||||
|
||||
onMounted(async () => {
|
||||
showLoading.start("正在获取帖子数据...");
|
||||
if (gid && typeof gid === "string") curGid.value = Number(gid);
|
||||
if (forum && typeof forum === "string") curForum.value = Number(forum);
|
||||
showLoading.start(`正在获取${getGameName(curGid.value)}帖子数据...`);
|
||||
const gameLabel = getGameLabel(curGid.value);
|
||||
const forumLabel = getForumLabel(curGid.value, curForum.value);
|
||||
await TGLogger.Info(`[Posts][${gameLabel}][onMounted][${forumLabel}] 打开帖子列表`);
|
||||
|
||||
@@ -63,7 +63,7 @@ export async function getCaptcha(
|
||||
"user-agent": TGConstant.BBS.UA_MOBILE,
|
||||
"content-type": "application/json",
|
||||
referer: "https://user.miyoushe.com/",
|
||||
"x-rpc-game_biz": TGConstant.Utils.GAME_BIZ,
|
||||
"x-rpc-game_biz": TGConstant.GAME_BIZ,
|
||||
};
|
||||
const resp = await TGHttp<
|
||||
TGApp.Plugins.Mys.CaptchaLogin.CaptchaResponse | TGApp.BBS.Response.Base
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
import JsonViewer from "vue-json-viewer";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
@@ -22,8 +22,8 @@ const route = useRoute();
|
||||
const annoId = Number(route.params.anno_id);
|
||||
const region = <AnnoServer>route.params.region;
|
||||
const lang = <AnnoLang>route.params.lang;
|
||||
let jsonList = reactive({});
|
||||
let jsonContent = reactive({});
|
||||
const jsonList = ref<TGApp.BBS.Announcement.AnnoSingle>();
|
||||
const jsonContent = ref<TGApp.BBS.Announcement.ContentItem>();
|
||||
|
||||
onMounted(async () => {
|
||||
showLoading.start("正在获取公告数据...");
|
||||
@@ -35,10 +35,10 @@ onMounted(async () => {
|
||||
const listData = await TGRequest.Anno.getList();
|
||||
listData.list.map((item: TGApp.BBS.Announcement.ListItem) => {
|
||||
return item.list.map((single: TGApp.BBS.Announcement.AnnoSingle) => {
|
||||
return single.ann_id === annoId ? (jsonList = single) : null;
|
||||
return single.ann_id === annoId ? (jsonList.value = single) : null;
|
||||
});
|
||||
});
|
||||
jsonContent = await TGRequest.Anno.getContent(annoId, region, lang);
|
||||
jsonContent.value = await TGRequest.Anno.getContent(annoId, region, lang);
|
||||
showLoading.end();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file web/constant/TGConstant.ts
|
||||
* @description 常量
|
||||
* @since Beta v0.5.1
|
||||
* @since Beta v0.6.3
|
||||
*/
|
||||
|
||||
import {
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
BBS_VERSION,
|
||||
CHANNEL_LIST,
|
||||
} from "./bbs.js";
|
||||
import SERVER from "./server.js";
|
||||
import { GAME_BIZ } from "./utils.js";
|
||||
|
||||
const TGConstant = {
|
||||
@@ -24,10 +23,7 @@ const TGConstant = {
|
||||
CHANNELS: CHANNEL_LIST,
|
||||
},
|
||||
Salt: BBS_SALT,
|
||||
Server: SERVER,
|
||||
Utils: {
|
||||
GAME_BIZ,
|
||||
},
|
||||
GAME_BIZ,
|
||||
};
|
||||
|
||||
export default TGConstant;
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* @file web constant server.ts
|
||||
* @description 服务器地址常量文件
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description 服务器地址
|
||||
* @since Alpha v0.2.0
|
||||
* @enum {string}
|
||||
* @readonly
|
||||
* @property {string} CN_ISLAND 国服-天空岛
|
||||
* @property {string} CN_TREE 国服-世界树
|
||||
* @property {string} OS_USA 美服
|
||||
* @property {string} OS_EURO 欧服
|
||||
* @property {string} OS_ASIA 亚服
|
||||
* @property {string} OS_CHT 台服
|
||||
* @property {string} UNKNOWN 未知
|
||||
* @returns {string} 服务器地址
|
||||
*/
|
||||
enum SERVER {
|
||||
CN_ISLAND = "cn_gf01",
|
||||
CN_TREE = "cn_qd01",
|
||||
OS_USA = "os_usa",
|
||||
OS_EURO = "os_euro",
|
||||
OS_ASIA = "os_asia",
|
||||
OS_CHT = "os_cht",
|
||||
UNKNOWN = "unknown",
|
||||
}
|
||||
|
||||
export default SERVER;
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGConstant from "../constant/TGConstant.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 生成 authkey
|
||||
@@ -23,11 +23,11 @@ export async function genAuthkey(
|
||||
const ck = { stoken: cookie.stoken, mid: cookie.mid };
|
||||
const data = {
|
||||
auth_appid: "webview_gacha",
|
||||
game_biz: TGConstant.Utils.GAME_BIZ,
|
||||
game_biz: TGConstant.GAME_BIZ,
|
||||
game_uid: account.gameUid,
|
||||
region: account.region,
|
||||
};
|
||||
const header = TGUtils.User.getHeader(ck, "POST", JSON.stringify(data), "lk2", true);
|
||||
const header = getRequestHeader(ck, "POST", JSON.stringify(data), "lk2", true);
|
||||
const resp = await TGHttp<TGApp.Game.Gacha.AuthkeyResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
headers: header,
|
||||
@@ -49,7 +49,7 @@ export async function genAuthkey2(
|
||||
payload: Record<string, string>,
|
||||
): Promise<TGApp.BBS.Response.Base> {
|
||||
const url = "https://api-takumi.mihoyo.com/binding/api/genAuthKey";
|
||||
const header = TGUtils.User.getHeader(cookie, "POST", JSON.stringify(payload), "lk2", true);
|
||||
const header = getRequestHeader(cookie, "POST", JSON.stringify(payload), "lk2", true);
|
||||
return await TGHttp<TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
headers: header,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 获取深渊信息
|
||||
@@ -29,7 +29,7 @@ export async function getAbyss(
|
||||
ltoken: cookie.ltoken,
|
||||
ltuid: cookie.ltuid,
|
||||
};
|
||||
const header = TGUtils.User.getHeader(ck, "GET", params, "common");
|
||||
const header = getRequestHeader(ck, "GET", params, "common");
|
||||
const resp = await TGHttp<TGApp.Game.Abyss.Response | TGApp.BBS.Response.Base>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 通过 stoken 获取 ActionTicket
|
||||
@@ -25,7 +25,7 @@ export async function getActionTicketBySToken(
|
||||
const url = "https://api-takumi.mihoyo.com/auth/api/getActionTicketBySToken";
|
||||
const params = { action_type: ActionType, stoken: SToken, uid: UID };
|
||||
const cookie = { mid: MID, stoken: SToken };
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "k2");
|
||||
const header = getRequestHeader(cookie, "GET", params, "k2");
|
||||
return await TGHttp<TGApp.BBS.Response.getActionTicketBySToken>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 手动刷新角色数据
|
||||
@@ -22,7 +22,7 @@ export async function getAvatarIndex(
|
||||
const url = TGApi.GameData.getUserBase;
|
||||
const params = { avatar_list_type: 1, role_id: user.gameUid, server: user.region };
|
||||
const ck = { cookie_token: cookie.cookie_token, account_id: cookie.account_id };
|
||||
const header = TGUtils.User.getHeader(ck, "GET", params, "common");
|
||||
const header = getRequestHeader(ck, "GET", params, "common");
|
||||
return await TGHttp<TGApp.BBS.Response.Base>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
@@ -44,7 +44,7 @@ export async function getAvatarList(
|
||||
const url = TGApi.GameData.byCookie.getAvatarList;
|
||||
const data = { role_id: user.gameUid, server: user.region };
|
||||
const ck = { cookie_token: cookie.cookie_token, account_id: cookie.account_id };
|
||||
const header = TGUtils.User.getHeader(ck, "POST", data, "common");
|
||||
const header = getRequestHeader(ck, "POST", data, "common");
|
||||
const resp = await TGHttp<TGApp.Game.Avatar.ListResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
@@ -70,7 +70,7 @@ export async function getAvatarDetail(
|
||||
const url = TGApi.GameData.byCookie.getAvatarDetail;
|
||||
const data = { role_id: user.gameUid, server: user.region, character_ids: avatarIds };
|
||||
const ck = { cookie_token: cookie.cookie_token, account_id: cookie.account_id };
|
||||
const header = TGUtils.User.getHeader(ck, "POST", data, "common");
|
||||
const header = getRequestHeader(ck, "POST", data, "common");
|
||||
const resp = await TGHttp<TGApp.Game.Avatar.DetailResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 根据 stoken 获取 cookie_token
|
||||
@@ -22,7 +22,7 @@ export async function getCookieTokenBySToken(
|
||||
const url = TGApi.GameTokens.getCookieToken;
|
||||
const cookie = { mid: Mid, stoken: Stoken };
|
||||
const params = { stoken: Stoken };
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
|
||||
const header = getRequestHeader(cookie, "GET", params, "common");
|
||||
const resp = await TGHttp<TGApp.BBS.Response.getCookieTokenBySToken | TGApp.BBS.Response.Base>(
|
||||
url,
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGConstant from "../constant/TGConstant.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 通过 stoken 获取游戏账号
|
||||
@@ -22,7 +22,7 @@ export async function getGameAccountsBySToken(
|
||||
): Promise<TGApp.BBS.Account.GameAccount[] | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.bySToken.getAccounts;
|
||||
const cookie = { stuid, stoken };
|
||||
const params = { stoken, stuid, game_biz: TGConstant.Utils.GAME_BIZ };
|
||||
const params = { stoken, stuid, game_biz: TGConstant.GAME_BIZ };
|
||||
return await getGameAccounts(url, cookie, params);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export async function getGameAccountsByCookie(
|
||||
): Promise<TGApp.BBS.Account.GameAccount[] | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.byCookie.getAccounts;
|
||||
const cookie = { account_id, cookie_token };
|
||||
const params = { game_biz: TGConstant.Utils.GAME_BIZ };
|
||||
const params = { game_biz: TGConstant.GAME_BIZ };
|
||||
return await getGameAccounts(url, cookie, params);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ async function getGameAccounts(
|
||||
cookie: Record<string, string>,
|
||||
params: Record<string, string>,
|
||||
): Promise<TGApp.BBS.Response.Base | TGApp.BBS.Account.GameAccount[]> {
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
|
||||
const header = getRequestHeader(cookie, "GET", params, "common");
|
||||
const resp = await TGHttp<TGApp.BBS.Response.getGameAccounts | TGApp.BBS.Response.Base>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 获取用户游戏数据
|
||||
@@ -23,7 +23,7 @@ export async function getGameRecord(
|
||||
): Promise<TGApp.Game.Record.FullData | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.getUserBase;
|
||||
const params = { role_id: user.gameUid, server: user.region };
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
|
||||
const header = getRequestHeader(cookie, "GET", params, "common");
|
||||
const resp = await TGHttp<TGApp.Game.Record.Response | TGApp.BBS.Response.Base>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 根据 stoken_v2 获取 ltoken
|
||||
@@ -22,7 +22,7 @@ export async function getLTokenBySToken(
|
||||
const url = TGApi.GameTokens.getLToken;
|
||||
const cookie = { mid: Mid, stoken: Stoken };
|
||||
const params = { stoken: Stoken };
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
|
||||
const header = getRequestHeader(cookie, "GET", params, "common");
|
||||
const resp = await TGHttp<TGApp.BBS.Response.getLTokenBySToken | TGApp.BBS.Response.Base>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 获取剧诗信息
|
||||
@@ -27,7 +27,7 @@ export async function getRoleCombat(
|
||||
ltoken: cookie.ltoken,
|
||||
ltuid: cookie.ltuid,
|
||||
};
|
||||
const header = TGUtils.User.getHeader(ck, "GET", params, "common");
|
||||
const header = getRequestHeader(ck, "GET", params, "common");
|
||||
const resp = await TGHttp<TGApp.Game.Combat.Response | TGApp.BBS.Response.Base>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 获取用户收藏帖子
|
||||
@@ -22,7 +22,7 @@ export async function getUserCollect(
|
||||
): Promise<TGApp.BBS.Collection.PostRespData | TGApp.BBS.Response.Base> {
|
||||
const url = "https://bbs-api.miyoushe.com/post/wapi/userFavouritePost";
|
||||
const params = { size: "20", uid, offset };
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
|
||||
const header = getRequestHeader(cookie, "GET", params, "common");
|
||||
const resp = await TGHttp<TGApp.BBS.Collection.PostResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 根据 cookie 获取用户信息
|
||||
@@ -25,7 +25,7 @@ export async function getUserInfoByCookie(
|
||||
};
|
||||
const url = TGApi.GameData.byCookie.getUserInfo;
|
||||
const params = { gids: "2" };
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common", true);
|
||||
const header = getRequestHeader(cookie, "GET", params, "common", true);
|
||||
const resp = await TGHttp<TGApp.Plugins.Mys.User.HomeResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader.js";
|
||||
|
||||
/**
|
||||
* @description 验证 ltoken 有效性,返回 mid
|
||||
@@ -22,7 +22,7 @@ export async function verifyLToken(
|
||||
const url = TGApi.GameTokens.verifyLToken;
|
||||
const cookie = { ltoken, ltuid };
|
||||
const data = { ltoken };
|
||||
const header = TGUtils.User.getHeader(cookie, "POST", data, "common");
|
||||
const header = getRequestHeader(cookie, "POST", data, "common");
|
||||
const resp = await TGHttp<TGApp.BBS.Response.verifyUserInfoBySToken | TGApp.BBS.Response.Base>(
|
||||
url,
|
||||
{
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/**
|
||||
* @file web utils TGUtils.ts
|
||||
* @description 应用用到的工具函数
|
||||
* @since Beta v0.3.4
|
||||
*/
|
||||
|
||||
import { getAnnoCard } from "./getAnnoCard.js";
|
||||
import { getRequestHeader } from "./getRequestHeader.js";
|
||||
import { getServerByUid, transCookie } from "./tools.js";
|
||||
|
||||
const TGUtils = {
|
||||
Anno: {
|
||||
getCard: getAnnoCard,
|
||||
},
|
||||
User: {
|
||||
getHeader: getRequestHeader,
|
||||
},
|
||||
Tools: {
|
||||
getServerByUid,
|
||||
transCookie,
|
||||
},
|
||||
};
|
||||
|
||||
export default TGUtils;
|
||||
@@ -207,7 +207,7 @@ function parseAnnoNode(
|
||||
|
||||
/**
|
||||
* @description 解析公告段落
|
||||
* @since Beta v0.5.5
|
||||
* @since Beta v0.6.3
|
||||
* @param {HTMLElement} p - 段落元素
|
||||
* @param {Record<string, string>} attr - 属性
|
||||
* @returns {TGApp.Plugins.Mys.SctPost.Base} 结构化数据
|
||||
@@ -267,7 +267,7 @@ function parseAnnoParagraph(
|
||||
const res = parseAnnoNode(child, { bold: "true" });
|
||||
return {
|
||||
insert: "",
|
||||
children: res,
|
||||
children: [...res, { insert: "\n" }],
|
||||
};
|
||||
}
|
||||
if (child.tagName === "T") {
|
||||
@@ -295,10 +295,12 @@ function parseAnnoParagraph(
|
||||
} else if (element.tagName === "A") {
|
||||
childRes = parseAnnoAnchor(element);
|
||||
} else if (element.tagName === "STRONG") {
|
||||
childRes = {
|
||||
insert: element.innerHTML,
|
||||
attributes: { bold: true },
|
||||
};
|
||||
const resS = parseAnnoNode(element, { bold: "true" });
|
||||
if (resS.length > 1) {
|
||||
childRes = { insert: element.outerHTML };
|
||||
} else {
|
||||
childRes = resS[0];
|
||||
}
|
||||
} else if (element.tagName === "T") {
|
||||
element.innerHTML = element.outerHTML;
|
||||
const resE = parseAnnoNode(element);
|
||||
|
||||
@@ -56,30 +56,11 @@ export function transParams(obj: Record<string, string | number | string[] | boo
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据 uid 获取 server
|
||||
* @since Beta v0.4.3
|
||||
* @todo instead of account.region
|
||||
* @deprecated
|
||||
* @param {string} uid uid
|
||||
* @returns {string} server
|
||||
* @description 根据 gid 获取游戏名称
|
||||
* @param {number} gid
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getServerByUid(uid: string): string {
|
||||
// 若长度为 10,则为国际服亚服
|
||||
if (uid.length === 10) return TGConstant.Server.OS_ASIA;
|
||||
// 获取第一个字符
|
||||
const first = uid[0];
|
||||
// 1-4 为国服-天空岛
|
||||
if (first >= "1" && first <= "4") return TGConstant.Server.CN_ISLAND;
|
||||
// 5 为国服-世界树
|
||||
if (first === "5") return TGConstant.Server.CN_TREE;
|
||||
// 6 为美服
|
||||
if (first === "6") return TGConstant.Server.OS_USA;
|
||||
// 7 为欧服
|
||||
if (first === "7") return TGConstant.Server.OS_EURO;
|
||||
// 8 为亚服
|
||||
if (first === "8") return TGConstant.Server.OS_ASIA;
|
||||
// 9 为台服
|
||||
if (first === "9") return TGConstant.Server.OS_CHT;
|
||||
// 其他情况返回未知
|
||||
return TGConstant.Server.UNKNOWN;
|
||||
export function getGameName(gid: number): string {
|
||||
const game = TGConstant.BBS.CHANNELS.find((item) => item.gid === gid.toString());
|
||||
return game ? game.title : "未知游戏";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user