diff --git a/app/Http/Controllers/Api/FileController.php b/app/Http/Controllers/Api/FileController.php index 9a3db007..b785ebd6 100755 --- a/app/Http/Controllers/Api/FileController.php +++ b/app/Http/Controllers/Api/FileController.php @@ -325,8 +325,8 @@ class FileController extends AbstractController // $file->size = $content->size; $file->save(); + $file->pushContentChange(); // - $content->content = $content->formatContent($file->type, $content->content); return Base::retSuccess('保存成功', $content); } diff --git a/app/Models/File.php b/app/Models/File.php index 881ce698..3122542f 100644 --- a/app/Models/File.php +++ b/app/Models/File.php @@ -3,7 +3,11 @@ namespace App\Models; use App\Exceptions\ApiException; +use App\Module\Base; +use App\Tasks\PushTask; +use Hhxsv5\LaravelS\Swoole\Task\Task; use Illuminate\Database\Eloquent\SoftDeletes; +use Request; /** * Class File @@ -155,6 +159,35 @@ class File extends AbstractModel return true; } + /** + * 推送内容发生变化消息 + */ + public function pushContentChange() + { + $userid = [$this->userid]; + if ($this->share == 1) { + $userid = array_merge($userid, WebSocket::wherePath('file/content/' . $this->id)->pluck('userid')->toArray()); + } elseif ($this->share == 2) { + $userid = array_merge($userid, FileUser::whereFileId($this->id)->pluck('userid')->toArray()); + } + // + $userid = array_values(array_filter(array_unique($userid))); + $params = [ + 'ignoreFd' => Request::header('fd'), + 'userid' => $userid, + 'msg' => [ + 'type' => 'fileContentChange', + 'data' => [ + 'id' => $this->id, + 'nickname' => User::nickname(), + 'time' => Base::time() + ], + ] + ]; + $task = new PushTask($params, false); + Task::deliver($task); + } + /** * 获取文件并检测权限 * @param $id diff --git a/app/Models/User.php b/app/Models/User.php index fd4fa565..b62287f0 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -265,6 +265,19 @@ class User extends AbstractModel return $user->userid; } + /** + * 获取我的昵称 + * @return string + */ + public static function nickname() + { + $user = self::authInfo(); + if (!$user) { + return ''; + } + return $user->nickname; + } + /** * 用户身份认证(获取用户信息) * @param null $identity 判断身份 diff --git a/resources/assets/js/components/UserAvatar.vue b/resources/assets/js/components/UserAvatar.vue index 8fdaf30e..e08781d0 100755 --- a/resources/assets/js/components/UserAvatar.vue +++ b/resources/assets/js/components/UserAvatar.vue @@ -12,14 +12,14 @@
-
+
{{nickname}}
-
{{user.nickname}}
+
{{user.nickname}}
@@ -37,6 +37,10 @@ type: [String, Number], default: 'default' }, + showIcon: { + type: Boolean, + default: true + }, showName: { type: Boolean, default: false @@ -90,6 +94,17 @@ } }, + nameStyle() { + const {showIcon} = this; + if (!showIcon) { + return { + paddingLeft: 0 + } + } else { + return {} + } + }, + avatarSize() { let {borderWitdh, size} = this if (size === 'default') size = 32; diff --git a/resources/assets/js/pages/manage/components/FileContent.vue b/resources/assets/js/pages/manage/components/FileContent.vue index bad140d0..5d0d86bd 100644 --- a/resources/assets/js/pages/manage/components/FileContent.vue +++ b/resources/assets/js/pages/manage/components/FileContent.vue @@ -123,6 +123,16 @@ export default { if (data.path == 'file/content/' + this.fileId) { this.editUser = data.userids; } + } else if (type == 'fileContentChange') { + if (this.parentShow && data.id == this.fileId) { + $A.modalConfirm({ + title: "更新提示", + content: '团队成员(' + data.nickname + ')更新了内容,
更新时间:' + $A.formatDate("Y-m-d H:i:s", data.time) + '。

点击【确定】加载最新内容。', + onOk: () => { + this.getContent(); + } + }); + } } }, deep: true, @@ -207,8 +217,6 @@ export default { }).then(({data, msg}) => { $A.messageSuccess(msg); this.loadIng--; - this.contentDetail = data.content; - this.updateBak(); this.$store.dispatch("saveFile", { id: this.fileId, size: data.size, diff --git a/resources/assets/js/pages/manage/file.vue b/resources/assets/js/pages/manage/file.vue index b755d967..e8b97649 100644 --- a/resources/assets/js/pages/manage/file.vue +++ b/resources/assets/js/pages/manage/file.vue @@ -80,7 +80,13 @@
- +
{ @@ -339,7 +378,7 @@ export default { { title: this.$L('类型'), key: 'type', - width: 120, + width: 110, resizable: true, sortable: true, render: (h, {row}) => { @@ -351,6 +390,23 @@ export default { } } }, + { + title: this.$L('所有者'), + key: 'userid', + width: 130, + resizable: true, + sortable: true, + render: (h, {row}) => { + return h('UserAvatar', { + props: { + size: 18, + userid: row.userid, + showIcon: false, + showName: true, + } + }); + } + }, { title: this.$L('最后修改'), key: 'updated_at', diff --git a/resources/assets/sass/pages/page-file.scss b/resources/assets/sass/pages/page-file.scss index e7d19914..96fef8a5 100644 --- a/resources/assets/sass/pages/page-file.scss +++ b/resources/assets/sass/pages/page-file.scss @@ -235,34 +235,46 @@ } } } - .file-name { + .file-nbox { display: flex; align-items: center; position: relative; - padding-right: 26px; - &:before { - flex-shrink: 0; - content: ""; - width: 18px; - height: 18px; - background-repeat: no-repeat; - background-size: contain; - margin-right: 8px; + .file-name { + flex: 1; + width: 0; + display: flex; + align-items: center; + position: relative; + margin-right: 46px; + &:before { + flex-shrink: 0; + content: ""; + width: 22px; + height: 22px; + background-repeat: no-repeat; + background-size: contain; + margin-right: 8px; + } + &.folder:before { + background-image: url("../images/file/folder.svg"); + } + &.document:before { + background-image: url("../images/file/document.svg"); + } + &.mind:before { + background-image: url("../images/file/mind.svg"); + } + &.sheet:before { + background-image: url("../images/file/sheet.svg"); + } + &.flow:before { + background-image: url("../images/file/flow.svg"); + } } - &.folder:before { - background-image: url("../images/file/folder.svg"); - } - &.document:before { - background-image: url("../images/file/document.svg"); - } - &.mind:before { - background-image: url("../images/file/mind.svg"); - } - &.sheet:before { - background-image: url("../images/file/sheet.svg"); - } - &.flow:before { - background-image: url("../images/file/flow.svg"); + .taskfont { + color: #aaaaaa; + font-size: 16px; + margin: 0 3px; } } } @@ -345,23 +357,31 @@ background-size: contain; margin-top: 12px; position: relative; - .taskfont { + .share-icon, + .share-avatar { position: absolute; - right: 10px; - bottom: -2px; - font-size: 18px; - color: #ffffff; + right: 0; + bottom: 0; + background-color: #9ACD7B; + width: 20px; + height: 20px; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + transform: scale(0.9); + .taskfont { + font-size: 18px; + color: #ffffff; + } } + } &.shear { opacity: 0.38; } &.folder .file-icon { background-image: url("../images/file/folder.svg"); - .taskfont { - right: 6px; - bottom: 2px; - } } &.document .file-icon { background-image: url("../images/file/document.svg"); diff --git a/resources/assets/sass/taskfont.scss b/resources/assets/sass/taskfont.scss index 6cbed74f..d49667ea 100644 --- a/resources/assets/sass/taskfont.scss +++ b/resources/assets/sass/taskfont.scss @@ -1,8 +1,8 @@ @font-face { font-family: 'taskfont'; /* Project id 2583385 */ - src: url('//at.alicdn.com/t/font_2583385_s6r5dbjuxi.woff2?t=1625128084843') format('woff2'), - url('//at.alicdn.com/t/font_2583385_s6r5dbjuxi.woff?t=1625128084843') format('woff'), - url('//at.alicdn.com/t/font_2583385_s6r5dbjuxi.ttf?t=1625128084843') format('truetype'); + src: url('//at.alicdn.com/t/font_2583385_vbi15jduv0n.woff2?t=1625644968453') format('woff2'), + url('//at.alicdn.com/t/font_2583385_vbi15jduv0n.woff?t=1625644968453') format('woff'), + url('//at.alicdn.com/t/font_2583385_vbi15jduv0n.ttf?t=1625644968453') format('truetype'); } .taskfont {