🚸 活动icon点击事件,调整类型声明

This commit is contained in:
目棃
2024-12-20 21:11:01 +08:00
parent 2c2d9d319c
commit 6494a85397
10 changed files with 75 additions and 326 deletions

View File

@@ -9,6 +9,7 @@
"build": "tauri build",
"debug": "tauri build --debug",
"dev": "tauri dev --exit-on-panic",
"eslint:pre": "pnpx @eslint/config-inspector@latest",
"lint": "concurrently \"pnpm:lint:*(!fix)\"",
"lint:fix": "concurrently \"pnpm:lint:*:fix\"",
"lint:code": "eslint .",

View File

@@ -8,7 +8,7 @@ mod utils;
use tauri::{AppHandle, Manager, WebviewWindowBuilder};
use tauri_utils::config::WebviewUrl;
static BBS_VERSION: &'static str = "2.78.1";
static BBS_VERSION: &'static str = "2.79.1";
#[tauri::command]
pub async fn create_mhy_client(handle: AppHandle, func: String, url: String) {

View File

@@ -2,7 +2,9 @@
<div class="ph-pool-card">
<div class="top">
<div class="main">
<div class="left"><img :src="props.position.icon" alt="icon" /></div>
<div class="left" @click="openPosition(props.position)">
<img :src="props.position.icon" alt="icon" />
</div>
<div class="right">
<div class="title">{{ props.position.title }}</div>
<div class="sub">{{ props.position.abstract }}</div>
@@ -48,11 +50,15 @@ const props = defineProps<PhPositionCardProps>();
async function openPosition(card: TGApp.Plugins.Mys.Position.RenderCard): Promise<void> {
const res = await parseLink(card.link);
if (res === "post") await createPost(card.postId, card.title);
if (res === "post") {
await createPost(card.postId, card.title);
return;
}
if (res === false) {
showSnackbar.warn(`未知链接:${card.link}`, 3000);
return;
}
window.open(card.link);
}
</script>
<style lang="css" scoped>

View File

@@ -1,151 +1,10 @@
/**
* @file types/BBS/Account.d.ts
* @description BBS 账户相关类型定义文件
* @since Beta v0.6.0
* @since Beta v0.6.7
*/
/**
* @description 米游社账户信息
* @since Beta v0.6.0
* @namespace TGApp.BBS.Account
* @memberof TGApp.BBS
*/
declare namespace TGApp.BBS.Account {
/**
* @description stoken 验证获取的用户信息
* @interface VerifySTokenInfo
* @since Alpha v0.1.5
* @property {string} aid 账号 id
* @property {string} mid mid
* @property {string} account_name 账号名称
* @property {string} email 邮箱
* @property {number} is_email_verify 是否验证邮箱 // 0 未验证 1 已验证
* @property {string} area_code 手机区号 // '+86'
* @property {string} safe_mobile 手机号 // 部分明文,中间隐藏
* @property {string} realname 真实姓名 // 最后一位明文,其他隐藏
* @property {string} identity_code 身份证号 // 头尾三位明文,其他隐藏
* @property {string} rebind_area_code 重新绑定手机区号
* @property {string} rebind_mobile 重新绑定手机号
* @property {string} rebind_mobile_time 重新绑定手机时间
* @property {unknown[]} links 账号绑定信息
* @return VerifySTokenInfo
*/
interface VerifySTokenInfo {
aid: string;
mid: string;
account_name: string;
email: string;
is_email_verify: number;
area_code: string;
safe_mobile: string;
realname: string;
identity_code: string;
rebind_area_code: string;
rebind_mobile: string;
rebind_mobile_time: string;
links: unknown[];
}
/**
* @description 通过 gameToken 获取 stoken 返回的用户信息
* @interface getStokenByGameTokenInfo
* @since Beta v0.3.0
* @property {string} aid 账号 id
* @property {string} mid mid
* @property {string} account_name 账号名称
* @property {string} email 邮箱
* @property {number} is_email_verify 是否验证邮箱 // 0 未验证 1 已验证
* @property {string} area_code 手机区号 // '+86'
* @property {string} mobile 手机号 // 部分明文,中间隐藏
* @property {string} safe_area_code 安全手机区号
* @property {string} safe_mobile 安全手机号
* @property {string} realname 真实姓名 // 最后一位明文,其他隐藏
* @property {string} identity_code 身份证号 // 头尾三位明文,其他隐藏
* @property {string} rebind_area_code 重新绑定手机区号
* @property {string} rebind_mobile 重新绑定手机号
* @property {string} rebind_mobile_time 重新绑定手机时间
* @property {unknown[]} links 账号绑定信息
* @property {string} country 国家
* @return getStokenByGameTokenInfo
*/
interface getStokenByGameTokenInfo {
aid: string;
mid: string;
account_name: string;
email: string;
is_email_verify: number;
area_code: string;
mobile: string;
safe_area_code: string;
safe_mobile: string;
realname: string;
identity_code: string;
rebind_area_code: string;
rebind_mobile: string;
rebind_mobile_time: string;
links: unknown[];
country: string;
}
/**
* @description 通过 sToken 获取 actionTicket 返回数据里的用户信息
* @interface getActionTicketBySTokenInfo
* @since Beta v0.3.4
* @property {boolean} is_realname 是否实名认证
* @property {string} mobile 手机号
* @property {string} safe_mobile 安全手机号
* @property {string} account_id 账号 id
* @property {string} account_name 账号名称
* @property {string} email 邮箱
* @property {boolean} is_email_verify 是否验证邮箱
* @property {string} area_code 手机区号
* @property {string} safe_area_code 安全手机区号
* @property {string} real_name 真实姓名
* @property {string} identity_code 身份证号
* @property {string} create_time 创建时间
* @property {string} create_ip 创建 ip
* @property {string} change_pwd_time 修改密码时间
* @property {string} nickname 昵称
* @property {number} user_icon_id 用户头像 id
* @property {number} safe_level 安全等级
* @property {string} black_endtime 黑名单结束时间
* @property {string} black_note 黑名单备注
* @property {number} gender 性别
* @property {number} real_stat 实名状态
* @property {string} apple_name 苹果账号名称
* @property {string} sony_name 索尼账号名称
* @property {string} tap_name tap 账号名称
* @property {string} reactivate_ticket 重新激活 ticket
* @return getActionTicketBySTokenInfo
*/
interface getActionTicketBySTokenInfo {
is_realname: boolean;
mobile: string;
safe_mobile: string;
account_id: string;
account_name: string;
email: string;
is_email_verify: boolean;
area_code: string;
safe_area_code: string;
real_name: string;
identity_code: string;
create_time: string;
create_ip: string;
change_pwd_time: string;
nickname: string;
user_icon_id: number;
safe_level: number;
black_endtime: string;
black_note: string;
gender: number;
real_stat: number;
apple_name: string;
sony_name: string;
tap_name: string;
reactivate_ticket: string;
}
/**
* @description 游戏账号类型
* @interface GameAccount

View File

@@ -4,12 +4,6 @@
* @since Beta v0.3.7
*/
/**
* @description 导航相关类型定义
* @since Beta v0.3.7
* @namespace TGApp.BBS.Navigator
* @memberof TGApp.BBS
*/
declare namespace TGApp.BBS.Navigator {
/**
* @description 导航列表返回响应类型
@@ -160,19 +154,16 @@ declare namespace TGApp.BBS.Navigator {
* @property {number} data[].count.discuss - 热门话题讨论数
* @return HotTopic
*/
interface HotTopic {
type HotTopic = {
position: number;
data: Array<{
topic_id: number;
image: string;
topic_name: string;
post_name: string;
count: {
view: number;
discuss: number;
};
count: { view: number; discuss: number };
}>;
}
};
/**
* @description 游戏接待
@@ -214,7 +205,7 @@ declare namespace TGApp.BBS.Navigator {
* @property {unknown} data.user_status - 游戏接待用户状态
* @return GameReception
*/
interface GameReception {
type GameReception = {
position: number;
data: {
config: {
@@ -224,10 +215,7 @@ declare namespace TGApp.BBS.Navigator {
description: string;
icon: string;
status: string;
rules: {
game_level: number;
community_level: number;
};
rules: { game_level: number; community_level: number };
questionnaire: {
questionnaire_type: number;
questionnaire_url: string;
@@ -246,15 +234,8 @@ declare namespace TGApp.BBS.Navigator {
filename: string;
pkg_version_name: string;
};
detail_servlet: {
type: number;
normal_servlet: unknown;
customize_detail: unknown;
};
pre_register_count: {
show_count: boolean;
count: string;
};
detail_servlet: { type: number; normal_servlet: unknown; customize_detail: unknown };
pre_register_count: { show_count: boolean; count: string };
is_top: boolean;
last_update_time: string;
app_store_switch: number;
@@ -263,7 +244,7 @@ declare namespace TGApp.BBS.Navigator {
};
user_status: unknown;
};
}
};
/**
* @description 兑换码接口返回数据
@@ -273,11 +254,7 @@ declare namespace TGApp.BBS.Navigator {
* @property {CodeData[]} data.code_list - 兑换码数据
* @return CodeResponse
*/
interface CodeResponse extends TGApp.BBS.Response.BaseWithData {
data: {
code_list: CodeData[];
};
}
type CodeResponse = TGApp.BBS.Response.BaseWithData & { data: { code_list: Array<CodeData> } };
/**
* @description 兑换码数据
@@ -289,10 +266,5 @@ declare namespace TGApp.BBS.Navigator {
* @property {string} to_get_time - 过期时间,时间戳(单位:秒)
* @return CodeData
*/
interface CodeData {
title: string;
code: string;
img: string;
to_get_time: string;
}
type CodeData = { title: string; code: string; img: string; to_get_time: string };
}

View File

@@ -4,12 +4,6 @@
* @since Beta v0.6.0
*/
/**
* @description BBS 返回数据类型定义
* @since Beta v0.6.0
* @namespace TGApp.BBS.Response
* @memberof TGApp.BBS
*/
declare namespace TGApp.BBS.Response {
/**
* @description 基础返回类型,设计米游社接口请求都是这个类型
@@ -20,11 +14,7 @@ declare namespace TGApp.BBS.Response {
* @property {never} data - 响应数据
* @return Base
*/
interface Base {
retcode: number;
message: string;
data: never;
}
type Base = { retcode: number; message: string; data: never };
/**
* @description 基础返回类型-带有 data 的
@@ -35,121 +25,5 @@ declare namespace TGApp.BBS.Response {
* @property {any} data - 响应数据
* @return BaseWithData
*/
interface BaseWithData {
retcode: 0;
message: string;
data: any;
}
/**
* @description 根据 stoken 获取 ltoken 的响应数据
* @interface getLTokenBySToken
* @since Alpha v0.1.5
* @extends BaseWithData
* @property {string} data.ltoken - ltoken 值
* @return getLTokenBySToken
*/
interface getLTokenBySToken extends BaseWithData {
data: {
ltoken: string;
};
}
/**
* @description 根据 stoken 获取 cookie_token 的响应数据
* @interface getCookieTokenBySToken
* @since Alpha v0.1.5
* @extends BaseWithData
* @property {string} data.uid - 用户 uid
* @property {string} data.cookie_token - cookie_token 值
* @return getCookieTokenBySToken
*/
interface getCookieTokenBySToken extends BaseWithData {
data: {
uid: string;
cookie_token: string;
};
}
/**
* @description 通过 stoken 验证用户信息的返回类型
* @interface verifyUserInfoBySToken
* @since Alpha v0.1.5
* @extends BaseWithData
* @property {TGApp.BBS.Account.VerifySTokenInfo} data.user_info - 用户信息
* @property {unknown} data.realname_info - 实名信息
* @property {boolean} data.need_realperson - 是否需要实名认证
* @return verifyUserInfoBySToken
*/
interface verifyUserInfoBySToken extends BaseWithData {
data: {
user_info: TGApp.BBS.Account.VerifySTokenInfo;
realname_info: unknown;
need_realperson: boolean;
};
}
/**
* @description 通过 sToken 获取 actionTicket 的返回类型
* @interface getActionTicketBySToken
* @since Beta v0.3.4
* @extends BaseWithData
* @property {string} data.ticket - actionTicket 值
* @property {boolean} data.is_verified - 是否验证
* @property {TGApp.BBS.Account.getActionTicketBySTokenInfo} data.account_info - 用户信息
* @return getActionTicketBySToken
*/
interface getActionTicketBySToken extends BaseWithData {
data: {
ticket: string;
is_verified: boolean;
account_info: TGApp.BBS.Account.getActionTicketBySTokenInfo;
};
}
/**
* @description 获取 deviceFp 的返回类型
* @interface getDeviceFp
* @since Beta v0.3.6
* @extends BaseWithData
* @property {string} data.device_fp - deviceFp 值
* @property {number} data.code - code 值
* @property {string} data.msg - msg 值
* @return getDeviceFp
*/
interface getDeviceFp extends BaseWithData {
data: {
device_fp: string;
code: number;
msg: string;
};
}
/**
* @description 获取游戏账户数据
* @interface getGameAccounts
* @since Beta v0.6.0
* @extends BaseWithData
* @property {TGApp.BBS.Account.GameAccount[]} data.list - 返回数据
* @returns getGameAccounts
*/
interface getGameAccounts extends BaseWithData {
data: {
list: TGApp.BBS.Account.GameAccount[];
};
}
/**
* @description 获取登录 ticket
* @interface getAuthTicketByGameBiz
* @since Beta v0.6.0
* @extends BaseWithData
* @property {string} data.ticket
* @returns getAuthTicketByGameBiz
*/
interface getAuthTicketByGameBiz extends BaseWithData {
data: {
ticket: string;
};
}
type BaseWithData = { retcode: 0; message: string; data: unknown };
}

View File

@@ -1,10 +1,10 @@
/**
* @file web/constant/bbs.ts
* @description 常量-应用数据
* @since Beta v0.6.5
* @since Beta v0.6.7
*/
export const BBS_VERSION: Readonly<string> = "2.78.1";
export const BBS_VERSION: Readonly<string> = "2.79.1";
export const BBS_UA_MOBILE: Readonly<string> = `Mozilla/5.0 (Linux; Android 12) Mobile miHoYoBBS/${BBS_VERSION}`;
/**

View File

@@ -92,7 +92,7 @@ async function getDeviceFp(
Referer: "https://webstatic.mihoyo.com/",
};
try {
const resp = await TGHttp<TGApp.BBS.Response.getDeviceFp>(
const resp = await TGHttp<DeviceFpResp>(
"https://public-data-api.mihoyo.com/device-fp/api/getFp",
{ method: "POST", body: JSON.stringify(data), headers: header },
);
@@ -125,3 +125,8 @@ async function refreshCode(
const OtherApi = { code: refreshCode, fp: getDeviceFp };
export default OtherApi;
/// 一些类型 ///
type DeviceFpResp = TGApp.BBS.Response.BaseWithData & {
data: { device_fp: string; code: number; msg: string };
};

View File

@@ -32,7 +32,7 @@ async function createAuthTicketByGameBiz(
"x-rpc-client_type": "3",
"x-rpc-app_id": "ddxf5dufpuyo",
};
const resp = await TGHttp<TGApp.BBS.Response.getAuthTicketByGameBiz>(
const resp = await TGHttp<AuthTicketByGameBizResp>(
`${pAbu}account/ma-cn-verifier/app/createAuthTicketByGameBiz`,
{ method: "POST", headers: headers, query: params },
);
@@ -51,7 +51,7 @@ async function getCookieAccountInfoBySToken(
): Promise<string | TGApp.BBS.Response.Base> {
const ck = { stoken: cookie.stoken, mid: cookie.mid };
const params = { stoken: cookie.stoken };
const resp = await TGHttp<TGApp.BBS.Response.getCookieTokenBySToken | TGApp.BBS.Response.Base>(
const resp = await TGHttp<GetCookieTokenBySTokenResp | TGApp.BBS.Response.Base>(
`${pAbu}account/auth/api/getCookieAccountInfoBySToken`,
{ method: "GET", headers: getRequestHeader(ck, "GET", params), query: params },
);
@@ -70,7 +70,7 @@ async function getLTokenBySToken(
): Promise<string | TGApp.BBS.Response.Base> {
const ck = { mid: cookie.mid, stoken: cookie.stoken };
const params = { stoken: cookie.stoken };
const resp = await TGHttp<TGApp.BBS.Response.getLTokenBySToken | TGApp.BBS.Response.Base>(
const resp = await TGHttp<GetLTokenBySTokenResp | TGApp.BBS.Response.Base>(
`${pAbu}account/auth/api/getLTokenBySToken`,
{ method: "GET", headers: getRequestHeader(ck, "GET", params), query: params },
);
@@ -89,10 +89,11 @@ async function verifyLToken(
): Promise<string | TGApp.BBS.Response.Base> {
const ck = { ltoken: cookie.ltoken, ltuid: cookie.ltuid };
const data = { ltoken: cookie.ltoken };
const resp = await TGHttp<TGApp.BBS.Response.verifyUserInfoBySToken | TGApp.BBS.Response.Base>(
`${p4Abu}account/ma-cn-session/web/verifyLtoken`,
{ method: "POST", headers: getRequestHeader(ck, "POST", data), body: JSON.stringify(data) },
);
const resp = await TGHttp<VerifyLtokenResp>(`${p4Abu}account/ma-cn-session/web/verifyLtoken`, {
method: "POST",
headers: getRequestHeader(ck, "POST", data),
body: JSON.stringify(data),
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data.user_info.mid;
}
@@ -104,3 +105,34 @@ const PassportApi = {
};
export default PassportApi;
/// 一些类型 ///
type AuthTicketByGameBizResp = TGApp.BBS.Response.BaseWithData & { data: { ticket: string } };
type GetCookieTokenBySTokenResp = TGApp.BBS.Response.BaseWithData & {
data: { uid: string; cookie_token: string };
};
type GetLTokenBySTokenResp = TGApp.BBS.Response.BaseWithData & { data: { ltoken: string } };
type VerifyLtokenResp = TGApp.BBS.Response.BaseWithData & {
data: {
realname_info: unknown;
need_realperson: boolean;
user_info: {
aid: string;
mid: string;
account_name: string;
email: string;
is_email_verify: number;
area_code: string;
safe_mobile: string;
realname: string;
identity_code: string;
rebind_area_code: string;
rebind_mobile: string;
rebind_mobile_time: string;
links: Array<unknown>;
};
};
};

View File

@@ -1,7 +1,7 @@
/**
* @file web/utils/getRequestHeader.ts
* @description 获取请求头
* @since Beta v0.5.3
* @since Beta v0.6.7
*/
import Md5 from "js-md5";
@@ -24,12 +24,12 @@ const enum SaltType {
/**
* @description salt 值
* @version 2.78.1
* @since Beta v0.6.5
* @version 2.79.1
* @since Beta v0.6.7
*/
const Salt: Readonly<Record<keyof typeof SaltType, string>> = {
K2: "GuODIETRPuJxpiUQoZairQxHtmzZKYFl",
LK2: "ACDpsiiEFSqqLiEpzXMuXNsLNqGkrIQc",
K2: "eOzxpHXVGBVdFBtkbkTvwyCgRpqRFeBr",
LK2: "AbuxbruiFDIgxLXksUNMAMvDyciznofM",
X4: "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
X6: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
PROD: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",