mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-06 08:32:51 +08:00
🐛 修复一些bug
*修复窗口`destory`失败 *修复`miyoushe`域名不识别 *修复子窗口权限报错
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
"core:window:allow-destroy",
|
||||
"core:window:allow-set-size",
|
||||
"core:window:allow-set-title",
|
||||
"core:window:allow-set-focus",
|
||||
"core:window:allow-set-fullscreen",
|
||||
"core:window:allow-show",
|
||||
"core:window:default",
|
||||
|
||||
@@ -701,6 +701,7 @@
|
||||
"identifier": "default",
|
||||
"description": "Default permissions for the plugin.",
|
||||
"permissions": [
|
||||
"allow-get-all-webviews",
|
||||
"allow-webview-position",
|
||||
"allow-webview-size",
|
||||
"allow-internal-toggle-devtools"
|
||||
@@ -717,6 +718,11 @@
|
||||
"description": "Enables the create_webview_window command without any pre-configured scope.",
|
||||
"commands": { "allow": ["create_webview_window"], "deny": [] }
|
||||
},
|
||||
"allow-get-all-webviews": {
|
||||
"identifier": "allow-get-all-webviews",
|
||||
"description": "Enables the get_all_webviews command without any pre-configured scope.",
|
||||
"commands": { "allow": ["get_all_webviews"], "deny": [] }
|
||||
},
|
||||
"allow-internal-toggle-devtools": {
|
||||
"identifier": "allow-internal-toggle-devtools",
|
||||
"description": "Enables the internal_toggle_devtools command without any pre-configured scope.",
|
||||
@@ -777,6 +783,11 @@
|
||||
"description": "Denies the create_webview_window command without any pre-configured scope.",
|
||||
"commands": { "allow": [], "deny": ["create_webview_window"] }
|
||||
},
|
||||
"deny-get-all-webviews": {
|
||||
"identifier": "deny-get-all-webviews",
|
||||
"description": "Denies the get_all_webviews command without any pre-configured scope.",
|
||||
"commands": { "allow": [], "deny": ["get_all_webviews"] }
|
||||
},
|
||||
"deny-internal-toggle-devtools": {
|
||||
"identifier": "deny-internal-toggle-devtools",
|
||||
"description": "Denies the internal_toggle_devtools command without any pre-configured scope.",
|
||||
@@ -836,6 +847,7 @@
|
||||
"identifier": "default",
|
||||
"description": "Default permissions for the plugin.",
|
||||
"permissions": [
|
||||
"allow-get-all-windows",
|
||||
"allow-scale-factor",
|
||||
"allow-inner-position",
|
||||
"allow-outer-position",
|
||||
@@ -897,6 +909,11 @@
|
||||
"description": "Enables the destroy command without any pre-configured scope.",
|
||||
"commands": { "allow": ["destroy"], "deny": [] }
|
||||
},
|
||||
"allow-get-all-windows": {
|
||||
"identifier": "allow-get-all-windows",
|
||||
"description": "Enables the get_all_windows command without any pre-configured scope.",
|
||||
"commands": { "allow": ["get_all_windows"], "deny": [] }
|
||||
},
|
||||
"allow-hide": {
|
||||
"identifier": "allow-hide",
|
||||
"description": "Enables the hide command without any pre-configured scope.",
|
||||
@@ -1222,6 +1239,11 @@
|
||||
"description": "Denies the destroy command without any pre-configured scope.",
|
||||
"commands": { "allow": [], "deny": ["destroy"] }
|
||||
},
|
||||
"deny-get-all-windows": {
|
||||
"identifier": "deny-get-all-windows",
|
||||
"description": "Denies the get_all_windows command without any pre-configured scope.",
|
||||
"commands": { "allow": [], "deny": ["get_all_windows"] }
|
||||
},
|
||||
"deny-hide": {
|
||||
"identifier": "deny-hide",
|
||||
"description": "Denies the hide command without any pre-configured scope.",
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
"core:window:allow-destroy",
|
||||
"core:window:allow-set-size",
|
||||
"core:window:allow-set-title",
|
||||
"core:window:allow-set-focus",
|
||||
"core:window:allow-set-fullscreen",
|
||||
"core:window:allow-show",
|
||||
"core:window:default",
|
||||
|
||||
@@ -2458,6 +2458,11 @@
|
||||
"type": "string",
|
||||
"enum": ["core:webview:allow-create-webview-window"]
|
||||
},
|
||||
{
|
||||
"description": "core:webview:allow-get-all-webviews -> Enables the get_all_webviews command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["core:webview:allow-get-all-webviews"]
|
||||
},
|
||||
{
|
||||
"description": "core:webview:allow-internal-toggle-devtools -> Enables the internal_toggle_devtools command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2518,6 +2523,11 @@
|
||||
"type": "string",
|
||||
"enum": ["core:webview:deny-create-webview-window"]
|
||||
},
|
||||
{
|
||||
"description": "core:webview:deny-get-all-webviews -> Denies the get_all_webviews command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["core:webview:deny-get-all-webviews"]
|
||||
},
|
||||
{
|
||||
"description": "core:webview:deny-internal-toggle-devtools -> Denies the internal_toggle_devtools command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2608,6 +2618,11 @@
|
||||
"type": "string",
|
||||
"enum": ["core:window:allow-destroy"]
|
||||
},
|
||||
{
|
||||
"description": "core:window:allow-get-all-windows -> Enables the get_all_windows command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["core:window:allow-get-all-windows"]
|
||||
},
|
||||
{
|
||||
"description": "core:window:allow-hide -> Enables the hide command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2933,6 +2948,11 @@
|
||||
"type": "string",
|
||||
"enum": ["core:window:deny-destroy"]
|
||||
},
|
||||
{
|
||||
"description": "core:window:deny-get-all-windows -> Denies the get_all_windows command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["core:window:deny-get-all-windows"]
|
||||
},
|
||||
{
|
||||
"description": "core:window:deny-hide -> Denies the hide command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
|
||||
@@ -2458,6 +2458,11 @@
|
||||
"type": "string",
|
||||
"enum": ["core:webview:allow-create-webview-window"]
|
||||
},
|
||||
{
|
||||
"description": "core:webview:allow-get-all-webviews -> Enables the get_all_webviews command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["core:webview:allow-get-all-webviews"]
|
||||
},
|
||||
{
|
||||
"description": "core:webview:allow-internal-toggle-devtools -> Enables the internal_toggle_devtools command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2518,6 +2523,11 @@
|
||||
"type": "string",
|
||||
"enum": ["core:webview:deny-create-webview-window"]
|
||||
},
|
||||
{
|
||||
"description": "core:webview:deny-get-all-webviews -> Denies the get_all_webviews command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["core:webview:deny-get-all-webviews"]
|
||||
},
|
||||
{
|
||||
"description": "core:webview:deny-internal-toggle-devtools -> Denies the internal_toggle_devtools command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2608,6 +2618,11 @@
|
||||
"type": "string",
|
||||
"enum": ["core:window:allow-destroy"]
|
||||
},
|
||||
{
|
||||
"description": "core:window:allow-get-all-windows -> Enables the get_all_windows command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["core:window:allow-get-all-windows"]
|
||||
},
|
||||
{
|
||||
"description": "core:window:allow-hide -> Enables the hide command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
@@ -2933,6 +2948,11 @@
|
||||
"type": "string",
|
||||
"enum": ["core:window:deny-destroy"]
|
||||
},
|
||||
{
|
||||
"description": "core:window:deny-get-all-windows -> Denies the get_all_windows command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": ["core:window:deny-get-all-windows"]
|
||||
},
|
||||
{
|
||||
"description": "core:window:deny-hide -> Denies the hide command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
|
||||
@@ -124,7 +124,6 @@ function onAvatarClick(avatar: TGApp.Sqlite.Character.UserRole): void {
|
||||
|
||||
.tdo-avatar {
|
||||
cursor: pointer;
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
|
||||
.tdo-card-container {
|
||||
|
||||
@@ -67,14 +67,16 @@
|
||||
<img src="/source/UI/empty.webp" alt="empty" />
|
||||
</div>
|
||||
</div>
|
||||
<TuaDetailOverlay
|
||||
v-model="showOverlay"
|
||||
:avatar="dataVal"
|
||||
:avatars="selectedList"
|
||||
v-model:mode="showMode"
|
||||
@to-next="handleSwitch"
|
||||
@to-avatar="selectRole"
|
||||
/>
|
||||
<suspense>
|
||||
<TuaDetailOverlay
|
||||
v-model="showOverlay"
|
||||
:avatar="dataVal"
|
||||
:avatars="selectedList"
|
||||
v-model:mode="showMode"
|
||||
@to-next="handleSwitch"
|
||||
@to-avatar="selectRole"
|
||||
/>
|
||||
</suspense>
|
||||
<TwoSelectC v-model="showSelect" @select-c="handleSelect" v-model:reset="resetSelect" />
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
@@ -310,7 +312,9 @@ function getUpdateTime(): string {
|
||||
function selectRole(role: TGApp.Sqlite.Character.UserRole): void {
|
||||
dataVal.value = role;
|
||||
selectIndex.value = roleList.value.indexOf(role);
|
||||
if (!showOverlay.value) showOverlay.value = true;
|
||||
if (!showOverlay.value) {
|
||||
showOverlay.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
function handleSelect(val: SelectedCValue) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file utils/TGClient.ts
|
||||
* @desc 负责米游社客户端的 callback 处理
|
||||
* @since Beta v0.5.1
|
||||
* @since Beta v0.5.5
|
||||
*/
|
||||
|
||||
import { event, core, webviewWindow } from "@tauri-apps/api";
|
||||
@@ -436,7 +436,7 @@ class TGClient {
|
||||
|
||||
/**
|
||||
* @func open
|
||||
* @since Beta v0.5.0
|
||||
* @since Beta v0.5.5
|
||||
* @desc 打开米游社客户端
|
||||
* @param {string} func - 方法名
|
||||
* @param {string} url - url
|
||||
@@ -446,7 +446,7 @@ class TGClient {
|
||||
if (url === undefined) url = this.getUrl(func);
|
||||
this.route = [url];
|
||||
await TGLogger.Info(`[TGClient][open][${func}] ${url}`);
|
||||
const windowFind = webviewWindow.WebviewWindow.getByLabel("mhy_client");
|
||||
const windowFind = await webviewWindow.WebviewWindow.getByLabel("mhy_client");
|
||||
if (windowFind !== null) {
|
||||
try {
|
||||
await windowFind.destroy();
|
||||
@@ -455,6 +455,7 @@ class TGClient {
|
||||
text: `[TGClient][open] ${e}`,
|
||||
color: "error",
|
||||
});
|
||||
await TGLogger.Error(`[TGClient][open] ${e}`);
|
||||
}
|
||||
}
|
||||
await core.invoke<InvokeArg>("create_mhy_client", { func, url });
|
||||
@@ -472,7 +473,10 @@ class TGClient {
|
||||
async closePage(arg: TGApp.Plugins.JSBridge.NullArg): Promise<void> {
|
||||
this.route.pop();
|
||||
if (this.route.length === 0) {
|
||||
await webviewWindow.WebviewWindow.getByLabel("mhy_client")?.destroy();
|
||||
const windowFind = await webviewWindow.WebviewWindow.getByLabel("mhy_client");
|
||||
if (windowFind != null) {
|
||||
await windowFind.destroy();
|
||||
}
|
||||
return;
|
||||
}
|
||||
const url = this.route[this.route.length - 1];
|
||||
@@ -578,7 +582,7 @@ class TGClient {
|
||||
|
||||
/**
|
||||
* @func getCookieToken
|
||||
* @since Beta v0.5.0
|
||||
* @since Beta v0.5.5
|
||||
* @desc 获取米游社客户端的 cookie_token
|
||||
* @param {TGApp.Plugins.JSBridge.Arg<TGApp.Plugins.JSBridge.GetCookieTokenPayload>} arg - 请求参数
|
||||
* @returns {void} - 无返回值
|
||||
@@ -598,14 +602,20 @@ class TGClient {
|
||||
}
|
||||
// todo 优化代码
|
||||
const executeJS = `javascript:(function(){
|
||||
document.cookie = "account_id_v2=${user.cookie.account_id};domain=.mihoyo.com;path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "cookie_token=${user.cookie.cookie_token};domain=.mihoyo.com;path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "ltuid_v2=${user.cookie.ltuid};domain=.mihoyo.com;path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "ltoken=${user.cookie.ltoken};domain=.mihoyo.com;path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "account_id=${user.cookie.account_id};domain=.mihoyo.com;path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "account_mid_v2=${user.cookie.mid};domain=.mihoyo.com;path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "ltuid_v2=${user.cookie.ltuid};domain=.mihoyo.com;path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "ltmid_v2=${user.cookie.mid};domain=.mihoyo.com;path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
let domainCur = window.location.hostname;
|
||||
if(domainCur.endsWith('.miyoushe.com')) {
|
||||
domainCur = '.miyoushe.com';
|
||||
} else {
|
||||
domainCur = '.mihoyo.com';
|
||||
}
|
||||
document.cookie = "account_id_v2=${user.cookie.account_id};domain=" + domainCur + ";path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "cookie_token=${user.cookie.cookie_token};domain=" + domainCur + ";path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "ltuid_v2=${user.cookie.ltuid};domain=" + domainCur + ";path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "ltoken=${user.cookie.ltoken};domain=" + domainCur + ";path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "account_id=${user.cookie.account_id};domain=" + domainCur + ";path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "account_mid_v2=${user.cookie.mid};domain=" + domainCur + ";path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "ltuid_v2=${user.cookie.ltuid};domain=" + domainCur + ";path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
document.cookie = "ltmid_v2=${user.cookie.mid};domain=" + domainCur + ";path=/;expires=Fri, 31 Dec 9999 23:59:59 GMT;";
|
||||
})();`;
|
||||
console.info(`[getCookieToken] ${executeJS}`);
|
||||
await core.invoke("execute_js", { label: "mhy_client", js: executeJS });
|
||||
@@ -720,7 +730,7 @@ class TGClient {
|
||||
|
||||
/**
|
||||
* @func openApplication
|
||||
* @since Beta v0.5.0
|
||||
* @since Beta v0.5.5
|
||||
* @desc 打开应用
|
||||
* @param {TGApp.Plugins.JSBridge.Arg<TGApp.Plugins.JSBridge.OpenApplicationPayload>} arg - 方法参数
|
||||
* @returns {void} - 无返回值
|
||||
@@ -729,7 +739,7 @@ class TGClient {
|
||||
arg: TGApp.Plugins.JSBridge.Arg<TGApp.Plugins.JSBridge.OpenApplicationPayload>,
|
||||
): Promise<void> {
|
||||
console.log(`[openApplication] ${JSON.stringify(arg.payload)}`);
|
||||
const appWindow = webviewWindow.WebviewWindow.getByLabel("TeyvatGuide");
|
||||
const appWindow = await webviewWindow.WebviewWindow.getByLabel("TeyvatGuide");
|
||||
await appWindow?.setFocus();
|
||||
showSnackbar({
|
||||
text: `不支持的操作:OpenApplication(${JSON.stringify(arg.payload)})`,
|
||||
@@ -740,7 +750,7 @@ class TGClient {
|
||||
resolve();
|
||||
}, 1500);
|
||||
});
|
||||
const windowFind = webviewWindow.WebviewWindow.getByLabel("mhy_client");
|
||||
const windowFind = await webviewWindow.WebviewWindow.getByLabel("mhy_client");
|
||||
if (windowFind !== null) {
|
||||
await windowFind.setFocus();
|
||||
}
|
||||
@@ -748,7 +758,7 @@ class TGClient {
|
||||
|
||||
/**
|
||||
* @func pushPage
|
||||
* @since Beta v0.5.0
|
||||
* @since Beta v0.5.5
|
||||
* @desc 打开米游社客户端的页面
|
||||
* @param {TGApp.Plugins.JSBridge.Arg<TGApp.Plugins.JSBridge.PushPagePayload>} arg - 方法参数
|
||||
* @returns {Promise<void>} - 无返回值
|
||||
@@ -758,8 +768,10 @@ class TGClient {
|
||||
): Promise<void> {
|
||||
const res = await parseLink(arg.payload.page, true);
|
||||
if (!res) {
|
||||
const appWindow = webviewWindow.WebviewWindow.getByLabel("TeyvatGuide");
|
||||
await appWindow?.setFocus();
|
||||
const appWindow = await webviewWindow.WebviewWindow.getByLabel("TeyvatGuide");
|
||||
if (appWindow != null) {
|
||||
await appWindow.setFocus();
|
||||
}
|
||||
showSnackbar({
|
||||
text: `未知链接:${arg.payload.page}`,
|
||||
color: "error",
|
||||
@@ -770,7 +782,7 @@ class TGClient {
|
||||
resolve();
|
||||
}, 3000);
|
||||
});
|
||||
const windowFind = webviewWindow.WebviewWindow.getByLabel("mhy_client");
|
||||
const windowFind = await webviewWindow.WebviewWindow.getByLabel("mhy_client");
|
||||
if (windowFind !== null) {
|
||||
await windowFind.setFocus();
|
||||
}
|
||||
@@ -786,7 +798,7 @@ class TGClient {
|
||||
await this.loadJSBridge();
|
||||
await this.hideSideBar();
|
||||
await this.hideOverlay();
|
||||
const windowFind = webviewWindow.WebviewWindow.getByLabel("mhy_client");
|
||||
const windowFind = await webviewWindow.WebviewWindow.getByLabel("mhy_client");
|
||||
if (windowFind !== null) {
|
||||
await windowFind.show();
|
||||
await windowFind.setFocus();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file src/utils/linkParser.ts
|
||||
* @description 处理链接
|
||||
* @since Beta v0.5.1
|
||||
* @since Beta v0.5.5
|
||||
*/
|
||||
|
||||
import { emit } from "@tauri-apps/api/event";
|
||||
@@ -52,7 +52,7 @@ export async function parsePost(link: string): Promise<false | string> {
|
||||
|
||||
/**
|
||||
* @function parseLink
|
||||
* @since Beta v0.5.1
|
||||
* @since Beta v0.5.5
|
||||
* @description 处理链接
|
||||
* @param {string} link - 链接
|
||||
* @param {boolean} useInner - 是否采用内置 JSBridge 打开
|
||||
@@ -133,6 +133,7 @@ export async function parseLink(
|
||||
"act.mihoyo.com",
|
||||
"mhyurl.cn",
|
||||
"webstatic.mihoyo.com",
|
||||
"webstatic.miyoushe.com",
|
||||
"bbs.mihoyo.com",
|
||||
"qaa.miyoushe.com",
|
||||
];
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { webviewWindow } from "@tauri-apps/api";
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import JsonViewer from "vue-json-viewer";
|
||||
import { useRoute } from "vue-router";
|
||||
@@ -17,6 +16,7 @@ import { useRoute } from "vue-router";
|
||||
import TSwitchTheme from "../components/app/t-switchTheme.vue";
|
||||
import ToLoading from "../components/overlay/to-loading.vue";
|
||||
import Mys from "../plugins/Mys/index.js";
|
||||
import TGLogger from "../utils/TGLogger.js";
|
||||
|
||||
// loading
|
||||
const loading = ref<boolean>(true);
|
||||
@@ -41,16 +41,19 @@ onMounted(async () => {
|
||||
} catch (e) {
|
||||
loadingTitle.value = "获取数据失败";
|
||||
loadingEmpty.value = true;
|
||||
await TGLogger.Error(`[${postId}]获取帖子数据失败:${e}`);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
parseData = JSON.parse(jsonData.post.content);
|
||||
} catch (e) {
|
||||
} catch (err) {
|
||||
try {
|
||||
parseData = JSON.parse(jsonData.post.structured_content);
|
||||
} catch (e) {
|
||||
isEmpty.value = true;
|
||||
await TGLogger.Error(`[${postId}]解析帖子数据失败:${e}`);
|
||||
}
|
||||
console.warn(`[${postId}]解析帖子数据失败:${err}`);
|
||||
}
|
||||
loading.value = false;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user