Compare commits

...

5 Commits

Author SHA1 Message Date
邹景立
f00f9f629e 修改支付 2022-11-21 15:00:12 +08:00
邹景立
294c8b82a6 Update Plugs.php 2022-11-21 12:45:48 +08:00
邹景立
6cbb687862 优化后台判断与Library配合 2022-11-21 12:42:23 +08:00
邹景立
90228f0ff6 修改系统运行服务 2022-11-21 11:40:25 +08:00
邹景立
983496fd9c Update Login.php 2022-11-21 11:30:26 +08:00
9 changed files with 25 additions and 32 deletions

View File

@ -94,7 +94,7 @@ class Auth extends Controller
{
$map = $this->_vali(['auth.require#id' => '权限ID不能为空']);
if (input('action') === 'get') {
if ($this->app->isDebug()) AdminService::clearCache();
if ($this->app->isDebug()) AdminService::clear();
$nodes = SystemNode::mk()->where($map)->column('node');
$this->success('获取权限节点成功!', AdminService::getTree($nodes));
} elseif (input('action') === 'save') {

View File

@ -19,6 +19,7 @@ namespace app\admin\controller;
use think\admin\Controller;
use think\admin\service\AdminService;
use think\admin\service\ModuleService;
use think\admin\service\RuntimeService;
use think\admin\service\SystemService;
use think\admin\storage\AliossStorage;
use think\admin\storage\QiniuStorage;
@ -81,7 +82,7 @@ class Config extends Controller
if ($post['xpath'] !== 'admin' && file_exists($this->app->getBasePath() . $post['xpath'])) {
$this->error("后台入口名称{$post['xpath']}已经存在应用!");
}
SystemService::setRuntime(null, [$post['xpath'] => 'admin']);
RuntimeService::set(null, [$post['xpath'] => 'admin']);
}
// 修改网站 ICON 图标,替换 public/favicon.ico
if (preg_match('#^https?://#', $post['site_icon'] ?? '')) try {

View File

@ -21,6 +21,7 @@ use think\admin\extend\CodeExtend;
use think\admin\model\SystemUser;
use think\admin\service\AdminService;
use think\admin\service\CaptchaService;
use think\admin\service\RuntimeService;
use think\admin\service\SystemService;
/**
@ -44,7 +45,7 @@ class Login extends Controller
$this->redirect(sysuri('admin/index/index'));
} else {
// 当前运行模式
$this->developMode = SystemService::checkRunMode();
$this->developMode = RuntimeService::check();
// 后台背景处理
$images = str2arr(sysconf('login_image') ?: '', '|');
if (empty($images)) $images = [
@ -129,7 +130,6 @@ class Login extends Controller
*/
public function out()
{
$this->app->session->clear();
$this->app->session->destroy();
$this->success('退出登录成功!', sysuri('admin/login/index'));
}

View File

@ -99,14 +99,13 @@ class Menu extends Controller
protected function _form_filter(array &$vo)
{
if ($this->request->isGet()) {
$debug = $this->app->isDebug();
/* 清理权限节点 */
if ($isDebug = $this->app->isDebug()) {
AdminService::clearCache();
}
$debug && AdminService::clear();
/* 读取系统功能节点 */
$this->auths = [];
$this->nodes = MenuService::getList($isDebug);
foreach (NodeService::getMethods($isDebug) as $node => $item) {
$this->nodes = MenuService::getList($debug);
foreach (NodeService::getMethods($debug) as $node => $item) {
if ($item['isauth'] && substr_count($node, '/') >= 2) {
$this->auths[] = ['node' => $node, 'title' => $item['title']];
}

View File

@ -47,13 +47,10 @@ class Plugs extends Controller
*/
public function script(): \think\Response
{
$taDebug = $this->app->isDebug() ? 'true' : 'false';
$taAdmin = sysuri('admin/index/index', [], false);
$taEditor = sysconf('base.editor') ?: 'ckeditor4';
return response(join("\n", [
"window.taDebug = {$taDebug};",
"window.taAdmin = '{$taAdmin}';",
"window.taEditor = '{$taEditor}';",
return response(join("\r\n", [
sprintf("window.taDebug = %s;", $this->app->isDebug() ? 'true' : 'false'),
sprintf("window.taAdmin = '%s';", sysuri('admin/index/index', [], false)),
sprintf("window.taEditor = '%s';", sysconf('base.editor') ?: 'ckeditor4'),
]))->contentType('application/x-javascript');
}

View File

@ -19,7 +19,7 @@ namespace app\admin\controller\api;
use think\admin\Controller;
use think\admin\model\SystemConfig;
use think\admin\service\AdminService;
use think\admin\service\SystemService;
use think\admin\service\RuntimeService;
use think\exception\HttpResponseException;
/**
@ -37,9 +37,7 @@ class System extends Controller
public function push()
{
if (AdminService::isSuper()) try {
AdminService::clearCache();
SystemService::pushRuntime();
sysoplog('系统运维管理', '刷新创建路由缓存');
RuntimeService::push() && sysoplog('系统运维管理', '刷新发布运行缓存');
$this->success('网站缓存加速成功!', 'javascript:location.reload()');
} catch (HttpResponseException $exception) {
throw $exception;
@ -58,9 +56,7 @@ class System extends Controller
public function clear()
{
if (AdminService::isSuper()) try {
AdminService::clearCache();
SystemService::clearRuntime();
sysoplog('系统运维管理', '清理网站日志缓存');
RuntimeService::clear() && sysoplog('系统运维管理', '清理网站日志缓存');
$this->success('清空日志缓存成功!', 'javascript:location.reload()');
} catch (HttpResponseException $exception) {
throw $exception;
@ -79,11 +75,11 @@ class System extends Controller
public function debug()
{
if (AdminService::isSuper()) if (input('state')) {
SystemService::setRuntime('product');
RuntimeService::set('product');
sysoplog('系统运维管理', '开发模式切换为生产模式');
$this->success('已切换为生产模式!', 'javascript:location.reload()');
} else {
SystemService::setRuntime('debug');
RuntimeService::set('debug');
sysoplog('系统运维管理', '生产模式切换为开发模式');
$this->success('已切换为开发模式!', 'javascript:location.reload()');
} else {

View File

@ -18,7 +18,7 @@ namespace app\admin\controller\api;
use think\admin\Controller;
use think\admin\service\ModuleService;
use think\admin\service\SystemService;
use think\admin\service\RuntimeService;
/**
* 安装服务端支持
@ -33,7 +33,7 @@ class Update extends Controller
*/
protected function initialize()
{
if (!SystemService::checkRunMode()) {
if (!RuntimeService::check()) {
$this->error('只允许访问本地或官方代码!');
}
}

View File

@ -15,17 +15,17 @@
// +----------------------------------------------------------------------
use think\admin\Library;
use think\admin\service\SystemService;
use think\admin\service\RuntimeService;
/*! 非开发环境,清理限制文件 */
if (Library::$sapp->request->isGet() && !SystemService::checkRunMode()) {
if (Library::$sapp->request->isGet() && !RuntimeService::check()) {
@unlink(Library::$sapp->getBasePath() . 'admin/controller/api/Update.php');
@unlink(Library::$sapp->getBasePath() . 'admin/route/demo.php');
@rmdir(Library::$sapp->getBasePath() . 'admin/route');
}
/*! 演示环境禁止操作路由绑定 */
if (SystemService::checkRunMode('demo')) {
if (RuntimeService::check('demo')) {
Library::$sapp->route->post('index/pass', function () {
return json(['code' => 0, 'info' => '演示环境禁止修改用户密码!']);
});

View File

@ -53,8 +53,8 @@ class WechatPaymentService extends PaymentService
if ($info['return_code'] === 'SUCCESS' && $info['result_code'] === 'SUCCESS') {
// 创建支付记录
$this->createPaymentAction($orderNo, $payTitle, $payAmount);
// 微信二维码支付
if ($this->type === static::PAYMENT_WECHAT_QRC) {
// 微信二维码及网页支付
if (in_array($this->type, [static::PAYMENT_WECHAT_WAP, static::PAYMENT_WECHAT_QRC])) {
return $info;
}
// 返回JSAPI参数