diff --git a/src/components/t-sidebar.vue b/src/components/t-sidebar.vue
index 8644c367..55ea7e9c 100644
--- a/src/components/t-sidebar.vue
+++ b/src/components/t-sidebar.vue
@@ -20,11 +20,57 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -33,13 +79,13 @@
-
+
mdi-database
-
+
@@ -57,25 +103,27 @@
diff --git a/src/plugins/Mys/request/news.ts b/src/plugins/Mys/request/news.ts
index 3c61ec9e..6ddb8b1d 100644
--- a/src/plugins/Mys/request/news.ts
+++ b/src/plugins/Mys/request/news.ts
@@ -2,7 +2,7 @@
* @file plugins Mys request news.ts
* @description Mys 插件咨讯请求
* @author BTMuli
- * @since Alpha v0.1.1
+ * @since Alpha v0.1.2
*/
import { http } from "@tauri-apps/api";
@@ -10,7 +10,7 @@ import { NewsData, NewsResponse } from "../interface/news";
// 咨讯 API
const NEWS_LIST_API =
- "https://bbs-api.mihoyo.com/post/wapi/getNewsList?gids=2&page_size={page_size}&type={news_type}&last_id={last_id}";
+ "https://bbs-api.mihoyo.com/post/wapi/getNewsList?gids={gid}&page_size={page_size}&type={news_type}&last_id={last_id}";
/**
* @description 咨讯类型
@@ -29,16 +29,19 @@ enum NewsType {
/**
* @description 获取 Notice 列表
- * @since Alpha v0.1.1
+ * @since Alpha v0.1.2
+ * @param {string} gid gid: 1 为崩坏3, 2 为原神,3 为崩坏2,4 为未定事件簿,5 为大别野,6 为崩坏:星穹铁道,8 为绝区零
* @param {number} page_size 返回数量
* @param {number} last_id 上一次请求的最后一条数据的 id
* @return {Promise}
*/
export async function getNoticeList(
+ gid: string = "2",
page_size: number = 20,
last_id: number = 0
): Promise {
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
+ .replace("{gid}", gid)
.replace("{news_type}", NewsType.NOTICE)
.replace("{last_id}", last_id.toString());
return await http.fetch(url).then(res => res.data.data);
@@ -46,16 +49,19 @@ export async function getNoticeList(
/**
* @description 获取 Activity 列表
- * @since Alpha v0.1.1
+ * @since Alpha v0.1.2
+ * @param {string} gid gid: 1 为崩坏3, 2 为原神,3 为崩坏2,4 为未定事件簿,5 为大别野,6 为崩坏:星穹铁道,8 为绝区零
* @param {number} page_size 返回数量
* @param {number} last_id 上一次请求的最后一条数据的 id
* @return {Promise}
*/
export async function getActivityList(
+ gid: string = "2",
page_size: number = 20,
last_id: number = 0
): Promise {
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
+ .replace("{gid}", gid)
.replace("{news_type}", NewsType.ACTIVITY)
.replace("{last_id}", last_id.toString());
return await http.fetch(url).then(res => res.data.data);
@@ -63,13 +69,19 @@ export async function getActivityList(
/**
* @description 获取 News 列表
- * @since Alpha v0.1.1
+ * @since Alpha v0.1.2
+ * @param {string} gid gid: 1 为崩坏3, 2 为原神,3 为崩坏2,4 为未定事件簿,5 为大别野,6 为崩坏:星穹铁道,8 为绝区零
* @param {number} page_size 返回数量
* @param {number} last_id 上一次请求的最后一条数据的 id
* @return {Promise}
*/
-export async function getNewsList(page_size: number = 20, last_id: number = 0): Promise {
+export async function getNewsList(
+ gid: string = "2",
+ page_size: number = 20,
+ last_id: number = 0
+): Promise {
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
+ .replace("{gid}", gid)
.replace("{news_type}", NewsType.NEWS)
.replace("{last_id}", last_id.toString());
return await http.fetch(url).then(res => res.data.data);
diff --git a/src/plugins/Mys/request/post.ts b/src/plugins/Mys/request/post.ts
index 5a375501..ec1646c6 100644
--- a/src/plugins/Mys/request/post.ts
+++ b/src/plugins/Mys/request/post.ts
@@ -2,19 +2,19 @@
* @file plugins Mys request post.ts
* @description Mys帖子请求
* @author BTMuli
- * @since Alpha
+ * @since Alpha v0.1.2
*/
import { http } from "@tauri-apps/api";
import { PostResponse, PostData } from "../interface/post";
// 帖子 API
-const POST_API = "https://bbs-api.mihoyo.com/post/wapi/getPostFull?gids=2&post_id={post_id}";
-const POST_REFERER = "https://bbs.mihoyo.com/ys/article/{post_id}";
+const POST_API = "https://bbs-api.mihoyo.com/post/wapi/getPostFull?post_id={post_id}";
+const POST_REFERER = "https://bbs.mihoyo.com/";
/**
* @description 获取帖子信息
- * @since Alpha
+ * @since Alpha v0.1.2
* @param {number} post_id 帖子 ID
* @return {Promise}
*/
@@ -24,7 +24,7 @@ export async function getPostData(post_id: number): Promise {
method: "GET",
headers: {
"Content-Type": "application/json",
- Referer: POST_REFERER.replace("{post_id}", post_id.toString()),
+ Referer: POST_REFERER,
},
})
.then(res => {
diff --git a/src/plugins/Mys/utils/parser.ts b/src/plugins/Mys/utils/parser.ts
index 1fa64431..03b1e86a 100644
--- a/src/plugins/Mys/utils/parser.ts
+++ b/src/plugins/Mys/utils/parser.ts
@@ -2,21 +2,20 @@
* @file plugins Mys utils PostParser.ts
* @description 用于解析Mys数据的工具
* @author BTMuli
- * @since Alpha v0.1.1
+ * @since Alpha v0.1.2
*/
import { PostContent, PostData, PostStructuredContent } from "../interface/post";
/**
* @description 检测链接是否是米游社帖子
- * @since Alpha v0.1.1
+ * @since Alpha v0.1.2
* @param {string} url 链接
* @returns {boolean} 是否是米游社帖子
*/
export function IsMysPost(url: string): boolean {
- return (
- url.startsWith("https://bbs.mihoyo.com/ys/article/") ||
- url.startsWith("https://www.miyoushe.com/ys/article/")
- );
+ const regBBS = /^https:\/\/bbs\.mihoyo\.com\/\w+\/article\/\d+$/;
+ const regMYS = /^https:\/\/www\.miyoushe\.com\/\w+\/article\/\d+$/;
+ return regBBS.test(url) || regMYS.test(url);
}
/**
@@ -58,7 +57,7 @@ export function contentParser(content: string): string {
/**
* @description 解析Mys数据
- * @since Alpha v0.1.1
+ * @since Alpha v0.1.2
* @param {PostData} post Mys数据
* @description 为了安全考虑,不会解析所有的属性,只会解析几个常用的属性
* @returns {string} 解析后的HTML,可作为 v-html 使用
@@ -69,17 +68,16 @@ export function PostParser(post: PostData): string {
if (postContent.startsWith("<")) {
parserData = post.post.structured_content;
} else {
- parserData = contentParser(postContent);
+ try {
+ parserData = contentParser(post.post.content);
+ } catch (error) {
+ parserData = post.post.structured_content;
+ }
}
- // Json 化
let jsonData: PostStructuredContent[] = JSON.parse(parserData);
- // 创建 div
const doc = document.createElement("div");
- // 遍历 Json 数据
jsonData.forEach((item: any) => {
- // 解析
const parsed = ParserTransfer(item);
- // 插入
doc.appendChild(parsed);
});
return doc.innerHTML;
diff --git a/src/router/modules/main.ts b/src/router/modules/main.ts
index f98816de..17a260c8 100644
--- a/src/router/modules/main.ts
+++ b/src/router/modules/main.ts
@@ -2,13 +2,12 @@
* @file router modules main.ts
* @description 主路由模块
* @author BTMuli
- * @since Alpha v0.1.1
+ * @since Alpha v0.1.2
*/
// 信息展示
import Announcements from "../../pages/Announcements.vue";
import Home from "../../pages/Home.vue";
-import News from "../../pages/News.vue";
import GCG from "../../pages/GCG.vue";
// 数据交互
import Achievements from "../../pages/Achievements.vue";
@@ -45,11 +44,6 @@ const mainRoutes = [
path: "/home",
redirect: "/",
},
- {
- path: "/news",
- name: "咨讯",
- component: News,
- },
];
export default mainRoutes;
diff --git a/src/router/modules/sub.ts b/src/router/modules/sub.ts
index 9b67aa50..7ef232c3 100644
--- a/src/router/modules/sub.ts
+++ b/src/router/modules/sub.ts
@@ -2,18 +2,35 @@
* @file router modules sub.ts
* @description 子路由模块,用于二级窗口
* @author BTMuli
- * @since Alpha v0.1.1
+ * @since Alpha v0.1.2
*/
+// 游戏内公告
+import TAnno from "../../views/t-anno.vue";
+import TAnnoJson from "../../views/t-anno-json.vue";
+// 咨讯
+import TNews from "../../views/t-news.vue";
// 帖子相关
import TPost from "../../views/t-post.vue";
import TPostJson from "../../views/t-post-json.vue";
// 抽奖
import TLottery from "../../views/t-lottery.vue";
-// 游戏内公告
-import TAnno from "../../views/t-anno.vue";
-import TAnnoJson from "../../views/t-anno-json.vue";
const subRoutes = [
+ {
+ path: "/anno_detail/:anno_id",
+ name: "游戏内公告",
+ component: TAnno,
+ },
+ {
+ path: "/anno_detail_json/:anno_id",
+ name: "游戏内公告(JSON)",
+ component: TAnnoJson,
+ },
+ {
+ path: "/news/:gid",
+ name: "咨讯",
+ component: TNews,
+ },
{
path: "/post_detail/:post_id",
name: "帖子详情",
@@ -29,16 +46,6 @@ const subRoutes = [
name: "抽奖详情",
component: TLottery,
},
- {
- path: "/anno_detail/:anno_id",
- name: "游戏内公告",
- component: TAnno,
- },
- {
- path: "/anno_detail_json/:anno_id",
- name: "游戏内公告(JSON)",
- component: TAnnoJson,
- },
];
export default subRoutes;
diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts
index 1eb78357..bf8c1b8f 100644
--- a/src/store/modules/app.ts
+++ b/src/store/modules/app.ts
@@ -27,6 +27,9 @@ const useAppStore = defineStore({
collapse: true,
// 是否显示
submenu: {
+ // 米游社
+ mihoyo: false,
+ // 数据库
database: false,
},
},
@@ -57,13 +60,16 @@ const useAppStore = defineStore({
this.sidebar = {
collapse: true,
submenu: {
+ mihoyo: false,
database: false,
},
};
} else {
if (this.sidebar.collapse === undefined) this.sidebar.collapse = false;
- if (this.sidebar.submenu === undefined) this.sidebar.submenu = { database: false };
+ if (this.sidebar.submenu === undefined)
+ this.sidebar.submenu = { database: false, mihoyo: false };
if (this.sidebar.submenu.database === undefined) this.sidebar.submenu.database = false;
+ if (this.sidebar.submenu.mihoyo === undefined) this.sidebar.submenu.mihoyo = false;
}
},
// 初始化配置
@@ -72,6 +78,7 @@ const useAppStore = defineStore({
this.sidebar = {
collapse: false,
submenu: {
+ mihoyo: false,
database: false,
},
};
@@ -88,6 +95,7 @@ const useAppStore = defineStore({
getSubmenu() {
let open = [];
if (this.sidebar.submenu.database) open.push("database");
+ if (this.sidebar.submenu.mihoyo) open.push("mihoyo");
return open;
},
},
diff --git a/src/pages/News.vue b/src/views/t-news.vue
similarity index 82%
rename from src/pages/News.vue
rename to src/views/t-news.vue
index 03d9085e..98b85eaa 100644
--- a/src/pages/News.vue
+++ b/src/views/t-news.vue
@@ -6,9 +6,9 @@
-
+
-
+
mdi-bullhorn
@@ -100,7 +100,7 @@
-
+