Files
crawler-plugin/frontend-vue/src/pages/brand/components/BrandTopBar.vue
T
huangzd1997 634fefbc2f revert(common-tools): 回滚常用工具分类与三个工具页
按 2026-10-24 决定整体下线:工具目录分组、定价换算/五国ASIN/关键词共享
三页面与路由、资料下载区与测试全部移除;保留 package.json 的 test:mount
脚本(仓内测试基础设施,与后管同口径)。
2026-10-24 01:43:45 +08:00

348 lines
8.2 KiB
Vue

<template>
<header class="top-bar" :class="{ 'top-bar--compact': !showNav && !showActions }">
<div class="logo-area" :class="{ 'logo-area--compact': !showNav && !showActions }">
<span class="app-name">数富AI-亚马逊</span>
<div v-if="$slots.logoExtra" class="logo-extra">
<slot name="logoExtra" />
</div>
<router-link v-if="showHomeLink" to="/home" class="btn-home">返回首页</router-link>
</div>
<nav v-if="showNav" class="nav-sections" aria-label="顶部功能导航">
<section v-for="group in visibleNavGroups" :key="group.columnKey" class="nav-section">
<div class="nav-section-title">{{ group.label }}</div>
<div class="nav-section-items">
<template v-for="item in group.items" :key="item.key">
<router-link v-if="item.href" :to="item.href" class="nav-item" :class="{ active: active === item.key }" @mouseenter="onNavItemHover(item.href)">
{{ item.label }}
</router-link>
<span v-else class="nav-item disabled" :class="{ active: active === item.key }">
{{ item.label }}
</span>
</template>
</div>
</section>
</nav>
<div v-if="showActions" class="top-right">
<BrandApiSecretSettingsButton />
</div>
<DownloadProgressPanel v-if="showActions" />
</header>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import BrandApiSecretSettingsButton from '@/pages/brand/components/BrandApiSecretSettingsButton.vue'
import { getCurrentUserAppColumnKeys } from '@/shared/api/permission'
import { prefetchRouteChunk } from '@/shared/route-prefetch'
import DownloadProgressPanel from '@/shared/components/DownloadProgressPanel.vue'
import { useRouter } from 'vue-router'
const router = useRouter()
type ActiveNavKey =
| 'brand'
| 'publish'
| 'appearance-patent'
| 'similar-asin'
| 'dedupe'
| 'convert'
| 'split'
| 'delete-brand'
| 'product-risk'
| 'shop-match'
| 'pricing'
| 'patrol-delete'
| 'query-asin'
| 'shop-data-crawl'
| 'withdraw'
| 'collect-data'
| 'image-video'
| 'amazon-console'
type NavItem = {
key: string
label: string
href?: string
columnKey?: string
aliases?: ReadonlyArray<string>
}
type NavGroup = {
columnKey: string
label: string
items: ReadonlyArray<NavItem>
}
const props = withDefaults(defineProps<{
active: ActiveNavKey
showNav?: boolean
showHomeLink?: boolean
showActions?: boolean
}>(), {
showNav: true,
showHomeLink: true,
showActions: true,
})
const active = props.active
const showNav = props.showNav
const showHomeLink = props.showHomeLink
const showActions = props.showActions
const allowedColumnKeys = ref<string[]>([])
const navGroups: ReadonlyArray<NavGroup> = [
{
columnKey: 'brand_front_tools',
label: '前端工具',
items: [
{ key: 'collect-data', label: '采集数据', href: '/collect-data' },
{ key: 'variant-collection', label: 'ASIN变体采集', href: '/variant-collection' },
// { key: 'image-video', label: '视频', href: '/image-video' },
{ key: 'brand', label: '品牌检测', href: '/brand' },
{ key: 'appearance-patent', label: '外观专利检测', href: '/appearance-patent' },
{ key: 'similar-asin', label: '货源查询', href: '/similar-asin' },
{ key: 'dedupe', label: '数据去重', href: '/dedupe' },
{ key: 'split', label: '数据拆分', href: '/split' },
{ key: 'convert', label: '格式转换', href: '/convert' },
],
},
{
columnKey: 'brand_operation_tools',
label: '运营工具',
items: [
{ key: 'publish', label: '上架', href: '/publish' },
{ key: 'delete-brand', label: '删除ASIN', href: '/delete-brand' },
{ key: 'product-risk', label: '商品风险解决', href: '/product-risk' },
{ key: 'shop-match', label: '定时匹配', href: '/shop-match' },
{ key: 'pricing', label: '跟价', href: '/price-track', aliases: ['price-track'] },
{ key: 'patrol-delete', label: '巡店删除', href: '/patrol-delete' },
{ key: 'query-asin', label: '查询ASIN', href: '/query-asin' },
{ key: 'shop-data-crawl', label: '店铺数据抓取', href: '/shop-data-crawl', columnKey: 'shop_data_crawl', aliases: ['shop-data-crawl'] },
{ key: 'withdraw', label: '取款', href: '/withdraw' },
{ key: 'shop-status', label: '店铺状态查询' },
],
},
{
columnKey: 'brand_logistics_tools',
label: '后勤工具',
items: [
{ key: 'purchase', label: '采购' },
{ key: 'erp', label: 'ERP' },
],
},
]
function getItemPermissionKeys(item: NavItem) {
return [item.key, item.columnKey, ...(item.aliases || [])]
.map((key) => String(key || '').trim().toLowerCase())
.filter(Boolean)
}
const visibleNavGroups = computed(() => {
const allowedSet = new Set(allowedColumnKeys.value)
const groups = navGroups.flatMap((group) => {
if (allowedSet.has(group.columnKey)) {
return [group]
}
const items = group.items.filter((item) =>
getItemPermissionKeys(item).some((key) => allowedSet.has(key)),
)
return items.length ? [{ ...group, items }] : []
})
return groups
})
onMounted(async () => {
try {
allowedColumnKeys.value = await getCurrentUserAppColumnKeys()
} catch (_error) {
allowedColumnKeys.value = []
}
})
/** 导航项 hover 预取目标页 chunk:弱网下点击跳转不再等 chunk 下载 */
function onNavItemHover(href?: string) {
prefetchRouteChunk(router, href)
}
</script>
<style scoped>
.top-bar {
min-height: 88px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20px;
padding: 10px 24px 12px;
background: #111;
border-bottom: 1px solid #2a2a2a;
}
.top-bar--compact {
min-height: 64px;
align-items: center;
justify-content: flex-start;
padding-top: 0;
padding-bottom: 0;
}
.logo-area {
display: flex;
align-items: center;
gap: 16px;
min-width: 0;
padding-top: 10px;
}
.logo-area--compact {
gap: 12px;
padding-top: 0;
}
.app-name {
color: #fff;
font-size: 18px;
font-weight: 800;
letter-spacing: 0.02em;
white-space: nowrap;
}
.btn-home {
color: #d2d2d2;
font-size: 13px;
text-decoration: none;
white-space: nowrap;
}
.logo-extra {
display: flex;
align-items: center;
}
.btn-home:hover {
color: #fff;
}
.nav-sections {
flex: 1;
min-width: 0;
display: flex;
align-items: stretch;
justify-content: center;
gap: 0;
}
.nav-section {
flex: 1;
min-width: 0;
padding: 0 18px;
position: relative;
}
.nav-section+.nav-section::before {
content: '';
position: absolute;
left: 0;
top: 14px;
bottom: 8px;
width: 1px;
background: rgba(255, 255, 255, 0.14);
}
.nav-section-title {
margin-bottom: 10px;
text-align: center;
color: #e8dfcf;
font-size: 16px;
font-weight: 800;
letter-spacing: 0.08em;
}
.nav-section-items {
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
padding: 10px 14px;
border-radius: 14px;
background: linear-gradient(180deg, rgba(83, 74, 67, 0.92) 0%, rgba(72, 65, 59, 0.96) 100%);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.nav-item {
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 28px;
padding: 0 2px;
color: #f3eee4;
font-size: 14px;
font-weight: 700;
text-decoration: none;
border-bottom: 2px solid transparent;
transition: color 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}
.nav-item:hover {
color: #fff;
border-bottom-color: rgba(255, 255, 255, 0.68);
}
.nav-item.active {
color: #fff;
border-bottom-color: #8dc4ff;
}
.nav-item.disabled {
color: rgba(255, 255, 255, 0.78);
opacity: 0.82;
cursor: default;
}
.top-right {
width: 140px;
flex-shrink: 0;
display: flex;
justify-content: flex-end;
padding-top: 8px;
}
@media (max-width: 1200px) {
.top-bar {
flex-direction: column;
align-items: stretch;
}
.top-bar--compact {
min-height: 64px;
flex-direction: row;
align-items: center;
}
.logo-area {
padding-top: 0;
}
.nav-sections {
flex-direction: column;
}
.nav-section {
padding: 0;
}
.nav-section+.nav-section::before {
display: none;
}
.top-right {
display: none;
}
}
</style>