From ec04e4944c6709192fc0a46551898da090143f12 Mon Sep 17 00:00:00 2001 From: mydearxym Date: Tue, 17 Aug 2021 15:46:18 +0800 Subject: [PATCH 1/6] chore: wip --- server/routes.js | 2 +- .../BuyMeChuanChuan/ChuanSelector.tsx | 8 +- src/components/NaviCatalog/index.tsx | 6 + src/components/NaviCatalog/logic.ts | 156 +++++++ .../Navigator/MainEntries/DesktopView.tsx | 2 +- .../Navigator/MorePanel/MobileView.tsx | 2 +- src/components/SupportUs/index.tsx | 7 +- .../content/CoolGuideContent/FilterBar.tsx | 6 +- .../content/RecipesContent/Footer/index.js | 2 +- .../content/TrendingContent/Footer/index.js | 2 +- src/pages/cool-guide.js | 2 +- utils/mock.ts | 419 ++++++------------ 12 files changed, 314 insertions(+), 300 deletions(-) create mode 100644 src/components/NaviCatalog/logic.ts diff --git a/server/routes.js b/server/routes.js index 0e1304ad4..6aa8b7c61 100644 --- a/server/routes.js +++ b/server/routes.js @@ -62,7 +62,7 @@ router.route('/meetups/:slug?').get((req, res) => { return renderAndCache({ req, res, path: '/meetups' }) }) -// 酷导游 +// 酷导航 router.route('/cool-guide/:slug?').get((req, res) => { return renderAndCache({ req, res, path: '/cool-guide' }) }) diff --git a/src/components/BuyMeChuanChuan/ChuanSelector.tsx b/src/components/BuyMeChuanChuan/ChuanSelector.tsx index b585d16c9..bc6b86fa9 100755 --- a/src/components/BuyMeChuanChuan/ChuanSelector.tsx +++ b/src/components/BuyMeChuanChuan/ChuanSelector.tsx @@ -24,8 +24,12 @@ const ChuanSelector: FC = ({ active, onSelect }) => { x {options.map((item) => ( - onSelect(item)}> - 1 + onSelect(item)} + > + {item} ))} diff --git a/src/components/NaviCatalog/index.tsx b/src/components/NaviCatalog/index.tsx index 6706d2bcb..43c179369 100755 --- a/src/components/NaviCatalog/index.tsx +++ b/src/components/NaviCatalog/index.tsx @@ -14,6 +14,8 @@ import { buildLog } from '@/utils/logger' import { nilOrEmpty } from '@/utils/validator' import { getQueryFromUrl, markRoute } from '@/utils/route' +import Button from '@/components/Buttons/Button' + import type { TMenuItem, TMenuMode } from './spec' import { ROOT_MENU, CHILD_MENU } from './constant' import Header from './Header' @@ -21,6 +23,7 @@ import Dashboard from './Dashboard' import List from './List' import { Wrapper } from './styles' +import { tags2Menu } from './logic' import { getCurrentMenuItem, findPath, covertPathToURLQuery } from './helper' @@ -182,6 +185,9 @@ const NaviCatalog: FC = ({ viewPath={viewPath} /> + { + // console.log('findUpdatePath menu: ', menu) + // console.log('findUpdatePath extra: ', extra) + + const rootIndex = findIndex((item) => equals(item.extra, [extra[0]]), menu) + if (rootIndex === -1) return [] + + const updatePath = [] + + const parentMenuPath = extra.slice(0, extra.length - 1) + // console.log('findUpdatePath parentMenuPath: ', parentMenuPath) + if (parentMenuPath.length === 1) { + updatePath.push(rootIndex) + } + + if (parentMenuPath.length === 2) { + updatePath.push(rootIndex) + + const index = findIndex( + (item) => equals(item.extra, parentMenuPath), + menu[rootIndex].children, + ) + + updatePath.push(index) + } + + return updatePath +} + +/** + * covert tags data to menu format data + */ +export const tags2Menu = (): TMenu => { + // let menu = [] + + // const rawMenu = filter((item) => item.extra.length === 1, tags) + // menu = rawMenu.map((item) => ({ ...item, children: [] })) + + const menu = filter((item) => item.extra.length === 1, tags) + + // const rawMenu = filter((item) => item.extra.length === 1, tags) + // menu = rawMenu.map((item) => ({ ...item, children: [] })) + + // level-2 + const menu2 = filter((item) => item.extra.length === 2, tags) + menu2.forEach((item) => { + const pathIndex = findUpdatePath(menu, item.extra) + if (!menu[pathIndex[0]].children) menu[pathIndex[0]].children = [] + menu[pathIndex[0]].children.push(item) + }) + + // level-3 + const menu3 = filter((item) => item.extra.length === 3, tags) + menu3.forEach((item) => { + const pathIndex = findUpdatePath(menu, item.extra) + + if (!menu[pathIndex[0]].children[pathIndex[1]].children) { + menu[pathIndex[0]].children[pathIndex[1]].children = [] + } + menu[pathIndex[0]].children[pathIndex[1]].children.push(item) + }) + + console.log('findal: ', menu) + return menu +} + +export const holder = 1 diff --git a/src/components/Navigator/MainEntries/DesktopView.tsx b/src/components/Navigator/MainEntries/DesktopView.tsx index 6f572e458..378af14b1 100644 --- a/src/components/Navigator/MainEntries/DesktopView.tsx +++ b/src/components/Navigator/MainEntries/DesktopView.tsx @@ -42,7 +42,7 @@ const DesktopView: FC = ({ type }) => { active={mainPath === ROUTE.COOL_GUIDE} testid={`header-${ROUTE.COOL_GUIDE}`} > - 酷导游 + 酷导航 diff --git a/src/components/Navigator/MorePanel/MobileView.tsx b/src/components/Navigator/MorePanel/MobileView.tsx index e80930834..0b09ce2ed 100644 --- a/src/components/Navigator/MorePanel/MobileView.tsx +++ b/src/components/Navigator/MorePanel/MobileView.tsx @@ -25,7 +25,7 @@ const items = [ }, { icon: `${ICON}/route/cool-guide.svg`, - title: '酷导游', + title: '酷导航', desc: '发现有意思的东西', href: `/${ROUTE.DISCOVERY}`, raw: 12, diff --git a/src/components/SupportUs/index.tsx b/src/components/SupportUs/index.tsx index 7cbe46ac2..d060595d0 100755 --- a/src/components/SupportUs/index.tsx +++ b/src/components/SupportUs/index.tsx @@ -97,14 +97,15 @@ const SupportUS: FC = ({ metric = METRIC.SUPPORT_US }) => { {/* eslint-disable-next-line */} - 编写一个功能完善的现代社区需要开发者保持长期的专注和付出,论坛的持续打磨和维护,更需要团队投入海量的精力,矛盾的是,现阶段因为缺乏流量等各种资源,难以通过自身造血实现正向循环。你的支持将有助于我们保持独立,在论坛的开发和运营上倾注更多时间。 + 编写一个功能完善 & {/* eslint-disable-next-line */} + 体验良好的现代社区需要开发者保持长期的专注和付出,论坛的持续打磨和维护,更需要团队投入海量的精力,矛盾的是,现阶段因为缺乏流量等各种资源,难以通过自身造血实现正向循环。你的支持将有助于我们保持独立,在论坛的开发和运营上倾注更多时间。 -
+

- 开源项目的健康发展无法仅靠情怀支撑,所受钱款将全部用于支付本站所使用的基础设施、第三方服务、资源以及开发人员生计等产生的必要费用,确保社区稳定、可持续,谢谢理解。 + 开源项目的健康发展无法仅靠情怀支撑,所受钱款将全部用于支付本项目所使用的基础设施、第三方服务、资源以及开发人员生计等产生的必要费用,确保社区稳定、可持续,谢谢理解。
diff --git a/src/containers/content/CoolGuideContent/FilterBar.tsx b/src/containers/content/CoolGuideContent/FilterBar.tsx index 9ee98f27f..8e93f5371 100644 --- a/src/containers/content/CoolGuideContent/FilterBar.tsx +++ b/src/containers/content/CoolGuideContent/FilterBar.tsx @@ -29,14 +29,14 @@ const FilterBar: FC = ({ topFilter, menuOnSelect }) => { {topFilter !== 'all' && ( )} - + */}