Skip to content

Commit 3b68e1b

Browse files
author
Googlefan
committed
refactor: remove unused dependencies and update open function
1 parent 276a309 commit 3b68e1b

File tree

5 files changed

+26
-38
lines changed

5 files changed

+26
-38
lines changed

src-tauri/Cargo.lock

Lines changed: 0 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ anyhow = "1.0.87"
2121
tokio = { version = "1.40.0", features = ["sync"] }
2222
hf-hub = "0.3.2"
2323
ort = { git = "https://github.com/pykeio/ort.git", version = "2.0.0-rc.6" }
24-
whoami = "1.5.2"
2524
open = "5.3.0"
2625

2726
[features]
@@ -31,4 +30,4 @@ custom-protocol = ["tauri/custom-protocol"]
3130
[profile.release]
3231
lto = true
3332
debug = false
34-
strip = true
33+
strip = true

src-tauri/src/main.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ use std::env;
66
use hf_hub::api::sync::Api;
77

88
#[tauri::command]
9-
fn open() {
10-
open::that(format!(
11-
"C:/Users/{}/AppData/Local/sbv2-gui/models",
12-
whoami::username()
13-
))
14-
.ok();
9+
fn open() -> Result<(), String> {
10+
let dir = env::current_dir().map_err(|e| e.to_string())?;
11+
open::that(dir.join("models")).ok();
12+
Ok(())
13+
}
14+
15+
#[tauri::command]
16+
fn path() -> Result<String, String> {
17+
env::current_dir()
18+
.map(|p| p.to_string_lossy().to_string())
19+
.map_err(|e| e.to_string())
1520
}
1621

1722
fn main() {
@@ -38,6 +43,7 @@ fn main() {
3843
tts::synthesize,
3944
tts::models,
4045
open,
46+
path,
4147
])
4248
.run(tauri::generate_context!())
4349
.expect("error while running tauri application");

src/App.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useState } from "react";
2-
import { reloadModels, getModels, synthesize, open } from "./typing";
2+
import { reloadModels, getModels, synthesize, open, getPath } from "./typing";
33
import { Button } from "~/components/ui/button";
44
import {
55
Select,
@@ -22,7 +22,15 @@ function App() {
2222
const [inSynthesize, setInSynthesize] = useState(false);
2323
const [audio, setAudio] = useState<string | null>(null);
2424
const [error, setError] = useState<string | null>(null);
25+
const [path, setPath] = useState<string | null>(null);
2526
useEffect(() => {
27+
(async () => {
28+
try {
29+
setPath(await getPath());
30+
} catch (e) {
31+
setError(String(e));
32+
}
33+
})();
2634
(async () => {
2735
setReloading(true);
2836
try {
@@ -65,7 +73,7 @@ function App() {
6573
<p className="text-lg">
6674
モデルを
6775
<a className="text-slate-600" onClick={() => open()}>
68-
~/AppData/Local/sbv2-gui/models
76+
{path}
6977
</a>
7078
に配置してください。
7179
</p>

src/typing.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export async function reloadModels() {
77
export async function getModels(): Promise<string[]> {
88
return invoke("models");
99
}
10+
export async function getPath(): Promise<string> {
11+
return invoke("path");
12+
}
1013

1114
export async function synthesize(
1215
ident: string,

0 commit comments

Comments
 (0)