Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0b2cf63d1 | ||
|
|
079fdd512c | ||
|
|
413376d3f3 |
No files matched your search
@@ -6,3 +6,6 @@ resolver = "3"
|
|||||||
lto = true
|
lto = true
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
strip = true
|
strip = true
|
||||||
|
# debug = true # keep symbols
|
||||||
|
# lto = false # disable LTO
|
||||||
|
# opt-level = 1 # reduce but don't maximize optimization
|
||||||
|
After Width: | Height: | Size: 2.0 MiB |
@@ -0,0 +1,75 @@
|
|||||||
|
import sharp from "sharp";
|
||||||
|
import { spawnSync } from "child_process";
|
||||||
|
|
||||||
|
async function resizeAndMakeWhiteTransparent(inputPath, outputPath) {
|
||||||
|
const whiteThreshold = 250; // treat >= as white
|
||||||
|
const img = sharp(inputPath).ensureAlpha();
|
||||||
|
|
||||||
|
// Get metadata to compute resize dimensions preserving aspect ratio
|
||||||
|
const meta = await img.metadata();
|
||||||
|
const origW = meta.width || 0;
|
||||||
|
const origH = meta.height || 0;
|
||||||
|
if (!origW || !origH) throw new Error("Unable to read image dimensions");
|
||||||
|
|
||||||
|
const targetW = Math.max(origW, origH);
|
||||||
|
const targetH = targetW;
|
||||||
|
|
||||||
|
// Resize and output raw RGBA buffer
|
||||||
|
const { data, info } = await img
|
||||||
|
.resize(targetW, targetH, { fit: "fill" })
|
||||||
|
.raw()
|
||||||
|
.toBuffer({ resolveWithObject: true });
|
||||||
|
|
||||||
|
const { width: w, height: h, channels } = info; // channels should be 4 (RGBA)
|
||||||
|
if (channels < 3) throw new Error("Unexpected channel count");
|
||||||
|
|
||||||
|
// Check if image already has any transparency
|
||||||
|
let hasTransparency = false;
|
||||||
|
for (let i = 0; i < data.length; i += channels) {
|
||||||
|
if (data[i + 3] < 255) {
|
||||||
|
hasTransparency = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasTransparency) {
|
||||||
|
// Modify alpha for near-white pixels
|
||||||
|
for (let i = 0; i < data.length; i += channels) {
|
||||||
|
const r = data[i];
|
||||||
|
const g = data[i + 1];
|
||||||
|
const b = data[i + 2];
|
||||||
|
const a = channels === 4 ? data[i + 3] : 255;
|
||||||
|
|
||||||
|
if (
|
||||||
|
a > 0 &&
|
||||||
|
r >= whiteThreshold &&
|
||||||
|
g >= whiteThreshold &&
|
||||||
|
b >= whiteThreshold
|
||||||
|
) {
|
||||||
|
if (channels === 4) data[i + 3] = 0;
|
||||||
|
else {
|
||||||
|
// expand to RGBA if input lacked alpha
|
||||||
|
// create a new buffer would be required; throw for simplicity
|
||||||
|
throw new Error(
|
||||||
|
"Input image missing alpha channel; ensure ensureAlpha() was applied.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recreate and save PNG
|
||||||
|
await sharp(data, { raw: { width: w, height: h, channels } })
|
||||||
|
.png({ compressionLevel: 9 })
|
||||||
|
.toFile(outputPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [, , input] = process.argv;
|
||||||
|
if (!input) {
|
||||||
|
throw new Error(`Input is required: input=${input}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Example usage
|
||||||
|
resizeAndMakeWhiteTransparent(input, "app-icon.png")
|
||||||
|
.then(() => spawnSync("pnpm tauri icon", { shell: true, stdio: "inherit" }))
|
||||||
|
.catch((err) => console.error(err));
|
||||||
@@ -5,21 +5,22 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:desktop": "cross-env RUST_BACKTRACE=1 tauri dev",
|
"dev:desktop": "cross-env RUST_BACKTRACE=1 tauri dev",
|
||||||
"dev:mobile": "cross-env RUST_BACKTRACE=1 tauri dev -c src-tauri/tauri.mobile.conf.json",
|
"dev:mobile": "cross-env RUST_BACKTRACE=1 tauri dev -c src-tauri/tauri.mobile.conf.json",
|
||||||
"dev:android": "cross-env RUST_BACKTRACE=1 tauri android dev",
|
"dev:android": "cross-env RUST_BACKTRACE=1 tauri android run",
|
||||||
"log:android": "adb logcat -e \"RustStdoutStderr\"",
|
"dev:android:server": "cross-env RUST_BACKTRACE=1 tauri android dev",
|
||||||
|
"dev:android:install": "adb install -r src-tauri/gen/android/app/build/outputs/apk/arm64/debug/app-arm64-debug.apk",
|
||||||
|
"dev:android:build": "tauri android build --debug",
|
||||||
|
"dev:android:log": "adb logcat -e \"RustStdoutStderr\"",
|
||||||
"build:desktop": "tauri build",
|
"build:desktop": "tauri build",
|
||||||
"build:android": "tauri android build",
|
"build:android": "tauri android build",
|
||||||
"install:android": "adb install -r src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk",
|
"install:android": "adb install -r src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk",
|
||||||
"build:android:debug": "tauri android build --debug",
|
|
||||||
"install:android:debug": "adb install -r src-tauri/gen/android/app/build/outputs/apk/universal/debug/app-universal-debug.apk",
|
|
||||||
"run:desktop": ".\\target\\release\\cjdic2.exe",
|
"run:desktop": ".\\target\\release\\cjdic2.exe",
|
||||||
"release": "node release.js",
|
"release": "node release.js",
|
||||||
"dev": "cd src-react && pnpm run dev",
|
"dev": "cd src-react && pnpm run dev",
|
||||||
"build": "cd src-react && pnpm run build",
|
"build": "cd src-react && pnpm run build"
|
||||||
"tauri": "tauri"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tauri-apps/cli": "^2",
|
"@tauri-apps/cli": "^2",
|
||||||
"cross-env": "^10.1.0"
|
"cross-env": "^10.1.0",
|
||||||
|
"sharp": "^0.34.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,9 @@ importers:
|
|||||||
cross-env:
|
cross-env:
|
||||||
specifier: ^10.1.0
|
specifier: ^10.1.0
|
||||||
version: 10.1.0
|
version: 10.1.0
|
||||||
|
sharp:
|
||||||
|
specifier: ^0.34.5
|
||||||
|
version: 0.34.5
|
||||||
|
|
||||||
js-server:
|
js-server:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ mod yomitan;
|
|||||||
pub use yomitan::YomitanRow;
|
pub use yomitan::YomitanRow;
|
||||||
|
|
||||||
mod yomitan_writer;
|
mod yomitan_writer;
|
||||||
pub use yomitan_writer::{YomitanProgress, YomitanWriter, YomitanZipImportResult, ZipSource};
|
pub use yomitan_writer::{YomitanProgress, YomitanWriter, YomitanZipImportResult};
|
||||||
|
|
||||||
use crate::{CJDicError, tokenizer::Tokenizer};
|
use crate::{CJDicError, tokenizer::Tokenizer};
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ use rusqlite::{Connection, OptionalExtension, Result, Transaction, params};
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
env::current_dir,
|
env::current_dir,
|
||||||
fs::{File, create_dir_all},
|
fs::{File, create_dir_all},
|
||||||
io::{self, Cursor, Read},
|
io::{self, Read},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
use zip::ZipArchive;
|
use zip::ZipArchive;
|
||||||
@@ -30,21 +29,6 @@ pub(super) fn normalize_term(s: &str) -> String {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ZipSource {
|
|
||||||
fn file_name(&self) -> &str;
|
|
||||||
fn bytes(&self) -> std::io::Result<Cow<'_, [u8]>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ZipSource for PathBuf {
|
|
||||||
fn file_name(&self) -> &str {
|
|
||||||
Path::file_name(self).and_then(|n| n.to_str()).unwrap_or("")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bytes(&self) -> std::io::Result<Cow<'_, [u8]>> {
|
|
||||||
std::fs::read(self).map(Cow::Owned)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Debug, Clone)]
|
#[derive(Serialize, Debug, Clone)]
|
||||||
pub struct YomitanProgress {
|
pub struct YomitanProgress {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
@@ -446,24 +430,23 @@ impl YomitanWriter {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn import_dictionary_zip_file<Z, Callback>(
|
pub fn import_dictionary_zip_file<Callback>(
|
||||||
&mut self,
|
&mut self,
|
||||||
zip_file: &Z,
|
zip_file: &PathBuf,
|
||||||
asset_dir: &PathBuf,
|
asset_dir: &PathBuf,
|
||||||
lang: &str,
|
lang: &str,
|
||||||
progress_callback: Callback,
|
progress_callback: Callback,
|
||||||
) -> anyhow::Result<YomitanZipImportResult, CJDicError>
|
) -> anyhow::Result<YomitanZipImportResult, CJDicError>
|
||||||
where
|
where
|
||||||
Z: ZipSource,
|
|
||||||
Callback: Fn(YomitanProgress),
|
Callback: Fn(YomitanProgress),
|
||||||
{
|
{
|
||||||
let bundle_name = zip_file.file_name();
|
let bundle_name = zip_file.file_name().and_then(|n| n.to_str()).unwrap_or("");
|
||||||
let _timer = Timer::new(format!("Importing {}", bundle_name));
|
let _timer = Timer::new(format!("Importing {}", bundle_name));
|
||||||
|
|
||||||
self.conn.execute_batch("PRAGMA foreign_keys = off")?;
|
self.conn.execute_batch("PRAGMA foreign_keys = off")?;
|
||||||
|
|
||||||
let cursor = Cursor::new(zip_file.bytes()?);
|
let file = File::open(&zip_file)?;
|
||||||
let mut archive = ZipArchive::new(cursor)?;
|
let mut archive = ZipArchive::new(file)?;
|
||||||
|
|
||||||
let mut asset_count = 0;
|
let mut asset_count = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ mod service;
|
|||||||
mod tokenizer;
|
mod tokenizer;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
pub use db::{YomitanProgress, YomitanRow, YomitanZipImportResult, ZipSource};
|
pub use db::{YomitanProgress, YomitanRow, YomitanZipImportResult};
|
||||||
pub use error::CJDicError;
|
pub use error::CJDicError;
|
||||||
pub use service::{AppService, SqlParam, YomitanDictEntry};
|
pub use service::{AppService, SqlParam, YomitanDictEntry};
|
||||||
pub use tokenizer::TokenizeSegment;
|
pub use tokenizer::TokenizeSegment;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use rusqlite::{Connection, params_from_iter};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Timer, ZipSource,
|
Timer,
|
||||||
db::{
|
db::{
|
||||||
DBFILE, Database, DbChild, YomitanProgress, YomitanRow, YomitanWriter,
|
DBFILE, Database, DbChild, YomitanProgress, YomitanRow, YomitanWriter,
|
||||||
YomitanZipImportResult,
|
YomitanZipImportResult,
|
||||||
@@ -40,6 +40,7 @@ pub enum SqlParam {
|
|||||||
Bool(bool),
|
Bool(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct AppService {
|
pub struct AppService {
|
||||||
db: Database,
|
db: Database,
|
||||||
tokenizer: Tokenizer,
|
tokenizer: Tokenizer,
|
||||||
@@ -163,24 +164,23 @@ impl AppService {
|
|||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_yomitan_zip_dir<Z, LoadCallback, ImportCallback>(
|
pub fn load_yomitan_zip_dir<LoadCallback, ImportCallback>(
|
||||||
&self,
|
&self,
|
||||||
zip_dir: Vec<Z>,
|
zip_dir: Vec<PathBuf>,
|
||||||
asset_dir: &PathBuf,
|
asset_dir: &PathBuf,
|
||||||
lang: &str,
|
lang: &str,
|
||||||
load_callback: LoadCallback,
|
load_callback: LoadCallback,
|
||||||
import_callback: ImportCallback,
|
import_callback: ImportCallback,
|
||||||
) -> Result<LoadYomitanZipDirResult, CJDicError>
|
) -> Result<LoadYomitanZipDirResult, CJDicError>
|
||||||
where
|
where
|
||||||
Z: ZipSource,
|
|
||||||
LoadCallback: Fn(LoadYomitanZipDirResult),
|
LoadCallback: Fn(LoadYomitanZipDirResult),
|
||||||
ImportCallback: Fn(YomitanProgress),
|
ImportCallback: Fn(YomitanProgress),
|
||||||
{
|
{
|
||||||
let mut dir_zip_map: HashMap<String, &Z> = HashMap::new();
|
let mut dir_zip_map: HashMap<String, &PathBuf> = HashMap::new();
|
||||||
let mut zip_dir_ord: HashMap<String, usize> = HashMap::new();
|
let mut zip_dir_ord: HashMap<String, usize> = HashMap::new();
|
||||||
|
|
||||||
for (i, entry) in zip_dir.iter().enumerate() {
|
for (i, entry) in zip_dir.iter().enumerate() {
|
||||||
let filename = entry.file_name();
|
let filename = entry.file_name().and_then(|n| n.to_str()).unwrap_or("");
|
||||||
dir_zip_map.insert(filename.to_string(), entry);
|
dir_zip_map.insert(filename.to_string(), entry);
|
||||||
zip_dir_ord.insert(filename.to_string(), i);
|
zip_dir_ord.insert(filename.to_string(), i);
|
||||||
}
|
}
|
||||||
@@ -276,15 +276,14 @@ impl AppService {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn import_yomitan_zip_file<Z, Callback>(
|
pub fn import_yomitan_zip_file<Callback>(
|
||||||
writer: &mut YomitanWriter, // Reuse existing connection
|
writer: &mut YomitanWriter, // Reuse existing connection
|
||||||
zip_file: &Z,
|
zip_file: &PathBuf,
|
||||||
asset_dir: &PathBuf,
|
asset_dir: &PathBuf,
|
||||||
lang: &str,
|
lang: &str,
|
||||||
progress_callback: Callback,
|
progress_callback: Callback,
|
||||||
) -> Result<YomitanZipImportResult, CJDicError>
|
) -> Result<YomitanZipImportResult, CJDicError>
|
||||||
where
|
where
|
||||||
Z: ZipSource,
|
|
||||||
Callback: Fn(YomitanProgress),
|
Callback: Fn(YomitanProgress),
|
||||||
{
|
{
|
||||||
Ok(writer.import_dictionary_zip_file(zip_file, asset_dir, lang, progress_callback)?)
|
Ok(writer.import_dictionary_zip_file(zip_file, asset_dir, lang, progress_callback)?)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ android {
|
|||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
getByName("debug") {
|
getByName("debug") {
|
||||||
applicationIdSuffix = ".dev"
|
// applicationIdSuffix = ".dev"
|
||||||
manifestPlaceholders["usesCleartextTraffic"] = "true"
|
manifestPlaceholders["usesCleartextTraffic"] = "true"
|
||||||
isDebuggable = true
|
isDebuggable = true
|
||||||
isJniDebuggable = true
|
isJniDebuggable = true
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 16 KiB |
@@ -1,4 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">cjdic2 (debug)</string>
|
|
||||||
<string name="main_activity_title">cjdic2 (debug)</string>
|
|
||||||
</resources>
|
|
||||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 163 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 974 B After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 903 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 232 KiB |
|
After Width: | Height: | Size: 961 B |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 937 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 25 KiB |
@@ -59,26 +59,35 @@ pub async fn init_yomitan(
|
|||||||
.map(|d| data_dir.join(&d.filepath))
|
.map(|d| data_dir.join(&d.filepath))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let update_count = Cell::new(0usize);
|
let state = state.inner().clone();
|
||||||
|
let app_clone = app.clone();
|
||||||
|
|
||||||
state.load_yomitan_zip_dir(
|
let update_count = tokio::task::spawn_blocking(move || {
|
||||||
zip_files,
|
let update_count = Cell::new(0usize);
|
||||||
&yomitan_assets,
|
|
||||||
lang.as_str(),
|
|
||||||
|r| {
|
|
||||||
update_count.set(update_count.get() + r.new_dicts.len() + r.to_be_removed_dicts.len());
|
|
||||||
app.emit("load-yomitan-dir", r).unwrap();
|
|
||||||
},
|
|
||||||
|r| {
|
|
||||||
update_count.set(update_count.get() + 1);
|
|
||||||
app.emit("yomitan-import-progress", r).unwrap();
|
|
||||||
},
|
|
||||||
)?;
|
|
||||||
|
|
||||||
if update_count.get() > 0 {
|
state.load_yomitan_zip_dir(
|
||||||
|
zip_files,
|
||||||
|
&yomitan_assets,
|
||||||
|
lang.as_str(),
|
||||||
|
|r| {
|
||||||
|
update_count
|
||||||
|
.set(update_count.get() + r.new_dicts.len() + r.to_be_removed_dicts.len());
|
||||||
|
app.emit("load-yomitan-dir", r).unwrap();
|
||||||
|
},
|
||||||
|
|r| {
|
||||||
|
update_count.set(update_count.get() + 1);
|
||||||
|
app.emit("yomitan-import-progress", r).unwrap();
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
Ok::<usize, CJDicError>(update_count.get())
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| CJDicError::Error(e.to_string()))??;
|
||||||
|
|
||||||
|
if update_count > 0 {
|
||||||
println!("Request app restart?",);
|
println!("Request app restart?",);
|
||||||
// Request app restart anyway
|
// Request app restart anyway
|
||||||
app.request_restart();
|
app_clone.request_restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||