mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🔥 部分跳转改为新建窗口
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
//! @file src/client/menu.rs
|
//! @file src/client/menu.rs
|
||||||
//! @desc 客户端菜单模块,负责操作米游社客户端菜单
|
//! @desc 客户端菜单模块,负责操作米游社客户端菜单
|
||||||
//! @since Beta v0.4.3
|
//! @since Beta v0.4.5
|
||||||
|
|
||||||
use tauri::{AppHandle, CustomMenuItem, LogicalSize, Manager, Menu, Size, Submenu, WindowUrl};
|
use tauri::{AppHandle, CustomMenuItem, LogicalSize, Manager, Menu, Size, Submenu, WindowUrl};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
@@ -27,8 +27,8 @@ fn create_utils_menu() -> Menu {
|
|||||||
let retry_bridge = CustomMenuItem::new("retry".to_string(), "重试桥接");
|
let retry_bridge = CustomMenuItem::new("retry".to_string(), "重试桥接");
|
||||||
let mock_touch = CustomMenuItem::new("mock_touch".to_string(), "模拟触摸");
|
let mock_touch = CustomMenuItem::new("mock_touch".to_string(), "模拟触摸");
|
||||||
let remove_overlay = CustomMenuItem::new("remove_overlay".to_string(), "移除遮罩");
|
let remove_overlay = CustomMenuItem::new("remove_overlay".to_string(), "移除遮罩");
|
||||||
// 旋转窗口/切换横屏或者竖屏
|
|
||||||
let rotate_window = CustomMenuItem::new("rotate_window".to_string(), "旋转窗口");
|
let rotate_window = CustomMenuItem::new("rotate_window".to_string(), "旋转窗口");
|
||||||
|
let switch_ua = CustomMenuItem::new("switch_ua".to_string(), "切换 UA");
|
||||||
return Menu::new()
|
return Menu::new()
|
||||||
.add_item(retry_bridge)
|
.add_item(retry_bridge)
|
||||||
.add_item(mock_touch)
|
.add_item(mock_touch)
|
||||||
@@ -65,6 +65,7 @@ pub fn handle_menu_event(app_handle: AppHandle, event: tauri::MenuEvent) {
|
|||||||
"mock_touch" => handle_menu_mock_touch(app_handle),
|
"mock_touch" => handle_menu_mock_touch(app_handle),
|
||||||
"remove_overlay" => handle_menu_remove_overlay(app_handle),
|
"remove_overlay" => handle_menu_remove_overlay(app_handle),
|
||||||
"rotate_window" => handle_menu_rotate_window(app_handle),
|
"rotate_window" => handle_menu_rotate_window(app_handle),
|
||||||
|
"switch_ua" => handle_menu_switch_ua(app_handle),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,3 +211,23 @@ fn handle_menu_rotate_window(app_handle: AppHandle) {
|
|||||||
window.center().unwrap();
|
window.center().unwrap();
|
||||||
window.set_focus().unwrap();
|
window.set_focus().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理切换 UA 菜单
|
||||||
|
fn handle_menu_switch_ua(app_handle: AppHandle) {
|
||||||
|
let window = app_handle.get_window("mhy_client");
|
||||||
|
let execute_js = r#"
|
||||||
|
javascript:(async function(){
|
||||||
|
const isPc = navigator.userAgent.includes("Windows NT");
|
||||||
|
const arg = {
|
||||||
|
method: 'teyvat_switch_ua',
|
||||||
|
payload: {
|
||||||
|
url: window.location.href,
|
||||||
|
isPc,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await window.__TAURI__.event.emit('post_mhy_client',JSON.stringify(arg));
|
||||||
|
})()"#;
|
||||||
|
if window.is_some() {
|
||||||
|
window.unwrap().eval(&execute_js).ok().unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! @file src/client/mod.rs
|
//! @file src/client/mod.rs
|
||||||
//! @desc 客户端模块,负责操作米游社客户端
|
//! @desc 客户端模块,负责操作米游社客户端
|
||||||
//! @since Beta v0.4.3
|
//! @since Beta v0.4.5
|
||||||
|
|
||||||
mod menu;
|
mod menu;
|
||||||
use tauri::async_runtime::block_on;
|
use tauri::async_runtime::block_on;
|
||||||
@@ -15,6 +15,11 @@ pub async fn create_mhy_client(handle: AppHandle, func: String, url: String) {
|
|||||||
} else {
|
} else {
|
||||||
mhy_window_config.url = menu::get_mhy_client_url(func.clone());
|
mhy_window_config.url = menu::get_mhy_client_url(func.clone());
|
||||||
}
|
}
|
||||||
|
// if pc {
|
||||||
|
// let user_agent = mhy_window_config.user_agent.as_ref().unwrap();
|
||||||
|
// let version = user_agent.split("/").last().unwrap();
|
||||||
|
// mhy_window_config.user_agent = Some(format!("Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/{}", version));
|
||||||
|
// }
|
||||||
if func == "birthday"
|
if func == "birthday"
|
||||||
|| func == "web_act"
|
|| func == "web_act"
|
||||||
|| url.starts_with("https://webstatic.mihoyo.com/ys/event/e20220303-birthday/index.html")
|
|| url.starts_with("https://webstatic.mihoyo.com/ys/event/e20220303-birthday/index.html")
|
||||||
|
|||||||
@@ -200,11 +200,6 @@
|
|||||||
<img src="/icon/material/210.webp" class="side-icon-menu" alt="daily_note" />
|
<img src="/icon/material/210.webp" class="side-icon-menu" alt="daily_note" />
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
<v-list-item class="side-item-menu" title="酒馆" @click="openClient('tavern')">
|
|
||||||
<template #prepend>
|
|
||||||
<img src="/platforms/mhy/mys.webp" alt="酒馆" class="side-icon-menu" />
|
|
||||||
</template>
|
|
||||||
</v-list-item>
|
|
||||||
<v-list-item class="side-item-menu" title="收藏" :link="true" href="/collection">
|
<v-list-item class="side-item-menu" title="收藏" :link="true" href="/collection">
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<img src="/source/UI/posts.png" alt="collect" class="side-icon-menu" />
|
<img src="/source/UI/posts.png" alt="collect" class="side-icon-menu" />
|
||||||
|
|||||||
@@ -54,7 +54,6 @@
|
|||||||
import { computed, onMounted, ref, watch } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
|
|
||||||
import { AppAchievementsData, AppAchievementSeriesData } from "../../data";
|
import { AppAchievementsData, AppAchievementSeriesData } from "../../data";
|
||||||
import TGClient from "../../utils/TGClient";
|
|
||||||
import TGLogger from "../../utils/TGLogger";
|
import TGLogger from "../../utils/TGLogger";
|
||||||
import TOverlay from "../main/t-overlay.vue";
|
import TOverlay from "../main/t-overlay.vue";
|
||||||
|
|
||||||
@@ -103,7 +102,7 @@ async function search(word: string): Promise<void> {
|
|||||||
await TGLogger.Info(`[ToAchiInfo][${props.data?.id}][Search] 查询 ${word}`);
|
await TGLogger.Info(`[ToAchiInfo][${props.data?.id}][Search] 查询 ${word}`);
|
||||||
const str = encodeURIComponent(word);
|
const str = encodeURIComponent(word);
|
||||||
const url = `https://www.miyoushe.com/ys/search?keyword=${str}`;
|
const url = `https://www.miyoushe.com/ys/search?keyword=${str}`;
|
||||||
await TGClient.open("web_thin", url);
|
window.open(url, "_blank");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="css" scoped>
|
<style lang="css" scoped>
|
||||||
|
|||||||
@@ -20,8 +20,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import TGClient from "../../utils/TGClient";
|
|
||||||
|
|
||||||
interface TpAvatarProps {
|
interface TpAvatarProps {
|
||||||
data: TGApp.Plugins.Mys.User.Post;
|
data: TGApp.Plugins.Mys.User.Post;
|
||||||
position: "left" | "right";
|
position: "left" | "right";
|
||||||
@@ -37,8 +35,8 @@ function getAuthorDesc(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function toAuthor(): Promise<void> {
|
async function toAuthor(): Promise<void> {
|
||||||
const url = `https://m.miyoushe.com/ys/#/accountCenter/0?id=${props.data.uid}`;
|
const url = `https://www.miyoushe.com/ys/#/accountCenter/0?id=${props.data.uid}`;
|
||||||
await TGClient.open("web_thin", url);
|
window.open(url, "_blank");
|
||||||
}
|
}
|
||||||
|
|
||||||
const flexAlign = props.position === "left" ? "flex-start" : "flex-end";
|
const flexAlign = props.position === "left" ? "flex-start" : "flex-end";
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
:key="achievement.id"
|
:key="achievement.id"
|
||||||
class="card-achi"
|
class="card-achi"
|
||||||
:title="allSeriesData.find((item) => item.id === achievement.series)?.name ?? ''"
|
:title="allSeriesData.find((item) => item.id === achievement.series)?.name ?? ''"
|
||||||
@click="toAchiInfo(achievement, index)"
|
@click="showAchiInfo(achievement, index)"
|
||||||
>
|
>
|
||||||
<div class="achi-version">v{{ achievement.version }}</div>
|
<div class="achi-version">v{{ achievement.version }}</div>
|
||||||
<div class="achi-pre">
|
<div class="achi-pre">
|
||||||
@@ -259,7 +259,7 @@ function openImg(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 打开成就详情
|
// 打开成就详情
|
||||||
function toAchiInfo(item: TGApp.Sqlite.Achievement.SingleTable, index: number): void {
|
function showAchiInfo(item: TGApp.Sqlite.Achievement.SingleTable, index: number): void {
|
||||||
showAchiData.value = item;
|
showAchiData.value = item;
|
||||||
showAchi.value = true;
|
showAchi.value = true;
|
||||||
curAchiDataIndex.value = index;
|
curAchiDataIndex.value = index;
|
||||||
|
|||||||
Reference in New Issue
Block a user