避免undefined文件提交

This commit is contained in:
xiaoqi.cxq 2023-10-18 09:09:27 +08:00
parent 550bb2fd91
commit 96ea8cd0db
7 changed files with 30 additions and 2 deletions

View File

@ -4,3 +4,6 @@ dist
.history .history
images images
docs docs
Dockerfile
README.md
build.sh

View File

@ -59,7 +59,7 @@ exports.generate = (req, res) => {
const metadata = readJson(req.query.metadata); const metadata = readJson(req.query.metadata);
const params = []; const params = [];
params.push('--latex-engine=xelatex'); params.push('--pdf-engine=xelatex');
params.push('--webtex=http://chart.apis.google.com/chart?cht=tx&chf=bg,s,FFFFFF00&chco=000000&chl='); params.push('--webtex=http://chart.apis.google.com/chart?cht=tx&chf=bg,s,FFFFFF00&chco=000000&chl=');
if (options.toc) { if (options.toc) {
params.push('--toc'); params.push('--toc');

View File

@ -317,6 +317,12 @@ export default {
isImg, isImg,
commitMessage, commitMessage,
}) { }) {
// 非法的文件名 不让提交
if (!path || path.endsWith('undefined')) {
return new Promise((resolve) => {
resolve({ res: { content: { sha: null } } });
});
}
let uploadContent = content; let uploadContent = content;
if (isImg && typeof content !== 'string') { if (isImg && typeof content !== 'string') {
uploadContent = await utils.encodeFiletoBase64(content); uploadContent = await utils.encodeFiletoBase64(content);

View File

@ -279,6 +279,12 @@ export default {
isImg, isImg,
commitMessage, commitMessage,
}) { }) {
// 非法的文件名 不让提交
if (!path || path.endsWith('undefined')) {
return new Promise((resolve) => {
resolve({ res: { content: { sha: null } } });
});
}
let uploadContent = content; let uploadContent = content;
if (isImg && typeof content !== 'string') { if (isImg && typeof content !== 'string') {
uploadContent = await utils.encodeFiletoBase64(content); uploadContent = await utils.encodeFiletoBase64(content);

View File

@ -179,6 +179,12 @@ export default {
isImg, isImg,
commitMessage, commitMessage,
}) { }) {
// 非法的文件名 不让提交
if (!path || path.endsWith('undefined')) {
return new Promise((resolve) => {
resolve({ res: { content: { sha: null } } });
});
}
let uploadContent = content; let uploadContent = content;
if (isImg && typeof content !== 'string') { if (isImg && typeof content !== 'string') {
uploadContent = await utils.encodeFiletoBase64(content); uploadContent = await utils.encodeFiletoBase64(content);

View File

@ -281,6 +281,12 @@ export default {
isImg, isImg,
commitMessage, commitMessage,
}) { }) {
// 非法的文件名 不让提交
if (!path || path.endsWith('undefined')) {
return new Promise((resolve) => {
resolve({ res: { content: { sha: null } } });
});
}
let uploadContent = content; let uploadContent = content;
if (isImg && typeof content !== 'string') { if (isImg && typeof content !== 'string') {
uploadContent = await utils.encodeFiletoBase64(content); uploadContent = await utils.encodeFiletoBase64(content);

View File

@ -131,6 +131,7 @@
if (withToken) { if (withToken) {
withToken = false; withToken = false;
xhr.open('GET', url); xhr.open('GET', url);
xhr.send();
} else { } else {
console.error('An error occurred: ' + xhr.status); console.error('An error occurred: ' + xhr.status);
document.getElementById('div_info').innerHTML = `分享内容获取失败或已失效!请登录 <a href="${appUri}" target="_brank">主文档空间</a> 后再刷新此页面!`; document.getElementById('div_info').innerHTML = `分享内容获取失败或已失效!请登录 <a href="${appUri}" target="_brank">主文档空间</a> 后再刷新此页面!`;