@varlet/cli 2.20.5 → 3.0.0-alpha.1704352780759
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/index.d.ts +3 -2
- package/lib/client/index.js +20 -11
- package/lib/node/config/varlet.config.d.ts +4 -0
- package/lib/node/config/varlet.default.config.js +152 -8
- package/package.json +15 -15
- package/site/mobile/App.vue +63 -23
- package/site/pc/Layout.vue +1 -1
- package/site/pc/components/AppHeader.vue +91 -48
- package/site/pc/components/code-example/CodeExample.vue +1 -1
- package/site/pc/components/code-example/codeExample.less +1 -1
- package/site/pc/pages/index/index.vue +10 -9
- package/site/utils.ts +0 -6
- package/template/generators/base/package.json +2 -2
- package/template/generators/config/i18n/base/varlet.config.mjs +1 -1
package/lib/client/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ interface PCLocationInfo {
|
|
|
5
5
|
menuName: string;
|
|
6
6
|
hash: string;
|
|
7
7
|
}
|
|
8
|
-
export type Theme = 'lightTheme' | 'darkTheme';
|
|
8
|
+
export type Theme = 'lightTheme' | 'darkTheme' | 'md3LightTheme' | 'md3DarkTheme';
|
|
9
9
|
export type StyleVars = Record<string, string>;
|
|
10
10
|
export declare function getPCLocationInfo(): PCLocationInfo;
|
|
11
11
|
export declare function getBrowserTheme(): Theme;
|
|
@@ -13,7 +13,8 @@ export declare function watchLang(cb: (lang: string) => void, platform?: 'pc' |
|
|
|
13
13
|
export declare function withSiteConfigNamespace(styleVars: Record<string, any>): StyleVars;
|
|
14
14
|
export declare function watchPlatform(cb: (platform: string) => void): void;
|
|
15
15
|
export declare function useRouteListener(cb: () => void): void;
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function setTheme(theme: Theme): void;
|
|
17
|
+
export declare function onThemeChange(cb?: (theme: Theme) => void): void;
|
|
17
18
|
export declare function getSiteStyleVars(theme: Theme): StyleVars;
|
|
18
19
|
export declare function setColorScheme(theme: Theme): void;
|
|
19
20
|
export declare function watchTheme(cb: (theme: Theme, from: 'pc' | 'mobile' | 'default' | 'playground') => void, shouldUnmount?: boolean): void;
|
package/lib/client/index.js
CHANGED
|
@@ -19,13 +19,13 @@ function getHashSearch() {
|
|
|
19
19
|
}
|
|
20
20
|
export function getBrowserTheme() {
|
|
21
21
|
const themeKey = get(config, 'themeKey');
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
return 'lightTheme';
|
|
25
|
-
}
|
|
22
|
+
const defaultLightTheme = get(config, 'defaultLightTheme');
|
|
23
|
+
const defaultDarkTheme = get(config, 'defaultDarkTheme');
|
|
26
24
|
const storageTheme = window.localStorage.getItem(themeKey);
|
|
27
25
|
if (!storageTheme) {
|
|
28
|
-
const preferTheme = window.matchMedia?.('(prefers-color-scheme: dark)').matches
|
|
26
|
+
const preferTheme = window.matchMedia?.('(prefers-color-scheme: dark)').matches
|
|
27
|
+
? defaultDarkTheme
|
|
28
|
+
: defaultLightTheme;
|
|
29
29
|
window.localStorage.setItem(themeKey, preferTheme);
|
|
30
30
|
return preferTheme;
|
|
31
31
|
}
|
|
@@ -63,12 +63,21 @@ export function useRouteListener(cb) {
|
|
|
63
63
|
window.removeEventListener('popstate', cb);
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
const themeMap = {
|
|
67
|
+
lightTheme: null,
|
|
68
|
+
darkTheme: Themes.dark,
|
|
69
|
+
md3LightTheme: Themes.md3Light,
|
|
70
|
+
md3DarkTheme: Themes.md3Dark,
|
|
71
|
+
};
|
|
72
|
+
export function setTheme(theme) {
|
|
73
|
+
const siteStyleVars = withSiteConfigNamespace(get(config, theme, {}));
|
|
74
|
+
const styleVars = { ...siteStyleVars, ...(themeMap[theme] ?? {}) };
|
|
75
|
+
StyleProvider(styleVars);
|
|
76
|
+
setColorScheme(theme);
|
|
77
|
+
}
|
|
78
|
+
export function onThemeChange(cb) {
|
|
67
79
|
watchTheme((theme) => {
|
|
68
|
-
|
|
69
|
-
const darkStyleVars = { ...siteStyleVars, ...Themes.dark, ...dark };
|
|
70
|
-
StyleProvider(theme === 'darkTheme' ? darkStyleVars : siteStyleVars);
|
|
71
|
-
setColorScheme(theme);
|
|
80
|
+
setTheme(theme);
|
|
72
81
|
cb?.(theme);
|
|
73
82
|
});
|
|
74
83
|
}
|
|
@@ -76,7 +85,7 @@ export function getSiteStyleVars(theme) {
|
|
|
76
85
|
return withSiteConfigNamespace(get(config, theme, {}));
|
|
77
86
|
}
|
|
78
87
|
export function setColorScheme(theme) {
|
|
79
|
-
document.documentElement.style.setProperty('color-scheme', theme
|
|
88
|
+
document.documentElement.style.setProperty('color-scheme', theme.toLowerCase().includes('dark') ? 'dark' : 'light');
|
|
80
89
|
}
|
|
81
90
|
export function watchTheme(cb, shouldUnmount = true) {
|
|
82
91
|
const handleThemeChange = (event) => {
|
|
@@ -70,6 +70,10 @@ export interface VarletConfig {
|
|
|
70
70
|
useMobile?: boolean;
|
|
71
71
|
lightTheme?: Record<string, string>;
|
|
72
72
|
darkTheme?: Record<string, string>;
|
|
73
|
+
md3LightTheme?: Record<string, string>;
|
|
74
|
+
md3DarkTheme?: Record<string, string>;
|
|
75
|
+
defaultLightTheme?: 'lightTheme' | 'md3LightTheme';
|
|
76
|
+
defaultDarkTheme?: 'darkTheme' | 'md3DarkTheme';
|
|
73
77
|
highlight?: {
|
|
74
78
|
style: string;
|
|
75
79
|
};
|
|
@@ -418,11 +418,48 @@ export default defineConfig({
|
|
|
418
418
|
'zh-CN': '中文',
|
|
419
419
|
'en-US': 'English',
|
|
420
420
|
},
|
|
421
|
-
|
|
421
|
+
currentVersion: 'Latest',
|
|
422
|
+
versions: [
|
|
423
|
+
{
|
|
424
|
+
name: 'varlet.gitee.io',
|
|
425
|
+
items: [
|
|
426
|
+
{
|
|
427
|
+
label: 'Latest',
|
|
428
|
+
link: 'https://varlet.gitee.io/varlet-ui',
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
label: 'v2.x',
|
|
432
|
+
link: 'https://varlet.gitee.io/varlet-ui/v2',
|
|
433
|
+
},
|
|
434
|
+
],
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
name: 'varletjs.vercel.app',
|
|
438
|
+
items: [
|
|
439
|
+
{
|
|
440
|
+
label: 'latest',
|
|
441
|
+
link: 'varlet-varletjs.vercel.app',
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
label: 'v2.x',
|
|
445
|
+
link: 'https://varlet-git-v2x-varletjs.vercel.app',
|
|
446
|
+
},
|
|
447
|
+
],
|
|
448
|
+
},
|
|
449
|
+
],
|
|
422
450
|
github: 'https://github.com/varletjs/varlet',
|
|
423
451
|
changelog: 'https://github.com/varletjs/varlet/blob/main/CHANGELOG.md',
|
|
424
452
|
playground: 'https://varlet.gitee.io/varlet-ui-playground',
|
|
453
|
+
/**
|
|
454
|
+
* @deprecated
|
|
455
|
+
*/
|
|
425
456
|
darkMode: true,
|
|
457
|
+
themes: [
|
|
458
|
+
{ 'zh-CN': 'Md2 亮色', 'en-US': 'Md2 Light', value: 'lightTheme' },
|
|
459
|
+
{ 'zh-CN': 'Md2 暗色', 'en-US': 'Md2 Dark', value: 'darkTheme' },
|
|
460
|
+
{ 'zh-CN': 'Md3 亮色', 'en-US': 'Md3 Light', value: 'md3LightTheme' },
|
|
461
|
+
{ 'zh-CN': 'Md3 暗色', 'en-US': 'Md3 Dark', value: 'md3DarkTheme' },
|
|
462
|
+
],
|
|
426
463
|
},
|
|
427
464
|
clipboard: {
|
|
428
465
|
'zh-CN': '代码已复制到剪切板',
|
|
@@ -444,21 +481,27 @@ export default defineConfig({
|
|
|
444
481
|
'en-US': 'English',
|
|
445
482
|
},
|
|
446
483
|
github: 'https://github.com/varletjs/varlet',
|
|
447
|
-
|
|
484
|
+
themes: [
|
|
485
|
+
{ 'zh-CN': 'Md2 亮色', 'en-US': 'Md2 Light', value: 'lightTheme' },
|
|
486
|
+
{ 'zh-CN': 'Md2 暗色', 'en-US': 'Md2 Dark', value: 'darkTheme' },
|
|
487
|
+
{ 'zh-CN': 'Md3 亮色', 'en-US': 'Md3 Light', value: 'md3LightTheme' },
|
|
488
|
+
{ 'zh-CN': 'Md3 暗色', 'en-US': 'Md3 Dark', value: 'md3DarkTheme' },
|
|
489
|
+
],
|
|
448
490
|
},
|
|
449
491
|
},
|
|
450
492
|
themeKey: 'VARLET_THEME',
|
|
493
|
+
defaultLightTheme: 'md3LightTheme',
|
|
494
|
+
defaultDarkTheme: 'md3DarkTheme',
|
|
451
495
|
lightTheme: {
|
|
452
496
|
'color-body': '#fff',
|
|
453
497
|
'color-index-page-background': '#fff',
|
|
454
498
|
'color-index-page-get-started-button': '#3a7afe',
|
|
455
|
-
'color-index-page-github-button': '#212121',
|
|
456
|
-
'color-index-page-feature-background': '#fff',
|
|
457
499
|
'color-index-page-logo-mask-background': 'linear-gradient(-45deg, #8baff8 50%, #84e0ff 50%)',
|
|
458
500
|
'color-index-page-second-text-color': 'rgba(60, 60, 60, .7)',
|
|
459
501
|
'color-index-page-divider-color': '#ddd',
|
|
502
|
+
'card-border-radius': '12px',
|
|
503
|
+
'code-example-border-radius': '8px',
|
|
460
504
|
'color-bar': '#fff',
|
|
461
|
-
'color-sub-bar': '#f5f5f5',
|
|
462
505
|
'color-text': '#555',
|
|
463
506
|
'color-sub-text': '#888',
|
|
464
507
|
'color-border': 'rgba(0, 0, 0, 0.12)',
|
|
@@ -477,6 +520,11 @@ export default defineConfig({
|
|
|
477
520
|
'color-pc-language-active-background': '#edf5ff',
|
|
478
521
|
'color-mobile-language-active': '#3a7afe',
|
|
479
522
|
'color-mobile-language-active-background': '#edf5ff',
|
|
523
|
+
'color-pc-theme-active': '#3a7afe',
|
|
524
|
+
'color-pc-theme-active-background': '#edf5ff',
|
|
525
|
+
'color-mobile-theme-active': '#3a7afe',
|
|
526
|
+
'color-mobile-theme-active-background': '#edf5ff',
|
|
527
|
+
'color-mobile-body': '#fff',
|
|
480
528
|
'color-hl-background': '#fafafa',
|
|
481
529
|
'color-hl-code': '#58727e',
|
|
482
530
|
'color-hl-border': '#f3f3f3',
|
|
@@ -493,14 +541,13 @@ export default defineConfig({
|
|
|
493
541
|
darkTheme: {
|
|
494
542
|
'color-body': '#121212',
|
|
495
543
|
'color-index-page-background': '#1e1e1e',
|
|
496
|
-
'color-index-page-get-started-button': '#4a7afe',
|
|
497
|
-
'color-index-page-github-button': '#303030',
|
|
498
544
|
'color-index-page-feature-background': '#303030',
|
|
499
545
|
'color-index-page-logo-mask-background': 'linear-gradient(-45deg, #729dfc 50%, #6859f4 50%)',
|
|
500
546
|
'color-index-page-second-text-color': 'rgba(255, 255, 255, .75)',
|
|
501
547
|
'color-index-page-divider-color': 'rgba(84, 84, 84, .8)',
|
|
548
|
+
'card-border-radius': '12px',
|
|
549
|
+
'code-example-border-radius': '8px',
|
|
502
550
|
'color-bar': '#1e1e1e',
|
|
503
|
-
'color-sub-bar': '#272727',
|
|
504
551
|
'color-text': '#fff',
|
|
505
552
|
'color-sub-text': '#aaa',
|
|
506
553
|
'color-border': '#333',
|
|
@@ -519,6 +566,11 @@ export default defineConfig({
|
|
|
519
566
|
'color-pc-language-active-background': '#4a7afe20',
|
|
520
567
|
'color-mobile-language-active': '#4a7afe',
|
|
521
568
|
'color-mobile-language-active-background': '#4a7afe20',
|
|
569
|
+
'color-pc-theme-active': '#4a7afe',
|
|
570
|
+
'color-pc-theme-active-background': '#4a7afe20',
|
|
571
|
+
'color-mobile-theme-active': '#4a7afe',
|
|
572
|
+
'color-mobile-theme-active-background': '#4a7afe20',
|
|
573
|
+
'color-mobile-body': '#1e1e1e',
|
|
522
574
|
'color-hl-background': '#272727',
|
|
523
575
|
'color-hl-code': '#fff',
|
|
524
576
|
'color-hl-border': '#272727',
|
|
@@ -532,6 +584,98 @@ export default defineConfig({
|
|
|
532
584
|
'color-hl-group-h': '#14a6e9',
|
|
533
585
|
'color-hl-group-i': '#96cbfe',
|
|
534
586
|
},
|
|
587
|
+
md3LightTheme: {
|
|
588
|
+
'color-body': '#fff',
|
|
589
|
+
'color-index-page-background': '#fff',
|
|
590
|
+
'color-index-page-feature-background': '#fff',
|
|
591
|
+
'color-index-page-logo-mask-background': 'linear-gradient(-45deg, #8baff8 50%, #84e0ff 50%)',
|
|
592
|
+
'color-index-page-second-text-color': 'rgba(60, 60, 60, .7)',
|
|
593
|
+
'color-index-page-divider-color': '#ddd',
|
|
594
|
+
'card-border-radius': '12px',
|
|
595
|
+
'code-example-border-radius': '8px',
|
|
596
|
+
'color-bar': '#fff',
|
|
597
|
+
'color-text': '#555',
|
|
598
|
+
'color-sub-text': '#888',
|
|
599
|
+
'color-border': 'rgba(0, 0, 0, 0.12)',
|
|
600
|
+
'color-shadow': '#eee',
|
|
601
|
+
'color-introduce-border': '#6750A4',
|
|
602
|
+
'color-primary': '#6750A4',
|
|
603
|
+
'color-link': '#21005D',
|
|
604
|
+
'color-type': '#21005D',
|
|
605
|
+
'color-loading-bar': '#6750A4',
|
|
606
|
+
'color-side-bar': '#6750A4',
|
|
607
|
+
'color-side-bar-active-background': '#E8DEF8',
|
|
608
|
+
'color-app-bar': '#6750A4',
|
|
609
|
+
'color-nav-button-hover-background': 'rgba(0, 0, 0, 0.08)',
|
|
610
|
+
'color-mobile-cell-hover': '#6750A4',
|
|
611
|
+
'color-pc-language-active': '#6750A4',
|
|
612
|
+
'color-pc-language-active-background': '#E8DEF8',
|
|
613
|
+
'color-mobile-language-active': '#6750A4',
|
|
614
|
+
'color-mobile-language-active-background': '#E8DEF8',
|
|
615
|
+
'color-pc-theme-active': '#6750A4',
|
|
616
|
+
'color-pc-theme-active-background': '#E8DEF8',
|
|
617
|
+
'color-mobile-theme-active': '#6750A4',
|
|
618
|
+
'color-mobile-theme-active-background': '#E8DEF8',
|
|
619
|
+
'color-mobile-body': '#FEF7FF',
|
|
620
|
+
'color-hl-background': '#fafafa',
|
|
621
|
+
'color-hl-code': '#58727e',
|
|
622
|
+
'color-hl-border': '#f3f3f3',
|
|
623
|
+
'color-hl-group-a': '#7c7c7c',
|
|
624
|
+
'color-hl-group-b': '#6750A4',
|
|
625
|
+
'color-hl-group-c': '#7D5260',
|
|
626
|
+
'color-hl-group-d': '#B3261E',
|
|
627
|
+
'color-hl-group-e': '#7D5260',
|
|
628
|
+
'color-hl-group-f': '#7D5260',
|
|
629
|
+
'color-hl-group-g': '#7D5260',
|
|
630
|
+
'color-hl-group-h': '#633B48',
|
|
631
|
+
'color-hl-group-i': '#633B48',
|
|
632
|
+
},
|
|
633
|
+
md3DarkTheme: {
|
|
634
|
+
'color-body': '#050505',
|
|
635
|
+
'color-index-page-background': '#1e1e1e',
|
|
636
|
+
'color-index-page-feature-background': '#303030',
|
|
637
|
+
'color-index-page-logo-mask-background': 'linear-gradient(-45deg, #729dfc 50%, #6859f4 50%)',
|
|
638
|
+
'color-index-page-second-text-color': 'rgba(255, 255, 255, .75)',
|
|
639
|
+
'color-index-page-divider-color': 'rgba(84, 84, 84, .8)',
|
|
640
|
+
'card-border-radius': '12px',
|
|
641
|
+
'code-example-border-radius': '8px',
|
|
642
|
+
'color-bar': '#1e1e1e',
|
|
643
|
+
'color-text': '#fff',
|
|
644
|
+
'color-sub-text': '#aaa',
|
|
645
|
+
'color-border': '#333',
|
|
646
|
+
'color-shadow': '#090909',
|
|
647
|
+
'color-introduce-border': '#555',
|
|
648
|
+
'color-primary': '#D0BCFF',
|
|
649
|
+
'color-link': '#EADDFF',
|
|
650
|
+
'color-type': '#EADDFF',
|
|
651
|
+
'color-loading-bar': '#D0BCFF',
|
|
652
|
+
'color-side-bar': '#D0BCFF',
|
|
653
|
+
'color-side-bar-active-background': '#4A4458',
|
|
654
|
+
'color-app-bar': '#211F26',
|
|
655
|
+
'color-nav-button-hover-background': 'rgba(255, 255, 255, 0.08)',
|
|
656
|
+
'color-mobile-cell-hover': '#D0BCFF',
|
|
657
|
+
'color-pc-language-active': '#D0BCFF',
|
|
658
|
+
'color-pc-language-active-background': '#4A4458',
|
|
659
|
+
'color-mobile-language-active': '#D0BCFF',
|
|
660
|
+
'color-mobile-language-active-background': '#4A4458',
|
|
661
|
+
'color-pc-theme-active': '#D0BCFF',
|
|
662
|
+
'color-pc-theme-active-background': '#4A4458',
|
|
663
|
+
'color-mobile-theme-active': '#D0BCFF',
|
|
664
|
+
'color-mobile-theme-active-background': '#4A4458',
|
|
665
|
+
'color-mobile-body': '#141218',
|
|
666
|
+
'color-hl-background': '#272727',
|
|
667
|
+
'color-hl-code': '#fff',
|
|
668
|
+
'color-hl-border': '#272727',
|
|
669
|
+
'color-hl-group-a': '#7c7c7c',
|
|
670
|
+
'color-hl-group-b': '#D0BCFF',
|
|
671
|
+
'color-hl-group-c': '#EFB8C8',
|
|
672
|
+
'color-hl-group-d': '#F2B8B5',
|
|
673
|
+
'color-hl-group-e': '#EFB8C8',
|
|
674
|
+
'color-hl-group-f': '#EFB8C8',
|
|
675
|
+
'color-hl-group-g': '#EFB8C8',
|
|
676
|
+
'color-hl-group-h': '#EFB8C8',
|
|
677
|
+
'color-hl-group-i': '#EFB8C8',
|
|
678
|
+
},
|
|
535
679
|
icons: {
|
|
536
680
|
name: 'varlet-icons',
|
|
537
681
|
namespace: 'var-icon',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.1704352780759",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"@varlet/release": "^0.1.2",
|
|
38
38
|
"@babel/core": "^7.22.5",
|
|
39
39
|
"@babel/preset-typescript": "^7.22.5",
|
|
40
|
-
"@vitejs/plugin-vue": "5.0.
|
|
40
|
+
"@vitejs/plugin-vue": "5.0.1",
|
|
41
41
|
"@vitejs/plugin-vue-jsx": "3.1.0",
|
|
42
42
|
"@vue/babel-plugin-jsx": "1.1.5",
|
|
43
|
-
"@vue/compiler-sfc": "3.4.
|
|
44
|
-
"@vue/runtime-core": "3.4.
|
|
43
|
+
"@vue/compiler-sfc": "3.4.3",
|
|
44
|
+
"@vue/runtime-core": "3.4.3",
|
|
45
|
+
"vue": "3.4.3",
|
|
45
46
|
"vite": "5.0.10",
|
|
46
|
-
"vue": "3.4.0",
|
|
47
47
|
"esbuild": "0.19.3",
|
|
48
48
|
"vitest": "1.1.0",
|
|
49
49
|
"chokidar": "^3.5.2",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"slash": "^3.0.0",
|
|
65
65
|
"typescript": "^5.1.5",
|
|
66
66
|
"webfont": "11.2.26",
|
|
67
|
-
"@varlet/shared": "
|
|
68
|
-
"@varlet/vite-plugins": "
|
|
67
|
+
"@varlet/shared": "3.0.0-alpha.1704352780759",
|
|
68
|
+
"@varlet/vite-plugins": "3.0.0-alpha.1704352780759"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/babel__core": "^7.20.1",
|
|
@@ -80,12 +80,12 @@
|
|
|
80
80
|
"@types/semver": "^7.3.9",
|
|
81
81
|
"@types/sharp": "0.31.1",
|
|
82
82
|
"rimraf": "^5.0.1",
|
|
83
|
-
"@varlet/ui": "
|
|
84
|
-
"@varlet/icons": "
|
|
85
|
-
"@varlet/touch-emulator": "
|
|
83
|
+
"@varlet/ui": "3.0.0-alpha.1704352780759",
|
|
84
|
+
"@varlet/icons": "3.0.0-alpha.1704352780759",
|
|
85
|
+
"@varlet/touch-emulator": "3.0.0-alpha.1704352780759"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
|
-
"@vue/runtime-core": "3.3
|
|
88
|
+
"@vue/runtime-core": "3.4.3",
|
|
89
89
|
"@vue/test-utils": "2.4.1",
|
|
90
90
|
"@vitest/coverage-istanbul": "1.1.0",
|
|
91
91
|
"vitest": "1.1.0",
|
|
@@ -93,11 +93,11 @@
|
|
|
93
93
|
"clipboard": "^2.0.6",
|
|
94
94
|
"live-server": "^1.2.1",
|
|
95
95
|
"lodash-es": "^4.17.21",
|
|
96
|
-
"vue": "3.3
|
|
96
|
+
"vue": "3.4.3",
|
|
97
97
|
"vue-router": "4.2.0",
|
|
98
|
-
"@varlet/ui": "
|
|
99
|
-
"@varlet/icons": "
|
|
100
|
-
"@varlet/touch-emulator": "
|
|
98
|
+
"@varlet/ui": "3.0.0-alpha.1704352780759",
|
|
99
|
+
"@varlet/icons": "3.0.0-alpha.1704352780759",
|
|
100
|
+
"@varlet/touch-emulator": "3.0.0-alpha.1704352780759"
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
103
|
"dev": "tsc --watch",
|
package/site/mobile/App.vue
CHANGED
|
@@ -20,22 +20,15 @@
|
|
|
20
20
|
</template>
|
|
21
21
|
<template #right>
|
|
22
22
|
<var-button
|
|
23
|
-
v-if="
|
|
23
|
+
v-if="themes.length > 1"
|
|
24
|
+
class="theme-button"
|
|
24
25
|
text
|
|
25
|
-
round
|
|
26
26
|
color="transparent"
|
|
27
27
|
text-color="#fff"
|
|
28
|
-
|
|
29
|
-
transform: languages ? 'translateX(-4px)' : 'translateX(-6px)',
|
|
30
|
-
}"
|
|
31
|
-
@click="toggleTheme"
|
|
28
|
+
@click.stop="showThemeMenu = true"
|
|
32
29
|
>
|
|
33
|
-
<var-icon
|
|
34
|
-
|
|
35
|
-
color="#fff"
|
|
36
|
-
:size="24"
|
|
37
|
-
:name="currentTheme === 'lightTheme' ? 'white-balance-sunny' : 'weather-night'"
|
|
38
|
-
/>
|
|
30
|
+
<var-icon name="palette" :size="28" class="palette"/>
|
|
31
|
+
<var-icon name="chevron-down" class="arrow-down"/>
|
|
39
32
|
</var-button>
|
|
40
33
|
<var-button
|
|
41
34
|
v-if="languages"
|
|
@@ -69,6 +62,21 @@
|
|
|
69
62
|
</var-cell>
|
|
70
63
|
</div>
|
|
71
64
|
</transition>
|
|
65
|
+
|
|
66
|
+
<transition name="site-menu">
|
|
67
|
+
<div class="theme-settings var-elevation--3" v-if="showThemeMenu">
|
|
68
|
+
<var-cell
|
|
69
|
+
v-for="t in themes"
|
|
70
|
+
:key="t.value"
|
|
71
|
+
class="mobile-theme-cell"
|
|
72
|
+
:class="[currentTheme === t.value && 'mobile-theme-cell--active']"
|
|
73
|
+
v-ripple
|
|
74
|
+
@click="toggleTheme(t.value)"
|
|
75
|
+
>
|
|
76
|
+
{{ t[language] }}
|
|
77
|
+
</var-cell>
|
|
78
|
+
</div>
|
|
79
|
+
</transition>
|
|
72
80
|
</div>
|
|
73
81
|
</template>
|
|
74
82
|
|
|
@@ -78,11 +86,12 @@ import { computed, ComputedRef, defineComponent, ref, Ref, watch } from 'vue'
|
|
|
78
86
|
import { useRoute } from 'vue-router'
|
|
79
87
|
import {
|
|
80
88
|
getBrowserTheme,
|
|
81
|
-
type Theme,
|
|
82
89
|
watchLang,
|
|
83
|
-
watchTheme
|
|
90
|
+
watchTheme,
|
|
91
|
+
setTheme,
|
|
92
|
+
type Theme,
|
|
84
93
|
} from '@varlet/cli/client'
|
|
85
|
-
import { removeEmpty,
|
|
94
|
+
import { removeEmpty, inIframe, isPhone } from '../utils'
|
|
86
95
|
import { bigCamelize } from '@varlet/shared'
|
|
87
96
|
import { get } from 'lodash-es'
|
|
88
97
|
|
|
@@ -92,8 +101,10 @@ export default defineComponent({
|
|
|
92
101
|
const route = useRoute()
|
|
93
102
|
const showBackIcon: Ref<boolean> = ref(false)
|
|
94
103
|
const showMenu: Ref<boolean> = ref(false)
|
|
104
|
+
const showThemeMenu: Ref<boolean> = ref(false)
|
|
95
105
|
const language: Ref<string> = ref('')
|
|
96
106
|
const languages: Ref<Record<string, string>> = ref(get(config, 'mobile.header.i18n'))
|
|
107
|
+
const themes: Ref<Record<string, any>[]> = ref(get(config, 'mobile.header.themes'))
|
|
97
108
|
const nonEmptyLanguages: ComputedRef<Record<string, string>> = computed(() => removeEmpty(languages.value))
|
|
98
109
|
const redirect = get(config, 'mobile.redirect', '')
|
|
99
110
|
const github: Ref<string> = ref(get(config, 'mobile.header.github'))
|
|
@@ -144,13 +155,14 @@ export default defineComponent({
|
|
|
144
155
|
|
|
145
156
|
const setCurrentTheme = (theme: Theme) => {
|
|
146
157
|
currentTheme.value = theme
|
|
147
|
-
setTheme(
|
|
158
|
+
setTheme(currentTheme.value)
|
|
148
159
|
window.localStorage.setItem(get(config, 'themeKey'), currentTheme.value)
|
|
149
160
|
}
|
|
150
161
|
|
|
151
|
-
const toggleTheme = () => {
|
|
152
|
-
setCurrentTheme(
|
|
162
|
+
const toggleTheme = (value: Theme) => {
|
|
163
|
+
setCurrentTheme(value)
|
|
153
164
|
window.postMessage(getThemeMessage(), '*')
|
|
165
|
+
showThemeMenu.value = false
|
|
154
166
|
|
|
155
167
|
if (!isPhone() && inIframe()) {
|
|
156
168
|
;(window.top as any).postMessage(getThemeMessage(), '*')
|
|
@@ -158,11 +170,12 @@ export default defineComponent({
|
|
|
158
170
|
}
|
|
159
171
|
|
|
160
172
|
;(window as any).toggleTheme = toggleTheme
|
|
161
|
-
setTheme(
|
|
173
|
+
setTheme(currentTheme.value)
|
|
162
174
|
window.postMessage(getThemeMessage(), '*')
|
|
163
175
|
|
|
164
176
|
document.body.addEventListener('click', () => {
|
|
165
177
|
showMenu.value = false
|
|
178
|
+
showThemeMenu.value = false
|
|
166
179
|
})
|
|
167
180
|
|
|
168
181
|
watchTheme((theme, from) => {
|
|
@@ -175,6 +188,7 @@ export default defineComponent({
|
|
|
175
188
|
github,
|
|
176
189
|
showMenu,
|
|
177
190
|
languages,
|
|
191
|
+
themes,
|
|
178
192
|
language,
|
|
179
193
|
nonEmptyLanguages,
|
|
180
194
|
currentTheme,
|
|
@@ -183,6 +197,7 @@ export default defineComponent({
|
|
|
183
197
|
back,
|
|
184
198
|
changeLanguage,
|
|
185
199
|
toggleTheme,
|
|
200
|
+
showThemeMenu,
|
|
186
201
|
}
|
|
187
202
|
},
|
|
188
203
|
})
|
|
@@ -197,11 +212,11 @@ export default defineComponent({
|
|
|
197
212
|
body {
|
|
198
213
|
margin: 0;
|
|
199
214
|
padding: 0;
|
|
200
|
-
min-height:
|
|
215
|
+
min-height: 100vh;
|
|
201
216
|
font-size: 16px;
|
|
202
217
|
font-family: 'Roboto', sans-serif;
|
|
203
218
|
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
204
|
-
background: var(--site-config-color-
|
|
219
|
+
background: var(--site-config-color-mobile-body);
|
|
205
220
|
color: var(--site-config-color-text);
|
|
206
221
|
transition: background-color 0.25s, color 0.25s;
|
|
207
222
|
}
|
|
@@ -248,6 +263,14 @@ header {
|
|
|
248
263
|
background: var(--site-config-color-bar);
|
|
249
264
|
}
|
|
250
265
|
|
|
266
|
+
.theme-settings {
|
|
267
|
+
position: fixed;
|
|
268
|
+
z-index: 200;
|
|
269
|
+
top: 48px;
|
|
270
|
+
right: 68px;
|
|
271
|
+
background: var(--site-config-color-bar);
|
|
272
|
+
}
|
|
273
|
+
|
|
251
274
|
.router-view__block {
|
|
252
275
|
padding: 55px 15px 15px;
|
|
253
276
|
}
|
|
@@ -263,6 +286,17 @@ header {
|
|
|
263
286
|
}
|
|
264
287
|
}
|
|
265
288
|
|
|
289
|
+
.mobile-theme-cell {
|
|
290
|
+
color: var(--site-config-color-text) !important;
|
|
291
|
+
background: var(--site-config-color-bar) !important;
|
|
292
|
+
cursor: pointer !important;
|
|
293
|
+
|
|
294
|
+
&--active {
|
|
295
|
+
color: var(--site-config-color-mobile-theme-active) !important;
|
|
296
|
+
background: var(--site-config-color-mobile-theme-active-background) !important;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
266
300
|
.arrow-left {
|
|
267
301
|
font-size: 28px !important;
|
|
268
302
|
}
|
|
@@ -271,11 +305,11 @@ header {
|
|
|
271
305
|
font-size: 28px !important;
|
|
272
306
|
}
|
|
273
307
|
|
|
274
|
-
.
|
|
308
|
+
.i18n {
|
|
275
309
|
font-size: 24px !important;
|
|
276
310
|
}
|
|
277
311
|
|
|
278
|
-
.
|
|
312
|
+
.palette {
|
|
279
313
|
font-size: 24px !important;
|
|
280
314
|
}
|
|
281
315
|
|
|
@@ -289,6 +323,12 @@ header {
|
|
|
289
323
|
padding-left: 12px !important;
|
|
290
324
|
}
|
|
291
325
|
|
|
326
|
+
.theme-button {
|
|
327
|
+
padding-right: 6px !important;
|
|
328
|
+
margin-right: 4px;
|
|
329
|
+
padding-left: 12px !important;
|
|
330
|
+
}
|
|
331
|
+
|
|
292
332
|
.app-bar {
|
|
293
333
|
background: var(--site-config-color-app-bar) !important;
|
|
294
334
|
}
|
package/site/pc/Layout.vue
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
class="varlet-site-header__versions"
|
|
11
11
|
@mouseenter="isOpenVersionsMenu = true"
|
|
12
12
|
@mouseleave="isOpenVersionsMenu = false"
|
|
13
|
-
v-if="
|
|
13
|
+
v-if="isShowVersion"
|
|
14
14
|
>
|
|
15
|
-
<span style="font-size:
|
|
15
|
+
<span style="font-size: 16px;">{{ currentVersion }}</span>
|
|
16
16
|
<var-icon name="chevron-down"/>
|
|
17
17
|
<transition name="fade">
|
|
18
18
|
<div
|
|
@@ -21,12 +21,13 @@
|
|
|
21
21
|
:style="{ pointerEvents: isOpenVersionsMenu ? 'auto' : 'none' }"
|
|
22
22
|
>
|
|
23
23
|
<var-cell
|
|
24
|
-
v-for="(
|
|
24
|
+
v-for="(i, key) in versionItems"
|
|
25
25
|
v-ripple
|
|
26
26
|
:key="key"
|
|
27
|
-
:class="{ 'varlet-site-header__animation-list--active': currentVersion ===
|
|
28
|
-
@click="open(
|
|
29
|
-
>
|
|
27
|
+
:class="{ 'varlet-site-header__animation-list--active': currentVersion === i.label }"
|
|
28
|
+
@click="open(i.link)"
|
|
29
|
+
>
|
|
30
|
+
{{ i.label }}
|
|
30
31
|
</var-cell>
|
|
31
32
|
</div>
|
|
32
33
|
</transition>
|
|
@@ -41,15 +42,30 @@
|
|
|
41
42
|
<a class="varlet-site-header__link" target="_blank" :href="github" v-ripple v-if="github">
|
|
42
43
|
<var-icon name="github" :size="28"/>
|
|
43
44
|
</a>
|
|
44
|
-
<div
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
<div
|
|
46
|
+
class="varlet-site-header__theme"
|
|
47
|
+
@mouseenter="isOpenThemeMenu = true"
|
|
48
|
+
@mouseleave="isOpenThemeMenu = false"
|
|
49
|
+
v-if="themes.length > 1"
|
|
50
|
+
>
|
|
51
|
+
<var-icon name="palette" :size="28" />
|
|
52
|
+
<var-icon name="chevron-down"/>
|
|
53
|
+
<transition name="fade">
|
|
54
|
+
<div
|
|
55
|
+
class="varlet-site-header__animation-list var-elevation--5"
|
|
56
|
+
v-show="isOpenThemeMenu"
|
|
57
|
+
:style="{ pointerEvents: isOpenThemeMenu ? 'auto' : 'none' }"
|
|
58
|
+
>
|
|
59
|
+
<var-cell
|
|
60
|
+
v-for="t in themes"
|
|
61
|
+
v-ripple
|
|
62
|
+
:key="t.value"
|
|
63
|
+
:class="{ 'varlet-site-header__animation-list--active': currentTheme === t.value }"
|
|
64
|
+
@click="() => toggleTheme(t.value as Theme)"
|
|
65
|
+
>{{ t[language as keyof typeof t] }}
|
|
66
|
+
</var-cell>
|
|
67
|
+
</div>
|
|
68
|
+
</transition>
|
|
53
69
|
</div>
|
|
54
70
|
<div
|
|
55
71
|
class="varlet-site-header__language"
|
|
@@ -85,8 +101,7 @@
|
|
|
85
101
|
import config from '@config'
|
|
86
102
|
import { ref, computed, defineComponent } from 'vue'
|
|
87
103
|
import { get } from 'lodash-es'
|
|
88
|
-
import { getBrowserTheme, getPCLocationInfo, Theme, watchTheme } from '@varlet/cli/client'
|
|
89
|
-
import { setTheme } from '../../utils'
|
|
104
|
+
import { getBrowserTheme, getPCLocationInfo, Theme, watchTheme, setTheme } from '@varlet/cli/client'
|
|
90
105
|
import { removeEmpty } from '../../utils'
|
|
91
106
|
import { useRouter } from 'vue-router'
|
|
92
107
|
import type { Ref, ComputedRef } from 'vue'
|
|
@@ -102,20 +117,23 @@ export default defineComponent({
|
|
|
102
117
|
const title: Ref<string> = ref(get(config, 'title'))
|
|
103
118
|
const logo: Ref<string> = ref(get(config, 'logo'))
|
|
104
119
|
const languages: Ref<Record<string, string>> = ref(get(config, 'pc.header.i18n'))
|
|
105
|
-
const currentVersion: Ref<string> = ref(get(config, 'pc.header.
|
|
106
|
-
const
|
|
120
|
+
const currentVersion: Ref<string> = ref(get(config, 'pc.header.currentVersion'))
|
|
121
|
+
const versions = get(config, 'pc.header.versions')
|
|
122
|
+
const isShowVersion: Ref<boolean> = ref(!!versions)
|
|
123
|
+
const versionItems: Ref<Array<Record<string, any>>> = ref((versions ?? []).find((i: any) => window.location.host.includes(i.name))?.items ?? versions?.[0]?.items ?? [])
|
|
107
124
|
const playground: Ref<string> = ref(get(config, 'pc.header.playground'))
|
|
108
125
|
const github: Ref<string> = ref(get(config, 'pc.header.github'))
|
|
126
|
+
const themes: Ref<Record<string, any>> = ref(get(config, 'pc.header.themes'))
|
|
109
127
|
const changelog: Ref<string> = ref(get(config, 'pc.header.changelog'))
|
|
110
128
|
const redirect = get(config, 'pc.redirect')
|
|
111
129
|
const darkMode: Ref<boolean> = ref(get(config, 'pc.header.darkMode'))
|
|
112
130
|
const currentTheme = ref(getBrowserTheme())
|
|
113
131
|
|
|
114
132
|
const isOpenLanguageMenu: Ref<boolean> = ref(false)
|
|
133
|
+
const isOpenThemeMenu: Ref<boolean> = ref(false)
|
|
115
134
|
const isOpenVersionsMenu: Ref<boolean> = ref(false)
|
|
116
135
|
const router = useRouter()
|
|
117
136
|
const nonEmptyLanguages: ComputedRef<Record<string, string>> = computed(() => removeEmpty(languages.value))
|
|
118
|
-
const nonEmptyVersions: ComputedRef<Record<string, string>> = computed(() => removeEmpty(versionItems.value))
|
|
119
137
|
|
|
120
138
|
const backRoot = () => {
|
|
121
139
|
const { language: lang } = getPCLocationInfo()
|
|
@@ -130,17 +148,18 @@ export default defineComponent({
|
|
|
130
148
|
|
|
131
149
|
const setCurrentTheme = (theme: Theme) => {
|
|
132
150
|
currentTheme.value = theme
|
|
133
|
-
setTheme(
|
|
151
|
+
setTheme(currentTheme.value)
|
|
134
152
|
window.localStorage.setItem(get(config, 'themeKey'), currentTheme.value)
|
|
135
153
|
}
|
|
136
154
|
|
|
137
155
|
const getThemeMessage = () => ({ action: 'theme-change', from: 'pc', data: currentTheme.value })
|
|
138
156
|
|
|
139
|
-
const toggleTheme = () => {
|
|
140
|
-
setCurrentTheme(
|
|
157
|
+
const toggleTheme = (value: Theme) => {
|
|
158
|
+
setCurrentTheme(value)
|
|
141
159
|
|
|
142
160
|
window.postMessage(getThemeMessage(), '*')
|
|
143
161
|
notifyThemeChange('mobile')
|
|
162
|
+
isOpenThemeMenu.value = false
|
|
144
163
|
}
|
|
145
164
|
|
|
146
165
|
const notifyThemeChange = (target: 'mobile' | 'window') => {
|
|
@@ -153,9 +172,7 @@ export default defineComponent({
|
|
|
153
172
|
}
|
|
154
173
|
|
|
155
174
|
const open = (value: string) => {
|
|
156
|
-
|
|
157
|
-
window.location.href = value
|
|
158
|
-
}, 350)
|
|
175
|
+
window.location.href = value
|
|
159
176
|
}
|
|
160
177
|
|
|
161
178
|
watchTheme((theme, from) => {
|
|
@@ -169,7 +186,7 @@ export default defineComponent({
|
|
|
169
186
|
}
|
|
170
187
|
})
|
|
171
188
|
|
|
172
|
-
setTheme(
|
|
189
|
+
setTheme(currentTheme.value)
|
|
173
190
|
notifyThemeChange('window')
|
|
174
191
|
|
|
175
192
|
return {
|
|
@@ -178,14 +195,16 @@ export default defineComponent({
|
|
|
178
195
|
title,
|
|
179
196
|
currentVersion,
|
|
180
197
|
languages,
|
|
198
|
+
isShowVersion,
|
|
181
199
|
versionItems,
|
|
200
|
+
themes,
|
|
182
201
|
nonEmptyLanguages,
|
|
183
|
-
nonEmptyVersions,
|
|
184
202
|
playground,
|
|
185
203
|
changelog,
|
|
186
204
|
github,
|
|
187
205
|
isOpenLanguageMenu,
|
|
188
206
|
isOpenVersionsMenu,
|
|
207
|
+
isOpenThemeMenu,
|
|
189
208
|
darkMode,
|
|
190
209
|
currentTheme,
|
|
191
210
|
open,
|
|
@@ -244,21 +263,6 @@ export default defineComponent({
|
|
|
244
263
|
}
|
|
245
264
|
}
|
|
246
265
|
|
|
247
|
-
&__language {
|
|
248
|
-
border-radius: 3px;
|
|
249
|
-
height: 40px;
|
|
250
|
-
display: flex;
|
|
251
|
-
align-items: center;
|
|
252
|
-
padding: 0 10px;
|
|
253
|
-
position: relative;
|
|
254
|
-
cursor: pointer;
|
|
255
|
-
transition: background-color 0.25s;
|
|
256
|
-
|
|
257
|
-
&:hover {
|
|
258
|
-
background: var(--site-config-color-nav-button-hover-background);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
266
|
&__versions {
|
|
263
267
|
border-radius: 3px;
|
|
264
268
|
height: 40px;
|
|
@@ -298,16 +302,31 @@ export default defineComponent({
|
|
|
298
302
|
}
|
|
299
303
|
}
|
|
300
304
|
|
|
305
|
+
&__language {
|
|
306
|
+
border-radius: 3px;
|
|
307
|
+
height: 40px;
|
|
308
|
+
display: flex;
|
|
309
|
+
align-items: center;
|
|
310
|
+
padding: 0 10px;
|
|
311
|
+
position: relative;
|
|
312
|
+
cursor: pointer;
|
|
313
|
+
transition: background-color 0.25s;
|
|
314
|
+
|
|
315
|
+
&:hover {
|
|
316
|
+
background: var(--site-config-color-nav-button-hover-background);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
301
320
|
&__theme {
|
|
302
|
-
border-radius:
|
|
303
|
-
|
|
304
|
-
height: 42px;
|
|
321
|
+
border-radius: 3px;
|
|
322
|
+
height: 40px;
|
|
305
323
|
display: flex;
|
|
306
|
-
justify-content: center;
|
|
307
324
|
align-items: center;
|
|
325
|
+
padding: 0 10px;
|
|
326
|
+
position: relative;
|
|
308
327
|
cursor: pointer;
|
|
309
328
|
transition: background-color 0.25s;
|
|
310
|
-
margin-right:
|
|
329
|
+
margin-right: 6px;
|
|
311
330
|
|
|
312
331
|
&:hover {
|
|
313
332
|
background: var(--site-config-color-nav-button-hover-background);
|
|
@@ -338,6 +357,30 @@ export default defineComponent({
|
|
|
338
357
|
}
|
|
339
358
|
}
|
|
340
359
|
|
|
360
|
+
&__theme-animation-list {
|
|
361
|
+
background: var(--site-config-color-bar);
|
|
362
|
+
cursor: pointer;
|
|
363
|
+
color: var(--site-config-color-text);
|
|
364
|
+
border-radius: 2px;
|
|
365
|
+
position: absolute;
|
|
366
|
+
top: 40px;
|
|
367
|
+
left: -20px;
|
|
368
|
+
|
|
369
|
+
.var-cell {
|
|
370
|
+
width: 100px !important;
|
|
371
|
+
color: var(--site-config-color-text);
|
|
372
|
+
|
|
373
|
+
&__content {
|
|
374
|
+
color: inherit !important;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
&--active {
|
|
379
|
+
background: var(--site-config-color-pc-theme-active-background) !important;
|
|
380
|
+
color: var(--site-config-color-pc-theme-active) !important;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
341
384
|
&__animation-versions {
|
|
342
385
|
left: -7px;
|
|
343
386
|
}
|
|
@@ -93,7 +93,7 @@ export default defineComponent({
|
|
|
93
93
|
const toPlayground = () => {
|
|
94
94
|
const codeText = code.value?.innerText ?? ''
|
|
95
95
|
const file = { 'App.vue': codeText }
|
|
96
|
-
const initialTheme = getBrowserTheme()
|
|
96
|
+
const initialTheme = getBrowserTheme()
|
|
97
97
|
|
|
98
98
|
context.showPlayground = true
|
|
99
99
|
context.playgroundURL = `${playground.value}/?initialTheme=${initialTheme}#${utoa(JSON.stringify(file))}`
|
|
@@ -7,10 +7,11 @@ import { useRoute, useRouter } from 'vue-router'
|
|
|
7
7
|
import {
|
|
8
8
|
getPCLocationInfo,
|
|
9
9
|
watchTheme,
|
|
10
|
+
onThemeChange,
|
|
10
11
|
getBrowserTheme,
|
|
12
|
+
setTheme,
|
|
11
13
|
type Theme
|
|
12
14
|
} from '@varlet/cli/client'
|
|
13
|
-
import { setTheme } from '../../../utils'
|
|
14
15
|
|
|
15
16
|
const route = useRoute()
|
|
16
17
|
const router = useRouter()
|
|
@@ -32,7 +33,7 @@ const getThemeMessage = () => ({ action: 'theme-change', from: 'pc', data: curre
|
|
|
32
33
|
|
|
33
34
|
const setCurrentTheme = (theme: Theme) => {
|
|
34
35
|
currentTheme.value = theme
|
|
35
|
-
setTheme(
|
|
36
|
+
setTheme(currentTheme.value)
|
|
36
37
|
window.localStorage.setItem(get(config, 'themeKey'), currentTheme.value)
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -48,7 +49,7 @@ const to = (url: string) => {
|
|
|
48
49
|
window.open(url)
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
setTheme(
|
|
52
|
+
setTheme(currentTheme.value)
|
|
52
53
|
|
|
53
54
|
window.postMessage(getThemeMessage(), '*')
|
|
54
55
|
|
|
@@ -56,8 +57,10 @@ watchTheme((theme, from) => {
|
|
|
56
57
|
from === 'mobile' && setCurrentTheme(theme)
|
|
57
58
|
})
|
|
58
59
|
|
|
60
|
+
onThemeChange()
|
|
61
|
+
|
|
59
62
|
watch(() => route.path, () => {
|
|
60
|
-
language.value =
|
|
63
|
+
language.value = getPCLocationInfo().language
|
|
61
64
|
setLocale()
|
|
62
65
|
}, { immediate: true })
|
|
63
66
|
</script>
|
|
@@ -79,7 +82,7 @@ watch(() => route.path, () => {
|
|
|
79
82
|
<var-button class="varlet-doc-index__link-button" type="primary" style="line-height: 1.2" @click="getStar">
|
|
80
83
|
{{ indexPage.started[language] }}
|
|
81
84
|
</var-button>
|
|
82
|
-
<var-button class="varlet-doc-index__github-button"
|
|
85
|
+
<var-button class="varlet-doc-index__github-button" style="line-height: 1.2" @click="toGithub">
|
|
83
86
|
{{ indexPage.viewOnGithub[language] }}
|
|
84
87
|
</var-button>
|
|
85
88
|
</var-space>
|
|
@@ -239,7 +242,6 @@ watch(() => route.path, () => {
|
|
|
239
242
|
font-size: 19px !important;
|
|
240
243
|
transition: all .2s !important;
|
|
241
244
|
margin-top: 38px !important;
|
|
242
|
-
background: var(--site-config-color-index-page-get-started-button) !important;
|
|
243
245
|
}
|
|
244
246
|
|
|
245
247
|
&__github-button {
|
|
@@ -248,7 +250,6 @@ watch(() => route.path, () => {
|
|
|
248
250
|
font-size: 19px !important;
|
|
249
251
|
transition: all .2s !important;
|
|
250
252
|
margin-top: 38px !important;
|
|
251
|
-
background: var(--site-config-color-index-page-github-button) !important;
|
|
252
253
|
}
|
|
253
254
|
|
|
254
255
|
&__features {
|
|
@@ -262,7 +263,7 @@ watch(() => route.path, () => {
|
|
|
262
263
|
width: 300px;
|
|
263
264
|
margin: 12px;
|
|
264
265
|
padding: 20px;
|
|
265
|
-
border-radius:
|
|
266
|
+
border-radius: 12px;
|
|
266
267
|
background: var(--site-config-color-index-page-feature-background);
|
|
267
268
|
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
|
268
269
|
}
|
|
@@ -306,7 +307,7 @@ watch(() => route.path, () => {
|
|
|
306
307
|
width: 300px;
|
|
307
308
|
margin: 12px;
|
|
308
309
|
padding: 30px 20px;
|
|
309
|
-
border-radius:
|
|
310
|
+
border-radius: 12px;
|
|
310
311
|
background: var(--site-config-color-index-page-feature-background);
|
|
311
312
|
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
|
312
313
|
|
package/site/utils.ts
CHANGED
|
@@ -31,12 +31,6 @@ export function inIframe() {
|
|
|
31
31
|
return window.self !== window.top
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export function setTheme(config: Record<string, any>, theme: Theme) {
|
|
35
|
-
const styleVars = withSiteConfigNamespace(get(config, theme, {}))
|
|
36
|
-
StyleProvider({ ...styleVars, ...(theme === 'darkTheme' ? Themes.dark : {}) })
|
|
37
|
-
setColorScheme(theme)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
34
|
export function utoa(data: string): string {
|
|
41
35
|
return btoa(unescape(encodeURIComponent(data)))
|
|
42
36
|
}
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@varlet/shared": "workspace:*",
|
|
45
45
|
"@varlet/ui": "workspace:*",
|
|
46
46
|
"@vue/test-utils": "2.4.1",
|
|
47
|
-
"@vue/runtime-core": "3.4.
|
|
47
|
+
"@vue/runtime-core": "3.4.3",
|
|
48
48
|
"@vitest/coverage-istanbul": "1.1.0",
|
|
49
49
|
"jsdom": "22.1.0",
|
|
50
50
|
"vitest": "1.1.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"prettier": "^2.8.8",
|
|
57
57
|
"simple-git-hooks": "^2.8.0",
|
|
58
58
|
"typescript": "^5.1.5",
|
|
59
|
-
"vue": "3.4.
|
|
59
|
+
"vue": "3.4.3",
|
|
60
60
|
"vue-router": "4.2.0"
|
|
61
61
|
},
|
|
62
62
|
"lint-staged": {
|