diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index f68a3b374..ca98f1333 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -28,6 +28,6 @@ jobs: cache: pnpm registry-url: https://registry.npmjs.org/ - run: pnpm install && pnpm run build - - run: npm publish + - run: npm publish --tag latest env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.gitignore b/.gitignore index a81486cfb..6fc2ef2f7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ /docs/node_modules .npmrc + +.DS_Store diff --git a/docs/.vitepress/config/index.js b/docs/.vitepress/config/index.js index 3547d7e88..6b40c7b02 100644 --- a/docs/.vitepress/config/index.js +++ b/docs/.vitepress/config/index.js @@ -1,3 +1,4 @@ +import { fileURLToPath, URL } from 'node:url' import fs from 'fs' import path from 'path' import { defineConfig } from 'vitepress' @@ -18,6 +19,16 @@ function config () { }, define: { 'process.env': JSON.stringify(process.env) + }, + resolve: { + alias: [ + { + find: /^.*\/VPNavBarTitle\.vue$/, + replacement: fileURLToPath( + new URL('../../@components/NavbarTitle.vue', import.meta.url) + ) + } + ] } }, cleanUrls: true, @@ -37,7 +48,7 @@ function config () { languages: ['js', 'jsx', 'ts', 'tsx'] }, head: [ - ['link', { rel: 'icon', type: 'image/svg+xml', href: '/images/logo.svg' }], + ['link', { rel: 'icon', type: 'image/x-icon', href: '/images/fav.png' }], ['script', {}, `${klinecharts}`], [ 'script', diff --git a/docs/.vitepress/config/share.js b/docs/.vitepress/config/share.js index c0241a5a9..eac2fa740 100644 --- a/docs/.vitepress/config/share.js +++ b/docs/.vitepress/config/share.js @@ -49,6 +49,8 @@ export function getInstanceApiMenus (lang = '') { { text: 'setRightMinVisibleBarCount', link: `${prefix}/setRightMinVisibleBarCount` }, { text: 'setBarSpace', link: `${prefix}/setBarSpace` }, { text: 'getBarSpace', link: `${prefix}/getBarSpace` }, + { text: 'setBarSpaceLimit', link: `${prefix}/setBarSpaceLimit` }, + { text: 'getBarSpaceLimit', link: `${prefix}/getBarSpaceLimit` }, { text: 'setSymbol', link: `${prefix}/setSymbol` }, { text: 'getSymbol', link: `${prefix}/getSymbol` }, { text: 'setPeriod', link: `${prefix}/setPeriod` }, @@ -67,10 +69,10 @@ export function getInstanceApiMenus (lang = '') { { text: 'removeOverlay', link: `${prefix}/removeOverlay` }, { text: 'setPaneOptions', link: `${prefix}/setPaneOptions` }, { text: 'getPaneOptions', link: `${prefix}/getPaneOptions` }, - { text: 'setZoomEnabled', link: `${prefix}/setZoomEnabled` }, { text: 'setZoomAnchor', link: `${prefix}/setZoomAnchor` }, - { text: 'isZoomEnabled', link: `${prefix}/isZoomEnabled` }, { text: 'getZoomAnchor', link: `${prefix}/getZoomAnchor` }, + { text: 'setZoomEnabled', link: `${prefix}/setZoomEnabled` }, + { text: 'isZoomEnabled', link: `${prefix}/isZoomEnabled` }, { text: 'setScrollEnabled', link: `${prefix}/setScrollEnabled` }, { text: 'isScrollEnabled', link: `${prefix}/isScrollEnabled` }, { text: 'scrollByDistance', link: `${prefix}/scrollByDistance` }, diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css index 202e8f68b..697bfe3e4 100644 --- a/docs/.vitepress/theme/style.css +++ b/docs/.vitepress/theme/style.css @@ -17,17 +17,17 @@ :root { --light-c-text-1: #09090B; --light-c-text-2: #71717A; - --light-c-text-3: #71717A; + --light-c-text-3: #A1A1AA; --light-c-bg: #FFFFFF; --dark-c-text-1: #FAFAFA; --dark-c-text-2: #A1A1AA; - --dark-c-text-3: #A1A1AA; + --dark-c-text-3: #828282; --dark-c-bg: #09090B; --vp-c-indigo-1: #E6AC00; - --vp-c-indigo-2: #d6ac2e; - --vp-c-indigo-3: #c9aa4e; + --vp-c-indigo-2: #ebbc33; + --vp-c-indigo-3: #f0cd66; --vp-c-text-1: var(--light-c-text-1); --vp-c-text-2: var(--light-c-text-2); @@ -41,22 +41,12 @@ --vp-c-indigo-soft: rgb(22, 119, 255, 0.14); - --custom-red: #F92855; - --custom-green: #2DC08E; - --vp-c-bg-soft: #F5F5F5; --vp-code-bg: var(--vp-c-bg-soft); --vp-code-color: var(--vp-c-text-1); --vp-nav-height: 60px; - --vp-button-brand-border: var(--vp-c-indigo-2); - --vp-button-brand-bg: var(--vp-c-indigo-1); - --vp-button-brand-hover-border: var(--vp-c-indigo-2); - --vp-button-brand-hover-bg: var(--vp-c-indigo-2); - --vp-button-brand-active-border: var(--vp-c-indigo-2); - --vp-button-brand-active-bg: var(--vp-button-brand-bg); - --vp-sidebar-bg-color: var(--vp-c-bg); --vp-c-divider: #EFEFEF; --vp-c-border: var(--vp-c-divider); @@ -66,7 +56,8 @@ --vp-font-family-mono: SourceCode, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; --vp-font-family-base: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Arial", "sans-serif"; - --vp-home-hero-bg: linear-gradient(180deg, rgba(238, 238, 238, 0) 0%, rgba(234, 204, 117, 0.2) 52%, rgba(230, 172, 0, 0) 100%); + --custom-c-warn: #E6AC00; + --vp-custom-block-warning-bg: #f5dd99; } .dark { @@ -79,18 +70,18 @@ --vp-c-divider: #27272A; --vp-c-bg-alt: #161616; + --vp-c-bg-elv: #161616; --vp-c-bg-soft: #262626; --vp-local-search-bg: var(--vp-c-bg-alt); - - --vp-home-hero-bg: linear-gradient(180deg, rgba(238, 238, 238, 0) 0%, rgba(234, 204, 117, 0.15) 52%, rgba(230, 172, 0, 0) 100%); } body { font-feature-settings: normal; font-variation-settings: normal; line-height: 1.6; + overflow: hidden; } .VPFeatures .VPFeature { diff --git a/docs/@components/ChartPreview.vue b/docs/@components/ChartPreview.vue index f0170f832..be9fe8ffa 100644 --- a/docs/@components/ChartPreview.vue +++ b/docs/@components/ChartPreview.vue @@ -23,7 +23,6 @@ import SmoothExpand from './SmoothExpand.vue' const { isDark, lang } = useData() - const href = ref() const props = defineProps(['title', 'chartId', 'chartHeight', 'code']) @@ -33,6 +32,7 @@ const loading = ref(true) const showCode = ref(!props.chartId) const chartContainer = ref(null) +const chartInitializedFlag = ref(false) const observer = ref(null) const codeHtml = ref(null) @@ -166,50 +166,58 @@ onMounted(() => { defaultColor: 'light' }) } + if (props.code) { highlightCode() if (!!props.chartId) { - const transformJs = props.code + '\n' + `window['chart_${props.chartId}'] = chart` - const ast = parse(transformJs, { sourceType: 'module' }) - - traverse(ast, { - CallExpression(path) { - if ( - t.isCallExpression(path.node) && - t.isIdentifier(path.node.callee, { name: 'callback' }) - ) { - const postMessageFun = t.expressionStatement( - t.callExpression( - t.memberExpression(t.identifier('window'), t.identifier('postMessage')), - [t.stringLiteral(props.chartId)] - ) - ) - path.insertBefore(postMessageFun) - } - } - }) - window.addEventListener('message', handlerMessage, false); - - const { code } = transform(generator(ast, {}, transformJs).code, { - presets: [ - 'es2015', - ['stage-3', { decoratorsBeforeExport: true }], - ], - plugins: ['transform-modules-umd'], - }) - const chartDom = document.createElement('div') - const height = `${props.chartHeight || 350}px` - chartDom.style.height = height - chartDom.id = props.chartId - chartContainer.value.appendChild(chartDom) - const script = document.createElement('script') - script.innerHTML = code - chartContainer.value.appendChild(script) - window[`chart_${props.chartId}`].setStyles(isDark.value ? 'dark' : 'light') - observer.value = new ResizeObserver(_ => { - window[`chart_${props.chartId}`].resize() + if (!chartInitializedFlag.value) { + const bounding = chartContainer.value.getBoundingClientRect() + if (bounding.width === 0 || bounding.height === 0) { + return + } + chartInitializedFlag.value = true + const transformJs = props.code + '\n' + `window['chart_${props.chartId}'] = chart` + const ast = parse(transformJs, { sourceType: 'module' }) + + traverse(ast, { + CallExpression(path) { + if ( + t.isCallExpression(path.node) && + t.isIdentifier(path.node.callee, { name: 'callback' }) + ) { + const postMessageFun = t.expressionStatement( + t.callExpression( + t.memberExpression(t.identifier('window'), t.identifier('postMessage')), + [t.stringLiteral(props.chartId)] + ) + ) + path.insertBefore(postMessageFun) + } + } + }) + + const { code } = transform(generator(ast, {}, transformJs).code, { + presets: [ + 'es2015', + ['stage-3', { decoratorsBeforeExport: true }], + ], + plugins: ['transform-modules-umd'], + }) + const chartDom = document.createElement('div') + const height = `${props.chartHeight || 350}px` + chartDom.style.height = height + chartDom.id = props.chartId + chartContainer.value.appendChild(chartDom) + const script = document.createElement('script') + script.innerHTML = code + chartContainer.value.appendChild(script) + window[`chart_${props.chartId}`].setStyles(isDark.value ? 'dark' : 'light') + } else { + window[`chart_${props.chartId}`]?.resize() + } + }) observer.value.observe(chartContainer.value) } @@ -229,7 +237,7 @@ watch(isDark, (newValue) => { onUnmounted(() => { if (!!props.chartId) { if (observer.value && chartContainer.value) { - observer.value.unobserve(chartContainer.value) + observer.value.unobserve(chartContainer.value) } if (window.klinecharts) { window.klinecharts.dispose(props.chartId) @@ -245,7 +253,7 @@ onUnmounted(() => {
- +
-
+
- diff --git a/docs/@components/Logo.vue b/docs/@components/Logo.vue new file mode 100644 index 000000000..04b729ff8 --- /dev/null +++ b/docs/@components/Logo.vue @@ -0,0 +1,21 @@ + + + + diff --git a/docs/@components/NavbarTitle.vue b/docs/@components/NavbarTitle.vue new file mode 100644 index 000000000..324b31324 --- /dev/null +++ b/docs/@components/NavbarTitle.vue @@ -0,0 +1,124 @@ + + + + + diff --git a/docs/@components/Particle.vue b/docs/@components/Particle.vue new file mode 100644 index 000000000..f544a895a --- /dev/null +++ b/docs/@components/Particle.vue @@ -0,0 +1,121 @@ + + + + + \ No newline at end of file diff --git a/docs/@components/Tip.vue b/docs/@components/Tip.vue new file mode 100644 index 000000000..f6d3c9305 --- /dev/null +++ b/docs/@components/Tip.vue @@ -0,0 +1,97 @@ + + + + + \ No newline at end of file diff --git a/docs/@i18n/en-US.json b/docs/@i18n/en-US.json index 0b6b41c26..fbd34f2e3 100644 --- a/docs/@i18n/en-US.json +++ b/docs/@i18n/en-US.json @@ -1,7 +1,7 @@ { "view_banner_tip": "⚠️ Currently, the v10 alpha version is unstable, so it is recommended to use the 9.x version first.", - "view_home_hero_title": "Highly customizable professional lightweight financial chart", - "view_home_hero_desc": "Easy to use, lightweight and smooth, suitable for web front-end financial chart with rich scenarios.", + "view_home_hero_title": "Highly customizable professional financial chart", + "view_home_hero_desc": "Easy to use, lightweight and smooth, a perfect financial data visualization solution.", "view_home_hero_button": "Getting Started", "view_home_top_sponsor": "Top Sponsor", "view_home_quick_create_chart_title": "Create chart easily and quickly", diff --git a/docs/@i18n/zh-CN.json b/docs/@i18n/zh-CN.json index aa6cdba34..fd7d6dd4b 100644 --- a/docs/@i18n/zh-CN.json +++ b/docs/@i18n/zh-CN.json @@ -1,7 +1,7 @@ { "view_banner_tip": "⚠️ 目前 v10 alpha 版本不稳定,建议还是优先使用 9.x 版本。", "view_home_hero_title": "可高度自定义的专业级轻量金融图表", - "view_home_hero_desc": "简单易用,轻量流畅,适用场景丰富的 Web 前端金融图表。", + "view_home_hero_desc": "简单易用,轻量流畅,完美的金融数据可视化方案。", "view_home_hero_button": "快速开始", "view_home_top_sponsor": "顶级赞助商", "view_home_quick_create_chart_title": "简单快速创建图表", diff --git a/docs/@views/Banner.vue b/docs/@views/Banner.vue index 23756a2de..e2d3dec3d 100644 --- a/docs/@views/Banner.vue +++ b/docs/@views/Banner.vue @@ -49,10 +49,9 @@ onMounted(() => { background-color: var(--vp-c-bg); overflow: hidden; margin: 0; - color: var(--vp-c-indigo-1); + color: #E6AC00; font-size: 12px; border-bottom: solid 1px var(--vp-c-gutter); - transition: background-color 0.15s; } .banner span { diff --git a/docs/@views/ColorPalette.vue b/docs/@views/ColorPalette.vue new file mode 100644 index 000000000..13e52ddbe --- /dev/null +++ b/docs/@views/ColorPalette.vue @@ -0,0 +1,174 @@ + + + + + + diff --git a/docs/@views/Layout.vue b/docs/@views/Layout.vue index ebe284e10..f315fd85c 100644 --- a/docs/@views/Layout.vue +++ b/docs/@views/Layout.vue @@ -1,7 +1,7 @@