Skip to content

Commit

Permalink
chore: release 0.15.3 (#497)
Browse files Browse the repository at this point in the history
* chore: top content

* chore: release 0.15.3
  • Loading branch information
uyarn authored May 23, 2024
1 parent 05a423b commit 30b0872
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
2 changes: 2 additions & 0 deletions packages/components/config/index.js
Original file line number Diff line number Diff line change
@@ -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';
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tdesign-site-components",
"version": "0.15.2",
"version": "0.15.3",
"main": "lib/site.es.js",
"scripts": {
"dev": "vite",
Expand Down
77 changes: 36 additions & 41 deletions packages/components/src/components/td-logo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,16 @@
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';
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` <div class="list">
${list.map(
Expand All @@ -61,11 +27,17 @@ function renderList(list = []) {
</div>`;
}

function renderMenu() {
const len = navList.length;
return navList.map(
function renderMenu(list) {
const len = list.length;
return list.map(
(item, index) => html`
<span class="title"> ${item.title} </span>
${item.category_url
? html`
<a href="${item.category_url}" class="title" target="${item.target}">
${item.category_title} <i innerHTML="${chevronRightIcon}"></i>
</a>
`
: html` <span class="title"> ${item.category_title} </span> `}
${renderList(item.children)} ${index < len - 1 ? html`<div class="line"></div>` : html``}
`,
);
Expand All @@ -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`
<style>
${style}
Expand Down

0 comments on commit 30b0872

Please sign in to comment.