Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ pub fn run() {
settings::app_theme,
settings::set_theme,
updater::update_check,
updater::update_show,
updater::update_pending,
updater::update_fit,
updater::update_copy_command,
Expand Down
5 changes: 4 additions & 1 deletion src-tauri/src/notices/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const UPSTREAMS: &str = "upstreams";
const SECURITY: &str = "security";
const MCP: &str = "mcp";
const SETTINGS: &str = "settings";
/// 设置页的「网关监听」一节(`settings:<节>`,界面滚到那一节)
const LISTEN_SETTINGS: &str = "settings:listen";

/// 一个键默认落在哪一页(那一条已经不在列表里时用)。按键的种类,也就是冒号前那段
pub fn default_view(key: &str) -> &'static str {
Expand Down Expand Up @@ -306,7 +308,8 @@ pub fn from_event(ev: &Event) -> Vec<Signal> {
format!("{}网关仍在 {at} 上监听。", core_text::text(e)),
format!("{} The gateway is still listening on {at}.", e.text)
))
.view(SETTINGS),
// 设置页并滚到「网关监听」那一节:未生效的原因也写在那里
.view(LISTEN_SETTINGS),
]
}
Event::CredentialRotated {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/notices/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ fn a_listen_change_that_did_not_take_is_raised_and_one_that_did_clears_it() {
s.body,
"127.0.0.1:8080 已被其他程序占用。网关仍在 127.0.0.1:18790 上监听。"
);
assert_eq!(s.view, Some("settings"));
assert_eq!(s.view, Some("settings:listen"));
});
let ok = rules::from_event(&tw_api::Event::ListenChanged {
id: 2,
Expand Down
22 changes: 19 additions & 3 deletions src-tauri/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ pub(crate) fn show_pending_update(app: &tauri::AppHandle) {
}
}

/// 菜单里的「检查更新…」和设置页的「立即检查」查的是同一处
/// 菜单里的「检查更新…」和设置页「关于」里的「检查更新」查的是同一处
pub(crate) async fn find_update(app: &tauri::AppHandle) -> Result<Option<Found>, String> {
find(app).await
}
Expand All @@ -250,7 +250,7 @@ pub(crate) fn present_update(app: &tauri::AppHandle, found: Found) {
present(app, found);
}

/// 「立即检查」。查到了就把更新窗口拉起来。
/// 设置页的「检查更新」。查到了就把更新窗口拉起来。
#[tauri::command]
pub async fn update_check(app: tauri::AppHandle) -> Out<Option<Found>> {
let found = find(&app).await?;
Expand All @@ -260,6 +260,22 @@ pub async fn update_check(app: tauri::AppHandle) -> Out<Option<Found>> {
Ok(found)
}

/// 设置页的「更新到 x…」:已经查到了一版,把更新窗口拉起来。
///
/// **不再联网问一遍**(`update_check` 会):那一版已经记在这里,再问一遍只会让这个
/// 按钮在没网的时候失灵,而窗口里的「下载并安装」反正会自己去取。
#[tauri::command]
pub fn update_show(app: tauri::AppHandle) -> Out<()> {
if pending_update(&app).is_none() {
return Err(tr!(
"尚无可安装的新版本",
"No new version is waiting to be installed"
)
.into());
}
show_update_window(&app).map_err(|e| e.to_string().into())
}

/// 更新窗口打开时来读:要画的是哪一版、这一份该怎么装。
#[tauri::command]
pub fn update_pending(app: tauri::AppHandle) -> Option<OfferView> {
Expand Down Expand Up @@ -557,7 +573,7 @@ pub(crate) const UPDATE_EVERY: std::time::Duration = std::time::Duration::from_s
/// 自动检查。查到了就发一条系统通知。
///
/// **开发构建不自己去查。**每次 `tauri dev` 之后两分钟弹一个窗,写代码的
/// 人学会的只是把它关掉。「立即检查」在开发构建里照样能用。
/// 人学会的只是把它关掉。「检查更新」在开发构建里照样能用。
pub(crate) async fn update_loop(app: tauri::AppHandle) {
tokio::time::sleep(UPDATE_FIRST_LOOK).await;
loop {
Expand Down
31 changes: 25 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { call } from "@/control";
import { useRequests } from "./useRequests";
import { useStableState } from "./useStable";
import { EMPTY_FILTER } from "./requestTable";
import Config from "./Config";
import { SettingsPage } from "./settings/SettingsPage";
import { ConfigFileDialog, VersionHistoryDialog } from "./ConfigDialogs";
import UpstreamsPage from "./upstreams/UpstreamsPage";
import ClientsPage from "./clients/ClientsPage";
Expand Down Expand Up @@ -406,6 +406,8 @@ function Shell({ first }: { first: boolean }) {
if (!(SURFACES as readonly string[]).includes(page ?? "")) return;
// `requests:42`:打开流量页并展开那一条(菜单栏里点了一个进行中的请求)
if (page === "requests" && id) openRef.current("requests", { request: Number(id) });
// `settings:listen`:设置页并滚到那一节(「监听设置未生效」)
else if (page === "settings" && id) openRef.current("settings", { section: id });
else openRef.current(page as Surface);
};
void invoke<string | null>("take_pending_view")
Expand Down Expand Up @@ -613,7 +615,15 @@ function Shell({ first }: { first: boolean }) {

const changed = useCallback(() => setNudge((n) => n + 1), []);
const openConfigFile = useCallback((focus: string | null) => setConfigFile({ focus }), []);
const go = useCallback((to: string) => open(to as Surface), [open]);
/** 页面、提醒要落到别的页时用。`settings:listen`:设置页并滚到那一节 */
const go = useCallback(
(to: string) => {
const [page, section] = to.split(":");
if (page === "settings" && section) open("settings", { section });
else open(to as Surface);
},
[open],
);

/** 命令面板里只有外壳做得了的几件事。**引用不变**:面板按它们建条目,变了就要重建 */
const paletteShell = useMemo(
Expand Down Expand Up @@ -950,7 +960,7 @@ function Shell({ first }: { first: boolean }) {
{/*
断线时整块只读:`fieldset disabled` 让里面的按钮、输入框、下拉一起失效,
读、滚动、悬停说明照旧。设置页不整页只读:连接管理在那里,断线时正要来
这里(换密钥、切回本机);那一页里改服务器配置的几节自己只读,见 `Config`
这里(换密钥、切回本机);那一页里改服务器配置的几节自己只读,见 `SettingsPage`
*/}
<fieldset
disabled={remoteLost && tab !== "settings"}
Expand All @@ -977,7 +987,7 @@ function Shell({ first }: { first: boolean }) {
*/}
{!linked ? (
launching ? null : tab === "settings" ? (
<Config ov={null} status={null} onChanged={changed} />
<SettingsPage ov={null} status={null} local={c} linked={false} onChanged={changed} />
) : (
<Unlinked core={core} />
)
Expand Down Expand Up @@ -1029,7 +1039,14 @@ function Shell({ first }: { first: boolean }) {
skeleton
)
) : tab === "settings" ? (
<Config ov={ov} status={status} coreReadOnly={remoteLost} onChanged={changed} />
<SettingsPage
ov={ov}
status={status}
local={c}
linked
coreReadOnly={remoteLost}
onChanged={changed}
/>
) : (
<TrafficPage
rows={allRows}
Expand All @@ -1054,7 +1071,9 @@ function Shell({ first }: { first: boolean }) {
onClose={() => setConfigFile(null)}
onJump={(section) => {
setConfigFile(null);
open(surfaceOf(section));
// 监听、日志保留是设置页里的两节:直接滚到那一节
if (section === "listen" || section === "retention") open("settings", { section });
else open(surfaceOf(section));
}}
/>
)}
Expand Down
21 changes: 0 additions & 21 deletions src/Appearance.i18n.ts

This file was deleted.

70 changes: 0 additions & 70 deletions src/Appearance.tsx

This file was deleted.

95 changes: 0 additions & 95 deletions src/Config.i18n.tsx

This file was deleted.

Loading
Loading