Skip to content

Commit 98ac303

Browse files
author
Mark Huang
committed
Translated the project to zh-TW
see webman-php#8
1 parent 0573741 commit 98ac303

File tree

176 files changed

+9462
-9462
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+9462
-9462
lines changed

src/plugin/admin/api/Auth.php

+20-20
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
use function admin;
88

99
/**
10-
* 对外提供的鉴权接口
10+
* 對外提供的鑑權介面
1111
*/
1212
class Auth
1313
{
1414
/**
15-
* 判断权限
16-
* 如果没有权限则抛出异常
15+
* 判斷權限
16+
* 如果沒有權限則拋出異常
1717
* @param string $controller
1818
* @param string $action
1919
* @return void
@@ -29,7 +29,7 @@ public static function access(string $controller, string $action)
2929
}
3030

3131
/**
32-
* 判断是否有权限
32+
* 判斷是否有權限
3333
* @param string $controller
3434
* @param string $action
3535
* @param int $code
@@ -39,44 +39,44 @@ public static function access(string $controller, string $action)
3939
*/
4040
public static function canAccess(string $controller, string $action, int &$code = 0, string &$msg = ''): bool
4141
{
42-
// 无控制器信息说明是函数调用,函数不属于任何控制器,鉴权操作应该在函数内部完成
42+
// 無控制器資訊說明是函數調用,函​​數不屬於任何控制器,鑑權操作應該在函數內部完成
4343
if (!$controller) {
4444
return true;
4545
}
46-
// 获取控制器鉴权信息
46+
// 取得控制器鑑權資訊
4747
$class = new \ReflectionClass($controller);
4848
$properties = $class->getDefaultProperties();
4949
$noNeedLogin = $properties['noNeedLogin'] ?? [];
5050
$noNeedAuth = $properties['noNeedAuth'] ?? [];
5151

52-
// 不需要登录
52+
// 不需要登入
5353
if (in_array($action, $noNeedLogin)) {
5454
return true;
5555
}
5656

57-
// 获取登录信息
57+
// 取得登入資訊
5858
$admin = admin();
5959
if (!$admin) {
60-
$msg = '请登录';
61-
// 401是未登录固定的返回码
60+
$msg = '請登入';
61+
// 401是未登入固定的回傳碼
6262
$code = 401;
6363
return false;
6464
}
6565

66-
// 不需要鉴权
66+
// 不需要鑑權
6767
if (in_array($action, $noNeedAuth)) {
6868
return true;
6969
}
7070

71-
// 当前管理员无角色
71+
// 目前管理者無角色
7272
$roles = $admin['roles'];
7373
if (!$roles) {
74-
$msg = '无权限';
74+
$msg = '無權限';
7575
$code = 2;
7676
return false;
7777
}
7878

79-
// 角色没有规则
79+
// 角色沒有規則
8080
$rules = Role::whereIn('id', $roles)->pluck('rules');
8181
$rule_ids = [];
8282
foreach ($rules as $rule_string) {
@@ -86,17 +86,17 @@ public static function canAccess(string $controller, string $action, int &$code
8686
$rule_ids = array_merge($rule_ids, explode(',', $rule_string));
8787
}
8888
if (!$rule_ids) {
89-
$msg = '无权限';
89+
$msg = '無權限';
9090
$code = 2;
9191
return false;
9292
}
9393

94-
// 超级管理员
94+
// 超級管理員
9595
if (in_array('*', $rule_ids)){
9696
return true;
9797
}
9898

99-
// 如果action为index,规则里有任意一个以$controller开头的权限即可
99+
// 如果action為index,規則裡有任一個以$controller開頭的權限即可
100100
if (strtolower($action) === 'index') {
101101
$rule = Rule::where(function ($query) use ($controller, $action) {
102102
$controller_like = str_replace('\\', '\\\\', $controller);
@@ -105,18 +105,18 @@ public static function canAccess(string $controller, string $action, int &$code
105105
if ($rule) {
106106
return true;
107107
}
108-
$msg = '无权限';
108+
$msg = '無權限';
109109
$code = 2;
110110
return false;
111111
}
112112

113-
// 查询是否有当前控制器的规则
113+
// 查詢是否有目前控制器的規則
114114
$rule = Rule::where(function ($query) use ($controller, $action) {
115115
$query->where('key', "$controller@$action")->orWhere('key', $controller);
116116
})->whereIn('id', $rule_ids)->first();
117117

118118
if (!$rule) {
119-
$msg = '无权限';
119+
$msg = '無權限';
120120
$code = 2;
121121
return false;
122122
}

src/plugin/admin/api/Install.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
class Install
66
{
77
/**
8-
* 安装
8+
* 安裝
99
*
1010
* @param $version
1111
* @return void
1212
*/
1313
public static function install($version)
1414
{
15-
// 导入菜单
15+
// 導入選單
1616
Menu::import(static::getMenus());
1717
}
1818

1919
/**
20-
* 卸载
20+
* 解除安裝
2121
*
2222
* @param $version
2323
* @return void
2424
*/
2525
public static function uninstall($version)
2626
{
27-
// 删除菜单
27+
// 刪除選單
2828
foreach (static::getMenus() as $menu) {
2929
Menu::delete($menu['name']);
3030
}
@@ -40,29 +40,29 @@ public static function uninstall($version)
4040
*/
4141
public static function update($from_version, $to_version, $context = null)
4242
{
43-
// 删除不用的菜单
43+
// 刪除不用的選單
4444
if (isset($context['previous_menus'])) {
4545
static::removeUnnecessaryMenus($context['previous_menus']);
4646
}
47-
// 导入新菜单
47+
// 匯入新選單
4848
Menu::import(static::getMenus());
4949
}
5050

5151
/**
52-
* 更新前数据收集等
52+
* 更新前資料收集等
5353
*
5454
* @param $from_version
5555
* @param $to_version
5656
* @return array|array[]
5757
*/
5858
public static function beforeUpdate($from_version, $to_version)
5959
{
60-
// 在更新之前获得老菜单,通过context传递给 update
60+
// 在更新前取得舊選單,透過context傳遞給 update
6161
return ['previous_menus' => static::getMenus()];
6262
}
6363

6464
/**
65-
* 获取菜单
65+
* 取得選單
6666
*
6767
* @return array|mixed
6868
*/
@@ -77,7 +77,7 @@ public static function getMenus()
7777
}
7878

7979
/**
80-
* 删除不需要的菜单
80+
* 刪除不需要的選單
8181
*
8282
* @param $previous_menus
8383
* @return void

src/plugin/admin/api/Menu.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
use function admin;
88

99
/**
10-
* 对外提供的菜单接口
10+
* 對外提供的選單介面
1111
*/
1212
class Menu
1313
{
1414

1515
/**
16-
* 根据key获取菜单
16+
* 根據key取得選單
1717
* @param $key
1818
* @return array
1919
*/
@@ -24,7 +24,7 @@ public static function get($key)
2424
}
2525

2626
/**
27-
* 根据id获得菜单
27+
* 根據id取得菜單
2828
* @param $id
2929
* @return array
3030
*/
@@ -34,7 +34,7 @@ public static function find($id): array
3434
}
3535

3636
/**
37-
* 添加菜单
37+
* 新增選單
3838
* @param array $menu
3939
* @return int
4040
*/
@@ -49,7 +49,7 @@ public static function add(array $menu)
4949
}
5050

5151
/**
52-
* 导入菜单
52+
* 導入選單
5353
* @param array $menu_tree
5454
* @return void
5555
*/
@@ -76,7 +76,7 @@ public static function import(array $menu_tree)
7676
}
7777

7878
/**
79-
* 删除菜单
79+
* 刪除選單
8080
* @param $key
8181
* @return void
8282
*/
@@ -86,7 +86,7 @@ public static function delete($key)
8686
if (!$item) {
8787
return;
8888
}
89-
// 子规则一起删除
89+
// 子規則一起刪除
9090
$delete_ids = $children_ids = [$item['id']];
9191
while($children_ids) {
9292
$children_ids = Rule::whereIn('pid', $children_ids)->pluck('id')->toArray();
@@ -97,7 +97,7 @@ public static function delete($key)
9797

9898

9999
/**
100-
* 获取菜单中某个(些)字段的值
100+
* 取得選單中某個(些)欄位的值
101101
* @param $menu
102102
* @param null $column
103103
* @param null $index

src/plugin/admin/api/Middleware.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
use support\exception\BusinessException;
99

1010
/**
11-
* 对外提供的鉴权中间件
11+
* 對外提供的鑑權中間件
1212
*/
1313
class Middleware implements MiddlewareInterface
1414
{
1515
/**
16-
* 鉴权
16+
* 鑑權
1717
* @param Request $request
1818
* @param callable $handler
1919
* @return Response

src/plugin/admin/app/common/Auth.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Auth
1111
{
1212
/**
13-
* 获取权限范围内的所有角色id
13+
* 取得權限範圍內的所有角色id
1414
* @param bool $with_self
1515
* @return array
1616
*/
@@ -32,7 +32,7 @@ public static function getScopeRoleIds(bool $with_self = false): array
3232
}
3333

3434
/**
35-
* 获取权限范围内的所有管理员id
35+
* 取得權限範圍內的所有管理者id
3636
* @param bool $with_self
3737
* @return array
3838
*/
@@ -47,7 +47,7 @@ public static function getScopeAdminIds(bool $with_self = false): array
4747
}
4848

4949
/**
50-
* 兼容旧版本
50+
* 相容舊版
5151
* @param int $admin_id
5252
* @deprecated
5353
* @return bool
@@ -59,7 +59,7 @@ public static function isSupperAdmin(int $admin_id = 0): bool
5959
}
6060

6161
/**
62-
* 是否是超级管理员
62+
* 是否為超級管理員
6363
* @param int $admin_id
6464
* @return bool
6565
*/

0 commit comments

Comments
 (0)