feat(usage): add custom blank template for usage script
- 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
This commit is contained in:
@@ -27,6 +27,20 @@ interface UsageScriptModalProps {
|
|||||||
|
|
||||||
// 预设模板(JS 对象字面量格式)
|
// 预设模板(JS 对象字面量格式)
|
||||||
const PRESET_TEMPLATES: Record<string, string> = {
|
const PRESET_TEMPLATES: Record<string, string> = {
|
||||||
|
自定义: `({
|
||||||
|
request: {
|
||||||
|
url: "",
|
||||||
|
method: "GET",
|
||||||
|
headers: {}
|
||||||
|
},
|
||||||
|
extractor: function(response) {
|
||||||
|
return {
|
||||||
|
remaining: 0,
|
||||||
|
unit: "USD"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
})`,
|
||||||
|
|
||||||
通用模板: `({
|
通用模板: `({
|
||||||
request: {
|
request: {
|
||||||
url: "{{baseUrl}}/user/balance",
|
url: "{{baseUrl}}/user/balance",
|
||||||
|
|||||||
Reference in New Issue
Block a user