From 1787e7a86cbd3bdda8b4ab899760cb7fb008dbe8 Mon Sep 17 00:00:00 2001 From: thanatos Date: Thu, 23 Sep 2021 10:58:00 +0800 Subject: [PATCH] fix code style --- module/api/control.php | 8 ++--- module/api/lang/zh-cn.php | 53 ++++++++++++++++---------------- module/api/model.php | 2 +- module/api/view/content.html.php | 2 +- module/api/view/create.html.php | 10 +++--- module/api/view/edit.html.php | 4 +-- module/api/view/index.html.php | 4 +-- module/doc/model.php | 9 +++--- 8 files changed, 47 insertions(+), 45 deletions(-) diff --git a/module/api/control.php b/module/api/control.php index 9dedd4e9dd..001e7bb419 100644 --- a/module/api/control.php +++ b/module/api/control.php @@ -32,7 +32,7 @@ class api extends control * @access public * @return void */ - public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 1) + public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 0) { /* Get all api doc libraries. */ $libs = $this->doc->getApiLibs(); @@ -150,7 +150,7 @@ class api extends control $this->action->create('api', $apiID, 'Edited'); $this->sendSuccess([ - 'locate' => helper::createLink('api', 'index', "apiID=$apiID"), + 'locate' => helper::createLink('api', 'index', "libID=0&moduleID=0&apiID=$apiID"), ]); exit; } @@ -206,7 +206,7 @@ class api extends control if(empty($apiID)) return $this->sendError(dao::getError()); $this->action->create('api', $apiID, 'Created'); - return $this->sendSuccess(array('locate' => helper::createLink('api', 'index', "apiID=$apiID"))); + return $this->sendSuccess(array('locate' => helper::createLink('api', 'index', "libID=0&moduleID=0&apiID=$apiID"))); } $libs = $this->doc->getLibs('api', '', $libID); @@ -272,7 +272,7 @@ class api extends control public function ajaxGetParamsTypeOptions($scope) { if(empty($scope)) die(); - $options = []; + $options = array(); if($scope == apiModel::SCOPE_BODY) { $options = $this->lang->api->allParamsTypeOptions; diff --git a/module/api/lang/zh-cn.php b/module/api/lang/zh-cn.php index 85c1696b63..77793088c8 100644 --- a/module/api/lang/zh-cn.php +++ b/module/api/lang/zh-cn.php @@ -39,6 +39,7 @@ $lang->api->module = '模块'; $lang->api->apiDoc = '接口'; $lang->api->manageType = '维护模块'; $lang->api->doing = '开发中'; +$lang->api->done = '开发完成'; $lang->api->basicInfo = '基本信息'; $lang->api->principal = '负责人'; $lang->api->apiDesc = '接口说明'; @@ -75,52 +76,52 @@ $lang->api->desc = '描述'; $lang->api->customType = '自定义结构'; $lang->api->format = '格式化'; $lang->api->methodOptions = [ - 'GET' => 'GET', - 'POST' => 'POST', - 'PUT' => 'PUT', - 'DELETE' => 'DELETE', - 'PATCH' => 'PATCH', + 'GET' => 'GET', + 'POST' => 'POST', + 'PUT' => 'PUT', + 'DELETE' => 'DELETE', + 'PATCH' => 'PATCH', 'OPTIONS' => 'OPTIONS', - 'HEAD' => 'HEAD' + 'HEAD' => 'HEAD' ]; $lang->api->protocalOptions = [ - 'HTTP' => 'HTTP', + 'HTTP' => 'HTTP', 'HTTPS' => 'HTTPS', ]; $lang->api->requestTypeOptions = [ - 'application/json' => 'application/json', + 'application/json' => 'application/json', 'application/x-www-form-urlencoded' => 'application/x-www-form-urlencoded', - 'multipart/form-data' => 'multipart/form-data' + 'multipart/form-data' => 'multipart/form-data' ]; $lang->api->statusOptions = [ - 'doing' => '开发中', - 'done' => '开发完成', + 'doing' => '开发中', + 'done' => '开发完成', 'hidden' => '不显示' ]; $lang->api->paramsScopeOptions = [ 'formData' => 'formData', - 'path' => 'path', - 'query' => 'query', - 'body' => 'body', - 'header' => 'header', - 'cookie' => 'cookie', + 'path' => 'path', + 'query' => 'query', + 'body' => 'body', + 'header' => 'header', + 'cookie' => 'cookie', ]; /* Api global common params */ $lang->api->paramsTypeOptions = [ - 'string' => 'string', - 'date' => 'date', + 'string' => 'string', + 'date' => 'date', 'datetime' => 'datetime', - 'boolean' => 'boolean', - 'int' => 'int', - 'long' => 'long', - 'float' => 'float', - 'double' => 'double', - 'decimal' => 'decimal' + 'boolean' => 'boolean', + 'int' => 'int', + 'long' => 'long', + 'float' => 'float', + 'double' => 'double', + 'decimal' => 'decimal' ]; /* Api params */ $lang->api->paramsTypeCustomOptions = [ - 'file' => 'file', - 'ref' => 'ref', + 'file' => 'file', + 'ref' => 'ref', 'custom' => '自定义' ]; $lang->api->allParamsTypeOptions = array_merge($lang->api->paramsTypeOptions, $lang->api->paramsTypeCustomOptions); diff --git a/module/api/model.php b/module/api/model.php index df5d2c1b7b..1862eadcf0 100644 --- a/module/api/model.php +++ b/module/api/model.php @@ -306,7 +306,7 @@ class apiModel extends model 'protocol' => $data->protocol, 'method' => $data->method, 'requestType' => $data->requestType, - 'responseType' => $data->responseType, + 'responseType' => isset($data->responseType) ? $data->responseType : '', 'status' => $data->status, 'owner' => $data->owner, 'desc' => $data->desc, diff --git a/module/api/view/content.html.php b/module/api/view/content.html.php index f23c44db18..e0b296e9f8 100644 --- a/module/api/view/content.html.php +++ b/module/api/view/content.html.php @@ -19,7 +19,7 @@ style='max-height:240px; max-width: 300px; overflow-y:auto'> version; $version > 0; $version--): ?>
  • '># + data-url='createLink('api', 'index', "libID=0&moduleID=0&apiID=$apiID&version=$version"); ?>'>#
  • diff --git a/module/api/view/create.html.php b/module/api/view/create.html.php index 581deeead0..b1743db833 100644 --- a/module/api/view/create.html.php +++ b/module/api/view/create.html.php @@ -37,7 +37,7 @@

    id;?> - createLink('api', 'index', "apiID=$api->id"), $api->title, '', "title='$api->title'");?> + createLink('api', 'index', "libID=0&moduleID=0&apiID=$api->id"), $api->title, '', "title='$api->title'");?> arrow . ' ' . $lang->api->edit;?>

    api->formTitle; ?> - title, "class='form-control' required"); ?> + api->path; ?> - path, "class='form-control'"); ?> + api->protocol; ?> - api->protocalOptions, $api->protocol ? $api->protocol : 'HTTP'); ?> + api->protocalOptions, 'HTTP'); ?> api->method; ?> api->methodOptions, $api->method ? $api->method : 'GET', "class='form-control chosen'"); ?> + id='moduleBox'>api->methodOptions, 'GET', "class='form-control chosen'"); ?> diff --git a/module/api/view/edit.html.php b/module/api/view/edit.html.php index 3c00a899db..ee0fe85c17 100644 --- a/module/api/view/edit.html.php +++ b/module/api/view/edit.html.php @@ -146,13 +146,13 @@
    api->default; ?> - default, "class='form-control'"); ?> +
    api->desc; ?> - desc, "class='form-control' style='height:32px'"); ?> +
    diff --git a/module/api/view/index.html.php b/module/api/view/index.html.php index 6a061e86d4..846406b2fd 100644 --- a/module/api/view/index.html.php +++ b/module/api/view/index.html.php @@ -73,9 +73,9 @@
  • - + method; ?> - status); ?> + status); ?> path; ?> title; ?> diff --git a/module/doc/model.php b/module/doc/model.php index 89c36f9443..15dd2aa8cb 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -2180,7 +2180,7 @@ EOT; { $treeMenu[0] .= 'id == $docID ? ' class="active"' : ' class="independent"') . '>'; - $treeMenu[0] .= html::a(inlink('index', "apiID={$doc->id}"), "  " . $doc->title, '', "data-app='{$this->app->tab}' class='doc-title' title='{$doc->title}'"); + $treeMenu[0] .= html::a(inlink('index', "libID=0&moduelID=0&apiID={$doc->id}"), "  " . $doc->title, '', "data-app='{$this->app->tab}' class='doc-title' title='{$doc->title}'"); $treeMenu[0] .= '
  • '; } @@ -2296,7 +2296,7 @@ EOT; { $treeMenu[$module->id] .= 'id == $docID ? ' class="active"' : ' class="doc"') . '>'; - $treeMenu[$module->id] .= html::a(inlink('index', "apiID={$doc->id}"), "  " . $doc->title, '', "data-app='{$this->app->tab}' class='doc-title' title='{$doc->title}'"); + $treeMenu[$module->id] .= html::a(inlink('index', "libID=0&moduleID=0&apiID={$doc->id}"), "  " . $doc->title, '', "data-app='{$this->app->tab}' class='doc-title' title='{$doc->title}'"); $treeMenu[$module->id] .= ''; } @@ -2318,7 +2318,7 @@ EOT; if($type == static::DOC_TYPE_API) { - $li = html::a(inlink('index', "libID=$libID&module={$module->id}"), $module->name, '', "data-app='{$this->app->tab}' class='doc-title' title='{$module->name}'"); + $li = html::a(inlink('index', "libID=$libID&moduleID={$module->id}"), $module->name, '', "data-app='{$this->app->tab}' class='doc-title' title='{$module->name}'"); } else { @@ -2340,7 +2340,8 @@ EOT; if($type == static::DOC_TYPE_API) { $params = $_GET; - if(intval($params['module']) > 0 && $params['module'] == $module->id) + $moduleID = isset($params['moduleID']) ? $params['moduleID'] : 0; + if($moduleID && $moduleID == $module->id) { array_push($class, 'active'); }