feat: 检查应用是否已安装

This commit is contained in:
王昱 2025-05-23 12:40:33 +08:00
parent 6e03a05e6d
commit 1d92c2668d
7 changed files with 92 additions and 13 deletions

View File

@ -20,6 +20,7 @@ use App\Models\ApproveProcInstHistory;
use App\Exceptions\ApiException; use App\Exceptions\ApiException;
use App\Models\UserDepartment; use App\Models\UserDepartment;
use App\Models\WebSocketDialogMsg; use App\Models\WebSocketDialogMsg;
use App\Module\Apps;
use App\Module\BillMultipleExport; use App\Module\BillMultipleExport;
use Hhxsv5\LaravelS\Swoole\Task\Task; use Hhxsv5\LaravelS\Swoole\Task\Task;
@ -34,6 +35,9 @@ class ApproveController extends AbstractController
public function __construct() public function __construct()
{ {
if (!Apps::isInstalled('approve')) {
throw new ApiException('应用「Approval」未安装');
}
$this->flow_url = env('FLOW_URL') ?: 'http://approve'; $this->flow_url = env('FLOW_URL') ?: 'http://approve';
} }

View File

@ -11,6 +11,7 @@ use App\Models\FileContent;
use App\Models\FileLink; use App\Models\FileLink;
use App\Models\FileUser; use App\Models\FileUser;
use App\Models\User; use App\Models\User;
use App\Module\Apps;
use App\Module\Base; use App\Module\Base;
use App\Module\Timer; use App\Module\Timer;
use App\Module\Ihttp; use App\Module\Ihttp;
@ -509,6 +510,23 @@ class FileController extends AbstractController
'update_at' => Carbon::parse($file->updated_at)->toDateTimeString() 'update_at' => Carbon::parse($file->updated_at)->toDateTimeString()
]); ]);
} }
//
if ($down != 'yes') {
// office
if (in_array($file->type, ['word', 'excel', 'ppt']) && !Apps::isInstalled('office')) {
return Base::retError('应用「OnlyOffice」未安装');
}
// drawio
if ($file->type == 'drawio' && !Apps::isInstalled('drawio')) {
return Base::retError('应用「Drawio」未安装');
}
// mind
if ($file->type == 'mind' && !Apps::isInstalled('minder')) {
return Base::retError('应用「Minder」未安装');
}
}
//
// //
$builder = FileContent::whereFid($file->id); $builder = FileContent::whereFid($file->id);
if ($history_id > 0) { if ($history_id > 0) {
@ -577,10 +595,16 @@ class FileController extends AbstractController
$contentArray = Base::json2array($content); $contentArray = Base::json2array($content);
$contentString = $contentArray['xml']; $contentString = $contentArray['xml'];
$file->ext = 'drawio'; $file->ext = 'drawio';
if (!Apps::isInstalled('drawio')) {
return Base::retError('应用「Drawio」未安装');
}
break; break;
case 'mind': case 'mind':
$contentString = $content; $contentString = $content;
$file->ext = 'mind'; $file->ext = 'mind';
if (!Apps::isInstalled('minder')) {
return Base::retError('应用「Minder」未安装');
}
break; break;
case 'txt': case 'txt':
case 'code': case 'code':
@ -632,6 +656,10 @@ class FileController extends AbstractController
{ {
User::auth(); User::auth();
// //
if (!Apps::isInstalled('office')) {
return Base::retError('应用「OnlyOffice」未安装');
}
//
$config = Request::input('config'); $config = Request::input('config');
$token = \Firebase\JWT\JWT::encode($config, env('APP_KEY') ,'HS256'); $token = \Firebase\JWT\JWT::encode($config, env('APP_KEY') ,'HS256');
return Base::retSuccess('成功', [ return Base::retSuccess('成功', [
@ -657,6 +685,10 @@ class FileController extends AbstractController
{ {
$user = User::auth(); $user = User::auth();
// //
if (!Apps::isInstalled('office')) {
return Base::retError('应用「OnlyOffice」未安装');
}
//
$id = intval(Request::input('id')); $id = intval(Request::input('id'));
$status = intval(Request::input('status')); $status = intval(Request::input('status'));
$key = Request::input('key'); $key = Request::input('key');
@ -776,6 +808,19 @@ class FileController extends AbstractController
$history_id = intval(Request::input('history_id')); $history_id = intval(Request::input('history_id'));
// //
$file = File::permissionFind($id, $user); $file = File::permissionFind($id, $user);
// office
if (in_array($file->type, ['word', 'excel', 'ppt']) && !Apps::isInstalled('office')) {
return Base::retError('应用「OnlyOffice」未安装');
}
// drawio
if ($file->type == 'drawio' && !Apps::isInstalled('drawio')) {
return Base::retError('应用「Drawio」未安装');
}
// mind
if ($file->type == 'mind' && !Apps::isInstalled('minder')) {
return Base::retError('应用「Minder」未安装');
}
// //
$history = FileContent::whereFid($file->id)->whereId($history_id)->first(); $history = FileContent::whereFid($file->id)->whereId($history_id)->first();
if (empty($history)) { if (empty($history)) {

View File

@ -41,6 +41,7 @@ use App\Models\ProjectTaskFlowChange;
use App\Models\ProjectTaskVisibilityUser; use App\Models\ProjectTaskVisibilityUser;
use App\Models\ProjectTaskTemplate; use App\Models\ProjectTaskTemplate;
use App\Models\ProjectTag; use App\Models\ProjectTag;
use App\Module\Apps;
/** /**
* @apiDefine project * @apiDefine project
@ -1831,6 +1832,18 @@ class ProjectController extends AbstractController
'update_at' => Carbon::parse($file->updated_at)->toDateTimeString() 'update_at' => Carbon::parse($file->updated_at)->toDateTimeString()
]); ]);
} }
// office
if (in_array($file->ext, ['docx', 'xlsx', 'pptx']) && !Apps::isInstalled('office')) {
return Base::retError('应用「OnlyOffice」未安装');
}
// drawio
if ($file->ext == 'drawio' && !Apps::isInstalled('drawio')) {
return Base::retError('应用「Drawio」未安装');
}
// mind
if ($file->ext == 'mind' && !Apps::isInstalled('minder')) {
return Base::retError('应用「Minder」未安装');
}
// //
$data = $file->toArray(); $data = $file->toArray();
$data['path'] = $file->getRawOriginal('path'); $data['path'] = $file->getRawOriginal('path');

View File

@ -18,6 +18,7 @@ use LdapRecord\Container;
use App\Module\BillExport; use App\Module\BillExport;
use Guanguans\Notify\Factory; use Guanguans\Notify\Factory;
use App\Models\UserCheckinRecord; use App\Models\UserCheckinRecord;
use App\Module\Apps;
use App\Module\BillMultipleExport; use App\Module\BillMultipleExport;
use LdapRecord\LdapRecordException; use LdapRecord\LdapRecordException;
use Guanguans\Notify\Messages\EmailMessage; use Guanguans\Notify\Messages\EmailMessage;
@ -301,6 +302,10 @@ class SystemController extends AbstractController
{ {
User::auth('admin'); User::auth('admin');
// //
if (!Apps::isInstalled('ai')) {
return Base::retError('应用「AI Robot」未安装');
}
//
$type = trim(Request::input('type')); $type = trim(Request::input('type'));
$filter = trim(Request::input('filter')); $filter = trim(Request::input('filter'));
$setting = Base::setting('aibotSetting'); $setting = Base::setting('aibotSetting');
@ -450,6 +455,7 @@ class SystemController extends AbstractController
if (!$botUser) { if (!$botUser) {
return Base::retError('创建签到机器人失败'); return Base::retError('创建签到机器人失败');
} }
if (is_array($all['modes'])) {
if (in_array('locat', $all['modes'])) { if (in_array('locat', $all['modes'])) {
if (empty($all['locat_bd_lbs_key'])) { if (empty($all['locat_bd_lbs_key'])) {
return Base::retError('请填写百度地图AK'); return Base::retError('请填写百度地图AK');
@ -462,6 +468,13 @@ class SystemController extends AbstractController
return Base::retError('请选择有效的签到位置'); return Base::retError('请选择有效的签到位置');
} }
} }
// 人脸识别
if (in_array('face', $all['modes'])){
if (!Apps::isInstalled('face')) {
return Base::retError('应用「Face check-in」未安装');
}
}
}
} }
if ($all['modes']) { if ($all['modes']) {
$all['modes'] = array_intersect($all['modes'], ['auto', 'manual', 'locat', 'face']); $all['modes'] = array_intersect($all['modes'], ['auto', 'manual', 'locat', 'face']);

View File

@ -12,6 +12,7 @@ use App\Models\UserDepartment;
use App\Models\WebSocketDialog; use App\Models\WebSocketDialog;
use App\Models\WebSocketDialogConfig; use App\Models\WebSocketDialogConfig;
use App\Models\WebSocketDialogMsg; use App\Models\WebSocketDialogMsg;
use App\Module\Apps;
use App\Module\Base; use App\Module\Base;
use App\Module\Doo; use App\Module\Doo;
use App\Module\Ihttp; use App\Module\Ihttp;
@ -452,7 +453,9 @@ class BotReceiveMsgTask extends AbstractTask
if (in_array($this->client['platform'], ['win', 'mac', 'web']) && !Base::judgeClientVersion("0.41.11", $this->client['version'])) { if (in_array($this->client['platform'], ['win', 'mac', 'web']) && !Base::judgeClientVersion("0.41.11", $this->client['version'])) {
$errorContent = '当前客户端版本低所需版本≥v0.41.11)。'; $errorContent = '当前客户端版本低所需版本≥v0.41.11)。';
} }
if (!Apps::isInstalled('ai')) {
$errorContent = '应用「AI Robot」未安装';
}
if ($msg->reply_id > 0) { if ($msg->reply_id > 0) {
$replyCommand = $this->extractReplyCommand($msg->reply_id, $botUser); $replyCommand = $this->extractReplyCommand($msg->reply_id, $botUser);
if (Base::isError($replyCommand)) { if (Base::isError($replyCommand)) {

View File

@ -874,3 +874,4 @@ URL格式不正确
更新失败:(*) 更新失败:(*)
应用列表正在更新中,请稍后再试 应用列表正在更新中,请稍后再试
应用正在下载中,请稍后再试 应用正在下载中,请稍后再试
应用「*」未安装

View File

@ -556,7 +556,7 @@ export default {
} }
}).then(({data}) => { }).then(({data}) => {
this.updateData('unread', data, type) this.updateData('unread', data, type)
}).catch((msg) => { }).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
}).finally(_ => { }).finally(_ => {
this.loadIng = false; this.loadIng = false;