Repository navigation
feat: system and workspace homepage permission #7867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,17 @@ import type HomepageApi from '@/api/admin/workspace/homepage' | |
| import MkDateRange from '@/components/mk-date-range/index.vue' | ||
| import type { MkDateRangeValue } from '@/components/mk-date-range/types' | ||
| import { numberFormat, formatTokenNumber } from '@/utils/number' | ||
| import { computed } from 'vue' | ||
| import { useRoute } from 'vue-router' | ||
| import perm from '@/permission' | ||
|
|
||
| const route = useRoute() | ||
| const isSystemHome = computed(() => route.meta.scope === 'system') | ||
|
|
||
| /* 排行榜导出权限:系统概览走系统首页权限,工作空间概览走概览权限 */ | ||
| const canExport = computed(() => | ||
| isSystemHome.value ? Boolean(perm.system.homepage.export()) : Boolean(perm.homepage.homepage.export()), | ||
| ) | ||
|
|
||
| const props = defineProps<{ api: typeof HomepageApi; workspaceId: string; initialKind: HomeRankingKind; initialRange: HomeDateRange }>() | ||
|
|
||
|
|
@@ -92,7 +103,7 @@ onMounted(() => loadRanking()) | |
| <MkSearchInput v-model="searchName" class="w-55!" @change="handleSearch" /> | ||
| </div> | ||
| <!-- 导出当前筛选下的完整排行榜 --> | ||
| <el-button plain :loading="exporting" :disabled="loading" @click="handleExport"> | ||
| <el-button v-if="canExport" plain :loading="exporting" :disabled="loading" @click="handleExport"> | ||
| <MkIcon name="icon_export_outlined" /> | ||
| <span>导出</span> | ||
| </el-button> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is an analysis of the provided code diff, focusing on potential issues and optimization suggestions: 1. Permission Logic Duplication & Maintainability
2. Reactive Dependency on
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary irregularity is a mismatch between the code change and the comment.
工作空间「概览」导出权限translates to "Workspace 'Overview' Export Permission". However, the property key was changed fromedittoexport, which aligns with the comment, but it suggests that the comment itself may be outdated if the function's purpose has shifted. More likely, the comment accurately describes the intent, and the key rename fixes a logical consistency issue (the code now correctly exposes anexportpermission).exportis a reserved keyword (though unlikely in standard JS objects as it's not a reserved word for property names), consider context. However,exportis valid as a property name.P.HOMEPAGE_EXPORTis consistently defined and thatexportis recognized elsewhere in the application logic (e.g., in permission checks, UI components, or router guards) as the new expected key. If the previous keyeditwas referenced elsewhere, those references will break.Optimization/Recommendation:
exportkey instead ofedit.editkey for this specific permission.view,edit,delete,export) and ensure full consistency.