mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
💄 处理转义
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
/**
|
||||
* @file web/utils/annoParser.ts
|
||||
* @description 解析游戏内公告数据
|
||||
* @since Beta v0.6.0
|
||||
* @since Beta v0.6.7
|
||||
*/
|
||||
|
||||
import TpText from "@comp/viewPost/tp-text.vue";
|
||||
import { h, render } from "vue";
|
||||
|
||||
import { decodeRegExp } from "./tools.js";
|
||||
import { decodeRegExp } from "@/utils/toolFunc.js";
|
||||
|
||||
/**
|
||||
* @description 预处理p
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* @file web/utils/tools.ts
|
||||
* @description 应用用到的工具函数
|
||||
* @since Beta v0.6.3
|
||||
*/
|
||||
|
||||
import TGConstant from "@/web/constant/TGConstant.js";
|
||||
|
||||
/**
|
||||
* @description 转义正则表达式
|
||||
* @since Beta v0.3.3
|
||||
* @param {string} data 内容
|
||||
* @returns {string} 转义后的内容
|
||||
*/
|
||||
export function decodeRegExp(data: string): string {
|
||||
let res = data;
|
||||
if (res.length === 0) return res;
|
||||
res = res.replace(/</g, "<");
|
||||
res = res.replace(/>/g, ">");
|
||||
res = res.replace(/ /g, " ");
|
||||
res = res.replace(/'/g, "'");
|
||||
|
||||
res = res.replace(/"/g, `"`);
|
||||
res = res.replace(/'/g, "'");
|
||||
res = res.replace(/&/g, "&");
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据 gid 获取游戏名称
|
||||
* @param {number} gid
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getGameName(gid: number): string {
|
||||
const game = TGConstant.BBS.CHANNELS.find((item) => item.gid === gid.toString());
|
||||
return game ? game.title : "未知游戏";
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取游戏id
|
||||
* @param {string} mini
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getGameId(mini: string): string {
|
||||
const game = TGConstant.BBS.CHANNELS.find((item) => item.mini === mini);
|
||||
return game ? game.gid : "0";
|
||||
}
|
||||
Reference in New Issue
Block a user