From 5499f17f70e530a22a22c55ae2cfb808572d12aa Mon Sep 17 00:00:00 2001 From: iron Date: Tue, 26 Nov 2019 11:28:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0api=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/assets/AppAsset.php | 26 +++++++ api/config/.gitignore | 4 + api/config/bootstrap.php | 1 + api/config/main.php | 51 ++++++++++++ api/config/params.php | 3 + api/controllers/SiteController.php | 22 ++++++ api/controllers/TestController.php | 59 ++++++++++++++ api/runtime/.gitignore | 2 + api/views/site/error.php | 27 +++++++ api/web/.gitignore | 5 ++ api/web/assets/.gitignore | 2 + api/web/css/site.css | 120 +++++++++++++++++++++++++++++ api/web/favicon.ico | Bin 0 -> 318 bytes backend/views/layouts/sidebar.php | 19 +++-- common/config/bootstrap.php | 1 + datadictionary.md | 0 16 files changed, 332 insertions(+), 10 deletions(-) create mode 100644 api/assets/AppAsset.php create mode 100644 api/config/.gitignore create mode 100644 api/config/bootstrap.php create mode 100644 api/config/main.php create mode 100644 api/config/params.php create mode 100644 api/controllers/SiteController.php create mode 100644 api/controllers/TestController.php create mode 100644 api/runtime/.gitignore create mode 100644 api/views/site/error.php create mode 100644 api/web/.gitignore create mode 100644 api/web/assets/.gitignore create mode 100644 api/web/css/site.css create mode 100644 api/web/favicon.ico delete mode 100644 datadictionary.md diff --git a/api/assets/AppAsset.php b/api/assets/AppAsset.php new file mode 100644 index 0000000..6a7b360 --- /dev/null +++ b/api/assets/AppAsset.php @@ -0,0 +1,26 @@ + 'api', + 'basePath' => dirname(__DIR__), + 'controllerNamespace' => 'api\controllers', + 'bootstrap' => ['log'], + 'modules' => [], + 'components' => [ + 'request' => [ + 'parsers' => [ + 'application/json' => 'yii\web\JsonParser', + ], + 'csrfParam' => '_csrf-backend', + ], + 'user' => [ + 'identityClass' => 'common\models\User', + 'enableAutoLogin' => true, + 'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true], + ], + 'session' => [ + // this is the name of the session cookie used for login on the app + 'name' => 'advanced-api', + ], + 'log' => [ + 'traceLevel' => YII_DEBUG ? 3 : 0, + 'targets' => [ + [ + 'class' => 'yii\log\FileTarget', + 'levels' => ['error', 'warning'], + ], + ], + ], + 'errorHandler' => [ + 'errorAction' => 'site/error', + ], + 'urlManager' => [ + 'enablePrettyUrl' => true, + 'showScriptName' => true, + 'enableStrictParsing' => false, + 'rules' => [ + ['class' => 'yii\rest\UrlRule', 'controller' => 'test'], + ], + ], + ], + 'params' => $params, +]; diff --git a/api/config/params.php b/api/config/params.php new file mode 100644 index 0000000..d0b9c34 --- /dev/null +++ b/api/config/params.php @@ -0,0 +1,3 @@ + [ + 'class' => 'yii\web\ErrorAction', + ], + ]; + } +} diff --git a/api/controllers/TestController.php b/api/controllers/TestController.php new file mode 100644 index 0000000..7ede9df --- /dev/null +++ b/api/controllers/TestController.php @@ -0,0 +1,59 @@ + Goods::find(), + 'pagination' => [ + 'pageSize' => 1, + ], + ]); + } +} diff --git a/api/runtime/.gitignore b/api/runtime/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/api/runtime/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/api/views/site/error.php b/api/views/site/error.php new file mode 100644 index 0000000..0ba2574 --- /dev/null +++ b/api/views/site/error.php @@ -0,0 +1,27 @@ +title = $name; +?> +
+ +

title) ?>

+ +
+ +
+ +

+ The above error occurred while the Web server was processing your request. +

+

+ Please contact us if you think this is a server error. Thank you. +

+ +
diff --git a/api/web/.gitignore b/api/web/.gitignore new file mode 100644 index 0000000..ab89d98 --- /dev/null +++ b/api/web/.gitignore @@ -0,0 +1,5 @@ +/index.php +/index-test.php +/robots.txt +uploads + diff --git a/api/web/assets/.gitignore b/api/web/assets/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/api/web/assets/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/api/web/css/site.css b/api/web/css/site.css new file mode 100644 index 0000000..f787e34 --- /dev/null +++ b/api/web/css/site.css @@ -0,0 +1,120 @@ +html, +body { + height: 100%; +} + +.wrap { + min-height: 100%; + height: auto; + margin: 0 auto -60px; + padding: 0 0 60px; +} + +.wrap > .container { + padding: 70px 15px 20px; +} + +.footer { + height: 60px; + background-color: #f5f5f5; + border-top: 1px solid #ddd; + padding-top: 20px; +} + +.jumbotron { + text-align: center; + background-color: transparent; +} + +.jumbotron .btn { + font-size: 21px; + padding: 14px 24px; +} + +.not-set { + color: #c55; + font-style: italic; +} + +/* add sorting icons to gridview sort links */ +a.asc:after, a.desc:after { + position: relative; + top: 1px; + display: inline-block; + font-family: 'Glyphicons Halflings'; + font-style: normal; + font-weight: normal; + line-height: 1; + padding-left: 5px; +} + +a.asc:after { + content: /*"\e113"*/ "\e151"; +} + +a.desc:after { + content: /*"\e114"*/ "\e152"; +} + +.sort-numerical a.asc:after { + content: "\e153"; +} + +.sort-numerical a.desc:after { + content: "\e154"; +} + +.sort-ordinal a.asc:after { + content: "\e155"; +} + +.sort-ordinal a.desc:after { + content: "\e156"; +} + +.grid-view td { + white-space: nowrap; +} + +.grid-view .filters input, +.grid-view .filters select { + min-width: 50px; +} + +.hint-block { + display: block; + margin-top: 5px; + color: #999; +} + +.error-summary { + color: #a94442; + background: #fdf7f7; + border-left: 3px solid #eed3d7; + padding: 10px 20px; + margin: 0 0 15px 0; +} + +/* align the logout "link" (button in forms) of the navbar */ +.nav li > form > button.logout { + padding: 15px; + border: none; +} + +@media(max-width:767px) { + .nav li > form > button.logout { + display:block; + text-align: left; + width: 100%; + padding: 10px 15px; + } +} + +.nav > li > form > button.logout:focus, +.nav > li > form > button.logout:hover { + text-decoration: none; +} + +.nav > li > form > button.logout:focus { + outline: none; +} diff --git a/api/web/favicon.ico b/api/web/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..580ed732e86556ec57f3f3395a210246d679c076 GIT binary patch literal 318 zcmZQzU<5(|0RbS%!l1#(z#zuJz@P!d0zj+)#2|4HXaJKC0wf0lAEr2iX{M9K3=BR0 y!E90pK{x=K$Oz&POT#sS8N$ZKhC)h8ip0_|-T#43{vnSYgXBQCu@O54$pHYIza?e> literal 0 HcmV?d00001 diff --git a/backend/views/layouts/sidebar.php b/backend/views/layouts/sidebar.php index 828322f..a975ac1 100644 --- a/backend/views/layouts/sidebar.php +++ b/backend/views/layouts/sidebar.php @@ -15,22 +15,21 @@ use iron\widgets\Menu; echo Menu::widget([ 'items' => [ // ['label' => 'MAIN NAVIGATION', 'is_header' => true], - ['label' => '商城管理', 'url' => '#', 'icon' => 'far fa-store', 'items' => [ - ['label' => '运营数据', 'url' => ['site/index', 'tag' => 'new']], - ['label' => '基础配置', 'url' => ['config/index', 'tag' => 'new']], + ['label' => '商城管理', 'url' => '#', 'icon' => 'fa-store', 'items' => [ + ['label' => '运营数据', 'url' => ['site/index']], + ['label' => '基础配置', 'url' => ['config/index']], ] ], - ['label' => '商品管理', 'url' => '#', 'icon' => 'far fa-archive', 'items' => [ - ['label' => '商品分类', 'url' => ['category/index', 'tag' => 'new']], - ['label' => '商品列表', 'url' => ['goods/index']], - ['label' => '属性管理', 'url' => ['attribute/index']], + ['label' => '商品管理', 'url' => '#', 'icon' => 'fa-archive', 'items' => [ + ['label' => '商品分类', 'url' => ['/category']], + ['label' => '商品列表', 'url' => ['/goods']], + ['label' => '属性管理', 'url' => ['/attribute']], ] ], - ['label' => '订单管理', 'url' => '#', 'icon' => 'far fa-list-alt', 'items' => [ - ['label' => '订单列表', 'url' => ['order/index', 'tag' => 'new']], + ['label' => '订单管理', 'url' => '#', 'icon' => 'fa-list-alt', 'items' => [ + ['label' => '订单列表', 'url' => ['order/index']], ] ], - ] ]); ?> diff --git a/common/config/bootstrap.php b/common/config/bootstrap.php index 4102199..b8d4302 100755 --- a/common/config/bootstrap.php +++ b/common/config/bootstrap.php @@ -2,3 +2,4 @@ Yii::setAlias('@common', dirname(__DIR__)); Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console'); Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend'); +Yii::setAlias('@api', dirname(dirname(__DIR__)) . '/api'); diff --git a/datadictionary.md b/datadictionary.md deleted file mode 100644 index e69de29..0000000 From 32e9c73d0641dd0a8dd62fd15131d00d2512957e Mon Sep 17 00:00:00 2001 From: root Date: Tue, 26 Nov 2019 14:17:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=E5=A4=9A=E7=BA=A7=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=98=BE=E7=A4=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/views/layouts/sidebar.php | 14 ++++----- vendor/iron/grid/GridView.php | 24 ++++++++-------- vendor/iron/widgets/Menu.php | 47 ++++++++++++++++++++----------- 3 files changed, 51 insertions(+), 34 deletions(-) diff --git a/backend/views/layouts/sidebar.php b/backend/views/layouts/sidebar.php index 9eb71db..8978670 100755 --- a/backend/views/layouts/sidebar.php +++ b/backend/views/layouts/sidebar.php @@ -22,16 +22,16 @@ use iron\widgets\Menu; ], ['label' => '商品管理', 'url' => '#', 'icon' => 'far fa-archive', 'items' => [ - ['label' => '规格管理', 'url' => ['/antgoods/attribute/index']], - ['label' => '商品列表', 'url' => ['/antgoods/goods/index']], - ['label' => '后台商品分类', 'url' => ['/antgoods/category/index']], - ['label' => '前端商品分类', 'url' => ['/antgoods/shopcategory/index']], - ['label' => '品牌管理', 'url' => ['/antgoods/brand/index']], - ['label' => '供应商管理', 'url' => ['/antgoods/supplier/index']], + ['label' => '规格管理', 'url' => ['/antgoods/attribute']], + ['label' => '商品列表', 'url' => ['/antgoods/goods']], + ['label' => '后台商品分类', 'url' => ['/antgoods/category']], + ['label' => '前端商品分类', 'url' => ['/antgoods/shopcategory']], + ['label' => '品牌管理', 'url' => ['/antgoods/brand']], + ['label' => '供应商管理', 'url' => ['/antgoods/supplier']], ] ], ['label' => '订单管理', 'url' => '#', 'icon' => 'far fa-list-alt', 'items' => [ - ['label' => '订单列表', 'url' => ['/order/index', 'tag' => 'new']], + ['label' => '订单列表', 'url' => ['/order', 'tag' => 'new']], ] ], ] diff --git a/vendor/iron/grid/GridView.php b/vendor/iron/grid/GridView.php index 5b42816..4f83b4a 100644 --- a/vendor/iron/grid/GridView.php +++ b/vendor/iron/grid/GridView.php @@ -219,13 +219,13 @@ class GridView extends BaseListView
{batch} - 添加 + 添加
@@ -281,14 +281,14 @@ HTML; throw new InvalidConfigException('The "formatter" property must be either a Format object or a configuration array.'); } $this->pager = [ - 'options'=>['class'=>['justify-content-end','pagination']], - 'linkOptions'=>['class'=>'page-link'], - 'pageCssClass'=>'paginate_button page-item', - 'disabledPageCssClass'=>'page-link disabled', - 'firstPageLabel'=>'«', - 'prevPageLabel'=>'‹', - 'nextPageLabel'=>'›', - 'lastPageLabel'=>'»',]; + 'options' => ['class' => ['justify-content-end', 'pagination']], + 'linkOptions' => ['class' => 'page-link'], + 'pageCssClass' => 'paginate_button page-item', + 'disabledPageCssClass' => 'page-link disabled', + 'firstPageLabel' => '«', + 'prevPageLabel' => '‹', + 'nextPageLabel' => '›', + 'lastPageLabel' => '»',]; $this->initColumns(); } @@ -445,6 +445,8 @@ SCRIPT; return $this->renderFilter(); case '{batch}': return $this->renderBatch(); + case '{url}': + return Yii::$app->request->url; default: return false; } diff --git a/vendor/iron/widgets/Menu.php b/vendor/iron/widgets/Menu.php index 4da4c21..f4d2a66 100644 --- a/vendor/iron/widgets/Menu.php +++ b/vendor/iron/widgets/Menu.php @@ -36,7 +36,7 @@ use yii\helpers\Url; * 参照yii\widgets\Menu,根据AdminLTE样式从写的一个小物件 * @author Blobt * @email 380255922@qq.com - * 使用例子 + * 使用例子 * [ @@ -50,10 +50,11 @@ use yii\helpers\Url; * ] * ]); * ?> - * - * + * + * */ -class Menu extends Widget { +class Menu extends Widget +{ /** * @var array 菜单的item数组。 @@ -132,8 +133,8 @@ class Menu extends Widget { public $options = [ 'class' => 'nav nav-pills nav-sidebar flex-column', 'data-widget' => 'treeview', - 'role'=>'menu', - 'data-accordion'=>'false' + 'role' => 'menu', + 'data-accordion' => 'false' ]; /** @@ -164,7 +165,8 @@ class Menu extends Widget { /** * 渲染菜单 */ - public function run() { + public function run() + { if ($this->route === null && Yii::$app->controller !== null) { $this->route = Yii::$app->controller->getRoute(); } @@ -186,7 +188,8 @@ class Menu extends Widget { * @param array $items * @return string 渲染结果 */ - protected function renderItems($items) { + protected function renderItems($items) + { $lines = []; $n = count($items); foreach ($items as $i => $item) { @@ -234,7 +237,8 @@ class Menu extends Widget { * @param array $item * @return string 渲染结果 */ - protected function renderItem($item) { + protected function renderItem($item) + { if (isset($item['url'])) { if (isset($item['template'])) { $template = $item['template']; @@ -244,7 +248,7 @@ class Menu extends Widget { return strtr($template, [ '{url}' => Html::encode(Url::to($item['url'])), '{label}' => Html::encode($item['label']), - '{class}'=>isset($item['active'])?'active':'', + '{class}' => isset($item['active']) ? 'active' : '', '{icon}' => Html::encode($item['icon']) ]); } @@ -253,7 +257,7 @@ class Menu extends Widget { return strtr($template, [ '{label}' => $item['label'], - '{class}'=>isset($item['active'])?'active':'' + '{class}' => isset($item['active']) ? 'active' : '' ]); } @@ -262,21 +266,31 @@ class Menu extends Widget { * @param $item array * @return boolean $item */ - protected function isItemActive($item) { + protected function isItemActive($item) + { if (isset($item['url']) && is_array($item['url']) && isset($item['url'][0])) { $route = Yii::getAlias($item['url'][0]); - if ($route[0] !== '/' && Yii::$app->controller) { $route = Yii::$app->controller->module->getUniqueId() . '/' . $route; } - if (ltrim($route, '/') !== $this->route) { + $route = ltrim($route, '/'); + if ($route != substr($this->route, 0, strrpos($this->route, '/')) && $route != $this->route && + ltrim(Yii::$app->request->url, '/') !== $route) { + return false; } + unset($item['url']['#']); + if (count($item['url']) > 1) { + foreach (array_splice($item['url'], 1) as $name => $value) { + if ($value !== null && (!isset($this->params[$name]) || $this->params[$name] != $value)) { + return false; + } + } + } return true; } - return false; } @@ -285,7 +299,8 @@ class Menu extends Widget { * @param string $item * @param bool $active */ - protected function normalizeItems($items, &$active) { + protected function normalizeItems($items, &$active) + { foreach ($items as $i => $item) { /* 去除visible 为 false的item */ if (isset($item['visible']) && !$item['visible']) { From 2654745f852798486f93502de5b84b3a776b5f02 Mon Sep 17 00:00:00 2001 From: iron Date: Tue, 26 Nov 2019 14:43:15 +0800 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=E8=8F=9C=E5=8D=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/views/layouts/sidebar.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/views/layouts/sidebar.php b/backend/views/layouts/sidebar.php index 7a6af72..95f3359 100755 --- a/backend/views/layouts/sidebar.php +++ b/backend/views/layouts/sidebar.php @@ -20,7 +20,6 @@ use iron\widgets\Menu; ['label' => '基础配置', 'url' => ['config/index']], ] ], - ['label' => '商品管理', 'url' => '#', 'icon' => 'far fa-archive', 'items' => [ ['label' => '规格管理', 'url' => ['/antgoods/attribute']], ['label' => '商品列表', 'url' => ['/antgoods/goods']], @@ -28,7 +27,6 @@ use iron\widgets\Menu; ['label' => '前端商品分类', 'url' => ['/antgoods/shop-category']], ['label' => '品牌管理', 'url' => ['/antgoods/brand']], ['label' => '供应商管理', 'url' => ['/antgoods/supplier']], - ] ], ['label' => '订单管理', 'url' => '#', 'icon' => 'far fa-list-alt', 'items' => [