Compare commits

...

2 Commits

6 changed files with 32 additions and 29 deletions

View File

@@ -57,7 +57,7 @@
"axios": "^1.13.2",
"dayjs": "1.11.19",
"foxact": "^0.2.49",
"i18next": "^25.6.0",
"i18next": "^25.6.1",
"js-yaml": "^4.1.0",
"json-schema": "^0.4.0",
"lodash-es": "^4.17.21",

16
pnpm-lock.yaml generated
View File

@@ -78,8 +78,8 @@ importers:
specifier: ^0.2.49
version: 0.2.49(react@19.2.0)
i18next:
specifier: ^25.6.0
version: 25.6.0(typescript@5.9.3)
specifier: ^25.6.1
version: 25.6.1(typescript@5.9.3)
js-yaml:
specifier: ^4.1.0
version: 4.1.0
@@ -112,7 +112,7 @@ importers:
version: 7.66.0(react@19.2.0)
react-i18next:
specifier: 16.2.4
version: 16.2.4(i18next@25.6.0(typescript@5.9.3))(react-dom@19.2.0(react@19.2.0))(react@19.2.0)(typescript@5.9.3)
version: 16.2.4(i18next@25.6.1(typescript@5.9.3))(react-dom@19.2.0(react@19.2.0))(react@19.2.0)(typescript@5.9.3)
react-markdown:
specifier: 10.1.0
version: 10.1.0(@types/react@19.2.2)(react@19.2.0)
@@ -2943,8 +2943,8 @@ packages:
engines: {node: '>=18'}
hasBin: true
i18next@25.6.0:
resolution: {integrity: sha512-tTn8fLrwBYtnclpL5aPXK/tAYBLWVvoHM1zdfXoRNLcI+RvtMsoZRV98ePlaW3khHYKuNh/Q65W/+NVFUeIwVw==}
i18next@25.6.1:
resolution: {integrity: sha512-yUWvdXtalZztmKrKw3yz/AvSP3yKyqIkVPx/wyvoYy9lkLmwzItLxp0iHZLG5hfVQ539Jor4XLO+U+NHIXg7pw==}
peerDependencies:
typescript: ^5
peerDependenciesMeta:
@@ -7359,7 +7359,7 @@ snapshots:
husky@9.1.7: {}
i18next@25.6.0(typescript@5.9.3):
i18next@25.6.1(typescript@5.9.3):
dependencies:
'@babel/runtime': 7.28.4
optionalDependencies:
@@ -8183,11 +8183,11 @@ snapshots:
dependencies:
react: 19.2.0
react-i18next@16.2.4(i18next@25.6.0(typescript@5.9.3))(react-dom@19.2.0(react@19.2.0))(react@19.2.0)(typescript@5.9.3):
react-i18next@16.2.4(i18next@25.6.1(typescript@5.9.3))(react-dom@19.2.0(react@19.2.0))(react@19.2.0)(typescript@5.9.3):
dependencies:
'@babel/runtime': 7.28.4
html-parse-stringify: 3.0.1
i18next: 25.6.0(typescript@5.9.3)
i18next: 25.6.1(typescript@5.9.3)
react: 19.2.0
use-sync-external-store: 1.6.0(react@19.2.0)
optionalDependencies:

View File

@@ -12,7 +12,7 @@ use std::{
mpsc,
},
thread,
time::Instant,
time::{Duration, Instant},
};
use tauri::{Emitter, WebviewWindow};
@@ -92,12 +92,15 @@ impl NotificationSystem {
}
fn worker_loop(rx: mpsc::Receiver<FrontendEvent>) {
let handle = Handle::global();
while !handle.is_exiting() {
match rx.try_recv() {
loop {
let handle = Handle::global();
if handle.is_exiting() {
break;
}
match rx.recv_timeout(Duration::from_millis(1_000)) {
Ok(event) => Self::process_event(handle, event),
Err(mpsc::TryRecvError::Disconnected) => break,
Err(mpsc::TryRecvError::Empty) => break,
Err(mpsc::RecvTimeoutError::Timeout) => (),
Err(mpsc::RecvTimeoutError::Disconnected) => break,
}
}
}

View File

@@ -1,3 +1,5 @@
use std::time::Duration;
use anyhow::{Result, bail};
use percent_encoding::percent_decode_str;
use smartstring::alias::String;
@@ -73,24 +75,23 @@ pub(super) async fn resolve_scheme(param: &str) -> Result<()> {
"failed to parse profile from url: {:?}",
e
);
// TODO 通知系统疑似损坏,前端无法显示通知事件
handle::Handle::notice_message("import_sub_url::error", e.to_string());
return Ok(());
}
};
let uid = item.uid.clone().unwrap_or_default();
// TODO 通过 deep link 导入后需要正确调用前端刷新订阅页面,以及通知结果
match profiles::profiles_append_item_safe(&mut item).await {
Ok(_) => {
Config::profiles().await.apply();
let _ = Config::profiles().await.data_arc().save_file().await;
// TODO 通知系统疑似损坏,前端无法显示通知事件
handle::Handle::notice_message(
"import_sub_url::ok",
item.uid.clone().unwrap_or_default(),
"", // 空 msg 传入,我们不希望导致 后端-前端-后端 死循环,这里只做提醒。
);
// TODO fuck me this shit is fucking broken as fucked
handle::Handle::refresh_verge();
handle::Handle::notify_profile_changed(uid.clone());
tokio::time::sleep(Duration::from_millis(100)).await;
handle::Handle::notify_profile_changed(uid);
}
Err(e) => {
@@ -101,14 +102,10 @@ pub(super) async fn resolve_scheme(param: &str) -> Result<()> {
e
);
Config::profiles().await.discard();
// TODO 通知系统疑似损坏,前端无法显示通知事件
handle::Handle::notice_message("import_sub_url::error", e.to_string());
return Ok(());
}
}
handle::Handle::refresh_verge();
handle::Handle::refresh_clash();
Ok(())
}

View File

@@ -11,7 +11,10 @@ export const handleNoticeMessage = (
) => {
const handlers: Record<string, () => void> = {
"import_sub_url::ok": () => {
navigate("/profile", { state: { current: msg } });
// 空 msg 传入,我们不希望导致 后端-前端-后端 死循环,这里只做提醒。
// 未来细分事件通知时,可以考虑传入订阅 ID 或其他标识符
// navigate("/profile", { state: { current: msg } });
navigate("/profile");
showNotice("success", t("Import Subscription Successful"));
},
"import_sub_url::error": () => {

View File

@@ -13,15 +13,15 @@ import {
sortableKeyboardCoordinates,
} from "@dnd-kit/sortable";
import {
CheckBoxOutlineBlankRounded,
CheckBoxRounded,
ClearRounded,
ContentPasteRounded,
DeleteRounded,
IndeterminateCheckBoxRounded,
LocalFireDepartmentRounded,
RefreshRounded,
TextSnippetOutlined,
CheckBoxOutlineBlankRounded,
CheckBoxRounded,
IndeterminateCheckBoxRounded,
DeleteRounded,
} from "@mui/icons-material";
import { LoadingButton } from "@mui/lab";
import { Box, Button, Divider, Grid, IconButton, Stack } from "@mui/material";