refactor: 组件就近迁移、操作菜单组件化并统一页面命名
- 组件文件统一 PascalCase 并就近迁入所属目录 - 操作菜单抽为 ActionSheet 组件,危险操作确认拆为 useConfirmAction - 导航栏测量拆为 useNavbarMetrics 并收缩对外接口 - 页面方法按动词约定重命名,show 前缀与 handle 误用一并修正 - 通知与菜单接口类型改用字面量联合并修正取值注释 - 多行空壳注释收回单行
This commit is contained in:
1 parent
1e3954ce0c
commit
cb1a1e349f
63 files changed
+1653
-1423
No files matched your search
+12
-14
@@ -1,17 +1,15 @@
|
||||
<template>
|
||||
<view>
|
||||
<custom-navbar title="工作台" :show-back="false" placeholder />
|
||||
<!-- tabbar 壳为全出血(index/mine 的沉浸式头需要贴边),工作台网格用工具类补齐
|
||||
横向 32rpx / 顶部 16rpx,与 default 壳的 .page 内边距保持一致 -->
|
||||
<app-navbar title="工作台" :show-back="false" placeholder />
|
||||
<!-- tabbar 壳为全出血(index/mine 的沉浸式头需要贴边),工作台网格需要自己补横向留白 -->
|
||||
<view class="px-32rpx pt-16rpx">
|
||||
<template v-for="(item, index) in visibleGridList" :key="index">
|
||||
<template v-for="(item, index) in visibleGroups" :key="index">
|
||||
<wd-card :title="item.title">
|
||||
<wd-grid clickable :column="4">
|
||||
<wd-grid-item
|
||||
v-for="(child, childIndex) in item.children"
|
||||
:key="childIndex"
|
||||
use-slot
|
||||
@click="handleNavClick(child)"
|
||||
@click="navigate(child)"
|
||||
>
|
||||
<view class="p-2">
|
||||
<image class="w-72rpx h-72rpx rounded-8rpx" :src="child.icon" />
|
||||
@@ -29,7 +27,7 @@
|
||||
import { computed } from "vue";
|
||||
import { useNavigation } from "@/composables/useNavigation";
|
||||
import { workMenuGroups } from "@/config/work-menu";
|
||||
import { hasPermission as checkPermission } from "@/utils/permission";
|
||||
import { hasPermission } from "@/utils/permission";
|
||||
|
||||
definePage({
|
||||
name: "work",
|
||||
@@ -40,20 +38,20 @@ definePage({
|
||||
layout: "tabbar",
|
||||
});
|
||||
|
||||
const { handleNavClick } = useNavigation();
|
||||
const { navigate } = useNavigation();
|
||||
|
||||
// 检查是否有权限
|
||||
const hasPermission = (perm: string) => {
|
||||
// 无权限码的菜单视为公开入口,其余按当前账号的权限码判断
|
||||
const isMenuAllowed = (perm: string) => {
|
||||
if (!perm) return true;
|
||||
return checkPermission(perm);
|
||||
return hasPermission(perm);
|
||||
};
|
||||
|
||||
// 根据权限过滤后的菜单列表
|
||||
const visibleGridList = computed(() => {
|
||||
// 根据权限过滤后的菜单分组,未授权分组整体不展示
|
||||
const visibleGroups = computed(() => {
|
||||
return workMenuGroups
|
||||
.map((group) => ({
|
||||
...group,
|
||||
children: group.children.filter((item) => hasPermission(item.perm)),
|
||||
children: group.children.filter((item) => isMenuAllowed(item.perm)),
|
||||
}))
|
||||
.filter((group) => group.children.length > 0);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user