优化缓存数据
This commit is contained in:
parent
7cf76d91a0
commit
a5b1fec6b1
@ -379,7 +379,7 @@ class Project extends AbstractModel
|
||||
}
|
||||
$project = $builder->first();
|
||||
if (empty($project)) {
|
||||
throw new ApiException('项目不存在或不在成员列表内');
|
||||
throw new ApiException('项目不存在或不在成员列表内', [ 'project_id' => $project_id ], -4001);
|
||||
}
|
||||
return $project;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use App\Module\Base;
|
||||
use App\Tasks\PushTask;
|
||||
use Arr;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Hhxsv5\LaravelS\Swoole\Task\Task;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Request;
|
||||
@ -753,16 +754,20 @@ class ProjectTask extends AbstractModel
|
||||
}
|
||||
$task = $builder->first();
|
||||
if (empty($task)) {
|
||||
throw new ApiException('任务不存在');
|
||||
throw new ApiException('任务不存在', [ 'task_id' => $task_id ], -4002);
|
||||
}
|
||||
//
|
||||
if (ProjectTaskUser::whereUserid(User::userid())->whereTaskPid($task->id)->exists()) {
|
||||
$project = Project::find($task->project_id);
|
||||
if (empty($project)) {
|
||||
throw new ApiException('项目不存在或已被删除');
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$project = Project::userProject($task->project_id, $ignoreArchived);
|
||||
} catch (Exception $e) {
|
||||
if (ProjectTaskUser::whereUserid(User::userid())->whereTaskPid($task->id)->exists()) {
|
||||
$project = Project::find($task->project_id);
|
||||
if (empty($project)) {
|
||||
throw new ApiException('项目不存在或已被删除', [ 'task_id' => $task_id ], -4002);
|
||||
}
|
||||
} else {
|
||||
throw new ApiException($e->getMessage(), [ 'task_id' => $task_id ], -4002);
|
||||
}
|
||||
}
|
||||
//
|
||||
return $task;
|
||||
|
@ -65,14 +65,14 @@ class WebSocketDialog extends AbstractModel
|
||||
|
||||
/**
|
||||
* 获取对话(同时检验对话身份)
|
||||
* @param $id
|
||||
* @param $dialog_id
|
||||
* @return self
|
||||
*/
|
||||
public static function checkDialog($id)
|
||||
public static function checkDialog($dialog_id)
|
||||
{
|
||||
$dialog = WebSocketDialog::whereId($id)->first();
|
||||
$dialog = WebSocketDialog::find($dialog_id);
|
||||
if (empty($dialog)) {
|
||||
throw new ApiException('对话不存在或已被删除');
|
||||
throw new ApiException('对话不存在或已被删除', ['dialog_id' => $dialog_id], -4003);
|
||||
}
|
||||
//
|
||||
$userid = User::userid();
|
||||
|
@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div
|
||||
v-if="dialogData && dialogData.id"
|
||||
class="dialog-wrapper"
|
||||
@drop.prevent="chatPasteDrag($event, 'drag')"
|
||||
@dragover.prevent="chatDragOver(true, $event)"
|
||||
|
@ -69,15 +69,15 @@
|
||||
</div>
|
||||
|
||||
<div class="messenger-msg">
|
||||
<div class="msg-dialog-bg">
|
||||
<div class="msg-dialog-bg-icon"><Icon type="ios-chatbubbles" /></div>
|
||||
<div class="msg-dialog-bg-text">{{$L('选择一个会话开始聊天')}}</div>
|
||||
</div>
|
||||
<DialogWrapper v-if="dialogId > 0" :dialogId="dialogId" @on-active="scrollIntoActive">
|
||||
<div slot="inputBefore" class="dialog-back" @click="closeDialog">
|
||||
<Icon type="md-arrow-back" />
|
||||
</div>
|
||||
</DialogWrapper>
|
||||
<div v-else class="dialog-no">
|
||||
<div class="dialog-no-icon"><Icon type="ios-chatbubbles" /></div>
|
||||
<div class="dialog-no-text">{{$L('选择一个会话开始聊天')}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
26
resources/assets/js/store/actions.js
vendored
26
resources/assets/js/store/actions.js
vendored
@ -61,6 +61,14 @@ export default {
|
||||
resolve({data, msg});
|
||||
} else {
|
||||
reject({data, msg: msg || "Unknown error"})
|
||||
//
|
||||
if (ret === -4001) {
|
||||
dispatch("forgetProject", data.project_id);
|
||||
} else if (ret === -4002) {
|
||||
dispatch("forgetTask", data.task_id);
|
||||
} else if (ret === -4003) {
|
||||
dispatch("forgetDialog", data.dialog_id);
|
||||
}
|
||||
}
|
||||
};
|
||||
params.error = () => {
|
||||
@ -1287,6 +1295,24 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 忘记对话数据
|
||||
* @param state
|
||||
* @param dialog_id
|
||||
*/
|
||||
forgetDialog({state}, dialog_id) {
|
||||
let index = state.dialogs.findIndex(({id}) => id == dialog_id);
|
||||
if (index > -1) {
|
||||
state.dialogs.splice(index, 1);
|
||||
}
|
||||
if (dialog_id == state.method.getStorageInt("messenger::dialogId")) {
|
||||
state.method.setStorage("messenger::dialogId", 0)
|
||||
}
|
||||
setTimeout(() => {
|
||||
state.method.setStorage("cacheDialogs", state.cacheDialogs = state.dialogs);
|
||||
})
|
||||
},
|
||||
|
||||
/** *****************************************************************************************/
|
||||
/** ************************************** 消息 **********************************************/
|
||||
/** *****************************************************************************************/
|
||||
|
12
resources/assets/sass/pages/page-messenger.scss
vendored
12
resources/assets/sass/pages/page-messenger.scss
vendored
@ -269,13 +269,19 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
.dialog-no {
|
||||
.msg-dialog-bg {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 0;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.dialog-no-icon {
|
||||
.msg-dialog-bg-icon {
|
||||
background-color: #f4f5f7;
|
||||
padding: 20px;
|
||||
border-radius: 50%;
|
||||
@ -284,7 +290,7 @@
|
||||
font-size: 46px;
|
||||
}
|
||||
}
|
||||
.dialog-no-text {
|
||||
.msg-dialog-bg-text {
|
||||
margin-top: 16px;
|
||||
color: #bec6cc;
|
||||
background-color: #f4f5f7;
|
||||
|
Loading…
x
Reference in New Issue
Block a user