From dafa7f53ac4cc64b2019340272e86b1a3324ba98 Mon Sep 17 00:00:00 2001 From: William Tso Date: Wed, 23 Apr 2025 21:03:16 +0800 Subject: [PATCH] create en --- app/create-shorturl/page.tsx | 90 ++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/app/create-shorturl/page.tsx b/app/create-shorturl/page.tsx index 70f8496..f6dc1d1 100644 --- a/app/create-shorturl/page.tsx +++ b/app/create-shorturl/page.tsx @@ -47,11 +47,11 @@ function CreateShortUrlForm() { const [error, setError] = useState(null); const [success, setSuccess] = useState(false); - // 使用 useEffect 在加载时添加用户信息到表单数据中 + // Use useEffect to add user information to form data on load useEffect(() => { if (user) { - console.log('当前用户:', user.email); - // 可以在这里添加用户相关数据到表单中 + console.log('Current user:', user.email); + // Can add user-related data to the form here } }, [user]); @@ -93,32 +93,32 @@ function CreateShortUrlForm() { setError(null); try { - // 验证必填字段 + // Validate required fields if (!formData.originalUrl) { - throw new Error('原始 URL 是必填项'); + throw new Error('Original URL is required'); } if (!formData.title) { - throw new Error('标题是必填项'); + throw new Error('Title is required'); } if (!formData.teamId) { - throw new Error('团队是必填项'); + throw new Error('Team is required'); } if (!formData.projectId) { - throw new Error('项目是必填项'); + throw new Error('Project is required'); } if (!formData.domain) { - throw new Error('域名是必填项'); + throw new Error('Domain is required'); } - // 按照API要求构建请求数据 + // Construct request data according to API requirements const requestData = { type: "shorturl", attributes: { - // 可以添加任何额外属性,但attributes不能为空 + // Can add any additional attributes, but attributes cannot be empty icon: "" }, shortUrl: { @@ -134,20 +134,20 @@ function CreateShortUrlForm() { tagIds: formData.tags && formData.tags.length > 0 ? formData.tags : undefined }; - // 调用 API 创建 shorturl 资源 + // Call API to create shorturl resource const response = await limqRequest('resource/shorturl', 'POST', requestData as unknown as Record); - console.log('创建成功:', response); + console.log('Created successfully:', response); setSuccess(true); - // 2秒后跳转到链接列表页面 + // Redirect to links list page after 2 seconds setTimeout(() => { router.push('/links'); }, 2000); } catch (err) { - console.error('创建短链接失败:', err); - setError(err instanceof Error ? err.message : '创建短链接失败,请稍后重试'); + console.error('Failed to create short URL:', err); + setError(err instanceof Error ? err.message : 'Failed to create short URL, please try again later'); } finally { setIsSubmitting(false); } @@ -188,7 +188,7 @@ function CreateShortUrlForm() {

- 短链接创建成功!正在跳转... + Short URL created successfully! Redirecting...

@@ -196,10 +196,10 @@ function CreateShortUrlForm() { )}
- {/* 标题 */} + {/* Title */}
- {/* 原始 URL */} + {/* Original URL */}
- {/* 自定义短链接 */} + {/* Custom Short Link */}
@@ -250,14 +250,14 @@ function CreateShortUrlForm() { />

- 留空将生成随机短链接 + Leave blank to generate a random short link

- {/* 域名 */} + {/* Domain */}
- {/* 团队选择 */} + {/* Team Selection */}
({ ...prev, teamId: teamId as string, - // 当团队变更时清除已选项目 + // Clear selected project when team changes projectId: '' })); }} @@ -291,10 +291,10 @@ function CreateShortUrlForm() {
- {/* 项目选择 */} + {/* Project Selection */}
- {/* 描述 */} + {/* Description */}