Skip to content

Commit

Permalink
👽️ 增加 genshinnet 域名处理
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Nov 13, 2024
1 parent eaa0760 commit 857d993
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
5 changes: 4 additions & 1 deletion src-tauri/capabilities/Mys.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,15 @@
},
{
"url": "https://*.mihoyo.com/*"
},
{
"url": "https://*.genshinnet.com/*"
}
]
}
],
"remote": {
"urls": ["https://*.mihoyo.com/*", "https://*.miyoushe.com/*"]
"urls": ["https://*.mihoyo.com/*", "https://*.miyoushe.com/*", "https://*.genshinnet.com/*"]
},
"platforms": ["windows", "macOS"]
}
3 changes: 3 additions & 0 deletions src-tauri/capabilities/SubWindow.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
},
{
"url": "https://*.hoyoverse.com/*"
},
{
"url": "https://*.genshinnet.com/*"
}
]
}
Expand Down
13 changes: 10 additions & 3 deletions src-tauri/gen/schemas/capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
"Mys": {
"identifier": "Mys",
"description": "Capability for the mys client window",
"remote": { "urls": ["https://*.mihoyo.com/*", "https://*.miyoushe.com/*"] },
"remote": {
"urls": ["https://*.mihoyo.com/*", "https://*.miyoushe.com/*", "https://*.genshinnet.com/*"]
},
"local": true,
"windows": ["mhy_client"],
"permissions": [
Expand All @@ -64,7 +66,11 @@
{ "identifier": "fs:allow-write-text-file", "allow": [{ "path": "**" }] },
{
"identifier": "http:default",
"allow": [{ "url": "https://*.miyoushe.com/*" }, { "url": "https://*.mihoyo.com/*" }]
"allow": [
{ "url": "https://*.miyoushe.com/*" },
{ "url": "https://*.mihoyo.com/*" },
{ "url": "https://*.genshinnet.com/*" }
]
}
],
"platforms": ["windows", "macOS"]
Expand Down Expand Up @@ -118,7 +124,8 @@
{ "url": "https://*.mihoyo.com/*" },
{ "url": "https://*.mihoyogift.com/*" },
{ "url": "https://*.bilibili.com/*" },
{ "url": "https://*.hoyoverse.com/*" }
{ "url": "https://*.hoyoverse.com/*" },
{ "url": "https://*.genshinnet.com/*" }
]
}
],
Expand Down
28 changes: 7 additions & 21 deletions src/components/post/tp-text.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,8 @@ function getTextStyle(): StyleValue {
if (data.attributes) {
const ruleBold: StyleValue = "fontFamily: var(--font-title)";
const ruleItalic: StyleValue = "fontStyle: italic";
if (data.attributes.bold) {
style.push(ruleBold);
}
if (data.attributes.italic) {
style.push(ruleItalic);
}
if (data.attributes.bold) style.push(ruleBold);
if (data.attributes.italic) style.push(ruleItalic);
if (data.attributes.color) {
let colorGet = data.attributes.color;
if (isColorSimilar("#000000", data.attributes.color)) {
Expand All @@ -111,11 +107,7 @@ async function toLink() {
const res = await parseLink(link);
if (res === true) return;
if (res === false) {
showSnackbar({
text: `未知链接:${link}`,
color: "error",
timeout: 3000,
});
showSnackbar({ text: `未知链接:${link}`, color: "error", timeout: 3000 });
return;
}
window.open(res);
Expand All @@ -128,23 +120,17 @@ function getEmojiUrl(): string {
getEmojis().then((res) => {
if ("retcode" in res) {
console.error(res);
showSnackbar({
text: "获取表情包失败!",
color: "error",
});
showSnackbar({ text: "获取表情包失败!", color: "error" });
mode.value = "text";
return "";
} else {
localEmojis.value = JSON.stringify(res);
localStorage.setItem("emojis", localEmojis.value);
}
localEmojis.value = JSON.stringify(res);
localStorage.setItem("emojis", localEmojis.value);
});
}
const emojiName = getEmojiName();
const emojiMap: Record<string, string> = JSON.parse(<string>localEmojis.value);
if (!Object.keys(emojiMap).includes(emojiName)) {
mode.value = "text";
}
if (!Object.keys(emojiMap).includes(emojiName)) mode.value = "text";
return JSON.parse(<string>localEmojis.value)[emojiName];
}
Expand Down
5 changes: 3 additions & 2 deletions src/utils/linkParser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file src/utils/linkParser.ts
* @description 处理链接
* @since Beta v0.5.5
* @since Beta v0.6.3
*/

import { emit } from "@tauri-apps/api/event";
Expand Down Expand Up @@ -56,7 +56,7 @@ export async function parsePost(link: string): Promise<false | string> {

/**
* @function parseLink
* @since Beta v0.5.5
* @since Beta v0.6.3
* @description 处理链接
* @param {string} link - 链接
* @param {boolean} useInner - 是否采用内置 JSBridge 打开
Expand Down Expand Up @@ -140,6 +140,7 @@ export async function parseLink(
"webstatic.miyoushe.com",
"bbs.mihoyo.com",
"qaa.miyoushe.com",
"mihoyo.genshinnet.com",
];
if (prefix.includes(url.hostname) && !useInner) {
const openCheck = await showConfirm({
Expand Down

0 comments on commit 857d993

Please sign in to comment.