修改界面为左右布局、修改聊天框样式、添加部分动效
This commit is contained in:
parent
0ff8fc158f
commit
df0830a2ad
55
css/body.css
55
css/body.css
@ -1,32 +1,43 @@
|
|||||||
/* 基本样式重置 */
|
body {
|
||||||
body, html {
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
font-family: "Arial", sans-serif;
|
||||||
font-family: Arial, sans-serif; /* 默认字体 */
|
|
||||||
background-color:#f4f4f4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*主内容区test*/
|
|
||||||
.container {
|
|
||||||
width: 60%;
|
|
||||||
margin: 4% auto 0;
|
|
||||||
background-color: #f0f0f0;
|
|
||||||
padding: 2% 5%;
|
|
||||||
border-radius: 10px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
.main-layout {
|
||||||
padding-left: 20px;
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
height: calc(100vh - 100px);
|
||||||
|
padding-bottom: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul li {
|
.left-panel, .right-panel {
|
||||||
line-height: 2.3
|
width: 50%;
|
||||||
}
|
display: flex;
|
||||||
|
justify-content: center; /* 水平居中 */
|
||||||
|
align-items: center; /* 垂直居中 */
|
||||||
|
flex-direction: column; /* 内容垂直排列 */
|
||||||
|
padding: 20px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
.logo {
|
||||||
color: #20a53a
|
margin-top: 40px;
|
||||||
|
font-size: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.intro a {
|
||||||
|
display: block;
|
||||||
|
margin: 5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
font-family: 'Pacifico', cursive;
|
font-family: 'Pacifico', cursive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 默认隐藏 */
|
||||||
|
.mobile-toggle {
|
||||||
|
display: none;
|
||||||
|
margin: 10px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
85
css/chat.css
85
css/chat.css
@ -1,27 +1,84 @@
|
|||||||
/* 简单样式,仅用于展示 */
|
.chat-container {
|
||||||
#chatContainer {
|
position: fixed;
|
||||||
border: 1px solid #ccc;
|
bottom: 50px;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
background: #fff;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
height: 50px;
|
box-shadow: 0 -2px 5px #fff;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-box {
|
||||||
|
width: 90%;
|
||||||
|
max-height: 50vh;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
background: #f5f5f5;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
position: relative;
|
||||||
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message {
|
.chat-box.show {
|
||||||
margin: 5px 0;
|
animation: slideUp 0.3s ease-out forwards;
|
||||||
padding: 5px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.user {
|
.chat-box.hide {
|
||||||
color: blue;
|
animation: slideDown 0.3s ease-in forwards;
|
||||||
text-align: right;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bot {
|
|
||||||
color: green;
|
.input-row {
|
||||||
text-align: left;
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
width: 90%;
|
||||||
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#userInput {
|
#userInput {
|
||||||
width: 93%;
|
flex: 1;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 16px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
padding: 10px 16px;
|
||||||
|
font-size: 16px;
|
||||||
|
border: none;
|
||||||
|
background-color: #007BFF;
|
||||||
|
color: white;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background-color: #0056b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slideUp {
|
||||||
|
from {
|
||||||
|
transform: translateY(100%);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateY(0);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slideDown {
|
||||||
|
from {
|
||||||
|
transform: translateY(0);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateY(100%);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
@media screen and (max-width: 768px) {
|
||||||
|
.main-layout {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-panel, .right-panel {
|
||||||
|
width: 100%;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-container {
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
padding-bottom: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-toggle {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-toggle button {
|
||||||
|
margin: 0 5px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
font-size: 14px;
|
||||||
|
border: none;
|
||||||
|
background-color: #007BFF;
|
||||||
|
color: white;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-toggle button:hover {
|
||||||
|
background-color: #0056b3;
|
||||||
|
}
|
||||||
|
}
|
16
css/time.css
Normal file
16
css/time.css
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
.datetime {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time {
|
||||||
|
font-size: 36px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #666;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
68
index.html
68
index.html
@ -8,38 +8,64 @@
|
|||||||
<link rel="stylesheet" href="css/body.css">
|
<link rel="stylesheet" href="css/body.css">
|
||||||
<link rel="stylesheet" href="css/chat.css">
|
<link rel="stylesheet" href="css/chat.css">
|
||||||
<link rel="stylesheet" href="css/font.css">
|
<link rel="stylesheet" href="css/font.css">
|
||||||
|
<link rel="stylesheet" href="css/time.css">
|
||||||
|
<link rel="stylesheet" href="css/max_width.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div class="main-layout">
|
||||||
<div class="container">
|
<!-- 左侧内容 -->
|
||||||
<h1 class="logo">DreamLife</h1>
|
<div class="left-panel">
|
||||||
<h3>这是我的网站首页,主页代码正在完善中</h3>
|
<h1 class="logo">DreamLife</h1>
|
||||||
<ul>
|
<div class="intro">
|
||||||
<li>此网站将用于个人经历展示,个人技术分析</li>
|
<h3>这是我的网站首页,主页代码正在完善中</h3>
|
||||||
<li>目前网站工具箱以基本完善</li>
|
<ul>
|
||||||
<li>工具箱网站dreamlife.top/toolbox</li>
|
<li>此网站将用于个人经历展示,个人技术分析</li>
|
||||||
</ul>
|
<li>目前网站工具箱以基本完善</li>
|
||||||
|
<li>工具箱网站dreamlife.top/toolbox</li>
|
||||||
|
</ul>
|
||||||
|
<a href="http://dreamlife.top/toolbox/">ToolBox</a>
|
||||||
|
<a href="http://dreamlife.top:8080/">博客|WordPress</a>
|
||||||
|
<a href="http://dreamlife.top:13000/explore/">Gitea</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<a href="http://dreamlife.top/toolbox/">ToolBox</a>
|
<!-- 右侧内容 -->
|
||||||
<a href="http://dreamlife.top:8080/">博客|WordPress</a>
|
<div class="right-panel">
|
||||||
<a href="http://dreamlife.top:13000/explore/">Gitea</a>
|
<div class="datetime">
|
||||||
|
<div id="timeDisplay" class="time">--:--:--</div>
|
||||||
<h2>您的当前区域时间</h2>
|
<div id="dateDisplay" class="date">加载中...</div>
|
||||||
<p id="timeDisplay">加载中...</p>
|
</div>
|
||||||
|
<div class="future-content">
|
||||||
<h1>DeepSeek 聊天界面</h1>
|
<p>此处预留未来内容</p>
|
||||||
<div id="chatContainer"></div>
|
</div>
|
||||||
<input type="text" id="userInput" placeholder="输入你的消息...">
|
</div>
|
||||||
<button onclick="sendMessage()">发送</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 移动端切换按钮 -->
|
||||||
|
<div class="mobile-toggle">
|
||||||
|
<button onclick="showLeft()">显示左侧</button>
|
||||||
|
<button onclick="showRight()">显示右侧</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- DeepSeek 聊天输入 -->
|
||||||
|
<div class="chat-container">
|
||||||
|
<div id="chatContainer" class="chat-box hide"></div>
|
||||||
|
|
||||||
|
<div class="input-row">
|
||||||
|
<input type="text" id="userInput" placeholder="输入你的消息..." onfocus="toggleChat(true)">
|
||||||
|
<button onclick="sendMessage()">发送</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<p>© 2025 DreamLife 版权所有</p>
|
<p>© 2025 DreamLife 版权所有</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="javascape/time.js"></script>
|
<script src="javascape/time.js"></script>
|
||||||
<script src="javascape/ai_api.js"></script>
|
<script src="javascape/ai_api.js"></script>
|
||||||
|
<script src="javascape/chat.js"></script>
|
||||||
|
<script src="javascape/max_width.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -1,3 +1,4 @@
|
|||||||
|
// Ai模型接口
|
||||||
const API_KEY = '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';
|
const API_KEY = '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';
|
||||||
const API_URL = 'https://openrouter.ai/api/v1/chat/completions';
|
const API_URL = 'https://openrouter.ai/api/v1/chat/completions';
|
||||||
let messages = [];
|
let messages = [];
|
||||||
@ -47,11 +48,4 @@ async function sendMessage() {
|
|||||||
console.error('请求错误:', error);
|
console.error('请求错误:', error);
|
||||||
appendMessage('请求出错:' + error.message, 'bot');
|
appendMessage('请求出错:' + error.message, 'bot');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听回车键事件
|
|
||||||
document.getElementById('userInput').addEventListener('keydown', function(event) {
|
|
||||||
if (event.key === 'Enter') {
|
|
||||||
sendMessage();
|
|
||||||
}
|
|
||||||
});
|
|
43
javascape/chat.js
Normal file
43
javascape/chat.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// 监听回车键事件
|
||||||
|
document.getElementById('userInput').addEventListener('keydown', function(event) {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
sendMessage();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 控制聊天框显示和隐藏
|
||||||
|
function toggleChat(show) {
|
||||||
|
const chatBox = document.getElementById('chatContainer');
|
||||||
|
|
||||||
|
if (show) {
|
||||||
|
// 如果已经显示就不重复处理
|
||||||
|
if (chatBox.classList.contains('show')) return;
|
||||||
|
|
||||||
|
chatBox.style.display = 'block'; // 确保先显示再动画
|
||||||
|
chatBox.classList.remove('hide');
|
||||||
|
chatBox.classList.add('show');
|
||||||
|
|
||||||
|
document.addEventListener('click', outsideClickListener);
|
||||||
|
} else {
|
||||||
|
if (!chatBox.classList.contains('show')) return;
|
||||||
|
|
||||||
|
chatBox.classList.remove('show');
|
||||||
|
chatBox.classList.add('hide');
|
||||||
|
|
||||||
|
chatBox.addEventListener('animationend', function handler() {
|
||||||
|
chatBox.style.display = 'none';
|
||||||
|
chatBox.removeEventListener('animationend', handler);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.removeEventListener('click', outsideClickListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function outsideClickListener(event) {
|
||||||
|
const chatBox = document.getElementById('chatContainer');
|
||||||
|
const inputBox = document.getElementById('userInput');
|
||||||
|
|
||||||
|
if (!chatBox.contains(event.target) && !inputBox.contains(event.target)) {
|
||||||
|
toggleChat(false);
|
||||||
|
}
|
||||||
|
}
|
10
javascape/max_width.js
Normal file
10
javascape/max_width.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// 移动端切换
|
||||||
|
function showLeft() {
|
||||||
|
document.querySelector('.left-panel').style.display = 'block';
|
||||||
|
document.querySelector('.right-panel').style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
function showRight() {
|
||||||
|
document.querySelector('.right-panel').style.display = 'block';
|
||||||
|
document.querySelector('.left-panel').style.display = 'none';
|
||||||
|
}
|
@ -1,9 +1,26 @@
|
|||||||
//获取计算机的时间信息
|
//获取计算机的时间信息
|
||||||
function updateLocalTime() {
|
function updateLocalTime() {
|
||||||
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||||
const now = new Date().toLocaleString('zh-CN', { timeZone: timezone });
|
const now = new Date();
|
||||||
document.getElementById('timeDisplay').innerText = `当前时间 (${timezone}): ${now}`;
|
|
||||||
|
// 获取时间(24小时制)
|
||||||
|
const timeStr = now.toLocaleTimeString('zh-CN', {
|
||||||
|
timeZone: timezone,
|
||||||
|
hour12: false
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取日期
|
||||||
|
const dateStr = now.toLocaleDateString('zh-CN', {
|
||||||
|
timeZone: timezone,
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric',
|
||||||
|
weekday: 'long'
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('timeDisplay').innerText = timeStr;
|
||||||
|
document.getElementById('dateDisplay').innerText = dateStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(updateLocalTime, 1000); // 每秒更新时间
|
setInterval(updateLocalTime, 1000);
|
||||||
window.onload = updateLocalTime;
|
window.onload = updateLocalTime;
|
Loading…
x
Reference in New Issue
Block a user