feat: professional settings header, export, folder and reset
This commit is contained in:
parent
4e8ace1c68
commit
3609eddfc4
2 changed files with 107 additions and 0 deletions
|
|
@ -1439,6 +1439,27 @@ fn open_download_page() -> Result<(), String> {
|
||||||
updater::open_download_page()
|
updater::open_download_page()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn open_data_folder() -> Result<(), String> {
|
||||||
|
let path = engine::app_data_dir();
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
{
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
let mut command = std::process::Command::new("explorer.exe");
|
||||||
|
command.arg(path).stdin(std::process::Stdio::null());
|
||||||
|
command.creation_flags(0x0800_0000);
|
||||||
|
command
|
||||||
|
.spawn()
|
||||||
|
.map_err(|e| format!("Ayar klasörü açılamadı: {e}"))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
{
|
||||||
|
let _ = path;
|
||||||
|
Err("Bu platformda desteklenmiyor.".to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn prepare_for_update(state: State<'_, AppState>) -> Result<(), String> {
|
fn prepare_for_update(state: State<'_, AppState>) -> Result<(), String> {
|
||||||
// The updater installer replaces files under Program Files. Stop the
|
// The updater installer replaces files under Program Files. Stop the
|
||||||
|
|
@ -2449,6 +2470,7 @@ pub fn run() {
|
||||||
connect_eduroam_wifi,
|
connect_eduroam_wifi,
|
||||||
open_wifi_settings,
|
open_wifi_settings,
|
||||||
open_download_page,
|
open_download_page,
|
||||||
|
open_data_folder,
|
||||||
prepare_for_update,
|
prepare_for_update,
|
||||||
restart_app,
|
restart_app,
|
||||||
connect_without_login,
|
connect_without_login,
|
||||||
|
|
|
||||||
85
src/App.jsx
85
src/App.jsx
|
|
@ -31,6 +31,7 @@ import {
|
||||||
Languages,
|
Languages,
|
||||||
Sparkles,
|
Sparkles,
|
||||||
Server,
|
Server,
|
||||||
|
FolderOpen,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { QRCodeSVG } from "qrcode.react";
|
import { QRCodeSVG } from "qrcode.react";
|
||||||
import { TEXT } from "./i18n";
|
import { TEXT } from "./i18n";
|
||||||
|
|
@ -146,6 +147,7 @@ export default function App() {
|
||||||
const [ports, setPorts] = useState({ proxyPort: 18080, pacPort: 18081 });
|
const [ports, setPorts] = useState({ proxyPort: 18080, pacPort: 18081 });
|
||||||
const [lanWarn, setLanWarn] = useState(false);
|
const [lanWarn, setLanWarn] = useState(false);
|
||||||
const [autostartNote, setAutostartNote] = useState(false);
|
const [autostartNote, setAutostartNote] = useState(false);
|
||||||
|
const [resetArmed, setResetArmed] = useState(false);
|
||||||
const [eduroam, setEduroam] = useState(null);
|
const [eduroam, setEduroam] = useState(null);
|
||||||
const [captive, setCaptive] = useState(null);
|
const [captive, setCaptive] = useState(null);
|
||||||
const [autoBypass, setAutoBypass] = useState(null);
|
const [autoBypass, setAutoBypass] = useState(null);
|
||||||
|
|
@ -584,6 +586,35 @@ export default function App() {
|
||||||
else handleConnect();
|
else handleConnect();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleResetSettings = async () => {
|
||||||
|
if (!resetArmed) {
|
||||||
|
setResetArmed(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setResetArmed(false);
|
||||||
|
const defaults = {
|
||||||
|
autoStart: true,
|
||||||
|
autoConnect: false,
|
||||||
|
minimizeToTray: true,
|
||||||
|
lanSharing: false,
|
||||||
|
captiveAssistant: true,
|
||||||
|
autoOptimize: true,
|
||||||
|
connectionMode: "normal",
|
||||||
|
bypassMode: 1,
|
||||||
|
chunkSize: 4,
|
||||||
|
dohProvider: "auto",
|
||||||
|
quicBlock: false,
|
||||||
|
proxyPort: 18080,
|
||||||
|
pacPort: 18081,
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
await saveConfig(defaults, Boolean(status.isConnected));
|
||||||
|
pushLog("INFO", lang === "tr" ? "Ayarlar varsayılana döndürüldü." : "Settings reset to defaults.");
|
||||||
|
} catch (error) {
|
||||||
|
setLastError(String(error));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleLan = async (enabled) => {
|
const handleLan = async (enabled) => {
|
||||||
if (!config) return;
|
if (!config) return;
|
||||||
setBusy("lan");
|
setBusy("lan");
|
||||||
|
|
@ -1154,6 +1185,60 @@ export default function App() {
|
||||||
{view === "settings" && (
|
{view === "settings" && (
|
||||||
<>
|
<>
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
|
<section className="order-0 mica-card rounded-2xl p-5 space-y-3">
|
||||||
|
<div className="flex items-start justify-between gap-4">
|
||||||
|
<div>
|
||||||
|
<div className="flex items-center gap-2 text-sm font-semibold text-slate-100">
|
||||||
|
<Settings className="w-4 h-4 text-cyan-300" />
|
||||||
|
{lang === "tr" ? "Ayarlar" : "Settings"}
|
||||||
|
<span className="text-[10px] font-mono px-2 py-0.5 rounded-md border border-slate-700 text-slate-400">
|
||||||
|
v{appVersion}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p className="text-[11px] text-slate-400 mt-1">
|
||||||
|
{lang === "tr"
|
||||||
|
? "Değişiklikler otomatik kaydedilir. Bağlantı açıksa gerekli ayarlar yeniden uygulanır."
|
||||||
|
: "Changes save automatically. Active connections are reconfigured when required."}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
<button
|
||||||
|
onClick={() => copyText("settings", JSON.stringify(config, null, 2))}
|
||||||
|
className="flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-slate-700 bg-slate-900/60 text-[11px] text-slate-300 hover:border-cyan-400/40 hover:text-cyan-100"
|
||||||
|
>
|
||||||
|
{copied === "settings" ? <Check className="w-3.5 h-3.5 text-emerald-400" /> : <Copy className="w-3.5 h-3.5" />}
|
||||||
|
{lang === "tr" ? "Ayar JSON'unu kopyala" : "Copy settings JSON"}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => invokeTauri("open_data_folder").catch((e) => setLastError(String(e)))}
|
||||||
|
className="flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-slate-700 bg-slate-900/60 text-[11px] text-slate-300 hover:border-cyan-400/40 hover:text-cyan-100"
|
||||||
|
>
|
||||||
|
<FolderOpen className="w-3.5 h-3.5" />
|
||||||
|
{lang === "tr" ? "Ayar klasörünü aç" : "Open settings folder"}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={handleResetSettings}
|
||||||
|
className={`flex items-center gap-1.5 px-3 py-1.5 rounded-lg border text-[11px] ${
|
||||||
|
resetArmed
|
||||||
|
? "border-amber-400/60 bg-amber-500/15 text-amber-100"
|
||||||
|
: "border-slate-700 bg-slate-900/60 text-slate-300 hover:border-amber-400/40 hover:text-amber-100"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<RotateCcw className="w-3.5 h-3.5" />
|
||||||
|
{resetArmed
|
||||||
|
? lang === "tr" ? "Onayla: varsayılana dön" : "Confirm: reset"
|
||||||
|
: lang === "tr" ? "Varsayılanlara dön" : "Restore defaults"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{resetArmed && (
|
||||||
|
<div className="rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[10px] text-amber-200/90">
|
||||||
|
{lang === "tr"
|
||||||
|
? "Bu işlem otomatik başlatma, DPI, DNS ve port ayarlarını varsayılana döndürür."
|
||||||
|
: "This resets startup, DPI, DNS and port preferences."}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
{vpn?.connected && (
|
{vpn?.connected && (
|
||||||
<div className="rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-200">
|
<div className="rounded-xl border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-200">
|
||||||
VPN açık. DPI ayarları kilitli; değiştirmek için önce VPN sekmesinden bağlantıyı kesin.
|
VPN açık. DPI ayarları kilitli; değiştirmek için önce VPN sekmesinden bağlantıyı kesin.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue