优化更新

This commit is contained in:
2026-02-09 22:51:11 +08:00
parent 9939680942
commit adf7457502
12 changed files with 695 additions and 298 deletions

View File

@@ -79,12 +79,11 @@ class Permission extends Controller
public function store(Request $request)
{
$validated = $request->validate([
'name' => 'required|string|max:50',
'code' => 'required|string|max:100|unique:auth_permissions,code',
'title' => 'required|string|max:50',
'name' => 'required|string|max:100|unique:auth_permissions,name',
'type' => 'required|in:menu,api,button',
'route' => 'nullable|string|max:200',
'component' => 'nullable|string|max:200',
'icon' => 'nullable|string|max:50',
'parent_id' => 'nullable|integer|exists:auth_permissions,id',
'sort' => 'nullable|integer|min:0',
'status' => 'nullable|integer|in:0,1',
@@ -106,12 +105,11 @@ class Permission extends Controller
public function update(Request $request, $id)
{
$validated = $request->validate([
'name' => 'nullable|string|max:50',
'code' => 'nullable|string|max:100|unique:auth_permissions,code,' . $id,
'title' => 'nullable|string|max:50',
'name' => 'nullable|string|max:100|unique:auth_permissions,name,' . $id,
'type' => 'nullable|in:menu,api,button',
'route' => 'nullable|string|max:200',
'component' => 'nullable|string|max:200',
'icon' => 'nullable|string|max:50',
'parent_id' => 'nullable|integer|exists:auth_permissions,id',
'sort' => 'nullable|integer|min:0',
'status' => 'nullable|integer|in:0,1',

View File

@@ -13,11 +13,11 @@ class Permission extends Model
protected $table = 'auth_permissions';
protected $fillable = [
'title',
'name',
'code',
'type',
'parent_id',
'route',
'path',
'component',
'meta',
'sort',

View File

@@ -71,7 +71,7 @@ class User extends Authenticatable implements JWTSubject
{
foreach ($this->roles as $role) {
foreach ($role->permissions as $permission) {
if ($permission->code === $permissionCode) {
if ($permission->name === $permissionCode) {
return true;
}
}

View File

@@ -203,8 +203,9 @@ class AuthService
foreach ($permissions as $permission) {
if ($permission->parent_id == $parentId) {
$node = [
'path' => $permission->route,
'name' => $permission->code,
'path' => $permission->path,
'name' => $permission->name,
'title' => $permission->title,
'meta' => $permission->meta ? json_decode($permission->meta, true) : [],
];
@@ -238,8 +239,8 @@ class AuthService
$permissions = [];
foreach ($user->roles as $role) {
foreach ($role->permissions as $permission) {
if (!in_array($permission->code, $permissions)) {
$permissions[] = $permission->code;
if (!in_array($permission->name, $permissions)) {
$permissions[] = $permission->name;
}
}
}

View File

@@ -30,10 +30,10 @@ class PermissionCacheService
foreach ($role->permissions as $permission) {
$permissions[$permission->id] = [
'id' => $permission->id,
'title' => $permission->title,
'name' => $permission->name,
'code' => $permission->code,
'type' => $permission->type,
'route' => $permission->route,
'path' => $permission->path,
];
}
}
@@ -51,7 +51,7 @@ class PermissionCacheService
return Cache::remember($cacheKey, now()->addMinutes($this->cacheMinutes), function() use ($userId) {
$permissions = $this->getUserPermissions($userId);
return array_column($permissions, 'code');
return array_column($permissions, 'name');
});
}
@@ -112,8 +112,8 @@ class PermissionCacheService
return $role->permissions->map(function($permission) {
return [
'id' => $permission->id,
'title' => $permission->title,
'name' => $permission->name,
'code' => $permission->code,
'type' => $permission->type,
];
})->toArray();
@@ -195,10 +195,10 @@ class PermissionCacheService
if ($permission['parent_id'] == $parentId) {
$node = [
'id' => $permission['id'],
'title' => $permission['title'],
'name' => $permission['name'],
'code' => $permission['code'],
'type' => $permission['type'],
'route' => $permission['route'],
'path' => $permission['path'],
'component' => $permission['component'],
'meta' => json_decode($permission['meta'] ?? '{}', true),
'sort' => $permission['sort'],

View File

@@ -18,8 +18,8 @@ class PermissionService
// 搜索条件
if (!empty($params['keyword'])) {
$query->where(function ($q) use ($params) {
$q->where('name', 'like', '%' . $params['keyword'] . '%')
->orWhere('code', 'like', '%' . $params['keyword'] . '%');
$q->where('title', 'like', '%' . $params['keyword'] . '%')
->orWhere('name', 'like', '%' . $params['keyword'] . '%');
});
}
@@ -109,15 +109,15 @@ class PermissionService
return [
'id' => $permission->id,
'title' => $permission->title,
'name' => $permission->name,
'code' => $permission->code,
'type' => $permission->type,
'parent_id' => $permission->parent_id,
'parent' => $permission->parent ? [
'id' => $permission->parent->id,
'name' => $permission->parent->name,
] : null,
'route' => $permission->route,
'path' => $permission->path,
'component' => $permission->component,
'meta' => $permission->meta,
'sort' => $permission->sort,
@@ -132,17 +132,17 @@ class PermissionService
*/
public function create(array $data): Permission
{
// 检查权限名称是否已存在
if (Permission::where('name', $data['name'])->exists()) {
// 检查权限标题是否已存在
if (isset($data['title']) && Permission::where('title', $data['title'])->exists()) {
throw ValidationException::withMessages([
'name' => ['权限名称已存在'],
'title' => ['权限标题已存在'],
]);
}
// 检查权限编码是否已存在
if (Permission::where('code', $data['code'])->exists()) {
if (Permission::where('name', $data['name'])->exists()) {
throw ValidationException::withMessages([
'code' => ['权限编码已存在'],
'name' => ['权限编码已存在'],
]);
}
@@ -157,11 +157,11 @@ class PermissionService
}
return Permission::create([
'title' => $data['title'],
'name' => $data['name'],
'code' => $data['code'],
'type' => $data['type'] ?? 'api',
'type' => $data['type'] ?? 'menu',
'parent_id' => $data['parent_id'] ?? 0,
'route' => $data['route'] ?? null,
'path' => $data['path'] ?? null,
'component' => $data['component'] ?? null,
'meta' => $data['meta'] ?? null,
'sort' => $data['sort'] ?? 0,
@@ -182,20 +182,20 @@ class PermissionService
]);
}
// 检查权限名称是否已被其他权限使用
if (isset($data['name']) && $data['name'] !== $permission->name) {
if (Permission::where('name', $data['name'])->exists()) {
// 检查权限标题是否已被其他权限使用
if (isset($data['title']) && $data['title'] !== $permission->title) {
if (Permission::where('title', $data['title'])->exists()) {
throw ValidationException::withMessages([
'name' => ['权限名称已存在'],
'title' => ['权限标题已存在'],
]);
}
}
// 检查权限编码是否已被其他权限使用
if (isset($data['code']) && $data['code'] !== $permission->code) {
if (Permission::where('code', $data['code'])->exists()) {
if (isset($data['name']) && $data['name'] !== $permission->name) {
if (Permission::where('name', $data['name'])->exists()) {
throw ValidationException::withMessages([
'code' => ['权限编码已存在'],
'name' => ['权限编码已存在'],
]);
}
}
@@ -218,11 +218,11 @@ class PermissionService
}
$updateData = [
'title' => $data['title'] ?? $permission->title,
'name' => $data['name'] ?? $permission->name,
'code' => $data['code'] ?? $permission->code,
'type' => $data['type'] ?? $permission->type,
'parent_id' => $data['parent_id'] ?? $permission->parent_id,
'route' => $data['route'] ?? $permission->route,
'path' => $data['path'] ?? $permission->path,
'component' => $data['component'] ?? $permission->component,
'meta' => isset($data['meta']) ? $data['meta'] : $permission->meta,
'sort' => $data['sort'] ?? $permission->sort,
@@ -305,10 +305,10 @@ class PermissionService
if ($permission->parent_id == $parentId) {
$node = [
'id' => $permission->id,
'title' => $permission->title,
'name' => $permission->name,
'code' => $permission->code,
'type' => $permission->type,
'route' => $permission->route,
'path' => $permission->path,
'component' => $permission->component,
'meta' => $permission->meta,
'sort' => $permission->sort,

View File

@@ -32,7 +32,7 @@ return [
|
*/
'listen_port' => env('LARAVELS_LISTEN_PORT', 8000),
'listen_port' => env('LARAVELS_LISTEN_PORT', 8080),
/*
|--------------------------------------------------------------------------

View File

@@ -64,11 +64,11 @@ return new class extends Migration
// 权限表
Schema::create('auth_permissions', function (Blueprint $table) {
$table->id();
$table->string('name', 100)->unique()->comment('权限名称');
$table->string('code', 100)->unique()->comment('权限编码');
$table->string('type', 20)->default('api')->comment('类型api 菜单 按钮');
$table->string('title', 100)->comment('权限标题');
$table->string('name', 100)->unique()->comment('权限编码');
$table->string('type', 20)->default('menu')->comment('类型api button menu url');
$table->unsignedBigInteger('parent_id')->default(0)->comment('父级ID');
$table->string('route')->nullable()->comment('路由');
$table->string('path')->nullable()->comment('路由路径');
$table->string('component')->nullable()->comment('前端组件路径');
$table->json('meta')->nullable()->comment('元数据(隐藏菜单、面包屑等)');
$table->integer('sort')->default(0)->comment('排序');
@@ -79,6 +79,7 @@ return new class extends Migration
$table->index('parent_id');
$table->index('type');
$table->index('status');
$table->index('name');
});
// 用户角色关联表

View File

@@ -55,31 +55,48 @@ class AuthSeeder extends Seeder
private function createPermissions(): void
{
$permissions = [
// 系统管理
// 首页顶级菜单
[
'name' => '系统管理',
'code' => 'system',
'title' => '首页',
'name' => 'home',
'type' => 'menu',
'parent_id' => 0,
'route' => '/system',
'component' => 'Layout',
'path' => '/home',
'component' => null,
'meta' => json_encode([
'icon' => 'Setting',
'icon' => 'Dashboard',
'hidden' => false,
'hiddenBreadcrumb' => false,
'affix' => null,
'affix' => true,
]),
'sort' => 1,
'status' => 1,
],
// 用户管理
// 仪表盘
[
'name' => '用户管理',
'code' => 'system.users',
'title' => '仪表盘',
'name' => 'home.dashboard',
'type' => 'menu',
'parent_id' => 0,
'route' => '/system/users',
'component' => 'system/users/index',
'parent_id' => 0, // 稍后更新为首页菜单的ID
'path' => '/dashboard',
'component' => 'home/index',
'meta' => json_encode([
'icon' => 'DataLine',
'hidden' => false,
'hiddenBreadcrumb' => false,
'affix' => true,
]),
'sort' => 1,
'status' => 1,
],
// 个人中心
[
'title' => '个人中心',
'name' => 'home.profile',
'type' => 'menu',
'parent_id' => 0, // 稍后更新为首页菜单的ID
'path' => '/ucenter',
'component' => 'ucenter/index',
'meta' => json_encode([
'icon' => 'User',
'hidden' => false,
@@ -89,77 +106,143 @@ class AuthSeeder extends Seeder
'status' => 1,
],
[
'name' => '查看用户',
'code' => 'system.users.view',
'title' => '查看个人信息',
'name' => 'home.profile.view',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.users.index',
'parent_id' => 0, // 稍后更新为个人中心菜单的ID
'path' => null,
'component' => null,
'meta' => null,
'sort' => 1,
'status' => 1,
],
[
'name' => '创建用户',
'code' => 'system.users.create',
'title' => '编辑个人信息',
'name' => 'home.profile.update',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.users.store',
'parent_id' => 0, // 稍后更新为个人中心菜单的ID
'path' => null,
'component' => null,
'meta' => null,
'sort' => 2,
'status' => 1,
],
[
'name' => '编辑用户',
'code' => 'system.users.update',
'title' => '修改密码',
'name' => 'home.profile.change-password',
'type' => 'button',
'parent_id' => 0, // 稍后更新为个人中心菜单的ID
'path' => null,
'component' => null,
'meta' => null,
'sort' => 3,
'status' => 1,
],
// 权限顶级菜单
[
'title' => '权限',
'name' => 'auth',
'type' => 'menu',
'parent_id' => 0,
'route' => 'admin.users.update',
'path' => '/auth',
'component' => null,
'meta' => json_encode([
'icon' => 'User',
'hidden' => false,
'hiddenBreadcrumb' => false,
]),
'sort' => 2,
'status' => 1,
],
// 用户管理
[
'title' => '用户管理',
'name' => 'auth.users',
'type' => 'menu',
'parent_id' => 0, // 稍后更新为权限菜单的ID
'path' => '/auth/users',
'component' => 'auth/users/index',
'meta' => json_encode([
'icon' => 'UserOutlined',
'hidden' => false,
'hiddenBreadcrumb' => false,
]),
'sort' => 1,
'status' => 1,
],
[
'title' => '查看用户',
'name' => 'auth.users.view',
'type' => 'button',
'parent_id' => 0, // 稍后更新为用户管理菜单的ID
'path' => 'admin.users.index',
'component' => null,
'meta' => null,
'sort' => 1,
'status' => 1,
],
[
'title' => '创建用户',
'name' => 'auth.users.create',
'type' => 'button',
'parent_id' => 0, // 稍后更新为用户管理菜单的ID
'path' => 'admin.users.store',
'component' => null,
'meta' => null,
'sort' => 2,
'status' => 1,
],
[
'title' => '编辑用户',
'name' => 'auth.users.update',
'type' => 'button',
'parent_id' => 0, // 稍后更新为用户管理菜单的ID
'path' => 'admin.users.update',
'component' => null,
'meta' => null,
'sort' => 3,
'status' => 1,
],
[
'name' => '删除用户',
'code' => 'system.users.delete',
'title' => '删除用户',
'name' => 'auth.users.delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.users.destroy',
'parent_id' => 0, // 稍后更新为用户管理菜单的ID
'path' => 'admin.users.destroy',
'component' => null,
'meta' => null,
'sort' => 4,
'status' => 1,
],
[
'name' => '批量删除用户',
'code' => 'system.users.batch-delete',
'title' => '批量删除用户',
'name' => 'auth.users.batch-delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.users.batch-delete',
'parent_id' => 0, // 稍后更新为用户管理菜单的ID
'path' => 'admin.users.batch-delete',
'component' => null,
'meta' => null,
'sort' => 5,
'status' => 1,
],
[
'name' => '导出用户',
'code' => 'system.users.export',
'title' => '导出用户',
'name' => 'auth.users.export',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.users.export',
'parent_id' => 0, // 稍后更新为用户管理菜单的ID
'path' => 'admin.users.export',
'component' => null,
'meta' => null,
'sort' => 6,
'status' => 1,
],
[
'name' => '导入用户',
'code' => 'system.users.import',
'title' => '导入用户',
'name' => 'auth.users.import',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.users.import',
'parent_id' => 0, // 稍后更新为用户管理菜单的ID
'path' => 'admin.users.import',
'component' => null,
'meta' => null,
'sort' => 7,
@@ -167,81 +250,81 @@ class AuthSeeder extends Seeder
],
// 角色管理
[
'name' => '角色管理',
'code' => 'system.roles',
'title' => '角色管理',
'name' => 'auth.roles',
'type' => 'menu',
'parent_id' => 0,
'route' => '/system/roles',
'component' => 'system/roles/index',
'parent_id' => 0, // 稍后更新为权限菜单的ID
'path' => '/auth/roles',
'component' => 'auth/roles/index',
'meta' => json_encode([
'icon' => 'UserFilled',
'hidden' => false,
'hiddenBreadcrumb' => false,
]),
'sort' => 3,
'sort' => 2,
'status' => 1,
],
[
'name' => '查看角色',
'code' => 'system.roles.view',
'title' => '查看角色',
'name' => 'auth.roles.view',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.roles.index',
'parent_id' => 0, // 稍后更新为角色管理菜单的ID
'path' => 'admin.roles.index',
'component' => null,
'meta' => null,
'sort' => 1,
'status' => 1,
],
[
'name' => '创建角色',
'code' => 'system.roles.create',
'title' => '创建角色',
'name' => 'auth.roles.create',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.roles.store',
'parent_id' => 0, // 稍后更新为角色管理菜单的ID
'path' => 'admin.roles.store',
'component' => null,
'meta' => null,
'sort' => 2,
'status' => 1,
],
[
'name' => '编辑角色',
'code' => 'system.roles.update',
'title' => '编辑角色',
'name' => 'auth.roles.update',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.roles.update',
'parent_id' => 0, // 稍后更新为角色管理菜单的ID
'path' => 'admin.roles.update',
'component' => null,
'meta' => null,
'sort' => 3,
'status' => 1,
],
[
'name' => '删除角色',
'code' => 'system.roles.delete',
'title' => '删除角色',
'name' => 'auth.roles.delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.roles.destroy',
'parent_id' => 0, // 稍后更新为角色管理菜单的ID
'path' => 'admin.roles.destroy',
'component' => null,
'meta' => null,
'sort' => 4,
'status' => 1,
],
[
'name' => '批量删除角色',
'code' => 'system.roles.batch-delete',
'title' => '批量删除角色',
'name' => 'auth.roles.batch-delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.roles.batch-delete',
'parent_id' => 0, // 稍后更新为角色管理菜单的ID
'path' => 'admin.roles.batch-delete',
'component' => null,
'meta' => null,
'sort' => 5,
'status' => 1,
],
[
'name' => '分配权限',
'code' => 'system.roles.assign-permissions',
'title' => '分配权限',
'name' => 'auth.roles.assign-permissions',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.roles.assign-permissions',
'parent_id' => 0, // 稍后更新为角色管理菜单的ID
'path' => 'admin.roles.assign-permissions',
'component' => null,
'meta' => null,
'sort' => 6,
@@ -249,70 +332,70 @@ class AuthSeeder extends Seeder
],
// 权限管理
[
'name' => '权限管理',
'code' => 'system.permissions',
'title' => '权限管理',
'name' => 'auth.permissions',
'type' => 'menu',
'parent_id' => 0,
'route' => '/system/permissions',
'component' => 'system/permissions/index',
'parent_id' => 0, // 稍后更新为权限菜单的ID
'path' => '/auth/permissions',
'component' => 'auth/permissions/index',
'meta' => json_encode([
'icon' => 'Lock',
'hidden' => false,
'hiddenBreadcrumb' => false,
]),
'sort' => 4,
'sort' => 3,
'status' => 1,
],
[
'name' => '查看权限',
'code' => 'system.permissions.view',
'title' => '查看权限',
'name' => 'auth.permissions.view',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.permissions.index',
'parent_id' => 0, // 稍后更新为权限管理菜单的ID
'path' => 'admin.permissions.index',
'component' => null,
'meta' => null,
'sort' => 1,
'status' => 1,
],
[
'name' => '创建权限',
'code' => 'system.permissions.create',
'title' => '创建权限',
'name' => 'auth.permissions.create',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.permissions.store',
'parent_id' => 0, // 稍后更新为权限管理菜单的ID
'path' => 'admin.permissions.store',
'component' => null,
'meta' => null,
'sort' => 2,
'status' => 1,
],
[
'name' => '编辑权限',
'code' => 'system.permissions.update',
'title' => '编辑权限',
'name' => 'auth.permissions.update',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.permissions.update',
'parent_id' => 0, // 稍后更新为权限管理菜单的ID
'path' => 'admin.permissions.update',
'component' => null,
'meta' => null,
'sort' => 3,
'status' => 1,
],
[
'name' => '删除权限',
'code' => 'system.permissions.delete',
'title' => '删除权限',
'name' => 'auth.permissions.delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.permissions.destroy',
'parent_id' => 0, // 稍后更新为权限管理菜单的ID
'path' => 'admin.permissions.destroy',
'component' => null,
'meta' => null,
'sort' => 4,
'status' => 1,
],
[
'name' => '批量删除权限',
'code' => 'system.permissions.batch-delete',
'title' => '批量删除权限',
'name' => 'auth.permissions.batch-delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.permissions.batch-delete',
'parent_id' => 0, // 稍后更新为权限管理菜单的ID
'path' => 'admin.permissions.batch-delete',
'component' => null,
'meta' => null,
'sort' => 5,
@@ -320,70 +403,70 @@ class AuthSeeder extends Seeder
],
// 部门管理
[
'name' => '部门管理',
'code' => 'system.departments',
'title' => '部门管理',
'name' => 'auth.departments',
'type' => 'menu',
'parent_id' => 0,
'route' => '/system/departments',
'component' => 'system/departments/index',
'parent_id' => 0, // 稍后更新为权限菜单的ID
'path' => '/auth/departments',
'component' => 'auth/departments/index',
'meta' => json_encode([
'icon' => 'OfficeBuilding',
'hidden' => false,
'hiddenBreadcrumb' => false,
]),
'sort' => 5,
'sort' => 4,
'status' => 1,
],
[
'name' => '查看部门',
'code' => 'system.departments.view',
'title' => '查看部门',
'name' => 'auth.departments.view',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.departments.index',
'parent_id' => 0, // 稍后更新为部门管理菜单的ID
'path' => 'admin.departments.index',
'component' => null,
'meta' => null,
'sort' => 1,
'status' => 1,
],
[
'name' => '创建部门',
'code' => 'system.departments.create',
'title' => '创建部门',
'name' => 'auth.departments.create',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.departments.store',
'parent_id' => 0, // 稍后更新为部门管理菜单的ID
'path' => 'admin.departments.store',
'component' => null,
'meta' => null,
'sort' => 2,
'status' => 1,
],
[
'name' => '编辑部门',
'code' => 'system.departments.update',
'title' => '编辑部门',
'name' => 'auth.departments.update',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.departments.update',
'parent_id' => 0, // 稍后更新为部门管理菜单的ID
'path' => 'admin.departments.update',
'component' => null,
'meta' => null,
'sort' => 3,
'status' => 1,
],
[
'name' => '删除部门',
'code' => 'system.departments.delete',
'title' => '删除部门',
'name' => 'auth.departments.delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.departments.destroy',
'parent_id' => 0, // 稍后更新为部门管理菜单的ID
'path' => 'admin.departments.destroy',
'component' => null,
'meta' => null,
'sort' => 4,
'status' => 1,
],
[
'name' => '批量删除部门',
'code' => 'system.departments.batch-delete',
'title' => '批量删除部门',
'name' => 'auth.departments.batch-delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.departments.batch-delete',
'parent_id' => 0, // 稍后更新为部门管理菜单的ID
'path' => 'admin.departments.batch-delete',
'component' => null,
'meta' => null,
'sort' => 5,
@@ -394,6 +477,181 @@ class AuthSeeder extends Seeder
foreach ($permissions as $permission) {
Permission::create($permission);
}
// 更新parent_id
$this->updateParentIds();
}
/**
* 更新parent_id建立层级关系
*/
private function updateParentIds(): void
{
$permissions = Permission::all();
// 获取顶级菜单ID
$homeMenu = $permissions->where('name', 'home')->first();
$authMenu = $permissions->where('name', 'auth')->first();
// 获取首页子菜单ID
$dashboardMenu = $permissions->where('name', 'home.dashboard')->first();
$profileMenu = $permissions->where('name', 'home.profile')->first();
// 获取权限子菜单ID
$usersMenu = $permissions->where('name', 'auth.users')->first();
$rolesMenu = $permissions->where('name', 'auth.roles')->first();
$permissionsMenu = $permissions->where('name', 'auth.permissions')->first();
$departmentsMenu = $permissions->where('name', 'auth.departments')->first();
// 更新首页子菜单的parent_id
if ($homeMenu) {
if ($dashboardMenu) {
$dashboardMenu->update(['parent_id' => $homeMenu->id]);
}
if ($profileMenu) {
$profileMenu->update(['parent_id' => $homeMenu->id]);
}
}
// 更新权限子菜单的parent_id
if ($authMenu) {
if ($usersMenu) {
$usersMenu->update(['parent_id' => $authMenu->id]);
}
if ($rolesMenu) {
$rolesMenu->update(['parent_id' => $authMenu->id]);
}
if ($permissionsMenu) {
$permissionsMenu->update(['parent_id' => $authMenu->id]);
}
if ($departmentsMenu) {
$departmentsMenu->update(['parent_id' => $authMenu->id]);
}
}
// 更新按钮权限的parent_id - 首页部分
$profileViewBtn = $permissions->where('name', 'home.profile.view')->first();
$profileUpdateBtn = $permissions->where('name', 'home.profile.update')->first();
$profilePasswordBtn = $permissions->where('name', 'home.profile.change-password')->first();
if ($profileMenu) {
if ($profileViewBtn) {
$profileViewBtn->update(['parent_id' => $profileMenu->id]);
}
if ($profileUpdateBtn) {
$profileUpdateBtn->update(['parent_id' => $profileMenu->id]);
}
if ($profilePasswordBtn) {
$profilePasswordBtn->update(['parent_id' => $profileMenu->id]);
}
}
// 更新按钮权限的parent_id - 用户管理
$userViewBtn = $permissions->where('name', 'auth.users.view')->first();
$userCreateBtn = $permissions->where('name', 'auth.users.create')->first();
$userUpdateBtn = $permissions->where('name', 'auth.users.update')->first();
$userDeleteBtn = $permissions->where('name', 'auth.users.delete')->first();
$userBatchDeleteBtn = $permissions->where('name', 'auth.users.batch-delete')->first();
$userExportBtn = $permissions->where('name', 'auth.users.export')->first();
$userImportBtn = $permissions->where('name', 'auth.users.import')->first();
if ($usersMenu) {
if ($userViewBtn) {
$userViewBtn->update(['parent_id' => $usersMenu->id]);
}
if ($userCreateBtn) {
$userCreateBtn->update(['parent_id' => $usersMenu->id]);
}
if ($userUpdateBtn) {
$userUpdateBtn->update(['parent_id' => $usersMenu->id]);
}
if ($userDeleteBtn) {
$userDeleteBtn->update(['parent_id' => $usersMenu->id]);
}
if ($userBatchDeleteBtn) {
$userBatchDeleteBtn->update(['parent_id' => $usersMenu->id]);
}
if ($userExportBtn) {
$userExportBtn->update(['parent_id' => $usersMenu->id]);
}
if ($userImportBtn) {
$userImportBtn->update(['parent_id' => $usersMenu->id]);
}
}
// 更新按钮权限的parent_id - 角色管理
$roleViewBtn = $permissions->where('name', 'auth.roles.view')->first();
$roleCreateBtn = $permissions->where('name', 'auth.roles.create')->first();
$roleUpdateBtn = $permissions->where('name', 'auth.roles.update')->first();
$roleDeleteBtn = $permissions->where('name', 'auth.roles.delete')->first();
$roleBatchDeleteBtn = $permissions->where('name', 'auth.roles.batch-delete')->first();
$roleAssignBtn = $permissions->where('name', 'auth.roles.assign-permissions')->first();
if ($rolesMenu) {
if ($roleViewBtn) {
$roleViewBtn->update(['parent_id' => $rolesMenu->id]);
}
if ($roleCreateBtn) {
$roleCreateBtn->update(['parent_id' => $rolesMenu->id]);
}
if ($roleUpdateBtn) {
$roleUpdateBtn->update(['parent_id' => $rolesMenu->id]);
}
if ($roleDeleteBtn) {
$roleDeleteBtn->update(['parent_id' => $rolesMenu->id]);
}
if ($roleBatchDeleteBtn) {
$roleBatchDeleteBtn->update(['parent_id' => $rolesMenu->id]);
}
if ($roleAssignBtn) {
$roleAssignBtn->update(['parent_id' => $rolesMenu->id]);
}
}
// 更新按钮权限的parent_id - 权限管理
$permViewBtn = $permissions->where('name', 'auth.permissions.view')->first();
$permCreateBtn = $permissions->where('name', 'auth.permissions.create')->first();
$permUpdateBtn = $permissions->where('name', 'auth.permissions.update')->first();
$permDeleteBtn = $permissions->where('name', 'auth.permissions.delete')->first();
$permBatchDeleteBtn = $permissions->where('name', 'auth.permissions.batch-delete')->first();
if ($permissionsMenu) {
if ($permViewBtn) {
$permViewBtn->update(['parent_id' => $permissionsMenu->id]);
}
if ($permCreateBtn) {
$permCreateBtn->update(['parent_id' => $permissionsMenu->id]);
}
if ($permUpdateBtn) {
$permUpdateBtn->update(['parent_id' => $permissionsMenu->id]);
}
if ($permDeleteBtn) {
$permDeleteBtn->update(['parent_id' => $permissionsMenu->id]);
}
if ($permBatchDeleteBtn) {
$permBatchDeleteBtn->update(['parent_id' => $permissionsMenu->id]);
}
}
// 更新按钮权限的parent_id - 部门管理
$deptViewBtn = $permissions->where('name', 'auth.departments.view')->first();
$deptCreateBtn = $permissions->where('name', 'auth.departments.create')->first();
$deptUpdateBtn = $permissions->where('name', 'auth.departments.update')->first();
$deptDeleteBtn = $permissions->where('name', 'auth.departments.delete')->first();
$deptBatchDeleteBtn = $permissions->where('name', 'auth.departments.batch-delete')->first();
if ($departmentsMenu) {
if ($deptViewBtn) {
$deptViewBtn->update(['parent_id' => $departmentsMenu->id]);
}
if ($deptCreateBtn) {
$deptCreateBtn->update(['parent_id' => $departmentsMenu->id]);
}
if ($deptUpdateBtn) {
$deptUpdateBtn->update(['parent_id' => $departmentsMenu->id]);
}
if ($deptDeleteBtn) {
$deptDeleteBtn->update(['parent_id' => $departmentsMenu->id]);
}
if ($deptBatchDeleteBtn) {
$deptBatchDeleteBtn->update(['parent_id' => $departmentsMenu->id]);
}
}
}
/**

View File

@@ -48,72 +48,88 @@ class SystemSeeder extends Seeder
private function createSystemPermissions(): void
{
$permissions = [
// 系统配置
// 系统顶级菜单
[
'name' => '系统配置',
'code' => 'system.config',
'title' => '系统',
'name' => 'system',
'type' => 'menu',
'parent_id' => 0,
'route' => '/system/config',
'path' => '/system',
'component' => null,
'meta' => json_encode([
'icon' => 'Setting',
'hidden' => false,
'hiddenBreadcrumb' => false,
]),
'sort' => 3,
'status' => 1,
],
// 系统配置
[
'title' => '系统配置',
'name' => 'system.config',
'type' => 'menu',
'parent_id' => 0, // 稍后更新为系统菜单的ID
'path' => '/system/config',
'component' => 'system/config/index',
'meta' => json_encode([
'icon' => 'SettingFilled',
'hidden' => false,
'hiddenBreadcrumb' => false,
]),
'sort' => 6,
'sort' => 1,
'status' => 1,
],
[
'name' => '查看配置',
'code' => 'system.config.view',
'title' => '查看配置',
'name' => 'system.config.view',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.config.index',
'parent_id' => 0, // 稍后更新为系统配置菜单的ID
'path' => 'admin.config.index',
'component' => null,
'meta' => null,
'sort' => 1,
'status' => 1,
],
[
'name' => '创建配置',
'code' => 'system.config.create',
'title' => '创建配置',
'name' => 'system.config.create',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.config.store',
'parent_id' => 0, // 稍后更新为系统配置菜单的ID
'path' => 'admin.config.store',
'component' => null,
'meta' => null,
'sort' => 2,
'status' => 1,
],
[
'name' => '编辑配置',
'code' => 'system.config.update',
'title' => '编辑配置',
'name' => 'system.config.update',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.config.update',
'parent_id' => 0, // 稍后更新为系统配置菜单的ID
'path' => 'admin.config.update',
'component' => null,
'meta' => null,
'sort' => 3,
'status' => 1,
],
[
'name' => '删除配置',
'code' => 'system.config.delete',
'title' => '删除配置',
'name' => 'system.config.delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.config.destroy',
'parent_id' => 0, // 稍后更新为系统配置菜单的ID
'path' => 'admin.config.destroy',
'component' => null,
'meta' => null,
'sort' => 4,
'status' => 1,
],
[
'name' => '批量删除配置',
'code' => 'system.config.batch-delete',
'title' => '批量删除配置',
'name' => 'system.config.batch-delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.config.batch-delete',
'parent_id' => 0, // 稍后更新为系统配置菜单的ID
'path' => 'admin.config.batch-delete',
'component' => null,
'meta' => null,
'sort' => 5,
@@ -122,59 +138,59 @@ class SystemSeeder extends Seeder
// 系统日志
[
'name' => '系统日志',
'code' => 'system.logs',
'title' => '系统日志',
'name' => 'system.logs',
'type' => 'menu',
'parent_id' => 0,
'route' => '/system/logs',
'parent_id' => 0, // 稍后更新为系统菜单的ID
'path' => '/system/logs',
'component' => 'system/logs/index',
'meta' => json_encode([
'icon' => 'DocumentCopy',
'hidden' => false,
'hiddenBreadcrumb' => false,
]),
'sort' => 7,
'sort' => 2,
'status' => 1,
],
[
'name' => '查看日志',
'code' => 'system.logs.view',
'title' => '查看日志',
'name' => 'system.logs.view',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.logs.index',
'parent_id' => 0, // 稍后更新为系统日志菜单的ID
'path' => 'admin.logs.index',
'component' => null,
'meta' => null,
'sort' => 1,
'status' => 1,
],
[
'name' => '删除日志',
'code' => 'system.logs.delete',
'title' => '删除日志',
'name' => 'system.logs.delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.logs.destroy',
'parent_id' => 0, // 稍后更新为系统日志菜单的ID
'path' => 'admin.logs.destroy',
'component' => null,
'meta' => null,
'sort' => 2,
'status' => 1,
],
[
'name' => '批量删除日志',
'code' => 'system.logs.batch-delete',
'title' => '批量删除日志',
'name' => 'system.logs.batch-delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.logs.batch-delete',
'parent_id' => 0, // 稍后更新为系统日志菜单的ID
'path' => 'admin.logs.batch-delete',
'component' => null,
'meta' => null,
'sort' => 3,
'status' => 1,
],
[
'name' => '导出日志',
'code' => 'system.logs.export',
'title' => '导出日志',
'name' => 'system.logs.export',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.logs.export',
'parent_id' => 0, // 稍后更新为系统日志菜单的ID
'path' => 'admin.logs.export',
'component' => null,
'meta' => null,
'sort' => 4,
@@ -183,70 +199,70 @@ class SystemSeeder extends Seeder
// 数据字典
[
'name' => '数据字典',
'code' => 'system.dictionaries',
'title' => '数据字典',
'name' => 'system.dictionaries',
'type' => 'menu',
'parent_id' => 0,
'route' => '/system/dictionaries',
'parent_id' => 0, // 稍后更新为系统菜单的ID
'path' => '/system/dictionaries',
'component' => 'system/dictionaries/index',
'meta' => json_encode([
'icon' => 'Notebook',
'hidden' => false,
'hiddenBreadcrumb' => false,
]),
'sort' => 8,
'sort' => 3,
'status' => 1,
],
[
'name' => '查看字典',
'code' => 'system.dictionaries.view',
'title' => '查看字典',
'name' => 'system.dictionaries.view',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.dictionaries.index',
'parent_id' => 0, // 稍后更新为数据字典菜单的ID
'path' => 'admin.dictionaries.index',
'component' => null,
'meta' => null,
'sort' => 1,
'status' => 1,
],
[
'name' => '创建字典',
'code' => 'system.dictionaries.create',
'title' => '创建字典',
'name' => 'system.dictionaries.create',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.dictionaries.store',
'parent_id' => 0, // 稍后更新为数据字典菜单的ID
'path' => 'admin.dictionaries.store',
'component' => null,
'meta' => null,
'sort' => 2,
'status' => 1,
],
[
'name' => '编辑字典',
'code' => 'system.dictionaries.update',
'title' => '编辑字典',
'name' => 'system.dictionaries.update',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.dictionaries.update',
'parent_id' => 0, // 稍后更新为数据字典菜单的ID
'path' => 'admin.dictionaries.update',
'component' => null,
'meta' => null,
'sort' => 3,
'status' => 1,
],
[
'name' => '删除字典',
'code' => 'system.dictionaries.delete',
'title' => '删除字典',
'name' => 'system.dictionaries.delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.dictionaries.destroy',
'parent_id' => 0, // 稍后更新为数据字典菜单的ID
'path' => 'admin.dictionaries.destroy',
'component' => null,
'meta' => null,
'sort' => 4,
'status' => 1,
],
[
'name' => '批量删除字典',
'code' => 'system.dictionaries.batch-delete',
'title' => '批量删除字典',
'name' => 'system.dictionaries.batch-delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.dictionaries.batch-delete',
'parent_id' => 0, // 稍后更新为数据字典菜单的ID
'path' => 'admin.dictionaries.batch-delete',
'component' => null,
'meta' => null,
'sort' => 5,
@@ -255,130 +271,253 @@ class SystemSeeder extends Seeder
// 定时任务
[
'name' => '定时任务',
'code' => 'system.tasks',
'title' => '定时任务',
'name' => 'system.tasks',
'type' => 'menu',
'parent_id' => 0,
'route' => '/system/tasks',
'parent_id' => 0, // 稍后更新为系统菜单的ID
'path' => '/system/tasks',
'component' => 'system/tasks/index',
'meta' => json_encode([
'icon' => 'Timer',
'hidden' => false,
'hiddenBreadcrumb' => false,
]),
'sort' => 9,
'sort' => 4,
'status' => 1,
],
[
'name' => '查看任务',
'code' => 'system.tasks.view',
'title' => '查看任务',
'name' => 'system.tasks.view',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.tasks.index',
'parent_id' => 0, // 稍后更新为定时任务菜单的ID
'path' => 'admin.tasks.index',
'component' => null,
'meta' => null,
'sort' => 1,
'status' => 1,
],
[
'name' => '创建任务',
'code' => 'system.tasks.create',
'title' => '创建任务',
'name' => 'system.tasks.create',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.tasks.store',
'parent_id' => 0, // 稍后更新为定时任务菜单的ID
'path' => 'admin.tasks.store',
'component' => null,
'meta' => null,
'sort' => 2,
'status' => 1,
],
[
'name' => '编辑任务',
'code' => 'system.tasks.update',
'title' => '编辑任务',
'name' => 'system.tasks.update',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.tasks.update',
'parent_id' => 0, // 稍后更新为定时任务菜单的ID
'path' => 'admin.tasks.update',
'component' => null,
'meta' => null,
'sort' => 3,
'status' => 1,
],
[
'name' => '删除任务',
'code' => 'system.tasks.delete',
'title' => '删除任务',
'name' => 'system.tasks.delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.tasks.destroy',
'parent_id' => 0, // 稍后更新为定时任务菜单的ID
'path' => 'admin.tasks.destroy',
'component' => null,
'meta' => null,
'sort' => 4,
'status' => 1,
],
[
'name' => '批量删除任务',
'code' => 'system.tasks.batch-delete',
'title' => '批量删除任务',
'name' => 'system.tasks.batch-delete',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.tasks.batch-delete',
'parent_id' => 0, // 稍后更新为定时任务菜单的ID
'path' => 'admin.tasks.batch-delete',
'component' => null,
'meta' => null,
'sort' => 5,
'status' => 1,
],
[
'name' => '执行任务',
'code' => 'system.tasks.execute',
'title' => '执行任务',
'name' => 'system.tasks.execute',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.tasks.execute',
'parent_id' => 0, // 稍后更新为定时任务菜单的ID
'path' => 'admin.tasks.execute',
'component' => null,
'meta' => null,
'sort' => 6,
'status' => 1,
],
[
'name' => '启用任务',
'code' => 'system.tasks.enable',
'title' => '启用任务',
'name' => 'system.tasks.enable',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.tasks.enable',
'parent_id' => 0, // 稍后更新为定时任务菜单的ID
'path' => 'admin.tasks.enable',
'component' => null,
'meta' => null,
'sort' => 7,
'status' => 1,
],
[
'name' => '禁用任务',
'code' => 'system.tasks.disable',
'title' => '禁用任务',
'name' => 'system.tasks.disable',
'type' => 'button',
'parent_id' => 0,
'route' => 'admin.tasks.disable',
'parent_id' => 0, // 稍后更新为定时任务菜单的ID
'path' => 'admin.tasks.disable',
'component' => null,
'meta' => null,
'sort' => 8,
'status' => 1,
],
// 个人中心
[
'name' => '个人中心',
'code' => 'system.profile',
'type' => 'menu',
'parent_id' => 0,
'route' => '/system/profile',
'component' => 'system/profile/index',
'meta' => json_encode([
'icon' => 'UserFilled',
'hidden' => false,
'hiddenBreadcrumb' => false,
]),
'sort' => 10,
'status' => 1,
],
];
foreach ($permissions as $permission) {
Permission::create($permission);
}
// 更新parent_id
$this->updateParentIds();
}
/**
* 更新parent_id建立层级关系
*/
private function updateParentIds(): void
{
$permissions = Permission::all();
// 获取系统顶级菜单ID
$systemMenu = $permissions->where('name', 'system')->first();
// 获取系统子菜单ID
$configMenu = $permissions->where('name', 'system.config')->first();
$logsMenu = $permissions->where('name', 'system.logs')->first();
$dictionariesMenu = $permissions->where('name', 'system.dictionaries')->first();
$tasksMenu = $permissions->where('name', 'system.tasks')->first();
// 更新系统子菜单的parent_id
if ($systemMenu) {
if ($configMenu) {
$configMenu->update(['parent_id' => $systemMenu->id]);
}
if ($logsMenu) {
$logsMenu->update(['parent_id' => $systemMenu->id]);
}
if ($dictionariesMenu) {
$dictionariesMenu->update(['parent_id' => $systemMenu->id]);
}
if ($tasksMenu) {
$tasksMenu->update(['parent_id' => $systemMenu->id]);
}
}
// 更新按钮权限的parent_id - 系统配置
$configViewBtn = $permissions->where('name', 'system.config.view')->first();
$configCreateBtn = $permissions->where('name', 'system.config.create')->first();
$configUpdateBtn = $permissions->where('name', 'system.config.update')->first();
$configDeleteBtn = $permissions->where('name', 'system.config.delete')->first();
$configBatchDeleteBtn = $permissions->where('name', 'system.config.batch-delete')->first();
if ($configMenu) {
if ($configViewBtn) {
$configViewBtn->update(['parent_id' => $configMenu->id]);
}
if ($configCreateBtn) {
$configCreateBtn->update(['parent_id' => $configMenu->id]);
}
if ($configUpdateBtn) {
$configUpdateBtn->update(['parent_id' => $configMenu->id]);
}
if ($configDeleteBtn) {
$configDeleteBtn->update(['parent_id' => $configMenu->id]);
}
if ($configBatchDeleteBtn) {
$configBatchDeleteBtn->update(['parent_id' => $configMenu->id]);
}
}
// 更新按钮权限的parent_id - 系统日志
$logsViewBtn = $permissions->where('name', 'system.logs.view')->first();
$logsDeleteBtn = $permissions->where('name', 'system.logs.delete')->first();
$logsBatchDeleteBtn = $permissions->where('name', 'system.logs.batch-delete')->first();
$logsExportBtn = $permissions->where('name', 'system.logs.export')->first();
if ($logsMenu) {
if ($logsViewBtn) {
$logsViewBtn->update(['parent_id' => $logsMenu->id]);
}
if ($logsDeleteBtn) {
$logsDeleteBtn->update(['parent_id' => $logsMenu->id]);
}
if ($logsBatchDeleteBtn) {
$logsBatchDeleteBtn->update(['parent_id' => $logsMenu->id]);
}
if ($logsExportBtn) {
$logsExportBtn->update(['parent_id' => $logsMenu->id]);
}
}
// 更新按钮权限的parent_id - 数据字典
$dictViewBtn = $permissions->where('name', 'system.dictionaries.view')->first();
$dictCreateBtn = $permissions->where('name', 'system.dictionaries.create')->first();
$dictUpdateBtn = $permissions->where('name', 'system.dictionaries.update')->first();
$dictDeleteBtn = $permissions->where('name', 'system.dictionaries.delete')->first();
$dictBatchDeleteBtn = $permissions->where('name', 'system.dictionaries.batch-delete')->first();
if ($dictionariesMenu) {
if ($dictViewBtn) {
$dictViewBtn->update(['parent_id' => $dictionariesMenu->id]);
}
if ($dictCreateBtn) {
$dictCreateBtn->update(['parent_id' => $dictionariesMenu->id]);
}
if ($dictUpdateBtn) {
$dictUpdateBtn->update(['parent_id' => $dictionariesMenu->id]);
}
if ($dictDeleteBtn) {
$dictDeleteBtn->update(['parent_id' => $dictionariesMenu->id]);
}
if ($dictBatchDeleteBtn) {
$dictBatchDeleteBtn->update(['parent_id' => $dictionariesMenu->id]);
}
}
// 更新按钮权限的parent_id - 定时任务
$taskViewBtn = $permissions->where('name', 'system.tasks.view')->first();
$taskCreateBtn = $permissions->where('name', 'system.tasks.create')->first();
$taskUpdateBtn = $permissions->where('name', 'system.tasks.update')->first();
$taskDeleteBtn = $permissions->where('name', 'system.tasks.delete')->first();
$taskBatchDeleteBtn = $permissions->where('name', 'system.tasks.batch-delete')->first();
$taskExecuteBtn = $permissions->where('name', 'system.tasks.execute')->first();
$taskEnableBtn = $permissions->where('name', 'system.tasks.enable')->first();
$taskDisableBtn = $permissions->where('name', 'system.tasks.disable')->first();
if ($tasksMenu) {
if ($taskViewBtn) {
$taskViewBtn->update(['parent_id' => $tasksMenu->id]);
}
if ($taskCreateBtn) {
$taskCreateBtn->update(['parent_id' => $tasksMenu->id]);
}
if ($taskUpdateBtn) {
$taskUpdateBtn->update(['parent_id' => $tasksMenu->id]);
}
if ($taskDeleteBtn) {
$taskDeleteBtn->update(['parent_id' => $tasksMenu->id]);
}
if ($taskBatchDeleteBtn) {
$taskBatchDeleteBtn->update(['parent_id' => $tasksMenu->id]);
}
if ($taskExecuteBtn) {
$taskExecuteBtn->update(['parent_id' => $tasksMenu->id]);
}
if ($taskEnableBtn) {
$taskEnableBtn->update(['parent_id' => $tasksMenu->id]);
}
if ($taskDisableBtn) {
$taskDisableBtn->update(['parent_id' => $tasksMenu->id]);
}
}
}
/**

View File

@@ -5,7 +5,7 @@
<template #icon v-if="item.meta?.icon">
<component :is="getIconComponent(item.meta.icon)" />
</template>
<template #title>{{ item.meta?.title || item.name }}</template>
<template #title>{{ item.title || item.name }}</template>
<navMenu :menu-items="item.children" :active-path="activePath" :parent-path="item.path" />
</a-sub-menu>
<!-- 无子菜单的菜单项 -->
@@ -14,7 +14,7 @@
<template #icon v-if="item.meta?.icon">
<component :is="getIconComponent(item.meta.icon)" />
</template>
{{ item.meta?.title || item.name }}
{{ item.title || item.name }}
</a-menu-item>
</template>
</template>

View File

@@ -12,7 +12,7 @@
:class="{ active: selectedParentMenu?.path === item.path }"
@click="handleParentMenuClick(item)">
<component :is="getIconComponent(item.meta?.icon)" />
<span>{{ item.meta?.title }}</span>
<span>{{ item.title }}</span>
</li>
</ul>
</a-layout-sider>
@@ -24,7 +24,7 @@
:collapsed-width="64" class="right-sidebar">
<div class="parent-title">
<component :is="getIconComponent(selectedParentMenu.meta?.icon)" />
<span v-if="!sidebarCollapsed">{{ selectedParentMenu.meta?.title }}</span>
<span v-if="!sidebarCollapsed">{{ selectedParentMenu.title }}</span>
</div>
<a-menu v-model:openKeys="openKeys" v-model:selectedKeys="selectedKeys" mode="inline"
:selected-keys="[route.path]">