伪静态配置优化

feat/task1-c-wallet
gongfuxiang 2024-12-29 18:30:21 +08:00
parent 0958c545a2
commit f52e119784
3 changed files with 68 additions and 39 deletions

View File

@ -0,0 +1,59 @@
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | 路由规则
// +----------------------------------------------------------------------
use think\facade\Route;
// 分隔符
$ds = MyC('common_route_separator', '-', true);
// 商品详情
Route::get('goods'.$ds.':id', 'goods/index');
// 搜索
Route::rule('search', 'search/index', 'GET|POST');
Route::post('search-goods', 'search/goodslist');
// 分类
Route::get('category', 'category/index');
// 自定义页面
Route::get('custom'.$ds.':id', 'customview/index');
// 购物车
Route::get('cart', 'cart/index');
// 订单确认
Route::rule('buy', 'buy/index', 'GET|POST');
Route::post('buy-add', 'buy/add');
// 文章
Route::rule('article-category'.$ds.'[:id]', 'article/category', 'GET|POST');
Route::get('article'.$ds.':id', 'article/index');
// 页面设计
Route::get('design'.$ds.':id', 'design/index');
// 用户
Route::get('login', 'user/logininfo');
Route::get('login'.$ds.'modal', 'user/modallogininfo');
Route::get('regster', 'user/reginfo');
Route::get('regster'.$ds.'sms', 'user/smsreginfo');
Route::get('regster'.$ds.'email', 'user/emailreginfo');
Route::get('forget', 'user/forgetpwdinfo');
Route::get('logout', 'user/logout');
// 插件调用
Route::rule(':pluginsname'.$ds.'[:pluginscontrol]'.$ds.'[:pluginsaction]'.$ds.'[:id]','plugins/index')->completeMatch();
Route::rule(':pluginsname'.$ds.':pluginscontrol'.$ds.':pluginsaction'.$ds.'[:id]','plugins/index');
?>

View File

@ -17,42 +17,6 @@ use think\facade\Route;
// 分隔符
$ds = MyC('common_route_separator', '-', true);
// 商品详情
Route::get('goods'.$ds.':id', 'goods/index');
// 搜索
Route::rule('search', 'search/index', 'GET|POST');
Route::post('search-goods', 'search/goodslist');
// 分类
Route::get('category', 'category/index');
// 自定义页面
Route::get('custom'.$ds.':id', 'customview/index');
// 购物车
Route::get('cart', 'cart/index');
// 订单确认
Route::rule('buy', 'buy/index', 'GET|POST');
Route::post('buy-add', 'buy/add');
// 文章
Route::rule('article-category'.$ds.'[:id]', 'article/category', 'GET|POST');
Route::get('article'.$ds.':id', 'article/index');
// 页面设计
Route::get('design'.$ds.':id', 'design/index');
// 用户
Route::get('login', 'user/logininfo');
Route::get('login'.$ds.'modal', 'user/modallogininfo');
Route::get('regster', 'user/reginfo');
Route::get('regster'.$ds.'sms', 'user/smsreginfo');
Route::get('regster'.$ds.'email', 'user/emailreginfo');
Route::get('forget', 'user/forgetpwdinfo');
Route::get('logout', 'user/logout');
// 插件调用
Route::rule(':pluginsname'.$ds.'[:pluginscontrol]'.$ds.'[:pluginsaction]'.$ds.'[:id]','plugins/index')->completeMatch();
Route::rule(':pluginsname'.$ds.':pluginscontrol'.$ds.':pluginsaction'.$ds.'[:id]','plugins/index');

View File

@ -534,8 +534,8 @@ class ConfigService
{
if(array_key_exists('home_seo_url_model', $params))
{
$route_file = APP_PATH.'route'.DS.'route.config';
$route_arr = ['index'];
// 模块组
$route_arr = ['admin', 'index', 'api'];
// 后端+前端都生成对应的路由定义规则、为了后台进入前端url保持一致
foreach($route_arr as $module)
@ -556,7 +556,13 @@ class ConfigService
// pathinfo+短地址模式
if($params['home_seo_url_model'] == 2)
{
// 伪静态规则配置文件
$route_file = APP_PATH.'route'.DS.'route.config';
$module_route_file = APP_PATH.$module.DS.'route'.DS.'route.config';
if(file_exists($module_route_file))
{
$route_file = $module_route_file;
}
if(!file_exists($route_file))
{
return DataReturn(MyLang('common_service.config.route_file_config_no_exist_tips').'[./app/route/route.config]', -14);