mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🔥 部分跳转改为新建窗口
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//! @file src/client/menu.rs
|
||||
//! @desc 客户端菜单模块,负责操作米游社客户端菜单
|
||||
//! @since Beta v0.4.3
|
||||
//! @since Beta v0.4.5
|
||||
|
||||
use tauri::{AppHandle, CustomMenuItem, LogicalSize, Manager, Menu, Size, Submenu, WindowUrl};
|
||||
use url::Url;
|
||||
@@ -27,8 +27,8 @@ fn create_utils_menu() -> Menu {
|
||||
let retry_bridge = CustomMenuItem::new("retry".to_string(), "重试桥接");
|
||||
let mock_touch = CustomMenuItem::new("mock_touch".to_string(), "模拟触摸");
|
||||
let remove_overlay = CustomMenuItem::new("remove_overlay".to_string(), "移除遮罩");
|
||||
// 旋转窗口/切换横屏或者竖屏
|
||||
let rotate_window = CustomMenuItem::new("rotate_window".to_string(), "旋转窗口");
|
||||
let switch_ua = CustomMenuItem::new("switch_ua".to_string(), "切换 UA");
|
||||
return Menu::new()
|
||||
.add_item(retry_bridge)
|
||||
.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),
|
||||
"remove_overlay" => handle_menu_remove_overlay(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.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
|
||||
//! @desc 客户端模块,负责操作米游社客户端
|
||||
//! @since Beta v0.4.3
|
||||
//! @since Beta v0.4.5
|
||||
|
||||
mod menu;
|
||||
use tauri::async_runtime::block_on;
|
||||
@@ -15,6 +15,11 @@ pub async fn create_mhy_client(handle: AppHandle, func: String, url: String) {
|
||||
} else {
|
||||
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"
|
||||
|| func == "web_act"
|
||||
|| 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" />
|
||||
</template>
|
||||
</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">
|
||||
<template #prepend>
|
||||
<img src="/source/UI/posts.png" alt="collect" class="side-icon-menu" />
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
|
||||
import { AppAchievementsData, AppAchievementSeriesData } from "../../data";
|
||||
import TGClient from "../../utils/TGClient";
|
||||
import TGLogger from "../../utils/TGLogger";
|
||||
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}`);
|
||||
const str = encodeURIComponent(word);
|
||||
const url = `https://www.miyoushe.com/ys/search?keyword=${str}`;
|
||||
await TGClient.open("web_thin", url);
|
||||
window.open(url, "_blank");
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import TGClient from "../../utils/TGClient";
|
||||
|
||||
interface TpAvatarProps {
|
||||
data: TGApp.Plugins.Mys.User.Post;
|
||||
position: "left" | "right";
|
||||
@@ -37,8 +35,8 @@ function getAuthorDesc(): string {
|
||||
}
|
||||
|
||||
async function toAuthor(): Promise<void> {
|
||||
const url = `https://m.miyoushe.com/ys/#/accountCenter/0?id=${props.data.uid}`;
|
||||
await TGClient.open("web_thin", url);
|
||||
const url = `https://www.miyoushe.com/ys/#/accountCenter/0?id=${props.data.uid}`;
|
||||
window.open(url, "_blank");
|
||||
}
|
||||
|
||||
const flexAlign = props.position === "left" ? "flex-start" : "flex-end";
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
:key="achievement.id"
|
||||
class="card-achi"
|
||||
: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-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;
|
||||
showAchi.value = true;
|
||||
curAchiDataIndex.value = index;
|
||||
|
||||
Reference in New Issue
Block a user