@varlet/cli 1.27.20 → 2.0.0-alpha.1663742071515
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/LICENCE +1 -1
- package/lib/commands/commitLint.js +1 -1
- package/lib/commands/compile.d.ts +5 -3
- package/lib/commands/compile.js +2 -2
- package/lib/commands/create.d.ts +8 -3
- package/lib/commands/create.js +100 -51
- package/lib/commands/dev.d.ts +4 -2
- package/lib/commands/dev.js +3 -3
- package/lib/commands/gen.d.ts +8 -1
- package/lib/commands/gen.js +61 -33
- package/lib/commands/jest.js +11 -7
- package/lib/commands/release.d.ts +4 -2
- package/lib/commands/release.js +2 -2
- package/lib/commands/test.d.ts +7 -0
- package/lib/commands/test.js +26 -0
- package/lib/commands/useVite.d.ts +1 -0
- package/lib/commands/useVite.js +70 -0
- package/lib/commands/vite.d.ts +3 -0
- package/lib/commands/vite.js +69 -0
- package/lib/compiler/compileModule.js +9 -5
- package/lib/compiler/compileSFC.js +14 -11
- package/lib/compiler/compileScript.js +4 -12
- package/lib/compiler/compileStyle.d.ts +1 -1
- package/lib/compiler/compileStyle.js +7 -17
- package/lib/compiler/compileTypes.js +4 -7
- package/lib/config/jest.config.js +1 -0
- package/lib/config/vite.config.js +1 -1
- package/lib/config/vitest.config.d.ts +2 -0
- package/lib/config/vitest.config.js +28 -0
- package/lib/index.js +22 -3
- package/lib/shared/constant.js +1 -1
- package/lib/shared/logger.d.ts +1 -0
- package/lib/shared/logger.js +3 -0
- package/package.json +16 -12
- package/site/components/button/Button.vue +45 -23
- package/site/components/button/button.less +6 -6
- package/site/components/button/props.ts +10 -2
- package/site/components/cell/Cell.vue +24 -12
- package/site/components/cell/cell.less +11 -7
- package/site/components/cell/props.ts +2 -2
- package/site/components/code-example/CodeExample.vue +17 -23
- package/site/components/context/index.ts +4 -0
- package/site/components/context/lock.ts +30 -41
- package/site/components/icon/Icon.vue +16 -9
- package/site/components/loading/Loading.vue +54 -25
- package/site/components/loading/loading.less +120 -35
- package/site/components/loading/props.ts +7 -2
- package/site/components/popup/Popup.tsx +102 -0
- package/site/components/popup/index.ts +10 -0
- package/site/components/popup/popup.less +125 -0
- package/site/components/popup/props.ts +63 -0
- package/site/components/progress/Progress.vue +28 -24
- package/site/components/progress/progress.less +16 -13
- package/site/components/progress/props.ts +1 -1
- package/site/components/ripple/index.ts +28 -7
- package/site/components/ripple/ripple.less +3 -0
- package/site/components/snackbar/Snackbar.vue +10 -7
- package/site/components/snackbar/core.vue +37 -22
- package/site/components/snackbar/index.tsx +14 -14
- package/site/components/snackbar/props.ts +10 -7
- package/site/components/utils/components.ts +49 -1
- package/site/components/utils/elements.ts +17 -0
- package/site/mobile/App.vue +42 -42
- package/site/mobile/components/AppHome.vue +1 -1
- package/site/mobile/components/app-bar/AppBar.vue +17 -21
- package/site/mobile/components/app-bar/appBar.less +2 -1
- package/site/mobile/main.ts +6 -2
- package/site/pc/Layout.vue +93 -67
- package/site/pc/components/AnimationBox.vue +3 -15
- package/site/pc/components/AppHeader.vue +110 -97
- package/site/pc/components/AppMobile.vue +8 -2
- package/site/pc/components/AppSidebar.vue +19 -10
- package/site/pc/components/LogoAnimation.vue +29 -31
- package/site/pc/floating.ts +3 -3
- package/site/pc/main.ts +6 -0
- package/site/pc/pages/index/index.less +142 -197
- package/site/pc/pages/index/index.vue +65 -80
- package/site/pc/pages/index/locale/en-US.ts +1 -5
- package/site/pc/pages/index/locale/zh-CN.ts +1 -5
- package/site/useProgress.ts +14 -17
- package/site/utils.ts +32 -20
- package/template/create/__tests__/index.spec.ejs +8 -0
- package/template/create/docs/en-US.md +0 -0
- package/template/create/docs/zh-CN.md +0 -0
- package/template/create/example/index.ejs +15 -0
- package/template/create/example/locale/en-US.ts +3 -0
- package/{generators/config/i18n/sfc/src/button → template/create}/example/locale/index.ts +0 -0
- package/template/create/example/locale/zh-CN.ts +3 -0
- package/template/create/index.ejs +12 -0
- package/template/create/less.ejs +3 -0
- package/template/create/props.ts +1 -0
- package/template/create/tsx.ejs +13 -0
- package/template/create/vue.ejs +17 -0
- package/{generators → template/generators}/base/.prettierignore +0 -0
- package/{generators → template/generators}/base/.prettierrc +0 -0
- package/{generators → template/generators}/base/README.md +0 -0
- package/{generators → template/generators}/base/babel.config.js +0 -0
- package/{generators → template/generators}/base/public/highlight.css +0 -0
- package/{generators → template/generators}/base/public/logo.svg +0 -0
- package/{generators → template/generators}/base/shims/shims-md.d.ts +0 -0
- package/{generators → template/generators}/base/shims/shims-vue.d.ts +0 -0
- package/{generators → template/generators}/base/tsconfig.json +0 -0
- package/{generators → template/generators}/config/default/base/docs/home.zh-CN.md +0 -0
- package/{generators → template/generators}/config/default/base/package.json +1 -1
- package/{generators → template/generators}/config/default/base/types/basicComponent.d.ts +0 -0
- package/{generators → template/generators}/config/default/base/types/button.d.ts +0 -0
- package/{generators → template/generators}/config/default/base/types/index.d.ts +0 -0
- package/{generators → template/generators}/config/default/base/varlet.config.js +1 -1
- package/{generators → template/generators}/config/default/sfc/src/button/Button.vue +6 -6
- package/{generators → template/generators}/config/default/sfc/src/button/__tests__/index.spec.js +0 -0
- package/{generators/config/default/tsx → template/generators/config/default/sfc}/src/button/button.less +1 -1
- package/{generators → template/generators}/config/default/sfc/src/button/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/default/sfc/src/button/example/BasicUse.vue +0 -0
- package/{generators → template/generators}/config/default/sfc/src/button/example/ModifyColor.vue +0 -0
- package/{generators → template/generators}/config/default/sfc/src/button/example/index.vue +2 -2
- package/{generators → template/generators}/config/default/sfc/src/button/index.ts +0 -0
- package/{generators → template/generators}/config/default/tsx/src/button/Button.tsx +11 -13
- package/{generators → template/generators}/config/default/tsx/src/button/__tests__/index.spec.js +0 -0
- package/{generators/config/i18n → template/generators/config/default}/tsx/src/button/button.less +1 -1
- package/{generators → template/generators}/config/default/tsx/src/button/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/default/tsx/src/button/example/BasicUse.vue +0 -0
- package/{generators → template/generators}/config/default/tsx/src/button/example/ModifyColor.vue +0 -0
- package/{generators → template/generators}/config/default/tsx/src/button/example/index.vue +2 -2
- package/{generators → template/generators}/config/default/tsx/src/button/index.ts +0 -0
- package/{generators → template/generators}/config/i18n/base/docs/home.en-US.md +0 -0
- package/{generators → template/generators}/config/i18n/base/docs/home.zh-CN.md +0 -0
- package/{generators → template/generators}/config/i18n/base/package.json +1 -1
- package/{generators → template/generators}/config/i18n/base/types/basicComponent.d.ts +0 -0
- package/{generators → template/generators}/config/i18n/base/types/button.d.ts +0 -0
- package/{generators → template/generators}/config/i18n/base/types/index.d.ts +0 -0
- package/{generators → template/generators}/config/i18n/base/types/locale.d.ts +0 -0
- package/{generators → template/generators}/config/i18n/base/varlet.config.js +3 -3
- package/{generators → template/generators}/config/i18n/sfc/src/button/Button.vue +7 -7
- package/{generators → template/generators}/config/i18n/sfc/src/button/__tests__/index.spec.js +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/button/button.less +1 -1
- package/{generators → template/generators}/config/i18n/sfc/src/button/docs/en-US.md +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/button/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/button/example/BasicUse.vue +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/button/example/ModifyColor.vue +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/button/example/index.vue +1 -1
- package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/button/example/locale/en-US.ts +1 -1
- package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/button/example/locale/index.ts +0 -0
- package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/button/example/locale/zh-CN.ts +1 -1
- package/{generators → template/generators}/config/i18n/sfc/src/button/index.ts +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/locale/__tests__/index.spec.js +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/locale/docs/en-US.md +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/locale/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/locale/en-US.d.ts +0 -0
- package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/locale/en-US.ts +1 -1
- package/{generators → template/generators}/config/i18n/sfc/src/locale/index.ts +0 -0
- package/{generators → template/generators}/config/i18n/sfc/src/locale/zh-CN.d.ts +0 -0
- package/{generators/config/i18n/tsx → template/generators/config/i18n/sfc}/src/locale/zh-CN.ts +1 -1
- package/{generators → template/generators}/config/i18n/tsx/src/button/Button.tsx +12 -14
- package/{generators → template/generators}/config/i18n/tsx/src/button/__tests__/index.spec.js +0 -0
- package/{generators/config/default/sfc → template/generators/config/i18n/tsx}/src/button/button.less +1 -1
- package/{generators → template/generators}/config/i18n/tsx/src/button/docs/en-US.md +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/button/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/button/example/BasicUse.vue +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/button/example/ModifyColor.vue +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/button/example/index.vue +1 -1
- package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/button/example/locale/en-US.ts +1 -1
- package/template/generators/config/i18n/tsx/src/button/example/locale/index.ts +23 -0
- package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/button/example/locale/zh-CN.ts +1 -1
- package/{generators → template/generators}/config/i18n/tsx/src/button/index.ts +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/locale/__tests__/index.spec.js +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/locale/docs/en-US.md +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/locale/docs/zh-CN.md +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/locale/en-US.d.ts +0 -0
- package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/locale/en-US.ts +1 -1
- package/{generators → template/generators}/config/i18n/tsx/src/locale/index.ts +0 -0
- package/{generators → template/generators}/config/i18n/tsx/src/locale/zh-CN.d.ts +0 -0
- package/{generators/config/i18n/sfc → template/generators/config/i18n/tsx}/src/locale/zh-CN.ts +1 -1
- package/varlet.default.config.js +137 -15
- package/site/mobile/components/styles/common.less +0 -64
- package/site/mobile/components/styles/elevation.less +0 -126
- package/site/mobile/components/styles/var.less +0 -27
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import VarSnackbarCore from './core.vue'
|
|
2
|
+
import VarSnackbar from './Snackbar.vue'
|
|
3
3
|
import context from '../context'
|
|
4
4
|
import { reactive, TransitionGroup } from 'vue'
|
|
5
5
|
import { mountInstance } from '../utils/components'
|
|
6
|
-
import { isPlainObject, toNumber } from '@varlet/shared'
|
|
6
|
+
import { isNumber, isPlainObject, isString, toNumber } from '@varlet/shared'
|
|
7
7
|
import type { LoadingType, LoadingSize } from '../loading/props'
|
|
8
8
|
import type { App, Component, TeleportProps } from 'vue'
|
|
9
9
|
|
|
@@ -95,7 +95,7 @@ const transitionGroupProps: any = {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
const TransitionGroupHost = {
|
|
98
|
-
setup
|
|
98
|
+
setup() {
|
|
99
99
|
return () => {
|
|
100
100
|
const snackbarList = uniqSnackbarOptions.map(({ id, reactiveSnackOptions, _update }: UniqSnackbarOptions) => {
|
|
101
101
|
const transitionGroupEl = document.querySelector('.var-site-transition-group')
|
|
@@ -111,11 +111,11 @@ const TransitionGroupHost = {
|
|
|
111
111
|
|
|
112
112
|
const style = {
|
|
113
113
|
position,
|
|
114
|
-
...getTop(reactiveSnackOptions.position)
|
|
114
|
+
...getTop(reactiveSnackOptions.position),
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
return (
|
|
118
|
-
<
|
|
118
|
+
<VarSnackbarCore
|
|
119
119
|
{...reactiveSnackOptions}
|
|
120
120
|
key={id}
|
|
121
121
|
style={style}
|
|
@@ -139,11 +139,11 @@ const TransitionGroupHost = {
|
|
|
139
139
|
</TransitionGroup>
|
|
140
140
|
)
|
|
141
141
|
}
|
|
142
|
-
}
|
|
142
|
+
},
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
const Snackbar: Snackbar = function (options: SnackbarOptions | string): SnackbarHandel {
|
|
146
|
-
const snackOptions: SnackbarOptions =
|
|
145
|
+
const Snackbar: Snackbar = function (options: SnackbarOptions | string | number): SnackbarHandel {
|
|
146
|
+
const snackOptions: SnackbarOptions = isString(options) || isNumber(options) ? { content: String(options) } : options
|
|
147
147
|
const reactiveSnackOptions: SnackbarOptions = reactive<SnackbarOptions>({
|
|
148
148
|
...defaultOption,
|
|
149
149
|
...snackOptions,
|
|
@@ -194,7 +194,7 @@ SNACKBAR_TYPE.forEach((type) => {
|
|
|
194
194
|
})
|
|
195
195
|
|
|
196
196
|
Snackbar.install = function (app: App) {
|
|
197
|
-
app.component(
|
|
197
|
+
app.component(VarSnackbar.name, VarSnackbar)
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
Snackbar.allowMultiple = function (bool = false) {
|
|
@@ -213,7 +213,7 @@ Snackbar.clear = function () {
|
|
|
213
213
|
})
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
Snackbar.Component =
|
|
216
|
+
Snackbar.Component = VarSnackbar
|
|
217
217
|
|
|
218
218
|
function opened(element: HTMLElement): void {
|
|
219
219
|
const id = element.getAttribute('data-id')
|
|
@@ -261,10 +261,10 @@ function getTop(position = 'top') {
|
|
|
261
261
|
return { top: position === 'top' ? '5%' : '45%' }
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
|
|
265
|
-
app.component(
|
|
264
|
+
VarSnackbar.install = function (app: App) {
|
|
265
|
+
app.component(VarSnackbar.name, VarSnackbar)
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
export const _SnackbarComponent =
|
|
268
|
+
export const _SnackbarComponent = VarSnackbar
|
|
269
269
|
|
|
270
270
|
export default Snackbar
|
|
@@ -41,10 +41,13 @@ export const props = {
|
|
|
41
41
|
type: Boolean,
|
|
42
42
|
default: false,
|
|
43
43
|
},
|
|
44
|
-
// 加载动画类型
|
|
45
44
|
loadingType: pickProps(loadingProps, 'type'),
|
|
46
|
-
// 加载动画尺寸
|
|
47
45
|
loadingSize: pickProps(loadingProps, 'size'),
|
|
46
|
+
loadingRadius: pickProps(loadingProps, 'radius'),
|
|
47
|
+
loadingColor: {
|
|
48
|
+
...pickProps(loadingProps, 'color'),
|
|
49
|
+
default: 'currentColor',
|
|
50
|
+
},
|
|
48
51
|
// 是否禁止滚动穿透
|
|
49
52
|
lockScroll: {
|
|
50
53
|
type: Boolean,
|
|
@@ -67,26 +70,26 @@ export const props = {
|
|
|
67
70
|
},
|
|
68
71
|
// 打开时的回调函数
|
|
69
72
|
onOpen: {
|
|
70
|
-
type: Function
|
|
73
|
+
type: Function as PropType<() => void>,
|
|
71
74
|
default: () => {},
|
|
72
75
|
},
|
|
73
76
|
// 打开动画结束时的回调
|
|
74
77
|
onOpened: {
|
|
75
|
-
type: Function
|
|
78
|
+
type: Function as PropType<() => void>,
|
|
76
79
|
default: () => {},
|
|
77
80
|
},
|
|
78
81
|
// 关闭时的回调函数
|
|
79
82
|
onClose: {
|
|
80
|
-
type: Function
|
|
83
|
+
type: Function as PropType<() => void>,
|
|
81
84
|
default: () => {},
|
|
82
85
|
},
|
|
83
86
|
// 关闭动画结束时的回调
|
|
84
87
|
onClosed: {
|
|
85
|
-
type: Function
|
|
88
|
+
type: Function as PropType<() => void>,
|
|
86
89
|
default: () => {},
|
|
87
90
|
},
|
|
88
91
|
'onUpdate:show': {
|
|
89
|
-
type: Function
|
|
92
|
+
type: Function as PropType<(show: boolean) => void>,
|
|
90
93
|
},
|
|
91
94
|
_update: {
|
|
92
95
|
type: String,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { createApp, h, onActivated, onDeactivated, ref, Ref } from
|
|
1
|
+
import { createApp, h, onActivated, onDeactivated, onMounted, onUnmounted, ref, Ref } from "vue";
|
|
2
2
|
import type { Component } from 'vue'
|
|
3
|
+
import { isArray } from "@varlet/shared";
|
|
3
4
|
|
|
4
5
|
export interface MountInstance {
|
|
5
6
|
instance: any
|
|
@@ -67,3 +68,50 @@ export function useTeleport() {
|
|
|
67
68
|
disabled,
|
|
68
69
|
}
|
|
69
70
|
}
|
|
71
|
+
|
|
72
|
+
type ClassName = string | undefined | null
|
|
73
|
+
type Classes = (ClassName | [any, ClassName, ClassName?])[]
|
|
74
|
+
|
|
75
|
+
export function createNamespace(name: string) {
|
|
76
|
+
const namespace = `var-site-${name}`
|
|
77
|
+
|
|
78
|
+
const createBEM = (suffix?: string): string => {
|
|
79
|
+
if (!suffix) return namespace
|
|
80
|
+
|
|
81
|
+
return suffix.startsWith('--') ? `${namespace}${suffix}` : `${namespace}__${suffix}`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const classes = (...classes: Classes): any[] => {
|
|
85
|
+
return classes.map((className) => {
|
|
86
|
+
if (isArray(className)) {
|
|
87
|
+
const [condition, truthy, falsy = null] = className
|
|
88
|
+
return condition ? truthy : falsy
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return className
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
n: createBEM,
|
|
97
|
+
classes,
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function call<F extends (...arg: any) => any, P extends Parameters<F>>(
|
|
102
|
+
fn?: F | null,
|
|
103
|
+
...arg: P
|
|
104
|
+
): ReturnType<F> | undefined {
|
|
105
|
+
if (fn) return fn(...arg)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function useRouteListener(cb: () => void) {
|
|
109
|
+
onMounted(() => {
|
|
110
|
+
window.addEventListener('hashchange', cb)
|
|
111
|
+
window.addEventListener('popstate', cb)
|
|
112
|
+
})
|
|
113
|
+
onUnmounted(() => {
|
|
114
|
+
window.removeEventListener('hashchange', cb)
|
|
115
|
+
window.removeEventListener('popstate', cb)
|
|
116
|
+
})
|
|
117
|
+
}
|
|
@@ -83,3 +83,20 @@ export function doubleRaf() {
|
|
|
83
83
|
})
|
|
84
84
|
})
|
|
85
85
|
}
|
|
86
|
+
|
|
87
|
+
export function supportTouch() {
|
|
88
|
+
const inBrowser = typeof window !== 'undefined'
|
|
89
|
+
return inBrowser && 'ontouchstart' in window
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const multiplySizeUnit = (value: unknown, quantity = 1) => {
|
|
93
|
+
if (value == null) {
|
|
94
|
+
return undefined
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const legalSize = toSizeUnit(value) as string
|
|
98
|
+
|
|
99
|
+
const unit = legalSize.match(/(vh|%|rem|px|vw)$/)![0]
|
|
100
|
+
|
|
101
|
+
return `${parseFloat(legalSize) * quantity}${unit}`
|
|
102
|
+
}
|
package/site/mobile/App.vue
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div style="position: relative">
|
|
3
3
|
<header>
|
|
4
|
-
<var-
|
|
4
|
+
<var-app-bar class="app-bar" title-position="left" :title="bigCamelizeComponentName">
|
|
5
5
|
<template #left>
|
|
6
|
-
<var-
|
|
7
|
-
<var-
|
|
8
|
-
</var-
|
|
9
|
-
<var-
|
|
6
|
+
<var-button v-if="showBackIcon" text round @click="back" color="transparent" text-color="#fff">
|
|
7
|
+
<var-icon name="chevron-left" class="arrow-left" style="margin-top: 1px" />
|
|
8
|
+
</var-button>
|
|
9
|
+
<var-button
|
|
10
10
|
v-if="!showBackIcon && github"
|
|
11
11
|
style="margin-left: 2px"
|
|
12
12
|
text
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
color="transparent"
|
|
16
16
|
text-color="#fff"
|
|
17
17
|
>
|
|
18
|
-
<var-
|
|
19
|
-
</var-
|
|
18
|
+
<var-icon name="github" class="github" style="margin-top: 1px" />
|
|
19
|
+
</var-button>
|
|
20
20
|
</template>
|
|
21
21
|
<template #right>
|
|
22
|
-
<var-
|
|
22
|
+
<var-button
|
|
23
23
|
text
|
|
24
24
|
round
|
|
25
25
|
color="transparent"
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
v-if="darkMode"
|
|
31
31
|
@click="toggleTheme"
|
|
32
32
|
>
|
|
33
|
-
<var-
|
|
33
|
+
<var-icon
|
|
34
34
|
class="theme"
|
|
35
35
|
color="#fff"
|
|
36
|
-
:name="
|
|
36
|
+
:name="currentTheme === 'lightTheme' ? 'white-balance-sunny' : 'weather-night'"
|
|
37
37
|
/>
|
|
38
|
-
</var-
|
|
39
|
-
<var-
|
|
38
|
+
</var-button>
|
|
39
|
+
<var-button
|
|
40
40
|
class="i18n-button"
|
|
41
41
|
text
|
|
42
42
|
color="transparent"
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
@click.stop="showMenu = true"
|
|
45
45
|
v-if="languages"
|
|
46
46
|
>
|
|
47
|
-
<var-
|
|
48
|
-
<var-
|
|
49
|
-
</var-
|
|
47
|
+
<var-icon name="translate" class="i18n" />
|
|
48
|
+
<var-icon name="chevron-down" class="arrow-down" />
|
|
49
|
+
</var-button>
|
|
50
50
|
</template>
|
|
51
|
-
</var-
|
|
51
|
+
</var-app-bar>
|
|
52
52
|
</header>
|
|
53
53
|
<div class="router-view__block">
|
|
54
54
|
<router-view />
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
|
|
57
57
|
<transition name="site-menu">
|
|
58
58
|
<div class="settings var-site-elevation--3" v-if="showMenu">
|
|
59
|
-
<var-
|
|
59
|
+
<var-cell
|
|
60
60
|
v-for="(value, key) in nonEmptyLanguages"
|
|
61
61
|
:key="key"
|
|
62
62
|
class="mobile-language-cell"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
@click="changeLanguage(key)"
|
|
66
66
|
>
|
|
67
67
|
{{ value }}
|
|
68
|
-
</var-
|
|
68
|
+
</var-cell>
|
|
69
69
|
</div>
|
|
70
70
|
</transition>
|
|
71
71
|
</div>
|
|
@@ -76,19 +76,20 @@ import config from '@config'
|
|
|
76
76
|
import { computed, ComputedRef, defineComponent, ref, Ref, watch } from 'vue'
|
|
77
77
|
import { useRoute } from 'vue-router'
|
|
78
78
|
import {
|
|
79
|
-
|
|
79
|
+
getBrowserTheme,
|
|
80
80
|
inIframe,
|
|
81
81
|
isPhone,
|
|
82
82
|
removeEmpty,
|
|
83
|
-
|
|
83
|
+
setTheme,
|
|
84
|
+
Theme,
|
|
84
85
|
watchLang,
|
|
85
|
-
|
|
86
|
-
} from
|
|
86
|
+
watchTheme
|
|
87
|
+
} from "../utils";
|
|
87
88
|
import { bigCamelize } from '@varlet/shared'
|
|
88
89
|
import { get } from 'lodash-es'
|
|
89
90
|
|
|
90
91
|
export default defineComponent({
|
|
91
|
-
setup
|
|
92
|
+
setup() {
|
|
92
93
|
const bigCamelizeComponentName: Ref<string> = ref('')
|
|
93
94
|
const route = useRoute()
|
|
94
95
|
const showBackIcon: Ref<boolean> = ref(false)
|
|
@@ -97,10 +98,9 @@ export default defineComponent({
|
|
|
97
98
|
const languages: Ref<Record<string, string>> = ref(get(config, 'mobile.header.i18n'))
|
|
98
99
|
const nonEmptyLanguages: ComputedRef<Record<string, string>> = computed(() => removeEmpty(languages.value))
|
|
99
100
|
const redirect = get(config, 'mobile.redirect', '')
|
|
100
|
-
const themesKey = get(config, 'themesKey')
|
|
101
101
|
const github: Ref<string> = ref(get(config, 'mobile.header.github'))
|
|
102
102
|
const darkMode: Ref<string> = ref(get(config, 'mobile.header.darkMode'))
|
|
103
|
-
const
|
|
103
|
+
const currentTheme = ref(getBrowserTheme())
|
|
104
104
|
|
|
105
105
|
const changeLanguage = (lang: string) => {
|
|
106
106
|
language.value = lang
|
|
@@ -142,34 +142,34 @@ export default defineComponent({
|
|
|
142
142
|
}
|
|
143
143
|
)
|
|
144
144
|
|
|
145
|
-
const
|
|
145
|
+
const getThemeMessage = () => ({ action: 'theme-change', from: 'mobile', data: currentTheme.value })
|
|
146
146
|
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
window.localStorage.setItem(
|
|
147
|
+
const setCurrentTheme = (theme: Theme) => {
|
|
148
|
+
currentTheme.value = theme
|
|
149
|
+
setTheme(config, currentTheme.value)
|
|
150
|
+
window.localStorage.setItem(get(config, 'themeKey'), currentTheme.value)
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
const toggleTheme = () => {
|
|
154
|
-
|
|
155
|
-
window.postMessage(
|
|
154
|
+
setCurrentTheme(currentTheme.value === 'darkTheme' ? 'lightTheme' : 'darkTheme')
|
|
155
|
+
window.postMessage(getThemeMessage(), '*')
|
|
156
156
|
|
|
157
157
|
if (!isPhone() && inIframe()) {
|
|
158
|
-
;(window.top as any).postMessage(
|
|
158
|
+
;(window.top as any).postMessage(getThemeMessage(), '*')
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
;(window as any).toggleTheme = toggleTheme
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
window.postMessage(
|
|
164
|
+
setTheme(config, currentTheme.value)
|
|
165
|
+
window.postMessage(getThemeMessage(), '*')
|
|
166
166
|
|
|
167
167
|
document.body.addEventListener('click', () => {
|
|
168
168
|
showMenu.value = false
|
|
169
169
|
})
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
from === 'pc' &&
|
|
171
|
+
watchTheme((theme, from) => {
|
|
172
|
+
from === 'pc' && setCurrentTheme(theme)
|
|
173
173
|
})
|
|
174
174
|
|
|
175
175
|
return {
|
|
@@ -180,7 +180,7 @@ export default defineComponent({
|
|
|
180
180
|
languages,
|
|
181
181
|
language,
|
|
182
182
|
nonEmptyLanguages,
|
|
183
|
-
|
|
183
|
+
currentTheme,
|
|
184
184
|
darkMode,
|
|
185
185
|
toGithub,
|
|
186
186
|
back,
|
|
@@ -255,13 +255,13 @@ header {
|
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
.mobile-language-cell {
|
|
258
|
-
color: var(--site-config-color-text);
|
|
259
|
-
background: var(--site-config-color-bar);
|
|
258
|
+
color: var(--site-config-color-text) !important;
|
|
259
|
+
background: var(--site-config-color-bar) !important;
|
|
260
260
|
cursor: pointer;
|
|
261
261
|
|
|
262
262
|
&--active {
|
|
263
|
-
color: var(--site-config-color-mobile-language-active);
|
|
264
|
-
background: var(--site-config-color-mobile-language-active-background);
|
|
263
|
+
color: var(--site-config-color-mobile-language-active) !important;
|
|
264
|
+
background: var(--site-config-color-mobile-language-active-background) !important;
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
|
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
class="var-site-
|
|
4
|
-
:class="{ 'var-site-elevation--3': elevation }"
|
|
3
|
+
:class="classes(n(), [elevation, 'var-site-elevation--3'])"
|
|
5
4
|
:style="{
|
|
6
5
|
background: color,
|
|
7
6
|
color: textColor,
|
|
8
7
|
}"
|
|
9
8
|
>
|
|
10
|
-
<div class="
|
|
9
|
+
<div :class="n('left')">
|
|
11
10
|
<slot name="left" />
|
|
12
|
-
<div
|
|
13
|
-
class="var-site-app-bar__title"
|
|
14
|
-
:style="{ paddingLeft }"
|
|
15
|
-
v-if="titlePosition === 'left'"
|
|
16
|
-
>
|
|
11
|
+
<div :class="n('title')" :style="{ paddingLeft }" v-if="titlePosition === 'left'">
|
|
17
12
|
<slot>{{ title }}</slot>
|
|
18
13
|
</div>
|
|
19
14
|
</div>
|
|
20
15
|
|
|
21
|
-
<div class="
|
|
16
|
+
<div :class="n('title')" v-if="titlePosition === 'center'">
|
|
22
17
|
<slot>{{ title }}</slot>
|
|
23
18
|
</div>
|
|
24
19
|
|
|
25
|
-
<div class="
|
|
26
|
-
<div
|
|
27
|
-
class="var-site-app-bar__title"
|
|
28
|
-
:style="{ paddingRight }"
|
|
29
|
-
v-if="titlePosition === 'right'"
|
|
30
|
-
>
|
|
20
|
+
<div :class="n('right')">
|
|
21
|
+
<div :class="n('title')" :style="{ paddingRight }" v-if="titlePosition === 'right'">
|
|
31
22
|
<slot>{{ title }}</slot>
|
|
32
23
|
</div>
|
|
33
24
|
<slot name="right" />
|
|
@@ -36,11 +27,14 @@
|
|
|
36
27
|
</template>
|
|
37
28
|
|
|
38
29
|
<script lang="ts">
|
|
39
|
-
import {defineComponent,
|
|
30
|
+
import { defineComponent, ref, Ref, onMounted, onUpdated } from 'vue'
|
|
40
31
|
import { props } from './props'
|
|
32
|
+
import { createNamespace } from '../../../components/utils/components'
|
|
33
|
+
|
|
34
|
+
const { n, classes } = createNamespace('app-bar')
|
|
41
35
|
|
|
42
36
|
export default defineComponent({
|
|
43
|
-
name: '
|
|
37
|
+
name: 'VarAppBar',
|
|
44
38
|
props,
|
|
45
39
|
setup(props, { slots }) {
|
|
46
40
|
const paddingLeft: Ref<number | undefined> = ref()
|
|
@@ -55,15 +49,17 @@ export default defineComponent({
|
|
|
55
49
|
onUpdated(computePadding)
|
|
56
50
|
|
|
57
51
|
return {
|
|
52
|
+
n,
|
|
53
|
+
classes,
|
|
58
54
|
paddingLeft,
|
|
59
|
-
paddingRight
|
|
55
|
+
paddingRight,
|
|
60
56
|
}
|
|
61
|
-
}
|
|
57
|
+
},
|
|
62
58
|
})
|
|
63
59
|
</script>
|
|
64
60
|
|
|
65
61
|
<style lang="less">
|
|
66
|
-
@import '
|
|
67
|
-
@import '
|
|
62
|
+
@import '../../../components/styles/common';
|
|
63
|
+
@import '../../../components/styles/elevation';
|
|
68
64
|
@import './appBar';
|
|
69
65
|
</style>
|
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
.var-site-app-bar {
|
|
18
18
|
position: relative;
|
|
19
19
|
display: flex;
|
|
20
|
+
width: 100%;
|
|
20
21
|
justify-content: center;
|
|
21
22
|
align-items: center;
|
|
22
23
|
height: var(--site-app-bar-height);
|
|
23
24
|
background: var(--site-app-bar-color);
|
|
24
25
|
color: var(--site-app-bar-text-color);
|
|
25
|
-
transition: background-color .25s;
|
|
26
|
+
transition: background-color 0.25s;
|
|
26
27
|
|
|
27
28
|
&__title {
|
|
28
29
|
flex: 1;
|
package/site/mobile/main.ts
CHANGED
|
@@ -46,8 +46,12 @@ router.beforeEach((to: any) => {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
if (!isPhone() && inIframe()) {
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
try {
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
window.top.onMobileRouteChange(path, language, replace)
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.log(e)
|
|
54
|
+
}
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
// @ts-ignore
|