chore: compatible with macos

This commit is contained in:
GyDi 2021-12-06 10:31:17 +08:00
parent e22470969e
commit f320d515d5
9 changed files with 34 additions and 25 deletions

7
.editorconfig Normal file
View File

@ -0,0 +1,7 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
insert_final_newline = true

View File

@ -4,9 +4,9 @@
"scripts": {
"dev": "tauri dev",
"build": "tauri build",
"web:dev": "vite",
"web:build": "tsc && vite build",
"web:serve": "vite preview"
"web:dev": "parcel src/index.html -p 3000",
"web:build": "parcel build",
"tauri": "tauri"
},
"dependencies": {
"@emotion/react": "^11.7.0",
@ -19,12 +19,12 @@
"react-router-dom": "^6.0.2"
},
"devDependencies": {
"@parcel/transformer-sass": "^2.0.1",
"@tauri-apps/cli": "^1.0.0-beta.10",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@vitejs/plugin-react": "^1.0.0",
"parcel": "^2.0.1",
"sass": "^1.44.0",
"typescript": "^4.5.2",
"vite": "^2.6.14"
"typescript": "^4.5.2"
}
}

View File

@ -9,8 +9,6 @@ default-run = "app"
edition = "2021"
build = "src/build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.0.0-beta.4" }
@ -20,10 +18,12 @@ serde_json = "1.0"
serde_yaml = "0.8"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0-beta.8", features = ["api-all", "system-tray"] }
winreg = { version = "0.10", features = ["transactions"] }
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1", features = ["full"] }
[target.'cfg(windows)'.dependencies]
winreg = { version = "0.10", features = ["transactions"] }
[features]
default = [ "custom-protocol" ]
custom-protocol = [ "tauri/custom-protocol" ]

View File

@ -19,13 +19,15 @@ async fn get_config_data(url: String) -> Result<String, String> {
}
fn main() -> std::io::Result<()> {
let config = sysopt::get_proxy_config()?;
println!("{:?}", config);
clash::run_clash_bin(&clash::get_config_dir().to_str().unwrap());
let app = tauri::Builder::default()
.system_tray(
SystemTray::new()
.with_menu(SystemTrayMenu::new().add_item(CustomMenuItem::new("tray_event_quit", "Quit"))),
SystemTray::new().with_menu(
SystemTrayMenu::new()
.add_item(CustomMenuItem::new("event_show", "Show"))
.add_item(CustomMenuItem::new("event_quit", "Quit")),
),
)
.on_system_tray_event(move |app, event| match event {
SystemTrayEvent::LeftClick { .. } => {
@ -35,7 +37,12 @@ fn main() -> std::io::Result<()> {
}
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
"tray_event_quit" => {
"event_show" => {
let window = app.get_window("main").unwrap();
window.show().unwrap();
window.set_focus().unwrap();
}
"event_quit" => {
app.exit(0);
}
_ => {}

View File

@ -1,6 +1,9 @@
use serde::{Deserialize, Serialize};
use std::io;
#[cfg(target_os = "windows")]
use winreg::enums::*;
#[cfg(target_os = "windows")]
use winreg::RegKey;
#[derive(Debug, Deserialize, Serialize)]

View File

@ -26,7 +26,7 @@
"icons/icon.ico"
],
"resources": [],
"externalBin": ["bin/clash"],
"externalBin": ["sidebar/clash"],
"copyright": "",
"category": "DeveloperTool",
"shortDescription": "",

View File

@ -7,10 +7,10 @@
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
/>
<title>Vite App</title>
<title>Clash Verge</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script type="module" src="./main.tsx"></script>
</body>
</html>

1
src/vite-env.d.ts vendored
View File

@ -1 +0,0 @@
/// <reference types="vite/client" />

View File

@ -1,7 +0,0 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
});