做文章中心
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php /*a:4:{s:49:"E:\Demo\PHP\yunzer\app\index\view\index\index.php";i:1746890051;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\header.php";i:1748280591;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\main.php";i:1747748380;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;}*/ ?>
|
||||
<?php /*a:4:{s:49:"E:\Demo\PHP\yunzer\app\index\view\index\index.php";i:1746890051;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\header.php";i:1748341037;s:52:"E:\Demo\PHP\yunzer\app\index\view\component\main.php";i:1748359853;s:54:"E:\Demo\PHP\yunzer\app\index\view\component\footer.php";i:1747649140;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@@ -19,21 +19,21 @@
|
||||
<?php
|
||||
// 获取当前登录状态
|
||||
$isLoggedIn = false;
|
||||
$userInfo = [
|
||||
'is_login' => false,
|
||||
'name' => '',
|
||||
'avatar' => '/static/images/avatar.png' // 默认头像
|
||||
];
|
||||
|
||||
// 检查session
|
||||
if (session('user_id')) {
|
||||
// 检查cookie
|
||||
$userAccount = cookie('user_account');
|
||||
if ($userAccount) {
|
||||
$isLoggedIn = true;
|
||||
}
|
||||
// 如果session未登录,检查cookie
|
||||
else {
|
||||
$userAccount = cookie('user_account');
|
||||
if ($userAccount) {
|
||||
// 恢复session
|
||||
session('user_id', cookie('user_id'));
|
||||
session('user_name', cookie('user_name'));
|
||||
session('user_avatar', cookie('user_avatar'));
|
||||
$isLoggedIn = true;
|
||||
}
|
||||
$userInfo = [
|
||||
'is_login' => true,
|
||||
'name' => cookie('user_name'),
|
||||
'avatar' => cookie('user_avatar') ? cookie('user_avatar') : '/static/images/avatar.png'
|
||||
];
|
||||
}
|
||||
|
||||
// 添加一个隐藏的div来存储登录状态
|
||||
@@ -41,18 +41,10 @@ $loginStatus = [
|
||||
'isLoggedIn' => $isLoggedIn,
|
||||
'userAccount' => $userAccount ?? ''
|
||||
];
|
||||
|
||||
$userInfo = [
|
||||
'is_login' => $isLoggedIn,
|
||||
'name' => session('user_name'),
|
||||
'avatar' => session('user_avatar') ? '/static/uploads/avatar/' . session('user_avatar') : '/static/images/avatar.png'
|
||||
];
|
||||
?>
|
||||
|
||||
<!-- 添加一个隐藏的div来存储登录状态 -->
|
||||
<div id="loginStatus" style="display: none;"
|
||||
data-is-logged-in="<?php echo htmlentities((string) $isLoggedIn); ?>"
|
||||
data-user-account="<?php echo isset($userAccount) ? htmlentities((string) $userAccount) : ''; ?>">
|
||||
<div id="loginStatus" style="display: none;" data-is-logged-in="<?php echo htmlentities((string) $isLoggedIn); ?>" data-user-account="<?php echo isset($userAccount) ? htmlentities((string) $userAccount) : ''; ?>">
|
||||
</div>
|
||||
|
||||
<div style="display: flex;flex-direction: column;">
|
||||
@@ -94,10 +86,15 @@ $userInfo = [
|
||||
</ul>
|
||||
</div>
|
||||
<div class="main-menu__right">
|
||||
<div class="username">
|
||||
<?php if ($userInfo['is_login']): ?>
|
||||
<span class="username-text"><?php echo htmlentities((string) $userInfo['name']); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<!-- 根据登录状态显示不同的内容 -->
|
||||
<?php if ($userInfo['is_login']): ?>
|
||||
<div class="layui-inline" style="position: relative;">
|
||||
<div class="layui-inline" style="position: relative;margin-left:20px;">
|
||||
<img src="<?php echo htmlentities((string) $userInfo['avatar']); ?>" class="layui-circle"
|
||||
style="width: 40px; height: 40px; cursor: pointer;" id="userAvatarMain">
|
||||
<div class="user-dropdown" id="userDropdownMain">
|
||||
@@ -160,7 +157,7 @@ $userInfo = [
|
||||
<div class="layui-inline">
|
||||
<!-- 根据登录状态显示不同的内容 -->
|
||||
<?php if ($userInfo['is_login']): ?>
|
||||
<div class="layui-inline" style="position: relative;">
|
||||
<div class="layui-inline" style="position: relative;margin-left:20px;">
|
||||
<img src="<?php echo htmlentities((string) $userInfo['avatar']); ?>" class="layui-circle"
|
||||
style="width: 40px; height: 40px; cursor: pointer;" id="userAvatarSticky">
|
||||
<div class="user-dropdown" id="userDropdownSticky">
|
||||
@@ -391,11 +388,21 @@ $userInfo = [
|
||||
#test10 [carousel-item]>* {
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
.main-menu__right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.username {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// 在页面加载时立即执行
|
||||
(function() {
|
||||
(function () {
|
||||
// 检查是否已经刷新过
|
||||
if (sessionStorage.getItem('has_refreshed') === 'true') {
|
||||
return;
|
||||
@@ -406,16 +413,16 @@ $userInfo = [
|
||||
if (userAccount) {
|
||||
// 同步到cookie
|
||||
document.cookie = "user_account=" + userAccount + "; path=/";
|
||||
|
||||
|
||||
// 如果有其他必要的数据,也同步到cookie
|
||||
var userId = localStorage.getItem('user_id');
|
||||
var userName = localStorage.getItem('user_name');
|
||||
var userAvatar = localStorage.getItem('user_avatar');
|
||||
|
||||
|
||||
if (userId) document.cookie = "user_id=" + userId + "; path=/";
|
||||
if (userName) document.cookie = "user_name=" + userName + "; path=/";
|
||||
if (userAvatar) document.cookie = "user_avatar=" + userAvatar + "; path=/";
|
||||
|
||||
|
||||
// 刷新页面以应用新的cookie,并标记已刷新
|
||||
if (!document.cookie.includes('user_id')) {
|
||||
sessionStorage.setItem('has_refreshed', 'true');
|
||||
@@ -656,10 +663,18 @@ $userInfo = [
|
||||
time: 2000,
|
||||
shade: 0.3
|
||||
}, function () {
|
||||
// 强制刷新页面,不使用缓存
|
||||
window.location.href = window.location.href + '?t=' + new Date().getTime();
|
||||
// 获取当前页面URL,如果是从其他页面跳转来的,则返回上一页
|
||||
var currentUrl = window.location.href;
|
||||
var referrer = document.referrer;
|
||||
|
||||
// 如果是从登录页面跳转来的,则返回上一页
|
||||
if (referrer && referrer.includes('/index/user/login')) {
|
||||
window.location.href = referrer;
|
||||
} else {
|
||||
// 否则刷新当前页面
|
||||
window.location.href = currentUrl + '?t=' + new Date().getTime();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.msg, {
|
||||
icon: 2,
|
||||
time: 2000
|
||||
@@ -687,7 +702,7 @@ $userInfo = [
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-btn">更多</div>
|
||||
<div class="more-btn" onclick="window.open('/index/articles/index?cateid=1', '_blank')">更多</div>
|
||||
</div>
|
||||
<div class="product-list" id="webArticlesList">
|
||||
<!-- 文章将通过JavaScript动态加载 -->
|
||||
@@ -708,7 +723,7 @@ $userInfo = [
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-btn">更多</div>
|
||||
<div class="more-btn" onclick="window.open('/index/articles/index?cateid=3', '_blank')">更多</div>
|
||||
</div>
|
||||
<div class="product-list" id="techArticlesList">
|
||||
<!-- 文章将通过JavaScript动态加载 -->
|
||||
@@ -729,7 +744,7 @@ $userInfo = [
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-btn">更多</div>
|
||||
<div class="more-btn" onclick="window.open('/index/program/index?cateid=2', '_blank')">更多</div>
|
||||
</div>
|
||||
<div class="product-list" id="resourcesDownloadList">
|
||||
<!-- 文章将通过JavaScript动态加载 -->
|
||||
@@ -750,7 +765,7 @@ $userInfo = [
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-btn">更多</div>
|
||||
<div class="more-btn" onclick="window.open('/index/program/index?cateid=1', '_blank')">更多</div>
|
||||
</div>
|
||||
<div class="product-list" id="programDownloadList">
|
||||
<!-- 程序将通过JavaScript动态加载 -->
|
||||
@@ -771,7 +786,7 @@ $userInfo = [
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="more-btn">更多</div>
|
||||
<div class="more-btn" onclick="window.open('/index/game/index?cateid=8', '_blank')">更多</div>
|
||||
</div>
|
||||
<div class="product-list" id="gameDownloadList">
|
||||
<!-- 游戏将通过JavaScript动态加载 -->
|
||||
|
||||
Reference in New Issue
Block a user