fix: propVisual 字符串 emoji 取 .emoji 恒兜底 🎁(Task 6 审查修复)+ 朗读状态复位与定时器清理
This commit is contained in:
@@ -16,18 +16,22 @@ export default {
|
||||
label: { type: String, default: '听一听' }
|
||||
},
|
||||
data() {
|
||||
return { speaking: false }
|
||||
return { speaking: false, timer: null }
|
||||
},
|
||||
methods: {
|
||||
toggle() {
|
||||
if (this.speaking) {
|
||||
clearTimeout(this.timer)
|
||||
this.timer = null
|
||||
stopSpeak()
|
||||
this.speaking = false
|
||||
return
|
||||
}
|
||||
speak(this.text, this.file)
|
||||
this.speaking = true
|
||||
setTimeout(() => (this.speaking = false), 3000)
|
||||
if (this.text || this.file) {
|
||||
this.speaking = true
|
||||
this.timer = setTimeout(() => (this.speaking = false), 3000)
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeUnmount() {
|
||||
|
||||
@@ -16,6 +16,7 @@ function speakBrowser(text) {
|
||||
const u = new SpeechSynthesisUtterance(text)
|
||||
u.lang = 'zh-CN'
|
||||
u.rate = 0.9
|
||||
u.onend = u.onerror = () => { uttering = false }
|
||||
window.speechSynthesis.speak(u)
|
||||
uttering = true
|
||||
}
|
||||
|
||||
@@ -6,13 +6,15 @@ const SCENE_MAP = {
|
||||
商店: { emoji: '🏪', color: '#f6d365' }, 超市: { emoji: '🛒', color: '#f6d365' },
|
||||
游乐场: { emoji: '🎠', color: '#ff9a9e' }, 路上: { emoji: '🛤️', color: '#d5c4ae' },
|
||||
食堂: { emoji: '🍚', color: '#ffe0ac' }, 图书馆: { emoji: '📚', color: '#b8a6d9' },
|
||||
海滩: { emoji: '🏖️', color: '#83e3e8' }, 泳池: { emoji: '🏊', color: '#83e3e8' }
|
||||
海滩: { emoji: '🏖️', color: '#83e3e8' }, 泳池: { emoji: '🏊', color: '#83e3e8' },
|
||||
外婆家: { emoji: '🏡', color: '#ffd08a' }
|
||||
}
|
||||
const PROP_MAP = {
|
||||
画: '🖼️', 书: '📖', 剪刀: '✂️', 长杆: '🥢', 扫帚: '🧹', 绳子: '🪢',
|
||||
球: '⚽', 玩具: '🧸', 手机: '📱', 钥匙: '🔑', 雨伞: '☂️', 帽子: '🧢',
|
||||
凳子: '🪑', 书包: '🎒', 水杯: '🥤', 饼干: '🍪', 铅笔: '✏️', 纸: '📄',
|
||||
胶水: '🧴', 篮子: '🧺', 喇叭: '📢', 鼓: '🥁', 娃娃: '🎎', 积木: '🧱'
|
||||
胶水: '🧴', 篮子: '🧺', 喇叭: '📢', 鼓: '🥁', 娃娃: '🎎', 积木: '🧱',
|
||||
调色盘: '🎨', 蜡笔: '✏️', 电池: '🔋', 瓜子: '🥜', 苹果: '🍎', 小汽车: '🚗'
|
||||
}
|
||||
|
||||
function pick(list, key, fallback) {
|
||||
@@ -28,7 +30,7 @@ export function sceneVisual(name) {
|
||||
}
|
||||
|
||||
export function propVisual(name) {
|
||||
return { emoji: pick(PROP_MAP, name || '', '🎁').emoji || '🎁', color: '#fff0e5' }
|
||||
return { emoji: pick(PROP_MAP, name || '', '🎁'), color: '#fff0e5' }
|
||||
}
|
||||
|
||||
const PERSON_COLORS = ['#ff9a3d', '#ff6b6b', '#4ecdc4', '#6c8cff', '#a58cff', '#ffb347']
|
||||
|
||||
Reference in New Issue
Block a user