diff --git a/app/command/admin/Worker.php b/app/command/admin/Worker.php index 5bf4dae..3acd799 100644 --- a/app/command/admin/Worker.php +++ b/app/command/admin/Worker.php @@ -68,8 +68,9 @@ class Worker extends Command // 绑定成功通知 $connection->send(json_encode(['event'=>'BIND_USER_SUCCESS','userId'=>$auth->userId])); $client = SysUserClient::where([ - 'client_id' => $connection->clientId, - 'client_name'=> $connection->clientName + 'client_id' => $clientId, + 'client_name'=> $clientName, + 'user_id' => $connection->userId, ])->find(); if($client && $client['is_lock']) { // 锁定屏幕 @@ -82,7 +83,8 @@ class Worker extends Command var_dump("锁定客户端/通知全部ws触发锁定操作"); SysUserClient::where([ 'client_id' => $connection->clientId, - 'client_name'=> $connection->clientName + 'client_name'=> $connection->clientName, + 'user_id' => $connection->userId, ])->update(['is_lock'=>1,'lock_password'=>$lock_password,'lock_time'=>date('Y-m-d H:i:s')]); // 锁定屏幕 $connection->send(json_encode(['event'=>'LOCK_CLIENT_SCREEN'])); diff --git a/app/controller/admin/auth/AuthController.php b/app/controller/admin/auth/AuthController.php index 68914be..5f04391 100644 --- a/app/controller/admin/auth/AuthController.php +++ b/app/controller/admin/auth/AuthController.php @@ -4,6 +4,7 @@ namespace app\controller\admin\auth; use app\BaseController; use app\entity\SysUser; +use app\entity\SysUserClient; use app\enum\UserLoginEnum; use app\service\admin\LoginService; use think\db\exception\DataNotFoundException; @@ -41,4 +42,24 @@ class AuthController extends BaseController $srv->logout($this->request, $this->auth->getUser()); return $this->writeSuccess('退出成功'); } + + public function unlock() + { + $client = $this->request->getClient(); + $lock_password = $this->request->post('lock_password'); + $clientModel = SysUserClient::where([ + 'client_id' => $client->id, + 'client_name'=> $client->name, + 'user_id' => $this->auth->userId, + ])->find(); + if($clientModel) { + if($clientModel['lock_password'] !== $lock_password) { + return $this->writeSuccess('密码错误'); + } + $clientModel->save(['is_lock'=>0,'lock_password'=>'','lock_time'=>null]); + } + + + return $this->writeSuccess('解锁成功'); + } } diff --git a/route/api.php b/route/api.php index 92173c0..3890a09 100644 --- a/route/api.php +++ b/route/api.php @@ -55,6 +55,7 @@ Route::group("adminapi", function () { Route::group("auth", function () { Route::post("logout", [auth\AuthController::class, "logout"])->name("admin.SysUserLogout"); Route::get("user", [auth\AuthController::class, "user"])->name("admin.SysUserInfo"); + Route::post("unlock", [auth\AuthController::class, "unlock"])->name("admin.SysClientUnlock"); }); diff --git a/z_ele/src/components/LockScreenState/index.vue b/z_ele/src/components/LockScreenState/index.vue index 2c6e7cb..3948492 100644 --- a/z_ele/src/components/LockScreenState/index.vue +++ b/z_ele/src/components/LockScreenState/index.vue @@ -1,6 +1,6 @@ @@ -21,9 +36,9 @@ import { WsEvent, wsEventManager } from '@/plugins/websocket'; const visible = ref(false); - + const lockPassword = ref(''); + const confirmUnlock = () => {}; wsEventManager.subscribe(WsEvent.LOCK_CLIENT_SCREEN, () => { - console.log("LOCK_CLIENT_SCREEN->") visible.value = true; });