diff --git a/src/components/main/t-postcard.vue b/src/components/main/t-postcard.vue index 6b2152a9..13cf2e5b 100644 --- a/src/components/main/t-postcard.vue +++ b/src/components/main/t-postcard.vue @@ -38,7 +38,7 @@ -
+
{{ card.forum.name }}
@@ -179,7 +179,11 @@ function getCommonCard(item: TGApp.Plugins.Mys.Post.FullData): TGApp.Plugins.Mys function getPostCard(item: TGApp.Plugins.Mys.Post.FullData): TGApp.Plugins.Mys.News.RenderCard { const commonCard = getCommonCard(item); - if (item.news_meta !== null && item.news_meta.start_at_sec !== "0") { + if ( + item.news_meta !== undefined && + item.news_meta !== null && + item.news_meta.start_at_sec !== "0" + ) { isAct.value = true; const startTime = new Date(Number(item.news_meta.start_at_sec) * 1000).toLocaleDateString(); const endTime = new Date(Number(item.news_meta.end_at_sec) * 1000).toLocaleDateString(); diff --git a/src/components/overlay/to-achiInfo.vue b/src/components/overlay/to-achiInfo.vue index 74fd88a7..534ded7c 100644 --- a/src/components/overlay/to-achiInfo.vue +++ b/src/components/overlay/to-achiInfo.vue @@ -4,7 +4,9 @@
- {{ props.data.name }} + {{ + props.data.name + }} {{ props.data.description }}
@@ -24,7 +26,7 @@
mdi-alert-decagram - {{ item.name }} + {{ item.name }} ({{ item.type }})
@@ -49,6 +51,7 @@
+ diff --git a/src/components/post/tp-avatar.vue b/src/components/post/tp-avatar.vue index 71446a29..0cc8028c 100644 --- a/src/components/post/tp-avatar.vue +++ b/src/components/post/tp-avatar.vue @@ -4,7 +4,7 @@
{{ props.data.nickname }}
{{ getAuthorDesc() }}
-
+
avatar { - const url = `https://www.miyoushe.com/ys/#/accountCenter/0?id=${props.data.uid}`; - window.open(url, "_blank"); -} - const flexAlign = props.position === "left" ? "flex-start" : "flex-end"; const textAlign = props.position; @@ -83,7 +78,6 @@ const textAlign = props.position; position: relative; width: 50px; height: 50px; - cursor: pointer; } .tpa-icon { diff --git a/src/pages/common/News.vue b/src/pages/common/News.vue index abbfe87f..891488d2 100644 --- a/src/pages/common/News.vue +++ b/src/pages/common/News.vue @@ -8,7 +8,7 @@ v-model="search" class="news-search" append-icon="mdi-magnify" - label="请输入米游社帖子 ID" + label="请输入帖子 ID 或搜索词" :single-line="true" hide-details @click:append="searchPost" @@ -40,6 +40,7 @@ + diff --git a/src/pages/common/Posts.vue b/src/pages/common/Posts.vue index 34237c05..75d4ac8d 100644 --- a/src/pages/common/Posts.vue +++ b/src/pages/common/Posts.vue @@ -27,7 +27,7 @@ v-model="search" class="post-switch-item" append-inner-icon="mdi-magnify" - label="请输入帖子 ID" + label="请输入帖子 ID 或搜索词" variant="outlined" :single-line="true" hide-details @@ -51,6 +51,7 @@
+ @@ -351,7 +352,7 @@ function searchPost(): void { } .post-switch-item { - max-width: 200px; + width: fit-content; height: 50px; } diff --git a/src/plugins/Mys/index.ts b/src/plugins/Mys/index.ts index 3c32139e..7ce6b379 100644 --- a/src/plugins/Mys/index.ts +++ b/src/plugins/Mys/index.ts @@ -15,6 +15,7 @@ import getNewsList from "./request/getNewsList"; import { getPositionData } from "./request/getPositionData"; import getPostData from "./request/getPostData"; import { getVoteInfo, getVoteResult } from "./request/getVoteData"; +import searchPosts from "./request/searchPost"; import { getGachaCard } from "./utils/getGachaCard"; import getLotteryCard from "./utils/getLotteryCard"; import getPositionCard from "./utils/getPositionCard"; @@ -31,6 +32,7 @@ const Mys = { Posts: { get: getForumList, nav: getHomeNavigator, + search: searchPosts, }, Gacha: { get: getGachaData, diff --git a/src/plugins/Mys/request/searchPost.ts b/src/plugins/Mys/request/searchPost.ts new file mode 100644 index 00000000..2755741d --- /dev/null +++ b/src/plugins/Mys/request/searchPost.ts @@ -0,0 +1,42 @@ +/** + * @file plugins/Mys/request/searchPost.ts + * @description 帖子搜索 + * @since Beta v0.4.5 + */ + +import { http } from "@tauri-apps/api"; + +/** + * @description 搜索帖子 + * @since Beta v0.4.5 + * @param {string} gid 游戏分区 ID + * @param {string} keyword 关键词 + * @param {string} last_id 最后一条帖子 ID + * @return {Promise} 返回帖子列表 + */ +async function searchPosts( + gid: string = "2", + keyword: string, + last_id: string, +): Promise { + const url = "https://bbs-api.miyoushe.com/post/wapi/searchPosts"; + const params = { + gids: gid, + keyword, + last_id, + size: "20", + }; + return await http + .fetch(url, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + query: params, + }) + .then((res) => { + return res.data.data; + }); +} + +export default searchPosts; diff --git a/src/plugins/Mys/types/Post.d.ts b/src/plugins/Mys/types/Post.d.ts index b31fe8c7..b0ba953b 100644 --- a/src/plugins/Mys/types/Post.d.ts +++ b/src/plugins/Mys/types/Post.d.ts @@ -1,12 +1,12 @@ /** * @file plugins/Mys/types/post.d.ts * @description Mys 插件帖子类型定义文件 - * @since Beta v0.4.0 + * @since Beta v0.4.5 */ /** * @description Mys 插件帖子类型 - * @since Beta v0.4.0 + * @since Beta v0.4.5 * @namespace TGApp.Plugins.Mys.Post * @memberof TGApp.Plugins.Mys */ @@ -27,7 +27,7 @@ declare namespace TGApp.Plugins.Mys.Post { /** * @description 帖子数据 - * @since Beta v0.4.0 + * @since Beta v0.4.5 * @interface FullData * @property {Post} post 帖子信息 * @property {Forum} forum 所属版块 @@ -73,7 +73,7 @@ declare namespace TGApp.Plugins.Mys.Post { is_block_on: boolean; forum_rank_info: unknown | null; link_card_list: unknown[]; - news_meta: TGApp.Plugins.Mys.News.Meta | null; + news_meta: TGApp.Plugins.Mys.News.Meta | null | undefined; recommend_reason: unknown | null; villa_card: unknown | null; is_mentor: boolean; diff --git a/src/plugins/Mys/types/Search.d.ts b/src/plugins/Mys/types/Search.d.ts new file mode 100644 index 00000000..fd4f890d --- /dev/null +++ b/src/plugins/Mys/types/Search.d.ts @@ -0,0 +1,44 @@ +/** + * @file plugins/Mys/types/Search.d.ts + * @description Mys 插件搜索类型声明 + * @since Beta v0.4.5 + */ + +/** + * @description 搜索帖子返回 + * @since Beta v0.4.5 + * @namespace TGApp.Plugins.Mys.Search + * @memberof TGApp.Plugins.Mys + */ +declare namespace TGApp.Plugins.Mys.Search { + /** + * @description 搜索帖子返回 + * @since Beta v0.4.5 + * @interface PostsResponse + * @extends TGApp.BBS.Response.BaseWithData + * @property {PostsResponseData} data 返回数据 + * @return PostsResponse + */ + interface PostsResponse extends TGApp.BBS.Response.BaseWithData { + data: PostsResponseData; + } + + /** + * @description 搜索帖子返回数据 + * @since Beta v0.4.5 + * @interface PostsResponseData + * @property {TGApp.Plugins.Mys.Post.FullData[]} posts 帖子列表 + * @property {string} last_id 索引 + * @property {boolean} is_last 是否最后一页 + * @property {string[]} token_list token 列表 + * @property {Record} databox 数据盒 + * @return PostsResponseData + */ + interface PostsResponseData { + posts: TGApp.Plugins.Mys.Post.FullData[]; + last_id: string; + is_last: boolean; + token_list: string[]; + databox: Record; + } +}