Skip to content

Commit

Permalink
Merge pull request #918 from pxgo/master
Browse files Browse the repository at this point in the history
修复
  • Loading branch information
pxgo authored Sep 8, 2023
2 parents 130832a + b70c00f commit 4ce790b
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 5 deletions.
9 changes: 8 additions & 1 deletion dataModels/ThreadModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,14 @@ threadSchema.statics.getNewAcademicThread = async (fid) => {
const XsfsRecordModel = mongoose.model('xsfsRecords');
const ThreadModel = mongoose.model('threads');
const PostModel = mongoose.model('posts');
const academicPost = await XsfsRecordModel.find({}, { pid: 1 })
const academicPost = await XsfsRecordModel.find(
{
num: {
$gte: 1,
},
},
{ pid: 1 },
)
.limit(100)
.sort({ toc: -1 })
.lean();
Expand Down
16 changes: 14 additions & 2 deletions nkcModules/xssFilters/filterPasteHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ module.exports = (html = '') => {
html = xss(html, {
whiteList: {
a: ['href', 'title', 'target'],
img: ['src', 'alt'],
img: [
'src',
'_src',
'alt',
'data-tag',
'data-type',
'data-uploading-order',
],
br: [],
p: [],
},
onIgnoreTag: function (tag, html, options) {
onTagAttr(tag, name, value) {
if (tag === 'img' && name === 'src') {
return `${name}="${xss.escapeAttrValue(value)}"`;
}
},
onIgnoreTag: function () {
return '';
},
});
Expand Down
22 changes: 22 additions & 0 deletions pages/lib/js/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { getState } from './state';
import { detailedTime } from './time';
const { isProduction } = getState();
class Logger {
print(type, ...any) {
console.log(`[${detailedTime()}]`, `[${type}]`, ...any);
}
debug(...any) {
if (isProduction) {
return;
}
this.print('DEBUG', ...any);
}
info(...any) {
this.print('INFO', ...any);
}
warning(...any) {
this.print('WARN', ...any);
}
}

export const logger = new Logger();
8 changes: 6 additions & 2 deletions pages/lib/vue/PublicPaper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
form(v-if='question.type === "ans"')
.answer-form-group
span 答案:
textarea(:disabled = "isCorrect" v-model='fill' )
textarea(:disabled = "isCorrect" v-model.trim='fill' )
span(v-if="answerDesc.desc") {{answerDesc.desc}}
form(v-else)
label.options(v-if="question.isMultiple" v-for='(q, index) in question.answer' :class="bgc(index,q)")
Expand Down Expand Up @@ -337,11 +337,14 @@ export default Vue.extend({
},
beforeDestroy() {
window.removeEventListener('popstate', this.updateUrl);
window.removeEventListener('beforeunload', this.handleBeforeUnload);
this.removeBeforeunloadEventListener();
},
methods: {
getUrl,
detailedTime,
removeBeforeunloadEventListener() {
window.removeEventListener('beforeunload', this.handleBeforeUnload);
},
//获取考题
getInit(type='default',index = 0) {
nkcAPI(`/api/v1/exam/public/paper/${this.pid}?index=${index}&&type=${type}`, 'GET')
Expand Down Expand Up @@ -552,6 +555,7 @@ export default Vue.extend({
this.redirectUrl = redirectUrl
this.isFinished = true;
this.from = from;
this.removeBeforeunloadEventListener();
}
});
}
Expand Down
1 change: 1 addition & 0 deletions pages/publicModules/state.pug
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ if remoteState.isApp
-windowData.websiteCode = remoteState.serverSettings.websiteCode;
-windowData.websiteName = remoteState.serverSettings.websiteName;
-windowData.websiteBrief = remoteState.serverSettings.brief;
-windowData.isProduction = remoteState.isProduction;
meta(name='window-data' content=objToStr(windowData))

0 comments on commit 4ce790b

Please sign in to comment.