From df0830a2ad28394f39444d5f28aa81c2517845c2 Mon Sep 17 00:00:00 2001 From: Cx330 <1487537121@qq.com> Date: Sat, 5 Apr 2025 22:17:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=95=8C=E9=9D=A2=E4=B8=BA?= =?UTF-8?q?=E5=B7=A6=E5=8F=B3=E5=B8=83=E5=B1=80=E3=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E6=A1=86=E6=A0=B7=E5=BC=8F=E3=80=81=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=83=A8=E5=88=86=E5=8A=A8=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/body.css | 55 ++++++++++++++++----------- css/chat.css | 85 +++++++++++++++++++++++++++++++++++------- css/max_width.css | 37 ++++++++++++++++++ css/time.css | 16 ++++++++ index.html | 68 ++++++++++++++++++++++----------- javascape/ai_api.js | 10 +---- javascape/chat.js | 43 +++++++++++++++++++++ javascape/max_width.js | 10 +++++ javascape/time.js | 23 ++++++++++-- 9 files changed, 279 insertions(+), 68 deletions(-) create mode 100644 css/time.css create mode 100644 javascape/chat.js create mode 100644 javascape/max_width.js diff --git a/css/body.css b/css/body.css index a04685c..4e457a5 100644 --- a/css/body.css +++ b/css/body.css @@ -1,32 +1,43 @@ -/* 基本样式重置 */ -body, html { +body { margin: 0; - padding: 0; - 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 + font-family: "Arial", sans-serif; } -ul { - padding-left: 20px; +.main-layout { + display: flex; + flex-direction: row; + height: calc(100vh - 100px); + padding-bottom: 100px; } - ul li { - line-height: 2.3 - } +.left-panel, .right-panel { + width: 50%; + display: flex; + justify-content: center; /* 水平居中 */ + align-items: center; /* 垂直居中 */ + flex-direction: column; /* 内容垂直排列 */ + padding: 20px; + box-sizing: border-box; + height: 100%; +} -a { - color: #20a53a +.logo { + margin-top: 40px; + font-size: 32px; +} + +.intro a { + display: block; + margin: 5px 0; } .logo { font-family: 'Pacifico', cursive; -} \ No newline at end of file +} + +/* 默认隐藏 */ +.mobile-toggle { + display: none; + margin: 10px; + text-align: center; +} diff --git a/css/chat.css b/css/chat.css index dee71db..616e0e3 100644 --- a/css/chat.css +++ b/css/chat.css @@ -1,27 +1,84 @@ -/* 简单样式,仅用于展示 */ -#chatContainer { - border: 1px solid #ccc; +.chat-container { + position: fixed; + bottom: 50px; + left: 0; + width: 100%; + background: #fff; 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; + background: #f5f5f5; margin-bottom: 10px; + padding: 10px; + border-radius: 8px; + position: relative; + z-index: 10; } -.message { - margin: 5px 0; - padding: 5px; +.chat-box.show { + animation: slideUp 0.3s ease-out forwards; } -.user { - color: blue; - text-align: right; +.chat-box.hide { + animation: slideDown 0.3s ease-in forwards; } -.bot { - color: green; - text-align: left; + +.input-row { + display: flex; + justify-content: center; + width: 90%; + gap: 10px; } #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; + } +} \ No newline at end of file diff --git a/css/max_width.css b/css/max_width.css index e69de29..a715c97 100644 --- a/css/max_width.css +++ b/css/max_width.css @@ -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; + } +} \ No newline at end of file diff --git a/css/time.css b/css/time.css new file mode 100644 index 0000000..f8ce5d5 --- /dev/null +++ b/css/time.css @@ -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; +} \ No newline at end of file diff --git a/index.html b/index.html index f441e21..75eff51 100644 --- a/index.html +++ b/index.html @@ -8,38 +8,64 @@ + + - -
-

DreamLife

-

这是我的网站首页,主页代码正在完善中

- +
+ +
+

DreamLife

+
+

这是我的网站首页,主页代码正在完善中

+
    +
  • 此网站将用于个人经历展示,个人技术分析
  • +
  • 目前网站工具箱以基本完善
  • +
  • 工具箱网站dreamlife.top/toolbox
  • +
+ ToolBox + 博客|WordPress + Gitea +
+
- ToolBox - 博客|WordPress - Gitea - -

您的当前区域时间

-

加载中...

- -

DeepSeek 聊天界面

-
- - + +
+
+
--:--:--
+
加载中...
+
+
+

此处预留未来内容

+
+
- + + +
+ + +
+ + +
+
+ +
+ + +
+
+ + + \ No newline at end of file diff --git a/javascape/ai_api.js b/javascape/ai_api.js index 65c1d88..2bd09a2 100644 --- a/javascape/ai_api.js +++ b/javascape/ai_api.js @@ -1,3 +1,4 @@ +// Ai模型接口 const API_KEY = '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'; const API_URL = 'https://openrouter.ai/api/v1/chat/completions'; let messages = []; @@ -47,11 +48,4 @@ async function sendMessage() { console.error('请求错误:', error); appendMessage('请求出错:' + error.message, 'bot'); } -} - -// 监听回车键事件 -document.getElementById('userInput').addEventListener('keydown', function(event) { - if (event.key === 'Enter') { - sendMessage(); - } -}); \ No newline at end of file +} \ No newline at end of file diff --git a/javascape/chat.js b/javascape/chat.js new file mode 100644 index 0000000..3a727a2 --- /dev/null +++ b/javascape/chat.js @@ -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); + } +} \ No newline at end of file diff --git a/javascape/max_width.js b/javascape/max_width.js new file mode 100644 index 0000000..05a0145 --- /dev/null +++ b/javascape/max_width.js @@ -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'; +} \ No newline at end of file diff --git a/javascape/time.js b/javascape/time.js index 7b748d3..f767d87 100644 --- a/javascape/time.js +++ b/javascape/time.js @@ -1,9 +1,26 @@ //获取计算机的时间信息 function updateLocalTime() { const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; - const now = new Date().toLocaleString('zh-CN', { timeZone: timezone }); - document.getElementById('timeDisplay').innerText = `当前时间 (${timezone}): ${now}`; + const now = new Date(); + + // 获取时间(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; \ No newline at end of file