-
Notifications
You must be signed in to change notification settings - Fork 328
fix: fix change theme error when open playground #2681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { tinyOldTheme, tinyAuroraTheme } from '@opentiny/vue-theme/theme-tool' | ||
|
||
// localStorage中保存语言的key | ||
export const LANG_KEY = '_lang' | ||
// localStorage中保存语言的value | ||
|
@@ -12,17 +14,17 @@ export const LANG_PATH_MAP = { | |
export const CURRENT_THEME_KEY = 'tiny-current-theme' | ||
|
||
// 主题 | ||
export const DEFAULT_THEME = 'tiny-default-theme' | ||
export const AURORA_THEME = 'tiny-aurora-theme' | ||
export const SMB_THEME = 'tiny-smb-theme' | ||
export const INFINITY_THEME = 'tiny-infinity-theme' | ||
export const DEFAULT_THEME = 'os-theme' | ||
export const AURORA_THEME = 'aurora-theme' | ||
export const SMB_THEME = 'smb-theme' | ||
export const OLD_THEME = 'old-theme' | ||
Comment on lines
+17
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Theme constant values need to be updated across multiple files The verification reveals several files still using the old theme values with 'tiny-' prefix that need to be updated to match the new simplified theme constants:
🔗 Analysis chainVerify theme constant value changes across the codebase The theme constant values have been simplified by removing the 'tiny-' prefix. This change could impact other parts of the codebase that might be using the old values. Let's examine the actual usage of these theme values in the found files to determine if they need updates. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for any remaining references to old theme values
rg -l "tiny-(default|aurora|smb)-theme"
Length of output: 235 Script: #!/bin/bash
# Check the context of theme value usage in the affected files
echo "=== float-settings.vue ==="
rg -A 2 -B 2 "tiny-(default|aurora|smb)-theme" examples/sites/src/views/components/float-settings.vue
echo -e "\n=== useTheme.js ==="
rg -A 2 -B 2 "tiny-(default|aurora|smb)-theme" examples/docs/newsrc/uses/useTheme.js
echo -e "\n=== pc.vue ==="
rg -A 2 -B 2 "tiny-(default|aurora|smb)-theme" examples/docs/newsrc/pc.vue
echo -e "\n=== aurora-theme-index.js ==="
rg -A 2 -B 2 "tiny-(default|aurora|smb)-theme" packages/theme/src/aurora-theme-index.js
echo -e "\n=== release.js ==="
rg -A 2 -B 2 "tiny-(default|aurora|smb)-theme" packages/theme/build/release.js
Length of output: 2210 |
||
|
||
// 主题对应路由参数映射表 | ||
export const THEME_ROUTE_MAP = { | ||
[DEFAULT_THEME]: 'os-theme', | ||
[AURORA_THEME]: 'aurora-theme', | ||
[SMB_THEME]: 'smb-theme', | ||
[INFINITY_THEME]: 'infinity-theme' | ||
// 主题工具导出主题变量和主题的映射关系 | ||
export const themeToolValuesMap = { | ||
[DEFAULT_THEME]: '', | ||
[AURORA_THEME]: tinyAuroraTheme, | ||
[SMB_THEME]: '', | ||
[OLD_THEME]: tinyOldTheme | ||
Comment on lines
+22
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review empty theme implementations in themeToolValuesMap The map contains empty string values for Please clarify:
|
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,62 +4,44 @@ import designSaasConfig from '@opentiny/vue-design-saas' | |
import designSMBConfig from '@opentiny/vue-design-smb' | ||
import { router } from '@/router' | ||
import { appData } from './appData' | ||
import { THEME_ROUTE_MAP, CURRENT_THEME_KEY, DEFAULT_THEME, AURORA_THEME, SMB_THEME, INFINITY_THEME } from '../const' | ||
import { CURRENT_THEME_KEY, DEFAULT_THEME, AURORA_THEME, OLD_THEME, themeToolValuesMap } from '../const' | ||
import glaciers from '@/assets/images/glaciers.png' | ||
import glaciersIcon from '@/assets/images/glaciers-icon.png' | ||
|
||
import infinitely from '@/assets/images/Infinitely.png' | ||
import infinitelyIcon from '@/assets/images/Infinitely-icon.png' | ||
|
||
import oceanic from '@/assets/images/oceanic.png' | ||
import oceanicIcon from '@/assets/images/oceanic-icon.png' | ||
|
||
import starrySky from '@/assets/images/starry-sky.png' | ||
import starrySkyIcon from '@/assets/images/starry-sky-icon.png' | ||
import TinyThemeTool, { tinyOldTheme, tinyAuroraTheme } from '@opentiny/vue-theme/theme-tool' | ||
import TinyThemeTool from '@opentiny/vue-theme/theme-tool' | ||
|
||
const isEn = appData.lang === 'enUS' | ||
|
||
const themeData = [ | ||
{ | ||
value: [DEFAULT_THEME], | ||
label: isEn ? 'Default Theme' : '冰川主题', | ||
tips: isEn ? 'Accurate, Efficient, Distinct' : '精准、高效、清晰', | ||
icon: glaciersIcon, | ||
bgImage: glaciers | ||
}, | ||
{ | ||
value: [SMB_THEME], | ||
label: isEn ? 'Star Theme' : '星空主题', | ||
tips: isEn ? 'Leading, Innovative, Reliable' : '领先、创新、信赖', | ||
icon: starrySkyIcon, | ||
bgImage: starrySky | ||
}, | ||
{ | ||
value: [OLD_THEME], | ||
label: isEn ? 'Default Theme' : '冰川主题', | ||
tips: isEn ? 'Accurate, Efficient, Distinct' : '精准、高效、清晰', | ||
icon: glaciersIcon, | ||
bgImage: glaciers | ||
}, | ||
Comment on lines
+28
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the evidence gathered, I can now provide the final response: Theme metadata for OLD_THEME is inconsistent with its identifier The OLD_THEME (defined as 'old-theme' in const.ts) is being presented with misleading metadata:
This creates a confusing user experience as the theme name 'old-theme' doesn't match its presentation as a glacier/default theme. The theme metadata should accurately reflect the theme's identity and visual characteristics. 🔗 Analysis chainVerify theme metadata for OLD_THEME The OLD_THEME entry reuses the "冰川主题" (Glacier theme) metadata. This might be confusing for users if the visual appearance doesn't match the theme name and description. Let me check the content of these files to understand how the theme names and descriptions are used. Let me check the OLD_THEME definition and usage to understand its relationship with the theme metadata. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for other occurrences of theme names/descriptions
rg -l "冰川主题|Glacier theme|Default Theme"
Length of output: 254 Script: #!/bin/bash
# Check content of files containing theme references
echo "=== useTheme.js ==="
rg -A 2 -B 2 "冰川主题|Glacier theme|Default Theme" examples/sites/src/tools/useTheme.js
echo -e "\n=== changelog.md ==="
rg -A 2 -B 2 "冰川主题|Glacier theme|Default Theme" examples/sites/demos/pc/webdoc/changelog.md
echo -e "\n=== theme-en.md ==="
rg -A 2 -B 2 "冰川主题|Glacier theme|Default Theme" examples/sites/demos/pc/webdoc/theme-en.md
echo -e "\n=== badge.js ==="
rg -A 2 -B 2 "冰川主题|Glacier theme|Default Theme" examples/sites/demos/mobile-first/app/badge/webdoc/badge.js
echo -e "\n=== pc.vue ==="
rg -A 2 -B 2 "冰川主题|Glacier theme|Default Theme" examples/docs/newsrc/pc.vue
Length of output: 2302 Script: #!/bin/bash
# Search for OLD_THEME definition and usage
echo "=== OLD_THEME definition ==="
rg -A 2 -B 2 "OLD_THEME.*=|const.*OLD_THEME|let.*OLD_THEME|var.*OLD_THEME"
echo -e "\n=== OLD_THEME usage ==="
rg -A 2 -B 2 "OLD_THEME"
Length of output: 1823 |
||
{ | ||
value: [AURORA_THEME], | ||
label: isEn ? 'Ocean Theme' : '海洋主题', | ||
tips: isEn ? 'Simple, Agile, Delightful' : '简约、敏捷、愉悦', | ||
icon: oceanicIcon, | ||
bgImage: oceanic | ||
}, | ||
{ | ||
value: [INFINITY_THEME], | ||
label: isEn ? 'Infinity Theme' : '无限主题', | ||
tips: isEn ? 'Creative, Scientific, Efficient' : '创造、科学、高效', | ||
icon: infinitelyIcon, | ||
bgImage: infinitely | ||
} | ||
] | ||
|
||
const designConfigMap = { | ||
[DEFAULT_THEME]: {}, | ||
[INFINITY_THEME]: {}, | ||
[AURORA_THEME]: {}, | ||
[SMB_THEME]: {} | ||
} | ||
|
||
const defaultThemeKey = DEFAULT_THEME | ||
const currentThemeKey = hooks.ref(defaultThemeKey) | ||
const currentThemeKey = hooks.ref(DEFAULT_THEME) | ||
|
||
watch( | ||
() => currentThemeKey.value, | ||
|
@@ -82,7 +64,7 @@ const designConfig = computed(() => { | |
const changeTheme = (themeKey) => { | ||
router.push({ | ||
params: { | ||
theme: THEME_ROUTE_MAP[themeKey] | ||
theme: themeKey | ||
}, | ||
hash: router?.currentRoute.value.hash | ||
}) | ||
|
@@ -101,14 +83,10 @@ const watchRoute = () => { | |
watch( | ||
() => router.currentRoute.value.params.theme, | ||
(val) => { | ||
if (!loadedTheme && val === 'old-theme') { | ||
const themeTool = new TinyThemeTool() | ||
themeTool.changeTheme(tinyOldTheme) | ||
loadedTheme = true | ||
} | ||
if (!loadedTheme && val === 'aurora-theme') { | ||
if (!loadedTheme && themeToolValuesMap[val]) { | ||
currentThemeKey.value = val | ||
const themeTool = new TinyThemeTool() | ||
themeTool.changeTheme(tinyAuroraTheme) | ||
themeTool.changeTheme(themeToolValuesMap[val]) | ||
Comment on lines
+86
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review theme loading logic The theme loading logic has potential issues:
Consider these improvements: watch(
() => router.currentRoute.value.params.theme,
(val) => {
- if (!loadedTheme && themeToolValuesMap[val]) {
+ if (themeToolValuesMap[val]) {
currentThemeKey.value = val
const themeTool = new TinyThemeTool()
themeTool.changeTheme(themeToolValuesMap[val])
- loadedTheme = true
+ } else {
+ console.warn(`Theme '${val}' not found in themeToolValuesMap`)
}
}
)
|
||
loadedTheme = true | ||
} | ||
} | ||
|
@@ -122,6 +100,6 @@ export default function useTheme() { | |
changeTheme, | ||
currentThemeKey, | ||
designConfig, | ||
defaultTheme: THEME_ROUTE_MAP[defaultThemeKey] | ||
defaultTheme: DEFAULT_THEME | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking Change: Renamed 'infinity' theme to 'old'
This change removes support for the 'infinity' theme key, which could break existing implementations using this theme.
Consider: