feat: 恢复个人中心菜单数据
This commit is contained in:
parent
d866f15f24
commit
395712e6e5
49
sql/profile-menu.sql
Normal file
49
sql/profile-menu.sql
Normal file
@ -0,0 +1,49 @@
|
||||
-- 增量补齐个人中心隐藏菜单。
|
||||
-- 用途:已有库不需要重跑完整 vben-admin-init.sql 时,可单独执行本文件。
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
INSERT INTO `admin_menu` (
|
||||
`id`,
|
||||
`pid`,
|
||||
`name`,
|
||||
`path`,
|
||||
`component`,
|
||||
`redirect`,
|
||||
`auth_code`,
|
||||
`type`,
|
||||
`meta`,
|
||||
`status`,
|
||||
`sort`
|
||||
)
|
||||
VALUES (
|
||||
2041700000000100011,
|
||||
0,
|
||||
'Profile',
|
||||
'/profile',
|
||||
'_core/profile/index',
|
||||
NULL,
|
||||
NULL,
|
||||
'menu',
|
||||
'{"hideInMenu":true,"icon":"lucide:user","title":"page.auth.profile"}',
|
||||
1,
|
||||
10000
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`pid` = VALUES(`pid`),
|
||||
`path` = VALUES(`path`),
|
||||
`component` = VALUES(`component`),
|
||||
`redirect` = VALUES(`redirect`),
|
||||
`auth_code` = VALUES(`auth_code`),
|
||||
`type` = VALUES(`type`),
|
||||
`meta` = VALUES(`meta`),
|
||||
`status` = VALUES(`status`),
|
||||
`sort` = VALUES(`sort`),
|
||||
`is_deleted` = 0;
|
||||
|
||||
INSERT IGNORE INTO `admin_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT role.`id`, menu.`id`
|
||||
FROM `admin_role` role
|
||||
JOIN `admin_menu` menu ON menu.`name` = 'Profile'
|
||||
WHERE role.`is_deleted` = 0
|
||||
AND menu.`is_deleted` = 0;
|
||||
@ -204,7 +204,8 @@ VALUES
|
||||
(2041700000000100009, 0, 'Project', '/vben-admin', NULL, NULL, NULL, 'catalog', '{"badgeType":"dot","icon":"carbon:data-center","order":9998,"title":"demos.vben.title"}', 1, 9998),
|
||||
(2041700000000100901, 2041700000000100009, 'VbenDocument', '/vben-admin/document', 'IFrameView', NULL, NULL, 'embedded', '{"icon":"carbon:book","iframeSrc":"https://doc.vben.pro","title":"demos.vben.document"}', 1, 0),
|
||||
(2041700000000100902, 2041700000000100009, 'VbenGithub', '/vben-admin/github', 'IFrameView', NULL, NULL, 'link', '{"icon":"carbon:logo-github","link":"https://github.com/vbenjs/vue-vben-admin","title":"Github"}', 1, 0),
|
||||
(2041700000000100010, 0, 'About', '/about', '_core/about/index', NULL, NULL, 'menu', '{"icon":"lucide:copyright","order":9999,"title":"demos.vben.about"}', 1, 9999)
|
||||
(2041700000000100010, 0, 'About', '/about', '_core/about/index', NULL, NULL, 'menu', '{"icon":"lucide:copyright","order":9999,"title":"demos.vben.about"}', 1, 9999),
|
||||
(2041700000000100011, 0, 'Profile', '/profile', '_core/profile/index', NULL, NULL, 'menu', '{"hideInMenu":true,"icon":"lucide:user","title":"page.auth.profile"}', 1, 10000)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`pid` = VALUES(`pid`),
|
||||
`path` = VALUES(`path`),
|
||||
@ -310,6 +311,7 @@ VALUES
|
||||
(2041700000000010003, 2041700000000100009),
|
||||
(2041700000000010003, 2041700000000100901),
|
||||
(2041700000000010003, 2041700000000100902),
|
||||
(2041700000000010003, 2041700000000100010);
|
||||
(2041700000000010003, 2041700000000100010),
|
||||
(2041700000000010003, 2041700000000100011);
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
33
test/admin/profile-menu-sql.spec.ts
Normal file
33
test/admin/profile-menu-sql.spec.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
describe('profile-menu.sql', () => {
|
||||
const sql = readFileSync(join(process.cwd(), 'sql/profile-menu.sql'), 'utf8');
|
||||
const initSql = readFileSync(
|
||||
join(process.cwd(), 'sql/vben-admin-init.sql'),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
it('adds the hidden profile route menu to existing databases', () => {
|
||||
expect(sql).toContain("'Profile'");
|
||||
expect(sql).toContain("'/profile'");
|
||||
expect(sql).toContain("'_core/profile/index'");
|
||||
expect(sql).toContain('"hideInMenu":true');
|
||||
expect(sql).toContain('"title":"page.auth.profile"');
|
||||
});
|
||||
|
||||
it('keeps the full admin init script aligned with the profile menu', () => {
|
||||
expect(initSql).toContain(
|
||||
"'Profile', '/profile', '_core/profile/index'",
|
||||
);
|
||||
expect(initSql).toContain(
|
||||
'(2041700000000010003, 2041700000000100011)',
|
||||
);
|
||||
});
|
||||
|
||||
it('grants the profile menu to all active roles without deleting existing role menus', () => {
|
||||
expect(sql).toContain('INSERT IGNORE INTO `admin_role_menu`');
|
||||
expect(sql).toContain("menu.`name` = 'Profile'");
|
||||
expect(sql).not.toMatch(/DELETE\s+FROM\s+`admin_role_menu`/i);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user