@varlet/cli 2.16.0-alpha.1693852447755 → 2.16.0
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 +2 -2
- package/lib/client/index.js +3 -20
- package/package.json +9 -8
- package/site/mobile/App.vue +5 -6
- package/site/utils.ts +2 -2
- package/template/generators/config/default/sfc/src/button/Button.vue +2 -2
- package/template/generators/config/default/sfc/src/button/button.less +1 -1
- package/template/generators/config/default/sfc/src/button/docs/zh-CN.md +2 -2
- package/template/generators/config/default/sfc/src/button/example/BasicUse.vue +2 -2
- package/template/generators/config/default/sfc/src/button/example/ModifyColor.vue +2 -2
- package/template/generators/config/default/sfc/src/button/example/index.vue +3 -3
- package/template/generators/config/default/tsx/src/button/Button.tsx +2 -2
- package/template/generators/config/default/tsx/src/button/button.less +1 -1
- package/template/generators/config/default/tsx/src/button/docs/zh-CN.md +2 -2
- package/template/generators/config/default/tsx/src/button/example/BasicUse.vue +2 -2
- package/template/generators/config/default/tsx/src/button/example/ModifyColor.vue +2 -2
- package/template/generators/config/default/tsx/src/button/example/index.vue +3 -3
- package/template/generators/config/i18n/sfc/src/button/Button.vue +2 -2
- package/template/generators/config/i18n/sfc/src/button/button.less +1 -1
- package/template/generators/config/i18n/sfc/src/button/docs/en-US.md +2 -2
- package/template/generators/config/i18n/sfc/src/button/docs/zh-CN.md +2 -2
- package/template/generators/config/i18n/sfc/src/button/example/BasicUse.vue +2 -2
- package/template/generators/config/i18n/sfc/src/button/example/ModifyColor.vue +2 -2
- package/template/generators/config/i18n/sfc/src/button/example/index.vue +3 -3
- package/template/generators/config/i18n/tsx/src/button/Button.tsx +2 -2
- package/template/generators/config/i18n/tsx/src/button/button.less +1 -1
- package/template/generators/config/i18n/tsx/src/button/docs/en-US.md +2 -2
- package/template/generators/config/i18n/tsx/src/button/docs/zh-CN.md +2 -2
- package/template/generators/config/i18n/tsx/src/button/example/BasicUse.vue +2 -2
- package/template/generators/config/i18n/tsx/src/button/example/ModifyColor.vue +2 -2
- package/template/generators/config/i18n/tsx/src/button/example/index.vue +3 -3
package/lib/client/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AppType from './appType';
|
|
2
|
+
import { StyleProvider } from '@varlet/ui';
|
|
2
3
|
interface PCLocationInfo {
|
|
3
4
|
language: string;
|
|
4
5
|
menuName: string;
|
|
@@ -6,7 +7,6 @@ interface PCLocationInfo {
|
|
|
6
7
|
}
|
|
7
8
|
export type Theme = 'lightTheme' | 'darkTheme';
|
|
8
9
|
export type StyleVars = Record<string, string>;
|
|
9
|
-
export declare function StyleProvider(styleVars?: StyleVars | null): void;
|
|
10
10
|
export declare function getPCLocationInfo(): PCLocationInfo;
|
|
11
11
|
export declare function getBrowserTheme(): Theme;
|
|
12
12
|
export declare function watchLang(cb: (lang: string) => void, platform?: 'pc' | 'mobile'): void;
|
|
@@ -16,4 +16,4 @@ export declare function useRouteListener(cb: () => void): void;
|
|
|
16
16
|
export declare function watchDarkMode(dark: StyleVars, cb?: (theme: Theme) => void): void;
|
|
17
17
|
export declare function setColorScheme(theme: Theme): void;
|
|
18
18
|
export declare function watchTheme(cb: (theme: Theme, from: 'pc' | 'mobile' | 'default' | 'playground') => void, shouldUnmount?: boolean): void;
|
|
19
|
-
export { AppType };
|
|
19
|
+
export { AppType, StyleProvider };
|
package/lib/client/index.js
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
import config from '@config';
|
|
2
2
|
import AppType from './appType';
|
|
3
|
+
import { Themes, StyleProvider } from '@varlet/ui';
|
|
3
4
|
import { onMounted, onUnmounted } from 'vue';
|
|
4
|
-
import { kebabCase } from '@varlet/shared';
|
|
5
5
|
import { get } from 'lodash-es';
|
|
6
|
-
const mountedVarKeys = [];
|
|
7
|
-
function formatStyleVars(styleVars) {
|
|
8
|
-
return Object.entries(styleVars !== null && styleVars !== void 0 ? styleVars : {}).reduce((styles, [key, value]) => {
|
|
9
|
-
const cssVar = key.startsWith('--') ? key : `--${kebabCase(key)}`;
|
|
10
|
-
styles[cssVar] = value;
|
|
11
|
-
return styles;
|
|
12
|
-
}, {});
|
|
13
|
-
}
|
|
14
|
-
export function StyleProvider(styleVars = {}) {
|
|
15
|
-
mountedVarKeys.forEach((key) => document.documentElement.style.removeProperty(key));
|
|
16
|
-
mountedVarKeys.length = 0;
|
|
17
|
-
const styles = formatStyleVars(styleVars);
|
|
18
|
-
Object.entries(styles).forEach(([key, value]) => {
|
|
19
|
-
document.documentElement.style.setProperty(key, value);
|
|
20
|
-
mountedVarKeys.push(key);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
6
|
export function getPCLocationInfo() {
|
|
24
7
|
var _a;
|
|
25
8
|
const [, language, path] = window.location.hash.split('/');
|
|
@@ -87,7 +70,7 @@ export function useRouteListener(cb) {
|
|
|
87
70
|
export function watchDarkMode(dark, cb) {
|
|
88
71
|
watchTheme((theme) => {
|
|
89
72
|
const siteStyleVars = withSiteConfigNamespace(get(config, theme, {}));
|
|
90
|
-
const darkStyleVars = Object.assign(Object.assign({}, siteStyleVars), dark);
|
|
73
|
+
const darkStyleVars = Object.assign(Object.assign(Object.assign({}, siteStyleVars), Themes.dark), dark);
|
|
91
74
|
StyleProvider(theme === 'darkTheme' ? darkStyleVars : siteStyleVars);
|
|
92
75
|
setColorScheme(theme);
|
|
93
76
|
cb === null || cb === void 0 ? void 0 : cb(theme);
|
|
@@ -111,4 +94,4 @@ export function watchTheme(cb, shouldUnmount = true) {
|
|
|
111
94
|
}
|
|
112
95
|
cb(getBrowserTheme(), 'default');
|
|
113
96
|
}
|
|
114
|
-
export { AppType };
|
|
97
|
+
export { AppType, StyleProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "2.16.0
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"vite": "4.3.5",
|
|
68
68
|
"vue": "3.3.4",
|
|
69
69
|
"webfont": "^9.0.0",
|
|
70
|
-
"@varlet/
|
|
71
|
-
"@varlet/
|
|
70
|
+
"@varlet/shared": "2.16.0",
|
|
71
|
+
"@varlet/vite-plugins": "2.16.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/babel__core": "^7.20.1",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"@types/semver": "^7.3.9",
|
|
84
84
|
"@types/sharp": "0.31.1",
|
|
85
85
|
"rimraf": "^5.0.1",
|
|
86
|
-
"@varlet/
|
|
87
|
-
"@varlet/
|
|
88
|
-
"@varlet/touch-emulator": "2.16.0
|
|
86
|
+
"@varlet/ui": "2.16.0",
|
|
87
|
+
"@varlet/icons": "2.16.0",
|
|
88
|
+
"@varlet/touch-emulator": "2.16.0"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"@vue/runtime-core": "3.3.4",
|
|
@@ -98,8 +98,9 @@
|
|
|
98
98
|
"lodash-es": "^4.17.21",
|
|
99
99
|
"vue": "3.3.4",
|
|
100
100
|
"vue-router": "4.2.0",
|
|
101
|
-
"@varlet/icons": "2.16.0
|
|
102
|
-
"@varlet/touch-emulator": "2.16.0
|
|
101
|
+
"@varlet/icons": "2.16.0",
|
|
102
|
+
"@varlet/touch-emulator": "2.16.0",
|
|
103
|
+
"@varlet/ui": "2.16.0"
|
|
103
104
|
},
|
|
104
105
|
"scripts": {
|
|
105
106
|
"dev": "tsc --watch",
|
package/site/mobile/App.vue
CHANGED
|
@@ -149,16 +149,15 @@ export default defineComponent({
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
const toggleTheme = () => {
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
setCurrentTheme(currentTheme.value === 'darkTheme' ? 'lightTheme' : 'darkTheme')
|
|
153
|
+
window.postMessage(getThemeMessage(), '*')
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
155
|
+
if (!isPhone() && inIframe()) {
|
|
156
|
+
;(window.top as any).postMessage(getThemeMessage(), '*')
|
|
158
157
|
}
|
|
158
|
+
}
|
|
159
159
|
|
|
160
160
|
;(window as any).toggleTheme = toggleTheme
|
|
161
|
-
|
|
162
161
|
setTheme(config, currentTheme.value)
|
|
163
162
|
window.postMessage(getThemeMessage(), '*')
|
|
164
163
|
|
package/site/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { get } from 'lodash-es'
|
|
2
|
+
import { Themes } from '@varlet/ui'
|
|
2
3
|
import { StyleProvider, type Theme, withSiteConfigNamespace, setColorScheme } from '@varlet/cli/client'
|
|
3
4
|
|
|
4
5
|
export interface Menu {
|
|
@@ -32,8 +33,7 @@ export function inIframe() {
|
|
|
32
33
|
|
|
33
34
|
export function setTheme(config: Record<string, any>, theme: Theme) {
|
|
34
35
|
const styleVars = withSiteConfigNamespace(get(config, theme, {}))
|
|
35
|
-
|
|
36
|
-
StyleProvider(styleVars)
|
|
36
|
+
StyleProvider({ ...styleVars, ...(theme === 'darkTheme' ? Themes.dark : {}) })
|
|
37
37
|
setColorScheme(theme)
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<button class="
|
|
2
|
+
<button class="va-button" :style="{ background: color }" @click="handleClick">
|
|
3
3
|
<slot />
|
|
4
4
|
</button>
|
|
5
5
|
</template>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { defineComponent, PropType } from 'vue'
|
|
9
9
|
|
|
10
10
|
export default defineComponent({
|
|
11
|
-
name: '
|
|
11
|
+
name: 'VaButton',
|
|
12
12
|
props: {
|
|
13
13
|
color: {
|
|
14
14
|
type: String,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
### 基本使用
|
|
4
4
|
```html
|
|
5
|
-
<
|
|
5
|
+
<va-button>按钮起步</va-button>
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
```vue
|
|
@@ -11,7 +11,7 @@ import BasicUse from '../example/BasicUse'
|
|
|
11
11
|
|
|
12
12
|
### 主题色按钮
|
|
13
13
|
```html
|
|
14
|
-
<
|
|
14
|
+
<va-button color="#009688">按钮起步</va-button>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
```vue
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
2
|
+
import VaButton from '..'
|
|
3
3
|
import { AppType } from '@varlet/cli/client'
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
6
|
<template>
|
|
7
7
|
<app-type>基本使用</app-type>
|
|
8
|
-
<
|
|
8
|
+
<va-button>起步</va-button>
|
|
9
9
|
|
|
10
10
|
<app-type>修改颜色</app-type>
|
|
11
|
-
<
|
|
11
|
+
<va-button color="#03A9F4">起步</va-button>
|
|
12
12
|
</template>
|
|
@@ -2,7 +2,7 @@ import { defineComponent, PropType } from 'vue'
|
|
|
2
2
|
import './button.less'
|
|
3
3
|
|
|
4
4
|
export default defineComponent({
|
|
5
|
-
name: '
|
|
5
|
+
name: 'VaButton',
|
|
6
6
|
props: {
|
|
7
7
|
color: {
|
|
8
8
|
type: String,
|
|
@@ -18,7 +18,7 @@ export default defineComponent({
|
|
|
18
18
|
const { color } = props
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
|
-
<button class="
|
|
21
|
+
<button class="va-button" style={{ background: color }} onClick={handleClick}>
|
|
22
22
|
{slots.default?.()}
|
|
23
23
|
</button>
|
|
24
24
|
)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
### 基本使用
|
|
4
4
|
```html
|
|
5
|
-
<
|
|
5
|
+
<va-button>按钮起步</va-button>
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
```vue
|
|
@@ -11,7 +11,7 @@ import BasicUse from '../example/BasicUse'
|
|
|
11
11
|
|
|
12
12
|
### 主题色按钮
|
|
13
13
|
```html
|
|
14
|
-
<
|
|
14
|
+
<va-button color="#009688">按钮起步</va-button>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
```vue
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
2
|
+
import VaButton from '..'
|
|
3
3
|
import { AppType } from '@varlet/cli/client'
|
|
4
4
|
</script>
|
|
5
5
|
|
|
6
6
|
<template>
|
|
7
7
|
<app-type>基本使用</app-type>
|
|
8
|
-
<
|
|
8
|
+
<va-button>起步</va-button>
|
|
9
9
|
|
|
10
10
|
<app-type>修改颜色</app-type>
|
|
11
|
-
<
|
|
11
|
+
<va-button color="#03A9F4">起步</va-button>
|
|
12
12
|
</template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<button class="
|
|
2
|
+
<button class="va-button" :style="{ background: color }" @click="handleClick">
|
|
3
3
|
{{ pack.button }}
|
|
4
4
|
<slot />
|
|
5
5
|
</button>
|
|
@@ -12,7 +12,7 @@ import { defineComponent, PropType } from 'vue'
|
|
|
12
12
|
import { pack } from '../locale'
|
|
13
13
|
|
|
14
14
|
export default defineComponent({
|
|
15
|
-
name: '
|
|
15
|
+
name: 'VaButton',
|
|
16
16
|
props: {
|
|
17
17
|
color: {
|
|
18
18
|
type: String,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
### Basic Use
|
|
4
4
|
```html
|
|
5
|
-
<
|
|
5
|
+
<va-button>start</va-button>
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
```vue
|
|
@@ -11,7 +11,7 @@ import BasicUse from '../example/BasicUse'
|
|
|
11
11
|
|
|
12
12
|
### Theme Color Button
|
|
13
13
|
```html
|
|
14
|
-
<
|
|
14
|
+
<va-button color="#009688">start</va-button>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
```vue
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
### 基本使用
|
|
4
4
|
```html
|
|
5
|
-
<
|
|
5
|
+
<va-button>按钮起步</va-button>
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
```vue
|
|
@@ -11,7 +11,7 @@ import BasicUse from '../example/BasicUse'
|
|
|
11
11
|
|
|
12
12
|
### 主题色按钮
|
|
13
13
|
```html
|
|
14
|
-
<
|
|
14
|
+
<va-button color="#009688">按钮起步</va-button>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
```vue
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
2
|
+
import VaButton from '..'
|
|
3
3
|
import { watchLang } from '@varlet/cli/client'
|
|
4
4
|
import { pack, use } from './locale'
|
|
5
5
|
|
|
@@ -7,5 +7,5 @@ watchLang(use, 'pc')
|
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<template>
|
|
10
|
-
<
|
|
10
|
+
<va-button>{{ pack.start }}</va-button>
|
|
11
11
|
</template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
2
|
+
import VaButton from '..'
|
|
3
3
|
import { watchLang } from '@varlet/cli/client'
|
|
4
4
|
import { pack, use } from './locale'
|
|
5
5
|
|
|
@@ -7,5 +7,5 @@ watchLang(use, 'pc')
|
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<template>
|
|
10
|
-
<
|
|
10
|
+
<va-button color="#03A9F4">{{ pack.start }}</va-button>
|
|
11
11
|
</template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
2
|
+
import VaButton from '..'
|
|
3
3
|
import { watchLang, AppType } from '@varlet/cli/client'
|
|
4
4
|
import { pack, use } from './locale'
|
|
5
5
|
|
|
@@ -8,8 +8,8 @@ watchLang(use)
|
|
|
8
8
|
|
|
9
9
|
<template>
|
|
10
10
|
<app-type>{{ pack.basicUse }}</app-type>
|
|
11
|
-
<
|
|
11
|
+
<va-button>{{ pack.start }}</va-button>
|
|
12
12
|
|
|
13
13
|
<app-type>{{ pack.modifyColor }}</app-type>
|
|
14
|
-
<
|
|
14
|
+
<va-button color="#03A9F4">{{ pack.start }}</va-button>
|
|
15
15
|
</template>
|
|
@@ -5,7 +5,7 @@ import './button.less'
|
|
|
5
5
|
import { pack } from '../locale'
|
|
6
6
|
|
|
7
7
|
export default defineComponent({
|
|
8
|
-
name: '
|
|
8
|
+
name: 'VaButton',
|
|
9
9
|
props: {
|
|
10
10
|
color: {
|
|
11
11
|
type: String,
|
|
@@ -23,7 +23,7 @@ export default defineComponent({
|
|
|
23
23
|
const { color } = props
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<button class="
|
|
26
|
+
<button class="va-button" style={{ background: color }} onClick={handleClick}>
|
|
27
27
|
{pack.value.button}
|
|
28
28
|
{slots.default?.()}
|
|
29
29
|
</button>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
### Basic Use
|
|
4
4
|
```html
|
|
5
|
-
<
|
|
5
|
+
<va-button>start</va-button>
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
```vue
|
|
@@ -11,7 +11,7 @@ import BasicUse from '../example/BasicUse'
|
|
|
11
11
|
|
|
12
12
|
### Theme Color Button
|
|
13
13
|
```html
|
|
14
|
-
<
|
|
14
|
+
<va-button color="#009688">start</va-button>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
```vue
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
### 基本使用
|
|
4
4
|
```html
|
|
5
|
-
<
|
|
5
|
+
<va-button>按钮起步</va-button>
|
|
6
6
|
```
|
|
7
7
|
|
|
8
8
|
```vue
|
|
@@ -11,7 +11,7 @@ import BasicUse from '../example/BasicUse'
|
|
|
11
11
|
|
|
12
12
|
### 主题色按钮
|
|
13
13
|
```html
|
|
14
|
-
<
|
|
14
|
+
<va-button color="#009688">按钮起步</va-button>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
```vue
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
2
|
+
import VaButton from '..'
|
|
3
3
|
import { watchLang } from '@varlet/cli/client'
|
|
4
4
|
import { pack, use } from './locale'
|
|
5
5
|
|
|
@@ -7,5 +7,5 @@ watchLang(use, 'pc')
|
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<template>
|
|
10
|
-
<
|
|
10
|
+
<va-button>{{ pack.start }}</va-button>
|
|
11
11
|
</template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
2
|
+
import VaButton from '..'
|
|
3
3
|
import { watchLang } from '@varlet/cli/client'
|
|
4
4
|
import { pack, use } from './locale'
|
|
5
5
|
|
|
@@ -7,5 +7,5 @@ watchLang(use, 'pc')
|
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<template>
|
|
10
|
-
<
|
|
10
|
+
<va-button color="#03A9F4">{{ pack.start }}</va-button>
|
|
11
11
|
</template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
2
|
+
import VaButton from '..'
|
|
3
3
|
import { watchLang, AppType } from '@varlet/cli/client'
|
|
4
4
|
import { pack, use } from './locale'
|
|
5
5
|
|
|
@@ -8,8 +8,8 @@ watchLang(use)
|
|
|
8
8
|
|
|
9
9
|
<template>
|
|
10
10
|
<app-type>{{ pack.basicUse }}</app-type>
|
|
11
|
-
<
|
|
11
|
+
<va-button>{{ pack.start }}</va-button>
|
|
12
12
|
|
|
13
13
|
<app-type>{{ pack.modifyColor }}</app-type>
|
|
14
|
-
<
|
|
14
|
+
<va-button color="#03A9F4">{{ pack.start }}</va-button>
|
|
15
15
|
</template>
|