From 802c3bffd9d3a13dd2729183b7dd3d0c4e80299e Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 4 Nov 2025 21:53:42 +0800 Subject: [PATCH] feat(usage): add custom blank template for usage script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add "自定义" (Custom) template as the first preset option - Provide minimal structure with empty URL and headers for full customization - Include basic extractor function returning remaining and unit fields - Allow users to build usage queries from scratch without starting from complex examples --- src/components/UsageScriptModal.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/components/UsageScriptModal.tsx b/src/components/UsageScriptModal.tsx index 36e4046..451ad14 100644 --- a/src/components/UsageScriptModal.tsx +++ b/src/components/UsageScriptModal.tsx @@ -27,6 +27,20 @@ interface UsageScriptModalProps { // 预设模板(JS 对象字面量格式) const PRESET_TEMPLATES: Record = { + 自定义: `({ + request: { + url: "", + method: "GET", + headers: {} + }, + extractor: function(response) { + return { + remaining: 0, + unit: "USD" + }; + } +})`, + 通用模板: `({ request: { url: "{{baseUrl}}/user/balance",