关键词搜索

源码搜索 ×
×

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

发布2023-04-29浏览996次

详情内容

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

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

一、修改验证登录权限

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

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

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

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

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

二、上传接入第三方OSS

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

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

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

2.1 修改private function _upFile($config)

  1. $pathData = \app\services\upload\model\GetFileInfoModel::fileOssTypePath(!empty(Config::get('filesystem'))?Config::get('filesystem')['enterprise_id']:0);
  2. $path = !empty($pathData['data']['path'])?$pathData['data']['path']:'';
'url'      => \app\services\upload\model\GetFileInfoModel::GetFileUrl($saveName),

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

 我常量设置大小设置的是K,所以要*1024;

格式:转为数组

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

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

  1. $pathData = \app\services\upload\model\GetFileInfoModel::fileOssTypePath(!empty(Config::get('filesystem'))?Config::get('filesystem')['enterprise_id']:0);
  2. $public_path = !empty($pathData['data']['public_path'])?$pathData['data']['public_path']:'';
  3. return (new \yzh52521\filesystem\Filesystem(app()))->disk($public_path);

相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载