Skip to content

Commit

Permalink
优化了一些代码
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Jan 28, 2022
1 parent 02eb386 commit 21e618c
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 178 deletions.
2 changes: 2 additions & 0 deletions app/Http/Controllers/Api/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ public function content__upload()
'asp', 'properties', 'gitignore', 'log', 'bas', 'prg', 'python', 'ftl', 'aspx' => "code",
'mp3', 'wav', 'mp4', 'flv',
'avi', 'mov', 'wmv', 'mkv', '3gp', 'rm' => "media",
'xmind' => "xmind",
'rp' => "axure",
default => "",
};
$file = File::createInstance([
Expand Down
71 changes: 2 additions & 69 deletions app/Http/Controllers/Api/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1328,72 +1328,6 @@ public function task__update()
return Base::retSuccess('修改成功', $data);
}

/**
* @api {post} api/project/task/upload 27. 上传文件
*
* @apiDescription 需要token身份(限:项目、任务负责人)
* @apiVersion 1.0.0
* @apiGroup project
* @apiName task__upload
*
* @apiParam {Number} task_id 任务ID
* @apiParam {String} [filename] post-文件名称
* @apiParam {String} [image64] post-base64图片(二选一)
* @apiParam {File} [files] post-文件对象(二选一)
*
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function task__upload()
{
$user = User::auth();
//
$task_id = Base::getPostInt('task_id');
//
$task = ProjectTask::userTask($task_id, true, true);
//
$path = "uploads/task/" . $task->id . "/";
$image64 = Base::getPostValue('image64');
$fileName = Base::getPostValue('filename');
if ($image64) {
$data = Base::image64save([
"image64" => $image64,
"path" => $path,
"fileName" => $fileName,
]);
} else {
$data = Base::upload([
"file" => Request::file('files'),
"type" => 'file',
"path" => $path,
"fileName" => $fileName,
]);
}
//
if (Base::isError($data)) {
return Base::retError($data['msg']);
} else {
$fileData = $data['data'];
$file = ProjectTaskFile::createInstance([
'project_id' => $task->project_id,
'task_id' => $task->id,
'name' => $fileData['name'],
'size' => $fileData['size'] * 1024,
'ext' => $fileData['ext'],
'path' => $fileData['path'],
'thumb' => Base::unFillUrl($fileData['thumb']),
'userid' => $user->userid,
]);
$file->save();
//
$file = ProjectTaskFile::find($file->id);
$task->addLog("上传文件:" . $file->name);
$task->pushMsg('upload', $file);
return Base::retSuccess("上传成功", $file);
}
}

/**
* @api {get} api/project/task/dialog 28. 创建/获取聊天室
*
Expand Down Expand Up @@ -1653,7 +1587,7 @@ public function task__flow()
/**
* @api {get} api/project/flow/list 33. 工作流列表
*
* @apiDescription 需要token身份(限:项目负责人)
* @apiDescription 需要token身份
* @apiVersion 1.0.0
* @apiGroup project
* @apiName flow__list
Expand All @@ -1669,9 +1603,8 @@ public function flow__list()
User::auth();
//
$project_id = intval(Request::input('project_id'));
$is_filter = intval(Request::input('is_filter',0));
//
$project = Project::userProject($project_id, true, true, $is_filter);
$project = Project::userProject($project_id, true);
//
$list = ProjectFlow::with(['ProjectFlowItem'])->whereProjectId($project->id)->get();
return Base::retSuccess('success', $list);
Expand Down
9 changes: 4 additions & 5 deletions app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,10 @@ public function pushMsg($action, $data = null, $userid = null)
* 获取项目信息(用于判断会员是否存在项目内)
* @param int $project_id
* @param null|bool $archived true:仅限未归档, false:仅限已归档, null:不限制
* @param null $mustOwner true:仅限项目负责人, false:仅限非项目负责人, null:不限制
* @param int $is_filter 是否是用筛选列表
* @param null|bool $mustOwner true:仅限项目负责人, false:仅限非项目负责人, null:不限制
* @return self
*/
public static function userProject($project_id, $archived = true, $mustOwner = null, $is_filter = 0)
public static function userProject($project_id, $archived = true, $mustOwner = null)
{
$project = self::authData()->where('projects.id', intval($project_id))->first();
if (empty($project)) {
Expand All @@ -370,10 +369,10 @@ public static function userProject($project_id, $archived = true, $mustOwner = n
if ($archived === false && $project->archived_at == null) {
throw new ApiException('项目未归档', [ 'project_id' => $project_id ]);
}
if ($mustOwner === true && !$project->owner && $is_filter === 0) {
if ($mustOwner === true && !$project->owner) {
throw new ApiException('仅限项目负责人操作', [ 'project_id' => $project_id ]);
}
if ($mustOwner === false && $project->owner && $is_filter === 0) {
if ($mustOwner === false && $project->owner) {
throw new ApiException('禁止项目负责人操作', [ 'project_id' => $project_id ]);
}
return $project;
Expand Down
3 changes: 0 additions & 3 deletions app/Models/WebSocketDialogMsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ class WebSocketDialogMsg extends AbstractModel
'updated_at',
];

const MSG_TYPE_TEXT = "text";
const MSG_TYPE_FILE = "file";

/**
* 阅读占比
* @return int|mixed
Expand Down
3 changes: 2 additions & 1 deletion app/Module/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2263,7 +2263,8 @@ public static function upload($param)
'asp', 'properties', 'gitignore', 'log', 'bas', 'prg', 'python', 'ftl', 'aspx',
'mp3', 'wav', 'mp4', 'flv',
'avi', 'mov', 'wmv', 'mkv', '3gp', 'rm',
'xmind', 'rp',
'xmind',
'rp',
];
break;
default:
Expand Down
18 changes: 4 additions & 14 deletions resources/assets/js/pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,8 @@
<Input v-if="$Electron && cacheServerUrl" :value="$A.getDomain(cacheServerUrl)" prefix="ios-globe-outline" size="large" readonly clearable @on-clear="clearServerUrl"/>

<Input v-model="email" prefix="ios-mail-outline" :placeholder="$L('输入您的电子邮件')" size="large" @on-enter="onLogin" @on-blur="onBlur" />
<Input v-if="loginType=='login'"
v-model="password" prefix="ios-lock-outline" :placeholder="$L('输入您的密码')" type="password"
size="large"
@on-enter="onLogin" />
<Poptip v-else :content="$L('密码必须包含数字,字母大小写或者特殊字符的组合,长度在6~32位之间')" :transfer="true">
<Input v-model="password" prefix="ios-lock-outline" :placeholder="$L('输入您的密码')" type="password"
size="large"
@on-enter="onLogin" />
</Poptip>

<Input v-model="password" prefix="ios-lock-outline" :placeholder="$L('输入您的密码')" type="password" size="large" @on-enter="onLogin" />

<Input v-if="loginType=='reg'" v-model="password2" prefix="ios-lock-outline" :placeholder="$L('输入确认密码')" type="password" size="large" @on-enter="onLogin" />
<Input v-if="loginType=='reg' && needInvite" v-model="invite" class="login-code" :placeholder="$L('请输入注册邀请码')" type="text" size="large" @on-enter="onLogin"><span slot="prepend">&nbsp;{{$L('邀请码')}}&nbsp;</span></Input>
Expand Down Expand Up @@ -252,7 +245,7 @@ export default {
}
if (this.loginType == 'reg') {
if (this.password != this.password2) {
$A.noticeError("确认密码输入不一致");
$A.messageWarning("确认密码输入不一致");
return;
}
}
Expand All @@ -276,10 +269,7 @@ export default {
});
}).catch(({data, msg}) => {
this.loadIng--;
$A.noticeError({
desc: msg,
duration: 10
});
$A.modalError(msg);
if (data.code === 'need') {
this.reCode();
this.codeNeed = true;
Expand Down
7 changes: 6 additions & 1 deletion resources/assets/js/pages/manage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,12 @@ export default {
}, 5000)
},
workReportShow(show) {
if (show) {
this.getReportUnread(0);
}
},
unreadTotal: {
handler(num) {
if (this.$Electron) {
Expand Down Expand Up @@ -550,7 +556,6 @@ export default {
if (this.reportUnreadNumber > 0) {
this.reportTabs = "receive";
}
this.getReportUnread(0);
this.workReportShow = true;
return;
case 'clearCache':
Expand Down
17 changes: 10 additions & 7 deletions resources/assets/js/pages/manage/components/DialogWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@
<li v-if="dialogData.hasMorePages" class="history" @click="loadNextPage">{{$L('加载历史消息')}}</li>
<li v-else-if="dialogData.loading > 0 && dialogMsgList.length === 0" class="loading"><Loading/></li>
<li v-else-if="dialogMsgList.length === 0" class="nothing">{{$L('暂无消息')}}</li>
<DialogList
<li
v-for="item in dialogMsgList"
:dialogMsg="item"
:topId="topId"
:id="'view_' + item.id"
:key="item.id"
:dialogData="dialogData"
/>
:class="{self:item.userid == userId, 'history-tip': topId == item.id}">
<em v-if="topId == item.id" class="history-text">{{$L('历史消息')}}</em>
<div class="dialog-avatar">
<UserAvatar :userid="item.userid" :tooltipDisabled="item.userid == userId" :size="30"/>
</div>
<DialogView :msg-data="item" :dialog-type="dialogData.type"/>
</li>
<li
v-for="item in tempMsgList"
:id="'tmp_' + item.id"
Expand Down Expand Up @@ -108,12 +112,11 @@ import ScrollerY from "../../../components/ScrollerY";
import {mapState} from "vuex";
import DialogView from "./DialogView";
import DialogUpload from "./DialogUpload";
import DialogList from "./DialogList";
import {Store} from "le5le-store";
export default {
name: "DialogWrapper",
components: {DialogList, DialogUpload, DialogView, ScrollerY, DragInput},
components: {DialogUpload, DialogView, ScrollerY, DragInput},
props: {
dialogId: {
type: Number,
Expand Down
Loading

0 comments on commit 21e618c

Please sign in to comment.