File tree Expand file tree Collapse file tree
app/hackathon/(components) Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,10 +26,16 @@ const FormSchema = z.object({
2626 . min ( 11 , { message : "学号必须是至少 11 位数字。" } )
2727 . regex ( / ^ \d + $ / , { message : "学号只能包含数字。" } ) ,
2828 nickname : z . string ( ) . min ( 2 , { message : "昵称至少需要 2 个字符。" } ) ,
29- github_url : z . string ( ) . regex ( / ^ h t t p s : \/ \/ g i t h u b \. c o m \/ [ ^ \/ ] + \/ [ ^ \/ ] + $ / , {
30- message :
31- "请输入有效的 GitHub 项目主页链接(例如:https://github.com/user/repo)。" ,
32- } ) ,
29+ github_url : z
30+ . string ( )
31+ . optional ( )
32+ . refine (
33+ ( val ) => ! val || / ^ h t t p s : \/ \/ g i t h u b \. c o m \/ [ ^ \/ ] + \/ [ ^ \/ ] + $ / . test ( val ) ,
34+ {
35+ message :
36+ "请输入有效的 GitHub 项目主页链接(例如:https://github.com/user/repo)。" ,
37+ }
38+ ) ,
3339} ) ;
3440
3541type FormFields = z . infer < typeof FormSchema > ;
@@ -47,7 +53,7 @@ const formFields = [
4753 } ,
4854 {
4955 name : "github_url" ,
50- label : "GitHub 项目链接" ,
56+ label : "GitHub 项目链接(可后续添加或修改) " ,
5157 placeholder : "https://github.com/username/project" ,
5258 } ,
5359] as const ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export const createRegister = mutation({
66 userId : v . string ( ) ,
77 studentId : v . string ( ) ,
88 nickname : v . string ( ) ,
9- githubLink : v . string ( ) ,
9+ githubLink : v . optional ( v . string ( ) ) ,
1010 } ,
1111 handler : async ( ctx , args ) => {
1212 const existingRegister = await ctx . db
@@ -24,7 +24,7 @@ export const createRegister = mutation({
2424 userId : args . userId ,
2525 studentId : args . studentId ,
2626 nickname : args . nickname ,
27- githubLink : args . githubLink ,
27+ githubLink : args . githubLink ? args . githubLink : "https://example.com" ,
2828 } ) ;
2929 console . log ( `Created register with ID ${ registerId } ` ) ;
3030 }
You can’t perform that action at this time.
0 commit comments