diff --git a/app/create-shorturl/page.tsx b/app/create-shorturl/page.tsx index 415cf99..70f8496 100644 --- a/app/create-shorturl/page.tsx +++ b/app/create-shorturl/page.tsx @@ -5,6 +5,8 @@ import { useRouter } from 'next/navigation'; import { useAuth } from '@/lib/auth'; import { ProtectedRoute } from '@/lib/auth'; import { limqRequest } from '@/lib/api'; +import { TeamSelector } from '@/app/components/ui/TeamSelector'; +import { ProjectSelector } from '@/app/components/ui/ProjectSelector'; interface ShortUrlData { originalUrl: string; @@ -12,6 +14,9 @@ interface ShortUrlData { title: string; description?: string; tags?: string[]; + teamId: string; + projectId: string; + domain: string; } export default function CreateShortUrlPage() { @@ -32,6 +37,9 @@ function CreateShortUrlForm() { title: '', description: '', tags: [], + teamId: '', + projectId: '', + domain: 'googleads.link', }); const [tagInput, setTagInput] = useState(''); @@ -94,6 +102,18 @@ function CreateShortUrlForm() { throw new Error('标题是必填项'); } + if (!formData.teamId) { + throw new Error('团队是必填项'); + } + + if (!formData.projectId) { + throw new Error('项目是必填项'); + } + + if (!formData.domain) { + throw new Error('域名是必填项'); + } + // 按照API要求构建请求数据 const requestData = { type: "shorturl", @@ -106,11 +126,11 @@ function CreateShortUrlForm() { slug: formData.customSlug || undefined, title: formData.title, name: formData.title, - description: formData.description || "" + description: formData.description || "", + domain: formData.domain }, - // 如果有team或project ID也可以添加 - // teamId: "your-team-id", - // projectId: "your-project-id", + teamId: formData.teamId, + projectId: formData.projectId, tagIds: formData.tags && formData.tags.length > 0 ? formData.tags : undefined }; @@ -217,7 +237,7 @@ function CreateShortUrlForm() {
- shorturl.com/ + {formData.domain}/
+ {/* 域名 */} +
+ + +
+ + {/* 团队选择 */} +
+ +
+ { + setFormData(prev => ({ + ...prev, + teamId: teamId as string, + // 当团队变更时清除已选项目 + projectId: '' + })); + }} + /> +
+
+ + {/* 项目选择 */} +
+ +
+ { + setFormData(prev => ({ + ...prev, + projectId: projectId as string + })); + }} + /> +
+
+ {/* 描述 */}