Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
sumeiqiao
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
xuchentao
sumeiqiao
Commits
9489de6e
Commit
9489de6e
authored
Jul 28, 2026
by
xuchentao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: increase image upload limit
parent
77b3d936
Pipeline
#417
passed with stages
in 17 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
3 deletions
+8
-3
sumeiqiao.conf
deploy/nginx/sumeiqiao.conf
+2
-2
app.js
public/admin/app.js
+5
-0
article-store.ts
src/lib/article-store.ts
+1
-1
No files found.
deploy/nginx/sumeiqiao.conf
View file @
9489de6e
...
...
@@ -4,8 +4,8 @@ server {
listen
80
;
server_name
101
.
126
.
10
.
129
;
# 图片上限为
8
MB,JSON 中的 Base64 数据会额外增大请求体。
client_max_body_size
12
m
;
# 图片上限为
20
MB,JSON 中的 Base64 数据会额外增大请求体。
client_max_body_size
28
m
;
location
/ {
proxy_pass
http
://
127
.
0
.
0
.
1
:
8789
;
...
...
public/admin/app.js
View file @
9489de6e
const
$
=
(
selector
)
=>
document
.
querySelector
(
selector
);
const
API_BASE
=
"/api/cms"
;
const
MAX_UPLOAD_SIZE
=
20
*
1024
*
1024
;
let
categories
=
[];
let
editingSlug
=
null
;
let
editingStatus
=
"new-unsaved"
;
...
...
@@ -564,6 +565,10 @@ $("#file").addEventListener("change", async (event) => {
const
file
=
event
.
target
.
files
?.[
0
];
event
.
target
.
value
=
""
;
if
(
!
file
)
return
;
if
(
file
.
size
>
MAX_UPLOAD_SIZE
)
{
$
(
"#upload-status"
).
textContent
=
"图片不能超过 20MB"
;
return
;
}
$
(
"#upload-status"
).
textContent
=
"上传中…"
;
try
{
const
dataUrl
=
await
new
Promise
((
resolve
,
reject
)
=>
{
...
...
src/lib/article-store.ts
View file @
9489de6e
...
...
@@ -470,7 +470,7 @@ export async function saveUpload(dataUrl: unknown): Promise<string> {
const
match
=
String
(
dataUrl
||
""
).
match
(
/^data:
([^
;
]
+
)
;base64,
(
.+
)
$/
s
);
if
(
!
match
||
!
extensions
[
match
[
1
]])
throw
new
StoreError
(
"仅支持 PNG、JPG、WEBP 或 GIF 图片"
);
const
buffer
=
Buffer
.
from
(
match
[
2
],
"base64"
);
if
(
buffer
.
length
>
8
*
1024
*
1024
)
throw
new
StoreError
(
"图片不能超过 8
MB"
,
413
);
if
(
buffer
.
length
>
20
*
1024
*
1024
)
throw
new
StoreError
(
"图片不能超过 20
MB"
,
413
);
const
name
=
`
${
Date
.
now
()}
-
${
crypto
.
randomBytes
(
4
).
toString
(
"hex"
)}
.
${
extensions
[
match
[
1
]]}
`
;
await
writeAtomic
(
path
.
join
(
UPLOADS_DIR
,
name
),
buffer
);
return
`/uploads/
${
name
}
`
;
...
...
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