From 30b0872226fdcd3d0800f57abe5612f042ad6611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Thu, 23 May 2024 10:57:30 +0800 Subject: [PATCH] chore: release 0.15.3 (#497) * chore: top content * chore: release 0.15.3 --- packages/components/config/index.js | 2 + packages/components/package.json | 2 +- .../src/components/td-logo/index.js | 77 +++++++++---------- 3 files changed, 39 insertions(+), 42 deletions(-) diff --git a/packages/components/config/index.js b/packages/components/config/index.js index ee379cf4..036b0dd0 100644 --- a/packages/components/config/index.js +++ b/packages/components/config/index.js @@ -1,2 +1,4 @@ // logo 设置 +export const logoMenuConfigCdn = 'https://cdc.cdn-go.cn/tdc/latest/menu.json'; +export const logoMenuConfigWoaCdn = 'https://cdc.cdn-go.cn/tdc/latest/menu.woa.json'; export const logoMenuSvgPrefix = 'https://cdc.cdn-go.cn/tdc/latest/images'; diff --git a/packages/components/package.json b/packages/components/package.json index 85e8d315..9c48a53e 100755 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "tdesign-site-components", - "version": "0.15.2", + "version": "0.15.3", "main": "lib/site.es.js", "scripts": { "dev": "vite", diff --git a/packages/components/src/components/td-logo/index.js b/packages/components/src/components/td-logo/index.js index 183ca582..2a8eb20e 100755 --- a/packages/components/src/components/td-logo/index.js +++ b/packages/components/src/components/td-logo/index.js @@ -2,7 +2,9 @@ import { html, define } from 'hybrids'; import logoIcon from '@images/logo.svg?raw'; import menuApplicationIcon from '@images/menu-application.svg?raw'; -import { logoMenuSvgPrefix } from '@config'; +import chevronRightIcon from '@images/chevron-right.svg?raw'; +import { isIntranet } from '@utils/index'; +import { logoMenuConfigCdn, logoMenuConfigWoaCdn, logoMenuSvgPrefix } from '@config'; import { getLang } from '@utils'; import style from './style.less'; @@ -10,42 +12,6 @@ import portalStyle from './portal.less'; const isEnglish = getLang() === 'en'; -const navList = [ - { - title: '腾讯设计', - children: [ - { - key: 'tdesign', - title: 'TDesign', - url: 'https://tdesign.tencent.com/?utm_source=tdc&utm_medium=tdc.nav', - desc: '企业级设计体系', - }, - { - key: 'codesign', - title: 'CoDesign', - url: 'https://codesign.qq.com/?utm_source=tdc&utm_medium=tdc.nav', - desc: '一站式设计协作平台', - }, - ], - }, - { - title: '腾讯调研', - children: [ - { - key: 'wj', - title: '腾讯问卷', - url: 'https://wj.qq.com/?utm_source=tdc&utm_medium=tdc.nav', - desc: '免费的问卷调查系统', - }, - { - key: 'txc', - title: '兔小巢', - url: 'https://txc.qq.com/?utm_source=tdc&utm_medium=tdc.nav', - desc: '用户反馈服务平台', - }, - ], - }, -]; function renderList(list = []) { return html`
${list.map( @@ -61,11 +27,17 @@ function renderList(list = []) {
`; } -function renderMenu() { - const len = navList.length; - return navList.map( +function renderMenu(list) { + const len = list.length; + return list.map( (item, index) => html` - ${item.title} + ${item.category_url + ? html` + + ${item.category_title} + + ` + : html` ${item.category_title} `} ${renderList(item.children)} ${index < len - 1 ? html`
` : html``} `, ); @@ -77,6 +49,29 @@ export default define({ get: (host, lastValue) => lastValue || [], set: (host, value) => value, }, + isIntranet: { + get: () => isIntranet(), + set: (value) => value, + connect: (host) => { + const menuCdn = isIntranet() ? logoMenuConfigWoaCdn : logoMenuConfigCdn; + fetch(menuCdn) + .then((res) => res.json()) + .then((menuList) => { + // 整理 menu 字段 + menuList.forEach((menu) => { + menu.target = '_blank'; + menu.children.forEach((child) => { + if (child.url.includes('tdesign')) { + child.target = '_self'; + } else { + child.target = '_blank'; + } + }); + }); + Object.assign(host, { menuList }); + }); + }, + }, render: ({ menuList }) => html`