更新翻译

This commit is contained in:
jingrow 2025-10-26 00:44:37 +08:00
parent 862309650e
commit 3abe83fa11
3 changed files with 37 additions and 58 deletions

View File

@ -816,6 +816,8 @@
"Failed to uninstall app": "卸载应用失败", "Failed to uninstall app": "卸载应用失败",
"Uninstall App": "卸载应用", "Uninstall App": "卸载应用",
"Are you sure you want to uninstall": "您确定要卸载", "Are you sure you want to uninstall": "您确定要卸载",
"Are you sure you want to uninstall '{0}'? This action cannot be undone.": "您确定要卸载 '{0}' 吗?此操作无法撤销。",
"App '{0}' uninstalled successfully": "应用 '{0}' 卸载成功",
"This action cannot be undone.": "此操作无法撤销。", "This action cannot be undone.": "此操作无法撤销。",
"Not installed": "未安装", "Not installed": "未安装",

View File

@ -188,7 +188,7 @@ const showAppDetail = async (app: any) => {
const uninstallApp = async (app: any) => { const uninstallApp = async (app: any) => {
dialog.warning({ dialog.warning({
title: t('Uninstall App'), title: t('Uninstall App'),
content: t(`Are you sure you want to uninstall '${app.name}'? This action cannot be undone.`), content: t('Are you sure you want to uninstall \'{0}\'? This action cannot be undone.').replace('{0}', app.name),
positiveText: t('Uninstall'), positiveText: t('Uninstall'),
negativeText: t('Cancel'), negativeText: t('Cancel'),
onPositiveClick: async () => { onPositiveClick: async () => {
@ -200,7 +200,7 @@ const uninstallApp = async (app: any) => {
}) })
if (response.data.success) { if (response.data.success) {
message.success(t(`App '${app.name}' uninstalled successfully`)) message.success(t('App \'{0}\' uninstalled successfully').replace('{0}', app.name))
await loadInstalledApps() await loadInstalledApps()
} else { } else {
message.error(response.data.error || t('Failed to uninstall app')) message.error(response.data.error || t('Failed to uninstall app'))

View File

@ -75,19 +75,14 @@ async def get_local_apps(request: Request):
root = current.parents[4] root = current.parents[4]
apps_dir = root / "apps" apps_dir = root / "apps"
# 获取已安装的App列表 - 从Local Installed Apps PageType读取 # 获取已安装的App列表 - 通过get_single API获取
from jingrow import get_pg from jingrow.utils.jingrow_api import get_single_pagetype
result = get_single_pagetype("Local Installed Apps")
installed_names = set() installed_names = set()
try: if result.get('success'):
# 使用正确的single PageType获取方式 config = result.get('config', {})
local_installed_apps = get_pg("Local Installed Apps", "Local Installed Apps") local_installed_apps = config.get('local_installed_apps', [])
if local_installed_apps and hasattr(local_installed_apps, 'local_installed_apps') and local_installed_apps.local_installed_apps: installed_names = {app.get('app_name', '') for app in local_installed_apps}
installed_names = {app.app_name for app in local_installed_apps.local_installed_apps}
except Exception:
# 如果PageType不存在使用文件系统扫描作为备选
from jingrow.utils.app_installer import get_installed_apps as get_installed_apps_list
installed_apps = get_installed_apps_list()
installed_names = {app['name'] for app in installed_apps}
# 系统默认App列表需要排除 # 系统默认App列表需要排除
system_apps = { system_apps = {
@ -175,19 +170,15 @@ async def install_local_app(request: Request, app_name: str):
if not app_dir.exists(): if not app_dir.exists():
raise HTTPException(status_code=404, detail=f"App '{app_name}' not found") raise HTTPException(status_code=404, detail=f"App '{app_name}' not found")
# 检查是否已经安装 - 从Local Installed Apps PageType检查 # 检查是否已经安装 - 通过get_single API检查
from jingrow import get_pg from jingrow.utils.jingrow_api import get_single_pagetype
local_installed_apps = None result = get_single_pagetype("Local Installed Apps")
try: if result.get('success'):
# 使用正确的single PageType获取方式 config = result.get('config', {})
local_installed_apps = get_pg("Local Installed Apps", "Local Installed Apps") local_installed_apps = config.get('local_installed_apps', [])
if local_installed_apps and hasattr(local_installed_apps, 'local_installed_apps') and local_installed_apps.local_installed_apps: for app in local_installed_apps:
for app in local_installed_apps.local_installed_apps: if app.get('app_name', '') == app_name:
if app.app_name == app_name: raise HTTPException(status_code=400, detail=f"App '{app_name}' is already installed")
raise HTTPException(status_code=400, detail=f"App '{app_name}' is already installed")
except Exception:
# 如果PageType不存在跳过检查
pass
# 将App信息添加到Local Installed Apps PageType # 将App信息添加到Local Installed Apps PageType
try: try:
@ -227,17 +218,14 @@ async def install_local_app(request: Request, app_name: str):
@router.get("/jingrow/installed-apps") @router.get("/jingrow/installed-apps")
async def get_installed_apps(request: Request): async def get_installed_apps(request: Request):
"""获取已安装的应用列表 - 从Local Installed Apps PageType读""" """获取已安装的应用列表 - 通过get_single API获"""
try: try:
# 从Local Installed Apps PageType获取数据 # 通过get_single API获取Local Installed Apps数据
from jingrow import get_pg from jingrow.utils.jingrow_api import get_single_pagetype
# 获取Local Installed Apps的single实例 result = get_single_pagetype("Local Installed Apps")
try:
# 使用正确的single PageType获取方式 if not result.get('success'):
local_installed_apps = get_pg("Local Installed Apps", "Local Installed Apps")
except Exception as e:
# 如果PageType不存在或为空返回空列表
return { return {
'success': True, 'success': True,
'data': { 'data': {
@ -246,15 +234,17 @@ async def get_installed_apps(request: Request):
} }
} }
config = result.get('config', {})
local_installed_apps = config.get('local_installed_apps', [])
apps = [] apps = []
if local_installed_apps and hasattr(local_installed_apps, 'local_installed_apps') and local_installed_apps.local_installed_apps: for app in local_installed_apps:
for app in local_installed_apps.local_installed_apps: apps.append({
apps.append({ 'name': app.get('app_name', ''),
'name': app.app_name, 'version': app.get('app_version', '1.0.0'),
'version': app.app_version, 'git_branch': app.get('git_branch', 'main'),
'git_branch': app.git_branch, 'type': 'installed'
'type': 'installed' })
})
return { return {
'success': True, 'success': True,
@ -266,20 +256,7 @@ async def get_installed_apps(request: Request):
except Exception as e: except Exception as e:
log_error(f"获取已安装应用列表失败: {str(e)}") log_error(f"获取已安装应用列表失败: {str(e)}")
# 如果PageType相关操作失败回退到文件系统扫描 raise HTTPException(status_code=500, detail=str(e))
try:
from jingrow.utils.app_installer import get_installed_apps as get_installed_apps_list
installed_apps = get_installed_apps_list()
apps = [{'name': app['name'], 'version': '1.0.0', 'git_branch': 'main', 'type': 'installed'} for app in installed_apps]
return {
'success': True,
'data': {
'apps': apps,
'total': len(apps)
}
}
except Exception as e2:
raise HTTPException(status_code=500, detail=str(e2))
@router.post("/jingrow/uninstall/{app_name}") @router.post("/jingrow/uninstall/{app_name}")