杂务:更新 YumiNail 工作区
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const root = path.join(__dirname, '..')
|
||||
const appWxss = fs.readFileSync(path.join(root, 'app.wxss'), 'utf8')
|
||||
const productCardWxss = fs.readFileSync(path.join(root, 'components', 'product-card', 'product-card.wxss'), 'utf8')
|
||||
const navigationBarWxss = fs.readFileSync(path.join(root, 'components', 'navigation-bar', 'navigation-bar.wxss'), 'utf8')
|
||||
const pageRoot = path.join(root, 'pages')
|
||||
const legacyThemeColorPattern = /#(?:2d2430|1f1b17|8d7a84|7a5262|c6597d|C6597D|FFF7F9|FFF8F4)\b/
|
||||
|
||||
function readPageSources(dir) {
|
||||
return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
||||
const fullPath = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) {
|
||||
return readPageSources(fullPath)
|
||||
}
|
||||
if (!/\.(?:wxml|wxss)$/.test(entry.name)) {
|
||||
return []
|
||||
}
|
||||
return [{ file: path.relative(root, fullPath), source: fs.readFileSync(fullPath, 'utf8') }]
|
||||
})
|
||||
}
|
||||
|
||||
assert.ok(appWxss.includes('--theme-neutral: #4A443F;'))
|
||||
assert.ok(appWxss.includes('--theme-tertiary: #FDFBF9;'))
|
||||
assert.ok(appWxss.includes('.yumi-page'))
|
||||
assert.ok(appWxss.includes('.yumi-glass-card'))
|
||||
assert.ok(appWxss.includes('.yumi-status-chip'))
|
||||
assert.ok(appWxss.includes('.yumi-bottom-action'))
|
||||
assert.ok(!/--theme-primary:\s*#7c5357/i.test(appWxss))
|
||||
|
||||
assert.ok(productCardWxss.includes('background: rgba(255, 255, 255, 0.86);'))
|
||||
assert.ok(productCardWxss.includes('color: var(--text-primary);'))
|
||||
assert.ok(productCardWxss.includes('color: var(--text-secondary);'))
|
||||
assert.ok(navigationBarWxss.includes('backdrop-filter: blur(20rpx);'))
|
||||
assert.ok(navigationBarWxss.includes('color: var(--theme-neutral);'))
|
||||
|
||||
for (const { file, source } of [{ file: 'app.wxss', source: appWxss }, ...readPageSources(pageRoot)]) {
|
||||
assert.ok(!legacyThemeColorPattern.test(source), `${file} should use Luminous theme variables instead of legacy hardcoded theme colors`)
|
||||
}
|
||||
@@ -84,13 +84,51 @@ function normalizeActionPath(value) {
|
||||
if (!rawPath || !rawPath.startsWith('/') || rawPath.startsWith('//')) {
|
||||
return ''
|
||||
}
|
||||
const queryIndex = rawPath.indexOf('?')
|
||||
const pathOnly = queryIndex >= 0 ? rawPath.slice(0, queryIndex) : rawPath
|
||||
const query = queryIndex >= 0 ? rawPath.slice(queryIndex) : ''
|
||||
|
||||
if (rawPath.startsWith('/orders')) {
|
||||
const queryIndex = rawPath.indexOf('?')
|
||||
const query = queryIndex >= 0 ? rawPath.slice(queryIndex) : ''
|
||||
if (pathOnly.startsWith('/orders/')) {
|
||||
const id = pathOnly.split('/')[2] || ''
|
||||
return buildUrl('/pages/order-detail/index', { id })
|
||||
}
|
||||
|
||||
if (pathOnly === '/orders') {
|
||||
return `/pages/orders/index${query}`
|
||||
}
|
||||
|
||||
if (pathOnly === '/after-sales') {
|
||||
return `/pages/after-sales/index${query}`
|
||||
}
|
||||
|
||||
if (pathOnly === '/after-sale/apply') {
|
||||
return `/pages/after-sale-apply/index${query}`
|
||||
}
|
||||
|
||||
if (pathOnly === '/service-progress') {
|
||||
return `/pages/service-progress/index${query}`
|
||||
}
|
||||
|
||||
if (pathOnly === '/help') {
|
||||
return `/pages/help/index${query}`
|
||||
}
|
||||
|
||||
if (pathOnly === '/artist-orders') {
|
||||
return `/pages/artist-orders/index${query}`
|
||||
}
|
||||
|
||||
if (pathOnly === '/artist-calendar') {
|
||||
return `/pages/artist-calendar/index${query}`
|
||||
}
|
||||
|
||||
if (pathOnly === '/settings/account') {
|
||||
return `/pages/account-settings/index${query}`
|
||||
}
|
||||
|
||||
if (pathOnly === '/settings/password') {
|
||||
return `/pages/password-settings/index${query}`
|
||||
}
|
||||
|
||||
if (rawPath.startsWith('/product/')) {
|
||||
const id = rawPath.split('/')[2] || ''
|
||||
return buildUrl('/pages/product-detail/index', { id })
|
||||
@@ -135,9 +173,18 @@ function buildMessageActionPath(message) {
|
||||
|
||||
const businessType = String(message.businessType || '').toUpperCase()
|
||||
const businessId = message.businessId || ''
|
||||
if (businessType === 'ORDER' && businessId) {
|
||||
return buildUrl('/pages/order-detail/index', { id: businessId })
|
||||
}
|
||||
if (businessType === 'ORDER_ARTIST_CHANGE' && businessId) {
|
||||
return buildUrl('/pages/service-progress/index', { orderId: businessId })
|
||||
}
|
||||
if (businessType === 'ORDER_ARTIST_REVIEW' || businessType === 'ORDER_ARTIST_CHANGE' || businessType === 'ORDER') {
|
||||
return buildUrl('/pages/orders/index', businessId ? { orderId: businessId } : {})
|
||||
}
|
||||
if (businessType === 'AFTER_SALE') {
|
||||
return buildUrl('/pages/after-sales/index', businessId ? { orderId: businessId } : {})
|
||||
}
|
||||
if (businessType === 'PRODUCT') {
|
||||
return buildUrl('/pages/product-detail/index', businessId ? { id: businessId } : {})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
const assert = require('assert')
|
||||
const navigation = require('./navigation')
|
||||
const { TAB_PAGES } = require('./config')
|
||||
|
||||
assert.strictEqual(
|
||||
navigation.normalizeActionPath('/orders/10'),
|
||||
'/pages/order-detail/index?id=10'
|
||||
)
|
||||
|
||||
assert.strictEqual(
|
||||
navigation.normalizeActionPath('/after-sales?orderId=10'),
|
||||
'/pages/after-sales/index?orderId=10'
|
||||
)
|
||||
|
||||
assert.strictEqual(
|
||||
navigation.normalizeActionPath('/after-sale/apply?orderId=10&orderItemId=99'),
|
||||
'/pages/after-sale-apply/index?orderId=10&orderItemId=99'
|
||||
)
|
||||
|
||||
assert.strictEqual(
|
||||
navigation.normalizeActionPath('/service-progress?orderId=10'),
|
||||
'/pages/service-progress/index?orderId=10'
|
||||
)
|
||||
|
||||
assert.strictEqual(
|
||||
navigation.buildMessageActionPath({ businessType: 'ORDER', businessId: 10 }),
|
||||
'/pages/order-detail/index?id=10'
|
||||
)
|
||||
|
||||
assert.strictEqual(
|
||||
navigation.buildMessageActionPath({ businessType: 'AFTER_SALE', businessId: 10 }),
|
||||
'/pages/after-sales/index?orderId=10'
|
||||
)
|
||||
|
||||
assert.ok(TAB_PAGES.includes('/pages/home/index'))
|
||||
@@ -69,12 +69,18 @@ function buildStyleVars(theme) {
|
||||
`--theme-primary: ${theme.primaryColor};`,
|
||||
`--theme-secondary: ${theme.secondaryColor};`,
|
||||
`--theme-accent: ${theme.accentColor};`,
|
||||
`--theme-neutral: ${theme.neutralColor || theme.accentColor};`,
|
||||
`--theme-tertiary: ${theme.tertiaryColor || theme.pageBgColor};`,
|
||||
`--theme-primary-action: ${theme.primaryActionColor};`,
|
||||
`--theme-page-bg: ${theme.pageBgColor};`,
|
||||
`--theme-card-bg: ${theme.cardBgColor};`,
|
||||
`--theme-border: ${theme.borderColor};`,
|
||||
`--theme-primary-soft: ${theme.primarySoftColor};`,
|
||||
`--theme-secondary-soft: ${theme.secondarySoftColor};`,
|
||||
`--theme-gradient: ${theme.gradient};`,
|
||||
`--theme-gradient-soft: ${theme.softGradient};`
|
||||
`--theme-gradient-soft: ${theme.softGradient};`,
|
||||
`--text-primary: ${theme.textPrimary};`,
|
||||
`--text-secondary: ${theme.textSecondary};`
|
||||
]
|
||||
if (theme.backgroundImageUrl) {
|
||||
styleVars.push(
|
||||
@@ -95,15 +101,21 @@ function resolveShopTheme(source) {
|
||||
const normalizedPrimaryColor = normalizeHexColor(themeSource.themePrimaryColor)
|
||||
const primaryColor = normalizedPrimaryColor || DEFAULT_SHOP_THEME.primaryColor
|
||||
const secondaryColor = normalizeHexColor(themeSource.themeSecondaryColor)
|
||||
|| (normalizedPrimaryColor ? mixColor(primaryColor, '#FFFFFF', 0.68) : DEFAULT_SHOP_THEME.secondaryColor)
|
||||
const accentColor = normalizeHexColor(themeSource.themeAccentColor)
|
||||
|| (normalizedPrimaryColor ? mixColor(primaryColor, '#7A3F56', 0.38) : DEFAULT_SHOP_THEME.accentColor)
|
||||
const pageBgColor = normalizeHexColor(themeSource.themePageBgColor) || DEFAULT_SHOP_THEME.pageBgColor
|
||||
|| (normalizedPrimaryColor ? mixColor(primaryColor, DEFAULT_SHOP_THEME.secondaryColor, 0.35) : DEFAULT_SHOP_THEME.secondaryColor)
|
||||
const neutralColor = normalizeHexColor(themeSource.themeAccentColor)
|
||||
|| (normalizedPrimaryColor ? mixColor(DEFAULT_SHOP_THEME.neutralColor, primaryColor, 0.14) : DEFAULT_SHOP_THEME.neutralColor)
|
||||
const accentColor = neutralColor
|
||||
const tertiaryColor = normalizeHexColor(themeSource.themePageBgColor) || DEFAULT_SHOP_THEME.tertiaryColor
|
||||
const pageBgColor = tertiaryColor
|
||||
const cardBgColor = normalizeHexColor(themeSource.themeCardBgColor) || DEFAULT_SHOP_THEME.cardBgColor
|
||||
const borderColor = mixColor(primaryColor, cardBgColor, 0.82)
|
||||
const primarySoftColor = mixColor(primaryColor, cardBgColor, 0.88)
|
||||
const gradient = `linear-gradient(135deg, ${primaryColor} 0%, ${secondaryColor} 100%)`
|
||||
const softGradient = `linear-gradient(145deg, ${cardBgColor} 0%, ${mixColor(secondaryColor, pageBgColor, 0.55)} 58%, ${mixColor(primaryColor, pageBgColor, 0.82)} 100%)`
|
||||
const textPrimary = neutralColor
|
||||
const textSecondary = mixColor(neutralColor, cardBgColor, 0.18)
|
||||
const borderColor = mixColor(primaryColor, cardBgColor, 0.72)
|
||||
const primarySoftColor = mixColor(primaryColor, cardBgColor, 0.78)
|
||||
const secondarySoftColor = mixColor(secondaryColor, pageBgColor, 0.66)
|
||||
const primaryActionColor = mixColor(neutralColor, primaryColor, 0.28)
|
||||
const gradient = `linear-gradient(135deg, ${primaryActionColor} 0%, ${secondaryColor} 100%)`
|
||||
const softGradient = `linear-gradient(145deg, ${cardBgColor} 0%, ${secondarySoftColor} 58%, ${mixColor(primaryColor, pageBgColor, 0.62)} 100%)`
|
||||
const backgroundImageFileId = themeSource.themeBackgroundImageFileId
|
||||
? String(themeSource.themeBackgroundImageFileId).trim()
|
||||
: ''
|
||||
@@ -114,10 +126,16 @@ function resolveShopTheme(source) {
|
||||
primaryColor,
|
||||
secondaryColor,
|
||||
accentColor,
|
||||
tertiaryColor,
|
||||
neutralColor,
|
||||
pageBgColor,
|
||||
cardBgColor,
|
||||
textPrimary,
|
||||
textSecondary,
|
||||
borderColor,
|
||||
primarySoftColor,
|
||||
secondarySoftColor,
|
||||
primaryActionColor,
|
||||
gradient,
|
||||
softGradient,
|
||||
backgroundImageFileId,
|
||||
@@ -132,15 +150,21 @@ function resolveShopTheme(source) {
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
*/
|
||||
const DEFAULT_SHOP_THEME = {
|
||||
primaryColor: '#C6597D',
|
||||
secondaryColor: '#E9B7C7',
|
||||
accentColor: '#9F4967',
|
||||
pageBgColor: '#FFF7F9',
|
||||
primaryColor: '#E8B4B8',
|
||||
secondaryColor: '#C5A059',
|
||||
accentColor: '#4A443F',
|
||||
tertiaryColor: '#FDFBF9',
|
||||
neutralColor: '#4A443F',
|
||||
pageBgColor: '#FDFBF9',
|
||||
cardBgColor: '#FFFFFF',
|
||||
borderColor: '#EFD8E0',
|
||||
primarySoftColor: '#FBF1F4',
|
||||
gradient: 'linear-gradient(135deg, #C6597D 0%, #E9B7C7 100%)',
|
||||
softGradient: 'linear-gradient(145deg, #FFFFFF 0%, #FFF1F5 58%, #FFE8EF 100%)',
|
||||
textPrimary: '#4A443F',
|
||||
textSecondary: '#6B6662',
|
||||
borderColor: '#F9EAEC',
|
||||
primarySoftColor: '#FAEFF0',
|
||||
secondarySoftColor: '#EADCC2',
|
||||
primaryActionColor: '#766361',
|
||||
gradient: 'linear-gradient(135deg, #766361 0%, #C5A059 100%)',
|
||||
softGradient: 'linear-gradient(145deg, #FFFFFF 0%, #EADCC2 58%, #F5E0E0 100%)',
|
||||
backgroundImageFileId: '',
|
||||
backgroundImageUrl: ''
|
||||
}
|
||||
|
||||
@@ -9,6 +9,13 @@ const assert = require('assert')
|
||||
*/
|
||||
const theme = require('./theme')
|
||||
|
||||
assert.strictEqual(theme.DEFAULT_SHOP_THEME.primaryColor, '#E8B4B8')
|
||||
assert.strictEqual(theme.DEFAULT_SHOP_THEME.secondaryColor, '#C5A059')
|
||||
assert.strictEqual(theme.DEFAULT_SHOP_THEME.accentColor, '#4A443F')
|
||||
assert.strictEqual(theme.DEFAULT_SHOP_THEME.pageBgColor, '#FDFBF9')
|
||||
assert.ok(theme.DEFAULT_SHOP_THEME.styleVars.includes('--theme-neutral: #4A443F;'))
|
||||
assert.ok(theme.DEFAULT_SHOP_THEME.styleVars.includes('--theme-tertiary: #FDFBF9;'))
|
||||
|
||||
/**
|
||||
* Purpose: customized supports theme.test.js by holding or executing the customized page or API role.
|
||||
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
||||
@@ -29,7 +36,9 @@ assert.strictEqual(customized.pageBgColor, '#FFF8FA')
|
||||
assert.strictEqual(customized.cardBgColor, '#FFFFFF')
|
||||
assert.strictEqual(customized.backgroundImageFileId, 'bg-file')
|
||||
assert.ok(customized.styleVars.includes('--theme-primary: #8B4F65;'))
|
||||
assert.ok(customized.styleVars.includes('--theme-gradient: linear-gradient(135deg, #8B4F65 0%, #F2C9D4 100%);'))
|
||||
assert.ok(customized.styleVars.includes('--theme-neutral: #B86F84;'))
|
||||
assert.ok(customized.styleVars.includes('--theme-primary-action: #AB667B;'))
|
||||
assert.ok(customized.styleVars.includes('--theme-gradient: linear-gradient(135deg, #AB667B 0%, #F2C9D4 100%);'))
|
||||
|
||||
/**
|
||||
* Purpose: themedPageData supports theme.test.js by holding or executing the themed page data page or API role.
|
||||
|
||||
Reference in New Issue
Block a user