From d5bc102bd72a3c88910d59bbeb260a5671d2792f Mon Sep 17 00:00:00 2001 From: whm <973418690@qq.com> Date: Wed, 18 Mar 2026 16:50:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=8A=E4=BC=A0200MB=E9=99=90?= =?UTF-8?q?=E5=88=B6=E3=80=81=E5=A4=87=E6=A1=88=E4=BF=A1=E6=81=AF=E3=80=81?= =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98=E4=BB=85=E9=A6=96?= =?UTF-8?q?=E6=B3=A8=E3=80=81=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86=E8=8F=9C?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made-with: Cursor --- admin/src/layouts/AdminLayout.vue | 46 ++++++++++++++++++++++++---- admin/src/router/index.js | 6 ++++ admin/src/views/files/FileImages.vue | 23 ++++++++++++++ nginx/yuheng.docker.conf | 1 + server/handlers/register.go | 13 ++++++-- server/main.go | 1 + web/Dockerfile | 3 ++ web/src/views/Home.vue | 8 ++++- 8 files changed, 92 insertions(+), 9 deletions(-) create mode 100644 admin/src/views/files/FileImages.vue diff --git a/admin/src/layouts/AdminLayout.vue b/admin/src/layouts/AdminLayout.vue index 3281855..2b0a300 100644 --- a/admin/src/layouts/AdminLayout.vue +++ b/admin/src/layouts/AdminLayout.vue @@ -9,10 +9,19 @@ text-color="#bfcbd9" active-text-color="#409EFF" > - - - {{ item.title }} - + @@ -26,6 +35,7 @@ + @@ -61,10 +71,25 @@ const menuItems = computed(() => { { index: '/sites', title: '站点管理', icon: Monitor, permission: 'site:manage' }, { index: '/pages', title: '网页管理', icon: Document, permission: 'page:manage' }, { index: '/homepage-edit', title: '首页编辑', icon: EditPen, permission: 'homepage:edit' }, - { index: '/module-upload', title: '功能模块上传', icon: Upload, permission: 'module:upload' }, + { + index: 'files', + title: '文件管理', + icon: Folder, + permission: null, + children: [ + { index: '/files/images', title: '图片管理(含图标)', permission: null }, + { index: '/module-upload', title: '功能模块上传', permission: 'module:upload' } + ] + }, { index: '/role-permissions', title: '角色权限管理', icon: Key, permission: 'role:permission' } ] - return all.filter((item) => hasPermission(item.permission)) + return all.filter((item) => { + if (item.children) { + item.children = item.children.filter((sub) => hasPermission(sub.permission)) + return hasPermission(item.permission) && item.children.length > 0 + } + return hasPermission(item.permission) + }) }) const handleLogout = () => { @@ -109,4 +134,13 @@ const handleLogout = () => { background: #f0f2f5; padding: 20px; } +.layout-footer { + padding: 8px 20px; + font-size: 12px; + color: #999; + text-align: center; + border-top: 1px solid #eee; +} +.layout-footer a { color: #999; text-decoration: none; } +.layout-footer a:hover { text-decoration: underline; } diff --git a/admin/src/router/index.js b/admin/src/router/index.js index 458c93d..78af748 100644 --- a/admin/src/router/index.js +++ b/admin/src/router/index.js @@ -66,6 +66,12 @@ const routes = [ component: () => import('../views/sites/HomepageEdit.vue'), meta: { title: '首页编辑', permission: 'homepage:edit' } }, + { + path: 'files/images', + name: 'FileImages', + component: () => import('../views/files/FileImages.vue'), + meta: { title: '图片管理', permission: null } + }, { path: 'module-upload', name: 'ModuleUpload', diff --git a/admin/src/views/files/FileImages.vue b/admin/src/views/files/FileImages.vue new file mode 100644 index 0000000..4d3909e --- /dev/null +++ b/admin/src/views/files/FileImages.vue @@ -0,0 +1,23 @@ + + + + + + diff --git a/nginx/yuheng.docker.conf b/nginx/yuheng.docker.conf index 5ed6598..977e6f5 100644 --- a/nginx/yuheng.docker.conf +++ b/nginx/yuheng.docker.conf @@ -4,6 +4,7 @@ server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name yuheng.yuxindazhineng.com; + client_max_body_size 200m; ssl_certificate /etc/ssl/yh_web/yuheng.yuxindazhineng.com/fullchain.pem; ssl_certificate_key /etc/ssl/yh_web/yuheng.yuxindazhineng.com/privkey.pem; diff --git a/server/handlers/register.go b/server/handlers/register.go index 3baffe5..fa0e66d 100644 --- a/server/handlers/register.go +++ b/server/handlers/register.go @@ -179,12 +179,21 @@ func Register(c *gin.Context) { } } + // 超级管理员仅一个:第一个注册用户为超级管理员,后续均为普通用户 + count, _ := coll.CountDocuments(ctx, bson.M{}) + roleID := models.RoleIDUser + role := "user" + if count == 0 { + roleID = models.RoleIDSuperAdmin + role = "admin" + } + doc := bson.M{ "username": username, "mobile": input.Mobile, "password": utils.HashPassword(input.Password), - "role": "admin", - "role_id": models.RoleIDSuperAdmin, + "role": role, + "role_id": roleID, } if input.Email != "" { doc["email"] = input.Email diff --git a/server/main.go b/server/main.go index 72109d9..5ea46e7 100644 --- a/server/main.go +++ b/server/main.go @@ -79,6 +79,7 @@ func main() { } r := gin.Default() + r.MaxMultipartMemory = 200 << 20 // 200MB,与 Nginx client_max_body_size 一致,避免上传 413 r.Use(middleware.ErrorLogger()) // CORS(ALLOWED_ORIGINS 为空则允许所有来源;否则仅允许配置的域名) diff --git a/web/Dockerfile b/web/Dockerfile index ce00d0f..a521460 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -22,6 +22,9 @@ RUN printf '%s\n' \ ' alias /verify-root/$1;' \ ' }' \ '' \ +' location = / {' \ +' try_files /index.html =404;' \ +' }' \ ' location / {' \ ' try_files $uri $uri/ /index.html;' \ ' }' \ diff --git a/web/src/views/Home.vue b/web/src/views/Home.vue index cdfb9f9..ffd5184 100644 --- a/web/src/views/Home.vue +++ b/web/src/views/Home.vue @@ -48,7 +48,10 @@ - + @@ -360,6 +363,9 @@ onUnmounted(() => { margin-top: 80px; position: relative; z-index: 10; } .landing footer p { color: rgba(255,255,255,0.3); font-size: 12px; font-family: 'Exo 2', sans-serif; letter-spacing: 2px; } +.landing footer .beian { margin-top: 8px; } +.landing footer .beian a { color: rgba(255,255,255,0.4); text-decoration: none; } +.landing footer .beian a:hover { text-decoration: underline; } @media (max-width: 768px) { .navbar { padding: 15px 20px; }