Browse Source

fix(demo): websocket url

1.Update updateUrl 2.fix websocket parse data error
master
mengshukeji 5 years ago
parent
commit
cf77ec3307
  1. 4
      src/controllers/resize.js
  2. 18
      src/controllers/server.js
  3. 3
      src/index.html
  4. 8
      src/locale/en.js
  5. 11
      src/locale/es.js
  6. 8
      src/locale/zh.js

4
src/controllers/resize.js

@ -124,6 +124,10 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) {
const toobarElements = Store.toobarObject.toobarElements; const toobarElements = Store.toobarObject.toobarElements;
let moreButtonIndex = 0; let moreButtonIndex = 0;
// When you resize the window during initialization, you will find that the dom has not been rendered yet
if(toobarWidths == undefined){
return;
}
// 找到应该隐藏的起始元素位置 // 找到应该隐藏的起始元素位置
for (let index = toobarWidths.length - 1; index >= 0; index--) { for (let index = toobarWidths.length - 1; index >= 0; index--) {

18
src/controllers/server.js

@ -155,7 +155,7 @@ const server = {
//连接建立时触发 //连接建立时触发
_this.websocket.onopen = function() { _this.websocket.onopen = function() {
console.info('WebSocket连接成功'); console.info(locale().websocket.success);
hideloading(); hideloading();
_this.wxErrorCount = 0; _this.wxErrorCount = 0;
@ -216,7 +216,10 @@ const server = {
} }
} }
else if(type == 4){ //批量指令更新 else if(type == 4){ //批量指令更新
let items = JSON.parse(data.data); // let items = JSON.parse(data.data);
// After editing by multiple people, data.data may appear as an empty string
let items = data.data === "" ? data.data : JSON.parse(data.data);
for(let i = 0; i < items.length; i++){ for(let i = 0; i < items.length; i++){
_this.wsUpdateMsg(item[i]); _this.wsUpdateMsg(item[i]);
@ -229,22 +232,23 @@ const server = {
_this.wxErrorCount++; _this.wxErrorCount++;
if(_this.wxErrorCount > 3){ if(_this.wxErrorCount > 3){
showloading("WebSocket连接发生错误, 请刷新页面!"); showloading(locale().websocket.refresh);
} }
else{ else{
showloading("WebSocket连接发生错误, 请耐心等待!"); showloading(locale().websocket.wait);
_this.openWebSocket(); _this.openWebSocket();
} }
} }
//连接关闭时触发 //连接关闭时触发
_this.websocket.onclose = function(){ _this.websocket.onclose = function(){
console.info('WebSocket连接关闭'); console.info(locale().websocket.close);
alert("服务器通信发生错误,请刷新页面后再试,如若不行请联系管理员!");
alert(locale().websocket.contact);
} }
} }
else{ else{
alert('当前浏览器 Not Support WebSocket'); alert(locale().websocket.support);
} }
}, },
wsUpdateMsg: function(item) { wsUpdateMsg: function(item) {

3
src/index.html

@ -21,7 +21,6 @@
<body> <body>
<div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height:100%;left: 0px;top: 0px;"></div> <div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height:100%;left: 0px;top: 0px;"></div>
<!-- 1 -->
<!-- demo feature, non-production use --> <!-- demo feature, non-production use -->
<script src="./demoData/demoFeature.js"></script> <script src="./demoData/demoFeature.js"></script>
<script src="./demoData/sheetFormula.js"></script> <script src="./demoData/sheetFormula.js"></script>
@ -67,7 +66,7 @@
lang: lang, lang: lang,
allowUpdate:true, allowUpdate:true,
updateImageUrl: location.origin + "/luckysheet/api/updateImg", updateImageUrl: location.origin + "/luckysheet/api/updateImg",
updateUrl: "ws://"+ location.host +"/luckysheet/websocket/qksheet", updateUrl: "ws://"+ location.host +"/luckysheet/websocket/luckysheet",
gridKey: gridKey, gridKey: gridKey,
loadUrl: location.origin + "/luckysheet/api/load", loadUrl: location.origin + "/luckysheet/api/load",
loadSheetUrl: location.origin + "/luckysheet/api/loadsheet" loadSheetUrl: location.origin + "/luckysheet/api/loadsheet"

8
src/locale/en.js

@ -9999,6 +9999,14 @@ export default {
}, },
edit:{ edit:{
typing:"typing", typing:"typing",
},
websocket:{
success: 'WebSocket connection success',
refresh: 'An error occurred in the WebSocket connection, please refresh the page!',
wait: 'An error occurred in the WebSocket connection, please be patient!',
close: 'WebSocket connection closed',
contact: 'Server communication error occurred, please refresh the page and try again, if not, please contact the administrator!',
support: 'The current browser does not support WebSocket',
} }
}; };

11
src/locale/es.js

@ -9979,5 +9979,16 @@ export default {
menuItemAreas:"Imprimir áreas", menuItemAreas:"Imprimir áreas",
menuItemRows:"Imprimir títulos de filas", menuItemRows:"Imprimir títulos de filas",
menuItemColumns:"Imprimir títulos de columnas", menuItemColumns:"Imprimir títulos de columnas",
},
edit:{
typing:"mecanografía",
},
websocket:{
success: 'Éxito de la conexión de WebSocket',
refresh: 'Se produjo un error en la conexión de WebSocket, ¡actualice la página!',
wait: 'Se produjo un error en la conexión de WebSocket, ¡tenga paciencia!',
close: 'Conexión WebSocket cerrada',
contact: 'Ocurrió un error de comunicación con el servidor, actualice la página y vuelva a intentarlo; de lo contrario, comuníquese con el administrador.',
support: 'El navegador actual no es compatible con WebSocket',
} }
}; };

8
src/locale/zh.js

@ -10240,6 +10240,14 @@ export default {
}, },
edit:{ edit:{
typing:"正在输入", typing:"正在输入",
},
websocket:{
success: 'WebSocket连接成功',
refresh: 'WebSocket连接发生错误, 请刷新页面!',
wait: 'WebSocket连接发生错误, 请耐心等待!',
close: 'WebSocket连接关闭',
contact: '服务器通信发生错误,请刷新页面后再试,如若不行请联系管理员!',
support: '当前浏览器不支持WebSocket',
} }
}; };

Loading…
Cancel
Save