更新代码

This commit is contained in:
mkm 2024-01-20 22:40:47 +08:00
parent 1795255b61
commit f7b813b2dd
12 changed files with 61 additions and 122 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
.env
/tests/tmp
/tests/.phpunit.result.cache
public/uploads

View File

@ -91,25 +91,7 @@ class GeneratorController extends BaseAdminController
return $this->success('操作成功', $result, 1, 1);
}
/**
* @notes 下载文件
* @return \think\response\File|\think\response\Json
* @author 段誉
* @date 2022/6/24 9:51
*/
public function download()
{
$params = (new GenerateTableValidate())->goCheck('download');
$result = GeneratorLogic::download($params['file']);
if (false === $result) {
return $this->fail(GeneratorLogic::getError() ?: '下载失败');
}
return download($result, 'likeadmin-curd.zip');
}
/**
* @notes 预览代码
* @return \think\response\Json

View File

@ -149,8 +149,12 @@ class WebSettingLogic extends BaseLogic
'privacy_content' => ConfigService::get('agreement', 'privacy_content'),
];
$config['service_content'] = get_file_domain($config['service_content']);
$config['privacy_content'] = get_file_domain($config['privacy_content']);
if($config['service_content']){
$config['service_content'] = get_file_domain($config['service_content']);
}
if($config['privacy_content']){
$config['privacy_content'] = get_file_domain($config['privacy_content']);
}
return $config;
}

View File

@ -1,12 +1,28 @@
<?php
namespace app\api\controller;
use WebSocket\Client;
class IndexController{
public function index(){
var_dump(runtime_path());
use app\admin\validate\tools\GenerateTableValidate;
use app\admin\logic\tools\GeneratorLogic;
use app\common\controller\BaseLikeAdminController;
class IndexController extends BaseLikeAdminController
{
public function index()
{
return json(['msg' => 'hello']);
}
}
/**
* @notes 下载文件
*/
public function download()
{
$params = (new GenerateTableValidate())->goCheck('download');
$result = GeneratorLogic::download($params['file']);
if (false === $result) {
return $this->fail(GeneratorLogic::getError() ?: '下载失败');
}
return response()->download($result, 'webman-curd.zip');
}
}

View File

@ -57,8 +57,8 @@ class GenerateService
public function __construct()
{
$this->generatePath = base_path() . '/runtime/generate/';
$this->runtimePath = base_path() . '/runtime/';
$this->generatePath = runtime_path() . '/generate/';
$this->runtimePath = runtime_path() . '/';
}
@ -228,9 +228,8 @@ class GenerateService
*/
public function getDownloadUrl()
{
// $vars = ['file' => $this->zipTempName];
Cache::set('curd_file_name' . $this->zipTempName, $this->zipTempName, 3600);
return "admin/tools/generator/download?file=".$this->zipTempName;
return getenv('WEB_URL')."/api/index/download?file=".$this->zipTempName;
}
}

View File

@ -1,17 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
{NAMESPACE}

View File

@ -1,16 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
{NAMESPACE}

View File

@ -1,16 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
{NAMESPACE}

View File

@ -1,16 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
{NAMESPACE}

View File

@ -1,16 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
{NAMESPACE}

View File

@ -1,16 +1,4 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
{NAMESPACE}

View File

@ -2,9 +2,8 @@
/**
* Here is your custom functions.
*/
use app\common\service\FileService;
use support\Response;
use support\Request;
if(!function_exists('substr_symbol_behind')){
/**
@ -125,22 +124,6 @@ function createDir($path){
return mkdir($path);
}
if (!function_exists('download')) {
/**
* 获取\think\response\Download对象实例
* @param string $filename 要下载的文件
* @param string $name 显示文件名
* @param bool $content 是否为内容
* @param int $expire 有效期(秒)
* @return \think\response\File
*/
function download(string $filename, string $name = '', bool $content = false, int $expire = 180)
{
return response()->download($filename,$name);
}
}
/**
* @notes 删除目标目录
* @param $path
@ -196,4 +179,31 @@ function get_no_prefix_table_name($tableName)
}
$tableName = substr_replace($tableName, '', 0, strlen($tablePrefix));
return trim($tableName);
}
/**
* @notes 去除内容图片域名
* @param $content
* @return array|string|string[]
* @author 段誉
* @date 2022/9/26 10:43
*/
function clear_file_domain($content)
{
$fileUrl = FileService::getFileUrl();
return str_replace($fileUrl, '/', $content);
}
/**
* @notes 设置内容图片域名
* @param $content
* @return array|string|string[]|null
* @author 段誉
* @date 2022/9/26 10:43
*/
function get_file_domain($content)
{
$preg = '/(<img .*?src=")[^https|^http](.*?)(".*?>)/is';
$fileUrl = FileService::getFileUrl();
return preg_replace($preg, "\${1}$fileUrl\${2}\${3}", $content);
}