Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ai-box
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
青山
ai-box
Commits
17b0985c
Commit
17b0985c
authored
Nov 07, 2024
by
fisherdaddy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: 新增urlencode
parent
d47d7d2a
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
412 additions
and
241 deletions
+412
-241
App.jsx
src/App.jsx
+2
-0
UrlEncode.jsx
src/components/UrlEncode.jsx
+138
-0
i18n.json
src/data/i18n.json
+267
-0
i18n.js
src/js/i18n.js
+1
-238
Home.jsx
src/pages/Home.jsx
+4
-3
No files found.
src/App.jsx
View file @
17b0985c
...
@@ -8,6 +8,7 @@ import NotFound from './pages/NotFound';
...
@@ -8,6 +8,7 @@ import NotFound from './pages/NotFound';
const
JsonFormatter
=
lazy
(()
=>
import
(
'./components/JsonFormatter'
));
const
JsonFormatter
=
lazy
(()
=>
import
(
'./components/JsonFormatter'
));
const
TextToImage
=
lazy
(()
=>
import
(
'./components/TextToImage'
));
const
TextToImage
=
lazy
(()
=>
import
(
'./components/TextToImage'
));
const
UrlDecode
=
lazy
(()
=>
import
(
'./components/UrlDecode'
));
const
UrlDecode
=
lazy
(()
=>
import
(
'./components/UrlDecode'
));
const
UrlEncode
=
lazy
(()
=>
import
(
'./components/UrlEncode'
));
const
About
=
lazy
(()
=>
import
(
'./pages/About'
));
const
About
=
lazy
(()
=>
import
(
'./pages/About'
));
const
OpenAITimeline
=
lazy
(()
=>
import
(
'./components/OpenAITimeline'
));
const
OpenAITimeline
=
lazy
(()
=>
import
(
'./components/OpenAITimeline'
));
const
PricingCharts
=
lazy
(()
=>
import
(
'./components/PricingCharts'
));
const
PricingCharts
=
lazy
(()
=>
import
(
'./components/PricingCharts'
));
...
@@ -25,6 +26,7 @@ function App() {
...
@@ -25,6 +26,7 @@ function App() {
<
Route
path=
"/text2image"
element=
{
<
TextToImage
/>
}
/>
<
Route
path=
"/text2image"
element=
{
<
TextToImage
/>
}
/>
<
Route
path=
"/json-formatter"
element=
{
<
JsonFormatter
/>
}
/>
<
Route
path=
"/json-formatter"
element=
{
<
JsonFormatter
/>
}
/>
<
Route
path=
"/url-decode"
element=
{
<
UrlDecode
/>
}
/>
<
Route
path=
"/url-decode"
element=
{
<
UrlDecode
/>
}
/>
<
Route
path=
"/url-encode"
element=
{
<
UrlEncode
/>
}
/>
<
Route
path=
"/about"
element=
{
<
About
/>
}
/>
<
Route
path=
"/about"
element=
{
<
About
/>
}
/>
<
Route
path=
"/openai-timeline"
element=
{
<
OpenAITimeline
/>
}
/>
<
Route
path=
"/openai-timeline"
element=
{
<
OpenAITimeline
/>
}
/>
<
Route
path=
"/llm-model-price"
element=
{
<
PricingCharts
/>
}
/>
<
Route
path=
"/llm-model-price"
element=
{
<
PricingCharts
/>
}
/>
...
...
src/components/UrlEncode.jsx
0 → 100644
View file @
17b0985c
import
React
,
{
useState
,
useCallback
}
from
'react'
;
import
{
Title
,
Wrapper
,
Container
,
InputText
,
Preview
}
from
'../js/SharedStyles'
;
import
styled
from
'styled-components'
;
import
{
useTranslation
}
from
'../js/i18n'
;
import
SEO
from
'./SEO'
;
const
EncoderContainer
=
styled
(
Container
)
`
flex-direction: column;
`
;
const
StyledInputText
=
styled
(
InputText
)
`
height: 100px;
margin-bottom: 20px;
@media (min-width: 768px) {
height: 100px;
width: 100%;
}
`
;
const
PreviewWrapper
=
styled
.
div
`
width: 100%;
`
;
const
Label
=
styled
.
label
`
font-weight: 500;
font-size: 14px;
color: #5f6368;
margin-bottom: 8px;
display: block;
letter-spacing: 0.1px;
`
;
const
StyledPreview
=
styled
(
Preview
)
`
background-color: #f8f9fa;
padding: 12px 40px 12px 12px; // 增加右侧 padding 为按钮留出空间
border-radius: 8px;
border: 1px solid #dadce0;
font-size: 14px;
color: #202124;
min-height: 24px; // 确保即使内容为空,也有足够的高度容纳按钮
`
;
const
ResultContainer
=
styled
.
div
`
position: relative;
width: 100%;
`
;
const
CopyButton
=
styled
.
button
`
position: absolute;
top: 8px;
right: 8px;
background-color: transparent;
border: none;
cursor: pointer;
padding: 4px;
display: flex;
align-items: center;
justify-content: center;
opacity: 0.6;
transition: opacity 0.3s, color 0.3s;
&:hover {
opacity: 1;
}
svg {
width: 16px;
height: 16px;
}
&.copied {
color: #34a853; // 成功复制后的绿色反馈
}
`
;
function
UrlEncoder
()
{
const
{
t
}
=
useTranslation
();
const
[
input
,
setInput
]
=
useState
(
''
);
const
[
encodedText
,
setEncodedText
]
=
useState
(
''
);
const
[
isCopied
,
setIsCopied
]
=
useState
(
false
);
const
handleInputChange
=
(
e
)
=>
{
const
inputValue
=
e
.
target
.
value
;
setInput
(
inputValue
);
try
{
const
encoded
=
encodeURIComponent
(
inputValue
);
setEncodedText
(
encoded
);
}
catch
(
error
)
{
setEncodedText
(
'编码出错'
);
}
};
const
handleCopy
=
useCallback
(()
=>
{
navigator
.
clipboard
.
writeText
(
encodedText
).
then
(()
=>
{
setIsCopied
(
true
);
setTimeout
(()
=>
setIsCopied
(
false
),
2000
);
});
},
[
encodedText
]);
return
(
<>
<
SEO
title=
{
t
(
'tools.urlEncode.title'
)
}
description=
{
t
(
'tools.urlEncode.description'
)
}
/>
<
Wrapper
>
<
Title
>
{
t
(
'tools.urlEncode.title'
)
}
</
Title
>
<
EncoderContainer
>
<
StyledInputText
id=
"urlInput"
placeholder=
{
t
(
'tools.urlEncode.inputLabel'
)
}
value=
{
input
}
onChange=
{
handleInputChange
}
/>
<
PreviewWrapper
>
<
Label
>
{
t
(
'tools.urlEncode.resultLabel'
)
}
</
Label
>
<
ResultContainer
>
<
StyledPreview
>
{
encodedText
}
</
StyledPreview
>
<
CopyButton
onClick=
{
handleCopy
}
className=
{
isCopied
?
'copied'
:
''
}
>
{
isCopied
?
(
<
svg
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 24 24"
fill=
"currentColor"
>
<
path
d=
"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"
/>
</
svg
>
)
:
(
<
svg
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 24 24"
fill=
"currentColor"
>
<
path
d=
"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"
/>
</
svg
>
)
}
</
CopyButton
>
</
ResultContainer
>
</
PreviewWrapper
>
</
EncoderContainer
>
</
Wrapper
>
</>
);
}
export
default
UrlEncoder
;
src/data/i18n.json
0 → 100644
View file @
17b0985c
This diff is collapsed.
Click to expand it.
src/js/i18n.js
View file @
17b0985c
This diff is collapsed.
Click to expand it.
src/pages/Home.jsx
View file @
17b0985c
...
@@ -5,10 +5,11 @@ import SEO from '../components/SEO';
...
@@ -5,10 +5,11 @@ import SEO from '../components/SEO';
const
tools
=
[
const
tools
=
[
{
id
:
'text2image'
,
icon
:
'fa-image'
,
path
:
'/text2image'
},
{
id
:
'text2image'
,
icon
:
'fa-image'
,
path
:
'/text2image'
},
{
id
:
'jsonFormatter'
,
icon
:
'fa-
code
'
,
path
:
'/json-formatter'
},
{
id
:
'jsonFormatter'
,
icon
:
'fa-
jsonformat
'
,
path
:
'/json-formatter'
},
{
id
:
'urlDecode'
,
icon
:
'fa-decode'
,
path
:
'/url-decode'
},
{
id
:
'urlDecode'
,
icon
:
'fa-decode'
,
path
:
'/url-decode'
},
{
id
:
'openAITimeline'
,
icon
:
'fa-decode'
,
path
:
'/openai-timeline'
},
{
id
:
'urlEncode'
,
icon
:
'fa-encode'
,
path
:
'/url-encode'
},
{
id
:
'modelPrice'
,
icon
:
'fa-decode'
,
path
:
'/llm-model-price'
},
{
id
:
'openAITimeline'
,
icon
:
'fa-openai-timeline'
,
path
:
'/openai-timeline'
},
{
id
:
'modelPrice'
,
icon
:
'fa-model-price'
,
path
:
'/llm-model-price'
},
];
];
const
Home
=
()
=>
{
const
Home
=
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment