Переглянути джерело

去掉文档预览的js引用

zmw 8 місяців тому
батько
коміт
5b826be96e

+ 6 - 0
app/common/controller/Api.php

@@ -1260,6 +1260,12 @@ class Api extends BaseController {
         return view("", ["id" => $talentInfo["id"], "type" => $type]);
     }
 
+    public function filePreview(){
+        $url = $this->request["url"];
+        $title = $this->request["title"];
+        return view("", ["url" => $url, "title" => $title]);
+    }
+
     public function getEnterpriseData() {
         
     }

+ 38 - 0
app/common/view/api/file_preview.html

@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
+    <title>文件预览</title>
+    <script src="https://office.jinjianghc.com/web-apps/apps/api/documents/api.js"></script>
+</head>
+<body id="preview">
+
+</body>
+<script>
+    let title = '{$title}',url = '{$url}';
+    const index = title.lastIndexOf('.');
+    const fileType = title.substr(index + 1);
+    const config = {
+        "document": {
+            "permissions": {
+                comment: false,
+                fillForms: false,
+                "edit": false,
+            },
+            "fileType": fileType,
+            "title": title,
+            "url": url,
+            // "key": this.md5,
+            "lang": "zh-CN"
+        },
+        "width": '100%',
+        "editorConfig": {
+            mode: 'view',
+            "lang": "zh-CN"
+        }
+    };
+    document.title = title;
+    const docEditor = new window.DocsAPI.DocEditor("preview", config);
+</script>
+</html>

+ 18 - 23
public/static/js/common/Feng.js

@@ -566,29 +566,24 @@ var Feng = {
         // layer.full(index);
     },
     showExcel: function (url, id, title) {
-        const index = title.lastIndexOf('.');
-        const fileType = title.substr(index + 1);
-        const config = {
-            "document": {
-                "permissions": {
-                    comment: false,
-                    fillForms: false,
-                    "edit": false,
-                },
-                "fileType": fileType,
-                "title": title,
-                "url": url,
-                // "key": this.md5,
-                "lang": "zh-CN"
-            },
-            "width": '100%',
-            "editorConfig": {
-                mode: 'view',
-                "lang": "zh-CN"
-            }
-        };
-        document.title = title;
-        const docEditor = new window.DocsAPI.DocEditor("placeholder", config);
+        if (Feng.isEmptyStr(id)) {
+            id = "id";
+        }
+        if (Feng.isEmptyStr(title)) {
+            title = "预览";
+        }
+        let origin = window.location.origin;
+        //let full_url = "https://fileview.jinjianghc.com/onlinePreview?url=" + encodeURIComponent(Base64.encode(url));
+        var index = layer.open({
+            id: id,
+            type: 2,
+            shade: 0,
+            title: title,
+            area: ['80%', '80%'], //宽高
+            fix: false, //不固定
+            maxmin: true,
+            content: Feng.ctxPath + "/common/api/filePreview?url=" + url + "&title=" + title,
+        });
         //window.location.href = url;
     },
     showFile: function (url, id, title) {