🐛 fix(editor): Add Go template editor component and update related schemas
This commit is contained in:
@@ -46,6 +46,7 @@ import {
|
||||
TooltipTrigger,
|
||||
} from '@workspace/ui/components/tooltip';
|
||||
import { ConfirmButton } from '@workspace/ui/custom-components/confirm-button';
|
||||
import { GoTemplateEditor } from '@workspace/ui/custom-components/editor';
|
||||
import { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input';
|
||||
import { Icon } from '@workspace/ui/custom-components/icon';
|
||||
import { UploadImage } from '@workspace/ui/custom-components/upload-image';
|
||||
@@ -63,7 +64,7 @@ const createClientFormSchema = (t: any) =>
|
||||
description: z.string().optional(),
|
||||
icon: z.string().optional(),
|
||||
user_agent: z.string().min(1, `User-Agent ${t('form.validation.userAgentRequiredSuffix')}`),
|
||||
proxy_template: z.string().default(''),
|
||||
schema: z.string().default(''),
|
||||
template: z.string().default(''),
|
||||
output_format: z.string().default(''),
|
||||
download_link: z.object({
|
||||
@@ -94,7 +95,7 @@ export function ProtocolForm() {
|
||||
description: '',
|
||||
icon: '',
|
||||
user_agent: '',
|
||||
proxy_template: '',
|
||||
schema: '',
|
||||
template: '',
|
||||
output_format: '',
|
||||
download_link: {
|
||||
@@ -230,7 +231,7 @@ export function ProtocolForm() {
|
||||
description: '',
|
||||
icon: '',
|
||||
user_agent: '',
|
||||
proxy_template: '',
|
||||
schema: '',
|
||||
template: '',
|
||||
output_format: '',
|
||||
download_link: {
|
||||
@@ -252,7 +253,7 @@ export function ProtocolForm() {
|
||||
description: client.description || '',
|
||||
icon: client.icon || '',
|
||||
user_agent: client.user_agent,
|
||||
proxy_template: client.proxy_template || '',
|
||||
schema: client.proxy_template || '',
|
||||
template: client.template || '',
|
||||
output_format: client.output_format || '',
|
||||
download_link: {
|
||||
@@ -301,6 +302,7 @@ export function ProtocolForm() {
|
||||
if (editingClient) {
|
||||
await updateSubscribeApplication({
|
||||
...data,
|
||||
proxy_template: data.schema || '',
|
||||
is_default: editingClient.is_default,
|
||||
id: editingClient.id,
|
||||
});
|
||||
@@ -308,6 +310,7 @@ export function ProtocolForm() {
|
||||
} else {
|
||||
await createSubscribeApplication({
|
||||
...data,
|
||||
proxy_template: data.schema || '',
|
||||
is_default: false,
|
||||
});
|
||||
toast.success(t('actions.createSuccess'));
|
||||
@@ -491,20 +494,17 @@ export function ProtocolForm() {
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name='proxy_template'
|
||||
name='schema'
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>{t('form.fields.proxyTemplate')}</FormLabel>
|
||||
<FormLabel>{t('form.fields.schema')}</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
placeholder='clash://install-config?url={url}&name={name}'
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormDescription>
|
||||
{t('form.descriptions.proxyTemplate')}
|
||||
{`{url} {name}`}
|
||||
</FormDescription>
|
||||
<FormDescription>{t('form.descriptions.schema')}</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
@@ -517,10 +517,10 @@ export function ProtocolForm() {
|
||||
<FormItem>
|
||||
<FormLabel>{t('form.fields.template')}</FormLabel>
|
||||
<FormControl>
|
||||
<Textarea
|
||||
placeholder='proxies:\n - name: {name}\n type: {type}\n server: {server}\n port: {port}'
|
||||
className='min-h-[120px] font-mono text-sm'
|
||||
{...field}
|
||||
<GoTemplateEditor
|
||||
enableSprig
|
||||
value={field.value || ''}
|
||||
onChange={(value) => field.onChange(value)}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormDescription>{t('form.descriptions.template')}</FormDescription>
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
"name": "Name",
|
||||
"description": "Description",
|
||||
"outputFormat": "Output Format",
|
||||
"proxyTemplate": "Subscription Link",
|
||||
"template": "Config Template"
|
||||
"schema": "URL Schema",
|
||||
"template": "Subscription File Template"
|
||||
},
|
||||
"descriptions": {
|
||||
"icon": "Icon URL or base64 encoding",
|
||||
@@ -61,8 +61,8 @@
|
||||
"userAgentPrefix": "Client identifier for distinguishing different clients",
|
||||
"description": "Detailed client description",
|
||||
"outputFormat": "Subscription configuration file format",
|
||||
"proxyTemplate": "Subscription link template, supports variables: ",
|
||||
"template": "Subscription configuration template, supports various variables",
|
||||
"schema": "URL Schema template, supports variables: '{url}' subscription URL, '{name}' site name",
|
||||
"template": "Subscription file template, supports various variables",
|
||||
"downloadLink": "platform download URL"
|
||||
},
|
||||
"validation": {
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
"icon": "图标 URL 或 base64 编码",
|
||||
"name": "客户端显示名称",
|
||||
"outputFormat": "订阅配置文件格式",
|
||||
"proxyTemplate": "订阅链接模板,支持变量:",
|
||||
"template": "订阅配置模板,支持各种变量",
|
||||
"schema": "URL Schema 模板,支持变量:'{url}' 订阅地址,'{name}' 站点名称",
|
||||
"template": "订阅文件模板,支持各种变量",
|
||||
"userAgentPrefix": "用于区分不同客户端的客户端标识符"
|
||||
},
|
||||
"editTitle": "编辑客户端",
|
||||
@@ -57,8 +57,8 @@
|
||||
"icon": "图标",
|
||||
"name": "名称",
|
||||
"outputFormat": "输出格式",
|
||||
"proxyTemplate": "订阅链接",
|
||||
"template": "配置模板"
|
||||
"schema": "URL Schema",
|
||||
"template": "订阅文件模板"
|
||||
},
|
||||
"tabs": {
|
||||
"basic": "基本信息",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @ts-ignore
|
||||
|
||||
|
||||
// API 更新时间:
|
||||
// API 唯一标识:
|
||||
import * as ads from './ads';
|
||||
|
||||
+3
@@ -339,6 +339,7 @@ declare namespace API {
|
||||
name: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
scheme?: string;
|
||||
user_agent: string;
|
||||
is_default: boolean;
|
||||
proxy_template: string;
|
||||
@@ -1501,6 +1502,7 @@ declare namespace API {
|
||||
name: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
scheme?: string;
|
||||
user_agent: string;
|
||||
is_default: boolean;
|
||||
proxy_template: string;
|
||||
@@ -1779,6 +1781,7 @@ declare namespace API {
|
||||
name: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
scheme?: string;
|
||||
user_agent: string;
|
||||
is_default: boolean;
|
||||
proxy_template: string;
|
||||
|
||||
Reference in New Issue
Block a user