Skip to content

Commit cab4bc9

Browse files
authored
fix(site): the aurora-theme switch function is added to the official website (#2604)
* fix(site): fix * fix(theme): add aurora theme of build scripts * fix(site): add aurora-theme's route * fix(tooltip): fix
1 parent c53a740 commit cab4bc9

File tree

8 files changed

+40
-9
lines changed

8 files changed

+40
-9
lines changed

examples/sites/demos/pc/webdoc/theme.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ themeTool.changeTheme(
103103
)
104104
```
105105

106-
<!-- ## OLD主题配置
106+
## OLD主题配置
107107

108-
我们不建议用户继续使用旧主题,但对于历史项目,我们提供一组旧主题的`CSS变量`,需要用户在工程中适配。
108+
我们不建议用户继续使用旧主题,对于历史项目,我们提供一组旧主题的`CSS变量`,需要用户在工程中适配。
109109

110110
```ts
111111
import TinyThemeTool, { tinyOldTheme } from '@opentiny/vue-theme/theme-tool'
@@ -116,8 +116,9 @@ const themeTool = new TinyThemeTool(tinyOldTheme)
116116
```
117117

118118
<div class="warning custom-block">
119-
旧主题不能 100% 还原历史版本的所有细节,如果用户升级后有较大的影响,可以跟我们反馈,也可以回退使用<code> @opentiny/vue@3.18.0 </code> 版本。
120-
</div> -->
119+
<p> 旧主题不能 100% 还原历史版本的所有细节,如果用户升级后有较大的影响,可以跟我们反馈,也可以回退使用<code> @opentiny/vue@3.18.0 </code> 版本。</p>
120+
<p> 如果需要切换 <code>Aurora</code> 主题,可以从上面导出 <code>tinyAuroraTheme</code> 的主题。 </p>
121+
</div>
121122

122123
## 历史版本的主题配置
123124

examples/sites/src/tools/useTheme.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import oceanicIcon from '@/assets/images/oceanic-icon.png'
1616

1717
import starrySky from '@/assets/images/starry-sky.png'
1818
import starrySkyIcon from '@/assets/images/starry-sky-icon.png'
19-
import TinyThemeTool, { tinyOldTheme } from '@opentiny/vue-theme/theme-tool'
19+
import TinyThemeTool, { tinyOldTheme, tinyAuroraTheme } from '@opentiny/vue-theme/theme-tool'
2020

2121
const isEn = appData.lang === 'enUS'
2222

@@ -106,6 +106,11 @@ const watchRoute = () => {
106106
themeTool.changeTheme(tinyOldTheme)
107107
loadedTheme = true
108108
}
109+
if (!loadedTheme && val === 'aurora-theme') {
110+
const themeTool = new TinyThemeTool()
111+
themeTool.changeTheme(tinyAuroraTheme)
112+
loadedTheme = true
113+
}
109114
}
110115
)
111116
}

packages/theme/build/gulp-dist.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function concatIndex(cb) {
3333
// 2、拼接所有组件的 old-theme.less 到一起 old-theme-index.less
3434
function concatOldTheme(cb) {
3535
_concatFiles('../src/*/old-theme.less', '../src/old-theme-index.less')
36+
_concatFiles('../src/*/aurora-theme.less', '../src/aurora-theme-index.less')
3637
cb()
3738
}
3839
// 3、编译
@@ -41,7 +42,8 @@ gulp.task('compile', () => {
4142
.src([
4243
`${source}/**/index.less`, // 编译默认主题
4344
`${source}/index.less`,
44-
`${source}/old-theme-index.less` // 编译旧主题
45+
`${source}/old-theme-index.less`, // 编译旧主题
46+
`${source}/aurora-theme-index.less` // 编译aurora主题
4547
])
4648
.pipe(svgInline(svgInlineOption))
4749
.pipe(less())

packages/theme/build/release.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ jsStr = jsStr.replace('#CSS#', cssStr)
2323
fs.writeFileSync(path.resolve(root, 'src/old-theme-index.js'), jsStr) // 供开发时(pnpm site), 可以访问到最新的定制主题变量
2424
fs.writeFileSync(path.resolve(root, 'dist/old-theme-index.js'), jsStr) // 打包发布用
2525

26+
// 2.1、读取 aurora-theme-index.js , dist/aurora-theme-index.less, 合并后写入 dist/ aurora-theme-index.js
27+
jsStr = `
28+
export default {
29+
id: 'tiny-aurora-theme',
30+
name: 'AuroraTheme',
31+
cnName: '欧若拉主题',
32+
css: \`#CSS#\`
33+
}
34+
`
35+
cssStr = fs.readFileSync(path.resolve(root, 'dist/aurora-theme-index.css'), 'utf8')
36+
37+
jsStr = jsStr.replace('#CSS#', cssStr)
38+
fs.writeFileSync(path.resolve(root, 'src/aurora-theme-index.js'), jsStr) // 供开发时(pnpm site), 可以访问到最新的定制主题变量
39+
fs.writeFileSync(path.resolve(root, 'dist/aurora-theme-index.js'), jsStr) // 打包发布用
40+
2641
// 3、复制 package.json
2742
const content = fs.readFileSync(path.resolve(root, 'package.json'), 'utf8')
2843
const packageJson = JSON.parse(content)

packages/theme/src/aurora-theme-index.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import './base/aurora-theme.less';

packages/theme/src/theme-tool.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import tinyOldTheme from './old-theme-index.js'
2+
import tinyAuroraTheme from './aurora-theme-index.js'
23

3-
export { tinyOldTheme }
4+
export { tinyOldTheme, tinyAuroraTheme }
45

56
/**
67
* 动态切换文档或影子根节点的样式类

packages/theme/src/tooltip/vars.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@
7070
// 弹框阴影
7171
--tv-Tooltip-box-shadow: var(--tv-shadow-2-down);
7272
// 弹框垂直内边距
73-
--tv-Tooltip-padding-y: 12px;
73+
--tv-Tooltip-padding-y: var(--tv-space-lg);
7474
// 弹框水平内边距
75-
--tv-Tooltip-padding-x: 16px;
75+
--tv-Tooltip-padding-x: var(--tv-space-xl);
7676
// 文字提示错误图标色
7777
--tv-Tooltip-validate-icon-color: var(--tv-color-error-icon);
7878
// 文本内容容器最大高度

0 commit comments

Comments
 (0)