[Update] update tauri v1-> v2 (development)
This commit is contained in:
3516
src-tauri/Cargo.lock
generated
3516
src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -7,19 +7,27 @@ edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
# The `_lib` suffix may seem redundant but it is necessary
|
||||
# to make the lib name unique and wouldn't conflict with the bin name.
|
||||
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
||||
name = "vrct_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "1", features = [] }
|
||||
tauri-build = { version = "=2.2.0", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "1", features = [ "fs-remove-dir", "fs-read-file", "fs-create-dir", "fs-write-file", "fs-exists", "http-request", "fs-read-dir", "window-hide", "window-set-focus", "global-shortcut-all", "window-set-size", "window-set-position", "window-unmaximize", "window-close", "window-maximize", "window-minimize", "window-unminimize", "window-start-dragging", "window-set-decorations", "window-set-always-on-top", "shell-sidecar", "shell-open", "devtools"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
font-kit = "0.14.2"
|
||||
window-shadows = { git = "https://github.com/tauri-apps/window-shadows.git" }
|
||||
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
|
||||
base64 = "0.22.1"
|
||||
tauri = { version = "=2.5.1", features = ["devtools"] }
|
||||
tauri-plugin-opener = "=2.2.6"
|
||||
serde = { version = "=1.0.219", features = ["derive"] }
|
||||
serde_json = "=1.0.140"
|
||||
tauri-plugin-fs = "=2.2.1"
|
||||
tauri-plugin-http = "=2.4.3"
|
||||
tauri-plugin-shell = "2.2.1"
|
||||
font-kit = "=0.14.2"
|
||||
reqwest = "=0.12.15"
|
||||
base64 = "=0.22.1"
|
||||
|
||||
|
||||
[features]
|
||||
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-global-shortcut = "=2.2.0"
|
||||
|
||||
10
src-tauri/capabilities/default.json
Normal file
10
src-tauri/capabilities/default.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"opener:default"
|
||||
]
|
||||
}
|
||||
63
src-tauri/capabilities/vrct_capability.json
Normal file
63
src-tauri/capabilities/vrct_capability.json
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "vrct-capability",
|
||||
"description": "VRCT main window capabilities",
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:window:default",
|
||||
"core:window:allow-start-dragging",
|
||||
"core:window:allow-close",
|
||||
"core:window:allow-set-position",
|
||||
"core:window:allow-set-size",
|
||||
"core:window:allow-set-always-on-top",
|
||||
"core:window:allow-maximize",
|
||||
"core:window:allow-unmaximize",
|
||||
"core:window:allow-minimize",
|
||||
"core:window:allow-unminimize",
|
||||
"core:window:allow-set-focus",
|
||||
|
||||
"global-shortcut:allow-is-registered",
|
||||
"global-shortcut:allow-register",
|
||||
"global-shortcut:allow-register-all",
|
||||
"global-shortcut:allow-unregister",
|
||||
"global-shortcut:allow-unregister-all",
|
||||
|
||||
"fs:default",
|
||||
"fs:allow-write-file",
|
||||
"fs:allow-remove",
|
||||
"fs:allow-resource-read-recursive",
|
||||
"fs:allow-resource-meta-recursive",
|
||||
{
|
||||
"identifier": "fs:scope",
|
||||
"allow": [
|
||||
{ "path": "$RESOURCE/plugins/**" },
|
||||
{ "path": "src-tauri/target/debug/plugins/**" }
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"identifier": "http:default",
|
||||
"allow": [
|
||||
{ "url": "https://api.github.com/repos/**" },
|
||||
{ "url": "https://github.com/**" },
|
||||
{ "url": "https://raw.githubusercontent.com/ShiinaSakamoto/vrct_plugins_list/main/vrct_plugins_list.json" },
|
||||
{ "url": "https://raw.githubusercontent.com/ShiinaSakamoto/vrct_plugins_list/main/dev_vrct_plugins_list.json" }
|
||||
]
|
||||
},
|
||||
|
||||
"shell:allow-open",
|
||||
"shell:allow-stdin-write",
|
||||
{
|
||||
"identifier": "shell:allow-spawn",
|
||||
"allow": [
|
||||
{ "name": "bin/VRCT-sidecar", "sidecar": true, "args": true }
|
||||
]
|
||||
},
|
||||
{
|
||||
"identifier": "shell:allow-execute",
|
||||
"allow": [
|
||||
{ "name": "bin/VRCT-sidecar", "sidecar": true, "args": true }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
64
src-tauri/src/lib.rs
Normal file
64
src-tauri/src/lib.rs
Normal file
@@ -0,0 +1,64 @@
|
||||
use tauri::Manager;
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
let main_window = app.get_webview_window("main").unwrap(); // `main_window` is declared here for all builds
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{ main_window.open_devtools(); }
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_http::init())
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.invoke_handler(tauri::generate_handler![get_font_list, download_zip_asset])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
|
||||
use font_kit::{source::SystemSource};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[tauri::command]
|
||||
async fn get_font_list() -> Vec<String> {
|
||||
let source = SystemSource::new();
|
||||
let mut font_families = HashSet::new();
|
||||
|
||||
if let Ok(fonts) = source.all_fonts() {
|
||||
for font in fonts {
|
||||
if let Ok(info) = font.load() {
|
||||
font_families.insert(info.family_name().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
font_families.into_iter().collect()
|
||||
}
|
||||
|
||||
|
||||
use base64::engine::general_purpose::STANDARD as BASE64;
|
||||
use base64::Engine;
|
||||
|
||||
#[tauri::command]
|
||||
async fn download_zip_asset(url: String) -> Result<String, String> {
|
||||
use reqwest;
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let resp = client.get(&url)
|
||||
.header("Accept", "application/octet-stream")
|
||||
.send()
|
||||
.await.map_err(|e| format!("Request error: {}", e))?;
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!("HTTP error: {}", resp.status()));
|
||||
}
|
||||
|
||||
let bytes = resp.bytes().await.map_err(|e| format!("Reading bytes error: {}", e))?;
|
||||
|
||||
Ok(BASE64.encode(&bytes))
|
||||
}
|
||||
@@ -1,67 +1,6 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use tauri::Manager;
|
||||
use window_shadows::set_shadow;
|
||||
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
let main_window = app.get_window("main").unwrap(); // `main_window` is declared here for all builds
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{ main_window.open_devtools(); }
|
||||
|
||||
#[cfg(any(windows, target_os = "macos"))]
|
||||
set_shadow(main_window, true).unwrap();
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.on_window_event(|event| { // This is for fix the bug that the window scaling issue when dragging between monitors.
|
||||
if let tauri::WindowEvent::ScaleFactorChanged { new_inner_size, .. } = event.event() {
|
||||
event.window().set_size(tauri::Size::Physical(*new_inner_size)).unwrap();
|
||||
}
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![get_font_list, download_zip_asset])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
vrct_lib::run()
|
||||
}
|
||||
|
||||
|
||||
use font_kit::{source::SystemSource};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[tauri::command]
|
||||
async fn get_font_list() -> Vec<String> {
|
||||
let source = SystemSource::new();
|
||||
let mut font_families = HashSet::new();
|
||||
|
||||
if let Ok(fonts) = source.all_fonts() {
|
||||
for font in fonts {
|
||||
if let Ok(info) = font.load() {
|
||||
font_families.insert(info.family_name().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
font_families.into_iter().collect()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn download_zip_asset(url: String) -> Result<String, String> {
|
||||
use reqwest;
|
||||
// reqwest のクライアントを作成
|
||||
let client = reqwest::Client::new();
|
||||
// GET リクエストを送信(リダイレクトも自動追従します)
|
||||
let resp = client.get(&url)
|
||||
.header("Accept", "application/octet-stream")
|
||||
.send()
|
||||
.await.map_err(|e| format!("Request error: {}", e))?;
|
||||
if !resp.status().is_success() {
|
||||
return Err(format!("HTTP error: {}", resp.status()));
|
||||
}
|
||||
// レスポンスのバイナリデータを取得
|
||||
let bytes = resp.bytes().await.map_err(|e| format!("Reading bytes error: {}", e))?;
|
||||
// バイナリデータを base64 エンコードして返す
|
||||
Ok(base64::encode(&bytes))
|
||||
}
|
||||
@@ -1,62 +1,16 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "VRCT",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.vrct.app",
|
||||
"build": {
|
||||
"beforeDevCommand": "",
|
||||
"devUrl": "http://localhost:1420",
|
||||
"beforeBuildCommand": "",
|
||||
"devPath": "http://localhost:1420",
|
||||
"distDir": "../dist"
|
||||
"frontendDist": "../dist"
|
||||
},
|
||||
"package": {
|
||||
"productName": "VRCT",
|
||||
"version": "3.0.0"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
"all": false,
|
||||
"window": {
|
||||
"all": false,
|
||||
"setAlwaysOnTop": true,
|
||||
"setFocus": true,
|
||||
"setDecorations": true,
|
||||
"close": true,
|
||||
"hide": true,
|
||||
"setPosition": true,
|
||||
"setSize": true,
|
||||
"maximize": true,
|
||||
"minimize": true,
|
||||
"unmaximize": true,
|
||||
"unminimize": true,
|
||||
"startDragging": true
|
||||
},
|
||||
"globalShortcut": {
|
||||
"all": true
|
||||
},
|
||||
"fs": {
|
||||
"readDir": true,
|
||||
"readFile": true,
|
||||
"exists": true,
|
||||
"writeFile": true,
|
||||
"createDir": true,
|
||||
"removeDir": true,
|
||||
"scope": ["$RESOURCE/**", "**/src-tauri/target/debug/plugins/**"]
|
||||
},
|
||||
"http": {
|
||||
"request": true,
|
||||
"scope": [
|
||||
"https://api.github.com/repos/**",
|
||||
"https://github.com/**",
|
||||
"https://raw.githubusercontent.com/ShiinaSakamoto/vrct_plugins_list/main/vrct_plugins_list.json",
|
||||
"https://raw.githubusercontent.com/ShiinaSakamoto/vrct_plugins_list/main/dev_vrct_plugins_list.json"
|
||||
]
|
||||
},
|
||||
"shell": {
|
||||
"all": false,
|
||||
"open": true,
|
||||
"sidecar": true,
|
||||
"scope": [
|
||||
{ "name": "bin/VRCT-sidecar", "sidecar": true, "args": true }
|
||||
]
|
||||
}
|
||||
},
|
||||
"app": {
|
||||
"enableGTKAppId": false,
|
||||
"windows": [{
|
||||
"title": "VRCT",
|
||||
"center": true,
|
||||
@@ -65,37 +19,40 @@
|
||||
"minWidth": 400,
|
||||
"minHeight": 200,
|
||||
"transparent": true,
|
||||
"decorations": false
|
||||
"decorations": false,
|
||||
"shadow": false
|
||||
}],
|
||||
"security": { "csp": null },
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "nsis",
|
||||
"identifier": "com.vrct.dev",
|
||||
"publisher": "m's software",
|
||||
"copyright": "Copyright m's software",
|
||||
"shortDescription": "VRCT",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"externalBin": [
|
||||
"bin/VRCT-sidecar"
|
||||
],
|
||||
"resources": {
|
||||
"bin/_internal": "_internal",
|
||||
"plugins": "plugins"
|
||||
},
|
||||
"windows": {
|
||||
"nsis": {
|
||||
"template": "nsis/template.nsi",
|
||||
"license": "../LICENSE",
|
||||
"installMode": "currentUser",
|
||||
"displayLanguageSelector": true
|
||||
}
|
||||
"security": {
|
||||
"csp": null,
|
||||
"capabilities": ["default", "vrct-capability"]
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "nsis",
|
||||
"publisher": "m's software",
|
||||
"copyright": "Copyright m's software",
|
||||
"licenseFile": "../LICENSE",
|
||||
"shortDescription": "VRCT",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"externalBin": [
|
||||
"bin/VRCT-sidecar"
|
||||
],
|
||||
"resources": {
|
||||
"bin/_internal": "_internal",
|
||||
"plugins": "plugins"
|
||||
},
|
||||
"windows": {
|
||||
"nsis": {
|
||||
"template": "nsis/template.nsi",
|
||||
"installMode": "currentUser",
|
||||
"displayLanguageSelector": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user