From 351c27c4206536491e2e8e57dcff567f0a56d541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=99=E7=A0=81=E7=94=9F=E8=8A=B1?= <18523774412@qq.com> Date: Sat, 12 Mar 2022 23:24:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E8=B5=84=E6=96=99store?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Dashboard.php | 3 +- app/admin/lang/en.php | 2 ++ app/admin/lang/zh-cn.php | 2 ++ app/admin/library/Auth.php | 2 +- .../layouts/backend/components/navMenus.vue | 30 ++++++++++++++----- web/src/stores/adminInfo.ts | 19 ++++++++++++ web/src/stores/constant/cacheKey.ts | 1 - web/src/stores/interface/index.ts | 9 ++++++ web/src/utils/common.ts | 17 ++--------- web/src/views/backend/dashboard.vue | 7 ++--- web/src/views/backend/login.vue | 14 +++++---- web/src/views/backend/routine/adminInfo.vue | 7 ++++- 12 files changed, 77 insertions(+), 36 deletions(-) create mode 100644 web/src/stores/adminInfo.ts diff --git a/app/admin/controller/Dashboard.php b/app/admin/controller/Dashboard.php index 3965360e..b099e75d 100644 --- a/app/admin/controller/Dashboard.php +++ b/app/admin/controller/Dashboard.php @@ -10,8 +10,7 @@ class Dashboard extends Backend public function dashboard() { $this->success('', [ - 'adminName' => $this->auth->nickname, - 'remark' => get_route_remark() + 'remark' => get_route_remark() ]); } } \ No newline at end of file diff --git a/app/admin/lang/en.php b/app/admin/lang/en.php index 72fa291c..9f4f43f8 100644 --- a/app/admin/lang/en.php +++ b/app/admin/lang/en.php @@ -1,5 +1,7 @@ 'Please login first', + 'You have no permission' => 'You have no permission', 'Username' => 'User Name', 'Password' => 'Password', 'Nickname' => 'Nickname', diff --git a/app/admin/lang/zh-cn.php b/app/admin/lang/zh-cn.php index 8accb706..cd99efa3 100644 --- a/app/admin/lang/zh-cn.php +++ b/app/admin/lang/zh-cn.php @@ -1,5 +1,7 @@ '请先登录!', + 'You have no permission' => '没有权限操作!', 'Username' => '用户名', 'Password' => '密码', 'Nickname' => '昵称', diff --git a/app/admin/library/Auth.php b/app/admin/library/Auth.php index 54bd20b0..f54943c4 100644 --- a/app/admin/library/Auth.php +++ b/app/admin/library/Auth.php @@ -37,7 +37,7 @@ class Auth extends \ba\Auth /** * @var string[] 允许输出的字段 */ - protected $allowFields = ['id', 'username', 'nickname', 'avatar']; + protected $allowFields = ['id', 'username', 'nickname', 'avatar', 'lastlogintime']; public function __construct() { diff --git a/web/src/layouts/backend/components/navMenus.vue b/web/src/layouts/backend/components/navMenus.vue index b4a34491..a42ad275 100644 --- a/web/src/layouts/backend/components/navMenus.vue +++ b/web/src/layouts/backend/components/navMenus.vue @@ -41,24 +41,24 @@
- +
-
Admin
-
2022-01-23 18:52
+
{{ adminInfo.nickname }}
+
{{ adminInfo.lastlogintime }}
@@ -77,9 +77,16 @@ import { useConfig } from '/@/stores/config' import { ElMessage } from 'element-plus' import { useI18n } from 'vue-i18n' import Config from './config.vue' +import { useAdminInfo } from '/@/stores/adminInfo' +import { Local } from '/@/utils/storage' +import { ADMIN_INFO } from '/@/stores/constant/cacheKey' +import router from '/@/router' +import { routePush } from '/@/utils/common' +import { RouteRecordRaw } from 'vue-router' const { t } = useI18n() +const adminInfo = useAdminInfo() const configStore = useConfig() const state = reactive({ @@ -105,6 +112,15 @@ const onFullScreen = () => { state.isFullScreen = screenfull.isFullscreen }) } + +const onAdminInfo = () => { + routePush({ name: 'routine/adminInfo' } as RouteRecordRaw) +} + +const onLogout = () => { + Local.remove(ADMIN_INFO) + router.go(0) +}