0
点赞
收藏
分享

微信扫一扫

tp6.1 bingher/ueditor(百度编辑器)(七牛、阿里OSS第三方云)详情图文教程(第二版)


之前做过一版:tp6 bingher/ueditor(百度编辑器)(七牛、阿里OSS第三方云)详情图文教程_我是高手高手高高手的博客

登录权限是Session,现在系统是Cookie加jwt的Token方式验证

一、修改验证登录权限

修改文件: vendor\bingher\ueditor\src\controller\Base.php

1.1 引用自己的验证登录方法

use think\facade\Cookie;
use app\services\jwt\JwtAdmin as Jwt;

1.2 获取登录用户信息,这里需要企业ID,在这里public function __construct()加入

//验证登录
        $CookieToken=Cookie::get(Jwt::getName())?Cookie::get(Jwt::getName()):"";//获取Cookie中的Token
        if(!$CookieToken){
            throw new HttpResponseException($this->error("请登录!"));
        }
        $manager = Jwt::setToken($CookieToken);
        $tokeInfo=$manager->auth(true);
        // var_dump($adminuserinfoArr['data']['enterprise']['id']);
        if(!$tokeInfo){
            throw new HttpResponseException($this->error("非法数据!"));
        }
        $adminuserinfoArr=$manager->getPayload();//获取用户信息
        $this->enterprise_id = $adminuserinfoArr['data']['enterprise']['id'] ;

tp6.1 bingher/ueditor(百度编辑器)(七牛、阿里OSS第三方云)详情图文教程(第二版)_文件大小

 

二、上传接入第三方OSS

vendor\bingher\ueditor\src\controller\Ueditor.php

把企业ID传入$this->config对象中

$fsConfig['enterprise_id'] = $this->enterprise_id;
        Config::set($fsConfig, 'filesystem');

tp6.1 bingher/ueditor(百度编辑器)(七牛、阿里OSS第三方云)详情图文教程(第二版)_百度编辑器_02

2.1 修改private function _upFile($config)

$pathData = \app\services\upload\model\GetFileInfoModel::fileOssTypePath(!empty(Config::get('filesystem'))?Config::get('filesystem')['enterprise_id']:0);
        $path = !empty($pathData['data']['path'])?$pathData['data']['path']:'';

'url'      => \app\services\upload\model\GetFileInfoModel::GetFileUrl($saveName),

tp6.1 bingher/ueditor(百度编辑器)(七牛、阿里OSS第三方云)详情图文教程(第二版)_php_03

像其它文件大小、格式之类

tp6.1 bingher/ueditor(百度编辑器)(七牛、阿里OSS第三方云)详情图文教程(第二版)_php_04

三、修改vendor\bingher\ueditor\src\config\UeConfig.php文件的方法

public function initFilesystem(string $diskName = 'ueditor')

$pathData = \app\services\upload\model\GetFileInfoModel::fileOssTypePath(!empty(Config::get('filesystem'))?Config::get('filesystem')['enterprise_id']:0);
        $public_path = !empty($pathData['data']['public_path'])?$pathData['data']['public_path']:'';


return (new \yzh52521\filesystem\Filesystem(app()))->disk($public_path);

tp6.1 bingher/ueditor(百度编辑器)(七牛、阿里OSS第三方云)详情图文教程(第二版)_百度编辑器_05

举报

相关推荐

0 条评论