Translated the project to english (translations done by google translate).

This commit is contained in:
Joe Huss 2022-10-20 04:28:37 -04:00
parent d0d1da26c8
commit 8ed7fd321a
29 changed files with 385 additions and 385 deletions

View File

@ -7,13 +7,13 @@ use support\exception\BusinessException;
use function admin; use function admin;
/** /**
* 对外提供的鉴权接口 * Authentication interface provided externally
*/ */
class Auth class Auth
{ {
/** /**
* 判断权限 * judgment authority
* 如果没有权限则抛出异常 * Throw exception if no permission
* *
* @param string $controller * @param string $controller
* @param string $action * @param string $action
@ -30,7 +30,7 @@ class Auth
} }
/** /**
* 判断是否有权限 * Determine whether there is permission
* *
* @param string $controller * @param string $controller
* @param string $action * @param string $action
@ -41,40 +41,40 @@ class Auth
*/ */
public static function canAccess(string $controller, string $action, int &$code = 0, string &$msg = '') public static function canAccess(string $controller, string $action, int &$code = 0, string &$msg = '')
{ {
// 获取控制器鉴权信息 // Get controller authentication information
$class = new \ReflectionClass($controller); $class = new \ReflectionClass($controller);
$properties = $class->getDefaultProperties(); $properties = $class->getDefaultProperties();
$noNeedLogin = $properties['noNeedLogin'] ?? []; $noNeedLogin = $properties['noNeedLogin'] ?? [];
$noNeedAuth = $properties['noNeedAuth'] ?? []; $noNeedAuth = $properties['noNeedAuth'] ?? [];
// 不需要登录 // No login required
if (in_array($action, $noNeedLogin)) { if (in_array($action, $noNeedLogin)) {
return true; return true;
} }
// 获取登录信息 // Get login information
$admin = admin(); $admin = admin();
if (!$admin) { if (!$admin) {
$msg = '请登录'; $msg = 'please sign in';
// 401是未登录固定的返回码 // 401is not logged in fixed return code
$code = 401; $code = 401;
return false; return false;
} }
// 不需要鉴权 // No authentication required
if (in_array($action, $noNeedAuth)) { if (in_array($action, $noNeedAuth)) {
return true; return true;
} }
// 当前管理员无角色 // Current administrator has no role
$roles = $admin['roles']; $roles = $admin['roles'];
if (!$roles) { if (!$roles) {
$msg = '无权限'; $msg = 'No permission';
$code = 2; $code = 2;
return false; return false;
} }
// 角色没有规则 // Role has no rules
$rules = AdminRole::whereIn('id', $roles)->pluck('rules'); $rules = AdminRole::whereIn('id', $roles)->pluck('rules');
$rule_ids = []; $rule_ids = [];
foreach ($rules as $rule_string) { foreach ($rules as $rule_string) {
@ -84,23 +84,23 @@ class Auth
$rule_ids = array_merge($rule_ids, explode(',', $rule_string)); $rule_ids = array_merge($rule_ids, explode(',', $rule_string));
} }
if (!$rule_ids) { if (!$rule_ids) {
$msg = '无权限'; $msg = 'No permission';
$code = 2; $code = 2;
return false; return false;
} }
// 超级管理员 // Super Admin
if (in_array('*', $rule_ids)){ if (in_array('*', $rule_ids)){
return true; return true;
} }
// 没有当前控制器的规则 // No rules for current controller
$rule = AdminRule::where(function ($query) use ($controller, $action) { $rule = AdminRule::where(function ($query) use ($controller, $action) {
$query->where('name', "$controller@$action")->orWhere('name', $controller); $query->where('name', "$controller@$action")->orWhere('name', $controller);
})->whereIn('id', $rule_ids)->first(); })->whereIn('id', $rule_ids)->first();
if (!$rule) { if (!$rule) {
$msg = '无权限'; $msg = 'No permission';
$code = 2; $code = 2;
return false; return false;
} }

View File

@ -5,33 +5,33 @@ namespace plugin\admin\api;
class Install class Install
{ {
/** /**
* 安装 * Install
* *
* @param $version * @param $version
* @return void * @return void
*/ */
public static function install($version) public static function install($version)
{ {
// 导入菜单 // Import menu
Menu::import(static::getMenus()); Menu::import(static::getMenus());
} }
/** /**
* 卸载 * Uninstall
* *
* @param $version * @param $version
* @return void * @return void
*/ */
public static function uninstall($version) public static function uninstall($version)
{ {
// 删除菜单 // Delete menu
foreach (static::getMenus() as $menu) { foreach (static::getMenus() as $menu) {
Menu::delete($menu['name']); Menu::delete($menu['name']);
} }
} }
/** /**
* 更新 * renew
* *
* @param $from_version * @param $from_version
* @param $to_version * @param $to_version
@ -40,16 +40,16 @@ class Install
*/ */
public static function update($from_version, $to_version, $context = null) public static function update($from_version, $to_version, $context = null)
{ {
// 删除不用的菜单 // Delete unused menus
if (isset($context['previous_menus'])) { if (isset($context['previous_menus'])) {
static::removeUnnecessaryMenus($context['previous_menus']); static::removeUnnecessaryMenus($context['previous_menus']);
} }
// 导入新菜单 // Import new menu
Menu::import(static::getMenus()); Menu::import(static::getMenus());
} }
/** /**
* 更新前数据收集等 * Data collection before update etc
* *
* @param $from_version * @param $from_version
* @param $to_version * @param $to_version
@ -57,12 +57,12 @@ class Install
*/ */
public static function beforeUpdate($from_version, $to_version) public static function beforeUpdate($from_version, $to_version)
{ {
// 在更新之前获得老菜单通过context传递给 update // Get the old menu before updating, passed the context to update
return ['previous_menus' => static::getMenus()]; return ['previous_menus' => static::getMenus()];
} }
/** /**
* 获取菜单 * Get menu
* *
* @return array|mixed * @return array|mixed
*/ */
@ -77,7 +77,7 @@ class Install
} }
/** /**
* 删除不需要的菜单 * Remove unwanted menus
* *
* @param $previous_menus * @param $previous_menus
* @return void * @return void

View File

@ -7,13 +7,13 @@ use support\exception\BusinessException;
use function admin; use function admin;
/** /**
* 对外提供的菜单接口 * Externally provided menu interface
*/ */
class Menu class Menu
{ {
/** /**
* 根据名字获得菜单 * Get menu by name
* *
* @param $name * @param $name
* @return array * @return array
@ -25,7 +25,7 @@ class Menu
} }
/** /**
* 根据id获得菜单 * Get menu by id
* *
* @param $id * @param $id
* @return array * @return array
@ -36,7 +36,7 @@ class Menu
} }
/** /**
* 添加菜单 * Add menu
* *
* @param array $menu * @param array $menu
* @return int * @return int
@ -55,7 +55,7 @@ class Menu
} }
/** /**
* 导入菜单 * Import menu
* *
* @param array $menu_tree * @param array $menu_tree
* @return void * @return void
@ -83,7 +83,7 @@ class Menu
} }
/** /**
* 删除菜单 * Delete menu
* *
* @param $name * @param $name
* @return void * @return void
@ -94,7 +94,7 @@ class Menu
if (!$item) { if (!$item) {
return; return;
} }
// 子规则一起删除 // Sub-rules are deleted together
$delete_ids = $children_ids = [$item['id']]; $delete_ids = $children_ids = [$item['id']];
while($children_ids) { while($children_ids) {
$children_ids = AdminRule::whereIn('pid', $children_ids)->pluck('id')->toArray(); $children_ids = AdminRule::whereIn('pid', $children_ids)->pluck('id')->toArray();
@ -105,7 +105,7 @@ class Menu
/** /**
* 获取菜单中某个()字段的值 * Get the value of a field(s) in the menu
* *
* @param $menus * @param $menus
* @param $column * @param $column

View File

@ -8,7 +8,7 @@ use Webman\Http\Response;
use Webman\MiddlewareInterface; use Webman\MiddlewareInterface;
/** /**
* 对外提供的中间件 * Externally provided middleware
*/ */
class Middleware implements MiddlewareInterface class Middleware implements MiddlewareInterface
{ {

View File

@ -31,7 +31,7 @@ class Util
static public function checkTableName($table) static public function checkTableName($table)
{ {
if (!preg_match('/^[a-zA-Z_0-9]+$/', $table)) { if (!preg_match('/^[a-zA-Z_0-9]+$/', $table)) {
throw new BusinessException('表名不合法'); throw new BusinessException('The table name is invalid');
} }
return true; return true;
} }
@ -71,7 +71,7 @@ class Util
public static function methodControlMap() public static function methodControlMap()
{ {
return [ return [
//method=>[控件] //method=>[Controls]
'integer' => ['InputNumber'], 'integer' => ['InputNumber'],
'string' => ['Input'], 'string' => ['Input'],
'text' => ['InputTextArea'], 'text' => ['InputTextArea'],

View File

@ -7,25 +7,25 @@ use support\Db;
use support\Request; use support\Request;
/** /**
* 基础控制器 * Basic Controller
*/ */
class Base class Base
{ {
/** /**
* 无需登录的方法及鉴权 * Method and authentication without login
* @var array * @var array
*/ */
protected $noNeedLogin = []; protected $noNeedLogin = [];
/** /**
* 需要登录无需鉴权的方法 * Requires login without authentication method
* @var array * @var array
*/ */
protected $noNeedAuth = []; protected $noNeedAuth = [];
/** /**
* 返回格式化json数据 * return formatted json data
* *
* @param int $code * @param int $code
* @param string $msg * @param string $msg

View File

@ -18,7 +18,7 @@ trait Crud
/** /**
* 查询 * Inquire
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -60,7 +60,7 @@ trait Crud
} }
/** /**
* 添加 * Add to
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
*/ */
@ -70,7 +70,7 @@ trait Crud
$table = $this->model->getTable(); $table = $this->model->getTable();
$allow_column = Util::db()->select("desc `$table`"); $allow_column = Util::db()->select("desc `$table`");
if (!$allow_column) { if (!$allow_column) {
return $this->json(2, '表不存在'); return $this->json(2, 'table does not exist');
} }
$columns = array_column($allow_column, 'Field', 'Field'); $columns = array_column($allow_column, 'Field', 'Field');
foreach ($data as $col => $item) { foreach ($data as $col => $item) {
@ -94,7 +94,7 @@ trait Crud
} }
/** /**
* 更新 * renew
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
*/ */
@ -106,14 +106,14 @@ trait Crud
$table = $this->model->getTable(); $table = $this->model->getTable();
$allow_column = Util::db()->select("desc `$table`"); $allow_column = Util::db()->select("desc `$table`");
if (!$allow_column) { if (!$allow_column) {
return $this->json(2, '表不存在'); return $this->json(2, 'table does not exist');
} }
foreach ($data as $col => $item) { foreach ($data as $col => $item) {
if (is_array($item)) { if (is_array($item)) {
$data[$col] = implode(',', $item); $data[$col] = implode(',', $item);
} }
if ($col === 'password') { if ($col === 'password') {
// 密码为空,则不更新密码 // If the password is empty, the password will not be updated
if ($item == '') { if ($item == '') {
unset($data[$col]); unset($data[$col]);
continue; continue;
@ -126,7 +126,7 @@ trait Crud
} }
/** /**
* 删除 * delete
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
* @throws \Support\Exception\BusinessException * @throws \Support\Exception\BusinessException
@ -140,7 +140,7 @@ trait Crud
} }
/** /**
* 摘要 * Summary
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
* @throws \Support\Exception\BusinessException * @throws \Support\Exception\BusinessException
@ -168,7 +168,7 @@ trait Crud
} }
/** /**
* 按表获取摘要 * Get summary by table
* *
* @param $table * @param $table
* @param $section * @param $section
@ -269,7 +269,7 @@ trait Crud
$allow_column = Util::db()->select("desc `$table`"); $allow_column = Util::db()->select("desc `$table`");
if (!$allow_column) { if (!$allow_column) {
return $this->json(2, '表不存在'); return $this->json(2, 'table does not exist');
} }
$allow_column = array_column($allow_column, 'Field', 'Field'); $allow_column = array_column($allow_column, 'Field', 'Field');
if (!in_array($field, $allow_column)) { if (!in_array($field, $allow_column)) {
@ -317,7 +317,7 @@ trait Crud
} }
/** /**
* 表格树 * table tree
* *
* @param $items * @param $items
* @return \support\Response * @return \support\Response

View File

@ -10,21 +10,21 @@ class IndexController
{ {
/** /**
* 无需登录的方法 * Methods without login
* @var array * @var array
*/ */
protected $noNeedLogin = ['index']; protected $noNeedLogin = ['index'];
/** /**
* 后台主页 * Background Home
* *
* @return \support\Response * @return \support\Response
*/ */
public function index(Request $request) public function index(Request $request)
{ {
if (!$request->queryString()) { if (!$request->queryString()) {
// 检查是否安装了admin // Check if installedadmin
$database_config_file = base_path() . '/plugin/admin/config/database.php'; $database_config_file = base_path() . '/plugin/admin/config/database.php';
clearstatcache(); clearstatcache();
if (!is_file($database_config_file)) { if (!is_file($database_config_file)) {

View File

@ -8,7 +8,7 @@ use plugin\admin\app\model\Admin;
use support\Request; use support\Request;
/** /**
* 管理员设置 * Administrator Settings
*/ */
class AdminController extends Base class AdminController extends Base
{ {
@ -19,12 +19,12 @@ class AdminController extends Base
protected $model = null; protected $model = null;
/** /**
* 增删改查 * Add, delete, modify and check
*/ */
use Crud; use Crud;
/** /**
* 构造函数 * Constructor
*/ */
public function __construct() public function __construct()
{ {
@ -32,7 +32,7 @@ class AdminController extends Base
} }
/** /**
* 删除 * delete
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -43,7 +43,7 @@ class AdminController extends Base
$column = $request->post('column'); $column = $request->post('column');
$value = $request->post('value'); $value = $request->post('value');
if ($value == admin_id()) { if ($value == admin_id()) {
return $this->json(1, '不能删除自己'); return $this->json(1, 'Cannot delete myself');
} }
$this->model->where([$column => $value])->delete(); $this->model->where([$column => $value])->delete();
return $this->json(0); return $this->json(0);

View File

@ -11,7 +11,7 @@ use support\Db;
use support\Request; use support\Request;
/** /**
* 管理员角色设置 * Administrator role settings
*/ */
class AdminRoleController extends Base class AdminRoleController extends Base
{ {
@ -21,12 +21,12 @@ class AdminRoleController extends Base
protected $model = null; protected $model = null;
/** /**
* 增删改查 * Add, delete, modify and check
*/ */
use Crud; use Crud;
/** /**
* 构造函数 * Constructor
*/ */
public function __construct() public function __construct()
{ {
@ -34,7 +34,7 @@ class AdminRoleController extends Base
} }
/** /**
* 更新 * renew
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -47,14 +47,14 @@ class AdminRoleController extends Base
$table = $this->model->getTable(); $table = $this->model->getTable();
$allow_column = Util::db()->select("desc $table"); $allow_column = Util::db()->select("desc $table");
if (!$allow_column) { if (!$allow_column) {
return $this->json(2, '表不存在'); return $this->json(2, 'table does not exist');
} }
$data['rules'] = array_filter(array_unique((array)$data['rules'])); $data['rules'] = array_filter(array_unique((array)$data['rules']));
$item = $this->model->where($column, $value)->first(); $item = $this->model->where($column, $value)->first();
if (!$item) { if (!$item) {
return $this->json(1, '记录不存在'); return $this->json(1, 'Record does not exist');
} }
if ($item->id == 1) { if ($item->id == 1) {
$data['rules'] = '*'; $data['rules'] = '*';
@ -65,7 +65,7 @@ class AdminRoleController extends Base
$data[$col] = implode(',', $item); $data[$col] = implode(',', $item);
} }
if ($col === 'password') { if ($col === 'password') {
// 密码为空,则不更新密码 // If the password is empty, the password will not be updated
if ($item == '') { if ($item == '') {
unset($data[$col]); unset($data[$col]);
continue; continue;
@ -79,7 +79,7 @@ class AdminRoleController extends Base
} }
/** /**
* 删除 * delete
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
* @throws \Support\Exception\BusinessException * @throws \Support\Exception\BusinessException
@ -93,7 +93,7 @@ class AdminRoleController extends Base
return $this->json(0); return $this->json(0);
} }
if ($item->id == 1) { if ($item->id == 1) {
return $this->json(1, '无法删除超级管理员角色'); return $this->json(1, 'Cannot delete super administrator role');
} }
$this->model->where('id', $item->id)->delete(); $this->model->where('id', $item->id)->delete();
return $this->json(0); return $this->json(0);

View File

@ -17,12 +17,12 @@ class AdminRuleController extends Base
protected $model = null; protected $model = null;
/** /**
* 增删改查 * Add, delete, modify and check
*/ */
use Crud; use Crud;
/** /**
* 构造函数 * Constructor
*/ */
public function __construct() public function __construct()
{ {
@ -30,7 +30,7 @@ class AdminRuleController extends Base
} }
/** /**
* 获取权限树 * Get permission tree
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -43,7 +43,7 @@ class AdminRuleController extends Base
} }
/** /**
* 根据类同步规则到数据库 * According to class synchronization rules to database
* *
* @return void * @return void
*/ */
@ -91,7 +91,7 @@ class AdminRuleController extends Base
} }
} }
} }
// 从数据库中删除已经不存在的方法 // Remove a method that no longer exists from the database
$menu_names_to_del = array_diff($methods_in_db, $methods_in_files); $menu_names_to_del = array_diff($methods_in_db, $methods_in_files);
if ($menu_names_to_del) { if ($menu_names_to_del) {
AdminRule::whereIn('name', $menu_names_to_del)->delete(); AdminRule::whereIn('name', $menu_names_to_del)->delete();
@ -99,7 +99,7 @@ class AdminRuleController extends Base
} }
/** /**
* 查询 * Inquire
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -141,7 +141,7 @@ class AdminRuleController extends Base
} }
/** /**
* 添加 * Add to
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
*/ */
@ -151,11 +151,11 @@ class AdminRuleController extends Base
$table = $this->model->getTable(); $table = $this->model->getTable();
$allow_column = Util::db()->select("desc $table"); $allow_column = Util::db()->select("desc $table");
if (!$allow_column) { if (!$allow_column) {
return $this->json(2, '表不存在'); return $this->json(2, 'table does not exist');
} }
$name = $data['name']; $name = $data['name'];
if ($this->model->where('name', $name)->first()) { if ($this->model->where('name', $name)->first()) {
return $this->json(1, "菜单key $name 已经存在"); return $this->json(1, "Menu key $name already exists");
} }
$columns = array_column($allow_column, 'Field', 'Field'); $columns = array_column($allow_column, 'Field', 'Field');
foreach ($data as $col => $item) { foreach ($data as $col => $item) {
@ -178,7 +178,7 @@ class AdminRuleController extends Base
} }
/** /**
* 更新 * renew
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
*/ */
@ -190,11 +190,11 @@ class AdminRuleController extends Base
$table = $this->model->getTable(); $table = $this->model->getTable();
$allow_column = Util::db()->select("desc `$table`"); $allow_column = Util::db()->select("desc `$table`");
if (!$allow_column) { if (!$allow_column) {
return $this->json(2, '表不存在'); return $this->json(2, 'table does not exist');
} }
$row = $this->model->where($column, $value)->first(); $row = $this->model->where($column, $value)->first();
if (!$row) { if (!$row) {
return $this->json(2, '记录不存在'); return $this->json(2, 'Record does not exist');
} }
foreach ($data as $col => $item) { foreach ($data as $col => $item) {
if (is_array($item)) { if (is_array($item)) {
@ -204,7 +204,7 @@ class AdminRuleController extends Base
if (!isset($data['pid'])) { if (!isset($data['pid'])) {
$data['pid'] = 0; $data['pid'] = 0;
} elseif ($data['pid'] == $row['id']) { } elseif ($data['pid'] == $row['id']) {
return $this->json(2, '不能将自己设置为上级菜单'); return $this->json(2, 'Cannot set yourself as parent menu');
} }
$data['path'] = (empty($data['pid']) ? '/' : '') . ltrim($data['path'], '/'); $data['path'] = (empty($data['pid']) ? '/' : '') . ltrim($data['path'], '/');
@ -214,7 +214,7 @@ class AdminRuleController extends Base
} }
/** /**
* 删除 * delete
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
* @throws \Support\Exception\BusinessException * @throws \Support\Exception\BusinessException
@ -225,9 +225,9 @@ class AdminRuleController extends Base
$value = $request->post('value'); $value = $request->post('value');
$item = $this->model->where($column, $value)->first(); $item = $this->model->where($column, $value)->first();
if (!$item) { if (!$item) {
return $this->json(1, '记录不存在'); return $this->json(1, 'Record does not exist');
} }
// 子规则一起删除 // Sub-rules are deleted together
$delete_ids = $children_ids = [$item['id']]; $delete_ids = $children_ids = [$item['id']];
while($children_ids) { while($children_ids) {
$children_ids = $this->model->whereIn('pid', $children_ids)->pluck('id')->toArray(); $children_ids = $this->model->whereIn('pid', $children_ids)->pluck('id')->toArray();
@ -238,7 +238,7 @@ class AdminRuleController extends Base
} }
/** /**
* 一键生成菜单 * One-click menu generation
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -258,7 +258,7 @@ class AdminRuleController extends Base
if ($pid) { if ($pid) {
$parent_menu = AdminRule::find($pid); $parent_menu = AdminRule::find($pid);
if (!$parent_menu) { if (!$parent_menu) {
return $this->json(1, '父菜单不存在'); return $this->json(1, 'Parent menu does not exist');
} }
$path = $parent_menu['path']; $path = $parent_menu['path'];
} }
@ -283,20 +283,20 @@ class AdminRuleController extends Base
$model_file = base_path() . "/plugin/admin/app/model/$model_class.php"; $model_file = base_path() . "/plugin/admin/app/model/$model_class.php";
if (!$overwrite) { if (!$overwrite) {
if (is_file($controller_file)) { if (is_file($controller_file)) {
return $this->json(1, substr($controller_file, strlen(base_path())) . '已经存在'); return $this->json(1, substr($controller_file, strlen(base_path())) . 'already exists');
} }
if (is_file($model_file)) { if (is_file($model_file)) {
return $this->json(1, substr($model_file, strlen(base_path())) . '已经存在'); return $this->json(1, substr($model_file, strlen(base_path())) . 'already exists');
} }
} }
// 创建model // createmodel
$this->createModel($model_class, "plugin\\admin\\app\\model", $model_file, $table_name); $this->createModel($model_class, "plugin\\admin\\app\\model", $model_file, $table_name);
// 创建controller // createcontroller
$this->createController($controller_class, $controller_namespace, $controller_file, $model_class, $name); $this->createController($controller_class, $controller_namespace, $controller_file, $model_class, $name);
// 菜单相关参数 // Menu related parameters
$menu_path = str_replace('_', '', $table_basename); $menu_path = str_replace('_', '', $table_basename);
$suffix = substr($menu_path, -2); $suffix = substr($menu_path, -2);
if ($suffix != 'ss' && $suffix != 'es') { if ($suffix != 'ss' && $suffix != 'es') {
@ -328,7 +328,7 @@ class AdminRuleController extends Base
$rule_ids = array_merge($rule_ids, explode(',', $rule_string)); $rule_ids = array_merge($rule_ids, explode(',', $rule_string));
} }
// 不是超级管理员,则需要给当前管理员这个菜单的权限 // If you are not a super administrator, you need to give the current administrator permission to this menu
if (!in_array('*', $rule_ids) && $roles){ if (!in_array('*', $rule_ids) && $roles){
$role = AdminRole::find(current($roles)); $role = AdminRole::find(current($roles));
if ($role) { if ($role) {
@ -341,7 +341,7 @@ class AdminRuleController extends Base
} }
/** /**
* 创建model * createmodel
* *
* @param $class * @param $class
* @param $namespace * @param $namespace
@ -363,7 +363,7 @@ class AdminRuleController extends Base
foreach (Util::db()->select("select COLUMN_NAME,DATA_TYPE,COLUMN_KEY,COLUMN_COMMENT from INFORMATION_SCHEMA.COLUMNS where table_name = '$table' and table_schema = '$database'") as $item) { foreach (Util::db()->select("select COLUMN_NAME,DATA_TYPE,COLUMN_KEY,COLUMN_COMMENT from INFORMATION_SCHEMA.COLUMNS where table_name = '$table' and table_schema = '$database'") as $item) {
if ($item->COLUMN_KEY === 'PRI') { if ($item->COLUMN_KEY === 'PRI') {
$pk = $item->COLUMN_NAME; $pk = $item->COLUMN_NAME;
$item->COLUMN_COMMENT .= "(主键)"; $item->COLUMN_COMMENT .= "(primary key)";
} }
$type = $this->getType($item->DATA_TYPE); $type = $this->getType($item->DATA_TYPE);
$properties .= " * @property $type \${$item->COLUMN_NAME} {$item->COLUMN_COMMENT}\n"; $properties .= " * @property $type \${$item->COLUMN_NAME} {$item->COLUMN_COMMENT}\n";
@ -416,7 +416,7 @@ EOF;
} }
/** /**
* 创建控制器 * Create Controller
* *
* @param $controller_class * @param $controller_class
* @param $namespace * @param $namespace
@ -444,7 +444,7 @@ use support\Request;
class $controller_class extends Base class $controller_class extends Base
{ {
/** /**
* 开启增删改查 * Enable CRUD
*/ */
use Crud; use Crud;
@ -454,7 +454,7 @@ class $controller_class extends Base
protected \$model = null; protected \$model = null;
/** /**
* 构造函数 * Constructor
* *
* @return void * @return void
*/ */
@ -478,7 +478,7 @@ EOF;
} }
/** /**
* 字段类型到php类型映射 * Field type to php type mapping
* *
* @param string $type * @param string $type
* @return string * @return string

View File

@ -12,18 +12,18 @@ use support\Request;
use support\Response; use support\Response;
/** /**
* 管理员账户 * Administrator Account
*/ */
class AccountController extends Base class AccountController extends Base
{ {
/** /**
* 不需要登录的方法 * Methods that do not require login
* @var string[] * @var string[]
*/ */
public $noNeedLogin = ['login', 'logout', 'captcha']; public $noNeedLogin = ['login', 'logout', 'captcha'];
/** /**
* 不需要鉴权的方法 * Methods that do not require authentication
* @var string[] * @var string[]
*/ */
public $noNeedAuth = ['info', 'getPermCode']; public $noNeedAuth = ['info', 'getPermCode'];
@ -34,7 +34,7 @@ class AccountController extends Base
protected $model = null; protected $model = null;
/** /**
* 构造函数 * Constructor
*/ */
public function __construct() public function __construct()
{ {
@ -42,7 +42,7 @@ class AccountController extends Base
} }
/** /**
* 登录 * Log in
* *
* @param Request $request * @param Request $request
* @return Response * @return Response
@ -51,18 +51,18 @@ class AccountController extends Base
{ {
$captcha = $request->post('captcha'); $captcha = $request->post('captcha');
if (strtolower($captcha) !== session('captcha-login')) { if (strtolower($captcha) !== session('captcha-login')) {
return $this->json(1, '验证码错误'); return $this->json(1, 'Verification code error');
} }
$request->session()->forget('captcha-login'); $request->session()->forget('captcha-login');
$username = $request->post('username', ''); $username = $request->post('username', '');
$password = $request->post('password', ''); $password = $request->post('password', '');
if (!$username) { if (!$username) {
return $this->json(1, '用户名不能为空'); return $this->json(1, 'Username can not be empty');
} }
$this->checkLoginLimit($username); $this->checkLoginLimit($username);
$admin = Admin::where('username', $username)->first(); $admin = Admin::where('username', $username)->first();
if (!$admin || !Util::passwordVerify($password, $admin->password)) { if (!$admin || !Util::passwordVerify($password, $admin->password)) {
return $this->json(1, '账户不存在或密码错误'); return $this->json(1, 'Account does not exist or password is incorrect');
} }
$this->removeLoginLimit($username); $this->removeLoginLimit($username);
$admin = $admin->toArray(); $admin = $admin->toArray();
@ -70,14 +70,14 @@ class AccountController extends Base
unset($admin['password']); unset($admin['password']);
$admin['roles'] = $admin['roles'] ? explode(',', $admin['roles']) : []; $admin['roles'] = $admin['roles'] ? explode(',', $admin['roles']) : [];
$session->set('admin', $admin); $session->set('admin', $admin);
return $this->json(0, '登录成功', [ return $this->json(0, 'login successful', [
'nickname' => $admin['nickname'], 'nickname' => $admin['nickname'],
'token' => $request->sessionId(), 'token' => $request->sessionId(),
]); ]);
} }
/** /**
* 退出 * quit
* *
* @param Request $request * @param Request $request
* @return Response * @return Response
@ -90,7 +90,7 @@ class AccountController extends Base
/** /**
* 获取登录信息 * Get login information
* *
* @param Request $request * @param Request $request
* @return Response * @return Response
@ -116,7 +116,7 @@ class AccountController extends Base
} }
/** /**
* 验证码 * Verification Code
* @param Request $request * @param Request $request
* @param $type * @param $type
* @return Response * @return Response
@ -131,7 +131,7 @@ class AccountController extends Base
} }
/** /**
* 获取权限码(目前没作用) * Get permission code (currently has no effect)
* @return Response * @return Response
*/ */
public function getPermCode() public function getPermCode()
@ -140,7 +140,7 @@ class AccountController extends Base
} }
/** /**
* 更新 * renew
* *
* @param Request $request * @param Request $request
* @return Response * @return Response
@ -175,7 +175,7 @@ class AccountController extends Base
} }
/** /**
* 修改密码 * change Password
* *
* @param Request $request * @param Request $request
* @return Response * @return Response
@ -185,10 +185,10 @@ class AccountController extends Base
$hash = admin('password'); $hash = admin('password');
$password = $request->post('password'); $password = $request->post('password');
if (!$password) { if (!$password) {
return $this->json(2, '密码不能为空'); return $this->json(2, 'password can not be blank');
} }
if (!Util::passwordVerify($request->post('old_password'), $hash)) { if (!Util::passwordVerify($request->post('old_password'), $hash)) {
return $this->json(1, '原始密码不正确'); return $this->json(1, 'Original password is incorrect');
} }
$update_data = [ $update_data = [
'password' => Util::passwordHash($password) 'password' => Util::passwordHash($password)
@ -198,7 +198,7 @@ class AccountController extends Base
} }
/** /**
* 检查登录频率限制 * Check login frequency limit
* *
* @param $username * @param $username
* @return void * @return void
@ -228,13 +228,13 @@ class AccountController extends Base
$limit_info['count']++; $limit_info['count']++;
file_put_contents($limit_file, json_encode($limit_info)); file_put_contents($limit_file, json_encode($limit_info));
if ($limit_info['count'] >= 5) { if ($limit_info['count'] >= 5) {
throw new BusinessException('登录失败次数过多请5分钟后再试'); throw new BusinessException('Too many login failures, please try again in 5 minutes');
} }
} }
/** /**
* 解除登录限制 * Remove login restrictions
* *
* @param $username * @param $username
* @return void * @return void

View File

@ -13,18 +13,18 @@ use support\Response;
use support\Db; use support\Db;
/** /**
* 安装 * Install
*/ */
class InstallController extends Base class InstallController extends Base
{ {
/** /**
* 不需要登录的方法 * Methods that do not require login
* @var string[] * @var string[]
*/ */
public $noNeedLogin = ['step1', 'step2']; public $noNeedLogin = ['step1', 'step2'];
/** /**
* 设置数据库 * Setup Database
* *
* @param Request $request * @param Request $request
* @return Response * @return Response
@ -35,11 +35,11 @@ class InstallController extends Base
$database_config_file = base_path() . '/plugin/admin/config/database.php'; $database_config_file = base_path() . '/plugin/admin/config/database.php';
clearstatcache(); clearstatcache();
if (is_file($database_config_file)) { if (is_file($database_config_file)) {
return $this->json(1, '管理后台已经安装!如需重新安装,请删除该插件数据库配置文件并重启'); return $this->json(1, 'The management background has been installed! If you need to reinstall, please delete the plugin database configuration file and restart');
} }
if (!class_exists(CaptchaBuilder::class) || !class_exists(Manager::class)) { if (!class_exists(CaptchaBuilder::class) || !class_exists(Manager::class)) {
return $this->json(1, '请先restart重启webman后再进行此页面的设置'); return $this->json(1, 'Please restart webman before setting this page');
} }
$user = $request->post('user'); $user = $request->post('user');
@ -60,13 +60,13 @@ class InstallController extends Base
$tables = $smt->fetchAll(); $tables = $smt->fetchAll();
} catch (\Throwable $e) { } catch (\Throwable $e) {
if (stripos($e, 'Access denied for user')) { if (stripos($e, 'Access denied for user')) {
return $this->json(1, '数据库用户名或密码错误'); return $this->json(1, 'Incorrect database username or password');
} }
if (stripos($e, 'Connection refused')) { if (stripos($e, 'Connection refused')) {
return $this->json(1, 'Connection refused. 请确认数据库IP端口是否正确数据库已经启动'); return $this->json(1, 'Connection refused. Please confirm whether the database IP port is correct and the database has been started');
} }
if (stripos($e, 'timed out')) { if (stripos($e, 'timed out')) {
return $this->json(1, '数据库连接超时请确认数据库IP端口是否正确安全组及防火墙已经放行端口'); return $this->json(1, 'The database connection timed out, please confirm whether the database IP port is correct, the security group and firewall have released the port');
} }
throw $e; throw $e;
} }
@ -86,13 +86,13 @@ class InstallController extends Base
} }
$tables_conflict = array_intersect($tables_to_install, $tables_exist); $tables_conflict = array_intersect($tables_to_install, $tables_exist);
if ($tables_conflict) { if ($tables_conflict) {
return $this->json(1, '以下表' . implode(',', $tables_conflict) . '已经存在,如需覆盖请选择强制覆盖'); return $this->json(1, 'The following table' . implode(',', $tables_conflict) . ' already exists, if you want to overwrite, please select Force Overwrite');
} }
} }
$sql_file = base_path() . '/plugin/admin/webman-admin.sql'; $sql_file = base_path() . '/plugin/admin/webman-admin.sql';
if (!is_file($sql_file)) { if (!is_file($sql_file)) {
return $this->json(1, '数据库SQL文件不存在'); return $this->json(1, 'Database SQL file does not exist');
} }
$sql_query = file_get_contents($sql_file); $sql_query = file_get_contents($sql_file);
@ -102,7 +102,7 @@ class InstallController extends Base
$db->exec($sql); $db->exec($sql);
} }
// 导入菜单 // Import menu
$menus = include base_path() . '/plugin/admin/config/menu.php'; $menus = include base_path() . '/plugin/admin/config/menu.php';
$this->import($menus, $db); $this->import($menus, $db);
@ -130,7 +130,7 @@ EOF;
file_put_contents($database_config_file, $config_content); file_put_contents($database_config_file, $config_content);
// 尝试reload // tryreload
if (function_exists('posix_kill')) { if (function_exists('posix_kill')) {
set_error_handler(function () {}); set_error_handler(function () {});
posix_kill(posix_getppid(), SIGUSR1); posix_kill(posix_getppid(), SIGUSR1);
@ -141,7 +141,7 @@ EOF;
} }
/** /**
* 设置管理员 * Setup Administrator
* *
* @param Request $request * @param Request $request
* @return Response * @return Response
@ -153,24 +153,24 @@ EOF;
$password = $request->post('password'); $password = $request->post('password');
$password2 = $request->post('password2'); $password2 = $request->post('password2');
if ($password != $password2) { if ($password != $password2) {
return $this->json(1, '两次密码不一致'); return $this->json(1, 'The two passwords do not match');
} }
if (!is_file($config_file = base_path() . '/plugin/admin/config/database.php')) { if (!is_file($config_file = base_path() . '/plugin/admin/config/database.php')) {
return $this->json(1, '请先完成第一步数据库配置'); return $this->json(1, 'Please complete the first step of database configuration');
} }
$config = include $config_file; $config = include $config_file;
$connection = $config['connections']['mysql']; $connection = $config['connections']['mysql'];
$pdo = $this->getPdo($connection['host'], $connection['username'], $connection['password'], $connection['port'], $connection['database']); $pdo = $this->getPdo($connection['host'], $connection['username'], $connection['password'], $connection['port'], $connection['database']);
$smt = $pdo->query('select * from wa_admins limit 1'); $smt = $pdo->query('select * from wa_admins limit 1');
if ($smt->fetchAll()) { if ($smt->fetchAll()) {
return $this->json(1, '后台已经安装完毕,无法通过此页面创建管理员'); return $this->json(1, 'The background has been installed, the administrator cannot be created through this page');
} }
$smt = $pdo->prepare("insert into `wa_admins` (`username`, `password`, `nickname`, `roles`, `created_at`, `updated_at`) values (:username, :password, :nickname, :roles, :created_at, :updated_at)"); $smt = $pdo->prepare("insert into `wa_admins` (`username`, `password`, `nickname`, `roles`, `created_at`, `updated_at`) values (:username, :password, :nickname, :roles, :created_at, :updated_at)");
$time = date('Y-m-d H:i:s'); $time = date('Y-m-d H:i:s');
$data = [ $data = [
'username' => $username, 'username' => $username,
'password' => Util::passwordHash($password), 'password' => Util::passwordHash($password),
'nickname' => '超级管理员', 'nickname' => 'Super Admin',
'roles' => '1', 'roles' => '1',
'created_at' => $time, 'created_at' => $time,
'updated_at' => $time 'updated_at' => $time
@ -183,7 +183,7 @@ EOF;
} }
/** /**
* 添加菜单 * Add menu
* *
* @param array $menu * @param array $menu
* @param \PDO $pdo * @param \PDO $pdo
@ -214,7 +214,7 @@ EOF;
} }
/** /**
* 导入菜单 * Import menu
* *
* @param array $menu_tree * @param array $menu_tree
* @param \PDO $pdo * @param \PDO $pdo
@ -259,7 +259,7 @@ EOF;
} }
/** /**
* 去除sql文件中的注释 * Remove comments in sql file
* *
* @param $sql * @param $sql
* @return string * @return string
@ -318,7 +318,7 @@ EOF;
} }
/** /**
* 获取pdo连接 * Get pdo connection
* *
* @param $host * @param $host
* @param $username * @param $username

View File

@ -11,7 +11,7 @@ use function admin;
class MenuController extends Base class MenuController extends Base
{ {
/** /**
* 不需要权限的方法 * methods that don't require permissions
* *
* @var string[] * @var string[]
*/ */
@ -23,7 +23,7 @@ class MenuController extends Base
protected $model = null; protected $model = null;
/** /**
* 构造函数 * Constructor
*/ */
public function __construct() public function __construct()
{ {
@ -31,7 +31,7 @@ class MenuController extends Base
} }
/** /**
* 获取菜单 * Get menu
* *
* @return \support\Response * @return \support\Response
*/ */
@ -65,7 +65,7 @@ class MenuController extends Base
} }
} }
// 超级管理员权限为 * // Super administrator privilege is *
if (!in_array('*', $rules)) { if (!in_array('*', $rules)) {
$this->removeUncontain($formatted_items, 'id', $rules); $this->removeUncontain($formatted_items, 'id', $rules);
} }
@ -78,7 +78,7 @@ class MenuController extends Base
} }
/** /**
* 获取菜单树 * Get menu tree
* *
* @return \support\Response * @return \support\Response
*/ */
@ -112,7 +112,7 @@ class MenuController extends Base
} }
} }
// 超级管理员权限为 * // Super administrator privilege is *
if (!in_array('*', $rules)) { if (!in_array('*', $rules)) {
$this->removeUncontain($formatted_items, 'id', $rules); $this->removeUncontain($formatted_items, 'id', $rules);
} }
@ -127,7 +127,7 @@ class MenuController extends Base
} }
/** /**
* 移除不包含某些数据的数组 * Remove arrays that do not contain some data
* *
* @param $array * @param $array
* @param $key * @param $key
@ -152,7 +152,7 @@ class MenuController extends Base
} }
/** /**
* 判断数组是否包含某些数据 * Determine whether the array contains some data
* *
* @param $array * @param $array
* @param $key * @param $key
@ -179,7 +179,7 @@ class MenuController extends Base
} }
/** /**
* 递归删除某些key * recursively delete somekey
* *
* @param $array * @param $array
* @param $keys * @param $keys
@ -199,7 +199,7 @@ class MenuController extends Base
} }
/** /**
* 获取权限规则 * Get permission rules
* @return array * @return array
*/ */
protected function getRulesAndItems() protected function getRulesAndItems()
@ -219,7 +219,7 @@ class MenuController extends Base
} }
/** /**
* 递归重建数组下标 * Recursively rebuild array subscripts
* *
* @return void * @return void
*/ */

View File

@ -9,13 +9,13 @@ use function base_path;
use function json; use function json;
/** /**
* 上传 * upload
*/ */
class UploadController extends Base class UploadController extends Base
{ {
/** /**
* 上传文件 * upload files
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -24,7 +24,7 @@ class UploadController extends Base
{ {
$file = current($request->file()); $file = current($request->file());
if (!$file || !$file->isValid()) { if (!$file || !$file->isValid()) {
return $this->json(1, '未找到文件'); return $this->json(1, 'File not found');
} }
$img_exts = [ $img_exts = [
'jpg', 'jpg',
@ -39,11 +39,11 @@ class UploadController extends Base
if ($data['code']) { if ($data['code']) {
return $this->json($data['code'], $data['message']); return $this->json($data['code'], $data['message']);
} }
return json(['code' => 0, 'message' => '上传成功', 'url' => $data['data']['src']]); return json(['code' => 0, 'message' => 'Upload successful', 'url' => $data['data']['src']]);
} }
/** /**
* 上传头像 * Upload Avatar
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -55,7 +55,7 @@ class UploadController extends Base
if ($file && $file->isValid()) { if ($file && $file->isValid()) {
$ext = strtolower($file->getUploadExtension()); $ext = strtolower($file->getUploadExtension());
if (!in_array($ext, ['jpg', 'jpeg', 'gif', 'png'])) { if (!in_array($ext, ['jpg', 'jpeg', 'gif', 'png'])) {
return json(['code' => 2, 'msg' => '仅支持 jpg jpeg gif png格式']); return json(['code' => 2, 'msg' => 'Only support jpg jpeg gif png format']);
} }
$image = Image::make($file); $image = Image::make($file);
$width = $image->width(); $width = $image->width();
@ -87,7 +87,7 @@ class UploadController extends Base
return json([ return json([
'code' => 0, 'code' => 0,
'message' => '上传成功', 'message' => 'Upload successful',
'url' => "/app/admin/$relative_path/$name.$ext" 'url' => "/app/admin/$relative_path/$name.$ext"
]); ]);
} }
@ -95,7 +95,7 @@ class UploadController extends Base
} }
/** /**
* 上传图片 * upload image
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -122,18 +122,18 @@ class UploadController extends Base
unlink($realpath); unlink($realpath);
return json( [ return json( [
'code' => 500, 'code' => 500,
'message' => '处理图片发生错误' 'message' => 'Error processing image'
]); ]);
} }
return json( [ return json( [
'code' => 0, 'code' => 0,
'message' => '上传成功', 'message' => 'Upload successful',
'url' => $data['data']['src'] 'url' => $data['data']['src']
]); ]);
} }
/** /**
* 获取上传数据 * Get upload data
* *
* @param Request $request * @param Request $request
* @param $relative_dir * @param $relative_dir
@ -145,7 +145,7 @@ class UploadController extends Base
$relative_dir = ltrim($relative_dir, '/'); $relative_dir = ltrim($relative_dir, '/');
$file = current($request->file()); $file = current($request->file());
if (!$file || !$file->isValid()) { if (!$file || !$file->isValid()) {
return ['code' => 400, 'message' => '未找到上传文件']; return ['code' => 400, 'message' => 'Upload file not found'];
} }
$base_dir = base_path() . '/plugin/admin/public/'; $base_dir = base_path() . '/plugin/admin/public/';
@ -157,7 +157,7 @@ class UploadController extends Base
$ext = strtolower($file->getUploadExtension()); $ext = strtolower($file->getUploadExtension());
$ext_forbidden_map = ['php', 'php3', 'php5', 'css', 'js', 'html', 'htm', 'asp', 'jsp']; $ext_forbidden_map = ['php', 'php3', 'php5', 'css', 'js', 'html', 'htm', 'asp', 'jsp'];
if (in_array($ext, $ext_forbidden_map)) { if (in_array($ext, $ext_forbidden_map)) {
return ['code' => 400, 'message' => '不支持该格式的文件上传']; return ['code' => 400, 'message' => 'File upload in this format is not supported'];
} }
$relative_path = $relative_dir . '/' . bin2hex(pack('Nn',time(), random_int(1, 65535))) . ".$ext"; $relative_path = $relative_dir . '/' . bin2hex(pack('Nn',time(), random_int(1, 65535))) . ".$ext";
@ -167,7 +167,7 @@ class UploadController extends Base
$file->move($full_path); $file->move($full_path);
return [ return [
'code' => 0, 'code' => 0,
'msg' => '上传成功', 'msg' => 'Upload successful',
'data' => [ 'data' => [
'src' => "/app/admin/$relative_path", 'src' => "/app/admin/$relative_path",
'name' => $file_name, 'name' => $file_name,
@ -178,7 +178,7 @@ class UploadController extends Base
} }
/** /**
* 格式化文件大小 * Format file size
* *
* @param $file_size * @param $file_size
* @return string * @return string

View File

@ -13,13 +13,13 @@ use Support\Request;
class TableController extends Base class TableController extends Base
{ {
/** /**
* 不需要鉴权的方法 * Methods that do not require authentication
* @var string[] * @var string[]
*/ */
public $noNeedAuth = ['types']; public $noNeedAuth = ['types'];
/** /**
* 查询表 * Lookup table
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -51,7 +51,7 @@ class TableController extends Base
} }
/** /**
* 创建表 * Create table
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -70,7 +70,7 @@ class TableController extends Base
throw new BusinessException("请为{$column['field']}选择类型"); throw new BusinessException("请为{$column['field']}选择类型");
} }
if (!isset($type_method_map[$column['type']])) { if (!isset($type_method_map[$column['type']])) {
throw new BusinessException("不支持的类型{$column['type']}"); throw new BusinessException("unsupported type{$column['type']}");
} }
$this->createColumn($column, $table); $this->createColumn($column, $table);
} }
@ -78,10 +78,10 @@ class TableController extends Base
$table->collation = 'utf8mb4_general_ci'; $table->collation = 'utf8mb4_general_ci';
$table->engine = 'InnoDB'; $table->engine = 'InnoDB';
}); });
// @todo 防注入 // @todo Anti-injection
Util::db()->statement("ALTER TABLE `$table_name` COMMENT '$table_comment'"); Util::db()->statement("ALTER TABLE `$table_name` COMMENT '$table_comment'");
// 索引 // index
Util::schema()->table($table_name, function (Blueprint $table) use ($keys) { Util::schema()->table($table_name, function (Blueprint $table) use ($keys) {
foreach ($keys as $key) { foreach ($keys as $key) {
$name = $key['name']; $name = $key['name'];
@ -106,7 +106,7 @@ class TableController extends Base
} }
/** /**
* 修改表 * Modify table
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -120,7 +120,7 @@ class TableController extends Base
$table_comment = $data['table']['comment']; $table_comment = $data['table']['comment'];
$columns = $data['columns']; $columns = $data['columns'];
$keys = $data['keys'] ?? []; $keys = $data['keys'] ?? [];
// 改表名 // Rename table
if ($table_name != $old_table_name) { if ($table_name != $old_table_name) {
Util::checkTableName($table_name); Util::checkTableName($table_name);
Util::schema()->rename($old_table_name, $table_name); Util::schema()->rename($old_table_name, $table_name);
@ -130,17 +130,17 @@ class TableController extends Base
$type_method_map = Util::methodControlMap(); $type_method_map = Util::methodControlMap();
foreach ($columns as $column) { foreach ($columns as $column) {
if (!isset($type_method_map[$column['type']])) { if (!isset($type_method_map[$column['type']])) {
throw new BusinessException("不支持的类型{$column['type']}"); throw new BusinessException("unsupported type{$column['type']}");
} }
$field = $column['field']; $field = $column['field'];
// 重命名的字段 mysql8才支持 // Renamed fields are only supported by mysql8
if (isset($column['old_field']) && $column['old_field'] !== $field) { if (isset($column['old_field']) && $column['old_field'] !== $field) {
//Util::db()->statement("ALTER TABLE $table_name RENAME COLUMN {$column['old_field']} to $field"); //Util::db()->statement("ALTER TABLE $table_name RENAME COLUMN {$column['old_field']} to $field");
} }
$old_column = $old_columns[$field] ?? []; $old_column = $old_columns[$field] ?? [];
// 类型更改 // Type change
foreach ($old_column as $key => $value) { foreach ($old_column as $key => $value) {
if (isset($column[$key]) && $column[$key] != $value) { if (isset($column[$key]) && $column[$key] != $value) {
$this->modifyColumn($column, $table_name); $this->modifyColumn($column, $table_name);
@ -150,7 +150,7 @@ class TableController extends Base
} }
$table = $this->getSchema($table_name, 'table'); $table = $this->getSchema($table_name, 'table');
// @todo $table_comment 防止SQL注入 // @todo $table_comment Prevent SQL Injection
if ($table_comment !== $table['comment']) { if ($table_comment !== $table['comment']) {
Util::db()->statement("ALTER TABLE `$table_name` COMMENT '$table_comment'"); Util::db()->statement("ALTER TABLE `$table_name` COMMENT '$table_comment'");
} }
@ -159,12 +159,12 @@ class TableController extends Base
Util::schema()->table($table_name, function (Blueprint $table) use ($columns, $old_columns, $keys, $table_name) { Util::schema()->table($table_name, function (Blueprint $table) use ($columns, $old_columns, $keys, $table_name) {
foreach ($columns as $column) { foreach ($columns as $column) {
$field = $column['field']; $field = $column['field'];
// 新字段 // new field
if (!isset($old_columns[$field])) { if (!isset($old_columns[$field])) {
$this->createColumn($column, $table); $this->createColumn($column, $table);
} }
} }
// 更新索引名字 // Update index name
foreach ($keys as $key) { foreach ($keys as $key) {
if (!empty($key['old_name']) && $key['old_name'] !== $key['name']) { if (!empty($key['old_name']) && $key['old_name'] !== $key['name']) {
$table->renameIndex($key['old_name'], $key['name']); $table->renameIndex($key['old_name'], $key['name']);
@ -172,13 +172,13 @@ class TableController extends Base
} }
}); });
// 找到删除的字段 // Found deleted field
$old_columns = $this->getSchema($table_name, 'columns'); $old_columns = $this->getSchema($table_name, 'columns');
$exists_column_names = array_column($columns, 'field', 'field'); $exists_column_names = array_column($columns, 'field', 'field');
$old_columns_names = array_column($old_columns, 'field'); $old_columns_names = array_column($old_columns, 'field');
$drop_column_names = array_diff($old_columns_names, $exists_column_names); $drop_column_names = array_diff($old_columns_names, $exists_column_names);
foreach ($drop_column_names as $drop_column_name) { foreach ($drop_column_names as $drop_column_name) {
//$table->dropColumn($drop_column_name); 无法使用 //$table->dropColumn($drop_column_name); Not available
Util::db()->statement("ALTER TABLE $table_name DROP COLUMN $drop_column_name"); Util::db()->statement("ALTER TABLE $table_name DROP COLUMN $drop_column_name");
} }
@ -187,13 +187,13 @@ class TableController extends Base
foreach ($keys as $key) { foreach ($keys as $key) {
$key_name = $key['name']; $key_name = $key['name'];
$old_key = $old_keys[$key_name] ?? []; $old_key = $old_keys[$key_name] ?? [];
// 如果索引有变动,则删除索引,重新建立索引 // If the index changes, delete the index and rebuild the index
if ($old_key && ($key['type'] != $old_key['type'] || $key['columns'] != $old_key['columns'])) { if ($old_key && ($key['type'] != $old_key['type'] || $key['columns'] != $old_key['columns'])) {
$old_key = []; $old_key = [];
unset($old_keys[$key_name]); unset($old_keys[$key_name]);
$table->dropIndex($key_name); $table->dropIndex($key_name);
} }
// 重新建立索引 // Rebuild Index
if (!$old_key) { if (!$old_key) {
$name = $key['name']; $name = $key['name'];
$columns = $key['columns']; $columns = $key['columns'];
@ -206,7 +206,7 @@ class TableController extends Base
} }
} }
// 找到删除的索引 // Found deleted index
$exists_key_names = array_column($keys, 'name', 'name'); $exists_key_names = array_column($keys, 'name', 'name');
$old_keys_names = array_column($old_keys, 'name'); $old_keys_names = array_column($old_keys, 'name');
$drop_keys_names = array_diff($old_keys_names, $exists_key_names); $drop_keys_names = array_diff($old_keys_names, $exists_key_names);
@ -227,7 +227,7 @@ class TableController extends Base
} }
/** /**
* 查询记录 * Search record
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -242,11 +242,11 @@ class TableController extends Base
$page_size = $request->get('pageSize', $format === 'tree' ? 1000 : 10); $page_size = $request->get('pageSize', $format === 'tree' ? 1000 : 10);
if (!preg_match('/[a-zA-Z_0-9]+/', $table)) { if (!preg_match('/[a-zA-Z_0-9]+/', $table)) {
return $this->json(1, '表不存在'); return $this->json(1, 'table does not exist');
} }
$allow_column = Util::db()->select("desc $table"); $allow_column = Util::db()->select("desc $table");
if (!$allow_column) { if (!$allow_column) {
return $this->json(2, '表不存在'); return $this->json(2, 'table does not exist');
} }
$allow_column = array_column($allow_column, 'Field', 'Field'); $allow_column = array_column($allow_column, 'Field', 'Field');
if (!in_array($field, $allow_column)) { if (!in_array($field, $allow_column)) {
@ -298,7 +298,7 @@ class TableController extends Base
} }
/** /**
* 插入记录 * insert record
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -329,7 +329,7 @@ class TableController extends Base
} }
/** /**
* 更新记录 * update record
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -347,7 +347,7 @@ class TableController extends Base
$data[$col] = implode(',', $item); $data[$col] = implode(',', $item);
} }
if ($col === 'password') { if ($col === 'password') {
// 密码为空,则不更新密码 // If the password is empty, the password will not be updated
if ($item == '') { if ($item == '') {
unset($data[$col]); unset($data[$col]);
continue; continue;
@ -366,7 +366,7 @@ class TableController extends Base
} }
/** /**
* 删除记录 * Delete Record
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -383,7 +383,7 @@ class TableController extends Base
} }
/** /**
* 表摘要 * Table Summary
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -412,7 +412,7 @@ class TableController extends Base
} }
/** /**
* 获取摘要 * Get Summary
* *
* @param $table * @param $table
* @param $section * @param $section
@ -478,7 +478,7 @@ class TableController extends Base
} }
/** /**
* 获取字段长度 * Get field length
* *
* @param $schema * @param $schema
* @return string * @return string
@ -504,7 +504,7 @@ class TableController extends Base
} }
/** /**
* 删除表 * delete table
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -517,16 +517,16 @@ class TableController extends Base
} }
$table_not_allow_drop = ['wa_admins', 'wa_users', 'wa_options', 'wa_admin_roles', 'wa_admin_rules']; $table_not_allow_drop = ['wa_admins', 'wa_users', 'wa_options', 'wa_admin_roles', 'wa_admin_rules'];
if (in_array($table_name, $table_not_allow_drop)) { if (in_array($table_name, $table_not_allow_drop)) {
return $this->json(400, "$table_name 不允许删除"); return $this->json(400, "$table_name Delete not allowed");
} }
Util::schema()->drop($table_name); Util::schema()->drop($table_name);
// 删除schema // deleteschema
Util::db()->table('wa_options')->where('name', "table_form_schema_$table_name")->delete(); Util::db()->table('wa_options')->where('name', "table_form_schema_$table_name")->delete();
return $this->json(0, 'ok'); return $this->json(0, 'ok');
} }
/** /**
* 创建字段 * Create Field
* *
* @param $column * @param $column
* @param Blueprint $table * @param Blueprint $table
@ -537,7 +537,7 @@ class TableController extends Base
$method = $column['type']; $method = $column['type'];
$args = [$column['field']]; $args = [$column['field']];
if (stripos($method, 'int') !== false) { if (stripos($method, 'int') !== false) {
// auto_increment 会自动成为主键 // auto_increment will automatically become the primary key
if ($column['auto_increment']) { if ($column['auto_increment']) {
$column['nullable'] = false; $column['nullable'] = false;
$column['default'] = ''; $column['default'] = '';
@ -582,7 +582,7 @@ class TableController extends Base
} }
/** /**
* 更改字段 * Change Field
* *
* @param $column * @param $column
* @param Blueprint $table * @param Blueprint $table
@ -598,7 +598,7 @@ class TableController extends Base
$auto_increment = $column['auto_increment']; $auto_increment = $column['auto_increment'];
$length = (int)$column['length']; $length = (int)$column['length'];
$primary_key = $column['primary_key']; $primary_key = $column['primary_key'];
// @todo 防止SQL注入 // @todo Prevent SQL Injection
if (isset($column['old_field']) && $column['old_field'] !== $field) { if (isset($column['old_field']) && $column['old_field'] !== $field) {
$sql = "ALTER TABLE $table CHANGE COLUMN {$column['old_field']} $field "; $sql = "ALTER TABLE $table CHANGE COLUMN {$column['old_field']} $field ";
} else { } else {
@ -630,7 +630,7 @@ class TableController extends Base
$sql .= $length ? "$method($length) " : "$method "; $sql .= $length ? "$method($length) " : "$method ";
break; break;
case 'enum': case 'enum':
// @todo 防止SQL注入 // @todo Prevent SQL Injection
$args = array_map('trim', explode(',', $column['length'])); $args = array_map('trim', explode(',', $column['length']));
$sql .= "enum('" . implode("','", $args) . "') "; $sql .= "enum('" . implode("','", $args) . "') ";
break; break;
@ -667,7 +667,7 @@ class TableController extends Base
} }
/** /**
* 字段类型列表 * Field Type List
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -679,7 +679,7 @@ class TableController extends Base
} }
/** /**
* 获取在options对用的name * Get used in optionsname
* *
* @param $table_name * @param $table_name
* @return string * @return string
@ -690,7 +690,7 @@ class TableController extends Base
} }
/** /**
* 更新表的form schema信息 * Update table's form schema information
* *
* @param $table_name * @param $table_name
* @param $data * @param $data

View File

@ -17,7 +17,7 @@ class AppController extends Base
protected $noNeedAuth = ['schema', 'captcha']; protected $noNeedAuth = ['schema', 'captcha'];
/** /**
* 列表 * list
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -42,7 +42,7 @@ class AppController extends Base
$msg = "/api/app/list return $content"; $msg = "/api/app/list return $content";
echo "msg\r\n"; echo "msg\r\n";
Log::error($msg); Log::error($msg);
return $this->json(1, '获取数据出错'); return $this->json(1, 'Error getting data');
} }
$disabled = is_phar(); $disabled = is_phar();
foreach ($data['result']['items'] as $key => $item) { foreach ($data['result']['items'] as $key => $item) {
@ -54,7 +54,7 @@ class AppController extends Base
} }
/** /**
* 摘要 * Summary
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -69,7 +69,7 @@ class AppController extends Base
} }
/** /**
* 安装 * Install
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -82,27 +82,27 @@ class AppController extends Base
$installed_version = $this->getPluginVersion($name); $installed_version = $this->getPluginVersion($name);
$host = $request->host(true); $host = $request->host(true);
if (!$name || !$version) { if (!$name || !$version) {
return $this->json(1, '缺少参数'); return $this->json(1, 'Missing parameters');
} }
$user = session('app-plugin-user'); $user = session('app-plugin-user');
if (!$user) { if (!$user) {
return $this->json(0, '请登录', [ return $this->json(0, 'please sign in', [
'code' => 401, 'code' => 401,
'message' => '请登录' 'message' => 'please sign in'
]); ]);
} }
// 获取下载zip文件url // Get download zip fileurl
$data = $this->getDownloadUrl($name, $user['uid'], $host, $version); $data = $this->getDownloadUrl($name, $user['uid'], $host, $version);
if ($data['code'] == -1) { if ($data['code'] == -1) {
return $this->json(0, '请登录', [ return $this->json(0, 'please sign in', [
'code' => 401, 'code' => 401,
'message' => '请登录' 'message' => 'please sign in'
]); ]);
} }
// 下载zip文件 // download zip file
$base_path = base_path() . "/plugin/$name"; $base_path = base_path() . "/plugin/$name";
$zip_file = "$base_path.zip"; $zip_file = "$base_path.zip";
$extract_to = base_path() . '/plugin/'; $extract_to = base_path() . '/plugin/';
@ -112,14 +112,14 @@ class AppController extends Base
if (!$has_zip_archive) { if (!$has_zip_archive) {
$cmd = $this->getUnzipCmd($zip_file, $extract_to); $cmd = $this->getUnzipCmd($zip_file, $extract_to);
if (!$cmd) { if (!$cmd) {
throw new BusinessException('请给php安装zip模块或者给系统安装unzip命令'); throw new BusinessException('Please install the zip module for php or install the unzip command for the system');
} }
if (!function_exists('proc_open')) { if (!function_exists('proc_open')) {
throw new BusinessException('请解除proc_open函数的禁用或者给php安装zip模块'); throw new BusinessException('Please unblock the proc_open function or install the zip module for php');
} }
} }
// 解压zip到plugin目录 // Extract the zip to the plugin directory
if ($has_zip_archive) { if ($has_zip_archive) {
$zip = new \ZipArchive; $zip = new \ZipArchive;
$zip->open($zip_file, \ZIPARCHIVE::CHECKCONS); $zip->open($zip_file, \ZIPARCHIVE::CHECKCONS);
@ -128,7 +128,7 @@ class AppController extends Base
$context = null; $context = null;
$install_class = "\\plugin\\$name\\api\\Install"; $install_class = "\\plugin\\$name\\api\\Install";
if ($installed_version) { if ($installed_version) {
// 执行beforeUpdate // implementbeforeUpdate
if (class_exists($install_class) && method_exists($install_class, 'beforeUpdate')) { if (class_exists($install_class) && method_exists($install_class, 'beforeUpdate')) {
$context = call_user_func([$install_class, 'beforeUpdate'], $installed_version, $version); $context = call_user_func([$install_class, 'beforeUpdate'], $installed_version, $version);
} }
@ -144,12 +144,12 @@ class AppController extends Base
unlink($zip_file); unlink($zip_file);
if ($installed_version) { if ($installed_version) {
// 执行update更新 // Execute update update
if (class_exists($install_class) && method_exists($install_class, 'update')) { if (class_exists($install_class) && method_exists($install_class, 'update')) {
call_user_func([$install_class, 'update'], $installed_version, $version, $context); call_user_func([$install_class, 'update'], $installed_version, $version, $context);
} }
} else { } else {
// 执行install安装 // Execute install
if (class_exists($install_class) && method_exists($install_class, 'install')) { if (class_exists($install_class) && method_exists($install_class, 'install')) {
call_user_func([$install_class, 'install'], $version); call_user_func([$install_class, 'install'], $version);
} }
@ -161,7 +161,7 @@ class AppController extends Base
} }
/** /**
* 卸载 * Uninstall
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -171,23 +171,23 @@ class AppController extends Base
$name = $request->post('name'); $name = $request->post('name');
$version = $request->post('version'); $version = $request->post('version');
if (!$name || !preg_match('/^[a-zA-Z0-9_]+$/', $name)) { if (!$name || !preg_match('/^[a-zA-Z0-9_]+$/', $name)) {
return $this->json(1, '参数错误'); return $this->json(1, 'Parameter error');
} }
// 获得插件路径 // Get plugin path
clearstatcache(); clearstatcache();
$path = get_realpath(base_path() . "/plugin/$name"); $path = get_realpath(base_path() . "/plugin/$name");
if (!$path || !is_dir($path)) { if (!$path || !is_dir($path)) {
return $this->json(1, '已经删除'); return $this->json(1, 'deleted');
} }
// 执行uninstall卸载 // Execute uninstall
$install_class = "\\plugin\\$name\\api\\Install"; $install_class = "\\plugin\\$name\\api\\Install";
if (class_exists($install_class) && method_exists($install_class, 'uninstall')) { if (class_exists($install_class) && method_exists($install_class, 'uninstall')) {
call_user_func([$install_class, 'uninstall'], $version); call_user_func([$install_class, 'uninstall'], $version);
} }
// 删除目录 // delete directory
clearstatcache(); clearstatcache();
if (is_dir($path)) { if (is_dir($path)) {
$this->rmDir($path); $this->rmDir($path);
@ -200,7 +200,7 @@ class AppController extends Base
} }
/** /**
* 登录验证码 * Login verification code
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -219,7 +219,7 @@ class AppController extends Base
} }
/** /**
* 登录 * Log in
* *
* @param Request $request * @param Request $request
* @return \support\Response * @return \support\Response
@ -241,7 +241,7 @@ class AppController extends Base
$msg = "/api/user/login return $content"; $msg = "/api/user/login return $content";
echo "msg\r\n"; echo "msg\r\n";
Log::error($msg); Log::error($msg);
return $this->json(1, '发生错误'); return $this->json(1, 'An error occurred');
} }
if ($data['code'] != 0) { if ($data['code'] != 0) {
return $this->json($data['code'], $data['msg']); return $this->json($data['code'], $data['msg']);
@ -253,7 +253,7 @@ class AppController extends Base
} }
/** /**
* 获取zip下载url * Get zip downloadurl
* *
* @param $name * @param $name
* @param $uid * @param $uid
@ -281,19 +281,19 @@ class AppController extends Base
if (!$data) { if (!$data) {
$msg = "/api/app/download return $content"; $msg = "/api/app/download return $content";
Log::error($msg); Log::error($msg);
throw new BusinessException('访问官方接口失败'); throw new BusinessException('Failed to access official interface');
} }
if ($data['code'] && $data['code'] != -1) { if ($data['code'] && $data['code'] != -1) {
throw new BusinessException($data['msg']); throw new BusinessException($data['msg']);
} }
if ($data['code'] == 0 && !isset($data['result']['url'])) { if ($data['code'] == 0 && !isset($data['result']['url'])) {
throw new BusinessException('官方接口返回数据错误'); throw new BusinessException('The official interface returned data error');
} }
return $data; return $data;
} }
/** /**
* 下载zip * downloadzip
* *
* @param $url * @param $url
* @param $file * @param $file
@ -308,17 +308,17 @@ class AppController extends Base
$body = $response->getBody(); $body = $response->getBody();
$status = $response->getStatusCode(); $status = $response->getStatusCode();
if ($status == 404) { if ($status == 404) {
throw new BusinessException('安装包不存在'); throw new BusinessException('The installation package does not exist');
} }
$zip_content = $body->getContents(); $zip_content = $body->getContents();
if (empty($zip_content)) { if (empty($zip_content)) {
throw new BusinessException('安装包不存在'); throw new BusinessException('The installation package does not exist');
} }
file_put_contents($file, $zip_content); file_put_contents($file, $zip_content);
} }
/** /**
* 获取系统支持的解压命令 * Get the unzip command supported by the system
* *
* @param $zip_file * @param $zip_file
* @param $extract_to * @param $extract_to
@ -337,7 +337,7 @@ class AppController extends Base
} }
/** /**
* 使用解压命令解压 * Unzip using the unzip command
* *
* @param $cmd * @param $cmd
* @return void * @return void
@ -352,18 +352,18 @@ class AppController extends Base
]; ];
$handler = proc_open($cmd, $desc, $pipes); $handler = proc_open($cmd, $desc, $pipes);
if (!is_resource($handler)) { if (!is_resource($handler)) {
throw new BusinessException("解压zip时出错:proc_open调用失败"); throw new BusinessException("Error unpacking zip: proc_open call failed");
} }
$err = fread($pipes[2], 1024); $err = fread($pipes[2], 1024);
fclose($pipes[2]); fclose($pipes[2]);
proc_close($handler); proc_close($handler);
if ($err) { if ($err) {
throw new BusinessException("解压zip时出错:$err"); throw new BusinessException("Error unzipping zip:$err");
} }
} }
/** /**
* 获取本地插件版本 * Get local plugin version
* *
* @param $name * @param $name
* @return array|mixed|null * @return array|mixed|null
@ -378,7 +378,7 @@ class AppController extends Base
} }
/** /**
* 删除目录 * delete directory
* *
* @param $src * @param $src
* @return void * @return void
@ -401,13 +401,13 @@ class AppController extends Base
} }
/** /**
* 获取httpclient * Obtainhttpclient
* *
* @return Client * @return Client
*/ */
protected function httpClient() protected function httpClient()
{ {
// 下载zip // downloadzip
$options = [ $options = [
'base_uri' => config('plugin.admin.app.plugin_market_host'), 'base_uri' => config('plugin.admin.app.plugin_market_host'),
'timeout' => 30, 'timeout' => 30,
@ -427,13 +427,13 @@ class AppController extends Base
} }
/** /**
* 获取下载httpclient * Get Downloadhttpclient
* *
* @return Client * @return Client
*/ */
protected function downloadClient() protected function downloadClient()
{ {
// 下载zip // downloadzip
$options = [ $options = [
'timeout' => 30, 'timeout' => 30,
'connect_timeout' => 5, 'connect_timeout' => 5,
@ -451,7 +451,7 @@ class AppController extends Base
} }
/** /**
* 查找系统命令 * Find System Commands
* *
* @param string $name * @param string $name
* @param string|null $default * @param string|null $default

View File

@ -8,7 +8,7 @@ use plugin\admin\app\model\User;
use support\Request; use support\Request;
/** /**
* 用户管理 * User Management
*/ */
class UserController extends Base class UserController extends Base
{ {
@ -18,12 +18,12 @@ class UserController extends Base
protected $model = null; protected $model = null;
/** /**
* 增删改查 * Add, delete, modify and check
*/ */
use Crud; use Crud;
/** /**
* 构造函数 * Constructor
*/ */
public function __construct() public function __construct()
{ {

View File

@ -4,7 +4,7 @@
*/ */
/** /**
* 当前登录管理员id * Currently logged in administratorid
* *
* @return mixed|null * @return mixed|null
*/ */
@ -14,7 +14,7 @@ function admin_id()
} }
/** /**
* 当前管理员 * Current Admin
* *
* @param null|array|string $fields * @param null|array|string $fields
* @return array|mixed|null * @return array|mixed|null
@ -38,7 +38,7 @@ function admin($fields = null)
} }
/** /**
* 当前登录用户id * Currently logged in userid
* *
* @return mixed|null * @return mixed|null
*/ */
@ -48,7 +48,7 @@ function user_id()
} }
/** /**
* 当前登录用户 * Currently logged in user
* *
* @param null|array|string $fields * @param null|array|string $fields
* @return array|mixed|null * @return array|mixed|null

View File

@ -4,16 +4,16 @@ namespace plugin\admin\app\model;
/** /**
* @property integer $id ID(主键) * @property integer $id ID(primary key)
* @property string $username 用户名 * @property string $username username
* @property string $nickname 昵称 * @property string $nickname Nick name
* @property string $password 密码 * @property string $password password
* @property string $avatar 头像 * @property string $avatar avatar
* @property string $email 邮箱 * @property string $email Mail
* @property string $mobile 手机 * @property string $mobile cell phone
* @property string $created_at 创建时间 * @property string $created_at creation time
* @property string $updated_at 更新时间 * @property string $updated_at Update time
* @property string $roles 角色 * @property string $roles Role
*/ */
class Admin extends Base class Admin extends Base
{ {

View File

@ -3,11 +3,11 @@
namespace plugin\admin\app\model; namespace plugin\admin\app\model;
/** /**
* @property integer $id 主键(主键) * @property integer $id primary key (primary key)
* @property string $name 角色名 * @property string $name character name
* @property string $rules 规则 * @property string $rules rule
* @property string $created_at 创建时间 * @property string $created_at creation time
* @property string $updated_at 更新时间 * @property string $updated_at Update time
*/ */
class AdminRole extends Base class AdminRole extends Base
{ {

View File

@ -3,18 +3,18 @@
namespace plugin\admin\app\model; namespace plugin\admin\app\model;
/** /**
* @property integer $id 主键(主键) * @property integer $id primary key (primary key)
* @property string $title 标题 * @property string $title title
* @property string $name 名字 * @property string $name name
* @property integer $pid 上级id * @property integer $pid superiorid
* @property string $component 组件 * @property string $component component
* @property string $path 路径 * @property string $path path
* @property string $icon 图标 * @property string $icon icon
* @property string $created_at 创建时间 * @property string $created_at creation time
* @property string $updated_at 更新时间 * @property string $updated_at Update time
* @property string $frame_src url * @property string $frame_src url
* @property integer $hide_menu 隐藏菜单 * @property integer $hide_menu Hide menu
* @property integer $is_menu 是否菜单 * @property integer $is_menu Whether menu
*/ */
class AdminRule extends Base class AdminRule extends Base
{ {

View File

@ -14,7 +14,7 @@ class Base extends Model
protected $connection = 'plugin.admin.mysql'; protected $connection = 'plugin.admin.mysql';
/** /**
* 格式化日期 * Format Date
* *
* @param DateTimeInterface $date * @param DateTimeInterface $date
* @return string * @return string

View File

@ -4,11 +4,11 @@ namespace plugin\admin\app\model;
/** /**
* @property integer $id (主键) * @property integer $id (primary key)
* @property string $name * @property string $name
* @property mixed $value * @property mixed $value
* @property string $created_at 创建时间 * @property string $created_at creation time
* @property string $updated_at 更新时间 * @property string $updated_at Update time
*/ */
class Option extends Base class Option extends Base
{ {

View File

@ -3,17 +3,17 @@
namespace plugin\admin\app\model; namespace plugin\admin\app\model;
/** /**
* @property integer $id 主键(主键) * @property integer $id primary key (primary key)
* @property string $name 名字 * @property string $name name
* @property integer $pid 上级id * @property integer $pid superiorid
* @property string $component 组件 * @property string $component component
* @property string $path 路径 * @property string $path path
* @property string $icon 图标 * @property string $icon icon
* @property string $title 标题 * @property string $title title
* @property string $created_at 创建时间 * @property string $created_at creation time
* @property string $updated_at 更新时间 * @property string $updated_at Update time
* @property string $frame_src url * @property string $frame_src url
* @property integer $hide_menu 隐藏菜单 * @property integer $hide_menu Hide menu
*/ */
class Role extends Base class Role extends Base
{ {

View File

@ -3,26 +3,26 @@
namespace plugin\admin\app\model; namespace plugin\admin\app\model;
/** /**
* @property integer $id 主键(主键) * @property integer $id primary key (primary key)
* @property string $username 用户名 * @property string $username username
* @property string $nickname 昵称 * @property string $nickname Nick name
* @property string $password 密码 * @property string $password password
* @property string $sex 性别 * @property string $sex gender
* @property string $avatar 头像 * @property string $avatar avatar
* @property string $email 邮箱 * @property string $email Mail
* @property string $mobile 手机 * @property string $mobile cell phone
* @property integer $level 等级 * @property integer $level grade
* @property string $birthday 生日 * @property string $birthday Birthday
* @property integer $money 余额 * @property integer $money balance
* @property integer $score 积分 * @property integer $score integral
* @property string $last_time 上次登录时间 * @property string $last_time Last Login Time
* @property string $last_ip 上次登录ip * @property string $last_ip Last Loginip
* @property string $join_time 注册时间 * @property string $join_time Registration time
* @property string $join_ip 注册ip * @property string $join_ip registerip
* @property string $token token * @property string $token token
* @property string $created_at 创建时间 * @property string $created_at creation time
* @property string $updated_at 更新时间 * @property string $updated_at Update time
* @property string $roles 更新时间 * @property string $roles Update time
*/ */
class User extends Base class User extends Base
{ {

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="shortcut icon" type="image/x-icon" href="https://unpkg.byted-static.com/latest/byted/arco-config/assets/favicon.ico"> <link rel="shortcut icon" type="image/x-icon" href="https://unpkg.byted-static.com/latest/byted/arco-config/assets/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Arco Design Pro - 开箱即用的中台前端/设计解决方案</title> <title>Arco Design Pro - Out-of-the-box mid-stage front-end/design solutions</title>
<script type="module" crossorigin src="/assets/index.29d1f1fd.js"></script> <script type="module" crossorigin src="/assets/index.29d1f1fd.js"></script>
<link rel="modulepreload" href="/assets/arco.f97752e2.js"> <link rel="modulepreload" href="/assets/arco.f97752e2.js">
<link rel="modulepreload" href="/assets/chart.1bb0aa8b.js"> <link rel="modulepreload" href="/assets/chart.1bb0aa8b.js">

View File

@ -6,19 +6,19 @@ use plugin\queue\app\controller\redis\NormalController;
return [ return [
[ [
'title' => '数据库', 'title' => 'database',
'name' => 'database', 'name' => 'database',
'path' => '/database', 'path' => '/database',
'icon' => 'ant-design:database-filled', 'icon' => 'ant-design:database-filled',
'children' => [ 'children' => [
[ [
'title' => '所有表', 'title' => 'all tables',
'name' => 'plugin\\admin\\app\\controller\\database\\TableController', 'name' => 'plugin\\admin\\app\\controller\\database\\TableController',
'path' => 'table', 'path' => 'table',
'component' => '/database/table/index' 'component' => '/database/table/index'
], ],
[ [
'title' => '表详情', 'title' => 'Table Details',
'name' => 'tableview', 'name' => 'tableview',
'path' => 'table/view/:id', 'path' => 'table/view/:id',
'component' => '/database/table/View', 'component' => '/database/table/View',
@ -27,25 +27,25 @@ return [
] ]
], ],
[ [
'title' => '权限管理', 'title' => 'authority management',
'name' => 'auth', 'name' => 'auth',
'path' => '/auth', 'path' => '/auth',
'icon' => 'ant-design:setting-filled', 'icon' => 'ant-design:setting-filled',
'children' => [ 'children' => [
[ [
'title' => '账户管理', 'title' => 'Account Management',
'name' => 'plugin\\admin\\app\\controller\\auth\\AdminController', 'name' => 'plugin\\admin\\app\\controller\\auth\\AdminController',
'path' => 'admin', 'path' => 'admin',
'component' => '/auth/admin/index' 'component' => '/auth/admin/index'
], ],
[ [
'title' => '角色管理', 'title' => 'role management',
'name' => 'plugin\\admin\\app\\controller\\auth\\AdminRoleController', 'name' => 'plugin\\admin\\app\\controller\\auth\\AdminRoleController',
'path' => 'admin-role', 'path' => 'admin-role',
'component' => '/auth/admin-role/index', 'component' => '/auth/admin-role/index',
], ],
[ [
'title' => '菜单管理', 'title' => 'Menu management',
'name' => 'plugin\\admin\\app\\controller\\auth\\AdminRuleController', 'name' => 'plugin\\admin\\app\\controller\\auth\\AdminRuleController',
'path' => 'admin-rule', 'path' => 'admin-rule',
'component' => '/auth/admin-rule/index', 'component' => '/auth/admin-rule/index',
@ -53,13 +53,13 @@ return [
] ]
], ],
[ [
'title' => '会员管理', 'title' => 'Membership Management',
'name' => 'user', 'name' => 'user',
'path' => '/user', 'path' => '/user',
'icon' => 'ant-design:smile-filled', 'icon' => 'ant-design:smile-filled',
'children' => [ 'children' => [
[ [
'title' => '用户', 'title' => 'user',
'name' => 'plugin\\admin\\app\\controller\\user\\UserController', 'name' => 'plugin\\admin\\app\\controller\\user\\UserController',
'path' => 'user', 'path' => 'user',
'component' => '/user/user/index' 'component' => '/user/user/index'
@ -67,13 +67,13 @@ return [
] ]
], ],
[ [
'title' => '通用设置', 'title' => 'General Settings',
'name' => 'common', 'name' => 'common',
'path' => '/common', 'path' => '/common',
'icon' => 'ant-design:setting-filled', 'icon' => 'ant-design:setting-filled',
'children' => [ 'children' => [
[ [
'title' => '个人资料', 'title' => 'personal information',
'name' => 'plugin\\admin\\app\\controller\\user\\AccountController', 'name' => 'plugin\\admin\\app\\controller\\user\\AccountController',
'path' => 'account', 'path' => 'account',
'component' => '/common/account/index' 'component' => '/common/account/index'
@ -81,13 +81,13 @@ return [
] ]
], ],
[ [
'title' => '插件管理', 'title' => 'Plugin management',
'name' => 'plugin', 'name' => 'plugin',
'path' => '/plugin', 'path' => '/plugin',
'icon' => 'ant-design:appstore-filled', 'icon' => 'ant-design:appstore-filled',
'children' => [ 'children' => [
[ [
'title' => '应用插件', 'title' => 'Apply Plugins',
'name' => 'plugin\\admin\\app\\controller\\plugin\\AppController', 'name' => 'plugin\\admin\\app\\controller\\plugin\\AppController',
'path' => 'app', 'path' => 'app',
'component' => '/plugin/App' 'component' => '/plugin/App'

File diff suppressed because one or more lines are too long