opencode-kunrouter-auth 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +1 -1
- package/index.mjs +33 -30
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ magpie plugin login kunrouter
|
|
|
48
48
|
## 显示什么
|
|
49
49
|
|
|
50
50
|
- **钱包**:`/api/user/self` 的 `quota`,按 `/api/status` 的 `quota_per_unit` 换算,单位跟随站点币种(本站 🥚)。
|
|
51
|
-
- **订阅额度**:`/api/subscription/self` 里的套餐总额、已用、剩余和到期时间;Lite
|
|
51
|
+
- **订阅额度**:`/api/subscription/self` 里的套餐总额、已用、剩余和到期时间;Lite 等套餐的日/周/月滚动窗口也会分别显示为进度条。
|
|
52
52
|
- **计费优先级**:非默认优先级会跟在顶部套餐名后,不再单独占一行。
|
|
53
53
|
- **分组**:读 `/api/desktop/keys` 按 Key 遮罩匹配真实分组,读不到才退回授权时快照。
|
|
54
54
|
- **签到**:站点开着 `checkin_enabled` 时每日自动签到。
|
package/index.mjs
CHANGED
|
@@ -14,7 +14,7 @@ const SITE =
|
|
|
14
14
|
const API =
|
|
15
15
|
process.env.KUNROUTER_API?.replace(/\/+$/, "") ||
|
|
16
16
|
"https://direct.wcnmb.fun" // 直连 /v1,不受 CF 超时限制
|
|
17
|
-
const VERSION = "0.8.
|
|
17
|
+
const VERSION = "0.8.3"
|
|
18
18
|
const MAGPIE_CLIENT_ID = "magpie"
|
|
19
19
|
// 活动邀请码。改活动时优先用环境变量覆盖,不用改代码发版。
|
|
20
20
|
const INVITE_CODE = (
|
|
@@ -514,9 +514,10 @@ function durationLabel(seconds) {
|
|
|
514
514
|
}
|
|
515
515
|
|
|
516
516
|
function quotaWindowLabel(seconds) {
|
|
517
|
-
|
|
518
|
-
if (
|
|
519
|
-
if (
|
|
517
|
+
const value = Number(seconds)
|
|
518
|
+
if (value === 86400) return "日额度"
|
|
519
|
+
if (value === 604800) return "周额度"
|
|
520
|
+
if (value >= 28 * 86400 && value <= 31 * 86400) return "月额度"
|
|
520
521
|
return `${durationLabel(seconds)}额度`
|
|
521
522
|
}
|
|
522
523
|
|
|
@@ -862,31 +863,34 @@ export const KunRouterPlugin = async (input) => {
|
|
|
862
863
|
: ""
|
|
863
864
|
const allowWalletOverflow = sub.allow_wallet_overflow !== false
|
|
864
865
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
866
|
+
// 滚动窗口套餐把额度全放在 quota_windows 里,amount_total 是 0;
|
|
867
|
+
// 这时不画一条 0 / 0 的空进度条。
|
|
868
|
+
if (total > 0) {
|
|
869
|
+
subscriptionWindows.push({
|
|
870
|
+
name: title,
|
|
871
|
+
used: percent,
|
|
872
|
+
amount: used / unit,
|
|
873
|
+
limit: totalAmount,
|
|
874
|
+
unit: currencyUnit,
|
|
875
|
+
...(sub.start_time && sub.end_time
|
|
876
|
+
? {
|
|
877
|
+
span: Math.max(
|
|
878
|
+
0,
|
|
879
|
+
Number(sub.end_time) - Number(sub.start_time),
|
|
880
|
+
),
|
|
881
|
+
}
|
|
882
|
+
: {}),
|
|
883
|
+
...(sub.end_time
|
|
884
|
+
? {
|
|
885
|
+
runsOutAt: new Date(Number(sub.end_time) * 1000).toISOString(),
|
|
886
|
+
runsOut: remainingAmount,
|
|
887
|
+
}
|
|
888
|
+
: {}),
|
|
889
|
+
// 套餐允许钱包兜底时,用完订阅不会让账号停摆。
|
|
890
|
+
aside: allowWalletOverflow,
|
|
891
|
+
display: `剩余 ${money(remainingAmount)} / ${money(totalAmount)}${endHint ? ` · ${endHint} 到期` : ""}`,
|
|
892
|
+
})
|
|
893
|
+
}
|
|
890
894
|
|
|
891
895
|
for (const window of Array.isArray(sub.quota_windows)
|
|
892
896
|
? sub.quota_windows
|
|
@@ -906,7 +910,6 @@ export const KunRouterPlugin = async (input) => {
|
|
|
906
910
|
amount: windowUsed / unit,
|
|
907
911
|
limit: windowLimit / unit,
|
|
908
912
|
unit: currencyUnit,
|
|
909
|
-
balance: windowRemaining / unit,
|
|
910
913
|
span: Number(window?.window_seconds) || 0,
|
|
911
914
|
...(nextRelease
|
|
912
915
|
? { resetsAt: new Date(nextRelease * 1000).toISOString() }
|
package/package.json
CHANGED