Skip to content

Commit

Permalink
整理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Feb 19, 2022
1 parent f4f351c commit 7a267cc
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 191 deletions.
12 changes: 4 additions & 8 deletions app/Http/Controllers/Api/DialogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public function lists()
{
$user = User::auth();
//
$list = WebSocketDialog::select(['web_socket_dialogs.*','u.top','u.top_at'])
$list = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at'])
->join('web_socket_dialog_users as u', 'web_socket_dialogs.id', '=', 'u.dialog_id')
->where('u.userid', $user->userid)
->orderByDesc('u.top')
->orderByDesc('u.top_at')
->orderByDesc('web_socket_dialogs.last_at')
->paginate(Base::getPaginate(200, 100));
$list->transform(function (WebSocketDialog $item) use ($user) {
Expand Down Expand Up @@ -481,7 +481,7 @@ public function msg__withdraw()
/**
* @api {get} api/dialog/top 12. 会话置顶
*
* @apiDescription 消息撤回限制24小时内,需要token身份
* @apiDescription 需要token身份
* @apiVersion 1.0.0
* @apiGroup dialog
* @apiName top
Expand All @@ -500,12 +500,8 @@ public function top()
if (!$dialogUser) {
return Base::retError("会话不存在");
}
$top = $dialogUser->top === 1 ? 0 : 1;
$topAt = $dialogUser->top === 1 ? null : Carbon::now();
$dialogUser->top = $top;
$dialogUser->top_at = $topAt;
$dialogUser->top_at = $dialogUser->top_at ? null : Carbon::now();
$dialogUser->save();
return Base::retSuccess("success", $dialogId);
}

}
20 changes: 0 additions & 20 deletions app/Http/Controllers/Api/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,7 @@ public function login()
$type = trim(Request::input('type'));
$email = trim(Request::input('email'));
$password = trim(Request::input('password'));
if(!$email){
return Base::retError('请输入邮箱地址');
}
if ($type == 'reg') {
$password2 = trim(Request::input('password2'));
//邮箱
if (!Base::isMail($email)) {
return Base::retError('请输入正确的邮箱地址');
}
if (User::email2userid($email) > 0) {
return Base::retError('邮箱地址已存在');
}
if (empty($password)) {
return Base::retError('请输入密码');
}
if ($password != $password2) {
return Base::retError('确认密码输入不一致');
}
$setting = Base::setting('system');
if ($setting['reg'] == 'close') {
return Base::retError('未开放注册');
Expand All @@ -81,9 +64,6 @@ public function login()
return Base::retError('请输入正确的验证码', ['code' => 'need']);
}
}
if (empty($password)) {
return Base::retError('请输入密码');
}
//
$retError = function ($msg) use ($email) {
Cache::forever("code::" . $email, "need");
Expand Down
7 changes: 7 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ public function checkSystem($onlyUserid = null)
*/
public static function reg($email, $password, $other = [])
{
//邮箱
if (!Base::isEmail($email)) {
throw new ApiException('请输入正确的邮箱地址');
}
if (User::email2userid($email) > 0) {
throw new ApiException('邮箱地址已存在');
}
//密码
self::passwordPolicy($password);
//开始注册
Expand Down
1 change: 0 additions & 1 deletion app/Models/WebSocketDialogUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @property int $id
* @property int|null $dialog_id 对话ID
* @property int|null $userid 会员ID
* @property int|null $top 是否置顶:0否,1是
* @property \Illuminate\Support\Carbon|null $top_at 置顶时间
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
Expand Down
2 changes: 1 addition & 1 deletion app/Module/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ public static function isMobile($str)
* @param string $str 需要检测的字符串
* @return int
*/
public static function isMail($str)
public static function isEmail($str)
{
$RegExp = '/^[a-z0-9][a-z\.0-9-_]+@[a-z0-9_-]+(?:\.[a-z]{0,3}\.[a-z]{0,2}|\.[a-z]{0,3}|\.[a-z]{0,2})$/i';
return preg_match($RegExp, $str);
Expand Down
55 changes: 0 additions & 55 deletions app/Tasks/BatchRemoveFileTask.php

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion resources/assets/js/components/ImgUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<div class="browse-load" v-if="isLoading">{{$L('加载中...')}}</div>
<div class="browse-list" :class="httpType==='input'?'browse-list-disabled':''" ref="browselistbox">
<div v-if="browseList.length <= 0">{{$L('无内容')}}</div>
<div class="browse-item" v-for="item in browseList" @click="browseItem(item)">
<div v-else class="browse-item" v-for="item in browseList" @click="browseItem(item)">
<Icon v-if="item.active" class="browse-icon" type="ios-checkmark-circle"></Icon>
<div class="browse-img" v-bind:style="{ 'background-image': 'url(' + item.thumb + ')' }"></div>
<div class="browse-title">{{item.title}}</div>
Expand Down
9 changes: 9 additions & 0 deletions resources/assets/js/functions/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,15 @@
return /^1([3456789])\d{9}$/.test(str);
},

/**
* 检测邮箱地址格式
* @param email
* @returns {boolean}
*/
isEmail(email) {
return /^[a-z0-9][a-z\.0-9-_]+@[a-z0-9_-]+(?:\.[a-z]{0,3}\.[a-z]{0,2}|\.[a-z]{0,3}|\.[a-z]{0,2})$/.test(email);
},

/**
* 根据两点间的经纬度计算距离
* @param lng1
Expand Down
17 changes: 15 additions & 2 deletions resources/assets/js/pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,27 @@ export default {
onLogin() {
this.chackServerUrl(true).then(() => {
if (!$A.isEmail(this.email)) {
$A.messageWarning("请输入正确的邮箱地址");
return;
}
if (!this.password) {
$A.messageWarning("请输入密码");
return;
}
if (this.loginType == 'reg') {
if (this.password != this.password2) {
$A.messageWarning("确认密码输入不一致");
return;
}
}
this.loadIng++;
this.$store.dispatch("call", {
url: 'users/login',
data: {
type: this.loginType,
email: this.email,
password: this.password,
password2: this.password2,
code: this.code,
invite: this.invite,
},
Expand All @@ -298,7 +311,7 @@ export default {
});
}).catch(({data, msg}) => {
this.loadIng--;
$A.modalError(this.$L(msg));
$A.modalError(msg);
if (data.code === 'need') {
this.reCode();
this.codeNeed = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const Drawio = () => import('../../../components/Drawio');
export default {
name: "FileContent",
components: {AceEditor, TEditor, MDEditor, OnlyOffice,Drawio},
components: {AceEditor, TEditor, MDEditor, OnlyOffice, Drawio},
props: {
value: {
type: Boolean,
Expand Down
Loading

0 comments on commit 7a267cc

Please sign in to comment.