diff --git a/app/Http/Controllers/Api/FileController.php b/app/Http/Controllers/Api/FileController.php index 755616b4f..1670e4035 100755 --- a/app/Http/Controllers/Api/FileController.php +++ b/app/Http/Controllers/Api/FileController.php @@ -439,6 +439,7 @@ class FileController extends AbstractController * @apiParam {String} down 直接下载 * - no: 浏览(默认) * - yes: 下载(office文件直接下载) + * @apiParam {Number} [history_id] 读取历史记录ID * * @apiSuccess {Number} ret 返回状态码(1正确、0错误) * @apiSuccess {String} msg 返回信息(错误描述) @@ -449,6 +450,7 @@ class FileController extends AbstractController $id = Request::input('id'); $down = Request::input('down', 'no'); $only_update_at = Request::input('only_update_at', 'no'); + $history_id = intval(Request::input('history_id')); // if (Base::isNumber($id)) { User::auth(); @@ -470,7 +472,11 @@ class FileController extends AbstractController ]); } // - $content = FileContent::whereFid($file->id)->orderByDesc('id')->first(); + $builder = FileContent::whereFid($file->id); + if ($history_id > 0) { + $builder->whereId($history_id); + } + $content = $builder->orderByDesc('id')->first(); return FileContent::formatContent($file, $content?->content, $down == 'yes'); } @@ -767,6 +773,36 @@ class FileController extends AbstractController }); } + /** + * @api {get} api/file/content/history 08. 获取内容历史 + * + * @apiDescription 需要token身份 + * @apiVersion 1.0.0 + * @apiGroup file + * @apiName content__history + * + * @apiParam {Number} id 文件ID + * + * @apiParam {Number} [page] 当前页,默认:1 + * @apiParam {Number} [pagesize] 每页显示数量,默认:20,最大:100 + * + * @apiSuccess {Number} ret 返回状态码(1正确、0错误) + * @apiSuccess {String} msg 返回信息(错误描述) + * @apiSuccess {Object} data 返回数据 + */ + public function content__history() + { + $id = Request::input('id'); + // + $file = File::permissionFind(intval($id)); + // + $data = FileContent::select(['id', 'size', 'userid', 'created_at']) + ->whereFid($file->id) + ->orderByDesc('id') + ->paginate(Base::getPaginate(100, 20)); + return Base::retSuccess('success', $data); + } + /** * @api {get} api/file/share 12. 获取共享信息 * diff --git a/resources/assets/js/pages/manage/components/FileContent.vue b/resources/assets/js/pages/manage/components/FileContent.vue index a239c42c8..de4b533a3 100644 --- a/resources/assets/js/pages/manage/components/FileContent.vue +++ b/resources/assets/js/pages/manage/components/FileContent.vue @@ -43,7 +43,22 @@ {{$L('导出PDF文件')}} - +
+ + + +
+ +
{{$L('可通过此链接浏览文件。')}}
+
+
+ + +
+

{{$L('注意:刷新将导致原来的链接失效!')}}

+
+ +
+
+
@@ -64,6 +104,7 @@ import Vue from 'vue' import Minder from '../../../components/Minder' import {mapState} from "vuex"; +import FileHistory from "./FileHistory"; Vue.use(Minder) const MDEditor = () => import('../../../components/MDEditor/index'); @@ -74,7 +115,7 @@ const Drawio = () => import('../../../components/Drawio'); export default { name: "FileContent", - components: {AceEditor, TEditor, MDEditor, OnlyOffice, Drawio}, + components: {FileHistory, AceEditor, TEditor, MDEditor, OnlyOffice, Drawio}, props: { value: { type: Boolean, @@ -103,6 +144,12 @@ export default { editUser: [], loadPreview: true, + + linkShow: false, + linkData: {}, + linkLoad: 0, + + historyShow: false, } }, @@ -114,7 +161,7 @@ export default { window.__onBeforeUnload = () => { if (!this.equalContent) { $A.modalConfirm({ - content: '修改的内容尚未保存,真的要放弃修改吗?', + content: '修改的内容尚未保存,确定要放弃修改吗?', cancelText: '取消', okText: '放弃', onOk: () => { @@ -139,6 +186,9 @@ export default { this.ready = true; this.editUser = [this.userId]; this.getContent(); + } else { + this.linkShow = false; + this.historyShow = false; } }, immediate: true, @@ -224,7 +274,7 @@ export default { } }, - getContent() { + getContent(history_id = 0) { if (this.fileId === 0) { this.contentDetail = {}; this.updateBak(); @@ -241,10 +291,13 @@ export default { url: 'file/content', data: { id: this.fileId, + history_id: history_id }, }).then(({data}) => { this.contentDetail = data.content; - this.updateBak(); + if (!history_id) { + this.updateBak(); + } }).catch(({msg}) => { $A.modalError(msg); }).finally(_ => { @@ -259,13 +312,21 @@ export default { handleClick(act) { switch (act) { + case "link": + this.linkData = { + id: this.fileId + }; + this.linkShow = true; + this.linkGet() + break; + case "saveBefore": if (!this.equalContent && this.loadSave == 0) { this.handleClick('save'); } else { $A.messageWarning('没有任何修改!'); } - return; + break; case "save": if (this.file.only_view) { @@ -296,6 +357,58 @@ export default { } }, + handleHistory(item) { + this.historyShow = false; + if (!this.equalContent) { + $A.modalConfirm({ + content: '修改的内容尚未保存,确定要读取历史记录吗?', + cancelText: '取消', + okText: '确定', + onOk: () => { + this.getContent(item.id) + } + }); + } else { + this.getContent(item.id) + } + }, + + linkGet(refresh) { + this.linkLoad++; + this.$store.dispatch("call", { + url: 'file/link', + data: { + id: this.linkData.id, + refresh: refresh === true ? 'yes' : 'no' + }, + }).then(({data}) => { + this.linkData = Object.assign(data, { + id: this.linkData.id + }); + this.linkCopy(); + }).catch(({msg}) => { + this.linkShow = false + $A.modalError(msg); + }).finally(_ => { + this.linkLoad--; + }); + }, + + linkCopy() { + if (!this.linkData.url) { + return; + } + this.$copyText(this.linkData.url).then(() => { + $A.messageSuccess(this.$L('复制成功!')); + }, () => { + $A.messageError(this.$L('复制失败!')); + }); + }, + + linkFocus() { + this.$refs.linkInput.focus({cursor:'all'}); + }, + exportMenu(act) { switch (this.file.type) { case 'mind': diff --git a/resources/assets/js/pages/manage/components/FileHistory.vue b/resources/assets/js/pages/manage/components/FileHistory.vue new file mode 100644 index 000000000..9594026b1 --- /dev/null +++ b/resources/assets/js/pages/manage/components/FileHistory.vue @@ -0,0 +1,169 @@ + + + + diff --git a/resources/assets/js/pages/manage/file.vue b/resources/assets/js/pages/manage/file.vue index da6784948..02abc0f6b 100644 --- a/resources/assets/js/pages/manage/file.vue +++ b/resources/assets/js/pages/manage/file.vue @@ -1529,7 +1529,7 @@ export default { return } $A.modalConfirm({ - content: '文件尚未保存,是否放弃修改?', + content: '修改的内容尚未保存,确定要放弃修改吗?', cancelText: '取消', okText: '放弃', onOk: () => { diff --git a/resources/assets/sass/pages/components/file-content.scss b/resources/assets/sass/pages/components/file-content.scss index 04fa746ae..ef10b8de6 100644 --- a/resources/assets/sass/pages/components/file-content.scss +++ b/resources/assets/sass/pages/components/file-content.scss @@ -92,6 +92,25 @@ font-size: 12px !important; } } + .header-icons { + margin-left: -4px; + margin-right: 16px; + display: flex; + align-items: center; + justify-content: center; + .header-icon { + display: flex; + align-items: center; + justify-content: center; + width: 44px; + height: 100%; + color: #777777; + > i { + font-size: 20px; + } + } + } + .header-button { font-size: 12px; margin-right: 24px;