Skip to content

Commit

Permalink
Merge pull request #980 from pxgo/master
Browse files Browse the repository at this point in the history
修复,优化
  • Loading branch information
pxgo authored Aug 27, 2024
2 parents 60755b7 + 71cb4e6 commit 99a90b0
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 29 deletions.
41 changes: 21 additions & 20 deletions pages/community/communityTab.pug
Original file line number Diff line number Diff line change
@@ -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')"
) 我的订阅
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')"
) 我的订阅
3 changes: 2 additions & 1 deletion pages/forum/forum.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -24,6 +24,7 @@ $(function () {
uploadResourcesId: NKC.configs.uploadResourcesId
? NKC.configs.uploadResourcesId.split('-')
: [],
sizeLimit,
});
}
const threadUrlSwitch = $('#threadUrlSwitch');
Expand Down
2 changes: 1 addition & 1 deletion pages/forum/forum.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pages/lib/vue/zone/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
31 changes: 26 additions & 5 deletions pages/publicModules/library/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -51,6 +51,7 @@ NKC.modules.Library = class {
}
],
protocol: true, // 是否同意协议
sizeLimit: sizeLimit,
},
watch:{
listCategories() {
Expand Down Expand Up @@ -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;
},
Expand Down
13 changes: 12 additions & 1 deletion routes/app/check/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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更新多个版本后可移除
}
Expand Down
3 changes: 3 additions & 0 deletions routes/forum/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 99a90b0

Please sign in to comment.