mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2025-04-21 04:25:13 +08:00
fix(All): compile-error
Update Tauri and related plugins
This commit is contained in:
parent
f2f286205c
commit
2bc00ed397
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,6 +3,4 @@ dist
|
|||||||
|
|
||||||
.vscode
|
.vscode
|
||||||
.DS_Store
|
.DS_Store
|
||||||
pnpm-lock.yaml
|
|
||||||
scrcpy-mask.code-workspace
|
scrcpy-mask.code-workspace
|
||||||
src-tauri/Cargo.lock
|
|
||||||
|
20
package.json
20
package.json
@ -11,15 +11,16 @@
|
|||||||
"publish": "node publish.js"
|
"publish": "node publish.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tauri-apps/api": ">=2.0.0-beta.8",
|
"@tauri-apps/api": "2.1.1",
|
||||||
"@tauri-apps/plugin-clipboard-manager": "2.1.0-beta.1",
|
"@tauri-apps/plugin-clipboard-manager": "~2.2.1",
|
||||||
"@tauri-apps/plugin-http": "2.0.0-beta.3",
|
"@tauri-apps/plugin-http": "~2",
|
||||||
"@tauri-apps/plugin-process": "2.0.0-beta.2",
|
"@tauri-apps/plugin-os": "~2",
|
||||||
"@tauri-apps/plugin-shell": "2.0.0-beta.3",
|
"@tauri-apps/plugin-process": "~2",
|
||||||
"@tauri-apps/plugin-store": "2.0.0-beta.2",
|
"@tauri-apps/plugin-shell": "~2",
|
||||||
"pinia": "^2.1.7",
|
"@tauri-apps/plugin-store": "~2",
|
||||||
|
"pinia": "^3.0.1",
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.3.4",
|
||||||
"vue-i18n": "^9.13.1",
|
"vue-i18n": "10",
|
||||||
"vue-router": "4"
|
"vue-router": "4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -28,7 +29,8 @@
|
|||||||
"@vicons/ionicons5": "^0.12.0",
|
"@vicons/ionicons5": "^0.12.0",
|
||||||
"@vitejs/plugin-vue": "^5.0.4",
|
"@vitejs/plugin-vue": "^5.0.4",
|
||||||
"naive-ui": "^2.38.1",
|
"naive-ui": "^2.38.1",
|
||||||
"sass": "^1.71.1",
|
"sass": "^1.85.1",
|
||||||
|
"sass-loader": "^16.0.5",
|
||||||
"typescript": "^5.0.2",
|
"typescript": "^5.0.2",
|
||||||
"vite": "^5.0.0",
|
"vite": "^5.0.0",
|
||||||
"vue-tsc": "^1.8.5"
|
"vue-tsc": "^1.8.5"
|
||||||
|
1648
pnpm-lock.yaml
Normal file
1648
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,17 +8,18 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2.0.0-beta", features = [] }
|
tauri-build = { version = "2", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri = { version = "2.0.0-beta.18", features = ["macos-private-api", "devtools"] }
|
tauri = { version = "2", features = ["macos-private-api", "devtools"] }
|
||||||
tauri-plugin-store = "2.0.0-beta"
|
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
anyhow = "1.0"
|
anyhow = "1"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1"
|
||||||
tokio = { version = "1.36.0", features = ["rt-multi-thread", "net", "macros", "io-util", "time", "sync"] }
|
tokio = { version = "1", features = ["rt-multi-thread", "net", "macros", "io-util", "time", "sync"] }
|
||||||
tauri-plugin-process = "2.0.0-beta"
|
tauri-plugin-store = "2"
|
||||||
tauri-plugin-shell = "2.0.0-beta"
|
tauri-plugin-process = "2"
|
||||||
tauri-plugin-http = "2.0.0-beta"
|
tauri-plugin-shell = "2"
|
||||||
tauri-plugin-clipboard-manager = "2.1.0-beta.2"
|
tauri-plugin-http = "2"
|
||||||
|
tauri-plugin-clipboard-manager = "2"
|
||||||
|
tauri-plugin-os = "2"
|
||||||
|
@ -2,20 +2,24 @@
|
|||||||
"$schema": "../gen/schemas/desktop-schema.json",
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
"identifier": "default",
|
"identifier": "default",
|
||||||
"description": "Capability for the main window",
|
"description": "Capability for the main window",
|
||||||
"windows": ["main"],
|
"windows": [
|
||||||
|
"main"
|
||||||
|
],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"event:default",
|
"core:event:default",
|
||||||
"window:default",
|
"core:window:default",
|
||||||
"window:allow-set-position",
|
"core:window:allow-set-position",
|
||||||
"window:allow-set-size",
|
"core:window:allow-set-size",
|
||||||
"window:allow-maximize",
|
"core:window:allow-maximize",
|
||||||
"window:allow-minimize",
|
"core:window:allow-minimize",
|
||||||
"window:allow-close",
|
"core:window:allow-close",
|
||||||
"window:allow-is-maximizable",
|
"core:window:allow-is-maximizable",
|
||||||
"window:allow-start-dragging",
|
"core:window:allow-start-dragging",
|
||||||
"window:allow-unmaximize",
|
"core:window:allow-unmaximize",
|
||||||
"window:allow-set-cursor-position",
|
"core:window:allow-set-cursor-position",
|
||||||
"window:allow-set-cursor-visible",
|
"core:window:allow-set-cursor-visible",
|
||||||
|
"core:app:allow-version",
|
||||||
|
"core:app:default",
|
||||||
"store:default",
|
"store:default",
|
||||||
"store:allow-get",
|
"store:allow-get",
|
||||||
"store:allow-set",
|
"store:allow-set",
|
||||||
@ -26,8 +30,8 @@
|
|||||||
"store:allow-delete",
|
"store:allow-delete",
|
||||||
"process:default",
|
"process:default",
|
||||||
"process:allow-restart",
|
"process:allow-restart",
|
||||||
"webview:default",
|
"core:webview:default",
|
||||||
"webview:allow-internal-toggle-devtools",
|
"core:webview:allow-internal-toggle-devtools",
|
||||||
"shell:default",
|
"shell:default",
|
||||||
"shell:allow-open",
|
"shell:allow-open",
|
||||||
"http:default",
|
"http:default",
|
||||||
@ -40,10 +44,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"http:allow-fetch",
|
"http:allow-fetch",
|
||||||
"app:default",
|
|
||||||
"app:allow-version",
|
|
||||||
"clipboard-manager:default",
|
"clipboard-manager:default",
|
||||||
"clipboard-manager:allow-read-text",
|
"clipboard-manager:allow-read-text",
|
||||||
"clipboard-manager:allow-write-text"
|
"clipboard-manager:allow-write-text",
|
||||||
|
"os:default"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -9,7 +9,8 @@ use scrcpy_mask::{
|
|||||||
socket::connect_socket,
|
socket::connect_socket,
|
||||||
};
|
};
|
||||||
use std::{fs::read_to_string, sync::Arc};
|
use std::{fs::read_to_string, sync::Arc};
|
||||||
use tauri::Manager;
|
use tauri::{Emitter, Listener, Manager};
|
||||||
|
use tauri_plugin_store::StoreExt;
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
/// get devices info list
|
/// get devices info list
|
||||||
@ -159,101 +160,80 @@ fn check_adb_available() -> Result<(), String> {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn set_adb_path(adb_path: String, app: tauri::AppHandle) -> Result<(), String> {
|
fn set_adb_path(adb_path: String, app: tauri::AppHandle) -> Result<(), String> {
|
||||||
let app_h = app.app_handle().clone();
|
let store = app
|
||||||
let stores = app_h.state::<tauri_plugin_store::StoreCollection<tauri::Wry>>();
|
.store("store.bin")
|
||||||
let path = std::path::PathBuf::from("store.bin");
|
.map_err(|_| "failed to load store".to_string())?;
|
||||||
let store_res: Result<(), tauri_plugin_store::Error> =
|
store.set("adbPath", adb_path.clone());
|
||||||
tauri_plugin_store::with_store(app, stores, path, |store| {
|
*share::ADB_PATH.lock().unwrap() = adb_path;
|
||||||
store.insert(
|
Ok(())
|
||||||
"adbPath".to_string(),
|
|
||||||
serde_json::Value::String(adb_path.clone()),
|
|
||||||
)?;
|
|
||||||
*share::ADB_PATH.lock().unwrap() = adb_path;
|
|
||||||
Ok(())
|
|
||||||
});
|
|
||||||
|
|
||||||
match store_res {
|
|
||||||
Ok(_) => Ok(()),
|
|
||||||
Err(e) => Err(e.to_string()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_os::init())
|
||||||
.plugin(tauri_plugin_clipboard_manager::init())
|
.plugin(tauri_plugin_clipboard_manager::init())
|
||||||
.plugin(tauri_plugin_http::init())
|
.plugin(tauri_plugin_http::init())
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
.plugin(tauri_plugin_process::init())
|
.plugin(tauri_plugin_process::init())
|
||||||
.plugin(tauri_plugin_store::Builder::new().build())
|
.plugin(tauri_plugin_store::Builder::new().build())
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
let stores = app
|
let store = app
|
||||||
.app_handle()
|
.store("store.bin")
|
||||||
.state::<tauri_plugin_store::StoreCollection<tauri::Wry>>();
|
.map_err(|_| "failed to load store".to_string())?;
|
||||||
let path: std::path::PathBuf = std::path::PathBuf::from("store.bin");
|
|
||||||
tauri_plugin_store::with_store(app.app_handle().clone(), stores, path, |store| {
|
|
||||||
// load adb path
|
|
||||||
match store.get("adbPath") {
|
|
||||||
Some(value) => {
|
|
||||||
*share::ADB_PATH.lock().unwrap() = value.as_str().unwrap().to_string()
|
|
||||||
}
|
|
||||||
None => store
|
|
||||||
.insert(
|
|
||||||
"adbPath".to_string(),
|
|
||||||
serde_json::Value::String("adb".to_string()),
|
|
||||||
)
|
|
||||||
.unwrap(),
|
|
||||||
};
|
|
||||||
|
|
||||||
// restore window position and size
|
// set adb path
|
||||||
match store.get("maskArea") {
|
match store.get("adbPath") {
|
||||||
Some(value) => {
|
Some(value) => {
|
||||||
let pos_x = value["posX"].as_i64();
|
*share::ADB_PATH.lock().unwrap() = value.as_str().unwrap().to_string()
|
||||||
let pos_y = value["posY"].as_i64();
|
|
||||||
let size_w = value["sizeW"].as_i64().unwrap_or(800);
|
|
||||||
let size_h = value["sizeH"].as_i64().unwrap_or(600);
|
|
||||||
|
|
||||||
let main_window: tauri::WebviewWindow =
|
|
||||||
app.get_webview_window("main").unwrap();
|
|
||||||
|
|
||||||
main_window.set_zoom(1.).unwrap_or(());
|
|
||||||
|
|
||||||
if pos_x.is_none() || pos_y.is_none() {
|
|
||||||
main_window.center().unwrap_or(());
|
|
||||||
} else {
|
|
||||||
main_window
|
|
||||||
.set_position(tauri::Position::Logical(tauri::LogicalPosition {
|
|
||||||
x: (pos_x.unwrap() - 70) as f64,
|
|
||||||
y: (pos_y.unwrap() - 30) as f64,
|
|
||||||
}))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
main_window
|
|
||||||
.set_size(tauri::Size::Logical(tauri::LogicalSize {
|
|
||||||
width: (size_w + 70) as f64,
|
|
||||||
height: (size_h + 30) as f64,
|
|
||||||
}))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
let main_window: tauri::WebviewWindow =
|
|
||||||
app.get_webview_window("main").unwrap();
|
|
||||||
|
|
||||||
main_window.center().unwrap_or(());
|
|
||||||
|
|
||||||
main_window
|
|
||||||
.set_size(tauri::Size::Logical(tauri::LogicalSize {
|
|
||||||
width: (800 + 70) as f64,
|
|
||||||
height: (600 + 30) as f64,
|
|
||||||
}))
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
None => store.set("adbPath", "adb".to_string()),
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
// restore window position and size
|
||||||
})
|
match store.get("maskArea") {
|
||||||
.unwrap();
|
Some(value) => {
|
||||||
|
// TODO check position and size validity
|
||||||
|
|
||||||
|
let pos_x = value["posX"].as_i64();
|
||||||
|
let pos_y = value["posY"].as_i64();
|
||||||
|
let size_w = value["sizeW"].as_i64().unwrap_or(800);
|
||||||
|
let size_h = value["sizeH"].as_i64().unwrap_or(600);
|
||||||
|
|
||||||
|
let main_window: tauri::WebviewWindow = app.get_webview_window("main").unwrap();
|
||||||
|
|
||||||
|
main_window.set_zoom(1.).unwrap_or(());
|
||||||
|
|
||||||
|
if pos_x.is_none() || pos_y.is_none() {
|
||||||
|
main_window.center().unwrap_or(());
|
||||||
|
} else {
|
||||||
|
main_window
|
||||||
|
.set_position(tauri::Position::Logical(tauri::LogicalPosition {
|
||||||
|
x: (pos_x.unwrap() - 70) as f64,
|
||||||
|
y: (pos_y.unwrap() - 30) as f64,
|
||||||
|
}))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
main_window
|
||||||
|
.set_size(tauri::Size::Logical(tauri::LogicalSize {
|
||||||
|
width: (size_w + 70) as f64,
|
||||||
|
height: (size_h + 30) as f64,
|
||||||
|
}))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
let main_window: tauri::WebviewWindow = app.get_webview_window("main").unwrap();
|
||||||
|
|
||||||
|
main_window.center().unwrap_or(());
|
||||||
|
|
||||||
|
main_window
|
||||||
|
.set_size(tauri::Size::Logical(tauri::LogicalSize {
|
||||||
|
width: (800 + 70) as f64,
|
||||||
|
height: (600 + 30) as f64,
|
||||||
|
}))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check resource files
|
// check resource files
|
||||||
ResHelper::res_init(
|
ResHelper::res_init(
|
||||||
|
@ -2,6 +2,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
use tauri::Listener;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
io::AsyncReadExt,
|
io::AsyncReadExt,
|
||||||
net::{
|
net::{
|
||||||
|
30
src/App.vue
30
src/App.vue
@ -13,24 +13,26 @@ import { useRouter } from "vue-router";
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
router.replace({ name: "mask" });
|
await router.replace({ name: "mask" });
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NConfigProvider :theme="darkTheme" class="container">
|
<Suspense>
|
||||||
<NMessageProvider>
|
<NConfigProvider :theme="darkTheme" class="container">
|
||||||
<Header />
|
<NMessageProvider>
|
||||||
<NDialogProvider>
|
<Header />
|
||||||
<RouterView v-slot="{ Component }">
|
<NDialogProvider>
|
||||||
<KeepAlive>
|
<RouterView v-slot="{ Component }">
|
||||||
<component :is="Component" />
|
<KeepAlive>
|
||||||
</KeepAlive>
|
<component :is="Component" />
|
||||||
</RouterView>
|
</KeepAlive>
|
||||||
</NDialogProvider>
|
</RouterView>
|
||||||
<Sidebar />
|
</NDialogProvider>
|
||||||
</NMessageProvider>
|
<Sidebar />
|
||||||
</NConfigProvider>
|
</NMessageProvider>
|
||||||
|
</NConfigProvider>
|
||||||
|
</Suspense>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -44,7 +44,7 @@ import { shutdown } from "../frontcommand/scrcpyMaskCmd";
|
|||||||
import { useGlobalStore } from "../store/global";
|
import { useGlobalStore } from "../store/global";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { closeExternalControl, connectExternalControl } from "../websocket";
|
import { closeExternalControl, connectExternalControl } from "../websocket";
|
||||||
import { LogicalSize, getCurrent } from "@tauri-apps/api/window";
|
import { LogicalSize, getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
@ -97,7 +97,7 @@ onMounted(async () => {
|
|||||||
maskH = Math.round(store.rotation.verticalLength);
|
maskH = Math.round(store.rotation.verticalLength);
|
||||||
maskW = Math.round(maskH * (payload.width / payload.height));
|
maskW = Math.round(maskH * (payload.width / payload.height));
|
||||||
}
|
}
|
||||||
getCurrent().setSize(new LogicalSize(maskW + 70, maskH + 30));
|
getCurrentWindow().setSize(new LogicalSize(maskW + 70, maskH + 30));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
import { NButtonGroup, NButton, NIcon } from "naive-ui";
|
import { NButtonGroup, NButton, NIcon } from "naive-ui";
|
||||||
import { Close } from "@vicons/ionicons5";
|
import { Close } from "@vicons/ionicons5";
|
||||||
import { Maximize16Regular, Subtract16Regular } from "@vicons/fluent";
|
import { Maximize16Regular, Subtract16Regular } from "@vicons/fluent";
|
||||||
import { getCurrent } from "@tauri-apps/api/window";
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
|
|
||||||
async function maximizeOrRestore() {
|
async function maximizeOrRestore() {
|
||||||
const appWindow = getCurrent();
|
const appWindow = getCurrentWindow();
|
||||||
appWindow.isMaximized().then((maximized) => {
|
appWindow.isMaximized().then((maximized) => {
|
||||||
maximized ? appWindow.unmaximize() : appWindow.maximize();
|
maximized ? appWindow.unmaximize() : appWindow.maximize();
|
||||||
});
|
});
|
||||||
@ -16,7 +16,11 @@ async function maximizeOrRestore() {
|
|||||||
<div class="header">
|
<div class="header">
|
||||||
<div data-tauri-drag-region class="drag"></div>
|
<div data-tauri-drag-region class="drag"></div>
|
||||||
<NButtonGroup>
|
<NButtonGroup>
|
||||||
<NButton quaternary :focusable="false" @click="getCurrent().minimize()">
|
<NButton
|
||||||
|
quaternary
|
||||||
|
:focusable="false"
|
||||||
|
@click="getCurrentWindow().minimize()"
|
||||||
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<NIcon><Subtract16Regular /></NIcon>
|
<NIcon><Subtract16Regular /></NIcon>
|
||||||
</template>
|
</template>
|
||||||
@ -30,7 +34,7 @@ async function maximizeOrRestore() {
|
|||||||
quaternary
|
quaternary
|
||||||
:focusable="false"
|
:focusable="false"
|
||||||
class="close"
|
class="close"
|
||||||
@click="getCurrent().close()"
|
@click="getCurrentWindow().close()"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<NIcon><Close /></NIcon>
|
<NIcon><Close /></NIcon>
|
||||||
@ -52,11 +56,11 @@ async function maximizeOrRestore() {
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
|
|
||||||
.n-button-group{
|
.n-button-group {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.drag{
|
.drag {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@ import ScreenStream from "./ScreenStream.vue";
|
|||||||
import { getVersion } from "@tauri-apps/api/app";
|
import { getVersion } from "@tauri-apps/api/app";
|
||||||
import { fetch } from "@tauri-apps/plugin-http";
|
import { fetch } from "@tauri-apps/plugin-http";
|
||||||
import { open } from "@tauri-apps/plugin-shell";
|
import { open } from "@tauri-apps/plugin-shell";
|
||||||
import { getCurrent, PhysicalSize } from "@tauri-apps/api/window";
|
import { getCurrentWindow, PhysicalSize } from "@tauri-apps/api/window";
|
||||||
import { Store } from "@tauri-apps/plugin-store";
|
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { checkAdbAvailable } from "../invoke";
|
import { checkAdbAvailable } from "../invoke";
|
||||||
import { loadLocalStorage } from "../storeLoader";
|
import { loadPersistentStorage } from "../storeLoader";
|
||||||
|
import { load } from "@tauri-apps/plugin-store";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const store = useGlobalStore();
|
const store = useGlobalStore();
|
||||||
@ -68,7 +68,7 @@ onMounted(async () => {
|
|||||||
checkAdb();
|
checkAdb();
|
||||||
// listen to window resize event
|
// listen to window resize event
|
||||||
const maskElement = document.getElementById("maskElement") as HTMLElement;
|
const maskElement = document.getElementById("maskElement") as HTMLElement;
|
||||||
const appWindow = getCurrent();
|
const appWindow = getCurrentWindow();
|
||||||
appWindow.onResized(() => {
|
appWindow.onResized(() => {
|
||||||
store.maskSizeH = maskElement.clientHeight;
|
store.maskSizeH = maskElement.clientHeight;
|
||||||
store.maskSizeW = maskElement.clientWidth;
|
store.maskSizeW = maskElement.clientWidth;
|
||||||
@ -103,12 +103,13 @@ function genClientId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadLocalStore() {
|
async function loadLocalStore() {
|
||||||
const localStore = new Store("store.bin");
|
const localStore = await load("store.json");
|
||||||
await loadLocalStorage(localStore, store, t);
|
await loadPersistentStorage(localStore, store, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cleanAfterimage() {
|
async function cleanAfterimage() {
|
||||||
const appWindow = getCurrent();
|
// TODO fix oldSize making window large
|
||||||
|
const appWindow = getCurrentWindow();
|
||||||
const oldSize = await appWindow.outerSize();
|
const oldSize = await appWindow.outerSize();
|
||||||
const newSize = new PhysicalSize(oldSize.width, oldSize.height + 1);
|
const newSize = new PhysicalSize(oldSize.width, oldSize.height + 1);
|
||||||
await appWindow.setSize(newSize);
|
await appWindow.setSize(newSize);
|
||||||
|
@ -14,17 +14,17 @@ import {
|
|||||||
} from "naive-ui";
|
} from "naive-ui";
|
||||||
import { computed, onActivated, onMounted, ref, watch } from "vue";
|
import { computed, onActivated, onMounted, ref, watch } from "vue";
|
||||||
import { useGlobalStore } from "../../store/global";
|
import { useGlobalStore } from "../../store/global";
|
||||||
import { Store } from "@tauri-apps/plugin-store";
|
|
||||||
import { loadDefaultKeyconfig } from "../../invoke";
|
import { loadDefaultKeyconfig } from "../../invoke";
|
||||||
import { KeyMappingConfig } from "../../keyMappingConfig";
|
import { KeyMappingConfig } from "../../keyMappingConfig";
|
||||||
import { useKeyboardStore } from "../../store/keyboard";
|
import { useKeyboardStore } from "../../store/keyboard";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
|
import { load } from "@tauri-apps/plugin-store";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const store = useGlobalStore();
|
const store = useGlobalStore();
|
||||||
const keyboardStore = useKeyboardStore();
|
const keyboardStore = useKeyboardStore();
|
||||||
const localStore = new Store("store.bin");
|
const localStore = await load("store.json");
|
||||||
const message = useMessage();
|
const message = useMessage();
|
||||||
|
|
||||||
const showImportModal = ref(false);
|
const showImportModal = ref(false);
|
||||||
@ -56,7 +56,7 @@ onMounted(async () => {
|
|||||||
"keySettingPos"
|
"keySettingPos"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (storedPos === null) {
|
if (storedPos === undefined) {
|
||||||
await localStore.set("keySettingPos", keySettingPos.value);
|
await localStore.set("keySettingPos", keySettingPos.value);
|
||||||
storedPos = { x: 100, y: 100 };
|
storedPos = { x: 100, y: 100 };
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ import { open } from "@tauri-apps/plugin-shell";
|
|||||||
import { getVersion } from "@tauri-apps/api/app";
|
import { getVersion } from "@tauri-apps/api/app";
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { useGlobalStore } from "../../store/global";
|
import { useGlobalStore } from "../../store/global";
|
||||||
import { Store } from "@tauri-apps/plugin-store";
|
import { load } from "@tauri-apps/plugin-store";
|
||||||
|
|
||||||
const store = useGlobalStore();
|
const store = useGlobalStore();
|
||||||
const localStore = new Store("store.bin");
|
const localStore = await load('store.json');
|
||||||
|
|
||||||
const appVersion = ref("");
|
const appVersion = ref("");
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Store } from "@tauri-apps/plugin-store";
|
import { load } from "@tauri-apps/plugin-store";
|
||||||
import {
|
import {
|
||||||
NH4,
|
NH4,
|
||||||
NButton,
|
NButton,
|
||||||
@ -12,20 +12,22 @@ import {
|
|||||||
NTooltip,
|
NTooltip,
|
||||||
} from "naive-ui";
|
} from "naive-ui";
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import i18n from "../../i18n";
|
import i18n, { allLanguage } from "../../i18n";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { setAdbPath } from "../../invoke";
|
import { setAdbPath } from "../../invoke";
|
||||||
import { useGlobalStore } from "../../store/global";
|
import { useGlobalStore } from "../../store/global";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const localStore = new Store("store.bin");
|
const localStore = await load("store.json");
|
||||||
const store = useGlobalStore();
|
const store = useGlobalStore();
|
||||||
const message = useMessage();
|
const message = useMessage();
|
||||||
|
|
||||||
const languageOptions = [
|
const languageOptions = Object.entries(allLanguage).map(([key, value]) => {
|
||||||
{ label: "简体中文", value: "zh-CN" },
|
return {
|
||||||
{ label: "English", value: "en-US" },
|
label: value.label,
|
||||||
];
|
value: key,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const curLanguage = ref("en-US");
|
const curLanguage = ref("en-US");
|
||||||
|
|
||||||
@ -40,7 +42,7 @@ function changeLanguage(language: "zh-CN" | "en-US") {
|
|||||||
if (language === curLanguage.value) return;
|
if (language === curLanguage.value) return;
|
||||||
curLanguage.value = language;
|
curLanguage.value = language;
|
||||||
localStore.set("language", language);
|
localStore.set("language", language);
|
||||||
i18n.global.locale.value = language;
|
i18n.global.locale = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function adjustAdbPath() {
|
async function adjustAdbPath() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Store } from "@tauri-apps/plugin-store";
|
import { load } from "@tauri-apps/plugin-store";
|
||||||
import { Refresh, TrashBinOutline } from "@vicons/ionicons5";
|
import { Refresh, TrashBinOutline } from "@vicons/ionicons5";
|
||||||
import {
|
import {
|
||||||
NH4,
|
NH4,
|
||||||
@ -19,7 +19,8 @@ import { onMounted, ref } from "vue";
|
|||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const localStore = new Store("store.bin");
|
const localStore = await load("store.json");
|
||||||
|
|
||||||
const dialog = useDialog();
|
const dialog = useDialog();
|
||||||
|
|
||||||
const localStoreEntries = ref<[string, unknown][]>([]);
|
const localStoreEntries = ref<[string, unknown][]>([]);
|
||||||
|
@ -22,9 +22,9 @@ import {
|
|||||||
LogicalSize,
|
LogicalSize,
|
||||||
PhysicalPosition,
|
PhysicalPosition,
|
||||||
PhysicalSize,
|
PhysicalSize,
|
||||||
getCurrent,
|
getCurrentWindow,
|
||||||
} from "@tauri-apps/api/window";
|
} from "@tauri-apps/api/window";
|
||||||
import { Store } from "@tauri-apps/plugin-store";
|
import { load } from "@tauri-apps/plugin-store";
|
||||||
import { SettingsOutline } from "@vicons/ionicons5";
|
import { SettingsOutline } from "@vicons/ionicons5";
|
||||||
import { UnlistenFn } from "@tauri-apps/api/event";
|
import { UnlistenFn } from "@tauri-apps/api/event";
|
||||||
import { useGlobalStore } from "../../store/global";
|
import { useGlobalStore } from "../../store/global";
|
||||||
@ -35,7 +35,7 @@ let unlistenMove: UnlistenFn = () => {};
|
|||||||
let factor = 1;
|
let factor = 1;
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const localStore = new Store("store.bin");
|
const localStore = await load("store.json");
|
||||||
const store = useGlobalStore();
|
const store = useGlobalStore();
|
||||||
const message = useMessage();
|
const message = useMessage();
|
||||||
const formRef = ref<FormInst | null>(null);
|
const formRef = ref<FormInst | null>(null);
|
||||||
@ -120,7 +120,7 @@ async function adjustMaskArea() {
|
|||||||
const mt = 30;
|
const mt = 30;
|
||||||
const ml = 70;
|
const ml = 70;
|
||||||
|
|
||||||
const appWindow = getCurrent();
|
const appWindow = getCurrentWindow();
|
||||||
|
|
||||||
const pos = new LogicalPosition(
|
const pos = new LogicalPosition(
|
||||||
areaModel.value.posX - ml,
|
areaModel.value.posX - ml,
|
||||||
@ -137,11 +137,11 @@ async function adjustMaskArea() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const appWindow = getCurrent();
|
const appWindow = getCurrentWindow();
|
||||||
factor = await appWindow.scaleFactor();
|
factor = await appWindow.scaleFactor();
|
||||||
|
|
||||||
let maskArea = await localStore.get<MaskArea>("maskArea");
|
let maskArea = await localStore.get<MaskArea>("maskArea");
|
||||||
if (maskArea !== null) {
|
if (maskArea !== undefined) {
|
||||||
areaModel.value = maskArea;
|
areaModel.value = maskArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import {
|
|||||||
KeyTriggerWhenPressedSkill,
|
KeyTriggerWhenPressedSkill,
|
||||||
} from "./keyMappingConfig";
|
} from "./keyMappingConfig";
|
||||||
import { useGlobalStore } from "./store/global";
|
import { useGlobalStore } from "./store/global";
|
||||||
import { LogicalPosition, getCurrent } from "@tauri-apps/api/window";
|
import { LogicalPosition, getCurrentWindow } from "@tauri-apps/api/window";
|
||||||
import { readText } from "@tauri-apps/plugin-clipboard-manager";
|
import { readText } from "@tauri-apps/plugin-clipboard-manager";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { KeyToCodeMap } from "./frontcommand/KeyToCodeMap";
|
import { KeyToCodeMap } from "./frontcommand/KeyToCodeMap";
|
||||||
@ -663,7 +663,7 @@ function addSightShortcuts(
|
|||||||
sightKeyMapping: KeySight,
|
sightKeyMapping: KeySight,
|
||||||
fireKeyMapping?: KeyFire
|
fireKeyMapping?: KeyFire
|
||||||
) {
|
) {
|
||||||
const appWindow = getCurrent();
|
const appWindow = getCurrentWindow();
|
||||||
|
|
||||||
let mouseLock = false;
|
let mouseLock = false;
|
||||||
let msgReactive: ReturnType<typeof message.info> | null = null;
|
let msgReactive: ReturnType<typeof message.info> | null = null;
|
||||||
|
@ -1,22 +1,39 @@
|
|||||||
import { createI18n } from "vue-i18n";
|
import { createI18n } from "vue-i18n";
|
||||||
import { Store } from "@tauri-apps/plugin-store";
|
import { load } from "@tauri-apps/plugin-store";
|
||||||
|
import { locale } from "@tauri-apps/plugin-os";
|
||||||
|
|
||||||
import enUS from "./en-US.json";
|
import enUS from "./en-US.json";
|
||||||
import zhCN from "./zh-CN.json";
|
import zhCN from "./zh-CN.json";
|
||||||
|
const localStore = await load("store.json");
|
||||||
|
|
||||||
const localStore = new Store("store.bin");
|
export const allLanguage = {
|
||||||
|
"en-US": { label: "English US", value: enUS },
|
||||||
|
"zh-CN": { label: "简体中文", value: zhCN },
|
||||||
|
};
|
||||||
|
|
||||||
const i18n = createI18n({
|
const i18n = createI18n({
|
||||||
allowComposition: true,
|
allowComposition: true,
|
||||||
legacy: false,
|
messages: Object.fromEntries(
|
||||||
messages: {
|
Object.entries(allLanguage).map(([key, value]) => [key, value.value])
|
||||||
"en-US": enUS,
|
),
|
||||||
"zh-CN": zhCN,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
localStore.get<"en-US" | "zh-CN">("language").then((language) => {
|
localStore.get<"en-US" | "zh-CN">("language").then((language) => {
|
||||||
i18n.global.locale.value = language ?? "en-US";
|
if (language === undefined) {
|
||||||
|
locale().then((lang) => {
|
||||||
|
if (lang === null) i18n.global.locale = "en-US";
|
||||||
|
else if (lang in allLanguage) {
|
||||||
|
i18n.global.locale = lang;
|
||||||
|
} else {
|
||||||
|
if (lang.startsWith("zh")) i18n.global.locale = "zh-CN";
|
||||||
|
else if (lang.startsWith("en")) i18n.global.locale = "en-US";
|
||||||
|
else i18n.global.locale = "en-US";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// "en-US"
|
||||||
|
} else {
|
||||||
|
i18n.global.locale = language;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default i18n;
|
export default i18n;
|
||||||
|
@ -5,9 +5,9 @@ import {
|
|||||||
KeyMappingConfig,
|
KeyMappingConfig,
|
||||||
KeySteeringWheel,
|
KeySteeringWheel,
|
||||||
} from "../keyMappingConfig";
|
} from "../keyMappingConfig";
|
||||||
import { Store } from "@tauri-apps/plugin-store";
|
import { load } from "@tauri-apps/plugin-store";
|
||||||
|
|
||||||
const localStore = new Store("store.bin");
|
const localStore = await load("store.json");
|
||||||
|
|
||||||
export const useGlobalStore = defineStore("global", () => {
|
export const useGlobalStore = defineStore("global", () => {
|
||||||
const showLoadingRef = ref(false);
|
const showLoadingRef = ref(false);
|
||||||
@ -30,21 +30,17 @@ export const useGlobalStore = defineStore("global", () => {
|
|||||||
let checkUpdate: () => Promise<void> = async () => {};
|
let checkUpdate: () => Promise<void> = async () => {};
|
||||||
let checkAdb: () => Promise<void> = async () => {};
|
let checkAdb: () => Promise<void> = async () => {};
|
||||||
|
|
||||||
|
// Applies the edited key mapping list and checks for duplicate keys
|
||||||
function applyEditKeyMappingList(): boolean {
|
function applyEditKeyMappingList(): boolean {
|
||||||
const set = new Set<string>();
|
const set = new Set<string>();
|
||||||
for (const keyMapping of editKeyMappingList.value) {
|
for (const keyMapping of editKeyMappingList.value) {
|
||||||
if (keyMapping.type === "SteeringWheel") {
|
if (keyMapping.type === "SteeringWheel") {
|
||||||
const nameList: ["up", "down", "left", "right"] = [
|
for (const name of ["up", "down", "left", "right"] as const) {
|
||||||
"up",
|
|
||||||
"down",
|
|
||||||
"left",
|
|
||||||
"right",
|
|
||||||
];
|
|
||||||
for (const name of nameList) {
|
|
||||||
if (set.has((keyMapping as KeySteeringWheel).key[name])) return false;
|
if (set.has((keyMapping as KeySteeringWheel).key[name])) return false;
|
||||||
set.add((keyMapping as KeySteeringWheel).key[name]);
|
set.add((keyMapping as KeySteeringWheel).key[name]);
|
||||||
}
|
}
|
||||||
} else if (keyMapping.type !== "Fire") {
|
} else if (keyMapping.type !== "Fire") {
|
||||||
|
// check duplicated key
|
||||||
if (set.has(keyMapping.key as string)) return false;
|
if (set.has(keyMapping.key as string)) return false;
|
||||||
set.add(keyMapping.key as string);
|
set.add(keyMapping.key as string);
|
||||||
}
|
}
|
||||||
@ -56,12 +52,14 @@ export const useGlobalStore = defineStore("global", () => {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset the edited key mapping to the original key mapping list
|
||||||
function resetEditKeyMappingList() {
|
function resetEditKeyMappingList() {
|
||||||
editKeyMappingList.value = JSON.parse(
|
editKeyMappingList.value = JSON.parse(
|
||||||
JSON.stringify(keyMappingConfigList.value[curKeyMappingIndex.value].list)
|
JSON.stringify(keyMappingConfigList.value[curKeyMappingIndex.value].list)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// change key mapping scheme
|
||||||
function setKeyMappingIndex(index: number) {
|
function setKeyMappingIndex(index: number) {
|
||||||
curKeyMappingIndex.value = index;
|
curKeyMappingIndex.value = index;
|
||||||
resetEditKeyMappingList();
|
resetEditKeyMappingList();
|
||||||
|
@ -12,7 +12,7 @@ async function loadKeyMappingConfigList() {
|
|||||||
let keyMappingConfigList = await localStore.get<KeyMappingConfig[]>(
|
let keyMappingConfigList = await localStore.get<KeyMappingConfig[]>(
|
||||||
"keyMappingConfigList"
|
"keyMappingConfigList"
|
||||||
);
|
);
|
||||||
if (keyMappingConfigList === null || keyMappingConfigList.length === 0) {
|
if (keyMappingConfigList === undefined || keyMappingConfigList.length === 0) {
|
||||||
// add empty key mapping config
|
// add empty key mapping config
|
||||||
// unable to get mask element when app is not ready
|
// unable to get mask element when app is not ready
|
||||||
// so we use the stored mask area to get relative size
|
// so we use the stored mask area to get relative size
|
||||||
@ -23,7 +23,7 @@ async function loadKeyMappingConfigList() {
|
|||||||
sizeH: number;
|
sizeH: number;
|
||||||
}>("maskArea");
|
}>("maskArea");
|
||||||
let relativeSize = { w: 800, h: 600 };
|
let relativeSize = { w: 800, h: 600 };
|
||||||
if (maskArea !== null) {
|
if (maskArea !== undefined) {
|
||||||
relativeSize = {
|
relativeSize = {
|
||||||
w: maskArea.sizeW,
|
w: maskArea.sizeW,
|
||||||
h: maskArea.sizeH,
|
h: maskArea.sizeH,
|
||||||
@ -45,7 +45,7 @@ async function loadCurKeyMappingIndex() {
|
|||||||
// loading curKeyMappingIndex from local store
|
// loading curKeyMappingIndex from local store
|
||||||
let curKeyMappingIndex = await localStore.get<number>("curKeyMappingIndex");
|
let curKeyMappingIndex = await localStore.get<number>("curKeyMappingIndex");
|
||||||
if (
|
if (
|
||||||
curKeyMappingIndex === null ||
|
curKeyMappingIndex === undefined ||
|
||||||
curKeyMappingIndex >= store.keyMappingConfigList.length
|
curKeyMappingIndex >= store.keyMappingConfigList.length
|
||||||
) {
|
) {
|
||||||
curKeyMappingIndex = 0;
|
curKeyMappingIndex = 0;
|
||||||
@ -100,10 +100,9 @@ async function loadClipboardSync() {
|
|||||||
pasteFromPC: boolean;
|
pasteFromPC: boolean;
|
||||||
}>("clipboardSync");
|
}>("clipboardSync");
|
||||||
if (clipboardSync) store.clipboardSync = clipboardSync;
|
if (clipboardSync) store.clipboardSync = clipboardSync;
|
||||||
console.log(store.clipboardSync);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadLocalStorage(
|
export async function loadPersistentStorage(
|
||||||
theLocalStore: Store,
|
theLocalStore: Store,
|
||||||
theStore: ReturnType<typeof useGlobalStore>,
|
theStore: ReturnType<typeof useGlobalStore>,
|
||||||
theT: ReturnType<typeof useI18n>["t"]
|
theT: ReturnType<typeof useI18n>["t"]
|
||||||
|
@ -3,6 +3,14 @@ import vue from "@vitejs/plugin-vue";
|
|||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig(async () => ({
|
export default defineConfig(async () => ({
|
||||||
|
css: {
|
||||||
|
preprocessorOptions: {
|
||||||
|
scss: {
|
||||||
|
api: "modern-compiler", // 或 "modern"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
plugins: [vue()],
|
plugins: [vue()],
|
||||||
|
|
||||||
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
||||||
|
Loading…
Reference in New Issue
Block a user