Skip to content

PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.

feat(ui): always show the relay allowance on the official service page

baiyuze1a28a2bc9187
diff --git a/docs/assets/screenshots/en/official-usage-dark.png b/docs/assets/screenshots/en/official-usage-dark.png
index 68b18f3..bb5efbe 100644
Binary files a/docs/assets/screenshots/en/official-usage-dark.png and b/docs/assets/screenshots/en/official-usage-dark.png differ
diff --git a/docs/assets/screenshots/ja/official-usage-dark.png b/docs/assets/screenshots/ja/official-usage-dark.png
index b35c2f9..5a0d9b1 100644
Binary files a/docs/assets/screenshots/ja/official-usage-dark.png and b/docs/assets/screenshots/ja/official-usage-dark.png differ
diff --git a/docs/assets/screenshots/official-usage-dark.png b/docs/assets/screenshots/official-usage-dark.png
index d10115b..056da9f 100644
Binary files a/docs/assets/screenshots/official-usage-dark.png and b/docs/assets/screenshots/official-usage-dark.png differ
diff --git a/docs/assets/screenshots/zh-hk/official-usage-dark.png b/docs/assets/screenshots/zh-hk/official-usage-dark.png
index 0a542e3..fad138f 100644
Binary files a/docs/assets/screenshots/zh-hk/official-usage-dark.png and b/docs/assets/screenshots/zh-hk/official-usage-dark.png differ
diff --git a/docs/assets/screenshots/zh-tw/official-usage-dark.png b/docs/assets/screenshots/zh-tw/official-usage-dark.png
index 94e9362..cb99eb1 100644
Binary files a/docs/assets/screenshots/zh-tw/official-usage-dark.png and b/docs/assets/screenshots/zh-tw/official-usage-dark.png differ
diff --git a/docs/en/official/index.html b/docs/en/official/index.html
index a4f335d..0fb1e77 100644
--- a/docs/en/official/index.html
+++ b/docs/en/official/index.html
@@ -77,7 +77,7 @@
</div>
</div></section>
<section class="section"><div class="wrap official-copy"><h2>Direct first, relay when needed</h2><p class="intro">Official signaling exchanges connection information between online peers. The clients try STUN discovery and NAT traversal first, requesting relay only after that direct attempt fails. Content remains end-to-end encrypted.</p></div></section>
-<section class="section"><div class="wrap official-copy"><h2>Direct traffic does not use relay allowance</h2><p class="intro">The current default is 100 MB per machine quota group per day, upload plus download, resetting at midnight Beijing time. Reinstalling does not guarantee a fresh allowance. The usage page shows the actual limit, remaining amount and update time. Direct connections still work when relay allowance runs out. Allowances and availability may change; check the app.</p></div></section>
+<section class="section"><div class="wrap official-copy"><h2>Direct traffic does not use relay allowance</h2><p class="intro">The current default is 100 MB per machine quota group per day, upload plus download, resetting at midnight Beijing time. Reinstalling does not guarantee a fresh allowance. Once enabled, the usage page shows today&#x27;s allowance, the remaining amount and the update time without needing relay first, and lists whether each device is connected directly or through relay. Direct connections still work when relay allowance runs out. Allowances and availability may change; check the app.</p></div></section>
<section class="section"><div class="wrap official-copy"><h2>Your choice to enable it</h2><p class="intro">Official access is off on fresh installs. Enabling it records essential access statistics; an application-specific machine digest is derived only when relay is requested. Real device names, raw system identifiers and copied content are not uploaded as statistics. See the privacy notice for fields and retention.</p></div></section>
<section class="section"><div class="wrap official-copy"><h2>Self-hosting stays independent</h2><p class="intro">LAN, custom servers and Tailscale continue to work without the official gateway. Host your own public server when you need to control capacity, then use Save and connect beside its custom address.</p></div></section>
<section class="section"><div class="wrap official-copy">
diff --git a/docs/en/start/index.html b/docs/en/start/index.html
index 92cd200..d3fdf8c 100644
--- a/docs/en/start/index.html
+++ b/docs/en/start/index.html
@@ -144,7 +144,7 @@
<svg viewBox="0 0 240 112" aria-hidden="true"><rect class="p-dev" x="98" y="8" width="44" height="12" rx="3"/><rect class="p-dev" x="98" y="23" width="44" height="12" rx="3"/><rect class="p-net" x="6" y="50" width="100" height="56" rx="10"/><rect class="p-net" x="134" y="50" width="100" height="56" rx="10"/><path class="p-sig" d="M56 64V22h42M184 64V22h-42"/><path class="p-data" d="M80 80h80"/><rect class="p-dev" x="37" y="64" width="38" height="24" rx="3"/><path class="p-dev" d="M32 93h48"/><rect class="p-dev" x="165" y="64" width="38" height="24" rx="3"/><path class="p-dev" d="M160 93h48"/></svg>
<dl>
<div><dt>Direct first, relay when needed</dt><dd>Official signaling exchanges connection information between online peers. The clients try STUN discovery and NAT traversal first, requesting relay only after that direct attempt fails. Content remains end-to-end encrypted.</dd></div>
- <div><dt>Direct traffic does not use relay allowance</dt><dd>The current default is 100 MB per machine quota group per day, upload plus download, resetting at midnight Beijing time. Reinstalling does not guarantee a fresh allowance. The usage page shows the actual limit, remaining amount and update time. Direct connections still work when relay allowance runs out. Allowances and availability may change; check the app.</dd></div>
+ <div><dt>Direct traffic does not use relay allowance</dt><dd>The current default is 100 MB per machine quota group per day, upload plus download, resetting at midnight Beijing time. Reinstalling does not guarantee a fresh allowance. Once enabled, the usage page shows today's allowance, the remaining amount and the update time without needing relay first, and lists whether each device is connected directly or through relay. Direct connections still work when relay allowance runs out. Allowances and availability may change; check the app.</dd></div>
</dl>
</div>
</div>
diff --git a/docs/ja/official/index.html b/docs/ja/official/index.html
index 4d70e83..7a3c373 100644
--- a/docs/ja/official/index.html
+++ b/docs/ja/official/index.html
@@ -77,7 +77,7 @@
</div>
</div></section>
<section class="section"><div class="wrap official-copy"><h2>直接接続を先に、中継は必要なときだけ</h2><p class="intro">公式シグナリングはオンライン端末間の接続情報を交換します。まず STUN と NAT トラバーサルを試し、その試行に失敗した場合のみ中継を申請します。内容は常にエンドツーエンド暗号化されます。</p></div></section>
-<section class="section"><div class="wrap official-copy"><h2>直接通信は中継残量を消費しません</h2><p class="intro">現在の標準中継上限は端末の上限グループごとに送受信合計 100 MB/日で、北京時間午前 0 時にリセットします。再インストールで新たな残量が得られる保証はありません。使用量画面に実際の上限、残量、更新時刻を表示します。上限に達しても直接接続は利用できます。上限と提供状況は変更される場合があるため、アプリでご確認ください。</p></div></section>
+<section class="section"><div class="wrap official-copy"><h2>直接通信は中継残量を消費しません</h2><p class="intro">現在の標準中継上限は端末の上限グループごとに送受信合計 100 MB/日で、北京時間午前 0 時にリセットします。再インストールで新たな残量が得られる保証はありません。有効にすると、中継を使う前から使用量画面に本日の上限、残量、更新時刻を表示し、各デバイスが直接接続か中継かも一覧できます。上限に達しても直接接続は利用できます。上限と提供状況は変更される場合があるため、アプリでご確認ください。</p></div></section>
<section class="section"><div class="wrap official-copy"><h2>有効にするかは自分で選べます</h2><p class="intro">新規インストールではオフです。有効にした場合のみ必要な接続統計を記録し、中継申請時にのみ専用の端末ダイジェストを導出します。実際の端末名、元のシステム識別子、コピー内容を統計として送信しません。項目と保持期間はプライバシー説明をご覧ください。</p></div></section>
<section class="section"><div class="wrap official-copy"><h2>独自サーバーも引き続き利用可能</h2><p class="intro">LAN、独自サーバー、Tailscale は公式ゲートウェイから独立して動作します。容量を自分で管理したい場合はサーバーを構築し、独自アドレスの横にある「保存して接続」を使えます。</p></div></section>
<section class="section"><div class="wrap official-copy">
diff --git a/docs/ja/start/index.html b/docs/ja/start/index.html
index cca349a..4743f65 100644
--- a/docs/ja/start/index.html
+++ b/docs/ja/start/index.html
@@ -144,7 +144,7 @@
<svg viewBox="0 0 240 112" aria-hidden="true"><rect class="p-dev" x="98" y="8" width="44" height="12" rx="3"/><rect class="p-dev" x="98" y="23" width="44" height="12" rx="3"/><rect class="p-net" x="6" y="50" width="100" height="56" rx="10"/><rect class="p-net" x="134" y="50" width="100" height="56" rx="10"/><path class="p-sig" d="M56 64V22h42M184 64V22h-42"/><path class="p-data" d="M80 80h80"/><rect class="p-dev" x="37" y="64" width="38" height="24" rx="3"/><path class="p-dev" d="M32 93h48"/><rect class="p-dev" x="165" y="64" width="38" height="24" rx="3"/><path class="p-dev" d="M160 93h48"/></svg>
<dl>
<div><dt>直接接続を先に、中継は必要なときだけ</dt><dd>公式シグナリングはオンライン端末間の接続情報を交換します。まず STUN と NAT トラバーサルを試し、その試行に失敗した場合のみ中継を申請します。内容は常にエンドツーエンド暗号化されます。</dd></div>
- <div><dt>直接通信は中継残量を消費しません</dt><dd>現在の標準中継上限は端末の上限グループごとに送受信合計 100 MB/日で、北京時間午前 0 時にリセットします。再インストールで新たな残量が得られる保証はありません。使用量画面に実際の上限、残量、更新時刻を表示します。上限に達しても直接接続は利用できます。上限と提供状況は変更される場合があるため、アプリでご確認ください。</dd></div>
+ <div><dt>直接通信は中継残量を消費しません</dt><dd>現在の標準中継上限は端末の上限グループごとに送受信合計 100 MB/日で、北京時間午前 0 時にリセットします。再インストールで新たな残量が得られる保証はありません。有効にすると、中継を使う前から使用量画面に本日の上限、残量、更新時刻を表示し、各デバイスが直接接続か中継かも一覧できます。上限に達しても直接接続は利用できます。上限と提供状況は変更される場合があるため、アプリでご確認ください。</dd></div>
</dl>
</div>
</div>
diff --git a/docs/official/index.html b/docs/official/index.html
index 54d1a97..22c004c 100644
--- a/docs/official/index.html
+++ b/docs/official/index.html
@@ -77,7 +77,7 @@
</div>
</div></section>
<section class="section"><div class="wrap official-copy"><h2>先直连,再中转</h2><p class="intro">官方信令只帮助在线设备交换连接信息。客户端先用 STUN 探测和打洞;本轮直连失败后,才申请官方中转。传输内容始终端到端加密。</p></div></section>
-<section class="section"><div class="wrap official-copy"><h2>直连不消耗中转额度</h2><p class="intro">当前默认每机器额度组每日 100 MB 中转流量,上传与下载合计,北京时间零点重置。重新安装不会保证获得新额度。用量页显示实际额度、剩余量与更新时间;额度用尽仍可直连。额度与服务可用性可能调整,以客户端显示为准。</p></div></section>
+<section class="section"><div class="wrap official-copy"><h2>直连不消耗中转额度</h2><p class="intro">当前默认每机器额度组每日 100 MB 中转流量,上传与下载合计,北京时间零点重置。重新安装不会保证获得新额度。开启后用量页即显示今日额度、剩余量与更新时间,不必先用中转,并列出每台设备当前是直连还是中转;额度用尽仍可直连。额度与服务可用性可能调整,以客户端显示为准。</p></div></section>
<section class="section"><div class="wrap official-copy"><h2>由你决定是否开启</h2><p class="intro">新安装默认关闭。开启后记录必要接入统计;仅申请中转时派生项目专用机器摘要。真实设备名、原始系统标识和复制内容不会作为统计上传。完整字段与保留期限见隐私说明。</p></div></section>
<section class="section"><div class="wrap official-copy"><h2>仍可独立自建</h2><p class="intro">局域网、自定义服务器和 Tailscale 继续可用,不依赖官方网关。需要自行管理容量时,可选择自建公网服务器;在自定义地址旁点击「保存并连接」。</p></div></section>
<section class="section"><div class="wrap official-copy">
diff --git a/docs/start/index.html b/docs/start/index.html
index 453fe3e..1c3b546 100644
--- a/docs/start/index.html
+++ b/docs/start/index.html
@@ -144,7 +144,7 @@
<svg viewBox="0 0 240 112" aria-hidden="true"><rect class="p-dev" x="98" y="8" width="44" height="12" rx="3"/><rect class="p-dev" x="98" y="23" width="44" height="12" rx="3"/><rect class="p-net" x="6" y="50" width="100" height="56" rx="10"/><rect class="p-net" x="134" y="50" width="100" height="56" rx="10"/><path class="p-sig" d="M56 64V22h42M184 64V22h-42"/><path class="p-data" d="M80 80h80"/><rect class="p-dev" x="37" y="64" width="38" height="24" rx="3"/><path class="p-dev" d="M32 93h48"/><rect class="p-dev" x="165" y="64" width="38" height="24" rx="3"/><path class="p-dev" d="M160 93h48"/></svg>
<dl>
<div><dt>先直连,再中转</dt><dd>官方信令只帮助在线设备交换连接信息。客户端先用 STUN 探测和打洞;本轮直连失败后,才申请官方中转。传输内容始终端到端加密。</dd></div>
- <div><dt>直连不消耗中转额度</dt><dd>当前默认每机器额度组每日 100 MB 中转流量,上传与下载合计,北京时间零点重置。重新安装不会保证获得新额度。用量页显示实际额度、剩余量与更新时间;额度用尽仍可直连。额度与服务可用性可能调整,以客户端显示为准。</dd></div>
+ <div><dt>直连不消耗中转额度</dt><dd>当前默认每机器额度组每日 100 MB 中转流量,上传与下载合计,北京时间零点重置。重新安装不会保证获得新额度。开启后用量页即显示今日额度、剩余量与更新时间,不必先用中转,并列出每台设备当前是直连还是中转;额度用尽仍可直连。额度与服务可用性可能调整,以客户端显示为准。</dd></div>
</dl>
</div>
</div>
diff --git a/docs/zh-hk/official/index.html b/docs/zh-hk/official/index.html
index 5b6a832..4ae0ece 100644
--- a/docs/zh-hk/official/index.html
+++ b/docs/zh-hk/official/index.html
@@ -77,7 +77,7 @@
</div>
</div></section>
<section class="section"><div class="wrap official-copy"><h2>先直連,再中轉</h2><p class="intro">官方信令只協助在線裝置交換連線資料。用戶端先用 STUN 探測和打洞;本輪直連失敗後,才申請官方中轉。傳輸內容始終端到端加密。</p></div></section>
-<section class="section"><div class="wrap official-copy"><h2>直連不消耗中轉額度</h2><p class="intro">目前預設每機器額度組每日 100 MB 中轉流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。用量頁顯示實際額度、剩餘量與更新時間;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。</p></div></section>
+<section class="section"><div class="wrap official-copy"><h2>直連不消耗中轉額度</h2><p class="intro">目前預設每機器額度組每日 100 MB 中轉流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。開啟後用量頁即顯示今日額度、剩餘量與更新時間,不必先使用中轉,並列出每部裝置目前是直連還是中轉;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。</p></div></section>
<section class="section"><div class="wrap official-copy"><h2>由你決定是否啟用</h2><p class="intro">新安裝預設關閉。啟用後記錄必要連線統計;只在申請中轉時衍生項目專用機器摘要。真實裝置名稱、原始系統識別碼和複製內容不作為統計上傳。完整欄位與保留期限見私隱說明。</p></div></section>
<section class="section"><div class="wrap official-copy"><h2>仍可獨立自建</h2><p class="intro">區域網絡、自訂伺服器與 Tailscale 繼續可用,不依賴官方網關。需要自行管理容量時,可選擇自建公網伺服器;在自訂地址旁按「儲存並連接」。</p></div></section>
<section class="section"><div class="wrap official-copy">
diff --git a/docs/zh-hk/start/index.html b/docs/zh-hk/start/index.html
index ab5af9c..02448c8 100644
--- a/docs/zh-hk/start/index.html
+++ b/docs/zh-hk/start/index.html
@@ -144,7 +144,7 @@
<svg viewBox="0 0 240 112" aria-hidden="true"><rect class="p-dev" x="98" y="8" width="44" height="12" rx="3"/><rect class="p-dev" x="98" y="23" width="44" height="12" rx="3"/><rect class="p-net" x="6" y="50" width="100" height="56" rx="10"/><rect class="p-net" x="134" y="50" width="100" height="56" rx="10"/><path class="p-sig" d="M56 64V22h42M184 64V22h-42"/><path class="p-data" d="M80 80h80"/><rect class="p-dev" x="37" y="64" width="38" height="24" rx="3"/><path class="p-dev" d="M32 93h48"/><rect class="p-dev" x="165" y="64" width="38" height="24" rx="3"/><path class="p-dev" d="M160 93h48"/></svg>
<dl>
<div><dt>先直連,再中轉</dt><dd>官方信令只協助在線裝置交換連線資料。用戶端先用 STUN 探測和打洞;本輪直連失敗後,才申請官方中轉。傳輸內容始終端到端加密。</dd></div>
- <div><dt>直連不消耗中轉額度</dt><dd>目前預設每機器額度組每日 100 MB 中轉流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。用量頁顯示實際額度、剩餘量與更新時間;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。</dd></div>
+ <div><dt>直連不消耗中轉額度</dt><dd>目前預設每機器額度組每日 100 MB 中轉流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。開啟後用量頁即顯示今日額度、剩餘量與更新時間,不必先使用中轉,並列出每部裝置目前是直連還是中轉;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。</dd></div>
</dl>
</div>
</div>
diff --git a/docs/zh-tw/official/index.html b/docs/zh-tw/official/index.html
index ad90e1b..e92d961 100644
--- a/docs/zh-tw/official/index.html
+++ b/docs/zh-tw/official/index.html
@@ -77,7 +77,7 @@
</div>
</div></section>
<section class="section"><div class="wrap official-copy"><h2>先直連,再中繼</h2><p class="intro">官方信令只協助在線裝置交換連線資訊。用戶端先透過 STUN 探測和打洞;本輪直連失敗後,才申請官方中繼。傳輸內容始終端到端加密。</p></div></section>
-<section class="section"><div class="wrap official-copy"><h2>直連不消耗中繼額度</h2><p class="intro">目前預設每機器額度組每日 100 MB 中繼流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。用量頁顯示實際額度、剩餘量與更新時間;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。</p></div></section>
+<section class="section"><div class="wrap official-copy"><h2>直連不消耗中繼額度</h2><p class="intro">目前預設每機器額度組每日 100 MB 中繼流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。開啟後用量頁即顯示今日額度、剩餘量與更新時間,不必先使用中繼,並列出每台裝置目前是直連還是中繼;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。</p></div></section>
<section class="section"><div class="wrap official-copy"><h2>由你決定是否啟用</h2><p class="intro">新安裝預設關閉。啟用後記錄必要連線統計;僅申請中繼時衍生專案專用機器摘要。真實裝置名稱、原始系統識別碼和複製內容不作為統計上傳。完整欄位與保留期限見隱私說明。</p></div></section>
<section class="section"><div class="wrap official-copy"><h2>仍可獨立自建</h2><p class="intro">區域網路、自訂伺服器與 Tailscale 繼續可用,不依賴官方網關。需要自行管理容量時,可選擇自建公網伺服器;在自訂位址旁點擊「儲存並連線」。</p></div></section>
<section class="section"><div class="wrap official-copy">
diff --git a/docs/zh-tw/start/index.html b/docs/zh-tw/start/index.html
index bf01622..be5dfca 100644
--- a/docs/zh-tw/start/index.html
+++ b/docs/zh-tw/start/index.html
@@ -144,7 +144,7 @@
<svg viewBox="0 0 240 112" aria-hidden="true"><rect class="p-dev" x="98" y="8" width="44" height="12" rx="3"/><rect class="p-dev" x="98" y="23" width="44" height="12" rx="3"/><rect class="p-net" x="6" y="50" width="100" height="56" rx="10"/><rect class="p-net" x="134" y="50" width="100" height="56" rx="10"/><path class="p-sig" d="M56 64V22h42M184 64V22h-42"/><path class="p-data" d="M80 80h80"/><rect class="p-dev" x="37" y="64" width="38" height="24" rx="3"/><path class="p-dev" d="M32 93h48"/><rect class="p-dev" x="165" y="64" width="38" height="24" rx="3"/><path class="p-dev" d="M160 93h48"/></svg>
<dl>
<div><dt>先直連,再中繼</dt><dd>官方信令只協助在線裝置交換連線資訊。用戶端先透過 STUN 探測和打洞;本輪直連失敗後,才申請官方中繼。傳輸內容始終端到端加密。</dd></div>
- <div><dt>直連不消耗中繼額度</dt><dd>目前預設每機器額度組每日 100 MB 中繼流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。用量頁顯示實際額度、剩餘量與更新時間;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。</dd></div>
+ <div><dt>直連不消耗中繼額度</dt><dd>目前預設每機器額度組每日 100 MB 中繼流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。開啟後用量頁即顯示今日額度、剩餘量與更新時間,不必先使用中繼,並列出每台裝置目前是直連還是中繼;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。</dd></div>
</dl>
</div>
</div>
diff --git a/tools/site/content/official.py b/tools/site/content/official.py
index facb3ba..78c66f6 100644
--- a/tools/site/content/official.py
+++ b/tools/site/content/official.py
@@ -12,7 +12,7 @@ COPY = {
"routing_title": "先直连,再中转",
"routing": "官方信令只帮助在线设备交换连接信息。客户端先用 STUN 探测和打洞;本轮直连失败后,才申请官方中转。传输内容始终端到端加密。",
"quota_title": "直连不消耗中转额度",
- "quota": "当前默认每机器额度组每日 100 MB 中转流量,上传与下载合计,北京时间零点重置。重新安装不会保证获得新额度。用量页显示实际额度、剩余量与更新时间;额度用尽仍可直连。额度与服务可用性可能调整,以客户端显示为准。",
+ "quota": "当前默认每机器额度组每日 100 MB 中转流量,上传与下载合计,北京时间零点重置。重新安装不会保证获得新额度。开启后用量页即显示今日额度、剩余量与更新时间,不必先用中转,并列出每台设备当前是直连还是中转;额度用尽仍可直连。额度与服务可用性可能调整,以客户端显示为准。",
"privacy_title": "由你决定是否开启",
"privacy": "新安装默认关闭。开启后记录必要接入统计;仅申请中转时派生项目专用机器摘要。真实设备名、原始系统标识和复制内容不会作为统计上传。完整字段与保留期限见隐私说明。",
"self_title": "仍可独立自建",
@@ -32,7 +32,7 @@ COPY = {
"routing_title": "先直連,再中繼",
"routing": "官方信令只協助在線裝置交換連線資訊。用戶端先透過 STUN 探測和打洞;本輪直連失敗後,才申請官方中繼。傳輸內容始終端到端加密。",
"quota_title": "直連不消耗中繼額度",
- "quota": "目前預設每機器額度組每日 100 MB 中繼流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。用量頁顯示實際額度、剩餘量與更新時間;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。",
+ "quota": "目前預設每機器額度組每日 100 MB 中繼流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。開啟後用量頁即顯示今日額度、剩餘量與更新時間,不必先使用中繼,並列出每台裝置目前是直連還是中繼;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。",
"privacy_title": "由你決定是否啟用",
"privacy": "新安裝預設關閉。啟用後記錄必要連線統計;僅申請中繼時衍生專案專用機器摘要。真實裝置名稱、原始系統識別碼和複製內容不作為統計上傳。完整欄位與保留期限見隱私說明。",
"self_title": "仍可獨立自建",
@@ -52,7 +52,7 @@ COPY = {
"routing_title": "先直連,再中轉",
"routing": "官方信令只協助在線裝置交換連線資料。用戶端先用 STUN 探測和打洞;本輪直連失敗後,才申請官方中轉。傳輸內容始終端到端加密。",
"quota_title": "直連不消耗中轉額度",
- "quota": "目前預設每機器額度組每日 100 MB 中轉流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。用量頁顯示實際額度、剩餘量與更新時間;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。",
+ "quota": "目前預設每機器額度組每日 100 MB 中轉流量,上傳與下載合計,北京時間午夜重設。重新安裝不保證獲得新額度。開啟後用量頁即顯示今日額度、剩餘量與更新時間,不必先使用中轉,並列出每部裝置目前是直連還是中轉;額度用完仍可直連。額度與服務可用性可能調整,以用戶端顯示為準。",
"privacy_title": "由你決定是否啟用",
"privacy": "新安裝預設關閉。啟用後記錄必要連線統計;只在申請中轉時衍生項目專用機器摘要。真實裝置名稱、原始系統識別碼和複製內容不作為統計上傳。完整欄位與保留期限見私隱說明。",
"self_title": "仍可獨立自建",
@@ -72,7 +72,7 @@ COPY = {
"routing_title": "Direct first, relay when needed",
"routing": "Official signaling exchanges connection information between online peers. The clients try STUN discovery and NAT traversal first, requesting relay only after that direct attempt fails. Content remains end-to-end encrypted.",
"quota_title": "Direct traffic does not use relay allowance",
- "quota": "The current default is 100 MB per machine quota group per day, upload plus download, resetting at midnight Beijing time. Reinstalling does not guarantee a fresh allowance. The usage page shows the actual limit, remaining amount and update time. Direct connections still work when relay allowance runs out. Allowances and availability may change; check the app.",
+ "quota": "The current default is 100 MB per machine quota group per day, upload plus download, resetting at midnight Beijing time. Reinstalling does not guarantee a fresh allowance. Once enabled, the usage page shows today's allowance, the remaining amount and the update time without needing relay first, and lists whether each device is connected directly or through relay. Direct connections still work when relay allowance runs out. Allowances and availability may change; check the app.",
"privacy_title": "Your choice to enable it",
"privacy": "Official access is off on fresh installs. Enabling it records essential access statistics; an application-specific machine digest is derived only when relay is requested. Real device names, raw system identifiers and copied content are not uploaded as statistics. See the privacy notice for fields and retention.",
"self_title": "Self-hosting stays independent",
@@ -92,7 +92,7 @@ COPY = {
"routing_title": "直接接続を先に、中継は必要なときだけ",
"routing": "公式シグナリングはオンライン端末間の接続情報を交換します。まず STUN と NAT トラバーサルを試し、その試行に失敗した場合のみ中継を申請します。内容は常にエンドツーエンド暗号化されます。",
"quota_title": "直接通信は中継残量を消費しません",
- "quota": "現在の標準中継上限は端末の上限グループごとに送受信合計 100 MB/日で、北京時間午前 0 時にリセットします。再インストールで新たな残量が得られる保証はありません。使用量画面に実際の上限、残量、更新時刻を表示します。上限に達しても直接接続は利用できます。上限と提供状況は変更される場合があるため、アプリでご確認ください。",
+ "quota": "現在の標準中継上限は端末の上限グループごとに送受信合計 100 MB/日で、北京時間午前 0 時にリセットします。再インストールで新たな残量が得られる保証はありません。有効にすると、中継を使う前から使用量画面に本日の上限、残量、更新時刻を表示し、各デバイスが直接接続か中継かも一覧できます。上限に達しても直接接続は利用できます。上限と提供状況は変更される場合があるため、アプリでご確認ください。",
"privacy_title": "有効にするかは自分で選べます",
"privacy": "新規インストールではオフです。有効にした場合のみ必要な接続統計を記録し、中継申請時にのみ専用の端末ダイジェストを導出します。実際の端末名、元のシステム識別子、コピー内容を統計として送信しません。項目と保持期間はプライバシー説明をご覧ください。",
"self_title": "独自サーバーも引き続き利用可能",
diff --git a/ui/lib/l10n/app_en.arb b/ui/lib/l10n/app_en.arb
index d8dfd52..9655451 100644
--- a/ui/lib/l10n/app_en.arb
+++ b/ui/lib/l10n/app_en.arb
@@ -519,7 +519,8 @@
"officialSwitchConfirm": "This switches away from your custom server. Its saved address will be retained.",
"customServer": "Custom server",
"saveAndConnect": "Save and connect",
- "officialUnused": "Relay not requested; allowance not yet verified",
+ "officialLoading": "Checking the allowance…",
+ "officialFetchFailed": "Can't get the allowance right now. It will be retried automatically.",
"officialUnavailable": "Usage is unavailable; existing data may be out of date",
"officialQuotaTitle": "Daily relay allowance used up",
"officialQuotaBody": "Official relay is paused until the daily reset at midnight Beijing time. LAN and direct Internet connections remain available. Failed transfers can be retried later.",
@@ -527,7 +528,7 @@
"officialPaused": "Official relay is unavailable. Direct connections remain available.",
"officialViewUsage": "View usage",
"officialAcknowledge": "Got it",
- "officialToday": "Today's relay usage",
+ "officialToday": "Today's relay allowance",
"officialUsed": "Used",
"officialRemaining": "Remaining",
"officialDailyLimit": "Daily allowance",
@@ -535,6 +536,8 @@
"officialDownload": "Download",
"officialReset": "Reset time (Beijing)",
"officialUpdated": "Last updated",
+ "officialRoutes": "How devices connect",
+ "officialRoutesFootnote": "Direct connections don't go through the official relay and don't use the allowance.",
"officialDeviceID": "Device ID",
"officialWarning": "90% of the daily relay allowance has been used. Direct connections do not consume it.",
"officialAccounting": "Upload and download combined, including encryption overhead. Only official relay usage is measured; direct content and traffic are not recorded.",
diff --git a/ui/lib/l10n/app_ja.arb b/ui/lib/l10n/app_ja.arb
index 0556816..13db5ef 100644
--- a/ui/lib/l10n/app_ja.arb
+++ b/ui/lib/l10n/app_ja.arb
@@ -252,7 +252,8 @@
"officialSwitchConfirm": "現在のカスタムサーバーから切り替えます。保存済みのアドレスは保持されます。",
"customServer": "カスタムサーバー",
"saveAndConnect": "保存して接続",
- "officialUnused": "中継は未申請です。残量は未確認です",
+ "officialLoading": "残量を確認しています…",
+ "officialFetchFailed": "残量を取得できません。自動的に再試行します。",
"officialUnavailable": "使用量を取得できません。表示データは古い可能性があります",
"officialQuotaTitle": "本日の中継上限に達しました",
"officialQuotaBody": "公式中継は北京時間の午前0時にリセットされるまで停止します。LANと直接接続は引き続き利用できます。失敗した転送は後で再試行できます。",
@@ -260,7 +261,7 @@
"officialPaused": "公式中継は現在利用できません。直接接続は引き続き利用できます",
"officialViewUsage": "使用量を表示",
"officialAcknowledge": "確認しました",
- "officialToday": "本日の中継使用量",
+ "officialToday": "本日の中継残量",
"officialUsed": "使用済み",
"officialRemaining": "残量",
"officialDailyLimit": "1日の上限",
@@ -268,6 +269,8 @@
"officialDownload": "ダウンロード",
"officialReset": "リセット時刻(北京時間)",
"officialUpdated": "最終更新",
+ "officialRoutes": "デバイスの接続方法",
+ "officialRoutesFootnote": "直接接続は公式中継を経由せず、残量も消費しません。",
"officialDeviceID": "端末 ID",
"officialWarning": "本日の中継上限の90%を使用しました。直接接続ではこの残量は消費しません。",
"officialAccounting": "暗号化の通信量を含む送受信の合計です。公式中継のみ計測し、直接接続の内容や通信量は記録しません。",
diff --git a/ui/lib/l10n/app_localizations.dart b/ui/lib/l10n/app_localizations.dart
index dc96601..07f4db3 100644
--- a/ui/lib/l10n/app_localizations.dart
+++ b/ui/lib/l10n/app_localizations.dart
@@ -1622,11 +1622,17 @@ abstract class AppLocalizations {
/// **'Save and connect'**
String get saveAndConnect;
- /// No description provided for @officialUnused.
+ /// No description provided for @officialLoading.
///
/// In en, this message translates to:
- /// **'Relay not requested; allowance not yet verified'**
- String get officialUnused;
+ /// **'Checking the allowance…'**
+ String get officialLoading;
+
+ /// No description provided for @officialFetchFailed.
+ ///
+ /// In en, this message translates to:
+ /// **'Can\'t get the allowance right now. It will be retried automatically.'**
+ String get officialFetchFailed;
/// No description provided for @officialUnavailable.
///
@@ -1673,7 +1679,7 @@ abstract class AppLocalizations {
/// No description provided for @officialToday.
///
/// In en, this message translates to:
- /// **'Today\'s relay usage'**
+ /// **'Today\'s relay allowance'**
String get officialToday;
/// No description provided for @officialUsed.
@@ -1718,6 +1724,18 @@ abstract class AppLocalizations {
/// **'Last updated'**
String get officialUpdated;
+ /// No description provided for @officialRoutes.
+ ///
+ /// In en, this message translates to:
+ /// **'How devices connect'**
+ String get officialRoutes;
+
+ /// No description provided for @officialRoutesFootnote.
+ ///
+ /// In en, this message translates to:
+ /// **'Direct connections don\'t go through the official relay and don\'t use the allowance.'**
+ String get officialRoutesFootnote;
+
/// No description provided for @officialDeviceID.
///
/// In en, this message translates to:
diff --git a/ui/lib/l10n/app_localizations_en.dart b/ui/lib/l10n/app_localizations_en.dart
index fe5ea1f..dae9c81 100644
--- a/ui/lib/l10n/app_localizations_en.dart
+++ b/ui/lib/l10n/app_localizations_en.dart
@@ -939,8 +939,11 @@ class AppLocalizationsEn extends AppLocalizations {
String get saveAndConnect => 'Save and connect';
@override
- String get officialUnused =>
- 'Relay not requested; allowance not yet verified';
+ String get officialLoading => 'Checking the allowance…';
+
+ @override
+ String get officialFetchFailed =>
+ 'Can\'t get the allowance right now. It will be retried automatically.';
@override
String get officialUnavailable =>
@@ -968,7 +971,7 @@ class AppLocalizationsEn extends AppLocalizations {
String get officialAcknowledge => 'Got it';
@override
- String get officialToday => 'Today\'s relay usage';
+ String get officialToday => 'Today\'s relay allowance';
@override
String get officialUsed => 'Used';
@@ -991,6 +994,13 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get officialUpdated => 'Last updated';
+ @override
+ String get officialRoutes => 'How devices connect';
+
+ @override
+ String get officialRoutesFootnote =>
+ 'Direct connections don\'t go through the official relay and don\'t use the allowance.';
+
@override
String get officialDeviceID => 'Device ID';
diff --git a/ui/lib/l10n/app_localizations_ja.dart b/ui/lib/l10n/app_localizations_ja.dart
index 2f6d871..a805686 100644
--- a/ui/lib/l10n/app_localizations_ja.dart
+++ b/ui/lib/l10n/app_localizations_ja.dart
@@ -858,7 +858,10 @@ class AppLocalizationsJa extends AppLocalizations {
String get saveAndConnect => '保存して接続';
@override
- String get officialUnused => '中継は未申請です。残量は未確認です';
+ String get officialLoading => '残量を確認しています…';
+
+ @override
+ String get officialFetchFailed => '残量を取得できません。自動的に再試行します。';
@override
String get officialUnavailable => '使用量を取得できません。表示データは古い可能性があります';
@@ -883,7 +886,7 @@ class AppLocalizationsJa extends AppLocalizations {
String get officialAcknowledge => '確認しました';
@override
- String get officialToday => '本日の中継使用量';
+ String get officialToday => '本日の中継残量';
@override
String get officialUsed => '使用済み';
@@ -906,6 +909,12 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get officialUpdated => '最終更新';
+ @override
+ String get officialRoutes => 'デバイスの接続方法';
+
+ @override
+ String get officialRoutesFootnote => '直接接続は公式中継を経由せず、残量も消費しません。';
+
@override
String get officialDeviceID => '端末 ID';
diff --git a/ui/lib/l10n/app_localizations_zh.dart b/ui/lib/l10n/app_localizations_zh.dart
index 53f9646..c36dccc 100644
--- a/ui/lib/l10n/app_localizations_zh.dart
+++ b/ui/lib/l10n/app_localizations_zh.dart
@@ -852,7 +852,10 @@ class AppLocalizationsZh extends AppLocalizations {
String get saveAndConnect => '保存并连接';
@override
- String get officialUnused => '尚未申请中转,余额待核验';
+ String get officialLoading => '正在获取额度…';
+
+ @override
+ String get officialFetchFailed => '暂时获取不到额度,会自动重试。';
@override
String get officialUnavailable => '用量暂不可用,已有数据可能过期';
@@ -876,7 +879,7 @@ class AppLocalizationsZh extends AppLocalizations {
String get officialAcknowledge => '知道了';
@override
- String get officialToday => '今日中转用量';
+ String get officialToday => '今日中转额度';
@override
String get officialUsed => '已使用';
@@ -899,6 +902,12 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get officialUpdated => '最后更新';
+ @override
+ String get officialRoutes => '设备连接方式';
+
+ @override
+ String get officialRoutesFootnote => '直连时不经过官方中转,也不消耗额度。';
+
@override
String get officialDeviceID => '设备 ID';
@@ -1846,7 +1855,10 @@ class AppLocalizationsZhHantHk extends AppLocalizationsZh {
String get saveAndConnect => '儲存並連接';
@override
- String get officialUnused => '尚未申請中轉,餘額待確認';
+ String get officialLoading => '正在取得額度…';
+
+ @override
+ String get officialFetchFailed => '暫時無法取得額度,會自動重試。';
@override
String get officialUnavailable => '用量暫時無法取得,現有資料可能過期';
@@ -1870,7 +1882,7 @@ class AppLocalizationsZhHantHk extends AppLocalizationsZh {
String get officialAcknowledge => '知道了';
@override
- String get officialToday => '今日中轉用量';
+ String get officialToday => '今日中轉額度';
@override
String get officialUsed => '已使用';
@@ -1893,6 +1905,12 @@ class AppLocalizationsZhHantHk extends AppLocalizationsZh {
@override
String get officialUpdated => '上次更新';
+ @override
+ String get officialRoutes => '裝置連線方式';
+
+ @override
+ String get officialRoutesFootnote => '直連時不經過官方中轉,也不消耗額度。';
+
@override
String get officialDeviceID => '裝置 ID';
@@ -2840,7 +2858,10 @@ class AppLocalizationsZhHantTw extends AppLocalizationsZh {
String get saveAndConnect => '儲存並連線';
@override
- String get officialUnused => '尚未申請中繼,餘額待確認';
+ String get officialLoading => '正在取得額度…';
+
+ @override
+ String get officialFetchFailed => '暫時無法取得額度,會自動重試。';
@override
String get officialUnavailable => '用量暫時無法取得,現有資料可能過期';
@@ -2864,7 +2885,7 @@ class AppLocalizationsZhHantTw extends AppLocalizationsZh {
String get officialAcknowledge => '知道了';
@override
- String get officialToday => '今日中繼用量';
+ String get officialToday => '今日中繼額度';
@override
String get officialUsed => '已使用';
@@ -2887,6 +2908,12 @@ class AppLocalizationsZhHantTw extends AppLocalizationsZh {
@override
String get officialUpdated => '上次更新';
+ @override
+ String get officialRoutes => '裝置連線方式';
+
+ @override
+ String get officialRoutesFootnote => '直連時不經過官方中繼,也不消耗額度。';
+
@override
String get officialDeviceID => '裝置 ID';
diff --git a/ui/lib/l10n/app_zh.arb b/ui/lib/l10n/app_zh.arb
index 6f54161..c1cf44a 100644
--- a/ui/lib/l10n/app_zh.arb
+++ b/ui/lib/l10n/app_zh.arb
@@ -252,7 +252,8 @@
"officialSwitchConfirm": "这会切换当前自定义服务器,已保存的地址仍会保留。",
"customServer": "自定义服务器",
"saveAndConnect": "保存并连接",
- "officialUnused": "尚未申请中转,余额待核验",
+ "officialLoading": "正在获取额度…",
+ "officialFetchFailed": "暂时获取不到额度,会自动重试。",
"officialUnavailable": "用量暂不可用,已有数据可能过期",
"officialQuotaTitle": "今日中转额度已用完",
"officialQuotaBody": "官方中转已暂停,北京时间零点重置。局域网和公网直连仍可使用;传输失败时可稍后重试。",
@@ -260,7 +261,7 @@
"officialPaused": "官方中转暂不可用,直连仍可使用",
"officialViewUsage": "查看用量",
"officialAcknowledge": "知道了",
- "officialToday": "今日中转用量",
+ "officialToday": "今日中转额度",
"officialUsed": "已使用",
"officialRemaining": "剩余额度",
"officialDailyLimit": "每日额度",
@@ -268,6 +269,8 @@
"officialDownload": "下载",
"officialReset": "重置时间(北京时间)",
"officialUpdated": "最后更新",
+ "officialRoutes": "设备连接方式",
+ "officialRoutesFootnote": "直连时不经过官方中转,也不消耗额度。",
"officialDeviceID": "设备 ID",
"officialWarning": "今日中转额度已使用 90%,直连不消耗此额度。",
"officialAccounting": "上下行合计,包含加密传输开销;只统计官方中转,不统计直连内容或流量。",
diff --git a/ui/lib/l10n/app_zh_Hant_HK.arb b/ui/lib/l10n/app_zh_Hant_HK.arb
index 6f88728..fa8860e 100644
--- a/ui/lib/l10n/app_zh_Hant_HK.arb
+++ b/ui/lib/l10n/app_zh_Hant_HK.arb
@@ -252,7 +252,8 @@
"officialSwitchConfirm": "這會切換目前的自訂伺服器,已儲存的地址仍會保留。",
"customServer": "自訂伺服器",
"saveAndConnect": "儲存並連接",
- "officialUnused": "尚未申請中轉,餘額待確認",
+ "officialLoading": "正在取得額度…",
+ "officialFetchFailed": "暫時無法取得額度,會自動重試。",
"officialUnavailable": "用量暫時無法取得,現有資料可能過期",
"officialQuotaTitle": "今日中轉額度已用完",
"officialQuotaBody": "官方中轉已暫停,北京時間午夜重設。區域網絡和公網直連仍可使用;傳輸失敗時可稍後重試。",
@@ -260,7 +261,7 @@
"officialPaused": "官方中轉暫時無法使用,直連仍可使用",
"officialViewUsage": "查看用量",
"officialAcknowledge": "知道了",
- "officialToday": "今日中轉用量",
+ "officialToday": "今日中轉額度",
"officialUsed": "已使用",
"officialRemaining": "剩餘額度",
"officialDailyLimit": "每日額度",
@@ -268,6 +269,8 @@
"officialDownload": "下載",
"officialReset": "重設時間(北京時間)",
"officialUpdated": "上次更新",
+ "officialRoutes": "裝置連線方式",
+ "officialRoutesFootnote": "直連時不經過官方中轉,也不消耗額度。",
"officialDeviceID": "裝置 ID",
"officialWarning": "今日中轉額度已使用 90%,直連不消耗此額度。",
"officialAccounting": "上下行合計,包含加密傳輸開銷;只統計官方中轉,不統計直連內容或流量。",
diff --git a/ui/lib/l10n/app_zh_Hant_TW.arb b/ui/lib/l10n/app_zh_Hant_TW.arb
index 6242610..04f6964 100644
--- a/ui/lib/l10n/app_zh_Hant_TW.arb
+++ b/ui/lib/l10n/app_zh_Hant_TW.arb
@@ -252,7 +252,8 @@
"officialSwitchConfirm": "這會切換目前的自訂伺服器,已儲存的位址仍會保留。",
"customServer": "自訂伺服器",
"saveAndConnect": "儲存並連線",
- "officialUnused": "尚未申請中繼,餘額待確認",
+ "officialLoading": "正在取得額度…",
+ "officialFetchFailed": "暫時無法取得額度,會自動重試。",
"officialUnavailable": "用量暫時無法取得,現有資料可能過期",
"officialQuotaTitle": "今日中繼額度已用完",
"officialQuotaBody": "官方中繼已暫停,北京時間午夜重設。區域網路和公網直連仍可使用;傳輸失敗時可稍後重試。",
@@ -260,7 +261,7 @@
"officialPaused": "官方中繼暫時無法使用,直連仍可使用",
"officialViewUsage": "查看用量",
"officialAcknowledge": "知道了",
- "officialToday": "今日中繼用量",
+ "officialToday": "今日中繼額度",
"officialUsed": "已使用",
"officialRemaining": "剩餘額度",
"officialDailyLimit": "每日額度",
@@ -268,6 +269,8 @@
"officialDownload": "下載",
"officialReset": "重設時間(北京時間)",
"officialUpdated": "上次更新",
+ "officialRoutes": "裝置連線方式",
+ "officialRoutesFootnote": "直連時不經過官方中繼,也不消耗額度。",
"officialDeviceID": "裝置 ID",
"officialWarning": "今日中繼額度已使用 90%,直連不消耗此額度。",
"officialAccounting": "上下行合計,包含加密傳輸開銷;僅統計官方中繼,不統計直連內容或流量。",
diff --git a/ui/lib/pages/official_service_page.dart b/ui/lib/pages/official_service_page.dart
index 6418d6a..ab4dd44 100644
--- a/ui/lib/pages/official_service_page.dart
+++ b/ui/lib/pages/official_service_page.dart
@@ -5,9 +5,17 @@ import '../i18n.dart';
import '../main.dart';
import '../theme.dart';
import '../widgets/common.dart';
+import 'devices_page.dart' show connectionLabel, platformIcon;
+/// 官方服务:今日中转额度、各设备走直连还是中转、本机设备 ID。
+/// 额度一开启就由后台查询,没用过中转的设备也显示默认额度。
class OfficialServicePage extends StatelessWidget {
const OfficialServicePage({super.key});
+
+ // 后台空闲时 60 秒刷新一次;超过两个半周期没更新才算过期
+ static const _freshSeconds = 150;
+ static const _paused = {'global_exhausted', 'global_paused', 'relay_blocked', 'device_banned'};
+
String _mb(int bytes) => '${(bytes / 1000000).toStringAsFixed(2)} MB';
String _time(int seconds, {bool beijing = false}) {
var d = DateTime.fromMillisecondsSinceEpoch(seconds * 1000, isUtc: true);
@@ -19,164 +27,78 @@ class OfficialServicePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final state = AppScope.of(context), l = context.l10n, p = context.palette;
- final u = state.officialUsage;
- final known = u != null && u.updatedAtUnix.toInt() > 0;
- final fresh =
- known &&
- u.available &&
- DateTime.now().millisecondsSinceEpoch ~/ 1000 -
- u.updatedAtUnix.toInt() <
- 60;
- final used = known ? u.uploadBytes.toInt() + u.downloadBytes.toInt() : 0;
- final limit = known ? u.limitBytes.toInt() : 0;
- Widget row(String title, String value) => Padding(
- padding: const EdgeInsets.symmetric(vertical: 10),
- child: Row(
- children: [
- Expanded(
- child: Text(
- title,
- style: context.text.bodyMedium?.copyWith(color: p.textDim),
- ),
- ),
- SelectableText(value, style: context.text.bodyMedium),
- ],
- ),
- );
- final reason = u?.reason ?? '';
- final status = switch (reason) {
- 'quota_exhausted' => l.officialQuotaTitle,
- 'peer_quota_exhausted' => l.officialPeerQuota,
- 'global_exhausted' ||
- 'global_paused' ||
- 'relay_blocked' ||
- 'device_banned' => l.officialPaused,
- _ =>
- !known
- ? l.officialUnused
- : !fresh
- ? l.officialUnavailable
- : state.status?.signalingConnected == true
- ? l.connected
- : l.notConnected,
- };
+ final connected = state.status?.signalingConnected == true;
+ final peers = state.peers;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- PageHeader(title: l.officialService),
+ PageHeader(
+ title: l.officialService,
+ actions: [
+ Padding(
+ padding: const EdgeInsets.only(bottom: 6),
+ child: StatusDot(
+ color: connected ? p.online : p.textFaint,
+ label: connected ? l.connected : l.notConnected,
+ ),
+ ),
+ ],
+ ),
Expanded(
child: ListView(
- padding: const EdgeInsets.fromLTRB(
- Insets.xl,
- 0,
- Insets.xl,
- Insets.xxl,
- ),
+ padding: const EdgeInsets.fromLTRB(Insets.xl, 0, Insets.xl, Insets.xxl),
children: [
- GroupSection(
- title: l.connectionStatus,
- child: GroupBox(
- children: [
- Padding(
- padding: const EdgeInsets.all(Insets.lg),
- child: Text(
- status,
- style: context.text.bodyMedium?.copyWith(
- color: fresh ? p.text : p.warning,
- ),
- ),
- ),
- ],
- ),
- ),
GroupSection(
title: l.officialToday,
footnote: l.officialAccounting,
- child: GroupBox(
- children: [
- Padding(
- padding: const EdgeInsets.all(Insets.lg),
- child: Column(
- children: [
- if (known) ...[
- row(l.officialUsed, _mb(used)),
- LinearProgressIndicator(
- value: limit > 0
- ? (used / limit).clamp(0.0, 1.0)
- : 0,
- color: used >= limit * .9 ? p.warning : p.accent,
- backgroundColor: p.fill,
- ),
- const SizedBox(height: 12),
- row(
- l.officialRemaining,
- _mb(u.remainingBytes.toInt()),
- ),
- row(l.officialDailyLimit, _mb(limit)),
- row(l.officialUpload, _mb(u.uploadBytes.toInt())),
- row(
- l.officialDownload,
- _mb(u.downloadBytes.toInt()),
- ),
- row(
- l.officialReset,
- _time(u.resetAtUnix.toInt(), beijing: true),
- ),
- row(
- l.officialUpdated,
- _time(u.updatedAtUnix.toInt()),
- ),
- if (limit > 0 && used >= limit * .9)
- Padding(
- padding: const EdgeInsets.only(top: 12),
- child: Text(
- l.officialWarning,
- style: context.text.bodySmall?.copyWith(
- color: p.warning,
- ),
- ),
+ child: _allowance(context),
+ ),
+ if (peers.isNotEmpty)
+ GroupSection(
+ title: l.officialRoutes,
+ footnote: l.officialRoutesFootnote,
+ child: GroupBox(
+ dividerIndent: 52,
+ children: [
+ for (final d in peers)
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: Insets.lg, vertical: Insets.md),
+ child: Row(
+ children: [
+ Icon(platformIcon(d.platform), size: 20, color: p.textDim),
+ const SizedBox(width: Insets.md + 4),
+ Expanded(
+ child: Text(d.name, style: context.text.labelLarge, overflow: TextOverflow.ellipsis),
),
- ] else
- Padding(
- padding: const EdgeInsets.symmetric(vertical: 24),
- child: Text(
- l.officialUnused,
- style: context.text.bodyMedium,
+ const SizedBox(width: Insets.md),
+ StatusDot(
+ color: d.online ? p.online : p.textFaint,
+ label: d.online ? connectionLabel(d) : l.offline,
),
- ),
- ],
- ),
- ),
- ],
+ ],
+ ),
+ ),
+ ],
+ ),
),
- ),
GroupSection(
title: l.officialDeviceID,
child: GroupBox(
children: [
Padding(
- padding: const EdgeInsets.all(Insets.lg),
+ padding: const EdgeInsets.fromLTRB(Insets.lg, Insets.sm, Insets.sm, Insets.sm),
child: Row(
children: [
Expanded(
child: SelectableText(
state.status?.deviceId ?? state.self?.id ?? '',
- style: context.text.bodyMedium?.copyWith(
- fontFamily: monoFamily,
- ),
+ style: context.text.bodyMedium?.copyWith(fontFamily: monoFamily),
),
),
IconButton(
- tooltip: MaterialLocalizations.of(
- context,
- ).copyButtonLabel,
+ tooltip: MaterialLocalizations.of(context).copyButtonLabel,
onPressed: () => Clipboard.setData(
- ClipboardData(
- text:
- state.status?.deviceId ??
- state.self?.id ??
- '',
- ),
+ ClipboardData(text: state.status?.deviceId ?? state.self?.id ?? ''),
),
icon: const Icon(Icons.copy_outlined, size: 18),
),
@@ -186,13 +108,122 @@ class OfficialServicePage extends StatelessWidget {
],
),
),
- Text(
- l.officialPrivacy,
- style: context.text.bodySmall?.copyWith(color: p.textDim),
+ Text(l.officialPrivacy, style: context.text.bodySmall),
+ ],
+ ),
+ ),
+ ],
+ );
+ }
+
+ Widget _allowance(BuildContext context) {
+ final state = AppScope.of(context), l = context.l10n, p = context.palette;
+ final u = state.officialUsage;
+ final reason = u?.reason ?? '';
+ final known = u != null && u.updatedAtUnix.toInt() > 0;
+ if (!known) {
+ // 刚开启或刚启动时还没查到;查询失败时后台会自动重试
+ final failed = reason.isNotEmpty;
+ return GroupBox(
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: Insets.lg, vertical: Insets.xl),
+ child: Text(
+ _paused.contains(reason)
+ ? l.officialPaused
+ : failed
+ ? l.officialFetchFailed
+ : l.officialLoading,
+ style: context.text.bodyMedium?.copyWith(color: failed ? p.warning : p.textDim),
+ ),
+ ),
+ ],
+ );
+ }
+ final fresh =
+ u.available && DateTime.now().millisecondsSinceEpoch ~/ 1000 - u.updatedAtUnix.toInt() < _freshSeconds;
+ final upload = u.uploadBytes.toInt(), download = u.downloadBytes.toInt();
+ final used = upload + download;
+ final limit = u.limitBytes.toInt();
+ final remaining = u.remainingBytes.toInt();
+ final low = limit <= 0 || remaining <= limit * .1;
+ final notice = switch (reason) {
+ 'quota_exhausted' => l.officialQuotaTitle,
+ 'peer_quota_exhausted' => l.officialPeerQuota,
+ _ when _paused.contains(reason) => l.officialPaused,
+ _ when !fresh => l.officialUnavailable,
+ _ when limit > 0 && used >= limit * .9 => l.officialWarning,
+ _ => null,
+ };
+ const figures = [FontFeature.tabularFigures()];
+ Widget info(String title, String value) => Padding(
+ padding: const EdgeInsets.symmetric(horizontal: Insets.lg, vertical: 10),
+ child: Row(
+ children: [
+ Expanded(child: Text(title, style: context.text.bodyMedium?.copyWith(color: p.textDim))),
+ SelectableText(value, style: context.text.bodyMedium?.copyWith(fontFeatures: figures)),
+ ],
+ ),
+ );
+ return GroupBox(
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(Insets.lg, Insets.lg, Insets.lg, Insets.lg),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ if (notice != null) ...[
+ Text(notice, style: context.text.bodyMedium?.copyWith(color: p.warning)),
+ const SizedBox(height: Insets.md),
+ ],
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(l.officialRemaining, style: context.text.bodySmall),
+ const SizedBox(height: 2),
+ Text(
+ _mb(remaining),
+ style: context.text.headlineSmall?.copyWith(
+ fontFeatures: figures,
+ color: fresh ? p.text : p.textDim,
+ ),
+ ),
+ ],
+ ),
+ ),
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Text(l.officialDailyLimit, style: context.text.bodySmall),
+ const SizedBox(height: 2),
+ Text(_mb(limit), style: context.text.bodyMedium?.copyWith(fontFeatures: figures)),
+ ],
+ ),
+ ],
+ ),
+ const SizedBox(height: Insets.md),
+ // 条的长度是剩余额度:满格表示今天还没用
+ ClipRRect(
+ borderRadius: BorderRadius.circular(3),
+ child: LinearProgressIndicator(
+ value: limit > 0 ? (remaining / limit).clamp(0.0, 1.0) : 0,
+ minHeight: 6,
+ color: low ? p.warning : p.accent,
+ backgroundColor: p.fill,
+ ),
),
],
),
),
+ info(l.officialUsed, _mb(used)),
+ info(l.officialUpload, _mb(upload)),
+ info(l.officialDownload, _mb(download)),
+ info(l.officialReset, _time(u.resetAtUnix.toInt(), beijing: true)),
+ info(l.officialUpdated, _time(u.updatedAtUnix.toInt())),
],
);
}
diff --git a/ui/test/official_service_test.dart b/ui/test/official_service_test.dart
index d302c7b..2435535 100644
--- a/ui/test/official_service_test.dart
+++ b/ui/test/official_service_test.dart
@@ -59,7 +59,14 @@ void main() {
await tester.tap(find.text('官方服务').first);
await tester.pumpAndSettle();
expect(find.byType(OfficialServicePage), findsOneWidget);
- expect(find.text('尚未申请中转,余额待核验'), findsWidgets);
+ expect(
+ find.descendant(
+ of: find.byType(OfficialServicePage),
+ matching: find.text('未连接'),
+ ),
+ findsOneWidget,
+ );
+ expect(find.text('正在获取额度…'), findsOneWidget);
expect(find.text('0.00 MB'), findsNothing);
state.debugSeed(
status: state.status!,
@@ -135,6 +142,84 @@ void main() {
expect(find.byType(AlertDialog), findsNothing);
},
);
+ testWidgets(
+ 'allowance shows before any relay and devices show their route',
+ (tester) async {
+ final state = OfficialTestState(official: true);
+ state.debugSeed(
+ status: state.status!.deepCopy()..signalingConnected = true,
+ config: state.config!,
+ self: state.self!,
+ peers: [
+ Device(
+ id: 'mac',
+ name: '书房 Mac',
+ platform: 'darwin',
+ online: true,
+ connection: ConnectionKind.CONNECTION_KIND_DIRECT,
+ ),
+ Device(
+ id: 'win',
+ name: '办公室 Windows',
+ platform: 'windows',
+ online: true,
+ connection: ConnectionKind.CONNECTION_KIND_RELAY,
+ ),
+ Device(id: 'linux', name: 'Ubuntu', platform: 'linux'),
+ ],
+ );
+ await tester.pumpWidget(PasteFerryApp(state: state));
+ await tester.pumpAndSettle();
+ await tester.tap(find.text('官方服务').first);
+ await tester.pumpAndSettle();
+ final page = find.byType(OfficialServicePage);
+ Finder inPage(String text) =>
+ find.descendant(of: page, matching: find.text(text));
+ expect(inPage('已连接'), findsOneWidget);
+ expect(inPage('正在获取额度…'), findsOneWidget);
+ // A failed first query is not shown as zero or as a warning about usage.
+ state.usage(
+ OfficialUsage(available: false, reason: 'service_unavailable'),
+ );
+ await tester.pumpAndSettle();
+ expect(inPage('暂时获取不到额度,会自动重试。'), findsOneWidget);
+ // An unbound device gets the untouched default allowance from the gateway.
+ final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
+ state.usage(
+ OfficialUsage(
+ available: true,
+ day: '2026-10-19',
+ limitBytes: Int64(100000000),
+ remainingBytes: Int64(100000000),
+ resetAtUnix: Int64(now + 3600),
+ updatedAtUnix: Int64(now),
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(inPage('100.00 MB'), findsNWidgets(2));
+ expect(inPage('0.00 MB'), findsNWidgets(3));
+ expect(inPage('用量暂不可用,已有数据可能过期'), findsNothing);
+ final bar = tester.widget<LinearProgressIndicator>(
+ find.descendant(of: page, matching: find.byType(LinearProgressIndicator)),
+ );
+ expect(bar.value, 1.0);
+ expect(inPage('书房 Mac'), findsOneWidget);
+ expect(inPage('直连'), findsOneWidget);
+ expect(inPage('中转'), findsOneWidget);
+ expect(inPage('离线'), findsOneWidget);
+ // Figures older than two and a half idle refreshes are marked stale.
+ state.usage(
+ OfficialUsage(
+ available: true,
+ limitBytes: Int64(100000000),
+ remainingBytes: Int64(100000000),
+ updatedAtUnix: Int64(now - 600),
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(inPage('用量暂不可用,已有数据可能过期'), findsOneWidget);
+ },
+ );
for (final language in ['en', 'zh-Hans', 'zh-Hant-TW', 'zh-Hant-HK', 'ja']) {
testWidgets('official usage fits minimum window in $language', (
tester,
diff --git a/ui/tool/l10n/strings.py b/ui/tool/l10n/strings.py
index e6daaff..3f8479b 100644
--- a/ui/tool/l10n/strings.py
+++ b/ui/tool/l10n/strings.py
@@ -294,7 +294,8 @@ S = [
('officialSwitchConfirm', 'This switches away from your custom server. Its saved address will be retained.', '这会切换当前自定义服务器,已保存的地址仍会保留。', '現在のカスタムサーバーから切り替えます。保存済みのアドレスは保持されます。', '這會切換目前的自訂伺服器,已儲存的位址仍會保留。', '這會切換目前的自訂伺服器,已儲存的地址仍會保留。'),
('customServer', 'Custom server', '自定义服务器', 'カスタムサーバー', '自訂伺服器', '自訂伺服器'),
('saveAndConnect', 'Save and connect', '保存并连接', '保存して接続', '儲存並連線', '儲存並連接'),
- ('officialUnused', 'Relay not requested; allowance not yet verified', '尚未申请中转,余额待核验', '中継は未申請です。残量は未確認です', '尚未申請中繼,餘額待確認', '尚未申請中轉,餘額待確認'),
+ ('officialLoading', 'Checking the allowance…', '正在获取额度…', '残量を確認しています…', '正在取得額度…', '正在取得額度…'),
+ ('officialFetchFailed', "Can't get the allowance right now. It will be retried automatically.", '暂时获取不到额度,会自动重试。', '残量を取得できません。自動的に再試行します。', '暫時無法取得額度,會自動重試。', '暫時無法取得額度,會自動重試。'),
('officialUnavailable', 'Usage is unavailable; existing data may be out of date', '用量暂不可用,已有数据可能过期', '使用量を取得できません。表示データは古い可能性があります', '用量暫時無法取得,現有資料可能過期', '用量暫時無法取得,現有資料可能過期'),
('officialQuotaTitle', 'Daily relay allowance used up', '今日中转额度已用完', '本日の中継上限に達しました', '今日中繼額度已用完', '今日中轉額度已用完'),
('officialQuotaBody', 'Official relay is paused until the daily reset at midnight Beijing time. LAN and direct Internet connections remain available. Failed transfers can be retried later.', '官方中转已暂停,北京时间零点重置。局域网和公网直连仍可使用;传输失败时可稍后重试。', '公式中継は北京時間の午前0時にリセットされるまで停止します。LANと直接接続は引き続き利用できます。失敗した転送は後で再試行できます。', '官方中繼已暫停,北京時間午夜重設。區域網路和公網直連仍可使用;傳輸失敗時可稍後重試。', '官方中轉已暫停,北京時間午夜重設。區域網絡和公網直連仍可使用;傳輸失敗時可稍後重試。'),
@@ -302,7 +303,7 @@ S = [
('officialPaused', 'Official relay is unavailable. Direct connections remain available.', '官方中转暂不可用,直连仍可使用', '公式中継は現在利用できません。直接接続は引き続き利用できます', '官方中繼暫時無法使用,直連仍可使用', '官方中轉暫時無法使用,直連仍可使用'),
('officialViewUsage', 'View usage', '查看用量', '使用量を表示', '查看用量', '查看用量'),
('officialAcknowledge', 'Got it', '知道了', '確認しました', '知道了', '知道了'),
- ('officialToday', "Today's relay usage", '今日中转用量', '本日の中継使用量', '今日中繼用量', '今日中轉用量'),
+ ('officialToday', "Today's relay allowance", '今日中转额度', '本日の中継残量', '今日中繼額度', '今日中轉額度'),
('officialUsed', 'Used', '已使用', '使用済み', '已使用', '已使用'),
('officialRemaining', 'Remaining', '剩余额度', '残量', '剩餘額度', '剩餘額度'),
('officialDailyLimit', 'Daily allowance', '每日额度', '1日の上限', '每日額度', '每日額度'),
@@ -310,6 +311,8 @@ S = [
('officialDownload', 'Download', '下载', 'ダウンロード', '下載', '下載'),
('officialReset', 'Reset time (Beijing)', '重置时间(北京时间)', 'リセット時刻(北京時間)', '重設時間(北京時間)', '重設時間(北京時間)'),
('officialUpdated', 'Last updated', '最后更新', '最終更新', '上次更新', '上次更新'),
+ ('officialRoutes', 'How devices connect', '设备连接方式', 'デバイスの接続方法', '裝置連線方式', '裝置連線方式'),
+ ('officialRoutesFootnote', "Direct connections don't go through the official relay and don't use the allowance.", '直连时不经过官方中转,也不消耗额度。', '直接接続は公式中継を経由せず、残量も消費しません。', '直連時不經過官方中繼,也不消耗額度。', '直連時不經過官方中轉,也不消耗額度。'),
('officialDeviceID', 'Device ID', '设备 ID', '端末 ID', '裝置 ID', '裝置 ID'),
('officialWarning', '90% of the daily relay allowance has been used. Direct connections do not consume it.', '今日中转额度已使用 90%,直连不消耗此额度。', '本日の中継上限の90%を使用しました。直接接続ではこの残量は消費しません。', '今日中繼額度已使用 90%,直連不消耗此額度。', '今日中轉額度已使用 90%,直連不消耗此額度。'),
('officialAccounting', 'Upload and download combined, including encryption overhead. Only official relay usage is measured; direct content and traffic are not recorded.', '上下行合计,包含加密传输开销;只统计官方中转,不统计直连内容或流量。', '暗号化の通信量を含む送受信の合計です。公式中継のみ計測し、直接接続の内容や通信量は記録しません。', '上下行合計,包含加密傳輸開銷;僅統計官方中繼,不統計直連內容或流量。', '上下行合計,包含加密傳輸開銷;只統計官方中轉,不統計直連內容或流量。'),