mengshukeji
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
50 additions and
4 deletions
-
src/config.js
-
src/controllers/imageUpdateCtrl.js
-
src/controllers/server.js
-
src/core.js
|
|
@ -66,4 +66,5 @@ export default { |
|
|
|
showstatisticBarConfig:{}, //自定义计数栏
|
|
|
|
cellRightClickConfig:{}, //自定义单元格右键菜单
|
|
|
|
sheetRightClickConfig:{}, //自定义底部sheet页右击菜单
|
|
|
|
imageUpdateMethodConfig:{}, //自定义图片同步方式
|
|
|
|
} |
|
|
@ -0,0 +1,21 @@ |
|
|
|
// 自定义图片的更新方法例如: customImageUpdate("POST", "http://127.0.0.1:8000/luckysheetimageprocess/", d)
|
|
|
|
function customImageUpdate(method, url, obj) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
const xhr = new XMLHttpRequest() || new ActiveXObject("Microsoft.XMLHTTP"); |
|
|
|
xhr.open(method, url); |
|
|
|
xhr.send(JSON.stringify(obj)); // 发送 POST/GET 数据
|
|
|
|
xhr.onreadystatechange = function () { |
|
|
|
if (xhr.readyState == 4) { |
|
|
|
if (xhr.status == 200) { |
|
|
|
resolve(xhr.responseText); |
|
|
|
} else { |
|
|
|
reject("error"); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
export { |
|
|
|
customImageUpdate |
|
|
|
} |
|
|
@ -18,6 +18,8 @@ import { collaborativeEditBox } from './select' |
|
|
|
import locale from '../locale/locale'; |
|
|
|
import dayjs from "dayjs"; |
|
|
|
import json from '../global/json'; |
|
|
|
import luckysheetConfigsetting from './luckysheetConfigsetting'; |
|
|
|
import {customImageUpdate} from './imageUpdateCtrl'; |
|
|
|
|
|
|
|
const server = { |
|
|
|
gridKey: null, |
|
|
@ -141,11 +143,31 @@ const server = { |
|
|
|
// d.s = params.s;
|
|
|
|
} |
|
|
|
|
|
|
|
let msg = pako.gzip(encodeURIComponent(JSON.stringify(d)), { to: "string" }); |
|
|
|
// TODO 配置自定义方式同步图片
|
|
|
|
const customImageUpdateMethodConfig = luckysheetConfigsetting.imageUpdateMethodConfig |
|
|
|
if (JSON.stringify(customImageUpdateMethodConfig) !== "{}") { |
|
|
|
if ("images" != d.k) { |
|
|
|
let msg = pako.gzip(encodeURIComponent(JSON.stringify(d)), {to: "string"}); |
|
|
|
|
|
|
|
if(_this.websocket!=null){ |
|
|
|
_this.websocket.send(msg); |
|
|
|
} |
|
|
|
if (_this.websocket != null) { |
|
|
|
_this.websocket.send(msg); |
|
|
|
} |
|
|
|
} else { |
|
|
|
customImageUpdate(customImageUpdateMethodConfig.method, customImageUpdateMethodConfig.url, d) |
|
|
|
.then((data) => { |
|
|
|
console.log(data); |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
console.log(err); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
let msg = pako.gzip(encodeURIComponent(JSON.stringify(d)), {to: "string"}); |
|
|
|
if (_this.websocket != null) { |
|
|
|
_this.websocket.send(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
websocket: null, |
|
|
|
|
|
@ -140,6 +140,8 @@ luckysheet.create = function (setting) { |
|
|
|
|
|
|
|
luckysheetConfigsetting.initShowsheetbarConfig = false; |
|
|
|
|
|
|
|
luckysheetConfigsetting.imageUpdateMethodConfig = extendsetting.imageUpdateMethodConfig; |
|
|
|
|
|
|
|
if (Store.lang === 'zh') flatpickr.localize(Mandarin.zh); |
|
|
|
|
|
|
|
// Store the currently used plugins for monitoring asynchronous loading
|
|
|
|