Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions packages/hap-compiler/src/style/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,24 @@ const validateTime = function (v) {
}
}
}

// 灵感组件颜色值
const themeColors = [
'uxCardColorTheme',
'uxCardColorAccent',
'uxCardColorPrimary',
'uxCardColorSecondary',
'uxCardColorSecondaryVariant',
'uxCardColorTertiary',
'uxCardColorQuaternary',
'uxCardColorContainer',
'uxCardBackground',
'uxCardColorHue',
'uxCardColorHueSecondary',
'uxIconColorAccent',
'uxIconColorPrimary',
'uxIconColorSecondary',
'uxIconColorBackground'
]
const validator = {
/**
* 整数校验
Expand Down Expand Up @@ -2657,23 +2674,13 @@ const validatorMap = {
// font
fontSrc: validator.fontSrc,
fontFamily: validator.fontFamily,
themeColor: makeEnumValidator([
'uxCardColorTheme',
'uxCardColorAccent',
'uxCardColorPrimary',
'uxCardColorSecondary',
'uxCardColorSecondaryVariant',
'uxCardColorTertiary',
'uxCardColorQuaternary',
'uxCardColorContainer',
'uxCardBackground',
'uxCardColorHue',
'uxCardColorHueSecondary',
'uxIconColorAccent',
'uxIconColorPrimary',
'uxIconColorSecondary',
'uxIconColorBackground'
])
themeColor: makeEnumValidator(themeColors),
themeBackgroundColor: makeEnumValidator(themeColors),
themeLayerColor: makeEnumValidator(themeColors),
themeThumbColor: makeEnumValidator(themeColors),
themeTrackColor: makeEnumValidator(themeColors),
themeSelectColor: makeEnumValidator(themeColors),
themeBlockColor: makeEnumValidator(themeColors)
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/hap-server/src/preview/create-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ export default async function createRouter(previewTarget) {
script,
scriptNotFound: !scriptExists(script),
webJsUrl: genWebJsUrl(ctx.conf.options.webVersion),
language: currentLanguage
language: currentLanguage,
mediaQueryParams: JSON.stringify(ctx.conf.options.mediaQueryParams) // 传给页面的媒介查询参数
})
ctx.type = 'text/html'
ctx.body = html
Expand Down
1 change: 1 addition & 0 deletions packages/hap-server/src/preview/views/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
var base = '/preview'
var type = '{{ type }}'
window.language = `{{language}}`
window.mediaQueryParams = JSON.parse(`{{mediaQueryParams}}`)
;(function preview() {
var routeName = '{{ routeName }}'
Hap.init({
Expand Down