Bläddra i källkod

退出功能及修改word功能

Signed-off-by: lcw <1324309909@qq.com>
lcw 2 år sedan
förälder
incheckning
e87e3948b0
3 ändrade filer med 100 tillägg och 76 borttagningar
  1. 36 26
      js/Office/Poll.js
  2. 58 48
      js/Office/Word/Word.js
  3. 6 2
      uform.js

+ 36 - 26
js/Office/Poll.js

@@ -39,32 +39,42 @@ U.MD.O.P.pollingAsyn = function (r) {
             _message = r[_i];
             switch (_message.type) {
                 case 'us.word':     //判断是否是word 的消息
-                    _iframe = $('#UD_Word' + _message.messageInfo.docId + ' iframe')[0];
-                    if (_iframe) {
-                        _contentWindow = _iframe.contentWindow;
-                        if (_message.messageInfo.type == "updateName") {
-                            $('#UD_Word' + _message.messageInfo.docId + ' .U_MD_O_H_head_navigation_Title')[0].value = _message.messageInfo.name;
-                        }
-                        else if (_message.messageInfo.type == "insertModifyRecord") {
-                            _contentWindow.U.MD.O.W.Panel.syncHistory(_message.sendId, _message.messageInfo.historyid);
-                        }
-                        else if (_message.messageInfo.type == "addUser") {
-                            _contentWindow.U.MD.O.W.Panel.syncAddUser(_message.messageInfo.userIds, _message.sendId);
-                        }
-                        else if ($('#UD_Word' + _message.messageInfo.docId).css('display') == 'block') {
-                            switch (_message.messageInfo.type) {// 判断消息种类
-                                case 'update':
-                                    _contentWindow.U.MD.O.W.E.updateEditorLine(_message.messageInfo);
-                                    break;
-                                case 'add':
-                                    _contentWindow.U.MD.O.W.E.addEditorLine(_message.messageInfo);
-                                    break;
-                                case 'delete':
-                                    _contentWindow.U.MD.O.W.E.deleteEditorLine(_message.messageInfo);
-                                    break;
-                            }
-                        }
-                    }
+                    // _iframe = $('#UD_Word' + _message.messageInfo.docId + ' iframe')[0];
+                    // if (_iframe) {
+                    //     _contentWindow = _iframe.contentWindow;
+                    //     if (_message.messageInfo.type == "updateName") {
+                    //         $('#UD_Word' + _message.messageInfo.docId + ' .U_MD_O_H_head_navigation_Title')[0].value = _message.messageInfo.name;
+                    //     }
+                    //     else if (_message.messageInfo.type == "insertModifyRecord") {
+                    //         _contentWindow.U.MD.O.W.Panel.syncHistory(_message.sendId, _message.messageInfo.historyid);
+                    //     }
+                    //     else if (_message.messageInfo.type == "addUser") {
+                    //         _contentWindow.U.MD.O.W.Panel.syncAddUser(_message.messageInfo.userIds, _message.sendId);
+                    //     }
+                    //     else if ($('#UD_Word' + _message.messageInfo.docId).css('display') == 'block') {
+                    //         switch (_message.messageInfo.type) {// 判断消息种类
+                    //             case 'update':
+                    //                 _contentWindow.U.MD.O.W.E.updateEditorLine(_message.messageInfo);
+                    //                 break;
+                    //             case 'add':
+                    //                 _contentWindow.U.MD.O.W.E.addEditorLine(_message.messageInfo);
+                    //                 break;
+                    //             case 'delete':
+                    //                 _contentWindow.U.MD.O.W.E.deleteEditorLine(_message.messageInfo);
+                    //                 break;
+                    //         }
+                    //     }
+                    // }
+                     _iframe = $('#doc iframe')[0];
+                     if (_iframe) {
+                         _contentWindow = _iframe.contentWindow;
+                         switch (_message.messageInfo.type) {// 判断消息种类
+                             case 'update':
+                                _contentWindow.U.MD.O.W.updateEditorLine(_message.messageInfo);
+                                 break;
+                         }
+                         // }
+                     }
                     break;
                 case 'us.nav':
                     _iframe = $('#UD_Word' + _message.messageInfo.docId + ' iframe')[0];

+ 58 - 48
js/Office/Word/Word.js

@@ -73,9 +73,11 @@ U.MD.O.W.getuser = async function () {
                         U.A.Request(US.Config.pbl + "selectUser?userid=" + _user.userid, [], function (res) {//US.userInfo.userid
                             if (res.value == null || res.value[0].length == 0) {
                                 US.userInfo = res.value[0][0];
+                                US.userInfo.userid = _user.userid;
                                 resolve(res.value[0][0]); //记录用户数据
                             }
                             else {
+                                US.userInfo.userid = _user.userid;
                                 resolve(US.userInfo); //记录用户数据
 
                             }
@@ -298,6 +300,10 @@ U.MD.O.W.asynLoad = function (r) { //object 值
 
 //#region 保存区域
 
+U.MD.O.W.updateEditorLine = function (wordInfo) {
+    $("#U_MD_O_H_wordEditor")[0].innerHTML = wordInfo.data;
+}
+
 /**
  * 判断当前文件是否保存
  *
@@ -310,32 +316,36 @@ U.MD.O.W.isSave = function () {
 }
 
 U.MD.O.W.updateSocket = function (wordInfo) {
-    U.A.Request(US.SCOKET, ["getWord", "send", JSON.stringify(wordInfo), 1], function (r) {
+    U.A.Request(US.SCOKET, ["send", JSON.stringify(wordInfo)], function (r) {
         console.log(r);
     });
 }
 
 U.MD.O.W.updateFileData = function (wordInfo) {
-    U.A.Request(US.Config.pbl + "updateFileData" , [wordInfo.messageInfo.data,wordInfo.receiveId], function (res) { //US.userInfo.userid
+    U.A.Request(US.Config.pbl + "updateFileData", [wordInfo.messageInfo.data, wordInfo.receiveId], function (res) { //US.userInfo.userid
         U.Alert("保存成功");
         console.log(res);
     }, [], { "type": "GET", "withCredentials": true });
 }
 
-U.MD.O.W.wordInfo = function( type, content, navid, userid, roomid) {
+U.MD.O.W.wordInfo = function (type, content, navid, userid, roomid) {
     var _data = {
-      sendId: userid, //发送人id
-      receiveId: roomid, //文件id
-      type: navid, //消息类型
-      messageInfo: {
-        type: type, //类型
-        data: content, //内容
-        docId: roomid, //文档id
-        // pageId: US.pageId, //当前页面id
-      },
+        "us.word": [
+            {
+                sendId: userid, //发送人id
+                receiveId: roomid, //文件id
+                type: navid, //消息类型
+                messageInfo: {
+                    type: type, //类型
+                    data: content, //内容
+                    docId: roomid, //文档id
+                    // pageId: US.pageId, //当前页面id
+                },
+            },
+        ],
     };
     return _data;
-  }
+}
 
 /**
  * 保存Word
@@ -366,16 +376,16 @@ U.MD.O.W.save = function () {
 
     //保存到数据库
     // top.U.A.Request(US.DISK, ["SaveFileContent", US.userInfo.userid, _fileid, _html, _name, "uw"], function (r) {
-        // U.MD.O.W.fileinfo.UsOffice = r.context[1].innerHTML;
-        let wordInfo = U.MD.O.W.wordInfo(
-            "update",
-            $("#U_MD_O_H_wordEditor")[0].innerHTML,
-            "us.word",
-            top.US.userInfo.userid,
-            top.US.wordRoomInfo.id,
-        );
-        U.MD.O.W.updateSocket(wordInfo);
-        U.MD.O.W.updateFileData(wordInfo);
+    // U.MD.O.W.fileinfo.UsOffice = r.context[1].innerHTML;
+    let wordInfo = U.MD.O.W.wordInfo(
+        "update",
+        $("#U_MD_O_H_wordEditor")[0].innerHTML,
+        "us.word",
+        top.US.userInfo.userid,
+        top.US.wordRoomInfo.id,
+    );
+    U.MD.O.W.updateSocket(wordInfo);
+    U.MD.O.W.updateFileData(wordInfo['us.word'][0]);
     // }, (['', _el])); //保存到数据库
 
     // }
@@ -527,7 +537,7 @@ U.MD.O.W.newNavSwitch = function () {
 
 
 U.MD.O.W.isRoom = function () {
-    U.A.Request(US.Config.pbl + "selectRoomByFile?uid=" + US.userInfo.userid, [], function (res) { 
+    U.A.Request(US.Config.pbl + "selectRoomByFile?uid=" + US.userInfo.userid, [], function (res) {
         if (res.value == null || res.value[0].length == 0) {
             U.MD.O.W.openRoomConfirm();
         } else {
@@ -537,16 +547,16 @@ U.MD.O.W.isRoom = function () {
         }
     }, [], { "type": "GET", "withCredentials": true });
 }
-U.MD.O.W.MathRand = function() {
+U.MD.O.W.MathRand = function () {
     var Num = "";
     for (var i = 0; i < 6; i++) {
         Num += Math.floor(Math.random() * 10);
     }
     return Num;
 }
-U.MD.O.W.checkNum = function() {
+U.MD.O.W.checkNum = function () {
     var numNum = U.MD.O.W.MathRand();
-    U.A.Request(US.Config.pbl + "checkRoomNumByFile?num=" + numNum, [], function(res) {
+    U.A.Request(US.Config.pbl + "checkRoomNumByFile?num=" + numNum, [], function (res) {
         if (res.value == null || res.value[0].length == 0) {
             U.MD.O.W.addRoom(numNum);
         } else {
@@ -554,9 +564,9 @@ U.MD.O.W.checkNum = function() {
         }
     }, [], { "type": "GET", "withCredentials": true });
 }
-U.MD.O.W.addRoom = function(numNum) {
+U.MD.O.W.addRoom = function (numNum) {
     var data = decodeURIComponent(JSON.stringify([]));
-    U.A.Request(US.Config.pbl + "insertRoomByFile?uid=" + US.userInfo.userid + "&n=" + numNum + "&d=" + encodeURIComponent(data), [], function(res) {
+    U.A.Request(US.Config.pbl + "insertRoomByFile?uid=" + US.userInfo.userid + "&n=" + numNum + "&d=" + encodeURIComponent(data), [], function (res) {
         if (res.value == 1) {
             U.alert("创建成功");
             if ($("#add_room")[0]) {
@@ -569,7 +579,7 @@ U.MD.O.W.addRoom = function(numNum) {
     }, [], { "type": "GET", "withCredentials": true });
 }
 U.MD.O.W.goRoom = function (number) {
-    U.A.Request(US.Config.pbl + "selectRoomByFile?uid=" + number, [], function (res) { 
+    U.A.Request(US.Config.pbl + "selectRoomByFile?uid=" + number, [], function (res) {
         if (res.value[0].length > 0) {
             U.alert("加入成功");
             if ($("#add_room")[0]) {
@@ -582,37 +592,37 @@ U.MD.O.W.goRoom = function (number) {
     }, [], { "type": "GET", "withCredentials": true });
 }
 
-U.MD.O.W.copyText = function(target) {
+U.MD.O.W.copyText = function (target) {
     var div = $(".form_delete-main-room")[0].innerText;
     var clipboard = new ClipboardJS('.copy-message', {
-        text: function() {
+        text: function () {
             return div;
         }
     });
-    clipboard.on('success', function(e) {
+    clipboard.on('success', function (e) {
         console.log(e);
         e.clearSelection();
         U.alert("复制成功");
     });
-    clipboard.on('error', function(e) {
+    clipboard.on('error', function (e) {
         console.log(e);
         U.alert("复制失败");
     });
 }
 
 U.MD.O.W.getWork = function (rid) {
-    // U.A.Request(US.SCOKET, ["getWord", rid, US.pageId, uid], function (r) { 
-    //     console.log(r);
-    // });
-    U.A.Request(US.Config.pbl + "select_file?fid=" + rid, [], function (res) { 
+
+    U.A.Request(US.Config.pbl + "select_file?fid=" + rid, [], function (res) {
         if (res.value[0].length > 0) {
             US.wordRoomInfo = res.value[0][0];
-            $("#U_MD_O_H_wordEditor")[0].innerHTML = US.wordRoomInfo.data;
+            U.A.Request(US.SCOKET, ["getWord", rid, US.pageId, US.userInfo.userid], function (r) {
+                $("#U_MD_O_H_wordEditor")[0].innerHTML = US.wordRoomInfo.data;
+            });
         }
     }, [], { "type": "GET", "withCredentials": true });
 }
 
-U.MD.O.W.addPerson = function() {
+U.MD.O.W.addPerson = function () {
     var BOX = $$("div", {});
     var form_main = $$('div', { "className": "form-main" }, BOX);
     var form_content = $$('div', { "className": "form-content" }, form_main);
@@ -632,11 +642,11 @@ U.MD.O.W.addPerson = function() {
         if (a.indexOf(r[i].userid) != -1) {
             abc.checked = true
         }
-        person.onclick = function(e) {
+        person.onclick = function (e) {
             var el = e.currentTarget
             el.getElementsByTagName("input")[0].click();
         }
-        abc.onclick = function(e) {
+        abc.onclick = function (e) {
             e.stopPropagation();
             if (a.indexOf(e.target.id) !== -1) {
                 a.splice(a.indexOf(e.target.id), 1);
@@ -675,7 +685,7 @@ U.MD.O.W.addPerson = function() {
     // }
 }
 
-U.MD.O.W.isOpenRoomConfirm = function() {
+U.MD.O.W.isOpenRoomConfirm = function () {
     var BOX = $$("div", {});
     var form_main = $$('div', { "className": "form-main" }, BOX);
     var form_content = $$('div', { "className": "form-content" }, form_main);
@@ -691,7 +701,7 @@ U.MD.O.W.isOpenRoomConfirm = function() {
     $$("div", { "class": "link", "innerHTML": "房间号:", }, room_number)
     $$("div", { "class": "roomNumber", "innerHTML": US.numNum, }, room_number)
     $$("div", { "className": "link", "innerHTML": "复制房间号信息,打开协同文档输入即可加入。", }, form_delete_main_body)
-        // $$("input", { "className": "text", "type": "text" }, form_delete_main_body);
+    // $$("input", { "className": "text", "type": "text" }, form_delete_main_body);
     var btnBox = $$('div', { "className": "copy-btn" }, form_main);
     var confirm = $$('button', { "className": "copy-message", "innerHTML": `${"一键复制信息"}` }, btnBox);
     new U.UF.UI.form(`${"邀请成员"}`, BOX, {
@@ -717,11 +727,11 @@ U.MD.O.W.isOpenRoomConfirm = function() {
             "display": "flex",
         }
     });
-    confirm.onclick = function() {
+    confirm.onclick = function () {
         U.MD.O.W.copyText();
     }
 }
-U.MD.O.W.openRoomConfirm = function() {
+U.MD.O.W.openRoomConfirm = function () {
     var BOX = $$("div", {});
     var form_main = $$('div', { "className": "form-main" }, BOX);
     var form_content = $$('div', { "className": "form-content" }, form_main);
@@ -754,10 +764,10 @@ U.MD.O.W.openRoomConfirm = function() {
             "display": "flex",
         }
     });
-    confirm.onclick = function() {
+    confirm.onclick = function () {
         U.MD.O.W.checkNum();
     }
-    cencal.onclick = function() {
+    cencal.onclick = function () {
         U.MD.O.W.goRoom($(".form_delete-main_box")[0].value);
     }
 

+ 6 - 2
uform.js

@@ -11940,8 +11940,12 @@ U.MD.U.LO.logoutSystem = function (callback) {
     //如果用户登录的情况
     if (US.userInfo.userid) {
         //弹出退出登录的提示
-        U.UF.UI.confirm("是否退出" + US.userInfo.UserName + "账号", function () {
-            U.MD.U.LO.logout(callback);
+        U.UF.UI.confirm("是否退出" + US.userInfo.username + "账号", function () {
+            // U.MD.U.LO.logout(callback);
+            U.A.Request(US.Config.server + "logout", [], function (res) {
+                U.alert("退出成功!")
+                window.location.reload();
+            }, [], { "type": "POST", "withCredentials": true });
         });
     }
 }