diff --git a/src/assets/placeholder-bigbrother.png b/src/assets/placeholder-bigbrother.png new file mode 100644 index 0000000..08dadf0 Binary files /dev/null and b/src/assets/placeholder-bigbrother.png differ diff --git a/src/assets/placeholder-hosts.png b/src/assets/placeholder-hosts.png new file mode 100644 index 0000000..a7cd7a1 Binary files /dev/null and b/src/assets/placeholder-hosts.png differ diff --git a/src/assets/placeholder-tk.png b/src/assets/placeholder-tk.png new file mode 100644 index 0000000..c847483 Binary files /dev/null and b/src/assets/placeholder-tk.png differ diff --git a/src/assets/placeholder-webai.png b/src/assets/placeholder-webai.png new file mode 100644 index 0000000..72ca72e Binary files /dev/null and b/src/assets/placeholder-webai.png differ diff --git a/src/components/PermissionMask.vue b/src/components/PermissionMask.vue new file mode 100644 index 0000000..a694a6c --- /dev/null +++ b/src/components/PermissionMask.vue @@ -0,0 +1,279 @@ + + + + + diff --git a/src/layout/WorkbenchLayout.vue b/src/layout/WorkbenchLayout.vue index 449e86f..11942a6 100644 --- a/src/layout/WorkbenchLayout.vue +++ b/src/layout/WorkbenchLayout.vue @@ -67,36 +67,64 @@
- +
-
- +
+ -
-
+ /> +
+
-
+
+
- +
- + + +
- +
- + + +
- +
- + + +
@@ -109,7 +137,14 @@ import YoloBrowser from '@/views/YoloBrowser.vue' import TkWorkbenches from '@/views/tk/Workbenches.vue' import HostsList from '@/views/tk/HostsList.vue' import ConfigPage from '@/pages/ConfigPage.vue' -import FanWorkbench from '@/views/tk/FanWorkbench.vue' // Added import +import FanWorkbench from '@/views/tk/FanWorkbench.vue' +import PermissionMask from '@/components/PermissionMask.vue' + +// 占位图片 - 无权限时显示的工作台截图 +import placeholderTk from '@/assets/placeholder-tk.png' +import placeholderHosts from '@/assets/placeholder-hosts.png' +import placeholderWebAi from '@/assets/placeholder-webai.png' +import placeholderBigBrother from '@/assets/placeholder-bigbrother.png' const emit = defineEmits(['logout', 'go-back', 'stop-all']) diff --git a/src/pages/LoginPage.vue b/src/pages/LoginPage.vue index f89233b..f83fed3 100644 --- a/src/pages/LoginPage.vue +++ b/src/pages/LoginPage.vue @@ -159,7 +159,7 @@ import { ref, onMounted } from 'vue' import { useI18n } from 'vue-i18n' import { isElectron, getAppVersion } from '../utils/electronBridge' -import { setUser, setToken, setUserPass, getUserPass } from '@/utils/storage' +import { setUser, setToken, setUserPass, getUserPass, setPermissions } from '@/utils/storage' import logo from '../assets/logo.png' import illustration from '../assets/illustration.png' @@ -233,6 +233,13 @@ const handleSubmit = async () => { setToken(result.user.tokenValue); setUser(result.user); + // 保存权限信息 + setPermissions({ + bigBrother: result.user.bigBrother, + crawl: result.user.crawl, + webAi: result.user.webAi, + }); + emit('loginSuccess') } else { error.value = result.error || '登录失败' diff --git a/src/utils/storage.js b/src/utils/storage.js index 2475198..299afbb 100644 --- a/src/utils/storage.js +++ b/src/utils/storage.js @@ -51,3 +51,49 @@ export function setSerch(data) { export function getSerch() { return JSON.parse(localStorage.getItem('Serch')); } + +// ==================== 权限管理 ==================== + +const PERMISSIONS_KEY = 'user_permissions'; + +/** + * 存储权限信息 + * @param {Object} permissions - 权限对象 { bigBrother, crawl, webAi } + */ +export function setPermissions(permissions) { + localStorage.setItem(PERMISSIONS_KEY, JSON.stringify({ + bigBrother: permissions.bigBrother ?? 0, + crawl: permissions.crawl ?? 0, + webAi: permissions.webAi ?? 0, + })); +} + +/** + * 获取权限信息 + * @returns {Object} 权限对象 { bigBrother, crawl, webAi } + */ +export function getPermissions() { + try { + const permissions = JSON.parse(localStorage.getItem(PERMISSIONS_KEY)); + return permissions || { bigBrother: 0, crawl: 0, webAi: 0 }; + } catch { + return { bigBrother: 0, crawl: 0, webAi: 0 }; + } +} + +/** + * 清除权限信息 + */ +export function clearPermissions() { + localStorage.removeItem(PERMISSIONS_KEY); +} + +/** + * 检查特定权限 + * @param {string} permissionKey - 'bigBrother' | 'crawl' | 'webAi' + * @returns {boolean} 是否有权限 + */ +export function hasPermission(permissionKey) { + const permissions = getPermissions(); + return permissions[permissionKey] === 1; +}