mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-07 04:52:45 +08:00
Merge pull request #369 from jxxghp/cursor/fix-pwa-install-prompt-text-display-14c8
Fix PWA install prompt text display
This commit is contained in:
16626
package-lock.json
generated
Normal file
16626
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -62,31 +62,7 @@ const dismissBanner = () => {
|
||||
localStorage.setItem('pwa-install-dismissed', new Date().toISOString())
|
||||
}
|
||||
|
||||
// 从编译对象中提取文本
|
||||
const extractText = (obj: any): string => {
|
||||
// 如果是字符串直接返回
|
||||
if (typeof obj === 'string') return obj
|
||||
|
||||
// 如果是对象,尝试多种方式获取文本
|
||||
if (obj) {
|
||||
// 尝试获取编译对象中的静态文本
|
||||
if (obj.body?.static) return obj.body.static
|
||||
// 尝试获取源文本
|
||||
if (obj.source) return obj.source
|
||||
// 尝试获取文本属性
|
||||
if (obj.text) return obj.text
|
||||
// 尝试获取值属性
|
||||
if (obj.value) return obj.value
|
||||
// 如果对象可以转换为字符串
|
||||
if (obj.toString && typeof obj.toString === 'function' && obj.toString() !== '[object Object]') {
|
||||
return obj.toString()
|
||||
}
|
||||
}
|
||||
|
||||
// 如果都获取不到,返回空字符串
|
||||
console.warn('Failed to extract text from object:', obj)
|
||||
return ''
|
||||
}
|
||||
|
||||
// 获取平台特定的安装说明
|
||||
const instructions = computed(() => {
|
||||
@@ -96,11 +72,26 @@ const instructions = computed(() => {
|
||||
// 获取平台显示名称
|
||||
const platformName = t(`pwa.platforms.${platformKey}`)
|
||||
|
||||
// 获取安装步骤
|
||||
const currentLocale = unref(locale) as string
|
||||
const currentMessages = messages.value[currentLocale] || messages.value['zh-CN']
|
||||
const rawSteps = (currentMessages as any).pwa?.installSteps?.[platformKey] || []
|
||||
const steps = Array.isArray(rawSteps) ? rawSteps.map(extractText) : []
|
||||
// 直接使用t函数获取安装步骤,避免编译对象的问题
|
||||
const steps = []
|
||||
const maxSteps = 10 // 最大步骤数,防止无限循环
|
||||
|
||||
for (let i = 0; i < maxSteps; i++) {
|
||||
try {
|
||||
const stepKey = `pwa.installSteps.${platformKey}.${i}`
|
||||
const stepText = t(stepKey)
|
||||
|
||||
// 如果返回的是键名本身,说明没有找到对应的翻译
|
||||
if (stepText === stepKey) {
|
||||
break
|
||||
}
|
||||
|
||||
steps.push(stepText)
|
||||
} catch (error) {
|
||||
// 如果出现错误,说明没有更多步骤
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
platform: platformName,
|
||||
|
||||
@@ -171,51 +171,51 @@ export default {
|
||||
},
|
||||
// Installation steps
|
||||
installSteps: {
|
||||
ios: [
|
||||
'Tap the share button at the bottom of the browser',
|
||||
'Select "Add to Home Screen"',
|
||||
'Tap "Add" to confirm installation',
|
||||
],
|
||||
android: [
|
||||
'Tap the browser menu (three dots)',
|
||||
'Select "Add to Home Screen" or "Install App"',
|
||||
'Tap "Install" to confirm',
|
||||
],
|
||||
chrome: [
|
||||
'Click the install icon in the address bar',
|
||||
'Or click "Install MoviePilot" in the browser menu',
|
||||
'Click "Install" to confirm',
|
||||
],
|
||||
edge: [
|
||||
'Click the app icon in the address bar',
|
||||
'Select "Install this site as an app"',
|
||||
'Click "Install" to confirm',
|
||||
],
|
||||
firefox: [
|
||||
'Click the install icon in the address bar',
|
||||
'Select "Install"',
|
||||
'Confirm installation to desktop',
|
||||
],
|
||||
safari: [
|
||||
'Click the share button',
|
||||
'Select "Add to Home Screen"',
|
||||
'Tap "Add" to confirm',
|
||||
],
|
||||
desktop: [
|
||||
'Click the install icon in the address bar',
|
||||
'Select "Install App"',
|
||||
'Follow the prompts to complete installation',
|
||||
],
|
||||
mobile: [
|
||||
'Tap the browser menu',
|
||||
'Select "Add to Home Screen"',
|
||||
'Confirm installation',
|
||||
],
|
||||
other: [
|
||||
'Look for "Install" option in your browser',
|
||||
'Usually in the address bar or menu',
|
||||
'Follow the prompts to complete installation',
|
||||
],
|
||||
ios: {
|
||||
0: 'Tap the share button at the bottom of the browser',
|
||||
1: 'Select "Add to Home Screen"',
|
||||
2: 'Tap "Add" to confirm installation',
|
||||
},
|
||||
android: {
|
||||
0: 'Tap the browser menu (three dots)',
|
||||
1: 'Select "Add to Home Screen" or "Install App"',
|
||||
2: 'Tap "Install" to confirm',
|
||||
},
|
||||
chrome: {
|
||||
0: 'Click the install icon in the address bar',
|
||||
1: 'Or click "Install MoviePilot" in the browser menu',
|
||||
2: 'Click "Install" to confirm',
|
||||
},
|
||||
edge: {
|
||||
0: 'Click the app icon in the address bar',
|
||||
1: 'Select "Install this site as an app"',
|
||||
2: 'Click "Install" to confirm',
|
||||
},
|
||||
firefox: {
|
||||
0: 'Click the install icon in the address bar',
|
||||
1: 'Select "Install"',
|
||||
2: 'Confirm installation to desktop',
|
||||
},
|
||||
safari: {
|
||||
0: 'Click the share button',
|
||||
1: 'Select "Add to Home Screen"',
|
||||
2: 'Tap "Add" to confirm',
|
||||
},
|
||||
desktop: {
|
||||
0: 'Click the install icon in the address bar',
|
||||
1: 'Select "Install App"',
|
||||
2: 'Follow the prompts to complete installation',
|
||||
},
|
||||
mobile: {
|
||||
0: 'Tap the browser menu',
|
||||
1: 'Select "Add to Home Screen"',
|
||||
2: 'Confirm installation',
|
||||
},
|
||||
other: {
|
||||
0: 'Look for "Install" option in your browser',
|
||||
1: 'Usually in the address bar or menu',
|
||||
2: 'Follow the prompts to complete installation',
|
||||
},
|
||||
},
|
||||
},
|
||||
login: {
|
||||
|
||||
@@ -171,51 +171,51 @@ export default {
|
||||
},
|
||||
// 安装步骤
|
||||
installSteps: {
|
||||
ios: [
|
||||
'点击浏览器底部的分享按钮',
|
||||
'选择"添加到主屏幕"',
|
||||
'点击"添加"确认安装',
|
||||
],
|
||||
android: [
|
||||
'点击浏览器菜单(三个点)',
|
||||
'选择"添加到主屏幕"或"安装应用"',
|
||||
'点击"安装"确认',
|
||||
],
|
||||
chrome: [
|
||||
'点击地址栏右侧的安装图标',
|
||||
'或者点击浏览器菜单中的"安装 MoviePilot"',
|
||||
'点击"安装"确认',
|
||||
],
|
||||
edge: [
|
||||
'点击地址栏右侧的"应用可用"图标',
|
||||
'在弹出的面板中点击"安装"按钮',
|
||||
'在确认对话框中点击"安装"',
|
||||
],
|
||||
firefox: [
|
||||
'点击地址栏右侧的安装图标',
|
||||
'选择"安装"',
|
||||
'确认安装到桌面',
|
||||
],
|
||||
safari: [
|
||||
'点击分享按钮',
|
||||
'选择"添加到主屏幕"',
|
||||
'点击"添加"确认',
|
||||
],
|
||||
desktop: [
|
||||
'点击地址栏右侧的安装图标',
|
||||
'选择"安装应用"',
|
||||
'按照提示完成安装',
|
||||
],
|
||||
mobile: [
|
||||
'点击浏览器菜单',
|
||||
'选择"添加到主屏幕"',
|
||||
'确认安装',
|
||||
],
|
||||
other: [
|
||||
'查找浏览器中的"安装"选项',
|
||||
'通常在地址栏或菜单中',
|
||||
'按照提示完成安装',
|
||||
],
|
||||
ios: {
|
||||
0: '点击浏览器底部的分享按钮',
|
||||
1: '选择"添加到主屏幕"',
|
||||
2: '点击"添加"确认安装',
|
||||
},
|
||||
android: {
|
||||
0: '点击浏览器菜单(三个点)',
|
||||
1: '选择"添加到主屏幕"或"安装应用"',
|
||||
2: '点击"安装"确认',
|
||||
},
|
||||
chrome: {
|
||||
0: '点击地址栏右侧的安装图标',
|
||||
1: '或者点击浏览器菜单中的"安装 MoviePilot"',
|
||||
2: '点击"安装"确认',
|
||||
},
|
||||
edge: {
|
||||
0: '点击地址栏右侧的"应用可用"图标',
|
||||
1: '在弹出的面板中点击"安装"按钮',
|
||||
2: '在确认对话框中点击"安装"',
|
||||
},
|
||||
firefox: {
|
||||
0: '点击地址栏右侧的安装图标',
|
||||
1: '选择"安装"',
|
||||
2: '确认安装到桌面',
|
||||
},
|
||||
safari: {
|
||||
0: '点击分享按钮',
|
||||
1: '选择"添加到主屏幕"',
|
||||
2: '点击"添加"确认',
|
||||
},
|
||||
desktop: {
|
||||
0: '点击地址栏右侧的安装图标',
|
||||
1: '选择"安装应用"',
|
||||
2: '按照提示完成安装',
|
||||
},
|
||||
mobile: {
|
||||
0: '点击浏览器菜单',
|
||||
1: '选择"添加到主屏幕"',
|
||||
2: '确认安装',
|
||||
},
|
||||
other: {
|
||||
0: '查找浏览器中的"安装"选项',
|
||||
1: '通常在地址栏或菜单中',
|
||||
2: '按照提示完成安装',
|
||||
},
|
||||
},
|
||||
},
|
||||
login: {
|
||||
|
||||
@@ -172,51 +172,51 @@ export default {
|
||||
},
|
||||
// 安裝步驟
|
||||
installSteps: {
|
||||
ios: [
|
||||
'點擊瀏覽器底部的分享按鈕',
|
||||
'選擇"添加到主屏幕"',
|
||||
'點擊"添加"確認安裝',
|
||||
],
|
||||
android: [
|
||||
'點擊瀏覽器菜單(三個點)',
|
||||
'選擇"添加到主屏幕"或"安裝應用"',
|
||||
'點擊"安裝"確認',
|
||||
],
|
||||
chrome: [
|
||||
'點擊地址欄右側的安裝圖標',
|
||||
'或者點擊瀏覽器菜單中的"安裝 MoviePilot"',
|
||||
'點擊"安裝"確認',
|
||||
],
|
||||
edge: [
|
||||
'點擊地址欄右側的應用圖標',
|
||||
'選擇"安裝此站點為應用"',
|
||||
'點擊"安裝"確認',
|
||||
],
|
||||
firefox: [
|
||||
'點擊地址欄右側的安裝圖標',
|
||||
'選擇"安裝"',
|
||||
'確認安裝到桌面',
|
||||
],
|
||||
safari: [
|
||||
'點擊分享按鈕',
|
||||
'選擇"添加到主屏幕"',
|
||||
'點擊"添加"確認',
|
||||
],
|
||||
desktop: [
|
||||
'點擊地址欄右側的安裝圖標',
|
||||
'選擇"安裝應用"',
|
||||
'按照提示完成安裝',
|
||||
],
|
||||
mobile: [
|
||||
'點擊瀏覽器菜單',
|
||||
'選擇"添加到主屏幕"',
|
||||
'確認安裝',
|
||||
],
|
||||
other: [
|
||||
'查找瀏覽器中的"安裝"選項',
|
||||
'通常在地址欄或菜單中',
|
||||
'按照提示完成安裝',
|
||||
],
|
||||
ios: {
|
||||
0: '點擊瀏覽器底部的分享按鈕',
|
||||
1: '選擇"添加到主屏幕"',
|
||||
2: '點擊"添加"確認安裝',
|
||||
},
|
||||
android: {
|
||||
0: '點擊瀏覽器菜單(三個點)',
|
||||
1: '選擇"添加到主屏幕"或"安裝應用"',
|
||||
2: '點擊"安裝"確認',
|
||||
},
|
||||
chrome: {
|
||||
0: '點擊地址欄右側的安裝圖標',
|
||||
1: '或者點擊瀏覽器菜單中的"安裝 MoviePilot"',
|
||||
2: '點擊"安裝"確認',
|
||||
},
|
||||
edge: {
|
||||
0: '點擊地址欄右側的應用圖標',
|
||||
1: '選擇"安裝此站點為應用"',
|
||||
2: '點擊"安裝"確認',
|
||||
},
|
||||
firefox: {
|
||||
0: '點擊地址欄右側的安裝圖標',
|
||||
1: '選擇"安裝"',
|
||||
2: '確認安裝到桌面',
|
||||
},
|
||||
safari: {
|
||||
0: '點擊分享按鈕',
|
||||
1: '選擇"添加到主屏幕"',
|
||||
2: '點擊"添加"確認',
|
||||
},
|
||||
desktop: {
|
||||
0: '點擊地址欄右側的安裝圖標',
|
||||
1: '選擇"安裝應用"',
|
||||
2: '按照提示完成安裝',
|
||||
},
|
||||
mobile: {
|
||||
0: '點擊瀏覽器菜單',
|
||||
1: '選擇"添加到主屏幕"',
|
||||
2: '確認安裝',
|
||||
},
|
||||
other: {
|
||||
0: '查找瀏覽器中的"安裝"選項',
|
||||
1: '通常在地址欄或菜單中',
|
||||
2: '按照提示完成安裝',
|
||||
},
|
||||
},
|
||||
},
|
||||
login: {
|
||||
|
||||
Reference in New Issue
Block a user