Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
O
Open-Platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杜宇森
Open-Platform
Commits
211f3cb6
Commit
211f3cb6
authored
Sep 02, 2021
by
UtopiaXC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🌍
重构部分结构,添加站点信息,完善登录退出
parent
d4077bde
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
270 additions
and
103 deletions
+270
-103
UserController.php
app/Http/Controllers/UserController.php
+17
-2
UserAuthMiddleware.php
app/Http/Middleware/View/UserAuthMiddleware.php
+4
-3
constants.php
config/System/constants.php
+43
-36
2021_09_01_100110_create_users_profile.php
...ase/migrations/2021_09_01_100110_create_users_profile.php
+1
-1
SiteProfileSeeder.php
database/seeders/SiteProfileSeeder.php
+28
-0
default_avatar.png
public/images/avatars/default_avatar.png
+0
-0
user_not_login.png
public/images/avatars/user_not_login.png
+0
-0
site_profile_description.php
resources/lang/zh_CN/site_profile_description.php
+3
-0
about.blade.php
resources/views/about.blade.php
+14
-0
register_verify.blade.php
resources/views/email/register_verify.blade.php
+8
-1
register_verify_link.blade.php
resources/views/email/register_verify_link.blade.php
+1
-1
index.blade.php
resources/views/index.blade.php
+4
-4
login.blade.php
resources/views/login.blade.php
+2
-26
open_source.blade.php
resources/views/open_source.blade.php
+14
-0
privacy_policy.blade.php
resources/views/privacy_policy.blade.php
+14
-0
register.blade.php
resources/views/register.blade.php
+1
-2
page_header.blade.php
resources/views/root/page_header.blade.php
+36
-22
root.blade.php
resources/views/root/root.blade.php
+4
-1
scripts.blade.php
resources/views/script/scripts.blade.php
+61
-0
api.php
routes/api.php
+1
-0
web.php
routes/web.php
+14
-4
No files found.
app/Http/Controllers/UserController.php
View file @
211f3cb6
...
...
@@ -54,7 +54,7 @@ class UserController extends Controller {
DB
::
commit
();
$code
=
md5
(
Uuid
::
generate
());
$link
=
env
(
"APP_URL"
)
.
\WebUrl
::
REGISTER_VERIFY
.
"/"
.
$code
;
R
::
ok
(
RedisAndCache
::
setWithExpire
(
RedisCacheKey
::
REGISTER_VERIFY
.
$code
,
$user
->
id
,
15
));
R
::
ok
(
RedisAndCache
::
setWithExpire
(
RedisCacheKey
::
REGISTER_VERIFY
.
$code
,
$user
->
id
,
15
));
Mail
::
to
(
$email
)
->
send
(
new
RegisterVerifyLinkMail
(
$link
,
$user_name
));
}
catch
(
Exception
$e
)
{
DB
::
rollBack
();
...
...
@@ -82,10 +82,25 @@ class UserController extends Controller {
if
(
!
password_verify
(
$password
,
$user
[
0
]
->
user_password
))
{
return
R
::
error
(
HTTP_CODE
::
REFUSED_LOGIN_WRONG
,
$user
[
0
]
->
user_password
);
}
$user_profile
=
UserProfile
::
query
()
->
where
(
"user_id"
,
$user
[
0
]
->
id
)
->
get
()[
0
];
$token
=
md5
(
$user
[
0
]
->
id
.
md5
(
microtime
(
true
)));
$cookie
=
Cookie
::
make
(
\CookieKey
::
USER_TOKEN
,
$token
,
60
*
24
*
30
);
$cookie
=
Cookie
::
make
(
env
(
"APP_NAME"
)
.
\CookieKey
::
USER_TOKEN
,
$token
,
60
*
24
*
30
);
$expiredMinutes
=
60
*
24
*
30
;
RedisAndCache
::
setWithExpire
(
RedisCacheKey
::
USER_TOKEN
.
$token
,
$user
[
0
],
$expiredMinutes
);
RedisAndCache
::
setWithExpire
(
RedisCacheKey
::
USER_PROFILE
.
$token
,
$user_profile
,
$expiredMinutes
);
return
R
::
ok
()
->
withCookie
(
$cookie
);
}
function
logout
(
Request
$request
)
{
$token
=
$request
->
cookie
(
env
(
"APP_NAME"
)
.
\CookieKey
::
USER_TOKEN
);
$cookie
=
Cookie
::
forget
(
env
(
"APP_NAME"
)
.
\CookieKey
::
USER_TOKEN
);
if
(
!
$token
)
{
return
R
::
ok
()
->
withCookie
(
$cookie
);
}
if
(
RedisAndCache
::
forget
(
RedisCacheKey
::
USER_TOKEN
.
$token
)
&&
RedisAndCache
::
forget
(
RedisCacheKey
::
USER_PROFILE
.
$token
,))
{
return
R
::
ok
()
->
withCookie
(
$cookie
);
}
else
{
return
R
::
error
(
HTTP_CODE
::
INTERNAL_SERVER_ERROR
);
}
}
}
app/Http/Middleware/View/UserAuthMiddleware.php
View file @
211f3cb6
...
...
@@ -18,15 +18,16 @@ class UserAuthMiddleware {
* @return mixed
*/
public
function
handle
(
Request
$request
,
Closure
$next
)
{
$token
=
$request
->
cookie
(
CookieKey
::
USER_TOKEN
);
$token
=
$request
->
cookie
(
env
(
"APP_NAME"
)
.
\
CookieKey
::
USER_TOKEN
);
if
(
!
$token
)
{
$request
->
attributes
->
add
([
HeaderKey
::
LOGIN_STATUS
=>
false
]);
}
$user
=
RedisAndCache
::
get
(
RedisCacheKey
::
USER_TOKEN
.
$token
);
$user
=
RedisAndCache
::
getWithJson
(
RedisCacheKey
::
USER_TOKEN
.
$token
);
$user_profile
=
RedisAndCache
::
getWithJson
(
RedisCacheKey
::
USER_PROFILE
.
$token
);
if
(
!
$user
)
$request
->
attributes
->
add
([
HeaderKey
::
LOGIN_STATUS
=>
false
]);
else
$request
->
attributes
->
add
([
HeaderKey
::
LOGIN_STATUS
=>
true
,
HeaderKey
::
USER_INFO
=>
$user
]);
$request
->
attributes
->
add
([
HeaderKey
::
LOGIN_STATUS
=>
true
,
HeaderKey
::
USER_INFO
=>
$user
,
HeaderKey
::
USER_PROFILE
=>
$user_profile
]);
return
$next
(
$request
);
}
}
config/System/constants.php
View file @
211f3cb6
<?php
class
WebUrl
{
class
WebUrl
{
const
INDEX
=
'/'
;
const
LOGIN
=
'/login'
;
const
REGISTER
=
'/register'
;
const
FIND_PASSWORD
=
'/find_password'
;
const
REGISTER_VERIFY
=
"/register_verify"
;
const
ABOUT
=
'/about'
;
const
PRIVACY_POLICY
=
"/privacy_policy"
;
const
REGISTER_VERIFY
=
"/register_verify"
;
const
OPEN_SOURCE
=
'/open_source'
;
}
class
ApiUrl
{
class
ApiUrl
{
const
API
=
'/api'
;
const
USER
=
'/user'
;
const
CAPTCHA
=
'/captcha'
;
const
REGISTER
=
"/register"
;
const
LOGIN
=
'/login'
;
const
LOGOUT
=
'/logout'
;
}
class
Middleware
{
class
Middleware
{
const
AUTH_MIDDLEWARE
=
'AuthMiddleware'
;
const
SITE_PROFILE_MIDDLEWARE
=
'SiteProfileMiddleware'
;
const
SITE_PROFILE_MIDDLEWARE
=
'SiteProfileMiddleware'
;
}
class
UserTypeEnum
{
class
UserTypeEnum
{
const
ADMIN
=
"01"
;
const
NORMAL
=
"02"
;
const
VIP
=
"03"
;
}
class
UserStatusEnum
{
class
UserStatusEnum
{
const
NOT_VERITY
=
"01"
;
const
NORMAL
=
"02"
;
const
BANNED
=
"03"
;
const
BANNED_FOREVER
=
"04"
;
}
class
RedisCacheKey
{
class
RedisCacheKey
{
const
SITE_PROFILE
=
"site_profile"
;
const
USER_TOKEN
=
"user_token:"
;
const
REGISTER_VERIFY
=
"register_verify:"
;
const
CAPTCHA
=
"captcha:"
;
const
USER_PROFILE
=
"user_profile:"
;
const
REGISTER_VERIFY
=
"register_verify:"
;
const
CAPTCHA
=
"captcha:"
;
}
class
CookieKey
{
const
USER_TOKEN
=
"user_token"
;
class
CookieKey
{
const
USER_TOKEN
=
"_user_token"
;
}
class
HeaderKey
{
class
HeaderKey
{
const
LOGIN_STATUS
=
"login_status"
;
const
USER_INFO
=
"user_info"
;
const
SITE_PROFILE
=
"site_profile"
;
const
USER_INFO
=
"user_info"
;
const
SITE_PROFILE
=
"site_profile"
;
const
USER_PROFILE
=
"user_profile"
;
}
class
FormKey
{
const
CAPTCHA
=
"captcha"
;
const
USER_NAME
=
"user_name"
;
const
EMAIL
=
"email"
;
const
PASSWORD
=
"password"
;
const
USER
=
"user"
;
class
FormKey
{
const
CAPTCHA
=
"captcha"
;
const
USER_NAME
=
"user_name"
;
const
EMAIL
=
"email"
;
const
PASSWORD
=
"password"
;
const
USER
=
"user"
;
}
class
SiteProfileTypeEnum
{
class
SiteProfileTypeEnum
{
const
WEB_TITLE
=
"01"
;
const
SITE_URL
=
"02"
;
const
WEB_FOOTER
=
"03"
;
const
KEY_WORDS
=
"04"
;
const
AUTHOR
=
"05"
;
const
DESCRIPTION
=
"06"
;
}
class
DefaultSiteProfile
{
class
DefaultSiteProfile
{
const
WEB_TITLE
=
'Utopia 开放平台'
;
const
SITE_URL
=
'http://localhost'
;
const
WEB_FOOTER
=
'Copyright ©2021 <a target="_blank" href="https://www.utopiaxc.cn/">UtopiaXC</a> All Rights Reserved | Powered By <a href="https://github.com/UtopiaXC/Utopia-Open-Platform" target="_blank">Utopia Open Platform</a>'
;
const
WEB_FOOTER
=
'Copyright ©2021 <a target="_blank" href="https://www.utopiaxc.cn/">UtopiaXC</a> All Rights Reserved | Powered By <a href="https://github.com/UtopiaXC/Utopia-Open-Platform" target="_blank">Utopia Open Platform</a>'
;
const
AUTHOR
=
'UtopiaXC'
;
const
DESCRIPTION
=
'UtopiaXC的个人开放平台'
;
const
KEY_WORDS
=
'UtopiaXC,开放平台,API,开源'
;
}
class
EnvKey
{
const
REDIS_USE
=
"REDIS_USE"
;
class
EnvKey
{
const
REDIS_USE
=
"REDIS_USE"
;
}
class
DatabaseDefault
{
const
USER_AVATAR
=
'/images/avatars/default_avatar.png'
;
const
NO_LOGIN_AVATAR
=
'/images/avatars/user_not_login.png'
;
}
database/migrations/2021_09_01_100110_create_users_profile.php
View file @
211f3cb6
...
...
@@ -17,7 +17,7 @@ class CreateUsersProfile extends Migration
$table
->
uuid
(
'id'
);
$table
->
string
(
'user_id'
);
$table
->
string
(
'user_nickname'
)
->
nullable
();;
$table
->
string
(
'user_avatar'
)
->
nullable
();;
$table
->
string
(
'user_avatar'
)
->
nullable
()
->
default
(
DatabaseDefault
::
USER_AVATAR
)
;;
$table
->
string
(
'user_sex'
)
->
nullable
();;
$table
->
date
(
'user_birthday'
)
->
nullable
();;
$table
->
string
(
'user_job'
)
->
nullable
();;
...
...
database/seeders/SiteProfileSeeder.php
View file @
211f3cb6
...
...
@@ -42,7 +42,35 @@ class SiteProfileSeeder extends Seeder
$site_profile
->
profile_content
=
\DefaultSiteProfile
::
WEB_FOOTER
;
$site_profile
->
save
();
//网站描述
$site_profile
=
new
SiteProfile
();
$site_profile
->
id
=
\Uuid
::
generate
();
$site_profile
->
profile_type
=
\SiteProfileTypeEnum
::
DESCRIPTION
;
$site_profile
->
profile_description
=
trans
(
'site_profile_description.'
.
\SiteProfileTypeEnum
::
DESCRIPTION
);
$site_profile
->
profile_content
=
\DefaultSiteProfile
::
DESCRIPTION
;
$site_profile
->
save
();
//网站作者
$site_profile
=
new
SiteProfile
();
$site_profile
->
id
=
\Uuid
::
generate
();
$site_profile
->
profile_type
=
\SiteProfileTypeEnum
::
AUTHOR
;
$site_profile
->
profile_description
=
trans
(
'site_profile_description.'
.
\SiteProfileTypeEnum
::
AUTHOR
);
$site_profile
->
profile_content
=
\DefaultSiteProfile
::
AUTHOR
;
$site_profile
->
save
();
//网站关键词
$site_profile
=
new
SiteProfile
();
$site_profile
->
id
=
\Uuid
::
generate
();
$site_profile
->
profile_type
=
\SiteProfileTypeEnum
::
KEY_WORDS
;
$site_profile
->
profile_description
=
trans
(
'site_profile_description.'
.
\SiteProfileTypeEnum
::
KEY_WORDS
);
$site_profile
->
profile_content
=
\DefaultSiteProfile
::
KEY_WORDS
;
$site_profile
->
save
();
}
catch
(
\Exception
$e
){
echo
$e
;
DB
::
rollBack
();
}
DB
::
commit
();
...
...
public/images/avatars/
profile-image
.png
→
public/images/avatars/
default_avatar
.png
View file @
211f3cb6
File moved
public/images/avatars/user_not_login.png
0 → 100644
View file @
211f3cb6
5.21 KB
resources/lang/zh_CN/site_profile_description.php
View file @
211f3cb6
...
...
@@ -3,4 +3,7 @@ return [
SiteProfileTypeEnum
::
WEB_TITLE
=>
'网站标题'
,
SiteProfileTypeEnum
::
SITE_URL
=>
'网站URL'
,
SiteProfileTypeEnum
::
WEB_FOOTER
=>
'网站版权注脚信息'
,
SiteProfileTypeEnum
::
KEY_WORDS
=>
'网站关键字'
,
SiteProfileTypeEnum
::
AUTHOR
=>
'网站作者'
,
SiteProfileTypeEnum
::
DESCRIPTION
=>
'网站描述'
,
];
resources/views/about.blade.php
0 → 100644
View file @
211f3cb6
@
extends
(
'root.app'
)
@
section
(
'title'
)
-
关于本站
@
endsection
@
section
(
'page_content'
)
<
div
class
="
row
">
<div class="
col
-
sm
-
12
col
-
xl
-
12
">
<div class="
card
">
<div class="
card
-
body
">
<h5 class="
card
-
title
">关于本站</h5>
</div>
</div>
</div>
</div>
@endsection
resources/views/email/register_verify.blade.php
View file @
211f3cb6
@
php
use
App\Http\Utils\RedisAndCache
;
$user
=
RedisAndCache
::
get
(
RedisCacheKey
::
REGISTER_VERIFY
.
request
()
->
get
(
"code"
));
if
(
!
$user
){
}
@
endphp
@
extends
(
'root.root'
)
@
section
(
'title'
)
-
注册验证
@
endsection
@
section
(
'body'
)
{{
$code
}}
@
endsection
resources/views/email/register_verify_link.blade.php
View file @
211f3cb6
...
...
@@ -52,7 +52,7 @@
font-size: 3em;
line-height: 1;
margin: 0 0 30px;"
>
欢迎注册
<br>
{{env('APP_SHOW_NAME','Utopia Open Platform')}}
</h2>
<p
style=
"width: 70%"
>
亲爱的 {{$user}}
<br>
您已成功注册{{env('APP_SHOW_NAME','Utopia Open Platform')}}
<p
style=
"width: 70%"
>
亲爱的 {{$user}}
<br>
您已成功注册
{{env('APP_SHOW_NAME','Utopia Open Platform')}}
的账户,请点击
<a
target=
"_blank"
href=
"{{$link}}"
>
验证链接
</a>
来激活您的账户功能。验证有效期十五分钟。
<br/><em>
如果您点击链接后未跳转,请将以下链接复制到浏览器访问:
<br>
{{$link}}
</em></p>
</div>
...
...
resources/views/index.blade.php
View file @
211f3cb6
@
php
$site_profile
=
app
(
'request'
)
->
get
(
HeaderKey
::
SITE_PROFILE
);
@
endphp
@
extends
(
'root.app'
)
@
section
(
'title'
)
-
主页
@
endsection
@
section
(
'description'
)
UtopiaXC的个人开放平台
@
endsection
@
section
(
'keywords'
)
UtopiaXC
,
开放平台
,
api
,
开源
@
endsection
@
section
(
'author'
)
UtopiaXC
@
endsection
@
section
(
'title'
)
-
主页
@
endsection
@
section
(
"page_content"
)
<
div
class
="
row
">
<div class="
col
-
md
-
6
col
-
xl
-
3
">
...
...
resources/views/login.blade.php
View file @
211f3cb6
@
extends
(
'root.root'
)
@
section
(
'title'
)
-
登录
@
endsection
@
section
(
'title'
)
-
登录
@
endsection
@
section
(
'body'
)
<
body
class
="
login
-
page
">
...
...
@@ -51,28 +51,13 @@
</div>
</div>
</div>
<div class="
modal
fade
" id="
alert
" tabindex="
-
1
" aria-labelledby="
alert
" aria-hidden="
true
">
<div class="
modal
-
dialog
">
<div class="
modal
-
content
">
<div class="
modal
-
header
">
<h5 class="
modal
-
title
" id="
alert_title
"></h5>
<button type="
button
" class="
btn
-
close
" data-bs-dismiss="
modal
" aria-label="
Close
"></button>
</div>
<div class="
modal
-
body
" id="
alert_content
"></div>
<div class="
modal
-
footer
">
<button type="
button
" class="
btn
btn
-
primary
" data-bs-dismiss="
modal
">确认</button>
</div>
</div>
</div>
</div>
<div class="
modal
fade
" id="
captcha_dialog
" tabindex="
-
1
" data-bs-backdrop="
static
" data-bs-keyboard="
false
"
aria-labelledby="
captcha
" aria-hidden="
true
">
<div class="
modal
-
dialog
">
<div class="
modal
-
content
">
<div class="
modal
-
header
">
<h5 class="
modal
-
title
" id="
captcha_title
">CAPTCHA 验证码</h5>
<button type="
button
" class="
btn
-
close
" data-bs-dismiss="
modal
" aria-label="
Close
"></button>
</div>
</div>
<div class="
modal
-
body
" id="
captcha_content
">
<div id="
captcha_process
" class="
progress
">
<div class="
progress
-
bar
progress
-
bar
-
striped
progress
-
bar
-
animated
" role="
progressbar
"
...
...
@@ -173,14 +158,5 @@
}
})
}
function
showAlert
(
title
,
content
)
{
let
alert
=
$
(
"#alert"
)
let
title_elem
=
$
(
"#alert_title"
)
let
content_elem
=
$
(
"#alert_content"
)
title_elem
.
html
(
title
)
content_elem
.
html
(
content
)
alert
.
modal
(
'show'
)
}
</
script
>
@
endsection
resources/views/open_source.blade.php
0 → 100644
View file @
211f3cb6
@
extends
(
'root.app'
)
@
section
(
'title'
)
-
开放源代码
@
endsection
@
section
(
'page_content'
)
<
div
class
="
row
">
<div class="
col
-
sm
-
12
col
-
xl
-
12
">
<div class="
card
">
<div class="
card
-
body
">
<h5 class="
card
-
title
">开放源代码</h5>
</div>
</div>
</div>
</div>
@endsection
resources/views/privacy_policy.blade.php
0 → 100644
View file @
211f3cb6
@
extends
(
'root.app'
)
@
section
(
'title'
)
-
隐私政策
@
endsection
@
section
(
'page_content'
)
<
div
class
="
row
">
<div class="
col
-
sm
-
12
col
-
xl
-
12
">
<div class="
card
">
<div class="
card
-
body
">
<h5 class="
card
-
title
">隐私政策</h5>
</div>
</div>
</div>
</div>
@endsection
resources/views/register.blade.php
View file @
211f3cb6
@
extends
(
'root.root'
)
@
section
(
'title'
)
-
注册
@
endsection
@
section
(
'title'
)
-
注册
@
endsection
@
section
(
'body'
)
<
body
class
="
login
-
page
">
...
...
@@ -98,7 +98,6 @@
<div class="
modal
-
content
">
<div class="
modal
-
header
">
<h5 class="
modal
-
title
" id="
captcha_title
">CAPTCHA 验证码</h5>
<button type="
button
" class="
btn
-
close
" data-bs-dismiss="
modal
" aria-label="
Close
"></button>
</div>
<div class="
modal
-
body
" id="
captcha_content
">
<div id="
captcha_process
" class="
progress
">
...
...
resources/views/root/page_header.blade.php
View file @
211f3cb6
@
php
$site_profile
=
app
(
'request'
)
->
get
(
HeaderKey
::
SITE_PROFILE
);
$site_profile
=
app
(
'request'
)
->
get
(
HeaderKey
::
SITE_PROFILE
);
$user_logged
=
app
(
'request'
)
->
get
(
HeaderKey
::
LOGIN_STATUS
);
$user
=
app
(
'request'
)
->
get
(
HeaderKey
::
USER_INFO
);
$user_profile
=
app
(
'request'
)
->
get
(
HeaderKey
::
USER_PROFILE
);
@
endphp
if
(
$user_logged
){
$user_avatar
=
'<li class="nav-item dropdown"><a class="nav-link profile-dropdown" href="#" id="profileDropDown"
role="button" data-bs-toggle="dropdown" aria-expanded="false"><img
src="'
.
$user_profile
[
"user_avatar"
]
.
'" alt=""></a>
<div class="dropdown-menu dropdown-menu-end profile-drop-menu"
aria-labelledby="profileDropDown">
<a class="dropdown-item" href="#"><i data-feather="user"></i>用户中心</a>
<a class="dropdown-item" href="#"><i data-feather="key"></i>OpenKey</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#"><i data-feather="settings"></i>用户设置</a>
<a class="dropdown-item" href="javascript:logout();"><i data-feather="log-out"></i>退出</a></div>
</li>'
;
}
else
{
$user_avatar
=
'<li class="nav-item dropdown"><a class="nav-link profile-dropdown" href="#" id="profileDropDown"
role="button" data-bs-toggle="dropdown" aria-expanded="false"><img
src="'
.
asset
(
DatabaseDefault
::
NO_LOGIN_AVATAR
)
.
'" alt=""></a>
<div class="dropdown-menu dropdown-menu-end profile-drop-menu"
aria-labelledby="profileDropDown">
<a class="dropdown-item" href="'
.
WebUrl
::
LOGIN
.
'"><i data-feather="key"></i>登录</a>
<a class="dropdown-item" href="'
.
WebUrl
::
REGISTER
.
'"><i data-feather="user"></i>注册</a>
<a class="dropdown-item" href="'
.
WebUrl
::
FIND_PASSWORD
.
'"><i data-feather="key"></i>忘记密码</a>
</li>'
;
}
@
endphp
{{
--
顶部工具栏
--
}}
...
...
@@ -12,12 +39,10 @@ $site_profile=app('request')->get(HeaderKey::SITE_PROFILE);
<ul class="
navbar
-
nav
" id="
leftNav
">
<li class="
nav
-
item
"><a class="
nav
-
link
" id="
sidebar
-
toggle
" href="
#"><i
data
-
feather
=
"menu"
></
i
></
a
></
li
>
<
li
class
="
nav
-
item
"><a class="
nav
-
link
" href="
/
">主页</a></li>
<li class="
nav
-
item
"><a class="
nav
-
link
" href="
#">API</a></li>
<
li
class
="
nav
-
item
"><a class="
nav
-
link
" href="
#">关于</a></li>
</
ul
>
</
div
>
<
div
><
a
href
=
"/"
style
=
"font-size: larger;color: gray"
>
UtopiaXC开放平台
</
a
></
div
>
<
div
><
a
href
=
"
{
{WebUrl::INDEX}
}
"
style
=
"font-size: larger;color: gray"
>
{{
$site_profile
[
SiteProfileTypeEnum
::
WEB_TITLE
]}}
</
a
></
div
>
<
div
class
=""
id
=
"headerNav"
>
<
ul
class
="
navbar
-
nav
">
<li class="
nav
-
item
dropdown
"><a class="
nav
-
link
search
-
dropdown
" href="
#" id="searchDropDown"
...
...
@@ -26,23 +51,12 @@ $site_profile=app('request')->get(HeaderKey::SITE_PROFILE);
<
div
class
="
dropdown
-
menu
dropdown
-
menu
-
end
dropdown
-
lg
search
-
drop
-
menu
"
aria-labelledby="
searchDropDown
">
<form>
<input class="
form
-
control
" type="
text
" placeholder="
Type
something
..
"
<input class="
form
-
control
" type="
text
" placeholder=""
aria-label="
Search
">
</form>
</div>
</li>
<li class="
nav
-
item
dropdown
"><a class="
nav
-
link
profile
-
dropdown
" href="
#" id="profileDropDown"
role
=
"button"
data
-
bs
-
toggle
=
"dropdown"
aria
-
expanded
=
"false"
><
img
src
=
"
{
{asset('/images/avatars/profile-image.png')}
}
"
alt
=
""
></
a
>
<
div
class
="
dropdown
-
menu
dropdown
-
menu
-
end
profile
-
drop
-
menu
"
aria-labelledby="
profileDropDown
">
<a class="
dropdown
-
item
" href="
#"><i data-feather="user"></i>用户中心</a>
<
a
class
="
dropdown
-
item
" href="
#"><i data-feather="key"></i>OpenKey</a>
<
a
class
="
dropdown
-
item
" href="
#"><i data-feather="sliders"></i>系统后台</a>
<
div
class
="
dropdown
-
divider
"></div>
<a class="
dropdown
-
item
" href="
#"><i data-feather="settings"></i>用户设置</a>
<
a
class
="
dropdown
-
item
" href="
#"><i data-feather="log-out"></i>退出</a></div>
</
li
>
{!!
$user_avatar
!!}
</ul>
</div>
</nav>
...
...
@@ -83,8 +97,8 @@ $site_profile=app('request')->get(HeaderKey::SITE_PROFILE);
</ul>
</li>
<li class="
sidebar
-
title
">关于</li>
<li><a href=""><i data-feather="
star
"></i>关于本站</a></li>
<li><a href=""><i data-feather="
shield
"></i>隐私权</a></li>
<li><a href=""><i data-feather="
git
-
commit
"></i>开放源代码</a></li>
<li><a href="
{{
WebUrl
::
ABOUT
}}
"><i data-feather="
star
"></i>关于本站</a></li>
<li><a href="
{{
WebUrl
::
PRIVACY_POLICY
}}
"><i data-feather="
shield
"></i>隐私权</a></li>
<li><a href="
{{
WebUrl
::
OPEN_SOURCE
}}
"><i data-feather="
git
-
commit
"></i>开放源代码</a></li>
</ul>
</div>
resources/views/root/root.blade.php
View file @
211f3cb6
@
php
$site_profile
=
app
(
'request'
)
->
get
(
HeaderKey
::
SITE_PROFILE
);
@
endphp
<!
DOCTYPE
html
>
<
html
lang
=
"{{ str_replace('_', '-', app()->getLocale()) }}"
>
<
head
>
<title>
UtopiaXC开放平台
@yield('title')
</title>
<
title
>
{{
$site_profile
[
SiteProfileTypeEnum
::
WEB_TITLE
]}}
@
yield
(
'title'
)
</
title
>
<
meta
charset
=
"utf-8"
>
<
meta
http
-
equiv
=
"X-UA-Compatible"
content
=
"IE=edge"
>
<
meta
name
=
"viewport"
content
=
"width=device-width, initial-scale=1"
>
...
...
resources/views/script/scripts.blade.php
View file @
211f3cb6
...
...
@@ -6,3 +6,64 @@
<script
src=
"{{asset('/plugins/perfectscroll/perfect-scrollbar.min.js')}}"
></script>
<script
src=
"{{asset('/plugins/apexcharts/apexcharts.min.js')}}"
></script>
<script
src=
"{{asset('/js/main.min.js')}}"
></script>
<script>
function
logout
()
{
$
(
"body"
).
append
(
'
\
<div class="modal fade" id="alert_logout" tabindex="-1" aria-labelledby="alert" aria-hidden="true">
\
<div class="modal-dialog">
\
<div class="modal-content">
\
<div class="modal-header">
\
<h5 class="modal-title" id="alert_title">确认退出?</h5>
\
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
\
</div>
\
<div class="modal-body" id="alert_content">您将在本浏览器上退出该账号,请确认您的操作</div>
\
<div class="modal-footer">
\
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
\
<button type="button" onclick="confirm_logout();" class="btn btn-primary" data-bs-dismiss="modal">确认</button>
\
</div>
\
</div>
\
</div>
\
</div>'
)
let
alert
=
$
(
"#alert_logout"
)
alert
.
modal
(
'show'
)
}
function
confirm_logout
(){
$
.
ajax
({
type
:
"PUT"
,
url
:
'{{ApiUrl::API.ApiUrl::USER.ApiUrl::LOGOUT}}'
,
dataType
:
"json"
,
success
:
function
(
result
)
{
if
(
result
.
code
===
200
)
{
window
.
location
=
"/"
;
}
else
{
showAlert
(
"抱歉"
,
"退出失败"
)
}
},
error
:
function
()
{
showAlert
(
"抱歉"
,
"退出失败"
)
}
});
}
function
showAlert
(
title
,
content
)
{
let
body
=
$
(
"body"
);
body
.
children
(
"#alert"
).
remove
()
body
.
append
(
'
\
<div class="modal fade" id="alert" tabindex="-1" aria-labelledby="alert" aria-hidden="true">
\
<div class="modal-dialog">
\
<div class="modal-content">
\
<div class="modal-header">
\
<h5 class="modal-title" id="alert_title">'
+
title
+
'</h5>
\
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
\
</div>
\
<div class="modal-body" id="alert_content">'
+
content
+
'</div>
\
<div class="modal-footer">
\
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">确认</button>
\
</div>
\
</div>
\
</div>
\
</div>'
)
let
alert
=
$
(
"#alert"
)
alert
.
modal
(
'show'
)
}
</script>
routes/api.php
View file @
211f3cb6
...
...
@@ -19,3 +19,4 @@ use Illuminate\Support\Facades\Route;
Route
::
get
(
ApiUrl
::
CAPTCHA
,[
CaptchaController
::
class
,
"getCaptcha"
]);
Route
::
post
(
ApiUrl
::
USER
.
ApiUrl
::
REGISTER
,
[
UserController
::
class
,
"register"
]);
Route
::
post
(
ApiUrl
::
USER
.
ApiUrl
::
LOGIN
,[
UserController
::
class
,
"login"
]);
Route
::
put
(
ApiUrl
::
USER
.
ApiUrl
::
LOGOUT
,[
UserController
::
class
,
"logout"
]);
routes/web.php
View file @
211f3cb6
...
...
@@ -14,16 +14,26 @@ use Illuminate\Support\Facades\Route;
*/
Route
::
group
([
'prefix'
=>
'/'
,
'middleware'
=>
[
Middleware
::
SITE_PROFILE_MIDDLEWARE
,
Middleware
::
AUTH_MIDDLEWARE
]],
function
()
{
Route
::
get
(
'/'
,
function
()
{
Route
::
get
(
WebUrl
::
INDEX
,
function
()
{
return
view
(
'index'
);
});
Route
::
get
(
"/login"
,
function
()
{
Route
::
get
(
WebUrl
::
LOGIN
,
function
()
{
return
view
(
'login'
);
});
Route
::
get
(
"/register"
,
function
()
{
Route
::
get
(
WebUrl
::
REGISTER
,
function
()
{
return
view
(
'register'
);
});
Route
::
get
(
"/register_verify/
{
code
}
"
,
function
(
$code
)
{
Route
::
get
(
WebUrl
::
REGISTER_VERIFY
.
"/
{
code
}
"
,
function
(
$code
)
{
request
()
->
attributes
->
add
([
"code"
=>
$code
]);
return
view
(
'email.register_verify'
)
->
with
(
"code"
,
$code
);
});
Route
::
get
(
WebUrl
::
ABOUT
,
function
(){
return
view
(
'about'
);
});
Route
::
get
(
WebUrl
::
PRIVACY_POLICY
,
function
(){
return
view
(
'privacy_policy'
);
});
Route
::
get
(
WebUrl
::
OPEN_SOURCE
,
function
(){
return
view
(
'open_source'
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment