mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-13 01:28:11 +00:00
perf: 文件右键菜单直接发送至会话
This commit is contained in:
parent
93996d7378
commit
8bbc1e8e4e
@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Models\AbstractModel;
|
||||
use App\Models\File;
|
||||
use App\Models\FileContent;
|
||||
use App\Models\FileLink;
|
||||
use App\Models\ProjectTask;
|
||||
use App\Models\ProjectTaskFile;
|
||||
use App\Models\User;
|
||||
@ -781,6 +783,77 @@ class DialogController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/msg/sendfileid 15. 通过文件ID发送文件
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup dialog
|
||||
* @apiName msg__sendfileid
|
||||
*
|
||||
* @apiParam {Number} file_id 消息ID
|
||||
* @apiParam {Array} dialogids 转发给的对话ID
|
||||
* @apiParam {Array} userids 转发给的成员ID
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function msg__sendfileid()
|
||||
{
|
||||
$user = User::auth();
|
||||
//
|
||||
$file_id = intval(Request::input("file_id"));
|
||||
$dialogids = Request::input('dialogids');
|
||||
$userids = Request::input('userids');
|
||||
//
|
||||
if (empty($dialogids) && empty($userids)) {
|
||||
return Base::retError("请选择转发对话或成员");
|
||||
}
|
||||
//
|
||||
$file = File::permissionFind($file_id);
|
||||
$fileLink = $file->getShareLink($user->userid);
|
||||
$fileMsg = "<a class=\"mention file\" href=\"{{RemoteURL}}single/file/{$fileLink['code']}\" target=\"_blank\">~{$file->getNameAndExt()}</a>";
|
||||
//
|
||||
$sender = $user->userid;
|
||||
return AbstractModel::transaction(function() use ($sender, $fileMsg, $userids, $dialogids) {
|
||||
$msgs = [];
|
||||
$already = [];
|
||||
if ($dialogids) {
|
||||
if (!is_array($dialogids)) {
|
||||
$dialogids = [$dialogids];
|
||||
}
|
||||
foreach ($dialogids as $dialogid) {
|
||||
$res = WebSocketDialogMsg::sendMsg(null, $dialogid, 'text', ['text' => $fileMsg], $sender);
|
||||
if (Base::isSuccess($res)) {
|
||||
$msgs[] = $res['data'];
|
||||
$already[] = $dialogid;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($userids) {
|
||||
if (!is_array($userids)) {
|
||||
$userids = [$userids];
|
||||
}
|
||||
foreach ($userids as $userid) {
|
||||
if (!User::whereUserid($userid)->exists()) {
|
||||
continue;
|
||||
}
|
||||
$dialog = WebSocketDialog::checkUserDialog($sender, $userid);
|
||||
if ($dialog && !in_array($dialog->id, $already)) {
|
||||
$res = WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $fileMsg], $sender);
|
||||
if (Base::isSuccess($res)) {
|
||||
$msgs[] = $res['data'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Base::retSuccess('发送成功', [
|
||||
'msgs' => $msgs
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/msg/readlist 16. 获取消息阅读情况
|
||||
*
|
||||
|
||||
@ -185,6 +185,7 @@
|
||||
|
||||
<DropdownItem v-if="contextMenuItem.userid == userId" name="share" divided>{{$L('共享')}}</DropdownItem>
|
||||
<DropdownItem v-else-if="contextMenuItem.share" name="outshare" divided>{{$L('退出共享')}}</DropdownItem>
|
||||
<DropdownItem name="send" :disabled="contextMenuItem.type == 'folder'">{{$L('发送')}}</DropdownItem>
|
||||
<DropdownItem name="link" :divided="contextMenuItem.userid != userId && !contextMenuItem.share" :disabled="contextMenuItem.type == 'folder'">{{$L('链接')}}</DropdownItem>
|
||||
<DropdownItem name="download" :disabled="contextMenuItem.ext == ''">{{$L('下载')}}</DropdownItem>
|
||||
|
||||
@ -314,6 +315,18 @@
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
<!-- 文件发送 -->
|
||||
<Modal
|
||||
v-model="sendShow"
|
||||
:title="$L('发送文件')"
|
||||
:mask-closable="false">
|
||||
<DialogSelect v-model="sendData"/>
|
||||
<div slot="footer" class="adaption">
|
||||
<Button type="default" @click="sendShow=false">{{$L('取消')}}</Button>
|
||||
<Button type="primary" :loading="sendLoad" @click="onSendFile">{{$L('发送文件')}}</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
<!--文件链接-->
|
||||
<Modal
|
||||
v-model="linkShow"
|
||||
@ -381,12 +394,13 @@ import UserInput from "../../components/UserInput";
|
||||
import DrawerOverlay from "../../components/DrawerOverlay";
|
||||
import PreviewImage from "../../components/PreviewImage";
|
||||
import longpress from "../../directives/longpress";
|
||||
import DialogSelect from "./components/DialogSelect";
|
||||
|
||||
const FilePreview = () => import('./components/FilePreview');
|
||||
const FileContent = () => import('./components/FileContent');
|
||||
|
||||
export default {
|
||||
components: {PreviewImage, FilePreview, DrawerOverlay, UserInput, FileContent},
|
||||
components: {DialogSelect, PreviewImage, FilePreview, DrawerOverlay, UserInput, FileContent},
|
||||
directives: {longpress},
|
||||
data() {
|
||||
return {
|
||||
@ -453,6 +467,13 @@ export default {
|
||||
shareList: [],
|
||||
shareLoad: 0,
|
||||
|
||||
sendShow: false,
|
||||
sendLoad: false,
|
||||
sendData: {
|
||||
dialogids: [],
|
||||
userids: [],
|
||||
},
|
||||
|
||||
linkShow: false,
|
||||
linkData: {},
|
||||
linkLoad: 0,
|
||||
@ -1142,6 +1163,15 @@ export default {
|
||||
this.shearIds = $A.cloneJSON(this.selectIds);
|
||||
break;
|
||||
|
||||
case 'send':
|
||||
this.sendData = {
|
||||
dialogids: [],
|
||||
userids: [],
|
||||
file_id: item.id
|
||||
};
|
||||
this.sendShow = true;
|
||||
break;
|
||||
|
||||
case 'share':
|
||||
this.shareInfo = {
|
||||
id: item.id,
|
||||
@ -1204,6 +1234,27 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
onSendFile() {
|
||||
if ($A.arrayLength(this.sendData.dialogids) === 0 && $A.arrayLength(this.sendData.userids) === 0) {
|
||||
$A.messageWarning("请选择转发对话或成员");
|
||||
return
|
||||
}
|
||||
this.sendLoad = true;
|
||||
this.$store.dispatch("call", {
|
||||
url: 'dialog/msg/sendfileid',
|
||||
data: this.sendData
|
||||
}).then(({data, msg}) => {
|
||||
this.sendShow = false;
|
||||
this.$store.dispatch("saveDialogMsg", data.msgs);
|
||||
this.$store.dispatch("updateDialogLastMsg", data.msgs);
|
||||
$A.messageSuccess(msg);
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg);
|
||||
}).finally(_ => {
|
||||
this.sendLoad = false;
|
||||
});
|
||||
},
|
||||
|
||||
linkGet(refresh) {
|
||||
this.linkLoad++;
|
||||
this.$store.dispatch("call", {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user