mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 19:35:50 +00:00
no message
This commit is contained in:
parent
7ab5ddc408
commit
fa2959515e
@ -14,6 +14,7 @@ export default {
|
|||||||
...mapState([
|
...mapState([
|
||||||
'previewImageIndex',
|
'previewImageIndex',
|
||||||
'previewImageList',
|
'previewImageList',
|
||||||
|
'previewImageBase64',
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -92,7 +93,15 @@ export default {
|
|||||||
$A.eeuiAppSendMessage({
|
$A.eeuiAppSendMessage({
|
||||||
action: 'picturePreview',
|
action: 'picturePreview',
|
||||||
position: index,
|
position: index,
|
||||||
paths
|
paths: paths.map(item => {
|
||||||
|
if (!$A.isJson(item)) {
|
||||||
|
item = {path: item}
|
||||||
|
}
|
||||||
|
if (this.previewImageBase64.has(item.path)) {
|
||||||
|
item.preview = this.previewImageBase64.get(item.path);
|
||||||
|
}
|
||||||
|
return item
|
||||||
|
})
|
||||||
});
|
});
|
||||||
} else if ($A.isElectron) {
|
} else if ($A.isElectron) {
|
||||||
this.$Electron.sendMessage('openMediaViewer', {
|
this.$Electron.sendMessage('openMediaViewer', {
|
||||||
|
|||||||
43
resources/assets/js/store/actions.js
vendored
43
resources/assets/js/store/actions.js
vendored
@ -3979,6 +3979,49 @@ export default {
|
|||||||
state.previewImageList = data.list;
|
state.previewImageList = data.list;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预览图片缓存 base64
|
||||||
|
* @param state
|
||||||
|
* @param imgElement
|
||||||
|
*/
|
||||||
|
previewCacheBase64({state}, imgElement) {
|
||||||
|
try {
|
||||||
|
const src = $A.thumbRestore(imgElement.currentSrc || imgElement.src);
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
|
// 计算缩放比例,保持原有比例,确保最长边不超过 200
|
||||||
|
const MAX_SIZE = 200;
|
||||||
|
const originalWidth = imgElement.naturalWidth;
|
||||||
|
const originalHeight = imgElement.naturalHeight;
|
||||||
|
let width = originalWidth;
|
||||||
|
let height = originalHeight;
|
||||||
|
if (originalWidth > originalHeight && originalWidth > MAX_SIZE) {
|
||||||
|
width = MAX_SIZE;
|
||||||
|
height = Math.floor(originalHeight * (MAX_SIZE / originalWidth));
|
||||||
|
} else if (originalHeight > MAX_SIZE) {
|
||||||
|
height = MAX_SIZE;
|
||||||
|
width = Math.floor(originalWidth * (MAX_SIZE / originalHeight));
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas.width = width;
|
||||||
|
canvas.height = height;
|
||||||
|
ctx.drawImage(imgElement, 0, 0);
|
||||||
|
const base64 = canvas.toDataURL('image/jpeg', 0.8);
|
||||||
|
state.previewImageBase64.set(src, base64);
|
||||||
|
//
|
||||||
|
if (state.previewImageBase64.size >= 10) {
|
||||||
|
const keys = Array.from(state.previewImageBase64.keys());
|
||||||
|
const removeCount = keys.length - 10;
|
||||||
|
for (let i = 0; i < removeCount; i++) {
|
||||||
|
state.previewImageBase64.delete(keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 播放音频
|
* 播放音频
|
||||||
* @param state
|
* @param state
|
||||||
|
|||||||
1
resources/assets/js/store/state.js
vendored
1
resources/assets/js/store/state.js
vendored
@ -225,6 +225,7 @@ export default {
|
|||||||
// 预览图片
|
// 预览图片
|
||||||
previewImageIndex: 0,
|
previewImageIndex: 0,
|
||||||
previewImageList: [],
|
previewImageList: [],
|
||||||
|
previewImageBase64: new Map(),
|
||||||
|
|
||||||
// 工作报告未读数量
|
// 工作报告未读数量
|
||||||
reportUnreadNumber: 0,
|
reportUnreadNumber: 0,
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit ca3803c8f27b96a955585a042102621249e08392
|
Subproject commit 80267d1193fc68dbd4966c4232e716a35ba51c0e
|
||||||
Loading…
x
Reference in New Issue
Block a user