feat 完善注释
This commit is contained in:
@@ -12,21 +12,12 @@ import tileService from '@/assets/home/entry-service.png'
|
||||
import tileContract from '@/assets/home/entry-contract.png'
|
||||
import tileFinance from '@/assets/home/entry-finance.png'
|
||||
|
||||
/**
|
||||
* 首页右上「业务服务」入口卡(设计稿标题即「业务服务」,与下方栏位同名)。
|
||||
*
|
||||
* 数据来自 store.quickEntries(← /vermins/portalEntryUser/list 的 groupType=1 项),
|
||||
* 接口不可用(游客 / 无权限)时回退到内置默认入口,保证卡片不空。
|
||||
* 设计稿固定五个入口,接口返回的多余项(如硬件 / 互联 / 其他)不展示。
|
||||
* 「>>」双箭头打开 HomeAppDialog,可在快捷 / 其他两组之间调整入口。
|
||||
*/
|
||||
const homeStore = useHomeStore()
|
||||
const { quickEntries } = storeToRefs(homeStore)
|
||||
const router = useRouter()
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
|
||||
/** 设计稿固定入口名目(设计稿没有的接口入口不展示) */
|
||||
const DESIGN_NAMES = [
|
||||
'工单需求池',
|
||||
'案例库管理',
|
||||
@@ -35,7 +26,6 @@ const DESIGN_NAMES = [
|
||||
'财务台账',
|
||||
]
|
||||
|
||||
/** 接口不可用时的默认入口(与设计稿五项一致,tone 对应设计稿五色) */
|
||||
const FALLBACK_QUICK: PortalEntryCard[] = [
|
||||
{
|
||||
id: 0,
|
||||
@@ -84,7 +74,6 @@ const FALLBACK_QUICK: PortalEntryCard[] = [
|
||||
},
|
||||
]
|
||||
|
||||
/** 设计稿切图:蓝湖整稿 97×97 方块(含底色与白色图案),按入口名映射 */
|
||||
const DESIGN_TILES: Record<string, string> = {
|
||||
工单需求池: tileDemand,
|
||||
案例库管理: tileCases,
|
||||
@@ -93,10 +82,8 @@ const DESIGN_TILES: Record<string, string> = {
|
||||
财务台账: tileFinance,
|
||||
}
|
||||
|
||||
/** 前端已注册的静态路由(route 无效时不跳转,避免出现无匹配路由) */
|
||||
const knownPaths = new Set(router.getRoutes().map((item) => item.path))
|
||||
|
||||
/** 卡片展示的入口:接口数据按设计稿名目过滤,最多 5 个 */
|
||||
const entries = computed<PortalEntryCard[]>(() => {
|
||||
const list = toPortalEntryCards(quickEntries.value).filter((card) =>
|
||||
DESIGN_NAMES.includes(card.label),
|
||||
@@ -104,14 +91,12 @@ const entries = computed<PortalEntryCard[]>(() => {
|
||||
return (list.length > 0 ? list : FALLBACK_QUICK).slice(0, 5)
|
||||
})
|
||||
|
||||
/** 入口图:接口 iconUrl 图案优先,否则设计稿切图 */
|
||||
function tileSrc(card: PortalEntryCard): string {
|
||||
return card.isImage && card.icon
|
||||
? card.icon
|
||||
: (DESIGN_TILES[card.label] ?? '')
|
||||
}
|
||||
|
||||
/** 解析可跳转路径:优先后端 route,其次同名默认入口,最后回首页 */
|
||||
function resolvePath(card: PortalEntryCard): string {
|
||||
if (card.route && knownPaths.has(card.route)) return card.route
|
||||
const fallback = FALLBACK_QUICK.find((item) => item.label === card.label)
|
||||
@@ -120,7 +105,6 @@ function resolvePath(card: PortalEntryCard): string {
|
||||
}
|
||||
|
||||
function onMore(): void {
|
||||
// 打开时同步一次,确保分组是后端最新结果
|
||||
void homeStore.fetchPortalEntries()
|
||||
dialogVisible.value = true
|
||||
}
|
||||
@@ -139,7 +123,6 @@ function onMore(): void {
|
||||
:to="resolvePath(entry)"
|
||||
class="home-quick__item"
|
||||
>
|
||||
<!-- 设计稿:97×97 彩色方块 + 白色图案(蓝湖整稿切图),接口 iconUrl 图案优先 -->
|
||||
<img
|
||||
class="home-quick__tile"
|
||||
:src="tileSrc(entry)"
|
||||
@@ -148,7 +131,6 @@ function onMore(): void {
|
||||
<span class="home-quick__label">{{ entry.label }}</span>
|
||||
</RouterLink>
|
||||
|
||||
<!-- 设计稿:双箭头图标与入口方块行垂直居中(@y875, 32×32,距末位方块 20) -->
|
||||
<button
|
||||
class="home-quick__more"
|
||||
type="button"
|
||||
@@ -191,12 +173,9 @@ function onMore(): void {
|
||||
position: relative;
|
||||
.flex(column, flex-start, stretch);
|
||||
flex-shrink: 0;
|
||||
// 设计稿右卡 722 宽;白底 + 浅灰描边
|
||||
// flex-basis 代替定宽:窄视口允许收缩,避免横向滚动条(1920 下仍为 722)
|
||||
flex: 0 1 722px;
|
||||
min-width: 0;
|
||||
gap: 0;
|
||||
// 设计稿:标题盒顶 y772 = 卡顶 +18,方块行顶 y841 = +87,卡高 264
|
||||
padding: 18px 40px 28px;
|
||||
border: 1px solid @home-card-border;
|
||||
border-radius: @radius-lg;
|
||||
@@ -207,7 +186,6 @@ function onMore(): void {
|
||||
}
|
||||
|
||||
&__title {
|
||||
// 设计稿卡内标题 36px / 700 / #121212,盒高 52(y772-824)
|
||||
font-size: @font-size-xxl;
|
||||
font-weight: 700;
|
||||
line-height: 52px;
|
||||
@@ -216,10 +194,9 @@ function onMore(): void {
|
||||
|
||||
&__list {
|
||||
.flex(row, flex-start, flex-start);
|
||||
// 设计稿入口图标间距(图标 97 + 间隙 30);方块行顶 y841 = 卡顶 +87
|
||||
gap: 30px;
|
||||
margin-top: 17px;
|
||||
flex-wrap: wrap; // 卡片被收缩时换行,避免卡内溢出
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
&__item {
|
||||
@@ -233,7 +210,6 @@ function onMore(): void {
|
||||
}
|
||||
}
|
||||
|
||||
// 设计稿:97×97 彩色方块切图(含底色与白色图案),整图渲染
|
||||
&__tile {
|
||||
display: block;
|
||||
width: 97px;
|
||||
@@ -243,7 +219,6 @@ function onMore(): void {
|
||||
}
|
||||
|
||||
&__label {
|
||||
// 设计稿入口文字 18px / 500 / #121212
|
||||
font-size: @font-size-lg;
|
||||
font-weight: 500;
|
||||
color: @home-ink;
|
||||
@@ -251,8 +226,6 @@ function onMore(): void {
|
||||
}
|
||||
|
||||
&__more {
|
||||
// 设计稿:» 32×32 @卡内 (665,121),与方块行(顶 y+87,高 97)垂直居中 → top 87+48.5-16 = 119.5
|
||||
// 绝对定位脱离 flex 流:卡收缩(窄视口)时不参与折行
|
||||
position: absolute;
|
||||
top: 120px;
|
||||
right: 25px;
|
||||
|
||||
Reference in New Issue
Block a user