no message

This commit is contained in:
kuaifan
2022-04-18 18:36:38 +08:00
parent 9553e43fa8
commit 2686bfbf5e
10 changed files with 81 additions and 30 deletions
+24 -22
View File
@@ -49,28 +49,30 @@ function genericPublish(url, version) {
} else {
for (const filename of files) {
const localFile = path.join(filePath, filename)
const fileStat = fs.statSync(localFile)
if (fileStat.isFile()) {
const uploadOra = ora(`${filename} uploading...`).start()
const formData = new FormData()
formData.append("file", fs.createReadStream(localFile));
await axios({
method: 'post',
url: url,
data: formData,
maxContentLength: Infinity,
maxBodyLength: Infinity,
headers: {
'Generic-Version': version,
'Content-Type': 'multipart/form-data;boundary=' + formData.getBoundary(),
}
}).then(_ => {
uploadOra.succeed(`${filename} upload successful`)
}).catch(_ => {
uploadOra.fail(`${filename} upload fail`)
}).finally(_ => {
fse.removeSync(localFile)
})
if (fse.existsSync(localFile)) {
const fileStat = fs.statSync(localFile)
if (fileStat.isFile()) {
const uploadOra = ora(`${filename} uploading...`).start()
const formData = new FormData()
formData.append("file", fs.createReadStream(localFile));
await axios({
method: 'post',
url: url,
data: formData,
maxContentLength: Infinity,
maxBodyLength: Infinity,
headers: {
'Generic-Version': version,
'Content-Type': 'multipart/form-data;boundary=' + formData.getBoundary(),
}
}).then(_ => {
uploadOra.succeed(`${filename} upload successful`)
}).catch(_ => {
uploadOra.fail(`${filename} upload fail`)
}).finally(_ => {
fse.removeSync(localFile)
})
}
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "DooTask",
"version": "0.13.36",
"version": "0.13.38",
"description": "DooTask is task management system.",
"scripts": {
"start": "./cmd dev",
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
8670e2bbf86722cc
964ec56060e5c9b0
+34
View File
@@ -1004,6 +1004,40 @@
window.scrollIntoView(element, options)
}
}
},
/**
* 等比缩放尺寸
* @param width
* @param height
* @param maxWidth
* @param maxHeight
* @returns {{width, height}|{width: number, height: number}}
*/
scaleToScale(width, height, maxWidth, maxHeight) {
let tempWidth;
let tempHeight;
if (width > 0 && height > 0) {
if (width / height >= maxWidth / maxHeight) {
if (width > maxWidth) {
tempWidth = maxWidth;
tempHeight = (height * maxWidth) / width;
} else {
tempWidth = width;
tempHeight = height;
}
} else {
if (height > maxHeight) {
tempHeight = maxHeight;
tempWidth = (width * maxHeight) / height;
} else {
tempWidth = width;
tempHeight = height;
}
}
return {width: parseInt(tempWidth), height: parseInt(tempHeight)};
}
return {width, height};
}
});
@@ -174,6 +174,21 @@ export default {
}
text = text.trim().replace(/(\n\x20*){3,}/g, "\n\n");
text = text.replace(/\{\{RemoteURL\}\}/g, $A.apiUrl('../'))
const array = text.match(/<img\s+[^>]*?>/g);
if (array) {
const widthReg = new RegExp("width=\"(\\d+)\"")
const heightReg = new RegExp("height=\"(\\d+)\"")
array.some(res => {
if (widthReg.test(res) && heightReg.test(res)) {
let width = parseInt(res.match(widthReg)[1]),
height = parseInt(res.match(heightReg)[1]),
maxSize = res.indexOf("emoticon") > -1 ? 150 : 220;
let scale = $A.scaleToScale(width, height, maxSize, maxSize);
let value = res.replace(widthReg, `width=${scale.width}`).replace(heightReg, `height=${scale.height}`)
text = text.replace(res, value)
}
})
}
return text;
},
@@ -290,7 +305,7 @@ export default {
} else if (type === 'text') {
const baseUrl = $A.apiUrl('../');
const array = msg.text.match(/<img\s+class="browse"[^>]*?src="(.*?)"[^>]*?>/g);
array.some(res => {
array && array.some(res => {
list.push(res.match(/<img\s+class="browse"[^>]*?src="(.*?)"[^>]*?>/)[1].replace(/\{\{RemoteURL\}\}/g, baseUrl))
})
}