diff --git a/src-tauri/build.rs b/src-tauri/build.rs
index 158c051..36dd018 100644
--- a/src-tauri/build.rs
+++ b/src-tauri/build.rs
@@ -1,3 +1,16 @@
fn main() {
+ #[cfg(target_os = "windows")]
+ {
+ let profile = std::env::var("PROFILE").unwrap_or_default();
+ let mut windows = tauri_build::WindowsAttributes::new();
+ // リリースビルドのみ requireAdministrator マニフェストを適用する。
+ // デバッグビルドで適用すると `cargo run` が os error 740 で失敗するため。
+ if profile == "release" {
+ windows = windows.app_manifest(include_str!("locksun.exe.manifest"));
+ }
+ let attrs = tauri_build::Attributes::new().windows_attributes(windows);
+ tauri_build::try_build(attrs).expect("failed to run tauri-build");
+ return;
+ }
tauri_build::build();
}
diff --git a/src-tauri/locksun.exe.manifest b/src-tauri/locksun.exe.manifest
new file mode 100644
index 0000000..68c93ec
--- /dev/null
+++ b/src-tauri/locksun.exe.manifest
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs
index 2159ba2..b012978 100644
--- a/src-tauri/src/commands/mod.rs
+++ b/src-tauri/src/commands/mod.rs
@@ -8,15 +8,13 @@ use crate::{
};
use chrono::Local;
use serde::{Deserialize, Serialize};
-use std::sync::{Arc, Mutex};
+use std::sync::Arc;
use tauri::State;
use tokio::sync::Notify;
/// アプリ共有状態
pub struct AppState {
pub update_notify: Arc,
- /// 権限エラー通知済みフラグ(重複通知を防ぐ)
- pub permission_notified: Mutex,
}
/// 設定を取得する
@@ -93,7 +91,7 @@ pub async fn preview_image_enhanced() -> Result {
};
// Gemini AI 強化
- let enhanced = crate::gemini::enhance_image(&cfg.gemini, &pos, &png_bytes)
+ let enhanced = crate::gemini::enhance_image(&cfg.gemini, &pos, png_bytes)
.await
.map_err(|e| e.to_string())?;
@@ -151,7 +149,7 @@ pub async fn preview_image_enhanced_with_config(cfg: config::AppConfig) -> Resul
buf.into_inner()
};
- let enhanced = crate::gemini::enhance_image(&cfg.gemini, &pos, &png_bytes)
+ let enhanced = crate::gemini::enhance_image(&cfg.gemini, &pos, png_bytes)
.await
.map_err(|e| e.to_string())?;
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 3feb605..7728b3c 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -10,7 +10,7 @@ pub mod renderer;
pub mod scheduler;
pub mod sun;
-use std::sync::{Arc, Mutex};
+use std::sync::Arc;
use tauri::{
menu::{Menu, MenuItem},
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
@@ -24,7 +24,6 @@ pub fn run() {
tauri::Builder::default()
.manage(commands::AppState {
update_notify: Arc::new(tokio::sync::Notify::new()),
- permission_notified: Mutex::new(false),
})
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_autostart::init(
@@ -87,15 +86,6 @@ pub fn run() {
})
.build(app)?;
- // 起動時権限チェック: 管理者権限がなければトレイツールチップに警告を設定する
- #[cfg(target_os = "windows")]
- if !lockscreen::check_permission() {
- log::warn!("管理者権限なし: ロックスクリーンを変更できません");
- let _ = _tray.set_tooltip(Some("⚠️ Locksun: 管理者権限が必要です"));
- let state = app.state::();
- *state.permission_notified.lock().unwrap() = true;
- }
-
// スケジューラーをバックグラウンドで開始
let app_handle = app.handle().clone();
tauri::async_runtime::spawn(async move {
diff --git a/src-tauri/src/scheduler/mod.rs b/src-tauri/src/scheduler/mod.rs
index e7d3757..7a5b16f 100644
--- a/src-tauri/src/scheduler/mod.rs
+++ b/src-tauri/src/scheduler/mod.rs
@@ -17,28 +17,7 @@ pub async fn start(app: AppHandle) {
loop {
if let Err(e) = run_once(&app).await {
- // Windows のみ: 権限エラーを検知してトレイ通知する(1回のみ)
- #[cfg(target_os = "windows")]
- {
- if !lockscreen::check_permission() {
- log::warn!("権限エラーを検出: {e:#}");
- let state = app.state::();
- let mut notified = state.permission_notified.lock().unwrap();
- if !*notified {
- *notified = true;
- if let Some(tray) = app.tray_by_id("main") {
- let _ = tray.set_tooltip(Some("⚠️ Locksun: 管理者権限が必要です"));
- }
- log::warn!("権限エラー: トレイ通知を更新しました");
- }
- } else {
- log::error!("更新サイクルエラー: {e:#}");
- }
- }
- #[cfg(not(target_os = "windows"))]
- {
- log::error!("更新サイクルエラー: {e:#}");
- }
+ log::error!("更新サイクルエラー: {e:#}");
}
let interval = config::load()
@@ -82,7 +61,7 @@ pub async fn run_once_with_config(app: &AppHandle, cfg: &config::AppConfig) -> a
// Gemini AI 強化が有効な場合は画像を加工する(失敗時はベース画像にフォールバック)
let final_bytes = if cfg.gemini.enabled && !cfg.gemini.api_key.is_empty() {
- match gemini::enhance_image(&cfg.gemini, &pos, &base_png).await {
+ match gemini::enhance_image(&cfg.gemini, &pos, base_png.clone()).await {
Ok(enhanced_bytes) => {
log::info!("Gemini AI 強化済み画像を保存しました");
enhanced_bytes