diff --git a/app/admin/controller/Dashboard.php b/app/admin/controller/Dashboard.php index 6595603f..1aed8841 100644 --- a/app/admin/controller/Dashboard.php +++ b/app/admin/controller/Dashboard.php @@ -11,7 +11,7 @@ class Dashboard extends Backend parent::initialize(); } - public function dashboard() + public function index(): void { $this->success('', [ 'remark' => get_route_remark() diff --git a/database/migrations/20230905060702_version202.php b/database/migrations/20230905060702_version202.php new file mode 100644 index 00000000..16973681 --- /dev/null +++ b/database/migrations/20230905060702_version202.php @@ -0,0 +1,69 @@ +where('name', 'dashboard/dashboard') + ->lock(true) + ->value('id'); + if ($dashboardId) { + // 修改name + Db::name('admin_rule') + ->where('name', 'dashboard/dashboard') + ->update([ + 'name' => 'dashboard', + ]); + + // 增加一个查看的权限节点 + $dashboardIndexId = Db::name('admin_rule')->insertGetId([ + 'pid' => $dashboardId, + 'type' => 'button', + 'title' => '查看', + 'name' => 'dashboard/index', + 'update_time' => time(), + 'create_time' => time(), + ]); + + // 原本有控制台权限的管理员,给予新增的查看权限 + $group = Db::name('admin_group') + ->where('rules', 'find in set', $dashboardId) + ->select(); + foreach ($group as $item) { + + $newRules = trim($item['rules'], ','); + $newRules = $newRules . ',' . $dashboardIndexId; + + Db::name('admin_group') + ->where('id', $item['id']) + ->update([ + 'rules' => $newRules + ]); + } + } + + // 修改name + Db::name('admin_rule') + ->where('name', 'buildadmin/buildadmin') + ->update([ + 'name' => 'buildadmin', + ]); + + Db::commit(); + } catch (Throwable $e) { + Db::rollback(); + throw $e; + } + } +} diff --git a/web/src/api/backend/dashboard.ts b/web/src/api/backend/dashboard.ts index 0ff501a2..5caef9de 100644 --- a/web/src/api/backend/dashboard.ts +++ b/web/src/api/backend/dashboard.ts @@ -2,9 +2,9 @@ import createAxios from '/@/utils/axios' export const url = '/admin/Dashboard/' -export function dashboard() { +export function index() { return createAxios({ - url: url + 'dashboard', + url: url + 'index', method: 'get', }) } diff --git a/web/src/views/backend/dashboard.vue b/web/src/views/backend/dashboard.vue index 390bd13d..d50d1ea9 100644 --- a/web/src/views/backend/dashboard.vue +++ b/web/src/views/backend/dashboard.vue @@ -156,7 +156,7 @@ import { CountUp } from 'countup.js' import * as echarts from 'echarts' import { useNavTabs } from '/@/stores/navTabs' import { useTemplateRefsList } from '@vueuse/core' -import { dashboard } from '/@/api/backend/dashboard' +import { index } from '/@/api/backend/dashboard' import { useI18n } from 'vue-i18n' import { Local } from '/@/utils/storage' import { useAdminInfo } from '/@/stores/adminInfo' @@ -187,7 +187,7 @@ const state: { pauseWork: false, }) -dashboard().then((res) => { +index().then((res) => { state.remark = res.data.remark })