修改原有框架中英文映射

This commit is contained in:
2026-03-17 18:09:10 +08:00
parent e7b8f4cae9
commit bdf50e61f5
81 changed files with 1956 additions and 735 deletions

View File

@@ -25,7 +25,7 @@ class InstallController extends BaseController
{
parent::__construct();
if ($this->adminId > 1) {
throw new ApiException('仅超级管理员能够操作');
throw new ApiException('Only super admin can perform this action');
}
}
@@ -105,17 +105,17 @@ class InstallController extends BaseController
{
$spl_file = current($request->file());
if (!$spl_file->isValid()) {
return $this->fail('上传文件校验失败');
return $this->fail('upload file validation failed');
}
$config = config('plugin.saipackage.upload', [
'size' => 1024 * 1024 * 5,
'type' => ['zip']
]);
if (!in_array($spl_file->getUploadExtension(), $config['type'])) {
return $this->fail('文件格式上传失败,请选择zip格式文件上传');
return $this->fail('upload failed, please upload zip file');
}
if ($spl_file->getSize() > $config['size']) {
return $this->fail('文件大小不能超过5M');
return $this->fail('file size cannot exceed 5M');
}
$install = new InstallLogic();
$info = $install->upload($spl_file);
@@ -132,7 +132,7 @@ class InstallController extends BaseController
{
$appName = $request->post("appName", '');
if (empty($appName)) {
return $this->fail('参数错误');
return $this->fail('Invalid parameters');
}
$install = new InstallLogic($appName);
$info = $install->install();
@@ -150,12 +150,12 @@ class InstallController extends BaseController
{
$appName = $request->post("appName", '');
if (empty($appName)) {
return $this->fail('参数错误');
return $this->fail('Invalid parameters');
}
$install = new InstallLogic($appName);
$install->uninstall();
UserMenuCache::clearMenuCache();
return $this->success('卸载插件成功');
return $this->success('uninstall plugin success');
}
/**
@@ -167,7 +167,7 @@ class InstallController extends BaseController
{
Server::restart();
return $this->success('重载成功');
return $this->success('reload success');
}
// ========== 商店代理接口 ==========
@@ -278,7 +278,7 @@ class InstallController extends BaseController
{
$token = $request->input('token');
if (empty($token)) {
return $this->fail('未登录');
return $this->fail('not logged in');
}
$result = $this->proxyRequest(
@@ -299,7 +299,7 @@ class InstallController extends BaseController
{
$token = $request->input('token');
if (empty($token)) {
return $this->fail('未登录');
return $this->fail('not logged in');
}
$result = $this->proxyRequest(
@@ -322,7 +322,7 @@ class InstallController extends BaseController
$appId = $request->input('app_id');
if (empty($token)) {
return $this->fail('未登录');
return $this->fail('not logged in');
}
$result = $this->proxyRequest(
@@ -345,11 +345,11 @@ class InstallController extends BaseController
$versionId = $request->input('id');
if (empty($token)) {
return $this->fail('未登录');
return $this->fail('not logged in');
}
if (empty($versionId)) {
return $this->fail('版本ID不能为空');
return $this->fail('version id is required');
}
$result = $this->proxyRequest(
@@ -365,7 +365,7 @@ class InstallController extends BaseController
}
if (!isset($result['raw'])) {
return $this->fail('下载失败');
return $this->fail('download failed');
}
// 保存临时 zip 文件
@@ -380,7 +380,7 @@ class InstallController extends BaseController
$install = new InstallLogic();
$info = $install->uploadFromPath($tempZip);
return $this->success($info, '下载成功,请在插件列表中安装');
return $this->success($info, 'download success, please install in plugin list');
} catch (Throwable $e) {
@unlink($tempZip);
return $this->fail($e->getMessage());

View File

@@ -108,7 +108,7 @@ class InstallLogic
if (empty($info['app'])) {
Filesystem::delDir($copyToDir);
// 基本配置不完整
throw new ApiException('插件的基础配置信息错误');
throw new ApiException('Plugin base config is invalid');
}
@@ -127,14 +127,14 @@ class InstallLogic
$upgrade = Version::compare($nextVersion, $info['version']);
if (!$upgrade) {
Filesystem::delDir($copyToDir);
throw new ApiException('插件已经存在');
throw new ApiException('Plugin already exists');
}
}
if (Filesystem::dirIsEmpty($this->appDir) || (!Filesystem::dirIsEmpty($this->appDir) && !$upgrade)) {
Filesystem::delDir($copyToDir);
// 模块目录被占
throw new ApiException('该插件的安装目录已经被占用');
throw new ApiException('Plugin install directory is already occupied');
}
}
@@ -167,7 +167,7 @@ class InstallLogic
public function uploadFromPath(string $zipPath): array
{
if (!is_file($zipPath)) {
throw new ApiException('文件不存在');
throw new ApiException('File not found');
}
// 解压
@@ -181,7 +181,7 @@ class InstallLogic
$info = Server::getIni($copyToDir);
if (empty($info['app'])) {
Filesystem::delDir($copyToDir);
throw new ApiException('插件的基础配置信息错误');
throw new ApiException('Plugin base config is invalid');
}
$this->appName = $info['app'];
@@ -199,13 +199,13 @@ class InstallLogic
$upgrade = Version::compare($nextVersion, $info['version']);
if (!$upgrade) {
Filesystem::delDir($copyToDir);
throw new ApiException('插件已经存在');
throw new ApiException('Plugin already exists');
}
}
if (Filesystem::dirIsEmpty($this->appDir) || (!Filesystem::dirIsEmpty($this->appDir) && !$upgrade)) {
Filesystem::delDir($copyToDir);
throw new ApiException('该插件的安装目录已经被占用');
throw new ApiException('Plugin install directory is already occupied');
}
}
@@ -237,11 +237,11 @@ class InstallLogic
{
$state = $this->getInstallState();
if ($state == self::INSTALLED || $state == self::DIRECTORY_OCCUPIED) {
throw new ApiException('插件已经存在');
throw new ApiException('Plugin already exists');
}
if ($state == self::DEPENDENT_WAIT_INSTALL) {
throw new ApiException('等待依赖安装');
throw new ApiException('Waiting for dependencies to be installed');
}
echo '开始安装[' . $this->appName . ']' . PHP_EOL;
@@ -351,14 +351,14 @@ class InstallLogic
public function checkPackage(): bool
{
if (!is_dir($this->appDir)) {
throw new ApiException('插件目录不存在');
throw new ApiException('Plugin directory not found');
}
$info = $this->getInfo();
$infoKeys = ['app', 'title', 'about', 'author', 'version', 'state'];
foreach ($infoKeys as $value) {
if (!array_key_exists($value, $info)) {
Filesystem::delDir($this->appDir);
throw new ApiException('该插件的基础配置信息不完善');
throw new ApiException('Plugin base config is incomplete');
}
}
return true;
@@ -527,6 +527,6 @@ class InstallLogic
} elseif ($arr) {
return Server::setIni($this->appDir, $arr);
}
throw new ApiException('参数错误');
throw new ApiException('Invalid parameters');
}
}