Browse Source

Polish the OAuth user interface & lang

兔姬桑 4 years ago
parent
commit
a73fb45e9f

+ 11 - 11
app/Http/Controllers/OAuth/BaseController.php

@@ -42,7 +42,7 @@ class BaseController extends Controller
             return $this->login($type, $info);
         }
 
-        return redirect()->route('login')->withErrors('第三方登录失败!');
+        return redirect()->route('login')->withErrors(trans('auth.oauth.login_failed'));
     }
 
     private function bind(string $type, $user, $info)
@@ -52,12 +52,12 @@ class BaseController extends Controller
         if ($auth) {
             $user->userAuths()->whereType($type)->update($data);
 
-            return redirect()->route('profile')->with('successMsg', '重新绑定成功');
+            return redirect()->route('profile')->with('successMsg', trans('auth.oauth.rebind_success'));
         }
 
         $user->userAuths()->create($data);
 
-        return redirect()->route('profile')->with('successMsg', '绑定成功');
+        return redirect()->route('profile')->with('successMsg', trans('auth.oauth.bind_success'));
     }
 
     private function login(string $type, $info)
@@ -84,10 +84,10 @@ class BaseController extends Controller
     {
         $user = Auth::user();
         if ($user && $user->userAuths()->whereType($type)->delete()) {
-            return redirect()->route('profile')->with('successMsg', '解绑成功');
+            return redirect()->route('profile')->with('successMsg', trans('auth.oauth.unbind_success'));
         }
 
-        return redirect()->route('profile')->with('successMsg', '解绑失败');
+        return redirect()->route('profile')->with('successMsg', trans('auth.oauth.unbind_failed'));
     }
 
     public function binding($type)
@@ -101,10 +101,10 @@ class BaseController extends Controller
                 return $this->bind($type, $user, $info);
             }
 
-            return redirect()->route('profile')->withErrors('绑定失败');
+            return redirect()->route('profile')->withErrors(trans('auth.oauth.bind_failed'));
         }
 
-        return redirect()->route('login')->withErrors('第三方登录失败!');
+        return redirect()->route('login')->withErrors(trans('auth.oauth.login_failed'));
     }
 
     public function logining($type)
@@ -115,7 +115,7 @@ class BaseController extends Controller
             return $this->login($type, $info);
         }
 
-        return redirect()->route('login')->withErrors('第三方登录失败!');
+        return redirect()->route('login')->withErrors(trans('auth.oauth.login_failed'));
     }
 
     public function register($type)
@@ -143,13 +143,13 @@ class BaseController extends Controller
                         return redirect()->route('login');
                     }
 
-                    return redirect()->route('register')->withErrors('注册失败');
+                    return redirect()->route('register')->withErrors(trans('auth.oauth.register_failed'));
                 }
             }
 
-            return redirect()->route('login')->withErrors('已注册,请直接登录');
+            return redirect()->route('login')->withErrors(trans('auth.oauth.registered'));
         }
 
-        return redirect()->route('login')->withErrors('第三方登录失败!');
+        return redirect()->route('login')->withErrors(trans('auth.oauth.login_failed'));
     }
 }

+ 11 - 1
resources/lang/en/auth.php

@@ -43,6 +43,17 @@ return [
     'logout'          => 'Logout',
     'maintenance'     => 'Maintain',
     'maintenance_tip' => 'Website under maintenance',
+    'oauth'           => [
+        'bind_success'    => 'Binding success',
+        'bind_failed'     => 'Binding failed',
+        'login_failed'    => 'Sign in failed!',
+        'register'        => 'Quick registration',
+        'registered'      => 'Already registered, please login directly',
+        'register_failed' => 'Registration failed',
+        'rebind_success'  => 'Rebinding success',
+        'unbind_success'  => 'Unbinding success',
+        'unbind_failed'   => 'Unbinding failed',
+    ],
     'optional'        => 'Optional',
     'password'        => [
         'forget'   => 'Forgot password?',
@@ -75,6 +86,5 @@ return [
     ],
     'remember_me'     => 'Remember me',
     'request'         => 'Request',
-    'sign_in_with'    => 'Sign in with :app',
     'tos'             => 'Terms of Service',
 ];

+ 9 - 2
resources/lang/en/user.php

@@ -72,10 +72,18 @@ return [
         'nodes'           => 'Node',
         'referrals'       => 'Affiliates',
         'shop'            => 'Shop',
+        'profile'         => 'Settings',
         'tickets'         => 'Ticket',
-        'admin_dashboard' => 'Admin Dashboard',
+        'admin_dashboard' => 'Dashboard',
     ],
     'contact'             => 'Contact Info',
+    'oauth'               => [
+        'bind_title' => 'Binding Your Social Accounts',
+        'not_bind'   => 'Not Yet Bound',
+        'bind'       => 'Bind',
+        'rebind'     => 'Rebind',
+        'unbind'     => 'Unbind',
+    ],
     'coupon'              => [
         'attribute'   => 'Coupon',
         'voucher'     => 'Voucher',
@@ -128,7 +136,6 @@ return [
     'payment_method'      => 'payment method',
     'pay'                 => 'Pay',
     'input_coupon'        => 'Please enter the gift code',
-    'user_profile'        => 'Account settings',
     'recharge'            => 'Pay',
     'recharge_credit'     => 'Add Funds',
     'recharging'          => 'Paying ...',

+ 11 - 1
resources/lang/zh_CN/auth.php

@@ -40,6 +40,17 @@ return [
     'logout'          => '登 出',
     'maintenance'     => '维护',
     'maintenance_tip' => '网站维护中',
+    'oauth'           => [
+        'bind_success'    => '绑定成功',
+        'bind_failed'     => '绑定失败',
+        'login_failed'    => '第三方登录失败!',
+        'register'        => '快速注册',
+        'registered'      => '已注册,请直接登录',
+        'register_failed' => '注册失败',
+        'rebind_success'  => '重新绑定成功',
+        'unbind_success'  => '解绑成功',
+        'unbind_failed'   => '解绑失败',
+    ],
     'optional'        => '可选',
     'password'        => [
         'forget'   => '忘记密码?',
@@ -69,6 +80,5 @@ return [
     ],
     'remember_me'     => '记住我',
     'request'         => '获 取',
-    'sign_in_with'    => ':app账号登录',
     'tos'             => '用户条款',
 ];

+ 14 - 7
resources/lang/zh_CN/user.php

@@ -57,11 +57,11 @@ return [
     'purchase_required'   => '本功能对非付费用户禁用!请',
     'more'                => '更多',
     'attribute'           => [
-        'node'     => '线路',
-        'data'     => '流量',
-        'ip'       => 'IP地址',
-        'isp'      => '运营商',
-        'address'  => '地区',
+        'node'    => '线路',
+        'data'    => '流量',
+        'ip'      => 'IP地址',
+        'isp'     => '运营商',
+        'address' => '地区',
     ],
     'purchase_promotion'  => '快 来 购 买 服 务 吧!',
     'menu'                => [
@@ -72,10 +72,18 @@ return [
         'nodes'           => '线 路',
         'referrals'       => '推 广',
         'shop'            => '服 务',
+        'profile'         => '设 置',
         'tickets'         => '工 单',
-        'admin_dashboard' => '管理面板',
+        'admin_dashboard' => '管 理',
     ],
     'contact'             => '联系方式',
+    'oauth'               => [
+        'bind_title' => '绑定社交账号',
+        'not_bind'   => '尚未绑定',
+        'bind'       => '绑 定',
+        'rebind'     => '重新绑定',
+        'unbind'     => '解 绑',
+    ],
     'coupon'              => [
         'attribute'   => '优惠券',
         'voucher'     => '代金券',
@@ -128,7 +136,6 @@ return [
     'payment_method'      => '支付方式',
     'pay'                 => '支付',
     'input_coupon'        => '请输入充值券码',
-    'user_profile'        => '个人设置',
     'recharge'            => '充值',
     'recharge_credit'     => '余额充值',
     'recharging'          => '充值中...',

+ 1 - 1
resources/views/auth/register.blade.php

@@ -102,7 +102,7 @@
     @if(sysConfig('is_register') && sysConfig('oauth_path'))
         <div class="pt-20" style="display: inline-block;">
             <div class="line">
-                <span> 快速注册 </span>
+                <span> {{trans('auth.oauth.register')}} </span>
             </div>
             @foreach (json_decode(sysConfig('oauth_path')) as $item)
                 @if ($item !== 'telegram')

+ 25 - 4
resources/views/user/layouts.blade.php

@@ -66,13 +66,13 @@
                         <div class="dropdown-menu" role="menu">
                             @can('admin.index')
                                 <a href="{{route('admin.index')}}" class="dropdown-item" role="menuitem">
-                                    <i class="icon wb-user" aria-hidden="true"></i>
+                                    <i class="icon wb-dashboard" aria-hidden="true"></i>
                                     {{trans('user.menu.admin_dashboard')}}
                                 </a>
                             @endcan
                             <a href="{{route('profile')}}" class="dropdown-item" role="menuitem">
-                                <i class="icon wb-user" aria-hidden="true"></i>
-                                {{trans('user.user_profile')}}
+                                <i class="icon wb-settings" aria-hidden="true"></i>
+                                {{trans('user.menu.profile')}}
                             </a>
                             <div class="dropdown-divider" role="presentation"></div>
                             <a href="{{route('logout')}}" class="dropdown-item" role="menuitem">
@@ -90,7 +90,7 @@
             <ul class="site-menu" data-plugin="menu">
                 <li class="site-menu-item {{request()->routeIs('home', 'profile' ,'article') ? 'active open' : ''}}">
                     <a href="{{route('home')}}">
-                        <i class="site-menu-icon wb-dashboard" aria-hidden="true"></i>
+                        <i class="site-menu-icon wb-home" aria-hidden="true"></i>
                         <span class="site-menu-title">{{trans('user.menu.home')}}</span>
                     </a>
                 </li>
@@ -112,6 +112,12 @@
                         <span class="site-menu-title">{{trans('user.menu.helps')}}</span>
                     </a>
                 </li>
+                <li class="site-menu-item {{request()->routeIs('profile') ? 'active open' : ''}}">
+                    <a href="{{route('profile')}}">
+                        <i class="site-menu-icon wb-settings" aria-hidden="true"></i>
+                        <span class="site-menu-title">{{trans('user.menu.profile')}}</span>
+                    </a>
+                </li>
                 @php
                     $openTicket = auth()->user()->tickets()->where('status','<>',2)->count()
                 @endphp
@@ -150,6 +156,21 @@
                         </li>
                     @endif
                 @endif
+                <hr>
+                @can('admin.index')
+                    <li class="site-menu-item">
+                        <a href="{{route('admin.index')}}">
+                            <i class="site-menu-icon wb-dashboard" aria-hidden="true"></i>
+                            <span class="site-menu-title">{{trans('user.menu.admin_dashboard')}}</span>
+                        </a>
+                    </li>
+                @endcan
+                <li class="site-menu-item">
+                    <a href="{{route('logout')}}">
+                        <i class="site-menu-icon wb-power" aria-hidden="true"></i>
+                        <span class="site-menu-title">{{trans('auth.logout')}}</span>
+                    </a>
+                </li>
             </ul>
         </div>
     </div>

+ 4 - 4
resources/views/user/profile.blade.php

@@ -34,7 +34,7 @@
                     </div>
                     @if(sysConfig('oauth_path'))
                         <div class="line">
-                            <span> 绑定社交账号 </span>
+                            <span> {{trans('user.oauth.bind_title')}} </span>
                         </div>
                         <div class="user-socials list-group-gap list-group-full row m-0">
                             @foreach (json_decode(sysConfig('oauth_path')) as $item)
@@ -42,16 +42,16 @@
                                    @if($item !== 'telegram') href="{{route('oauth.route', ['type' => $item, 'action' => 'binding'])}}" @endif>
                                     <i class="fab {{config('common.oauth.icon')[$item]}} fa-lg mr-10" aria-hidden="true"></i> {{config('common.oauth.labels')[$item]}} :
                                     @if(in_array($item, $auth))
-                                        <span class="red-600">重新绑定</span>
+                                        <span class="red-600">{{trans('user.oauth.rebind')}}</span>
                                     @else
-                                        <span class="grey-500">未绑定</span>
+                                        <span class="grey-500">{{trans('user.oauth.not_bind')}}</span>
                                     @endif
                                     @if($item === 'telegram')
                                         {!! Socialite::driver('telegram')->getButton() !!}
                                     @endif
                                 </a>
                                 @if(in_array($item, $auth))
-                                    <a class="col-2 btn btn-block btn-danger my-auto" href="{{route('oauth.unsubscribe', ['type' => $item])}}">解绑</a>
+                                    <a class="col-2 btn btn-block btn-danger my-auto" href="{{route('oauth.unsubscribe', ['type' => $item])}}">{{trans('user.oauth.unbind')}}</a>
                                 @endif
                             @endforeach
                         </div>