♻️ 类型迁移&重构

This commit is contained in:
目棃
2025-03-07 17:59:35 +08:00
parent ce5a88954a
commit d5aaecbf72
39 changed files with 514 additions and 567 deletions

View File

@@ -75,7 +75,7 @@ import { computed, onMounted, shallowRef, watch } from "vue";
import { generateShareImg } from "@/utils/TGShare.js";
import { createPost } from "@/utils/TGWindow.js";
type TPostCardProps = { modelValue: TGApp.Plugins.Mys.Post.FullData; selectMode?: boolean };
type TPostCardProps = { modelValue: TGApp.BBS.Post.FullData; selectMode?: boolean };
type TPostCardEmits = (e: "onSelected", v: string) => void;
type TPostStatus = RenderStatus & { stat: ActStat };
type RenderForum = { name: string; icon: string; id: number };
@@ -86,7 +86,7 @@ export type RenderCard = {
cover: string;
postId: number;
subtitle: string;
user: TGApp.Plugins.Mys.User.Post | null;
user: TGApp.BBS.Post.User | null;
forum: RenderForum | null;
data: RenderData | null;
status?: RenderStatus;
@@ -130,7 +130,7 @@ function getActivityStatus(status: number): RenderStatus {
return stats[ActStat.UNKNOWN];
}
function getPostCover(item: TGApp.Plugins.Mys.Post.FullData): string {
function getPostCover(item: TGApp.BBS.Post.FullData): string {
let cover;
if (item.cover) cover = item.cover.url;
else if (item.post.cover) cover = item.post.cover;
@@ -140,7 +140,7 @@ function getPostCover(item: TGApp.Plugins.Mys.Post.FullData): string {
return `${cover}?x-oss-process=image/resize,m_fill,w_360,h_130,limit_0/format,png`;
}
function getCommonCard(item: TGApp.Plugins.Mys.Post.FullData): RenderCard {
function getCommonCard(item: TGApp.BBS.Post.FullData): RenderCard {
let forumData: RenderForum | null = null;
let statData: RenderData | null = null;
if (item.forum !== null) {
@@ -167,7 +167,7 @@ function getCommonCard(item: TGApp.Plugins.Mys.Post.FullData): RenderCard {
};
}
function getPostCard(item: TGApp.Plugins.Mys.Post.FullData): RenderCard {
function getPostCard(item: TGApp.BBS.Post.FullData): RenderCard {
const commonCard = getCommonCard(item);
if (
item.news_meta !== undefined &&

View File

@@ -21,7 +21,7 @@ import parseAnnoContent from "@/web/utils/annoParser.js";
type TaParserProps = { data: TGApp.BBS.Announcement.ContentItem };
const props = defineProps<TaParserProps>();
function getTaName(ta: TGApp.Plugins.Mys.SctPost.Base): Component {
function getTaName(ta: TGApp.BBS.SctPost.Base): Component {
if (ta.children) return TpTexts;
if (typeof ta.insert === "string") return TpText;
if ("image" in ta.insert) return TpImage;

View File

@@ -30,7 +30,7 @@
import TMiImg from "@comp/app/t-mi-img.vue";
import { computed } from "vue";
type TpAvatarProps = { data: TGApp.Plugins.Mys.User.Post; position: "left" | "right" };
type TpAvatarProps = { data: TGApp.BBS.Post.User; position: "left" | "right" };
const props = defineProps<TpAvatarProps>();

View File

@@ -22,7 +22,7 @@
<TpParser :data="JSON.parse(props.data.insert.fold.content)" />
</div>
</details>
<TpUnknown v-else :data="<TGApp.Plugins.Mys.SctPost.Empty>props.data" />
<TpUnknown v-else :data="<TGApp.BBS.SctPost.Empty>props.data" />
</template>
<script lang="ts" setup>
import { ref, toRaw } from "vue";

View File

@@ -6,7 +6,7 @@
:title="props.data.insert.divider"
/>
</div>
<TpUnknown v-else :data="<TGApp.Plugins.Mys.SctPost.Empty>props.data" />
<TpUnknown v-else :data="<TGApp.BBS.SctPost.Empty>props.data" />
</template>
<script lang="ts" setup>
import { computed } from "vue";

View File

@@ -24,7 +24,7 @@ import TpVillaCard from "./tp-villaCard.vue";
import TpVod from "./tp-vod.vue";
import TpVote from "./tp-vote.vue";
type SctPostDataArr = Array<TGApp.Plugins.Mys.SctPost.Base>;
type SctPostDataArr = Array<TGApp.BBS.SctPost.Base>;
type TpParserProps = { data: SctPostDataArr };
const props = defineProps<TpParserProps>();
@@ -32,7 +32,7 @@ const props = defineProps<TpParserProps>();
function getParsedData(data: SctPostDataArr): SctPostDataArr {
const res: SctPostDataArr = [];
let child: SctPostDataArr = [];
let cur: TGApp.Plugins.Mys.SctPost.Base | undefined;
let cur: TGApp.BBS.SctPost.Base | undefined;
for (const tp of data) {
const tpName = getTpName(tp);
// 单独处理 TpMention
@@ -90,7 +90,7 @@ function getParsedText(data: TpTextType): Array<TpTextType> {
return [data];
}
function getTpName(tp: TGApp.Plugins.Mys.SctPost.Base): Component {
function getTpName(tp: TGApp.BBS.SctPost.Base): Component {
if (tp.children) return TpTexts;
if (typeof tp.insert === "string") return TpText;
if ("backup_text" in tp.insert) return TpBackupText;

View File

@@ -8,7 +8,7 @@ import { onMounted, toRaw } from "vue";
import TGLogger from "@/utils/TGLogger.js";
type TpUnknownProps = { data: TGApp.Plugins.Mys.SctPost.Empty };
type TpUnknownProps = { data: TGApp.BBS.SctPost.Empty };
const props = defineProps<TpUnknownProps>();

View File

@@ -22,7 +22,7 @@ import VpOverlayCollect from "./vp-overlay-collect.vue";
import TGLogger from "@/utils/TGLogger.js";
type TbCollectProps = { modelValue: number; data?: TGApp.Plugins.Mys.Post.FullData };
type TbCollectProps = { modelValue: number; data?: TGApp.BBS.Post.FullData };
const props = defineProps<TbCollectProps>();
const isCollected = ref<boolean>(false);

View File

@@ -39,7 +39,7 @@ import showSnackbar from "@comp/func/snackbar.js";
import TSUserCollection from "@Sqlite/modules/userCollect.js";
import { ref, shallowRef, watch } from "vue";
type ToPostCollectProps = { post?: TGApp.Plugins.Mys.Post.FullData };
type ToPostCollectProps = { post?: TGApp.BBS.Post.FullData };
type ToPostCollectEmits = (e: "submit") => void;
const props = defineProps<ToPostCollectProps>();

View File

@@ -54,7 +54,7 @@ import { useRouter } from "vue-router";
import { timestampToDate } from "@/utils/toolFunc.js";
import postReq from "@/web/request/postReq.js";
type TpoCollectionProps = { collection: TGApp.Plugins.Mys.Post.Collection };
type TpoCollectionProps = { collection: TGApp.BBS.Post.Collection };
type TpoCollectionItem = {
postId: string;
title: string;

View File

@@ -53,7 +53,7 @@ type RenderCard = {
id: string;
upWay: string;
status: string;
creator: TGApp.Plugins.Mys.User.Post;
creator: TGApp.BBS.Post.User;
drawTime: string;
rewards: Array<RenderReward>;
};
@@ -61,7 +61,7 @@ type RenderReward = {
name: string;
win: number;
goal: number;
users: TGApp.Plugins.Mys.User.Post[];
users: Array<TGApp.BBS.Post.User>;
};
const props = defineProps<TpoLotteryProps>();

View File

@@ -38,7 +38,7 @@ const lastId = ref<string>("");
const game = ref<string>("2");
const isLast = ref<boolean>(false);
const load = ref<boolean>(false);
const results = shallowRef<Array<TGApp.Plugins.Mys.Post.FullData>>([]);
const results = shallowRef<Array<TGApp.BBS.Post.FullData>>([]);
const gameName = computed<string>(
() => TGBbs.channels.find((v) => v.gid.toString() === game.value)?.title || "未知分区",
);

View File

@@ -122,7 +122,7 @@ const collections = shallowRef<Array<TGApp.Sqlite.UserCollection.UFCollection>>(
const selected = shallowRef<Array<TGApp.Sqlite.UserCollection.UFPost>>([]);
const length = computed<number>(() => Math.ceil(selected.value.length / 12));
const view = computed<number>(() => (length.value === 1 ? 1 : length.value > 5 ? 5 : length.value));
const curPosts = computed<Array<TGApp.Plugins.Mys.Post.FullData>>(() =>
const curPosts = computed<Array<TGApp.BBS.Post.FullData>>(() =>
selected.value.slice((page.value - 1) * 12, page.value * 12).map((i) => JSON.parse(i.content)),
);
@@ -372,10 +372,7 @@ async function freshUser(uid?: string): Promise<void> {
}
// 合并收藏帖子
async function mergePosts(
posts: Array<TGApp.Plugins.Mys.Post.FullData>,
collect: string,
): Promise<void> {
async function mergePosts(posts: Array<TGApp.BBS.Post.FullData>, collect: string): Promise<void> {
const title = `用户收藏-${collect}`;
for (const post of posts) {
await showLoading.update(`[POST]${post.post.subject} [collection]${title}`);

View File

@@ -159,7 +159,7 @@ const isReq = ref<boolean>(false);
const selectedForum = shallowRef<SortSelect>();
const sortGameList = shallowRef<Array<SortSelectGame>>([]);
const postRaw = shallowRef<PostRaw>({ isLast: false, lastId: "", total: 0 });
const posts = shallowRef<Array<TGApp.Plugins.Mys.Post.FullData>>([]);
const posts = shallowRef<Array<TGApp.BBS.Post.FullData>>([]);
onMounted(async () => {
await showLoading.start("正在加载帖子数据");

View File

@@ -72,7 +72,7 @@ import TGLogger from "@/utils/TGLogger.js";
import { createPost } from "@/utils/TGWindow.js";
import painterReq from "@/web/request/painterReq.js";
type PostData = { [key in NewsType]: Ref<Array<TGApp.Plugins.Mys.Post.FullData>> };
type PostData = { [key in NewsType]: Ref<Array<TGApp.BBS.Post.FullData>> };
type RawItem = { isLast: boolean; name: string; lastId: number };
type RawData = { [key in NewsType]: Ref<RawItem> };
@@ -88,9 +88,9 @@ const showList = ref<boolean>(false);
const showSearch = ref<boolean>(false);
const search = ref<string>("");
const postData = reactive<PostData>({
notice: shallowRef<Array<TGApp.Plugins.Mys.Post.FullData>>([]),
activity: shallowRef<Array<TGApp.Plugins.Mys.Post.FullData>>([]),
news: shallowRef<Array<TGApp.Plugins.Mys.Post.FullData>>([]),
notice: shallowRef<Array<TGApp.BBS.Post.FullData>>([]),
activity: shallowRef<Array<TGApp.BBS.Post.FullData>>([]),
news: shallowRef<Array<TGApp.BBS.Post.FullData>>([]),
});
const rawData = reactive<RawData>({
notice: shallowRef<RawItem>({ isLast: false, name: "公告", lastId: 0 }),

View File

@@ -115,7 +115,7 @@ const isReq = ref<boolean>(false);
const allGames = shallowRef<Array<TGApp.BBS.Game.Item>>([]);
const postRaw = shallowRef<PostMiniData>({ isLast: false, lastId: "", total: 0 });
const topicInfo = shallowRef<TGApp.BBS.Topic.InfoRes>();
const posts = shallowRef<Array<TGApp.Plugins.Mys.Post.FullData>>([]);
const posts = shallowRef<Array<TGApp.BBS.Post.FullData>>([]);
const curGame = shallowRef<GameList>();
const sortList = computed<Array<SortSelect>>(() => {
if (!topicInfo.value) return [];

View File

@@ -15,10 +15,10 @@ import { timestampToDate } from "@/utils/toolFunc.js";
* @description 获取插入游戏账号数据的sql
* @since Beta v0.6.0
* @param {string} uid - 米社UID
* @param {TGApp.BBS.Account.GameAccount} data - 游戏账号数据
* @param {TGApp.BBS.Game.Account} data - 游戏账号数据
* @return {string}
*/
function getInsertGameAccountSql(uid: string, data: TGApp.BBS.Account.GameAccount): string {
function getInsertGameAccountSql(uid: string, data: TGApp.BBS.Game.Account): string {
const isChosen = data.is_chosen ? 1 : 0;
const isOfficial = data.is_official ? 1 : 0;
const timeNow = timestampToDate(new Date().getTime());
@@ -265,12 +265,12 @@ async function getCurGameAccount(uid: string): Promise<TGApp.Sqlite.Account.Game
* @description 保存游戏账户数据
* @since Beta v0.6.0
* @param {string} uid - 米社UID
* @param {TGApp.BBS.Account.GameAccount[]} accounts - 账户数据
* @param {Array<TGApp.BBS.Game.Account>} accounts - 账户数据
* @return {Promise<void>}
*/
async function saveGameAccount(
uid: string,
accounts: TGApp.BBS.Account.GameAccount[],
accounts: Array<TGApp.BBS.Game.Account>,
): Promise<void> {
const db = await TGSqlite.getDB();
for (const account of accounts) {

View File

@@ -147,14 +147,14 @@ async function updateCollect(title: string, newTitle: string, newDesc: string):
* @description 添加收藏
* @since Beta v0.4.5
* @param {string} postId 文章 id
* @param {TGApp.Plugins.Mys.Post.FullData} post 文章信息
* @param {TGApp.BBS.Post.FullData} post 文章信息
* @param {string} collection 收藏合集标题,可能为 undefined
* @param {boolean} recursive 是否递归添加
* @return {Promise<boolean>} 返回是否添加成功
*/
async function addCollect(
postId: string,
post: TGApp.Plugins.Mys.Post.FullData,
post: TGApp.BBS.Post.FullData,
collection: string | undefined = undefined,
recursive: boolean = false,
): Promise<boolean> {
@@ -219,13 +219,10 @@ async function addCollect(
* @description 更新帖子信息
* @since Beta v0.4.5
* @param {string} postId 文章 id
* @param {TGApp.Plugins.Mys.Post.FullData} post 文章信息
* @param {TGApp.BBS.Post.FullData} post 文章信息
* @return {Promise<boolean>} 返回是否更新成功
*/
async function updatePostInfo(
postId: string,
post: TGApp.Plugins.Mys.Post.FullData,
): Promise<boolean> {
async function updatePostInfo(postId: string, post: TGApp.BBS.Post.FullData): Promise<boolean> {
const db = await TGSqlite.getDB();
const sql = "SELECT id FROM UFPost WHERE id = ?";
const res: Array<{ id: number }> = await db.select(sql, [postId]);

View File

@@ -1,32 +0,0 @@
/**
* @file types/BBS/Account.d.ts
* @description BBS 账户相关类型定义文件
* @since Beta v0.6.7
*/
declare namespace TGApp.BBS.Account {
/**
* @description 游戏账号类型
* @interface GameAccount
* @since Beta v0.6.0
* @property {string} game_biz 游戏 biz例如 hk4e_cn
* @property {string} game_uid 游戏 uid
* @property {boolean} is_chosen 是否为当前选中账号
* @property {boolean} is_official 是否为官服账号
* @property {string} level 游戏等级
* @property {string} nickname 游戏昵称
* @property {string} region 游戏区域
* @property {string} region_name 游戏区域名称
* @return Game
*/
interface GameAccount {
game_biz: string;
game_uid: string;
is_chosen: boolean;
is_official: boolean;
level: string;
nickname: string;
region: string;
region_name: string;
}
}

View File

@@ -23,9 +23,16 @@ declare namespace TGApp.BBS.Collection {
* @property {PostsRes} data - 返回数据
* @return PostsResp
*/
type PostsResp = TGApp.BBS.Response.BaseWithData & {
data: { posts: Array<TGApp.Plugins.Mys.Post.FullData> };
};
type PostsResp = TGApp.BBS.Response.BaseWithData<PostsRes>;
/**
* @description 帖子列表数据
* @since Beta v0.7.1
* @interface PostsRes
* @property {Array<TGApp.BBS.Post.FullData>} posts - 帖子列表
* @return PostsRes
*/
type PostsRes = { posts: Array<TGApp.BBS.Post.FullData> };
/**
* @description 用户收藏帖子响应数据
@@ -33,12 +40,12 @@ declare namespace TGApp.BBS.Collection {
* @interface UserPostRes
* @property {boolean} is_last - 是否最后一页
* @property {string} next_offset - 下一页偏移量
* @property {Array<TGApp.Plugins.Mys.Post.FullData>} list - 帖子列表
* @property {Array<TGApp.BBS.Post.FullData>} list - 帖子列表
* @return UserPostRes
*/
type UserPostRes = {
is_last: boolean;
next_offset: string;
list: Array<TGApp.Plugins.Mys.Post.FullData>;
list: Array<TGApp.BBS.Post.FullData>;
};
}

View File

@@ -64,8 +64,8 @@ declare namespace TGApp.BBS.Forum {
* @property {number} show_type 显示类型
* @property {number} default_tab 默认标签
* @property {string} read_me 说明
* @property {Array<ForumCat>} forum_cate_list 分类列表
* @property {Array<ForumCat>} video_cat_list 视频分类列表
* @property {Array<ForumCate>} forum_cate_list 分类列表
* @property {Array<ForumCate>} video_cat_list 视频分类列表
* @return GameForumItem
*/
type GameForumItem = {
@@ -94,33 +94,33 @@ declare namespace TGApp.BBS.Forum {
show_type: number;
default_tab: number;
read_me: string;
forum_cate_list: Array<ForumCat>;
video_cat_list: Array<ForumCat>;
forum_cate_list: Array<ForumCate>;
video_cat_list: Array<ForumCate>;
};
/**
* @description 视频分类
* @since Beta v0.6.8
* @interface ForumCat
* @interface ForumCate
* @property {number} id 分类 ID
* @property {string} name 分类名称
* @property {number} forum_id 版块 ID
* @property {string} desc 描述
* @property {string} remark 备注
* @return ForumCat
* @return ForumCate
*/
type ForumCat = { id: number; name: string; forum_id: number; desc: string; remark: string };
type ForumCate = { id: number; name: string; forum_id: number; desc: string; remark: string };
/**
* @description 版块帖子列表
* @since Beta v0.7.1
* @since Beta v0.7.2
* @interface PostForumRes
* @property {string} last_id 最后一条帖子 ID
* @property {boolean} is_last 是否最后一页
* @property {boolean} is_origin 是否原创
* @property {number} page 页码
* @property {unknown} databox 数据盒子
* @property {Array<TGApp.Plugins.Mys.Post.FullData>} list 帖子列表
* @property {Array<TGApp.BBS.Post.FullData>} list 帖子列表
* @return PostForumRes
*/
type PostForumRes = {
@@ -129,6 +129,6 @@ declare namespace TGApp.BBS.Forum {
is_origin: boolean;
page: number;
databox: unknown;
list: TGApp.Plugins.Mys.Post.FullData[];
list: Array<TGApp.BBS.Post.FullData>;
};
}

View File

@@ -1,7 +1,7 @@
/**
* @file types/BBS/Game.d.ts
* @description 游戏相关的类型定义
* @since Beta v0.6.8
* @since Beta v0.7.2
*/
declare namespace TGApp.BBS.Game {
@@ -49,4 +49,48 @@ declare namespace TGApp.BBS.Game {
has_wiki: boolean;
game_sort_config: Array<unknown>;
};
/**
* @description 游戏账号返回
* @since Beta v0.7.2
* @interface AccountResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {AccountRes} data 游戏账号数据
* @return AccountResp
*/
type AccountResp = TGApp.BBS.Response.BaseWithData<AccountRes>;
/**
* @description 游戏账号数据
* @since Beta v0.7.2
* @interface AccountRes
* @property {Array<Account>} list 游戏账号列表
* @return AccountRes
*/
type AccountRes = { list: Array<Account> };
/**
* @description 游戏账号类型
* @since Beta v0.7.2
* @interface Account
* @property {string} game_biz 游戏 biz例如 hk4e_cn
* @property {string} game_uid 游戏 uid
* @property {boolean} is_chosen 是否为当前选中账号
* @property {boolean} is_official 是否为官服账号
* @property {string} level 游戏等级
* @property {string} nickname 游戏昵称
* @property {string} region 游戏区域
* @property {string} region_name 游戏区域名称
* @return Account
*/
type Account = {
game_biz: string;
game_uid: string;
is_chosen: boolean;
is_official: boolean;
level: string;
nickname: string;
region: string;
region_name: string;
};
}

View File

@@ -1,7 +1,7 @@
/**
* @file types/BBS/Lottery.d.ts
* @description 米游社抽奖类型
* @since Beta v0.7.1
* @since Beta v0.7.2
*/
declare namespace TGApp.BBS.Lottery {
@@ -17,10 +17,10 @@ declare namespace TGApp.BBS.Lottery {
/**
* @description 抽奖数据
* @since Beta v0.7.1
* @since Beta v0.7.2
* @interface FullData
* @property {string} id 抽奖 ID
* @property {TGApp.Plugins.Mys.User.Post} creator 创建者
* @property {TGApp.BBS.Post.User} creator 创建者
* @property {string} draw_time 抽奖时间
* @property {string} participant_way 参与方式 // Forward: 转发
* @property {boolean} is_expect_unfocus_user 是否限制未关注用户
@@ -38,7 +38,7 @@ declare namespace TGApp.BBS.Lottery {
*/
type FullData = {
id: string;
creator: TGApp.Plugins.Mys.User.Post;
creator: TGApp.BBS.Post.User;
draw_time: string;
participant_way: string;
is_expect_unfocus_user: boolean;
@@ -56,13 +56,13 @@ declare namespace TGApp.BBS.Lottery {
/**
* @description 抽奖奖励
* @since Beta v0.7.1
* @since Beta v0.7.2
* @interface Reward
* @property {string} reward_name 奖励名称
* @property {number} winner_number 获奖人数
* @property {number} scheduled_winner_number 预计获奖人数
* @property {boolean} is_send_by_post 是否通过帖子发放
* @property {Array<>TGApp.Plugins.Mys.User.Post>} users 用户列表
* @property {Array<TGApp.BBS.Post.User>} users 用户列表
* @property {string} id 奖励 ID
* @return Reward
*/
@@ -71,7 +71,7 @@ declare namespace TGApp.BBS.Lottery {
winner_number: number;
scheduled_winner_number: number;
is_send_by_post: boolean;
users: Array<TGApp.Plugins.Mys.User.Post>;
users: Array<TGApp.BBS.Post.User>;
id: string;
};
}

View File

@@ -1,32 +0,0 @@
/**
* @file types/BBS/News.d.ts
* @description BBS 咨讯类型定义
* @since Beta v0.7.1
*/
declare namespace TGApp.BBS.News {
/**
* @description 咨讯返回数据
* @since Beta v0.7.1
* @interface Resp
* @extends TGApp.BBS.Response.BaseWithData
* @property {Res} data 咨讯数据
* @return Resp
*/
type Resp = TGApp.BBS.Response.BaseWithData<Res>;
/**
* @description 咨讯数据
* @since Beta v0.7.1
* @interface Res
* @property {number} last_id 最后一条咨讯 ID
* @property {boolean} is_last 是否最后一页
* @property {Array<TGApp.Plugins.Mys.Post.FullData>} list 咨讯列表
* @return Res
*/
type Res = {
last_id: number;
is_last: boolean;
list: Array<TGApp.Plugins.Mys.Post.FullData>;
};
}

View File

@@ -1,33 +1,92 @@
/**
* @file plugins/Mys/types/post.d.ts
* @description Mys
* @since Beta v0.7.1
* @file types/BBS/Post.d.ts
* @description
* @since Beta v0.7.2
*/
declare namespace TGApp.Plugins.Mys.Post {
declare namespace TGApp.BBS.Post {
/**
* @description
* @since Alpha v0.2.1
* @interface Response
* @description
* @since Beta v0.7.2
* @interface FullResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {FullData} data.post
* @return Response
* @property {FullRes} data
* @return FullResp
*/
type Response = TGApp.BBS.Response.BaseWithData & { data: { post: FullData } };
type FullResp = TGApp.BBS.Response.BaseWithData<FullRes>;
/**
* @description
* @since Beta v0.6.7
* @since Beta v0.7.2
* @interface FullRes
* @property {FullData} post
* @return FullRes
*/
type FullRes = { post: FullData };
/**
* @description
* @since Beta v0.7.2
* @interface SearchResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {SearchRes} data
* @return SearchResp
*/
type SearchResp = TGApp.BBS.Response.BaseWithData<SearchRes>;
/**
* @description
* @since Beta v0.7.2
* @interface SearchRes
* @property {Array<FullData>} posts
* @property {string} last_id
* @property {boolean} is_last
* @property {Array<string>} token_list token
* @property {Record<string,string>} databox
* @return SearchRes
*/
type SearchRes = {
posts: Array<FullData>;
last_id: string;
is_last: boolean;
token_list: Array<string>;
databox: Record<string, string>;
};
/**
* @description
* @since Beta v0.7.2
* @interface NewsResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {NewsRes} data
* @return NewsResp
*/
type NewsResp = TGApp.BBS.Response.BaseWithData<NewsRes>;
/**
* @description
* @since Beta v0.7.2
* @interface NewsRes
* @property {Array<FullData>} list
* @property {string} last_id ID
* @property {boolean} is_last
* @return NewsRes
*/
type NewsRes = { list: Array<FullData>; last_id: string; is_last: boolean };
/**
* @description
* @since Beta v0.7.2
* @interface FullData
* @property {Post} post
* @property {Forum|null} forum null
* @property {Array<TGApp.BBS.Topic.Info>} topics
* @property {TGApp.Plugins.Mys.User.Post|null} user null
* @property {TGApp.Plugins.Mys.User.SelfOperation} self_operation
* @property {User|null} user null
* @property {TGApp.BBS.User.SelfOperation} self_operation
* @property {Stat|null} stat null
* @property {HelpSys} help_sys null
* @property {Image} cover null
* @property {Image[]} image_list
* @property {Array<Image>} image_list
* @property {boolean} is_official_master
* @property {boolean} is_user_master
* @property {boolean} hot_reply_exist
@@ -35,23 +94,31 @@ declare namespace TGApp.Plugins.Mys.Post {
* @property {number} last_modify_time
* @property {string} recommend_type
* @property {Collection} collection null
* @property {unknown[]} vod_list
* @property {Array<Vod>} vod_list
* @property {boolean} is_block_on
* @property {unknown} forum_rank_info null
* @property {LinkCard[]} link_card_list
* @property {NewsMeta} news_meta null
* @property {NewsMeta} news_meta null'
* @property {RecommendReason|null} recommend_reason null
* @property {unknown} villa_card null
* @property {boolean} is_mentor
* @property {unknown} villa_room_card null
* @property {unknown} reply_avatar_action_info null
* @property {unknown} challenge null
* @property {Array<unknown>} hot_reply_list
* @property {Array<unknown>} villa_msg_image_list
* @return FullData
*/
interface FullData {
type FullData = {
post: Post;
forum: Forum | null;
topics: Array<TGApp.BBS.Topic.Info>;
user: TGApp.Plugins.Mys.User.Post | null;
self_operation: TGApp.Plugins.Mys.User.SelfOperation;
user: User | null;
self_operation: TGApp.BBS.User.SelfOperation;
stat: Stat | null;
help_sys: HelpSys | null;
cover: Image | null;
image_list: Image[];
image_list: Array<Image>;
is_official_master: boolean;
is_user_master: boolean;
hot_reply_exist: boolean;
@@ -59,24 +126,61 @@ declare namespace TGApp.Plugins.Mys.Post {
last_modify_time: number;
recommend_type: string;
collection: Collection | null;
vod_list: Vod[];
vod_list: Array<Vod>;
is_block_on: boolean;
forum_rank_info: unknown | null;
link_card_list: LinkCard[];
link_card_list: Array<LinkCard>;
news_meta?: NewsMeta | null;
recommend_reason: unknown | null;
recommend_reason: RecommendReason | null;
villa_card: unknown | null;
is_mentor: boolean;
villa_room_card: unknown | null;
reply_avatar_action_info: unknown | null;
challenge: unknown | null;
hot_reply_list: unknown[];
villa_msg_image_list: unknown[];
}
hot_reply_list: Array<unknown>;
villa_msg_image_list: Array<unknown>;
};
/**
* @description
* @since Beta v0.7.2
* @interface User
* @property {string} uid ID
* @property {string} nickname
* @property {string} introduce
* @property {string} avatar
* @property {number} gender
* @property {TGApp.BBS.User.Certification} certification
* @property level_exp
* @property {number} level_exp.level
* @property {number} level_exp.exp
* @property {boolean} is_following
* @property {boolean} is_followed
* @property {string} avatar_url
* @property {string} pendant URL ""
* @property {boolean} is_creator
* @property {TGApp.BBS.User.AvatarExt} avatar_ext
* @return User
*/
type User = {
uid: string;
nickname: string;
introduce: string;
avatar: string;
gender: number;
certification: TGApp.BBS.User.Certification;
level_exp: TGApp.BBS.User.LevelExp;
is_following: boolean;
is_followed: boolean;
avatar_url: string;
pendant: string;
is_creator: boolean;
avatar_ext: TGApp.BBS.User.AvatarExt;
};
/**
* @description
* @since Beta v0.3.7
* @since Beta v0.7.2
* @interface Post
* @property {number} game_id ID // 2 为原神
* @property {string} post_id ID
@@ -87,13 +191,9 @@ declare namespace TGApp.Plugins.Mys.Post {
* @property {string} cover URL ""
* @property {number} view_type
* @property {number} created_at
* @property {string[]} images
* @property post_status
* @property {boolean} post_status.is_top
* @property {boolean} post_status.is_good
* @property {boolean} post_status.is_official
* @property {number} post_status.post_status
* @property {number[]} topic_ids ID
* @property {Array<string>} images
* @property {PostStat} post_status
* @property {Array<number>} topic_ids ID
* @property {number} view_status
* @property {number} max_floor
* @property {number} is_original
@@ -101,8 +201,8 @@ declare namespace TGApp.Plugins.Mys.Post {
* @property {string} reply_time // "2023-03-05 20:26:54"
* @property {number} is_deleted
* @property {boolean} is_interactive
* @property {string} structured_content // 反序列化后为 TGApp.Plugins.Mys.SctPost.Common[]
* @property {string[]} structured_content_rows
* @property {string} structured_content // 反序列化后为 TGApp.BBS.SctPost.Common[]
* @property {Array<string>} structured_content_rows
* @property {number} review_id ID
* @property {boolean} is_profit
* @property {boolean} is_in_profit
@@ -121,7 +221,7 @@ declare namespace TGApp.Plugins.Mys.Post {
* @property {boolean} is_mentor
* @return Post
*/
interface Post {
type Post = {
game_id: number;
post_id: string;
f_forum_id: number;
@@ -131,14 +231,9 @@ declare namespace TGApp.Plugins.Mys.Post {
cover: string;
view_type: number;
created_at: number;
images: string[];
post_status: {
is_top: boolean;
is_good: boolean;
is_official: boolean;
post_status: number;
};
topic_ids: number[];
images: Array<string>;
post_status: PostStat;
topic_ids: Array<number>;
view_status: number;
max_floor: number;
is_original: number;
@@ -147,7 +242,7 @@ declare namespace TGApp.Plugins.Mys.Post {
is_deleted: number;
is_interactive: boolean;
structured_content: string;
structured_content_rows: string[];
structured_content_rows: Array<string>;
review_id: number;
is_profit: boolean;
is_in_profit: boolean;
@@ -164,26 +259,38 @@ declare namespace TGApp.Plugins.Mys.Post {
block_latest_reply_time: number;
selected_comment: number;
is_mentor: boolean;
}
};
/**
* @description
* @since Beta v0.7.2
* @interface PostStat
* @property {boolean} is_top
* @property {boolean} is_good
* @property {boolean} is_official
* @property {number} post_status
* @return PostStat
*/
type PostStat = { is_top: boolean; is_good: boolean; is_official: boolean; post_status: number };
/**
* @description
* @since Alpha v0.2.1
* @since Beta v0.7.2
* @interface Forum
* @property {number} id ID
* @property {string} name
* @property {string} icon URL
* @property {number} game_id ID // 2 为原神
* @property {unknown} forum_cate null
* @property {TGApp.BBS.Forum.ForumCate|null} forum_cate null
* @return Forum
*/
interface Forum {
type Forum = {
id: number;
name: string;
icon: string;
game_id: number;
forum_cate: unknown | null;
}
forum_cate: TGApp.BBS.Forum.ForumCate | null;
};
/**
* @description
@@ -194,39 +301,40 @@ declare namespace TGApp.Plugins.Mys.Post {
* @property {number} like_num
* @property {number} bookmark_num
* @property {number} forward_num
* @property post_upvote_stat
* @property {number} post_upvote_stat[].upvote_type
* @property {number} post_upvote_stat[].upvote_cnt
* @property {number} original_like_num
* @property {Array<StatUpvote>} post_upvote_stat
* @return Stat
*/
interface Stat {
type Stat = {
view_num: number;
reply_num: number;
like_num: number;
bookmark_num: number;
forward_num: number;
original_like_num: number;
post_upvote_stat: Array<{
upvote_type: number;
upvote_cnt: number;
}>;
}
post_upvote_stat: Array<StatUpvote>;
};
/**
* @description
* @since Beta v0.7.2
* @interface StatUpvote
* @property {number} upvote_type
* @property {number} upvote_cnt
* @return StatUpvote
*/
type StatUpvote = { upvote_type: number; upvote_cnt: number };
/**
* @description
* @since Beta v0.5.5
* @since Beta v0.7.2
* @interface Image
* @property {string} url URL
* @property {number} height
* @property {string} width
* @property {string} format // jpg
* @property {string} size // 281428
* @property crop null
* @property {number} crop.x X
* @property {number} crop.y Y
* @property {number} crop.w
* @property {number} crop.h
* @property {string} crop.url URL
* @property {ImageCrop|null} crop null
* @property {boolean} is_user_set_cover
* @property {string} image_id ID
* @property {string} entity_type // IMG_ENTITY_POST, IMG_ENTITY_UNKOWN
@@ -234,44 +342,47 @@ declare namespace TGApp.Plugins.Mys.Post {
* @property {boolean} is_deleted
* @return Image
*/
interface Image {
type Image = {
url: string;
height: number;
width: number;
format: string;
size: string;
crop: {
x: number;
y: number;
w: number;
h: number;
url: string;
} | null;
crop: ImageCrop | null;
is_user_set_cover?: boolean;
image_id: string;
entity_type: string;
entity_id: string;
is_deleted: boolean;
}
};
/**
* @description
* @since Beta v0.7.2
* @interface ImageCrop
* @property {number} x X
* @property {number} y Y
* @property {number} w
* @property {number} h
* @property {string} url URL
* @return ImageCrop
*/
type ImageCrop = { x: number; y: number; w: number; h: number; url: string };
/**
* @description help_sys
* @since Alpha v0.2.1
* @since Beta v0.7.2
* @interface HelpSys
* @property {unknown} top_up , null
* @property {unknown[]} top_n ,
* @property {Array<unknown>} top_n ,
* @property {number} answer_num
* @return HelpSys
*/
interface HelpSys {
top_up: unknown | null;
top_n: unknown[];
answer_num: number;
}
type HelpSys = { top_up: unknown | null; top_n: Array<unknown>; answer_num: number };
/**
* @description
* @since Beta v0.3.9
* @since Beta v0.7.2
* @interface Collection
* @property {string} prev_post_id ID 0
* @property {string} next_post_id ID 0
@@ -285,7 +396,7 @@ declare namespace TGApp.Plugins.Mys.Post {
* @property {number} next_post_view_type
* @return Collection
*/
interface Collection {
type Collection = {
prev_post_id: string;
next_post_id: string;
collection_id: string;
@@ -296,11 +407,11 @@ declare namespace TGApp.Plugins.Mys.Post {
next_post_game_id: number;
prev_post_view_type: number;
next_post_view_type: number;
}
};
/**
* @description
* @since Beta v0.6.7
* @since Beta v0.7.2
* @interface LinkCard
* @property {string} button_text
* @property {string} card_id ID
@@ -339,44 +450,53 @@ declare namespace TGApp.Plugins.Mys.Post {
/**
* @description
* @since Beta v0.3.7
* @since Beta v0.7.2
* @interface Vod
* @property {string} id ID
* @property {number} duration
* @property {string} cover URL
* @property {string} resolutions[].url URL
* @property {string} resolutions[].definition
* @property {number} resolutions[].width
* @property {number} resolutions[].height
* @property {number} resolutions[].bitrate
* @property {string} resolutions[].size
* @property {string} resolutions[].format
* @property {string} resolutions[].label
* @property {Array<VodResolution>} resolutions
* @property {number} view_num
* @property {number} transcoding_status
* @property {number} review_status
* @property {string} brief_info
* @return Vod
*/
interface Vod {
type Vod = {
id: string;
duration: number;
cover: string;
resolutions: Array<{
url: string;
definition: string;
width: number;
height: number;
bitrate: number;
size: string;
format: string;
label: string;
}>;
resolutions: Array<VodResolution>;
view_num: number;
transcoding_status: number;
review_status: number;
brief_info: string;
}
};
/**
* @description
* @since Beta v0.7.2
* @interface VodResolution
* @property {string} url URL
* @property {string} definition
* @property {number} width
* @property {number} height
* @property {number} bitrate
* @property {string} size
* @property {string} format
* @property {string} label
* @return VodResolution
*/
type VodResolution = {
url: string;
definition: string;
width: number;
height: number;
bitrate: number;
size: string;
format: string;
label: string;
};
/**
* @description
@@ -391,39 +511,11 @@ declare namespace TGApp.Plugins.Mys.Post {
/**
* @description
* @since Beta v0.3.7
* @since Beta v0.7.2
* @interface RecommendReason
* @property {string[]} tags
* @property {Array<string>} tags
* @property {boolean} is_mentor_rec_block
* @return RecommendReason
*/
interface RecommendReason {
tags: string[];
is_mentor_rec_block: boolean;
}
/**
* @description
* @since Beta v0.3.7
* @interface Challenge
* @property {string} id ID
* @property {string} title
* @property {number} participant_amount
* @property {TGApp.Plugins.Mys.User.Challenge} sponsor
* @property {TGApp.Plugins.Mys.User.Challenge[]} participants
* @property {boolean} is_sandbox
* @property {string} header_url URL
* @property {string} post_id ID
* @return Challenge
*/
interface Challenge {
id: string;
title: string;
participant_amount: number;
sponsor: TGApp.Plugins.Mys.User.Challenge;
participants: TGApp.Plugins.Mys.User.Challenge[];
is_sandbox: boolean;
header_url: string;
post_id: string;
}
type RecommendReason = { tags: Array<string>; is_mentor_rec_block: boolean };
}

View File

@@ -1,7 +1,7 @@
/**
* @file types/BBS/Reply.d.ts
* @description 回复数据类型定义文件
* @since Beta v0.7.1
* @since Beta v0.7.2
*/
declare namespace TGApp.BBS.Reply {
@@ -39,11 +39,11 @@ declare namespace TGApp.BBS.Reply {
* @description 子回复数据类型
* @since Beta v0.7.1
* @interface SubRootRes
* @property {TGApp.Plugins.Mys.Post.FullData} post - 帖子数据
* @property {TGApp.BBS.Post.FullData} post - 帖子数据
* @property {ReplyFull} reply - 回复数据
* @return SubRootRes
*/
type SubRootRes = { post: TGApp.Plugins.Mys.Post.FullData; reply: ReplyFull };
type SubRootRes = { post: TGApp.BBS.Post.FullData; reply: ReplyFull };
/**
* @description 回复数据类型
@@ -87,18 +87,18 @@ declare namespace TGApp.BBS.Reply {
/**
* @description 回复数据类型
* @since Beta v0.7.1
* @since Beta v0.7.2
* @interface ReplyFull
* @property {Reply} reply - 回复数据
* @property {User} user - 用户数据
* @property {Stat} stat - 点赞数据
* @property {SelfOperation} self_operation - 自身操作数据
* @property {TGApp.BBS.User.SelfOperation} self_operation - 自身操作数据
* @property {MasterStatus} master_status - 主楼状态数据
* @property {Array<TGApp.Plugins.Mys.Post.Image>} images - 图片数据
* @property {Array<TGApp.BBS.Post.Image>} images - 图片数据
* @property {Array<ReplyFull>} sub_replies - 子回复数据
* @property {boolean} is_lz - 是否楼主
* @property {number} sub_reply_count - 子回复数量
* @property {TGApp.Plugins.Mys.User.Reply} r_user - 回复用户数据
* @property {User} r_user - 回复用户数据
* @property {unknown} r_reply - 未知数据
* @property {unknown} r_post - 未知数据
* @property {unknown} user_game_info - 未知数据
@@ -106,15 +106,15 @@ declare namespace TGApp.BBS.Reply {
*/
type ReplyFull = {
reply: Reply;
user: TGApp.Plugins.Mys.User.Reply;
user: User;
stat: Stat;
self_operation: SelfOperation;
self_operation: TGApp.BBS.User.SelfOperation;
master_status: MasterStatus;
images: Array<TGApp.Plugins.Mys.Post.Image>;
images: Array<TGApp.BBS.Post.Image>;
sub_replies: Array<ReplyFull>;
is_lz: boolean;
sub_reply_count: number;
r_user: TGApp.Plugins.Mys.User.Reply | null;
r_user: User | null;
r_reply: unknown;
r_post: unknown;
user_game_info: unknown;
@@ -175,6 +175,45 @@ declare namespace TGApp.BBS.Reply {
view_status: number;
};
/**
* @description 帖子回复中的用户信息
* @since Beta v0.7.2
* @interface User
* @property {string} uid 用户 ID
* @property {string} nickname 用户昵称
* @property {string} introduce 用户简介
* @property {string} avatar 用户头像
* @property {number} gender 用户性别
* @property {TGApp.BBS.User.Certification} certification 用户认证信息
* @property {TGApp.BBS.User.LevelExp} level_exp 用户等级经验
* @property {string} avatar_url 用户头像链接
* @property {string} pendant 用户挂件 URL可能为 ""
* @property {string} ip_region 用户 IP 地区
* @property {boolean} is_following 是否关注
* @property {boolean} is_followed 是否被关注
* @property {TGApp.BBS.User.AvatarExt} avatar_ext 用户头像扩展信息
* @property {boolean} is_super_fan 是否是铁粉
* @property {Bubble} reply_bubble 回复气泡,可能为 null
* @return User
*/
type User = {
uid: string;
nickname: string;
introduce: string;
avatar: string;
gender: number;
certification: TGApp.BBS.User.Certification;
level_exp: TGApp.BBS.User.LevelExp;
avatar_url: string;
pendant: string;
ip_region: string;
is_following: boolean;
is_followed: boolean;
avatar_ext: TGApp.BBS.User.AvatarExt;
is_super_fan: boolean;
reply_bubble: Bubble | null;
};
/**
* @description 回复气泡数据类型
* @since Beta v0.7.1
@@ -199,16 +238,6 @@ declare namespace TGApp.BBS.Reply {
*/
type Stat = { reply_num: number; like_num: number; sub_num: number; dislike_num: number };
/**
* @description 自身操作数据类型
* @since Beta v0.7.1
* @interface SelfOperation
* @property {number} attitude - 操作态度
* @property {number} reply_vote_attitude - 回复投票态度
* @return SelfOperation
*/
type SelfOperation = { attitude: number; reply_vote_attitude: number };
/**
* @description 主楼状态数据类型
* @since Beta v0.5.5

View File

@@ -1,23 +1,23 @@
/**
* @file plugins/Mys/types/SctPost.d.ts
* @description Mys
* @since Beta v0.6.7
* @file types/BBS/SctPost.d.ts
* @description
* @since Beta v0.7.2
*/
declare namespace TGApp.Plugins.Mys.SctPost {
declare namespace TGApp.BBS.SctPost {
/**
* @description -
* @since Beta v0.6.7
* @interface Base
* @property {string | Record<string, unknown>} insert -
* @property {Record<string, unknown>} attributes -
* @property {Base[]} children -
* @property {Array<Base>} children -
* @return Base
*/
type Base = {
insert: string | Record<string, unknown>;
attributes?: Record<string, unknown>;
children?: Base[];
children?: Array<Base>;
};
/**
@@ -34,11 +34,11 @@ declare namespace TGApp.Plugins.Mys.SctPost {
* @description -
* @since Beta v0.6.7
* @property {string} describe -
* @property {string[]} imgs -
* @property {string[]} link_card_ids - ID
* @property {Array<string>} imgs -
* @property {Array<string>} link_card_ids - ID
* @return Other
*/
type Other = { describe: string; imgs: string[]; link_card_ids?: string[] } & {
type Other = { describe: string; imgs: Array<string>; link_card_ids?: Array<string> } & {
[key: string]: unknown;
};
}

View File

@@ -1,36 +0,0 @@
/**
* @file types/BBS/Search.d.ts
* @description 米游社搜索类型声明
* @since Beta v0.7.1
*/
declare namespace TGApp.BBS.Search {
/**
* @description 搜索帖子返回
* @since Beta v0.7.1
* @interface PostsResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {PostsRes} data 返回数据
* @return PostsResp
*/
type PostsResp = TGApp.BBS.Response.BaseWithData<PostsRes>;
/**
* @description 搜索帖子返回数据
* @since Beta v0.7.1
* @interface PostsRes
* @property {TGApp.Plugins.Mys.Post.FullData[]} posts 帖子列表
* @property {string} last_id 索引
* @property {boolean} is_last 是否最后一页
* @property {string[]} token_list token 列表
* @property {Record<string,string>} databox 数据盒
* @return PostsRes
*/
type PostsRes = {
posts: Array<TGApp.Plugins.Mys.Post.FullData>;
last_id: string;
is_last: boolean;
token_list: string[];
databox: Record<string, string>;
};
}

View File

@@ -59,14 +59,14 @@ declare namespace TGApp.BBS.Topic {
* @property {boolean} is_last 是否最后一页
* @property {boolean} is_origin 是否原创
* @property {string} last_id 最后一条帖子 ID
* @property {Array<TGApp.Plugins.Mys.Post.FullData>} posts 帖子列表
* @property {Array<TGApp.BBS.Post.FullData>} posts 帖子列表
* @return PostRes
*/
type PostRes = {
is_last: boolean;
is_origin: boolean;
last_id: string;
posts: Array<TGApp.Plugins.Mys.Post.FullData>;
posts: Array<TGApp.BBS.Post.FullData>;
};
/**

View File

@@ -1,26 +1,24 @@
/**
* @file plugins/Mys/types/user.ts
* @description Mys
* @since Beta v0.5.5
* @file types/BBS/User.d.ts
* @description
* @since Beta v0.7.2
*/
declare namespace TGApp.Plugins.Mys.User {
declare namespace TGApp.BBS.User {
/**
* @description
* @since Alpha v0.2.1
* @interface HomeResponse
* @description
* @since Beta v0.7.2
* @interface InfoResp
* @extends TGApp.BBS.Response.BaseWithData
* @property {Home} data
* @return HomeResponse
* @property {InfoRes} data
* @return InfoResp
*/
interface HomeResponse extends TGApp.BBS.Response.BaseWithData {
data: Home;
}
type InfoResp = TGApp.BBS.Response.BaseWithData<InfoRes>;
/**
* @description
* @since Alpha v0.2.1
* @interface Home
* @since Beta v0.7.2
* @interface InfoRes
* @property {Info} user_info
* @property {unknown} follow_relation
* @property {unknown[]} auth_relations
@@ -36,12 +34,12 @@ declare namespace TGApp.Plugins.Mys.User {
* @property {boolean} audit_info.is_introduce_in_audit
* @property {string} audit_info.introduce
* @property {number} audit_info.nickname_status
* @return Home
* @return InfoRes
*/
interface Home {
type InfoRes = {
user_info: Info;
follow_relation: unknown;
auth_relations: unknown[];
auth_relations: Array<unknown>;
is_in_blacklist: boolean;
is_has_collection: boolean;
is_creator: boolean;
@@ -56,11 +54,11 @@ declare namespace TGApp.Plugins.Mys.User {
introduce: string;
nickname_status: number;
};
}
};
/**
* @description -
* @since Alpha v0.2.1
* @since Beta v0.7.2
* @interface Info
* @property {string} uid ID
* @property {string} nickname
@@ -79,23 +77,23 @@ declare namespace TGApp.Plugins.Mys.User {
* @property {string} ip_region IP
* @return Info
*/
interface Info {
type Info = {
uid: string;
nickname: string;
introduce: string;
avatar: string;
gender: number;
certification: Certification;
level_exps: LevelExp[];
level_exps: Array<LevelExp>;
archive: Archive;
community_info: Community;
avatar_url: string;
certifications: Certification[];
certifications: Array<Certification>;
level_exp: LevelExp;
pendant: string;
is_logoff: boolean;
ip_region: string;
}
};
/**
* @description
@@ -105,25 +103,46 @@ declare namespace TGApp.Plugins.Mys.User {
* @property {string} label
* @return Certification
*/
interface Certification {
type: number;
label: string;
}
type Certification = { type: number; label: string };
/**
* @description
* @since Alpha v0.2.1
* @since Beta v0.7.2
* @interface LevelExp
* @property {number} level
* @property {number} exp
* @property {number} game_id ID
* @return LevelExp
*/
interface LevelExp {
level: number;
exp: number;
game_id: number;
}
type LevelExp = { level: number; exp: number; game_id?: number };
/**
* @description
* @since Beta v0.7.2
* @interface SelfOperation
* @property {number} attitude
* @property {boolean} is_collected
* @property {number} upvote_type
* @returns {SelfOperation}
*/
type SelfOperation = { attitude: number; is_collected: boolean; upvote_type: number };
/**
* @description
* @since Beta v0.7.2
* @interface AvatarExt
* @property {number} avatar_type
* @property {string} avatar_assets_id ID
* @property {Array<unknown>} resources
* @property {Array<unknown>} hd_resources
* @return AvatarExt
*/
type AvatarExt = {
avatar_type: number;
avatar_assets_id: string;
resources: Array<unknown>;
hd_resources: Array<unknown>;
};
/**
* @description
@@ -140,7 +159,7 @@ declare namespace TGApp.Plugins.Mys.User {
* @property {string} follow_collection_cnt
* @return Archive
*/
interface Archive {
type Archive = {
like_num: string;
post_num: string;
replypost_num: string;
@@ -150,11 +169,11 @@ declare namespace TGApp.Plugins.Mys.User {
new_follower_num: string;
good_post_num: string;
follow_collection_cnt: string;
}
};
/**
* @description
* @since Alpha v0.2.1
* @since Beta v0.7.2
* @interface Community
* @property {boolean} is_realname
* @property {boolean} agree_status
@@ -185,7 +204,7 @@ declare namespace TGApp.Plugins.Mys.User {
* @property {number} created_at
* @return Community
*/
interface Community {
type Community = {
is_realname: boolean;
agree_status: boolean;
silent_end_time: number;
@@ -216,131 +235,5 @@ declare namespace TGApp.Plugins.Mys.User {
last_login_ip: string;
last_login_time: number;
created_at: number;
}
/**
* @description post中的用户信息
* @since Beta v0.3.7
* @interface Post
* @property {string} uid ID
* @property {string} nickname
* @property {string} introduce
* @property {string} avatar
* @property {number} gender
* @property {Certification} certification
* @property level_exp
* @property {number} level_exp.level
* @property {number} level_exp.exp
* @property {boolean} is_following
* @property {boolean} is_followed
* @property {string} avatar_url
* @property {string} pendant URL ""
* @property {boolean} is_creator
* @property {AvatarExt} avatar_ext
* @return Post
*/
interface Post {
uid: string;
nickname: string;
introduce: string;
avatar: string;
gender: number;
certification: Certification;
level_exp: {
level: number;
exp: number;
};
is_following: boolean;
is_followed: boolean;
avatar_url: string;
pendant: string;
is_creator: boolean;
avatar_ext: AvatarExt;
}
/**
* @description
* @since Beta v0.3.7
* @interface SelfOperation
* @property {number} attitude
* @property {boolean} is_collected
* @property {number} upvote_type
* @returns {SelfOperation}
*/
interface SelfOperation {
attitude: number;
is_collected: boolean;
upvote_type: number;
}
/**
* @description
* @since Beta v0.3.7
* @interface AvatarExt
* @property {number} avatar_type
* @property {string} avatar_assets_id ID
* @property {unknown[]} resources
* @property {unknown[]} hd_resources
* @return AvatarExt
*/
interface AvatarExt {
avatar_type: number;
avatar_assets_id: string;
resources: unknown[];
hd_resources: unknown[];
}
/**
* @description post.challenge
* @since Beta v0.3.7
* @interface Challenge
* @property {string} uid ID
* @property {string} nickname
* @property {string} avatar_url
* @return Challenge
*/
interface Challenge {
uid: string;
nickname: string;
avatar_url: string;
}
/**
* @description
* @since Beta v0.5.5
* @interface Reply
* @property {string} uid ID
* @property {string} nickname
* @property {string} introduce
* @property {string} avatar
* @property {number} gender
* @property {Certification} certification
* @property {LevelExp} level_exp
* @property {string} avatar_url
* @property {string} pendant URL ""
* @property {string} ip_region IP
* @property {boolean} is_following
* @property {boolean} is_followed
* @property {AvatarExt} avatar_ext
* @property {boolean} is_super_fan
* @property {TGApp.BBS.Reply.Bubble} reply_bubble null
* @return Reply
*/
interface Reply {
uid: string;
nickname: string;
introduce: string;
avatar: string;
gender: number;
certification: Certification;
level_exp: LevelExp;
avatar_url: string;
pendant: string;
ip_region: string;
is_following: boolean;
is_followed: boolean;
avatar_ext: AvatarExt;
is_super_fan: boolean;
reply_bubble: TGApp.BBS.Reply.Bubble | null;
}
};
}

View File

@@ -17,7 +17,7 @@ declare namespace TGApp.Sqlite.UserCollection {
* @interface UFPost
* @property {string} id - 帖子 ID
* @property {string} title - 标题
* @description 反序列化后是 TGApp.Plugins.Mys.Post.FullData
* @description 反序列化后是 TGApp.BBS.Post.FullData
* @property {string} content - 内容
* @property {string} updated - 更新时间
* @return UFPost

View File

@@ -89,7 +89,7 @@ const lang = <AnnoLang>route.params.lang;
const { theme } = storeToRefs(useAppStore());
const jsonList = shallowRef<TGApp.BBS.Announcement.AnnoSingle>();
const jsonContent = shallowRef<TGApp.BBS.Announcement.ContentItem>();
const parsedJson = shallowRef<Array<TGApp.Plugins.Mys.SctPost.Base>>();
const parsedJson = shallowRef<Array<TGApp.BBS.SctPost.Base>>();
const jsonTheme = computed<"dark" | "light">(() => (theme.value === "dark" ? "dark" : "light"));
onMounted(async () => {

View File

@@ -66,8 +66,8 @@ const { theme } = storeToRefs(useAppStore());
const { cookie } = storeToRefs(useUserStore());
const postId = Number(useRoute().params.post_id);
const isEmpty = ref<boolean>(false);
const jsonData = shallowRef<TGApp.Plugins.Mys.Post.FullData>();
const parseData = shallowRef<Array<TGApp.Plugins.Mys.SctPost.Base>>();
const jsonData = shallowRef<TGApp.BBS.Post.FullData>();
const parseData = shallowRef<Array<TGApp.BBS.SctPost.Base>>();
const jsonTheme = computed<"dark" | "light">(() => (theme.value === "dark" ? "dark" : "light"));
onMounted(async () => {

View File

@@ -121,8 +121,8 @@ const postId = Number(useRoute().params.post_id);
const showCollection = ref<boolean>(false);
const isLike = ref<boolean>(false);
const shareTime = ref<number>(Math.floor(Date.now() / 1000));
const renderPost = shallowRef<Array<TGApp.Plugins.Mys.SctPost.Base>>([]);
const postData = shallowRef<TGApp.Plugins.Mys.Post.FullData>();
const renderPost = shallowRef<Array<TGApp.BBS.SctPost.Base>>([]);
const postData = shallowRef<TGApp.BBS.Post.FullData>();
// eslint-disable-next-line no-undef
let shareTimer: NodeJS.Timeout | null = null;
@@ -208,8 +208,8 @@ function getRepublishAuthorization(type: number): string {
}
async function getRenderPost(
data: TGApp.Plugins.Mys.Post.FullData,
): Promise<Array<TGApp.Plugins.Mys.SctPost.Base>> {
data: TGApp.BBS.Post.FullData,
): Promise<Array<TGApp.BBS.SctPost.Base>> {
const postContent = data.post.content;
let jsonParse: string;
if (postContent.startsWith("<")) {
@@ -228,8 +228,8 @@ async function getRenderPost(
}
async function parseContent(content: string): Promise<string> {
const data: TGApp.Plugins.Mys.SctPost.Other = JSON.parse(content);
const result: TGApp.Plugins.Mys.SctPost.Base[] = [];
const data: TGApp.BBS.SctPost.Other = JSON.parse(content);
const result: TGApp.BBS.SctPost.Base[] = [];
for (const key of Object.keys(data)) {
switch (key) {
case "describe":
@@ -301,7 +301,7 @@ async function toTopic(topic: TGApp.BBS.Topic.Info): Promise<void> {
await emit("active_deep_link", `router?path=/posts/topic/${gid}/${topic.id}`);
}
async function toForum(forum: TGApp.Plugins.Mys.Post.Forum): Promise<void> {
async function toForum(forum: TGApp.BBS.Post.Forum): Promise<void> {
await emit("active_deep_link", `router?path=/posts/forum/${forum.game_id}/${forum.id}`);
}

View File

@@ -31,14 +31,14 @@ async function getEmoticonSet(): Promise<Record<string, string> | TGApp.BBS.Resp
* @description 根据 cookie 获取用户信息
* @since Beta v0.5.0
* @param {TGApp.App.Account.Cookie} cookie - 账户 cookie
* @returns {Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.User.Info>}
* @returns {Promise<TGApp.BBS.Response.Base | TGApp.BBS.User.Info>}
*/
async function getUserFullInfo(
cookie: TGApp.App.Account.Cookie,
): Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.User.Info> {
): Promise<TGApp.BBS.Response.Base | TGApp.BBS.User.Info> {
const ck = { cookie_token: cookie.cookie_token, account_id: cookie.account_id };
const params = { gids: "2" };
const resp = await TGHttp<TGApp.Plugins.Mys.User.HomeResponse | TGApp.BBS.Response.Base>(
const resp = await TGHttp<TGApp.BBS.User.InfoResp>(
"https://bbs-api.miyoushe.com/user/wapi/getUserFullInfo",
{ method: "GET", headers: getRequestHeader(ck, "GET", params, "X4", true), query: params },
);
@@ -51,14 +51,14 @@ async function getUserFullInfo(
* @since Beta v0.7.1
* @param {number} gid - gid
* @param {string} userId - 用户 id
* @returns {Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.User.Info>}
* @returns {Promise<TGApp.BBS.Response.Base | TGApp.BBS.User.Info>}
*/
async function getOtherUserInfo(
gid: number,
userId: string,
): Promise<TGApp.BBS.Response.Base | TGApp.Plugins.Mys.User.Info> {
): Promise<TGApp.BBS.Response.Base | TGApp.BBS.User.Info> {
const params = { gids: gid.toString(), uid: userId };
const resp = await TGHttp<TGApp.Plugins.Mys.User.HomeResponse | TGApp.BBS.Response.Base>(
const resp = await TGHttp<TGApp.BBS.User.InfoResp>(
"https://bbs-api.miyoushe.com/user/wapi/getUserFullInfo",
{ method: "GET", headers: getRequestHeader({}, "GET", params, "X4", true), query: params },
);

View File

@@ -15,16 +15,16 @@ const bapBu: Readonly<string> = "https://bbs-api.miyoushe.com/painter/wapi/";
* @param {string} newsType 咨讯类型: 1 为公告2 为活动3 为咨讯
* @param {number} pageSize 返回数量
* @param {number} lastId 上一次请求的最后一条数据的 id
* @return {Promise<TGApp.BBS.News.Res>}
* @return {Promise<TGApp.BBS.Post.NewsRes>}
*/
async function getNewsList(
gid: string = "2",
newsType: string = "1",
pageSize: number = 20,
lastId: number = 0,
): Promise<TGApp.BBS.News.Res> {
): Promise<TGApp.BBS.Post.NewsRes> {
return (
await TGHttp<TGApp.BBS.News.Resp>(`${bapBu}getNewsList`, {
await TGHttp<TGApp.BBS.Post.NewsResp>(`${bapBu}getNewsList`, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: { gids: gid, page_size: pageSize, type: newsType, last_id: lastId },

View File

@@ -15,12 +15,12 @@ const Referer: Readonly<string> = "https://bbs.mihoyo.com/";
* @since Beta v0.7.1
* @param {number|string} postId 帖子 ID
* @param {Record<string, string>} cookie Cookie
* @return {Promise<TGApp.Plugins.Mys.Post.FullData|TGApp.BBS.Response.Base>}
* @return {Promise<TGApp.BBS.Post.FullData | TGApp.BBS.Response.Base>}
*/
async function getPostFull(
postId: number | string,
cookie?: Record<string, string>,
): Promise<TGApp.Plugins.Mys.Post.FullData | TGApp.BBS.Response.Base> {
): Promise<TGApp.BBS.Post.FullData | TGApp.BBS.Response.Base> {
const param = { post_id: postId, read: 1 };
let header;
if (cookie) {
@@ -29,7 +29,7 @@ async function getPostFull(
"x-rpc-client_type": "2",
};
} else header = { referer: Referer };
const resp = await TGHttp<TGApp.Plugins.Mys.Post.Response>(`${bapBu}getPostFull`, {
const resp = await TGHttp<TGApp.BBS.Post.FullResp>(`${bapBu}getPostFull`, {
method: "GET",
headers: header,
query: param,
@@ -42,11 +42,11 @@ async function getPostFull(
* @description 获取合集帖子
* @since Beta v0.7.1
* @param {string} collectionId 合集 ID
* @returns {Promise<TGApp.Plugins.Mys.Post.FullData[]>}
* @returns {Promise<Array<TGApp.BBS.Post.FullData>>}
*/
async function getPostFullInCollection(
collectionId: string,
): Promise<Array<TGApp.Plugins.Mys.Post.FullData>> {
): Promise<Array<TGApp.BBS.Post.FullData>> {
return (
await TGHttp<TGApp.BBS.Collection.PostsResp>(`${bapBu}getPostFullInCollection`, {
method: "GET",
@@ -177,15 +177,15 @@ async function getTopicPostList(
* @param {string} gid 游戏分区 ID
* @param {string} keyword 关键词
* @param {string} lastId 最后一条帖子 ID
* @return {Promise<TGApp.BBS.Search.PostsRes>} 返回帖子列表
* @return {Promise<TGApp.BBS.Post.SearchRes>} 返回帖子列表
*/
async function searchPosts(
gid: string = "2",
keyword: string,
lastId: string,
): Promise<TGApp.BBS.Search.PostsRes> {
): Promise<TGApp.BBS.Post.SearchRes> {
return (
await TGHttp<TGApp.BBS.Search.PostsResp>(`${bapBu}searchPosts`, {
await TGHttp<TGApp.BBS.Post.SearchResp>(`${bapBu}searchPosts`, {
method: "GET",
headers: { "Content-Type": "application/json" },
query: { gids: gid, keyword, last_id: lastId, size: 20 },

View File

@@ -129,15 +129,14 @@ async function genAuthKey2(
* @description 通过cookie获取游戏账号
* @since Beta v0.7.2
* @param {TGApp.App.Account.Cookie} cookie cookie
* @returns {Promise<TGApp.BBS.Account.GameAccount[]|TGApp.BBS.Response.Base>}
* @returns {Promise<Array<TGApp.BBS.Game.Account>|TGApp.BBS.Response.Base>}
*/
async function getUserGameRolesByCookie(
cookie: TGApp.App.Account.Cookie,
): Promise<TGApp.BBS.Account.GameAccount[] | TGApp.BBS.Response.Base> {
): Promise<Array<TGApp.BBS.Game.Account> | TGApp.BBS.Response.Base> {
const ck = { account_id: cookie.account_id, cookie_token: cookie.cookie_token };
const params = { game_biz: "hk4e_cn" };
type ResType = { list: Array<TGApp.BBS.Account.GameAccount> };
const resp = await TGHttp<TGApp.BBS.Response.BaseWithData<ResType>>(
const resp = await TGHttp<TGApp.BBS.Game.AccountResp>(
`${taBu}binding/api/getUserGameRolesByCookie`,
{
method: "GET",

View File

@@ -41,15 +41,13 @@ function handleAnnoContent(data: string): string {
* @description 解析公告内容,转换为结构化数据
* @since Beta v0.5.3
* @param {TGApp.BBS.Announcement.ContentItem} anno - 公告内容
* @returns {TGApp.Plugins.Mys.SctPost.Base[]} 结构化数据
* @returns {TGApp.BBS.SctPost.Base[]} 结构化数据
*/
function parseAnnoContent(
anno: TGApp.BBS.Announcement.ContentItem,
): Array<TGApp.Plugins.Mys.SctPost.Base> {
function parseAnnoContent(anno: TGApp.BBS.Announcement.ContentItem): Array<TGApp.BBS.SctPost.Base> {
const parser = new DOMParser();
const first = handleAnnoContent(anno.content);
const doc = parser.parseFromString(first, "text/html");
const children: Array<TGApp.Plugins.Mys.SctPost.Base> = [];
const children: Array<TGApp.BBS.SctPost.Base> = [];
if (anno.banner !== "") children.push({ insert: { image: anno.banner } });
doc.body.childNodes.forEach((child) => children.push(...parseAnnoNode(child)));
return children;
@@ -60,13 +58,10 @@ function parseAnnoContent(
* @since Beta v0.7.0
* @param {Node} node - 节点
* @param {Record<string, string>} attr - 属性
* @returns {TGApp.Plugins.Mys.SctPost.Base} 结构化数据
* @returns {TGApp.BBS.SctPost.Base} 结构化数据
*/
function parseAnnoNode(
node: Node,
attr?: Record<string, string>,
): Array<TGApp.Plugins.Mys.SctPost.Base> {
let defaultRes: TGApp.Plugins.Mys.SctPost.Base = {
function parseAnnoNode(node: Node, attr?: Record<string, string>): Array<TGApp.BBS.SctPost.Base> {
let defaultRes: TGApp.BBS.SctPost.Base = {
insert: {
tag: node.nodeName,
text: node.textContent,
@@ -95,7 +90,7 @@ function parseAnnoNode(
return [parseAnnoParagraph(element, attr)];
}
if (element.tagName === "OL" || element.tagName === "LI" || element.tagName === "UL") {
const res: Array<TGApp.Plugins.Mys.SctPost.Base> = [];
const res: Array<TGApp.BBS.SctPost.Base> = [];
Array.from(element.children).forEach((child) => res.push(...parseAnnoNode(child, attr)));
for (const comp of res) {
if (comp.children) {
@@ -112,7 +107,7 @@ function parseAnnoNode(
if (element.tagName === "TABLE") return [parseAnnoTable(element)];
if (element.tagName === "DIV") {
if (element.childNodes.length > 1) {
const res: Array<TGApp.Plugins.Mys.SctPost.Base> = [];
const res: Array<TGApp.BBS.SctPost.Base> = [];
element.childNodes.forEach((child) => res.push(...parseAnnoNode(child, attr)));
return res;
}
@@ -128,12 +123,12 @@ function parseAnnoNode(
}
if (element.tagName === "SPAN") return [parseAnnoSpan(element, attr)];
if (element.tagName === "STRONG") {
const res: Array<TGApp.Plugins.Mys.SctPost.Base> = [];
const res: Array<TGApp.BBS.SctPost.Base> = [];
element.childNodes.forEach((child) => res.push(...parseAnnoNode(child, { bold: "true" })));
return res;
}
if (element.tagName === "T") {
const res: Array<TGApp.Plugins.Mys.SctPost.Base> = [];
const res: Array<TGApp.BBS.SctPost.Base> = [];
element.childNodes.forEach((child) => res.push(...parseAnnoNode(child, attr)));
return res;
}
@@ -145,12 +140,9 @@ function parseAnnoNode(
* @since Beta v0.7.0
* @param {HTMLElement} p - 段落元素
* @param {Record<string, string>} attr - 属性
* @returns {TGApp.Plugins.Mys.SctPost.Base} 结构化数据
* @returns {TGApp.BBS.SctPost.Base} 结构化数据
*/
function parseAnnoParagraph(
p: HTMLElement,
attr?: Record<string, string>,
): TGApp.Plugins.Mys.SctPost.Base {
function parseAnnoParagraph(p: HTMLElement, attr?: Record<string, string>): TGApp.BBS.SctPost.Base {
const defaultRes = {
insert: {
tag: p.tagName,
@@ -193,9 +185,9 @@ function parseAnnoParagraph(
if (child.tagName === "T") return { insert: "", children: parseAnnoNode(child) };
return defaultRes;
}
const res: TGApp.Plugins.Mys.SctPost.Base = { insert: "", children: [] };
const res: TGApp.BBS.SctPost.Base = { insert: "", children: [] };
p.childNodes.forEach((child) => {
let childRes: TGApp.Plugins.Mys.SctPost.Base;
let childRes: TGApp.BBS.SctPost.Base;
if (child.nodeType === Node.TEXT_NODE) {
childRes = { insert: child.textContent ?? "" };
} else if (child.nodeType === Node.ELEMENT_NODE) {
@@ -227,12 +219,9 @@ function parseAnnoParagraph(
* @since Beta v0.7.0
* @param {HTMLElement} span - span 元素
* @param {Record<string, string>} attr - 属性
* @returns {TGApp.Plugins.Mys.SctPost.Base} 结构化数据
* @returns {TGApp.BBS.SctPost.Base} 结构化数据
*/
function parseAnnoSpan(
span: HTMLElement,
attr?: Record<string, string>,
): TGApp.Plugins.Mys.SctPost.Base {
function parseAnnoSpan(span: HTMLElement, attr?: Record<string, string>): TGApp.BBS.SctPost.Base {
const defaultRes = {
insert: {
tag: span.tagName,
@@ -281,9 +270,9 @@ function parseAnnoSpan(
* @description 解析公告图片
* @since Beta v0.7.0
* @param {HTMLElement} img - 图片元素
* @returns {TGApp.Plugins.Mys.SctPost.Base} 结构化数据
* @returns {TGApp.BBS.SctPost.Base} 结构化数据
*/
function parseAnnoImage(img: HTMLElement): TGApp.Plugins.Mys.SctPost.Base {
function parseAnnoImage(img: HTMLElement): TGApp.BBS.SctPost.Base {
if (img.tagName !== "IMG") {
return {
insert: {
@@ -304,9 +293,9 @@ function parseAnnoImage(img: HTMLElement): TGApp.Plugins.Mys.SctPost.Base {
* @description 解析公告锚点
* @since Beta v0.7.0
* @param {HTMLElement} a - 锚点元素
* @returns {TGApp.Plugins.Mys.SctPost.Base} 结构化数据
* @returns {TGApp.BBS.SctPost.Base} 结构化数据
*/
function parseAnnoAnchor(a: HTMLElement): TGApp.Plugins.Mys.SctPost.Base {
function parseAnnoAnchor(a: HTMLElement): TGApp.BBS.SctPost.Base {
if (a.tagName !== "A") {
return {
insert: {
@@ -333,9 +322,9 @@ function parseAnnoAnchor(a: HTMLElement): TGApp.Plugins.Mys.SctPost.Base {
* @description 解析公告详情
* @since Beta v0.7.0
* @param {HTMLElement} details - 详情元素
* @returns {TGApp.Plugins.Mys.SctPost.Base} 结构化数据
* @returns {TGApp.BBS.SctPost.Base} 结构化数据
*/
function parseAnnoDetails(details: HTMLElement): TGApp.Plugins.Mys.SctPost.Base {
function parseAnnoDetails(details: HTMLElement): TGApp.BBS.SctPost.Base {
const defaultRes = {
insert: {
tag: details.tagName,
@@ -368,9 +357,9 @@ function parseAnnoDetails(details: HTMLElement): TGApp.Plugins.Mys.SctPost.Base
* @description 解析公告表格
* @since Beta v0.7.0
* @param {HTMLElement} table - 表格元素
* @returns {TGApp.Plugins.Mys.SctPost.Base} 结构化数据
* @returns {TGApp.BBS.SctPost.Base} 结构化数据
*/
function parseAnnoTable(table: HTMLElement): TGApp.Plugins.Mys.SctPost.Base {
function parseAnnoTable(table: HTMLElement): TGApp.BBS.SctPost.Base {
const defaultRes = {
insert: {
tag: table.tagName,