Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
feat: use npm dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangchen915 committed Nov 1, 2020
1 parent ad73f9a commit e4bd439
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 42 deletions.
5 changes: 3 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ const paths = {
plugins: ['src/plugins/*.css'],
css:['src/css/*.css'],
pluginsJs:[
'src/plugins/js/jquery.min.js',
'node_modules/jquery/dist/jquery.min.js',
//'src/plugins/js/jquery.min.js',
'src/plugins/js/clipboard.min.js',
'src/plugins/js/spectrum.min.js',
'src/plugins/js/jquery-ui.min.js',
Expand All @@ -92,7 +93,7 @@ const paths = {
'src/plugins/js/moment-msdate.js',
'src/plugins/js/numeral.min.js',
'src/plugins/js/html2canvas.min.js',
'src/plugins/js/pako.min.js',
//'src/plugins/js/pako.min.js',
'src/plugins/js/localforage.min.js',
'src/plugins/js/lodash.min.js',
'src/plugins/js/daterangepicker.js',
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
},
"dependencies": {
"@babel/runtime": "^7.12.1",
"jspdf": "^2.1.1"
"dayjs": "^1.9.4",
"jquery": "^3.5.1",
"jspdf": "^2.1.1",
"pako": "^1.0.11"
},
"scripts": {
"build": "cross-env NODE_ENV=production gulp build",
Expand Down
79 changes: 40 additions & 39 deletions src/controllers/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pako from 'pako'
import { showloading, hideloading } from '../global/loading';
import { luckysheetrefreshgrid, jfrefreshgrid_rhcw } from '../global/refresh';
import { sheetHTML, luckyColor } from './constant';
Expand Down Expand Up @@ -69,7 +70,7 @@ const server = {
if(i == n - 1){
_this.saveParam("rv_end", sheetIndex, null);
}
}
}
}
},
saveParam: function (type, index, value, params) {
Expand Down Expand Up @@ -132,7 +133,7 @@ const server = {
if(_this.websocket!=null){
_this.websocket.send(msg);
}

},
websocket: null,
wxErrorCount: 0,
Expand Down Expand Up @@ -169,12 +170,12 @@ const server = {
}
else if(type == 3){ //多人操作不同选区("t": "mv")(用不同颜色显示其他人所操作的选区)
let id = data.id;
let username = data.username;
let username = data.username;
let item = JSON.parse(data.data);

let type = item.t,
index = item.i,
value = item.v;
value = item.v;

if(getObjType(value) != "array"){
value = JSON.parse(value);
Expand All @@ -189,7 +190,7 @@ const server = {
}
else if(type == 4){ //批量指令更新
let items = JSON.parse(data.data);

for(let i = 0; i < items.length; i++){
_this.wsUpdateMsg(item[i]);
}
Expand All @@ -213,7 +214,7 @@ const server = {
_this.websocket.onclose = function(){
console.info('WebSocket连接关闭');
alert("服务器通信发生错误,请刷新页面后再试,如若不行请联系管理员!");
}
}
}
else{
alert('当前浏览器 Not Support WebSocket');
Expand All @@ -224,7 +225,7 @@ const server = {
index = item.i,
value = item.v;

let file = Store.luckysheetfile[getSheetIndex(index)];
let file = Store.luckysheetfile[getSheetIndex(index)];

if(file == null){
return;
Expand Down Expand Up @@ -335,7 +336,7 @@ const server = {
// luckysheet.pivotTable.changePivotTable(index);
}
else if(k == "frozen"){ //freezen row and column

// tranform frozen
luckysheetFreezen.frozenTofreezen();

Expand Down Expand Up @@ -427,7 +428,7 @@ const server = {
// if(r == calcChain[a].r && c == calcChain[a].c && index == calcChain[a].index){
// calcChain[a].func = func;
// }
// }
// }
// }

setTimeout(function () {
Expand All @@ -439,10 +440,10 @@ const server = {
return;
}

let rc = item.rc,
st_i = value.index,
len = value.len,
mc = value.mc,
let rc = item.rc,
st_i = value.index,
len = value.len,
mc = value.mc,
borderInfo = value.borderInfo;
let data = file.data;

Expand All @@ -457,7 +458,7 @@ const server = {
row.push(null);
}

//删除多少行,增加多少行空白行
//删除多少行,增加多少行空白行
for (let r = 0; r < len; r++) {
data.push(row);
}
Expand Down Expand Up @@ -502,11 +503,11 @@ const server = {
return;
}

let rc = item.rc,
st_i = value.index,
len = value.len,
addData = value.data,
mc = value.mc,
let rc = item.rc,
st_i = value.index,
len = value.len,
addData = value.data,
mc = value.mc,
borderInfo = value.borderInfo;
let data = file.data;

Expand Down Expand Up @@ -599,8 +600,8 @@ const server = {
let copyindex = value.copyindex, name = value.name;

let copyarrindex = getSheetIndex(copyindex);
let copyjson = $.extend(true, {}, Store.luckysheetfile[copyarrindex]);
let copyjson = $.extend(true, {}, Store.luckysheetfile[copyarrindex]);

copyjson.index = index;
copyjson.name = name;

Expand Down Expand Up @@ -699,7 +700,7 @@ const server = {
file.chart.splice(i, 1);

$("#" + cid).remove();
sheetmanage.delChart($("#" + cid).attr("chart_id"), $("#" + cid).attr("sheetIndex"));
sheetmanage.delChart($("#" + cid).attr("chart_id"), $("#" + cid).attr("sheetIndex"));

return;
}
Expand All @@ -723,7 +724,7 @@ const server = {
if(!!margeset){
row = margeset.row[1];
row_pre = margeset.row[0];

col = margeset.column[1];
col_pre = margeset.column[0];
}
Expand Down Expand Up @@ -760,14 +761,14 @@ const server = {
submitTimeout: function(){
let _this = this;
clearTimeout(_this.requestTimeOut);

//console.log(_this.requestlast, moment(), (_this.requestlast!=null && _this.requestlast.add(10, 'seconds').isBefore(moment()) ) );
if(!_this.requestLock && (_this.requestlast!=null && _this.requestlast.clone().add(1, 'seconds').isBefore(moment()) ) ){
_this.request();
}

// if(!_this.imageRequestLock && (_this.imageRequestLast==null || _this.imageRequestLast.clone().add(30, 'seconds').isBefore(moment()) ) ){

// }

_this.requestTimeOut = setTimeout(function(){
Expand All @@ -782,7 +783,7 @@ const server = {
let _this = this;
let key = this.gridKey;
let cahce_key = key + "__qkcache";

_this.cachelocaldata(function(cahce_key, params){
if(params.length==0){
return;
Expand Down Expand Up @@ -814,15 +815,15 @@ const server = {
_this.requestlast = moment();
_this.requestLock = false;
});
}
}
});
},
imageRequestLast: null,
imageRequestLock: false,
imageRequestTimeout: null,
imageRequest: function(){
let _this = this;

html2canvas($("#" + container).find(".luckysheet-grid-window").get(0), {
onrendered: function(canvas) {
//let imgcut = $("#luckysheet-cell-main").find(".luckysheet-grid-window");
Expand All @@ -832,7 +833,7 @@ const server = {
let newwidth = old.width();
let newheight = old.height();
let imageData = old.get(0).getContext("2d").getImageData(0, 0, newwidth, newheight);

let cutW = newwidth, cutH = newheight;
if(cutW*0.54 > cutH){
cutW = cutH / 0.54;
Expand Down Expand Up @@ -871,7 +872,7 @@ const server = {
_this.imageRequestLock =true;
});
}

}
});
},
Expand Down Expand Up @@ -901,14 +902,14 @@ const server = {
//let d = $.extend(true, [], data); //原来
let d = data;
let _this = this;

if(value instanceof Array){
for(let i = 0; i < value.length; i++){
let vitem = value[i];

for(let a = 0; a < d.length; a++){
let ditem = data[i]; //let ditem = data[a];?

if(_this.matchOpt(vitem, ditem)){
delete d[a];
}
Expand All @@ -918,7 +919,7 @@ const server = {
else{
for(let a = 0; a < d.length; a++){
let ditem = d[a];

if(_this.matchOpt(value, ditem)){
delete d[a];
}
Expand Down Expand Up @@ -955,7 +956,7 @@ const server = {

_this.localdata = data;
func(_this.localdata);

//console.log(value);
// localforage.setItem(key, data).then(function () {
// console.log(data);
Expand Down Expand Up @@ -1043,10 +1044,10 @@ const server = {
let cahce_key = key + "__qkcache";
//store.remove(key);
localforage.removeItem(cahce_key, function(err,value) {
if(func && typeof(func)=="function"){
if(func && typeof(func)=="function"){
func();
}

});
},
restorecachelocaldata: function(func){
Expand All @@ -1066,7 +1067,7 @@ const server = {
if(func instanceof Function){
func(_this.localdata);
}

// localforage.setItem(key, newdata).then(function () {
// func(newdata);
// }).catch(function (err) {
Expand All @@ -1077,4 +1078,4 @@ const server = {
}
}

export default server;
export default server;

0 comments on commit e4bd439

Please sign in to comment.