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\Models\UserDepartment;
use App\Models\WebSocketDialogMsg;
use App\Module\Apps;
use App\Module\BillMultipleExport;
use Hhxsv5\LaravelS\Swoole\Task\Task;
@ -34,6 +35,9 @@ class ApproveController extends AbstractController
public function __construct()
{
if (!Apps::isInstalled('approve')) {
throw new ApiException('应用「Approval」未安装');
}
$this->flow_url = env('FLOW_URL') ?: 'http://approve';
}
@ -73,7 +77,7 @@ class ApproveController extends AbstractController
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function procdef__all()
public function procdef__all()
{
User::auth();
$data['name'] = Request::input('name');

View File

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

View File

@ -41,6 +41,7 @@ use App\Models\ProjectTaskFlowChange;
use App\Models\ProjectTaskVisibilityUser;
use App\Models\ProjectTaskTemplate;
use App\Models\ProjectTag;
use App\Module\Apps;
/**
* @apiDefine project
@ -1831,6 +1832,18 @@ class ProjectController extends AbstractController
'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['path'] = $file->getRawOriginal('path');

View File

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

View File

@ -12,6 +12,7 @@ use App\Models\UserDepartment;
use App\Models\WebSocketDialog;
use App\Models\WebSocketDialogConfig;
use App\Models\WebSocketDialogMsg;
use App\Module\Apps;
use App\Module\Base;
use App\Module\Doo;
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'])) {
$errorContent = '当前客户端版本低所需版本≥v0.41.11)。';
}
if (!Apps::isInstalled('ai')) {
$errorContent = '应用「AI Robot」未安装';
}
if ($msg->reply_id > 0) {
$replyCommand = $this->extractReplyCommand($msg->reply_id, $botUser);
if (Base::isError($replyCommand)) {

View File

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

View File

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