👽️ 调整公告解析正则

*Refer: https://github.com/UIGF-org/CurrentBannerWatcher
This commit is contained in:
BTMuli
2025-09-09 12:16:51 +08:00
parent 641ae0043f
commit fe5a5011eb
3 changed files with 17 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
//! @file src/client/mod.rs
//! @desc 客户端模块,负责操作米游社客户端
//! @since Beta v0.7.9
//! @since Beta v0.8.0
mod menu;
mod utils;
@@ -8,7 +8,7 @@ mod utils;
use tauri::{AppHandle, Manager, WebviewWindowBuilder};
use tauri_utils::config::WebviewUrl;
static BBS_VERSION: &'static str = "2.90.0";
static BBS_VERSION: &'static str = "2.93.0";
#[tauri::command]
pub async fn create_mhy_client(handle: AppHandle, func: String, url: String) {

View File

@@ -76,21 +76,23 @@ async function refreshAnnoTime(): Promise<void> {
function getAnnoTime(content: string): string | false {
const regexes = [
/〓活动时间〓.*?\d\.\d版本期间持续开放/,
/(?:|).*?(?:(\d\.\d)(?:|)|&lt;t class="t_(?:gl|lc)".*?&gt;(.*?)&lt;\/t&gt; *?)/s,
/(?:||||).*?(\d\.\d).*?~.*?&lt;t class="t_(?:gl|lc)".*?&gt;(.*?)&lt;\/t&gt;/s,
/〓活动时间〓.*?(\d\.\d|「月之[一二三四五六七八九]」)版本期间持续开放/,
/(?:|).*?(?:(\d\.\d|[])(?:|)|&lt;t class="t_(?:gl|lc)".*?&gt;(.*?)&lt;\/t&gt; *?)/s,
/(?:||||).*?(\d\.\d|[]).*?~.*?&lt;t class="t_(?:gl|lc)".*?&gt;(.*?)&lt;\/t&gt;/s,
/(?:(?:|)||).*?&lt;t class="t_(?:gl|lc)".*?&gt;(.*?)&lt;\/t&gt;.*?~.*?&lt;t class="t_(?:gl|lc)".*?&gt;(.*?)&lt;\/t&gt;/s,
// /〓活动时间〓.*?(\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}).*?(\d\.\d版本结束)/
/.*?(\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}).*?(\d\.\d)/s,
/.*?(\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}).*?((\d\.\d|[]))/s,
];
if (content.match(regexes[0])) {
const res = content.match(regexes[0]);
return res?.[0].replace(/.*?(\d\.\d版本期间持续开放)/, "$1") ?? false;
return (
res?.[0].replace(/.*?((\d\.\d|「月之[一二三四五六七八九]」)版本期间持续开放)/, "$1") ?? false
);
}
if (content.match(regexes[1])) {
const res = content.match(regexes[1]);
if (res === null) return false;
const regex2 = /\d\.\d版本更新(?:完成|)后永久开放/;
const regex2 = /(\d\.\d|「月之[一二三四五六七八九]」)版本更新(?:完成|)后永久开放/;
const regex3 = /\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}/;
const res2 = res[0].match(regex2);
if (res2 !== null) return res2[0];
@@ -99,7 +101,7 @@ function getAnnoTime(content: string): string | false {
}
if (content.match(regexes[2])) {
const res = content.match(regexes[2]);
if (res?.[1]?.match(/\d\.\d/)) {
if (res?.[1]?.match(/(\d\.\d|「月之[一二三四五六七八九]」)/)) {
const parser = new DOMParser().parseFromString(decodeRegExp(res[2]), "text/html");
return `${res?.[1]}版本更新后 ~ ${parser.body.innerText}`;
}

View File

@@ -1,7 +1,7 @@
/**
* @file utils/TGBbs.ts
* @description 关于 BBS 的工具函数
* @since Beta v0.7.9
* @since Beta v0.8.0
*/
/**
@@ -10,18 +10,18 @@
*/
export type SaltKey = "K2" | "LK2" | "X4" | "X6" | "PROD";
const BBS_VERSION: Readonly<string> = "2.90.0";
const BBS_VERSION: Readonly<string> = "2.93.0";
const BBS_UA_MOBILE: Readonly<string> = `Mozilla/5.0 (Linux; Android 12) Mobile miHoYoBBS/${BBS_VERSION}`;
const BBS_UA_PC: Readonly<string> = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/${BBS_VERSION}`;
/**
* @description salt 值
* @version 2.90.0
* @since Beta v0.7.9
* @version 2.93.0
* @since Beta v0.8.0
*/
const BBS_SALT: Readonly<Record<SaltKey, string>> = {
K2: "LKsbRciURVKljyjuhSeobiyFngbAyjAh",
LK2: "dDIQHbKOdaPaLuvQKVzUzqdeCaxjtaPV",
K2: "idMMaGYmVgPzh3wxmWudUXKUPGidO7GM",
LK2: "G1ktdwFL4IyGkHuuWSmz0wUe9Db9scyK",
X4: "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
X6: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
PROD: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",