更新翻译

This commit is contained in:
jingrow 2025-10-26 16:08:40 +08:00
parent 567b2b54f8
commit c2056e7042
2 changed files with 15 additions and 55 deletions

View File

@ -781,8 +781,9 @@
"Failed to uninstall package": "卸载扩展包失败",
"OK": "确定",
"Package '{0}' uninstalled successfully": "扩展包 '{0}' 卸载成功",
"Package '{0}' installed successfully": "扩展包 '{0}' 安装成功",
"App Installer": "应用安装",
"App Installer": "应用安装",
"Upload and install applications to your local Jingrow environment": "上传并安装应用到您的本地 Jingrow 环境",
"Upload App Package": "上传应用包",
"Uploading...": "上传中...",
@ -809,6 +810,16 @@
"Frontend Only": "仅前端",
"Full Stack": "全栈",
"Only ZIP files are supported": "仅支持 ZIP 文件",
"Only ZIP and TAR.GZ files are supported": "仅支持 ZIP 和 TAR.GZ 文件",
"Click or drag package file to this area to upload": "点击或拖拽应用包文件到此区域上传",
"Support for ZIP, TAR.GZ, and GZ format": "支持 ZIP、TAR.GZ 和 GZ 格式",
"Selected Package": "选中的应用包",
"Size": "大小",
"Extension Package": "扩展包",
"Failed to save package": "保存应用包失败",
"Installing extension package...": "正在安装扩展包...",
"Failed to load local apps": "加载本地应用失败",
"Failed to install app": "安装应用失败",
"Please select a file first": "请先选择文件",
"File not found": "文件未找到",
"Failed to load apps": "加载应用失败",
@ -821,8 +832,6 @@
"App '{0}' installed successfully": "应用 '{0}' 安装成功",
"System App": "系统应用",
"cannot be uninstalled": "不允许卸载",
"Version": "版本",
"Git Branch": "Git分支",
"This action cannot be undone.": "此操作无法撤销。",
"Not installed": "未安装",

View File

@ -1,7 +1,5 @@
<!-- Jingrow Local 应用安装页面 -->
<template>
<div class="app-installer-page">
<!-- 页面头部 -->
<div class="page-header">
<div class="header-content">
<h1 class="page-title">
@ -12,7 +10,6 @@
</div>
</div>
<!-- 上传区域 -->
<div class="upload-section">
<n-card :title="t('Upload App Package')" class="upload-card">
<n-upload
@ -40,7 +37,6 @@
</n-upload-dragger>
</n-upload>
<!-- 文件信息显示 -->
<div v-if="fileList.length > 0" class="file-info-card">
<n-alert type="info" :bordered="false">
<template #header>
@ -63,7 +59,6 @@
</n-alert>
</div>
<!-- 应用名称输入 - 仅普通应用包需要 -->
<div class="app-name-input" v-if="fileList.length > 0 && !isExtensionFile">
<n-form-item :label="t('App Name (Optional)')">
<n-input
@ -74,7 +69,6 @@
</n-form-item>
</div>
<!-- 上传按钮 -->
<div class="upload-actions" v-if="fileList.length > 0">
<n-space>
<n-button @click="clearFiles" :disabled="uploading">
@ -91,8 +85,6 @@
</n-card>
</div>
<!-- 本地App列表 -->
<div class="local-apps-section" v-if="localApps.length > 0">
<n-card :title="t('Local Apps Available')" class="local-apps-card">
<n-data-table
@ -105,7 +97,6 @@
</n-card>
</div>
<!-- 安装进度模态框 -->
<n-modal v-model:show="showProgressModal" preset="card" style="width: 500px">
<template #header>
<h3>{{ t('Installing App') }}</h3>
@ -142,7 +133,6 @@ import axios from 'axios'
import { get_session_api_headers } from '@/shared/api/auth'
import { t } from '@/shared/i18n'
//
const fileList = ref<UploadFileInfo[]>([])
const appName = ref('')
const uploading = ref(false)
@ -151,16 +141,14 @@ const installProgress = ref(0)
const installMessage = ref('')
const installStatus = ref<'success' | 'error' | 'info'>('info')
const showProgressModal = ref(false)
const isExtensionFile = ref(false) //
const isExtensionFile = ref(false)
// App
const localApps = ref<any[]>([])
const loadingLocalApps = ref(false)
const message = useMessage()
const uploadRef = ref()
// App
const localAppsColumns: DataTableColumns<any> = [
{
title: t('App Name'),
@ -198,8 +186,6 @@ const localAppsColumns: DataTableColumns<any> = [
}
]
//
const beforeUpload = (data: { file: UploadFileInfo }) => {
const file = data.file.file
if (!file) return false
@ -219,14 +205,12 @@ const beforeUpload = (data: { file: UploadFileInfo }) => {
const handleFileChange = (options: { fileList: UploadFileInfo[] }) => {
fileList.value = options.fileList
//
if (fileList.value.length > 0) {
const fileName = fileList.value[0].file?.name || ''
isExtensionFile.value = fileName.toLowerCase().endsWith('.tar.gz') ||
fileName.toLowerCase().endsWith('.tgz') ||
fileName.toLowerCase().endsWith('.gz')
//
if (isExtensionFile.value) {
appName.value = ''
}
@ -234,7 +218,6 @@ const handleFileChange = (options: { fileList: UploadFileInfo[] }) => {
}
const customUpload = async (_options: any) => {
//
return Promise.resolve()
}
@ -250,11 +233,9 @@ const startUpload = async () => {
return
}
// API endpoint
const fileName = file.name.toLowerCase()
const isExtensionPackage = fileName.endsWith('.tar.gz') || fileName.endsWith('.tgz') || fileName.endsWith('.gz')
// install_package
if (isExtensionPackage) {
try {
uploading.value = true
@ -264,35 +245,28 @@ const startUpload = async () => {
installMessage.value = t('Uploading file...')
installStatus.value = 'info'
// public/files
const formData = new FormData()
formData.append('file', file)
installProgress.value = 20
installMessage.value = t('Saving package...')
//
const saveResponse = await axios.post('/jingrow/install-extension', formData, {
headers: {
...get_session_api_headers(),
'Content-Type': 'multipart/form-data'
},
timeout: 60000 // 60
timeout: 60000
})
console.log('Save response:', saveResponse.data)
if (!saveResponse.data.success) {
throw new Error(saveResponse.data.error || t('Failed to save package'))
}
const fileUrl = saveResponse.data.file_url
console.log('File URL:', fileUrl)
installProgress.value = 50
installMessage.value = t('Installing package...')
// install_package
const installResponse = await axios.post('/api/action/jingrow.ai.utils.jlocal.install_package', {
package_file_url: fileUrl
}, {
@ -316,22 +290,18 @@ const startUpload = async () => {
installMessage.value = t('Installation failed!')
installStatus.value = 'error'
console.error('Upload error:', error)
console.error('Error response data:', error.response?.data)
const errorMsg = error.response?.data?.detail ||
error.response?.data?.error ||
error.message ||
t('Upload failed')
console.error('Final error message:', errorMsg)
message.error(errorMsg)
} finally {
uploading.value = false
installing.value = false
}
return // 使
return
}
const apiEndpoint = '/jingrow/install/upload'
@ -344,18 +314,14 @@ const startUpload = async () => {
installMessage.value = t('Preparing upload...')
installStatus.value = 'info'
// FormData
const formData = new FormData()
formData.append('file', file)
if (appName.value.trim() && !isExtensionPackage) {
// app_name
formData.append('app_name', appName.value.trim())
}
installProgress.value = 30
installMessage.value = isExtensionPackage ? t('Installing extension package...') : t('Uploading file...')
//
const response = await axios.post(apiEndpoint, formData, {
headers: {
...get_session_api_headers(),
@ -374,7 +340,6 @@ const startUpload = async () => {
installStatus.value = 'success'
if (response.data.success) {
//
clearFiles()
const resultAppName = isExtensionPackage ? response.data.package_name : response.data.app_name
@ -388,17 +353,11 @@ const startUpload = async () => {
installMessage.value = t('Installation failed!')
installStatus.value = 'error'
console.error('Upload error:', error)
console.error('Error response:', error.response)
console.error('Error details:', error.response?.data)
//
const errorDetail = error.response?.data?.detail ||
error.response?.data?.message ||
error.message ||
t('Upload failed')
console.error('Final error detail:', errorDetail)
message.error(errorDetail)
} finally {
uploading.value = false
@ -413,7 +372,6 @@ const clearFiles = () => {
uploadRef.value?.clear()
}
//
const formatFileSize = (bytes: number): string => {
if (bytes === 0) return '0 B'
const k = 1024
@ -422,7 +380,6 @@ const formatFileSize = (bytes: number): string => {
return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i]
}
// App
const loadLocalApps = async () => {
loadingLocalApps.value = true
try {
@ -438,7 +395,6 @@ const loadLocalApps = async () => {
message.error(response.data.detail || t('Failed to load local apps'))
}
} catch (error: any) {
console.error('Load local apps error:', error)
message.error(error?.response?.data?.detail || error?.message || t('Failed to load local apps'))
} finally {
loadingLocalApps.value = false
@ -455,20 +411,16 @@ const installLocalApp = async (appName: string) => {
if (response.data.success) {
message.success(t('App \'{0}\' installed successfully').replace('{0}', appName))
// App
await loadLocalApps()
} else {
message.error(response.data.detail || t('Failed to install app'))
}
} catch (error: any) {
console.error('Install local app error:', error)
message.error(error?.response?.data?.detail || error?.message || t('Failed to install app'))
}
}
//
onMounted(() => {
// App
loadLocalApps()
})
</script>
@ -567,7 +519,6 @@ onMounted(() => {
border: 1px solid #e5e7eb;
}
/* 响应式布局 */
@media (max-width: 1200px) {
.app-installer-page {
padding: 12px 16px;