From 694222de792bcddccaafe1b7fcc2f26fe306b7cc Mon Sep 17 00:00:00 2001 From: Blucepu <2287892008@qq.com> Date: Thu, 22 Aug 2024 16:40:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=E5=85=BC=E5=AE=B9app=E9=A1=B6?= =?UTF-8?q?=E9=83=A8tab=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/community/communityTab.pug | 41 ++++++++++++++++--------------- pages/lib/vue/zone/views/Home.vue | 2 +- routes/app/check/index.js | 13 +++++++++- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/pages/community/communityTab.pug b/pages/community/communityTab.pug index 5712067db..990cee6e2 100644 --- a/pages/community/communityTab.pug +++ b/pages/community/communityTab.pug @@ -1,23 +1,24 @@ if !isIncluded('community/communityTab') mixin renderCommunityTab(isApp,activeTab,communityTab,user) - .btn-group.btn-group-justified.m-b-05 - .btn-group(role="group") + if !isApp + .btn-group.btn-group-justified.m-b-05 + .btn-group(role="group") + a.btn.btn-default( + class=activeTab === communityTab.home ? 'btn-primary': '' + href=`/c` + ) 专业列表 + .btn-group(role="group") a.btn.btn-default( - class=activeTab === communityTab.home ? 'btn-primary': '' - href=`/c` - ) 专业列表 - .btn-group(role="group") - a.btn.btn-default( - class=activeTab === communityTab.new ? 'btn-primary': '' - href=`/c/new` - ) 最新 - .btn-group(role="group") - if user - a.btn.btn-default( - class=activeTab === communityTab.subscribe ? 'btn-primary': '' - href=`/c/sub` - ) 我的订阅 - else - button.btn.btn-default( - onclick="RootApp.openLoginPanel('login')" - ) 我的订阅 \ No newline at end of file + class=activeTab === communityTab.new ? 'btn-primary': '' + href=`/c/new` + ) 最新 + .btn-group(role="group") + if user + a.btn.btn-default( + class=activeTab === communityTab.subscribe ? 'btn-primary': '' + href=`/c/sub` + ) 我的订阅 + else + button.btn.btn-default( + onclick="RootApp.openLoginPanel('login')" + ) 我的订阅 \ No newline at end of file diff --git a/pages/lib/vue/zone/views/Home.vue b/pages/lib/vue/zone/views/Home.vue index de6bd44a6..d362c08e6 100644 --- a/pages/lib/vue/zone/views/Home.vue +++ b/pages/lib/vue/zone/views/Home.vue @@ -3,7 +3,7 @@ .row .col-md-offset-2.col-xs-12.col-md-8.min-md-p-r-0 .box-shadow - .btn-group.btn-group-justified.m-b-1 + .btn-group.btn-group-justified.m-b-1(v-if='!isApp') .btn-group(role="group") button.btn.btn-default(:class="{'btn-primary': tab === zoneTab.all }" @click="getList(type,'a')") 全部 .btn-group(role="group") diff --git a/routes/app/check/index.js b/routes/app/check/index.js index 2f60a3049..77eb0083b 100644 --- a/routes/app/check/index.js +++ b/routes/app/check/index.js @@ -31,7 +31,18 @@ checkRouter.get('/', async (ctx, next) => { '?t=' + Date.now(); if (version && version !== newVersion.appVersion) { - data.newVersion = newVersion; + const parts1 = newVersion.appVersion.split('.').map(Number); + const parts2 = version.split('.').map(Number); + let isNewVersion = false; + for (let i = 0; i < 3; i++) { + if (parts1[i] > parts2[i]) { + isNewVersion = true; + break; + } else if (parts1[i] < parts2[i]) { + break; + } + } + data.newVersion = isNewVersion ? newVersion : null; } data.latestVer = newVersion; // 兼容旧版APP的下载链接 2020-1-18,APP更新多个版本后可移除 } From de080b6448e6b6c587136f7dfb541d50dfaf3e6b Mon Sep 17 00:00:00 2001 From: Blucepu <2287892008@qq.com> Date: Tue, 27 Aug 2024 10:38:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=E6=96=87=E5=BA=93=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6?= =?UTF-8?q?=E4=B8=8E=E9=99=84=E4=BB=B6=E4=B8=8A=E4=BC=A0=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/forum/forum.js | 3 ++- pages/forum/forum.pug | 2 +- pages/publicModules/library/library.js | 31 +++++++++++++++++++++----- routes/forum/library.js | 3 +++ 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/pages/forum/forum.js b/pages/forum/forum.js index 04a5499f7..ff4ce9cc4 100644 --- a/pages/forum/forum.js +++ b/pages/forum/forum.js @@ -5,7 +5,7 @@ import { shareTypes } from '../lib/js/shareTypes'; const socket = getSocket(); const { isApp } = getState(); const forumInfo = NKC.methods.getDataById('forumInfo'); -const { fid, page, digest, sort } = forumInfo; +const { fid, page, digest, sort, sizeLimit } = forumInfo; $(function () { RNSetSharePanelStatus(true, shareTypes.forum, fid); @@ -24,6 +24,7 @@ $(function () { uploadResourcesId: NKC.configs.uploadResourcesId ? NKC.configs.uploadResourcesId.split('-') : [], + sizeLimit, }); } const threadUrlSwitch = $('#threadUrlSwitch'); diff --git a/pages/forum/forum.pug b/pages/forum/forum.pug index 8fe9cbde4..8dc227dc5 100644 --- a/pages/forum/forum.pug +++ b/pages/forum/forum.pug @@ -35,7 +35,7 @@ block content .forum-user-panel-body for targetUser in users include ../publicModules/user_panel/user_panel - .hidden#forumInfo=objToStr({fid: data.forum.fid, page: data.paging?data.paging.page:{}, digest: !!data.d, sort: data.s === 'toc'? 'toc': 'tlm'}) + .hidden#forumInfo=objToStr({fid: data.forum.fid, page: data.paging?data.paging.page:{}, digest: !!data.d, sort: data.s === 'toc'? 'toc': 'tlm', sizeLimit: data.sizeLimit}) .container-fluid.max-width .row .col-xs-12.col-md-1.min-md-p-r-0.hidden-xs.hidden-sm diff --git a/pages/publicModules/library/library.js b/pages/publicModules/library/library.js index 23c5fab06..840880a7d 100644 --- a/pages/publicModules/library/library.js +++ b/pages/publicModules/library/library.js @@ -2,7 +2,7 @@ import {getFileMD5} from "../../lib/js/file"; NKC.modules.Library = class { constructor(options) { - const {lid, folderId, tLid, uploadResourcesId} = options; + const {lid, folderId, tLid, uploadResourcesId, sizeLimit} = options; const self = this; self.app = new Vue({ el: "#moduleLibrary", @@ -51,6 +51,7 @@ NKC.modules.Library = class { } ], protocol: true, // 是否同意协议 + sizeLimit: sizeLimit, }, watch:{ listCategories() { @@ -321,14 +322,34 @@ NKC.modules.Library = class { file.ext = "mediaAttachment"; } } + if (this.sizeLimit) { + // 添加附件上传的尺寸限制大小 + let settingSize; + const ext = (file.data.name || '').split('.').at(-1); + const itemIndex = this.sizeLimit.others.findIndex( + (item) => item.ext === ext, + ); + if (itemIndex === -1) { + settingSize = this.sizeLimit.default; + } else { + settingSize = this.sizeLimit.others[itemIndex].size; + } + if (size > settingSize * 1024) { + file.error = `${ext}文件大小不能超过${this.getSize( + settingSize * 1024, + )}`; + file.disabled = true; + } + } if(file.ext === "mediaPicture") { file.error = "暂不允许上传图片到文库"; file.disabled = true; - } else if(file.size > 200 * 1024 * 1024) { - file.error = "文件大小不能超过200MB"; - file.disabled = true; - } + } + // else if(file.size > 200 * 1024 * 1024) { + // file.error = "文件大小不能超过200MB"; + // file.disabled = true; + // } return file; }, diff --git a/routes/forum/library.js b/routes/forum/library.js index 4d2ad5e82..7b5da1aeb 100644 --- a/routes/forum/library.js +++ b/routes/forum/library.js @@ -29,6 +29,9 @@ router data.libraryClosed = true; } } + const uploadSettings = await db.SettingModel.getSettings('upload'); + const { sizeLimit } = uploadSettings; + data.sizeLimit = sizeLimit; await next(); }) .post('/', async (ctx, next) => {