@@ -2,9 +2,11 @@ import { useEffect, useState } from "react";
2
2
import { Outlet , useNavigate , useParams , } from "react-router-dom" ;
3
3
import { HeaderShell } from "@/component/shell/Header.tsx" ;
4
4
import axios from "axios" ;
5
- import { Tabs } from "@mantine/core" ;
5
+ import { Tabs } from "@mantine/core" ;
6
6
import { Box , Card , Text , Button , Group } from "@mantine/core" ;
7
- import { AlertCircle , Loader2 } from "lucide-react" ;
7
+ import { AlertCircle , CopyIcon , Loader2 } from "lucide-react" ;
8
+ import { useClipboard } from "@mantine/hooks" ;
9
+ import { notifications } from "@mantine/notifications" ;
8
10
9
11
interface RepoApiResponse {
10
12
code : number ;
@@ -42,6 +44,7 @@ export const Repolayout = () => {
42
44
const [ repoData , setRepoData ] = useState < RepoData | null > ( null ) ;
43
45
const nav = useNavigate ( ) ;
44
46
const [ type , setType ] = useState ( 'files' ) ;
47
+ const clip = useClipboard ( )
45
48
useEffect ( ( ) => {
46
49
const urls = window . location . href . split ( "/" ) ;
47
50
setType ( "files" )
@@ -121,19 +124,56 @@ export const Repolayout = () => {
121
124
}
122
125
123
126
const { repo : repository } = repoData ;
127
+
128
+ function copyText ( arg0 : string ) {
129
+ clip . copy ( arg0 )
130
+ notifications . show ( {
131
+ message : "Copy Success" ,
132
+ color : "green"
133
+ } )
134
+ }
135
+
124
136
return (
125
137
< >
126
138
< HeaderShell />
127
139
< Box mt = { 64 } p = { 4 } style = { { maxWidth : '1200px' , margin : '0 auto' , width : '100%' } } >
128
- < Card mb = { 4 } >
140
+ < Card mb = { 4 } >
129
141
< Box p = { 4 } >
130
142
< Group justify = "space-between" mb = { 2 } >
131
143
< Text size = "2xl" > { owner } /{ repository . name } </ Text >
132
144
< Text color = "dimmed" >
133
145
{ new Date ( repository . updated_at ) . toLocaleDateString ( ) }
134
146
</ Text >
135
147
</ Group >
136
- < Text color = "dimmed" mb = { 4 } > { repository . description || 'No description provided' } </ Text >
148
+ < Box style = { {
149
+ justifyContent : "space-between" ,
150
+ display : "flex" ,
151
+ alignItems : "center" ,
152
+ } } >
153
+ < Text color = "dimmed" mb = { 4 } > { repository . description || 'No description provided' } </ Text >
154
+ < div style = { {
155
+ display : "flex" ,
156
+ alignItems : "center" ,
157
+ gap : "1rem" ,
158
+ } } >
159
+ < div style = { {
160
+ border : "1px solid #ccc" ,
161
+ borderRadius : "4px" ,
162
+ padding : "0.5rem" ,
163
+ display : "flex" ,
164
+ backgroundColor : "#f5f5f5" ,
165
+ alignItems : "center" ,
166
+ justifyContent : "space-between" ,
167
+ marginBottom : "0.5rem" ,
168
+ gap : "0.5rem"
169
+ } } >
170
+ { window . location . protocol + "//" } { window . location . host + "/git/" + owner + "/" + repository . name + ".git" }
171
+ < CopyIcon onClick = { ( ) => {
172
+ copyText ( window . location . protocol + "//" + window . location . host + "/git/" + owner + "/" + repository . name + ".git" ) ;
173
+ } } />
174
+ </ div >
175
+ </ div >
176
+ </ Box >
137
177
</ Box >
138
178
</ Card >
139
179
< Tabs defaultValue = { type } value = { type } onChange = { ( value ) => {
0 commit comments