diff --git a/app/Http/Controllers/Api/DialogController.php b/app/Http/Controllers/Api/DialogController.php index 23654ff9..b08d199e 100755 --- a/app/Http/Controllers/Api/DialogController.php +++ b/app/Http/Controllers/Api/DialogController.php @@ -357,22 +357,26 @@ class DialogController extends AbstractController // if ($data['type'] == 'file') { $codeExt = ['txt']; - $fillExt = ['jpg', 'jpeg', 'png', 'gif']; + $officeExt = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']; + $localExt = ['jpg', 'jpeg', 'png', 'gif']; $msg = Base::json2array($dialogMsg->getRawOriginal('msg')); $filePath = public_path($msg['path']); if (in_array($msg['ext'], $codeExt) && $msg['size'] < 2 * 1024 * 1024) { - // 文本代码,限制2M内的文件 + // 文本预览,限制2M内的文件 $data['content'] = file_get_contents($filePath); $data['file_mode'] = 1; + } elseif (in_array($msg['ext'], $officeExt)) { + // office预览 + $data['file_mode'] = 2; } else { - // 支持预览 - if (in_array($msg['ext'], $fillExt)) { + // 其他预览 + if (in_array($msg['ext'], $localExt)) { $url = Base::fillUrl($msg['path']); } else { $url = 'http://' . env('APP_IPPR') . '.3/' . $msg['path']; } $data['url'] = base64_encode($url); - $data['file_mode'] = 2; + $data['file_mode'] = 3; } } // diff --git a/app/Http/Controllers/Api/FileController.php b/app/Http/Controllers/Api/FileController.php index b17920f9..8fb628de 100755 --- a/app/Http/Controllers/Api/FileController.php +++ b/app/Http/Controllers/Api/FileController.php @@ -9,10 +9,12 @@ use App\Models\FileContent; use App\Models\FileLink; use App\Models\FileUser; use App\Models\User; +use App\Models\WebSocketDialogMsg; use App\Module\Base; use App\Module\Ihttp; use Illuminate\Support\Facades\DB; use Request; +use Response; /** * @apiDefine file @@ -379,11 +381,11 @@ class FileController extends AbstractController * @apiName content * * @apiParam {Number|String} id - * - Number 文件ID(需要登录) - * - String 链接码(不需要登录,用于预览) + * - Number: 文件ID(需要登录) + * - String: 链接码(不需要登录,用于预览) * @apiParam {String} down 直接下载 * - no: 浏览(默认) - * - yes: 下载 + * - yes: 下载(office文件直接下载) * * @apiSuccess {Number} ret 返回状态码(1正确、0错误) * @apiSuccess {String} msg 返回信息(错误描述) diff --git a/app/Http/Controllers/Api/ProjectController.php b/app/Http/Controllers/Api/ProjectController.php index d9ab79fd..35a1f6a8 100755 --- a/app/Http/Controllers/Api/ProjectController.php +++ b/app/Http/Controllers/Api/ProjectController.php @@ -1083,6 +1083,60 @@ class ProjectController extends AbstractController return Base::retSuccess('success', $file); } + /** + * @api {get} api/project/task/filedetail 22. 获取任务文件详情 + * + * @apiDescription 需要token身份(限:项目、任务负责人) + * @apiVersion 1.0.0 + * @apiGroup project + * @apiName task__filedetail + * + * @apiParam {Number} file_id 文件ID + * + * @apiSuccess {Number} ret 返回状态码(1正确、0错误) + * @apiSuccess {String} msg 返回信息(错误描述) + * @apiSuccess {Object} data 返回数据 + */ + public function task__filedetail() + { + User::auth(); + // + $file_id = intval(Request::input('file_id')); + // + $file = ProjectTaskFile::find($file_id); + if (empty($file)) { + return Base::retError("文件不存在"); + } + $data = $file->toArray(); + $data['path'] = $file->getRawOriginal('path'); + // + ProjectTask::userTask($file->task_id, true, true); + // + $codeExt = ['txt']; + $officeExt = ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']; + $localExt = ['jpg', 'jpeg', 'png', 'gif']; + $filePath = public_path($data['path']); + if (in_array($data['ext'], $codeExt) && $data['size'] < 2 * 1024 * 1024) { + // 文本预览,限制2M内的文件 + $data['content'] = file_get_contents($filePath); + $data['file_mode'] = 1; + } elseif (in_array($data['ext'], $officeExt)) { + // office预览 + $data['file_mode'] = 2; + } else { + // 其他预览 + if (in_array($data['ext'], $localExt)) { + $url = Base::fillUrl($data['path']); + } else { + $url = 'http://' . env('APP_IPPR') . '.3/' . $data['path']; + } + $data['url'] = base64_encode($url); + $data['file_mode'] = 3; + } + // + return Base::retSuccess('success', $data); + } + /** * @api {get} api/project/task/filedown 22. 下载任务文件 * diff --git a/docker-compose.yml b/docker-compose.yml index 65afbb33..56fd6670 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -96,7 +96,7 @@ services: fileview: container_name: "dootask-fileview-${APP_ID}" - image: "kuaifan/fileview:4.1.0-SNAPSHOT-RC2" + image: "kuaifan/fileview:4.1.0-SNAPSHOT-RC3" environment: TZ: "Asia/Shanghai" KK_CONTEXT_PATH: "/fileview" diff --git a/public/js/ace/theme-dracula-dark.js b/public/js/ace/theme-dracula-dark.js index 878f4711..e74af9ee 100644 --- a/public/js/ace/theme-dracula-dark.js +++ b/public/js/ace/theme-dracula-dark.js @@ -1,4 +1,4 @@ -define("ace/theme/dracula-dark",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!0,t.cssClass="ace-dracula-dark",t.cssText=".ace-dracula-dark .ace_gutter {background: #232323;color: rgb(144,145,148)}.ace-dracula-dark .ace_print-margin {width: 1px;background: #44475a}.ace-dracula-dark {background-color: #232323;color: #f8f8f2}.ace-dracula-dark .ace_cursor {color: #f8f8f0}.ace-dracula-dark .ace_marker-layer .ace_selection {background: #44475a}.ace-dracula-dark.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px #232323;border-radius: 2px}.ace-dracula-dark .ace_marker-layer .ace_step {background: rgb(198, 219, 174)}.ace-dracula-dark .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid #a29709}.ace-dracula-dark .ace_marker-layer .ace_active-line {background: #44475a}.ace-dracula-dark .ace_gutter-active-line {background-color: #44475a}.ace-dracula-dark .ace_marker-layer .ace_selected-word {box-shadow: 0px 0px 0px 1px #a29709;border-radius: 3px;}.ace-dracula-dark .ace_fold {background-color: #50fa7b;border-color: #f8f8f2}.ace-dracula-dark .ace_keyword {color: #ff79c6}.ace-dracula-dark .ace_constant.ace_language {color: #bd93f9}.ace-dracula-dark .ace_constant.ace_numeric {color: #bd93f9}.ace-dracula-dark .ace_constant.ace_character {color: #bd93f9}.ace-dracula-dark .ace_constant.ace_character.ace_escape {color: #ff79c6}.ace-dracula-dark .ace_constant.ace_other {color: #bd93f9}.ace-dracula-dark .ace_support.ace_function {color: #8be9fd}.ace-dracula-dark .ace_support.ace_constant {color: #6be5fd}.ace-dracula-dark .ace_support.ace_class {font-style: italic;color: #66d9ef}.ace-dracula-dark .ace_support.ace_type {font-style: italic;color: #66d9ef}.ace-dracula-dark .ace_storage {color: #ff79c6}.ace-dracula-dark .ace_storage.ace_type {font-style: italic;color: #8be9fd}.ace-dracula-dark .ace_invalid {color: #F8F8F0;background-color: #ff79c6}.ace-dracula-dark .ace_invalid.ace_deprecated {color: #F8F8F0;background-color: #bd93f9}.ace-dracula-dark .ace_string {color: #f1fa8c}.ace-dracula-dark .ace_comment {color: #6272a4}.ace-dracula-dark .ace_variable {color: #50fa7b}.ace-dracula-dark .ace_variable.ace_parameter {font-style: italic;color: #ffb86c}.ace-dracula-dark .ace_entity.ace_other.ace_attribute-name {color: #50fa7b}.ace-dracula-dark .ace_entity.ace_name.ace_function {color: #50fa7b}.ace-dracula-dark .ace_entity.ace_name.ace_tag {color: #ff79c6}.ace-dracula-dark .ace_invisible {color: #626680;}.ace-dracula-dark .ace_indent-guide {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNgYGBgYHB3d/8PAAOIAdULw8qMAAAAAElFTkSuQmCC) right repeat-y}",t.$selectionColorConflict=!0;var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass,!1)}); (function() { +define("ace/theme/dracula-dark",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!0,t.cssClass="ace-dracula-dark",t.cssText=".ace-dracula-dark .ace_gutter {background: #000000;color: rgb(144,145,148)}.ace-dracula-dark .ace_print-margin {width: 1px;background: #44475a}.ace-dracula-dark {background-color: #000000;color: #f8f8f2}.ace-dracula-dark .ace_cursor {color: #f8f8f0}.ace-dracula-dark .ace_marker-layer .ace_selection {background: #44475a}.ace-dracula-dark.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px #000000;border-radius: 2px}.ace-dracula-dark .ace_marker-layer .ace_step {background: rgb(198, 219, 174)}.ace-dracula-dark .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid #a29709}.ace-dracula-dark .ace_marker-layer .ace_active-line {background: #44475a}.ace-dracula-dark .ace_gutter-active-line {background-color: #44475a}.ace-dracula-dark .ace_marker-layer .ace_selected-word {box-shadow: 0px 0px 0px 1px #a29709;border-radius: 3px;}.ace-dracula-dark .ace_fold {background-color: #50fa7b;border-color: #f8f8f2}.ace-dracula-dark .ace_keyword {color: #ff79c6}.ace-dracula-dark .ace_constant.ace_language {color: #bd93f9}.ace-dracula-dark .ace_constant.ace_numeric {color: #bd93f9}.ace-dracula-dark .ace_constant.ace_character {color: #bd93f9}.ace-dracula-dark .ace_constant.ace_character.ace_escape {color: #ff79c6}.ace-dracula-dark .ace_constant.ace_other {color: #bd93f9}.ace-dracula-dark .ace_support.ace_function {color: #8be9fd}.ace-dracula-dark .ace_support.ace_constant {color: #6be5fd}.ace-dracula-dark .ace_support.ace_class {font-style: italic;color: #66d9ef}.ace-dracula-dark .ace_support.ace_type {font-style: italic;color: #66d9ef}.ace-dracula-dark .ace_storage {color: #ff79c6}.ace-dracula-dark .ace_storage.ace_type {font-style: italic;color: #8be9fd}.ace-dracula-dark .ace_invalid {color: #F8F8F0;background-color: #ff79c6}.ace-dracula-dark .ace_invalid.ace_deprecated {color: #F8F8F0;background-color: #bd93f9}.ace-dracula-dark .ace_string {color: #f1fa8c}.ace-dracula-dark .ace_comment {color: #6272a4}.ace-dracula-dark .ace_variable {color: #50fa7b}.ace-dracula-dark .ace_variable.ace_parameter {font-style: italic;color: #ffb86c}.ace-dracula-dark .ace_entity.ace_other.ace_attribute-name {color: #50fa7b}.ace-dracula-dark .ace_entity.ace_name.ace_function {color: #50fa7b}.ace-dracula-dark .ace_entity.ace_name.ace_tag {color: #ff79c6}.ace-dracula-dark .ace_invisible {color: #626680;}.ace-dracula-dark .ace_indent-guide {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNgYGBgYHB3d/8PAAOIAdULw8qMAAAAAElFTkSuQmCC) right repeat-y}",t.$selectionColorConflict=!0;var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass,!1)}); (function() { window.require(["ace/theme/dracula-dark"], function(m) { if (typeof module == "object" && typeof exports == "object" && module) { module.exports = m; diff --git a/resources/assets/js/components/OnlyOffice.vue b/resources/assets/js/components/OnlyOffice.vue index 43e577e8..9c3b0cae 100644 --- a/resources/assets/js/components/OnlyOffice.vue +++ b/resources/assets/js/components/OnlyOffice.vue @@ -123,7 +123,7 @@ export default { case 'ppt': return 'pptx' } - return ''; + return type; }, loadFile() { @@ -144,11 +144,12 @@ export default { } // let fileKey = this.code || this.value.id; + let fileName = $A.strExists(this.fileName, '.') ? this.fileName : (this.fileName + '.' + this.fileType); const config = { "document": { "fileType": this.fileType, "key": this.fileType + '-' + fileKey, - "title": this.fileName + '.' + this.fileType, + "title": fileName, "url": 'http://nginx/api/file/content/?id=' + fileKey + '&token=' + this.userToken, }, "editorConfig": { @@ -164,6 +165,11 @@ export default { "callbackUrl": 'http://nginx/api/file/content/office?id=' + fileKey + '&token=' + this.userToken, } }; + if ($A.leftExists(fileKey, "msgFile_")) { + config.document.url = 'http://nginx/api/dialog/msg/download/?msg_id=' + $A.leftDelete(fileKey, "msgFile_") + '&token=' + this.userToken; + } else if ($A.leftExists(fileKey, "taskFile_")) { + config.document.url = 'http://nginx/api/project/task/filedown/?file_id=' + $A.leftDelete(fileKey, "taskFile_") + '&token=' + this.userToken; + } if (this.readOnly) { config.editorConfig.mode = "view"; config.editorConfig.callbackUrl = null; diff --git a/resources/assets/js/pages/manage/components/DialogView.vue b/resources/assets/js/pages/manage/components/DialogView.vue index c49969b6..10bbdc11 100644 --- a/resources/assets/js/pages/manage/components/DialogView.vue +++ b/resources/assets/js/pages/manage/components/DialogView.vue @@ -181,8 +181,8 @@ export default { this.$Electron.ipcRenderer.send('windowRouter', { title: `${this.msgData.msg.name} (${$A.bytesToSize(this.msgData.msg.size)})`, titleFixed: true, - name: 'msgview-' + this.msgData.id, - path: "/single/msgview/" + this.msgData.id, + name: 'file-msg-' + this.msgData.id, + path: "/single/file/msg/" + this.msgData.id, force: false, config: { parent: null, @@ -191,7 +191,7 @@ export default { } }); } else { - window.open($A.apiUrl(`../single/msgview/${this.msgData.id}`)) + window.open($A.apiUrl(`../single/file/msg/${this.msgData.id}`)) } }, diff --git a/resources/assets/js/pages/manage/components/ProjectList.vue b/resources/assets/js/pages/manage/components/ProjectList.vue index 549a12fd..d65aded6 100644 --- a/resources/assets/js/pages/manage/components/ProjectList.vue +++ b/resources/assets/js/pages/manage/components/ProjectList.vue @@ -35,7 +35,7 @@
{{$L('你确定要删除这个文件吗?')}}
-