kuaifan před 5 roky
rodič
revize
36e5c9db7c

+ 18 - 0
app/Http/Controllers/Api/DocsController.php

@@ -587,6 +587,24 @@ class DocsController extends Controller
             return Base::retError(['已被会员【%】锁定!', Users::nickname($row['lockname'])]);
         }
         $D = Base::getContentsParse('D');
+        if ($row['type'] == 'document') {
+            $data = Base::json2array($D['content']);
+            $isRep = false;
+            preg_match_all("/<img\s*src=\"data:image\/(png|jpg|jpeg);base64,(.*?)\"/s", $data['content'], $matchs);
+            foreach ($matchs[2] as $key => $text) {
+                $p = "uploads/docs/document/" . $id . "/";
+                Base::makeDir(public_path($p));
+                $p.= md5($text) . "." . $matchs[1][$key];
+                $r = file_put_contents(public_path($p), base64_decode($text));
+                if ($r) {
+                    $data['content'] = str_replace($matchs[0][$key], '<img src="' . Base::fillUrl($p) . '"', $data['content']);
+                    $isRep = true;
+                }
+            }
+            if ($isRep == true) {
+                $D['content'] = Base::array2json($data);
+            }
+        }
         DB::table('docs_content')->insert([
             'bookid' => $row['bookid'],
             'sid' => $id,

+ 18 - 16
app/Module/Docs.php

@@ -78,23 +78,25 @@ class Docs
             }
         }
         $pushLists = [];
-        foreach ($array AS $tuser) {
-            $uLists = Base::DBC2A(DB::table('ws')->select(['fd', 'username', 'channel'])->where('username', $tuser['username'])->get());
-            foreach ($uLists AS $item) {
-                if ($item['username'] == $user['username']) {
-                    continue;
+        if ($array) {
+            foreach ($array AS $tuser) {
+                $uLists = Base::DBC2A(DB::table('ws')->select(['fd', 'username', 'channel'])->where('username', $tuser['username'])->get());
+                foreach ($uLists AS $item) {
+                    if ($item['username'] == $user['username']) {
+                        continue;
+                    }
+                    $pushLists[] = [
+                        'fd' => $item['fd'],
+                        'msg' => [
+                            'messageType' => 'docs',
+                            'body' => array_merge([
+                                'sid' => $sid,
+                                'nickname' => $user['nickname'] ?: $user['username'],
+                                'time' => time(),
+                            ], $bodyArray)
+                        ]
+                    ];
                 }
-                $pushLists[] = [
-                    'fd' => $item['fd'],
-                    'msg' => [
-                        'messageType' => 'docs',
-                        'body' => array_merge([
-                            'sid' => $sid,
-                            'nickname' => $user['nickname'] ?: $user['username'],
-                            'time' => time(),
-                        ], $bodyArray)
-                    ]
-                ];
             }
         }
         $pushTask = new PushTask($pushLists);

+ 1 - 0
resources/assets/js/main/components/TEditor.vue

@@ -225,6 +225,7 @@
                     language: "zh_CN",
                     toolbar: this.toolbar,
                     plugins: this.plugins,
+                    paste_data_images: true,
                     menu: {
                         view: {
                             title: 'View',

+ 1 - 0
resources/assets/js/main/pages/docs.vue

@@ -110,6 +110,7 @@
             display: flex;
             flex-direction: column;
             width: 100%;
+            min-width: 1024px;
             height: 100%;
             padding: 15px;
             .docs-body {

+ 68 - 43
resources/assets/js/main/pages/docs/edit.vue

@@ -67,7 +67,7 @@
                         <DropdownItem name="pdf">{{$L('导出PDF文件')}}</DropdownItem>
                     </DropdownMenu>
                 </Dropdown>
-                <Button :disabled="(disabledBtn || loadIng > 0) && hid == 0" class="header-button" size="small" type="primary" @click="handleClick('save')">{{$L('保存')}}</Button>
+                <Button :disabled="equalContent" :loading="loadIng > 0" class="header-button" size="small" type="primary" @click="handleClick('save')">{{$L('保存')}}</Button>
             </div>
             <div class="docs-body">
                 <template v-if="docDetail.type=='document'">
@@ -172,18 +172,20 @@
             position: absolute;
             width: 100%;
             height: 100%;
+            overflow-x: auto;
             .edit-header {
                 display: flex;
                 flex-direction: row;
                 align-items: center;
                 width: 100%;
                 height: 38px;
+                min-width: 1024px;
                 background-color: #ffffff;
                 box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.1);
                 position: relative;
                 z-index: 99;
                 .header-menu {
-                    width: 50px;
+                    width: 48px;
                     height: 100%;
                     text-align: center;
                     display: flex;
@@ -194,7 +196,7 @@
                     position: relative;
                     .menu-container {
                         display: inline-block;
-                        width: 50px;
+                        width: 48px;
                         height: 38px;
                         line-height: 38px;
                         color: #777777;
@@ -268,6 +270,8 @@
                     padding-left: 24px;
                     padding-right: 24px;
                     font-size: 16px;
+                    overflow: hidden;
+                    text-overflow:ellipsis;
                     white-space: nowrap;
                 }
                 .header-hint {
@@ -291,6 +295,7 @@
             .docs-body {
                 flex: 1;
                 width: 100%;
+                min-width: 1024px;
                 position: relative;
                 .body-text {
                     display: flex;
@@ -394,9 +399,7 @@
                                 if (params.index == 0) {
                                     data.sid = this.getSid();
                                 }
-                                this.goForward({name: 'docs-edit', params: data }, true);
-                                this.refreshSid();
-                                this.docDrawerShow = false;
+                                this.handleSection('openBefore', data);
                             }
                         }
                     }, this.$L('还原'));
@@ -415,6 +418,12 @@
                 this.timeValue = Math.round(new Date().getTime() / 1000);
             });
             //
+            $(window).bind('beforeunload', () => {
+                if (!this.equalContent && this.routeName === this.$route.name) {
+                    return '是否放弃修改的内容返回?';
+                }
+            });
+            //
             $A.WSOB.setOnMsgListener("chat/index", ['docs'], (msgDetail) => {
                 if (this.routeName !== this.$route.name) {
                     return;
@@ -474,6 +483,10 @@
             });
         },
         activated() {
+            this.docDrawerTab = '';
+            this.sectionNoDataText = '';
+            this.historyNoDataText = '';
+            //
             this.refreshSid();
             this.synergy(true);
         },
@@ -484,6 +497,10 @@
             }
             this.$Notice.close('docs-lock');
             //
+            if (!this.equalContent) {
+                this.handleClick('save');
+            }
+            //
             this.synergy(false);
             this.docDrawerShow = false;
             if ($A.getToken() === false) {
@@ -493,7 +510,7 @@
         watch: {
             sid(val) {
                 if (!val) {
-                    this.goBack({name:'docs'});
+                    this.goBackDirect();
                     return;
                 }
                 this.hid = $A.runNum($A.strExists(val, '-') ? $A.getMiddle(val, "-", null) : 0);
@@ -569,7 +586,7 @@
             }
         },
         computed: {
-            disabledBtn() {
+            equalContent() {
                 return this.bakContent == $A.jsonStringify(this.docContent);
             },
             synchUsersS() {
@@ -582,6 +599,11 @@
             }
         },
         methods: {
+            goBackDirect() {
+                this.bakContent = $A.jsonStringify(this.docContent);
+                this.goBack({name:'docs'});
+            },
+
             synergy(enter) {
                 if (enter === false) {
                     $A.WSOB.sendTo('docs', {
@@ -649,14 +671,14 @@
                         this.loadIng--;
                     },
                     error: () => {
-                        this.goBack({name:'docs'});
+                        this.goBackDirect();
                         alert(this.$L('网络繁忙,请稍后再试!'));
                     },
                     success: (res) => {
                         if (res.ret === 1) {
                             this.docDetail = res.data;
                             this.docContent = $A.jsonParse(res.data.content);
-                            this.bakContent = $A.jsonStringify(this.docContent);
+                            this.bakContent = this.hid == 0 ? $A.jsonStringify(this.docContent) : '';
                             this.continueLock(1000);
                         } else {
                             this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
@@ -666,10 +688,32 @@
             },
 
             handleSection(act, detail) {
-                if (act === 'open') {
-                    this.goForward({name: 'docs-edit', params: {sid: detail.id, other: detail || {}}}, true);
-                    this.refreshSid();
-                    this.docDrawerShow = false;
+                switch (act) {
+                    case 'open':
+                        this.handleSection('openBefore', {sid: detail.id, other: detail || {}})
+                        break;
+
+                    case 'openBefore':
+                        if (!this.equalContent) {
+                            this.$Modal.confirm({
+                                title: this.$L('温馨提示'),
+                                content: this.$L('是否放弃保存修改的内容?'),
+                                cancelText: this.$L('取消'),
+                                okText: this.$L('放弃保存'),
+                                onOk: () => {
+                                    this.handleSection('openConfirm', detail)
+                                }
+                            });
+                        } else {
+                            this.handleSection('openConfirm', detail)
+                        }
+                        break;
+
+                    case 'openConfirm':
+                        this.goForward({name: 'docs-edit', params: detail}, true);
+                        this.refreshSid();
+                        this.docDrawerShow = false;
+                        break;
                 }
             },
 
@@ -685,44 +729,20 @@
             handleClick(act) {
                 switch (act) {
                     case "back":
-                        if (this.bakContent == $A.jsonStringify(this.docContent) && this.hid == 0) {
-                            this.goBack({name:'docs'});
+                        if (this.equalContent) {
+                            this.goBackDirect();
                             return;
                         }
                         this.$Modal.confirm({
                             title: this.$L('温馨提示'),
                             content: this.$L('是否放弃修改的内容返回?'),
-                            loading: true,
                             cancelText: this.$L('放弃保存'),
                             onCancel: () => {
-                                this.goBack({name:'docs'});
+                                this.goBackDirect();
                             },
                             okText: this.$L('保存并返回'),
                             onOk: () => {
-                                this.bakContent = $A.jsonStringify(this.docContent);
-                                $A.apiAjax({
-                                    url: 'docs/section/save?id=' + this.getSid(),
-                                    method: 'post',
-                                    data: {
-                                        D: Object.assign(this.docDetail, {content: this.bakContent})
-                                    },
-                                    error: () => {
-                                        this.$Modal.remove();
-                                        alert(this.$L('网络繁忙,请稍后再试!'));
-                                    },
-                                    success: (res) => {
-                                        this.$Modal.remove();
-                                        this.goBack({name:'docs'});
-                                        setTimeout(() => {
-                                            if (res.ret === 1) {
-                                                this.$Message.success(res.msg);
-                                                this.historyNoDataText = '';
-                                            } else {
-                                                this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
-                                            }
-                                        }, 350);
-                                    }
-                                });
+                                this.handleClick('save');
                             }
                         });
                         break;
@@ -736,15 +756,20 @@
                                 D: Object.assign(this.docDetail, {content: this.bakContent})
                             },
                             error: () => {
+                                this.bakContent = '';
                                 alert(this.$L('网络繁忙,保存失败!'));
                             },
                             success: (res) => {
                                 if (res.ret === 1) {
                                     this.$Message.success(res.msg);
                                     this.historyNoDataText = '';
+                                    if (this.hid != 0) {
+                                        this.hid = 0;
+                                        this.goForward({name: 'docs-edit', params: {sid: this.getSid()}}, true);
+                                    }
                                 } else {
-                                    this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
                                     this.bakContent = '';
+                                    this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
                                 }
                             }
                         });

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 482 - 482
resources/assets/statics/public/js/grapheditor/js/EditorUi.js


+ 1 - 0
resources/lang/en/general.js

@@ -455,4 +455,5 @@ export default {
     "仅作者和文档成员可以阅读分享地址。": "Only authors and document members can read the Shared address.",
     "所有会员都可以阅读分享地址。": "All members can read the Shared address.",
     "所有人(含游客)都可以阅读分享地址。": "Everyone (including visitors) can read the Shared address.",
+    "是否放弃保存修改的内容?": "Do you want to abandon saving the modified content?",
 }