juc500 정상동작

This commit is contained in:
Macbook
2026-07-21 21:04:25 +09:00
parent ff60cee1cc
commit 1388668b56
2917 changed files with 708021 additions and 651 deletions
+24
View File
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+3
View File
@@ -0,0 +1,3 @@
{
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
}
+49
View File
@@ -0,0 +1,49 @@
# JUC500 Tauri Shell
케이블(`0711:7500` / `0711:700x`) 연결 시 Python 백엔드와 GUI를 자동으로 띄우는 데스크톱 셸입니다.
## 구조
```
Tauri (Rust) Python (juc500_xfer)
USB 감시 (rusb) → juc500_app.py --backend
트레이 아이콘 HTTP :8765
WebView ──────────→ 기존 static UI
```
## 빌드
```bash
cd juc500-app
npm install
npm run tauri build
```
산출물: `src-tauri/target/release/juc500-app` (macOS: `bundle/macos/JUC500.app`)
## 실행
프로젝트 루트에서:
```bash
./start.sh # Tauri 빌드가 있으면 자동 사용
./scripts/launch_tauri.sh
```
브라우저 모드(구버전): `JUC500_LEGACY_GUI=1 ./start.sh`
## 로그인 시 자동 실행 (케이블만 꽂아도 GUI)
**macOS**
```bash
./scripts/install_autolaunch_macos.sh
```
**Windows** (Tauri 빌드 후)
```bat
scripts\install_autolaunch_windows.bat
```
트레이 감시 앱이 로그인 시 뜨고, 케이블 연결 시 GUI가 열립니다.
+232
View File
@@ -0,0 +1,232 @@
{
"name": "juc500-app",
"version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "juc500-app",
"version": "0.1.0",
"devDependencies": {
"@tauri-apps/cli": "^2"
}
},
"node_modules/@tauri-apps/cli": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli/-/cli-2.11.4.tgz",
"integrity": "sha512-R8xGtMpwyetawSqm9kYOuMmEqkhUbvcUy8n0aNXIxollKBLESUu5f4Fx+64hgASYm1H+jSWq6jCW6zqTnH6hqQ==",
"dev": true,
"license": "Apache-2.0 OR MIT",
"bin": {
"tauri": "tauri.js"
},
"engines": {
"node": ">= 10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/tauri"
},
"optionalDependencies": {
"@tauri-apps/cli-darwin-arm64": "2.11.4",
"@tauri-apps/cli-darwin-x64": "2.11.4",
"@tauri-apps/cli-linux-arm-gnueabihf": "2.11.4",
"@tauri-apps/cli-linux-arm64-gnu": "2.11.4",
"@tauri-apps/cli-linux-arm64-musl": "2.11.4",
"@tauri-apps/cli-linux-riscv64-gnu": "2.11.4",
"@tauri-apps/cli-linux-x64-gnu": "2.11.4",
"@tauri-apps/cli-linux-x64-musl": "2.11.4",
"@tauri-apps/cli-win32-arm64-msvc": "2.11.4",
"@tauri-apps/cli-win32-ia32-msvc": "2.11.4",
"@tauri-apps/cli-win32-x64-msvc": "2.11.4"
}
},
"node_modules/@tauri-apps/cli-darwin-arm64": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.11.4.tgz",
"integrity": "sha512-1ryOF3ZhpZ/nemHV5zVwBQBz9jDGKmKPvWPADOhc83ig0P4bMc2iER4NbC6r9sjeIZ6RVQ4g3RZIYvezhcl4TQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-darwin-x64": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.11.4.tgz",
"integrity": "sha512-uFsGQAAfuyz1k/yGLmkWfkBlgKAqZfxqlHmLWx81QU27RJWfmbNHCIq8T8w1e+VClleIuZUjpHWfoE4E3DLo3A==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm-gnueabihf": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.11.4.tgz",
"integrity": "sha512-IaHZn5CdBL21oUmjiVOS1ctw6Ip1O0pjp70FwOWmYz1myWe0SY96ZIj2FYf7pT0m8bI2h/hrs5ZbEXXh44/MkQ==",
"cpu": [
"arm"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-gnu": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.11.4.tgz",
"integrity": "sha512-N41/ukTRVe6XSuUTESuFdGeOW2i7k62tK+6gHK5Kd5/q5RPvvi19GaWAVPPb9u95HSGmTChSolBfzynUsssFaA==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-arm64-musl": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.11.4.tgz",
"integrity": "sha512-v277UnT/fB64xAfSroL5N3Km3tLmvATWqJJw/wRI+g6o+HkeD0slyE7gOhNs1MbjE41R7bQOTxMVoL3aomUJmw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-riscv64-gnu": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-riscv64-gnu/-/cli-linux-riscv64-gnu-2.11.4.tgz",
"integrity": "sha512-qqgNkQ2u1yZHxjhxsZaxUtRDW8dIqIYm33rx/mzwQv0SfY9x1B+iraj8vWeFiXjjSVVhEMepXSOts1TqPzvXNQ==",
"cpu": [
"riscv64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-gnu": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.11.4.tgz",
"integrity": "sha512-2VRNWl84FOH0m2giiDkO2h0QXlcMJeX+zJDpI5kDIQAx6s+geF3v48F4DXfJez4GS/FdoDGnPnw1C2iYGbQ7bQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-linux-x64-musl": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.11.4.tgz",
"integrity": "sha512-o9GyhYor/nc7xarmwDE3ka2szuW3uuZzXjHWh64Q8YX5AtSgxdQkFWzrY4O8KiGtVNvFBI14H3Q49Qj5TOIP/A==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-arm64-msvc": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.11.4.tgz",
"integrity": "sha512-ld5Ehb598m0VkYyylRPNeCFsBe/km0jxis6KgMpl3IGY6I/i1RwQXO05I1AsXUXO2WC6AvB/Lw4qTf/asiuEiQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-ia32-msvc": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.11.4.tgz",
"integrity": "sha512-12Hxi0XX/H5VFxO/bGgHkFWhml9VMgEOu9CidjeCeTNQ1l6fpUlbiGgSP7CLI3PFtW9/FfbeHieZ+kyWK5H7CA==",
"cpu": [
"ia32"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@tauri-apps/cli-win32-x64-msvc": {
"version": "2.11.4",
"resolved": "https://registry.npmjs.org/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.11.4.tgz",
"integrity": "sha512-+vDiqBIU5dMISg/wNvX3sF+ZHfgJGJ5T0AcO+EHNXV9GGAG+P5fzodlDXD3QdKCRgZxMoCm5PPvj3BqLNjBthw==",
"cpu": [
"x64"
],
"dev": true,
"license": "Apache-2.0 OR MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
}
}
}
}
+12
View File
@@ -0,0 +1,12 @@
{
"name": "juc500-app",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"tauri": "tauri"
},
"devDependencies": {
"@tauri-apps/cli": "^2"
}
}
+7
View File
@@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas
+4918
View File
File diff suppressed because it is too large Load Diff
+20
View File
@@ -0,0 +1,20 @@
[package]
name = "juc500-app"
version = "0.1.0"
description = "JUC500/JUC700 Tauri shell — cable plug auto-launch"
authors = ["juc500"]
edition = "2021"
[lib]
name = "juc500_app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = ["tray-icon"] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
rusb = "0.9"
+3
View File
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
@@ -0,0 +1,16 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "JUC500 main capability",
"windows": ["main", "splash"],
"permissions": [
"core:default",
"core:window:allow-create",
"core:window:allow-show",
"core:window:allow-hide",
"core:window:allow-close",
"core:window:allow-set-focus",
"core:tray:default",
"opener:default"
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#fff</color>
</resources>
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

+117
View File
@@ -0,0 +1,117 @@
use std::net::{SocketAddr, TcpStream};
use std::path::{Path, PathBuf};
use std::process::{Child, Command, Stdio};
use std::time::{Duration, Instant};
pub const GUI_PORT: u16 = 8765;
/// Project root containing `juc500_app.py` (parent of `juc500-app/` in dev).
pub fn project_root() -> PathBuf {
if let Ok(root) = std::env::var("JUC500_ROOT") {
let p = PathBuf::from(root);
if p.join("juc500_app.py").is_file() {
return p;
}
}
if let Ok(cwd) = std::env::current_dir() {
if cwd.join("juc500_app.py").is_file() {
return cwd;
}
let parent = cwd.parent().map(Path::to_path_buf);
if let Some(ref p) = parent {
if p.join("juc500_app.py").is_file() {
return p.clone();
}
}
}
if let Ok(exe) = std::env::current_exe() {
let mut dir = exe.parent().map(Path::to_path_buf);
for _ in 0..10 {
let Some(ref d) = dir else { break };
if d.join("juc500_app.py").is_file() {
return d.clone();
}
if d.join("..").join("juc500_app.py").exists() {
if let Ok(canon) = d.join("..").canonicalize() {
if canon.join("juc500_app.py").is_file() {
return canon;
}
}
}
dir = d.parent().map(Path::to_path_buf);
}
}
PathBuf::from(".")
}
pub fn resolve_python(root: &Path) -> PathBuf {
if cfg!(windows) {
let venv = root.join(".venv").join("Scripts").join("python.exe");
if venv.is_file() {
return venv;
}
} else {
let venv = root.join(".venv").join("bin").join("python");
if venv.is_file() {
return venv;
}
}
if cfg!(windows) {
PathBuf::from("python")
} else {
PathBuf::from("python3")
}
}
pub fn kill_wormhole(root: &Path) {
let py = resolve_python(root);
let _ = Command::new(&py)
.current_dir(root)
.env("PYTHONPATH", root)
.args([
"-c",
"from juc500_xfer.wormhole_kill import kill_wormhole_processes; \
kill_wormhole_processes(force=True)",
])
.stdout(Stdio::null())
.stderr(Stdio::null())
.status();
}
pub fn backend_running(port: u16) -> bool {
let addr: SocketAddr = format!("127.0.0.1:{}", port).parse().unwrap();
TcpStream::connect_timeout(&addr, Duration::from_millis(200)).is_ok()
}
pub fn wait_backend(port: u16, timeout: Duration) -> bool {
let deadline = Instant::now() + timeout;
while Instant::now() < deadline {
if backend_running(port) {
return true;
}
std::thread::sleep(Duration::from_millis(200));
}
false
}
pub fn start_backend(root: &Path) -> std::io::Result<Child> {
kill_wormhole(root);
let py = resolve_python(root);
let app = root.join("juc500_app.py");
Command::new(&py)
.current_dir(root)
.env("PYTHONPATH", root)
.env("JUC500_TAURI", "1")
.arg(&app)
.arg("--backend")
.stdout(Stdio::null())
.stderr(Stdio::piped())
.spawn()
}
pub fn stop_backend(child: &mut Option<Child>) {
if let Some(mut c) = child.take() {
let _ = c.kill();
let _ = c.wait();
}
}
+279
View File
@@ -0,0 +1,279 @@
mod backend;
mod usb;
use std::sync::Mutex;
use std::time::Duration;
use tauri::{
menu::{Menu, MenuItem},
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
ActivationPolicy, AppHandle, Manager, RunEvent, State, WebviewUrl, WebviewWindowBuilder,
};
use tauri_plugin_opener::OpenerExt;
const MAIN_LABEL: &str = "main";
const SPLASH_LABEL: &str = "splash";
fn cable_autolaunch_enabled() -> bool {
std::env::var("JUC500_CABLE_AUTOLAUNCH")
.map(|v| {
matches!(
v.trim().to_lowercase().as_str(),
"1" | "true" | "yes" | "on"
)
})
.unwrap_or(false)
}
struct AppState {
backend: Option<std::process::Child>,
cable_was_present: bool,
window_open: bool,
}
impl AppState {
fn new() -> Self {
Self {
backend: None,
cable_was_present: usb::cable_present(),
window_open: false,
}
}
}
fn set_dock_visible(app: &AppHandle, visible: bool) {
#[cfg(target_os = "macos")]
{
let policy = if visible {
ActivationPolicy::Regular
} else {
ActivationPolicy::Accessory
};
let _ = app.set_activation_policy(policy);
}
}
fn show_splash(app: &AppHandle) {
if app.get_webview_window(SPLASH_LABEL).is_some() {
return;
}
let _ = WebviewWindowBuilder::new(app, SPLASH_LABEL, WebviewUrl::App("index.html".into()))
.title("JUC500")
.inner_size(420.0, 220.0)
.resizable(false)
.center()
.build();
}
fn close_splash(app: &AppHandle) {
if let Some(w) = app.get_webview_window(SPLASH_LABEL) {
let _ = w.close();
}
}
fn show_main_window(app: &AppHandle) -> Result<(), String> {
let url = format!("http://127.0.0.1:{}/", backend::GUI_PORT);
if let Some(w) = app.get_webview_window(MAIN_LABEL) {
let _ = w.show();
let _ = w.set_focus();
close_splash(app);
set_dock_visible(app, true);
return Ok(());
}
WebviewWindowBuilder::new(
app,
MAIN_LABEL,
WebviewUrl::External(
url.parse()
.map_err(|e| format!("invalid GUI url: {e}"))?,
),
)
.title("JUC500")
.inner_size(1280.0, 820.0)
.min_inner_size(900.0, 600.0)
.center()
.build()
.map_err(|e| e.to_string())?;
close_splash(app);
set_dock_visible(app, true);
Ok(())
}
fn hide_main_window(app: &AppHandle) {
if let Some(w) = app.get_webview_window(MAIN_LABEL) {
let _ = w.hide();
}
set_dock_visible(app, false);
}
fn ensure_backend(state: &State<'_, Mutex<AppState>>) -> Result<(), String> {
let root = backend::project_root();
if !root.join("juc500_app.py").is_file() {
return Err(format!(
"juc500_app.py 없음 (JUC500_ROOT={})",
root.display()
));
}
let mut guard = state.lock().map_err(|e| e.to_string())?;
if backend::backend_running(backend::GUI_PORT) {
return Ok(());
}
backend::stop_backend(&mut guard.backend);
let child = backend::start_backend(&root).map_err(|e| e.to_string())?;
guard.backend = Some(child);
drop(guard);
if !backend::wait_backend(backend::GUI_PORT, Duration::from_secs(45)) {
return Err("Python 백엔드 기동 시간 초과 (./scripts/setup_macos.sh 확인)".into());
}
Ok(())
}
fn stop_all(app: &AppHandle, state: &State<'_, Mutex<AppState>>) {
hide_main_window(app);
if let Ok(mut guard) = state.lock() {
guard.window_open = false;
backend::stop_backend(&mut guard.backend);
}
}
fn on_cable_present(app: &AppHandle, state: &State<'_, Mutex<AppState>>) {
show_splash(app);
match ensure_backend(state) {
Ok(()) => {
if let Err(e) = show_main_window(app) {
eprintln!("window error: {e}");
close_splash(app);
} else if let Ok(mut guard) = state.lock() {
guard.window_open = true;
}
}
Err(e) => {
eprintln!("backend error: {e}");
close_splash(app);
}
}
}
fn on_cable_absent(app: &AppHandle, state: &State<'_, Mutex<AppState>>) {
stop_all(app, state);
}
fn cable_watch_loop(app: AppHandle) {
std::thread::spawn(move || {
loop {
std::thread::sleep(Duration::from_millis(1500));
let present = usb::cable_present();
let state = app.state::<Mutex<AppState>>();
let Ok(mut guard) = state.lock() else {
continue;
};
let was = guard.cable_was_present;
guard.cable_was_present = present;
drop(guard);
if present && !was {
on_cable_present(&app, &state);
} else if !present && was {
on_cable_absent(&app, &state);
} else if present && was {
// Keep backend alive; reopen window if user closed it but cable still in
if backend::backend_running(backend::GUI_PORT) {
if app.get_webview_window(MAIN_LABEL).is_none() {
let _ = show_main_window(&app);
}
} else {
on_cable_present(&app, &state);
}
}
}
});
}
#[tauri::command]
fn cable_status() -> bool {
usb::cable_present()
}
#[tauri::command]
fn open_gui(state: State<'_, Mutex<AppState>>, app: AppHandle) -> Result<(), String> {
on_cable_present(&app, &state);
Ok(())
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.manage(Mutex::new(AppState::new()))
.setup(|app| {
let show_item = MenuItem::with_id(app, "show", "JUC500 열기", true, None::<&str>)?;
let open_root_item =
MenuItem::with_id(app, "open_root", "프로젝트 폴더", true, None::<&str>)?;
let quit_item = MenuItem::with_id(app, "quit", "종료", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&show_item, &open_root_item, &quit_item])?;
let _tray = TrayIconBuilder::new()
.menu(&menu)
.tooltip("JUC500 — 케이블 연결 시 자동 실행")
.on_menu_event(|app, event| match event.id().as_ref() {
"show" => {
let state = app.state::<Mutex<AppState>>();
on_cable_present(app, &state);
}
"open_root" => {
let root = backend::project_root();
let _ = app.opener().open_path(root.display().to_string(), None::<&str>);
}
"quit" => {
let state = app.state::<Mutex<AppState>>();
stop_all(app, &state);
app.exit(0);
}
_ => {}
})
.on_tray_icon_event(|tray, event| {
if let TrayIconEvent::Click {
button: MouseButton::Left,
button_state: MouseButtonState::Up,
..
} = event
{
let app = tray.app_handle();
let state = app.state::<Mutex<AppState>>();
on_cable_present(&app, &state);
}
})
.build(app)?;
set_dock_visible(app.handle(), false);
// 개발 중: 케이블 감지 자동 실행 비활성 (JUC500_CABLE_AUTOLAUNCH=1 일 때만)
if cable_autolaunch_enabled() {
cable_watch_loop(app.handle().clone());
if usb::cable_present() {
let state = app.state::<Mutex<AppState>>();
on_cable_present(app.handle(), &state);
}
} else {
eprintln!(
"JUC500: 케이블 자동 실행 비활성 (개발 모드). \
./start.sh 로 수동 실행하거나 트레이 메뉴 'JUC500 열기' 사용."
);
}
Ok(())
})
.invoke_handler(tauri::generate_handler![cable_status, open_gui])
.build(tauri::generate_context!())
.expect("error while running tauri application")
.run(|app, event| {
if let RunEvent::ExitRequested { api, .. } = event {
// Keep tray watcher alive when the user closes the window
api.prevent_exit();
hide_main_window(app);
if let Ok(mut guard) = app.state::<Mutex<AppState>>().lock() {
guard.window_open = false;
}
}
});
}
+6
View File
@@ -0,0 +1,6 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
juc500_app_lib::run()
}
+27
View File
@@ -0,0 +1,27 @@
//! JUC500/JUC700 cable presence (VID 0711, PID 7500 or 7000–700F).
const VID: u16 = 0x0711;
const PID_JUC500: u16 = 0x7500;
const PID_JUC700_MIN: u16 = 0x7000;
const PID_JUC700_MAX: u16 = 0x700f;
fn is_juc_cable(vid: u16, pid: u16) -> bool {
vid == VID
&& (pid == PID_JUC500 || (pid >= PID_JUC700_MIN && pid <= PID_JUC700_MAX))
}
/// True when a Smart Data Link / JUC700 DSS composite device is plugged in.
pub fn cable_present() -> bool {
let Ok(devices) = rusb::devices() else {
return false;
};
for device in devices.iter() {
let Ok(desc) = device.device_descriptor() else {
continue;
};
if is_juc_cable(desc.vendor_id(), desc.product_id()) {
return true;
}
}
false
}
+27
View File
@@ -0,0 +1,27 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "JUC500",
"version": "0.1.0",
"identifier": "com.juc500.desktop",
"build": {
"frontendDist": "../src"
},
"app": {
"withGlobalTauri": false,
"windows": [],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="32" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path fill="#F7DF1E" d="M0 0h256v256H0V0Z"></path><path d="m67.312 213.932l19.59-11.856c3.78 6.701 7.218 12.371 15.465 12.371c7.905 0 12.89-3.092 12.89-15.12v-81.798h24.057v82.138c0 24.917-14.606 36.259-35.916 36.259c-19.245 0-30.416-9.967-36.087-21.996m85.07-2.576l19.588-11.341c5.157 8.421 11.859 14.607 23.715 14.607c9.969 0 16.325-4.984 16.325-11.858c0-8.248-6.53-11.17-17.528-15.98l-6.013-2.58c-17.357-7.387-28.87-16.667-28.87-36.257c0-18.044 13.747-31.792 35.228-31.792c15.294 0 26.292 5.328 34.196 19.247l-18.732 12.03c-4.125-7.389-8.591-10.31-15.465-10.31c-7.046 0-11.514 4.468-11.514 10.31c0 7.217 4.468 10.14 14.778 14.608l6.014 2.577c20.45 8.765 31.963 17.7 31.963 37.804c0 21.654-17.012 33.51-39.867 33.51c-22.339 0-36.774-10.654-43.819-24.574"></path></svg>

After

Width:  |  Height:  |  Size: 995 B

+6
View File
@@ -0,0 +1,6 @@
<svg width="206" height="231" viewBox="0 0 206 231" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M143.143 84C143.143 96.1503 133.293 106 121.143 106C108.992 106 99.1426 96.1503 99.1426 84C99.1426 71.8497 108.992 62 121.143 62C133.293 62 143.143 71.8497 143.143 84Z" fill="#FFC131"/>
<ellipse cx="84.1426" cy="147" rx="22" ry="22" transform="rotate(180 84.1426 147)" fill="#24C8DB"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M166.738 154.548C157.86 160.286 148.023 164.269 137.757 166.341C139.858 160.282 141 153.774 141 147C141 144.543 140.85 142.121 140.558 139.743C144.975 138.204 149.215 136.139 153.183 133.575C162.73 127.404 170.292 118.608 174.961 108.244C179.63 97.8797 181.207 86.3876 179.502 75.1487C177.798 63.9098 172.884 53.4021 165.352 44.8883C157.82 36.3744 147.99 30.2165 137.042 27.1546C126.095 24.0926 114.496 24.2568 103.64 27.6274C92.7839 30.998 83.1319 37.4317 75.8437 46.1553C74.9102 47.2727 74.0206 48.4216 73.176 49.5993C61.9292 50.8488 51.0363 54.0318 40.9629 58.9556C44.2417 48.4586 49.5653 38.6591 56.679 30.1442C67.0505 17.7298 80.7861 8.57426 96.2354 3.77762C111.685 -1.01901 128.19 -1.25267 143.769 3.10474C159.348 7.46215 173.337 16.2252 184.056 28.3411C194.775 40.457 201.767 55.4101 204.193 71.404C206.619 87.3978 204.374 103.752 197.73 118.501C191.086 133.25 180.324 145.767 166.738 154.548ZM41.9631 74.275L62.5557 76.8042C63.0459 72.813 63.9401 68.9018 65.2138 65.1274C57.0465 67.0016 49.2088 70.087 41.9631 74.275Z" fill="#FFC131"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38.4045 76.4519C47.3493 70.6709 57.2677 66.6712 67.6171 64.6132C65.2774 70.9669 64 77.8343 64 85.0001C64 87.1434 64.1143 89.26 64.3371 91.3442C60.0093 92.8732 55.8533 94.9092 51.9599 97.4256C42.4128 103.596 34.8505 112.392 30.1816 122.756C25.5126 133.12 23.9357 144.612 25.6403 155.851C27.3449 167.09 32.2584 177.598 39.7906 186.112C47.3227 194.626 57.153 200.784 68.1003 203.846C79.0476 206.907 90.6462 206.743 101.502 203.373C112.359 200.002 122.011 193.568 129.299 184.845C130.237 183.722 131.131 182.567 131.979 181.383C143.235 180.114 154.132 176.91 164.205 171.962C160.929 182.49 155.596 192.319 148.464 200.856C138.092 213.27 124.357 222.426 108.907 227.222C93.458 232.019 76.9524 232.253 61.3736 227.895C45.7948 223.538 31.8055 214.775 21.0867 202.659C10.3679 190.543 3.37557 175.59 0.949823 159.596C-1.47592 143.602 0.768139 127.248 7.41237 112.499C14.0566 97.7497 24.8183 85.2327 38.4045 76.4519ZM163.062 156.711L163.062 156.711C162.954 156.773 162.846 156.835 162.738 156.897C162.846 156.835 162.954 156.773 163.062 156.711Z" fill="#24C8DB"/>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

+16
View File
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>JUC500</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body class="splash-body">
<div class="splash">
<h1>JUC500</h1>
<p>케이블 연결 감지 — 백엔드 시작 중…</p>
<p class="muted">트레이 아이콘에서 언제든 열 수 있습니다.</p>
</div>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
const { invoke } = window.__TAURI__.core;
let greetInputEl;
let greetMsgEl;
async function greet() {
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value });
}
window.addEventListener("DOMContentLoaded", () => {
greetInputEl = document.querySelector("#greet-input");
greetMsgEl = document.querySelector("#greet-msg");
document.querySelector("#greet-form").addEventListener("submit", (e) => {
e.preventDefault();
greet();
});
});
+15
View File
@@ -0,0 +1,15 @@
* { box-sizing: border-box; }
body.splash-body {
margin: 0;
font-family: -apple-system, "Segoe UI", "Apple SD Gothic Neo", sans-serif;
background: linear-gradient(180deg, #e8ebef 0%, #c9d1d8 100%);
color: #1c1c1e;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.splash { text-align: center; padding: 24px; }
.splash h1 { margin: 0 0 8px; font-size: 1.6rem; }
.splash p { margin: 6px 0; }
.muted { color: #6b7280; font-size: 0.9rem; }