feat(usage): add support for access token and user ID in usage scripts
Add optional accessToken and userId fields to usage query scripts,
enabling queries to authenticated endpoints like /api/user/self.
Changes:
- Add accessToken and userId fields to UsageScript type (frontend & backend)
- Extend script engine to support {{accessToken}} and {{userId}} placeholders
- Update NewAPI preset template to use /api/user/self endpoint
- Add UI inputs for access token and user ID in UsageScriptModal
- Pass new parameters through service layer to script executor
This allows users to query usage data from endpoints that require
login credentials, providing more accurate balance information for
services like NewAPI/OneAPI platforms.
This commit is contained in:
@@ -43,6 +43,8 @@ export interface UsageScript {
|
||||
language: "javascript"; // 脚本语言
|
||||
code: string; // 脚本代码(JSON 格式配置)
|
||||
timeout?: number; // 超时时间(秒,默认 10)
|
||||
accessToken?: string; // 访问令牌(用于需要登录的接口)
|
||||
userId?: string; // 用户ID(用于需要用户标识的接口)
|
||||
}
|
||||
|
||||
// 单个套餐用量数据
|
||||
|
||||
Reference in New Issue
Block a user