-
-
关于
+
+
@@ -1400,28 +1449,67 @@ function renderProfilePage() {
}
function bindProfilePageEvents() {
- // 登录按钮
- const loginBtn = document.getElementById('loginBtn');
- if (loginBtn) {
- loginBtn.addEventListener('click', () => {
+ // 用户卡片点击(已登录用户进入编辑页面)
+ const userCard = document.getElementById('userCard');
+ if (userCard && currentUser) {
+ userCard.addEventListener('click', () => {
+ showEditProfilePage();
+ });
+ }
+
+ // 小登录按钮
+ const loginBtnSmall = document.getElementById('loginBtnSmall');
+ if (loginBtnSmall) {
+ loginBtnSmall.addEventListener('click', () => {
showLoginPage();
});
}
- // 注册按钮
- const registerBtn = document.getElementById('registerBtn');
- if (registerBtn) {
- registerBtn.addEventListener('click', () => {
+ // 小注册按钮
+ const registerBtnSmall = document.getElementById('registerBtnSmall');
+ if (registerBtnSmall) {
+ registerBtnSmall.addEventListener('click', () => {
showRegisterPage();
});
}
- // 跳过按钮(游客模式)
- const skipBtn = document.getElementById('skipBtn');
- if (skipBtn) {
- skipBtn.addEventListener('click', () => {
- showToast('以游客模式继续使用');
- switchPage('chats');
+ // 用户编辑按钮
+ const editProfileBtn = document.getElementById('editProfileBtn');
+ if (editProfileBtn) {
+ editProfileBtn.addEventListener('click', () => {
+ showEditProfilePage();
+ });
+ }
+
+ // 消息通知按钮
+ const notificationBtn = document.getElementById('notificationBtn');
+ if (notificationBtn) {
+ notificationBtn.addEventListener('click', () => {
+ showNotificationPage();
+ });
+ }
+
+ // 隐私安全按钮
+ const privacyBtn = document.getElementById('privacyBtn');
+ if (privacyBtn) {
+ privacyBtn.addEventListener('click', () => {
+ showPrivacyPage();
+ });
+ }
+
+ // 帮助与反馈按钮
+ const helpBtn = document.getElementById('helpBtn');
+ if (helpBtn) {
+ helpBtn.addEventListener('click', () => {
+ showHelpPage();
+ });
+ }
+
+ // 关于按钮
+ const aboutBtn = document.getElementById('aboutBtn');
+ if (aboutBtn) {
+ aboutBtn.addEventListener('click', () => {
+ showAboutPage();
});
}
@@ -1454,6 +1542,767 @@ function bindProfilePageEvents() {
}
}
+// ==================== 用户编辑页面 ====================
+
+function showEditProfilePage() {
+ if (!currentUser) {
+ showToast('请先登录');
+ return;
+ }
+
+ // 获取完整用户信息
+ const users = JSON.parse(localStorage.getItem('registeredUsers') || '[]');
+ const fullUser = users.find(u => u.username === currentUser.username);
+
+ const avatar = currentUser.avatar || '👤';
+ const signature = currentUser.signature || '';
+ const phone = fullUser?.phone || '';
+ const email = fullUser?.email || '';
+ const gender = currentUser.gender || '';
+ const age = currentUser.age || '';
+ const region = currentUser.region || '';
+
+ const editHtml = `
+
+
+
+
+
+
+
+
+ ${['👤', '😊', '😎', '🤓', '🧑', '👨', '👩', '🧒', '👴', '👵', '🦸', '🧙', '🤖', '👽', '🥷'].map(a => `
+
${a}
+ `).join('')}
+
+
+
+
+
+
基本信息
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
个人资料
+
+
+
+
+ 不可修改
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `;
+
+ appContainer.innerHTML = editHtml;
+
+ // 绑定返回按钮
+ const backBtn = document.getElementById('editBackBtn');
+ if (backBtn) {
+ backBtn.addEventListener('click', () => {
+ switchPage('profile');
+ });
+ }
+
+ // 绑定头像选择
+ document.querySelectorAll('.avatar-option').forEach(option => {
+ option.addEventListener('click', () => {
+ const newAvatar = option.getAttribute('data-avatar');
+ document.getElementById('editAvatarPreview').textContent = newAvatar;
+ document.querySelectorAll('.avatar-option').forEach(o => o.classList.remove('selected'));
+ option.classList.add('selected');
+ });
+ });
+
+ // 绑定性别选择
+ document.querySelectorAll('.gender-option').forEach(option => {
+ option.addEventListener('click', () => {
+ document.querySelectorAll('.gender-option').forEach(o => o.classList.remove('selected'));
+ option.classList.add('selected');
+ });
+ });
+
+ // 绑定保存按钮
+ const saveBtn = document.getElementById('saveProfileBtn');
+ if (saveBtn) {
+ saveBtn.addEventListener('click', handleSaveProfile);
+ }
+}
+
+function handleSaveProfile() {
+ const newAvatar = document.querySelector('.avatar-option.selected')?.getAttribute('data-avatar') || '👤';
+ const newUsername = document.getElementById('editUsername')?.value.trim();
+ const newSignature = document.getElementById('editSignature')?.value.trim();
+ const newEmail = document.getElementById('editEmail')?.value.trim();
+ const newGender = document.querySelector('.gender-option.selected')?.getAttribute('data-gender') || '';
+ const newAge = document.getElementById('editAge')?.value;
+ const newRegion = document.getElementById('editRegion')?.value.trim();
+
+ // 验证用户名
+ if (!newUsername || newUsername.length < 3 || newUsername.length > 20) {
+ showToast('用户名需要3-20个字符');
+ return;
+ }
+
+ // 验证邮箱
+ if (newEmail && !validateEmail(newEmail)) {
+ showToast('请输入正确的邮箱格式');
+ return;
+ }
+
+ // 验证年龄
+ if (newAge && (parseInt(newAge) < 1 || parseInt(newAge) > 120)) {
+ showToast('年龄需要在1-120之间');
+ return;
+ }
+
+ // 检查用户名是否被其他人占用
+ const users = JSON.parse(localStorage.getItem('registeredUsers') || '[]');
+ if (newUsername !== currentUser.username) {
+ if (users.find(u => u.username === newUsername)) {
+ showToast('用户名已被占用');
+ return;
+ }
+ // 更新用户名
+ const userIndex = users.findIndex(u => u.username === currentUser.username);
+ if (userIndex >= 0) {
+ users[userIndex].username = newUsername;
+ }
+ }
+
+ // 更新邮箱
+ const userIndex = users.findIndex(u => u.username === currentUser.username);
+ if (userIndex >= 0) {
+ users[userIndex].email = newEmail;
+ }
+
+ // 更新 currentUser
+ currentUser.avatar = newAvatar;
+ currentUser.username = newUsername;
+ currentUser.signature = newSignature;
+ currentUser.gender = newGender;
+ currentUser.age = newAge ? parseInt(newAge) : '';
+ currentUser.region = newRegion;
+
+ saveCurrentUser();
+ localStorage.setItem('registeredUsers', JSON.stringify(users));
+
+ showToast('保存成功');
+ switchPage('profile');
+}
+
+// ==================== 消息通知页面 ====================
+
+function showNotificationPage() {
+ // 加载通知设置
+ const settings = JSON.parse(localStorage.getItem('notificationSettings') || '{}');
+ const enableNotification = settings.enableNotification !== false;
+ const enableSound = settings.enableSound !== false;
+ const enableVibration = settings.enableVibration !== false;
+ const quietHoursStart = settings.quietHoursStart || '23:00';
+ const quietHoursEnd = settings.quietHoursEnd || '08:00';
+
+ const notificationHtml = `
+
+
+
+
+
+
通知设置
+
+
+
+ 开启通知
+ 接收消息推送通知
+
+
+
+
+
+
+ 通知声音
+ 收到通知时播放声音
+
+
+
+
+
+
+
+
+
免打扰时段
+
+
+
+
+
+
免打扰时段内不会收到通知
+
+
+
+ `;
+
+ appContainer.innerHTML = notificationHtml;
+
+ // 绑定返回按钮
+ const backBtn = document.getElementById('notificationBackBtn');
+ if (backBtn) {
+ backBtn.addEventListener('click', () => {
+ saveNotificationSettings();
+ switchPage('profile');
+ });
+ }
+
+ // 绑定开关切换
+ document.querySelectorAll('.settings-toggle').forEach(toggle => {
+ toggle.addEventListener('click', () => {
+ toggle.classList.toggle('active');
+ });
+ });
+}
+
+function saveNotificationSettings() {
+ const settings = {
+ enableNotification: document.getElementById('toggleNotification')?.classList.contains('active'),
+ enableSound: document.getElementById('toggleSound')?.classList.contains('active'),
+ enableVibration: document.getElementById('toggleVibration')?.classList.contains('active'),
+ quietHoursStart: document.getElementById('quietHoursStart')?.value || '23:00',
+ quietHoursEnd: document.getElementById('quietHoursEnd')?.value || '08:00'
+ };
+ localStorage.setItem('notificationSettings', JSON.stringify(settings));
+}
+
+// ==================== 隐私安全页面 ====================
+
+function showPrivacyPage() {
+ const privacyHtml = `
+
+
+
+
+
+
账号安全
+
+ ${currentUser ? `
+
+
+ 修改密码
+ 定期修改密码保障账号安全
+
+
›
+
+
+
+
+ 账号信息
+ 查看注册时间等信息
+
+
›
+
+ ` : `
+
登录后可管理账号安全
+ `}
+
+
+
+
隐私设置
+
+
+
+ 清除聊天记录
+ 删除所有对话历史
+
+
+
+
+
+
+ 清除缓存
+ 清除应用缓存数据
+
+
+
+
+
+
+
数据安全
+
+
+
+ 数据本地存储
+ 所有数据存储在本地,不上传服务器
+
+
安全
+
+
+
+
+ 对话加密
+ 对话内容采用本地加密存储
+
+
已开启
+
+
+
+
+ `;
+
+ appContainer.innerHTML = privacyHtml;
+
+ // 绑定返回按钮
+ const backBtn = document.getElementById('privacyBackBtn');
+ if (backBtn) {
+ backBtn.addEventListener('click', () => {
+ switchPage('profile');
+ });
+ }
+
+ // 修改密码
+ const changePasswordBtn = document.getElementById('changePasswordBtn');
+ if (changePasswordBtn) {
+ changePasswordBtn.addEventListener('click', () => {
+ showChangePasswordPage();
+ });
+ }
+
+ // 账号信息
+ const showAccountInfoBtn = document.getElementById('showAccountInfoBtn');
+ if (showAccountInfoBtn) {
+ showAccountInfoBtn.addEventListener('click', () => {
+ showAccountInfoDialog();
+ });
+ }
+
+ // 清除聊天记录
+ const clearChatsBtn = document.getElementById('clearChatsBtn');
+ if (clearChatsBtn) {
+ clearChatsBtn.addEventListener('click', () => {
+ if (confirm('确定要清除所有聊天记录吗?')) {
+ conversations = [];
+ saveConversations();
+ showToast('聊天记录已清除');
+ }
+ });
+ }
+
+ // 清除缓存
+ const clearCacheBtn = document.getElementById('clearCacheBtn');
+ if (clearCacheBtn) {
+ clearCacheBtn.addEventListener('click', () => {
+ // 清除临时数据,保留用户数据
+ localStorage.removeItem('currentPage');
+ localStorage.removeItem('dailyUsage');
+ showToast('缓存已清除');
+ });
+ }
+}
+
+function showChangePasswordPage() {
+ const changePwdHtml = `
+
+ `;
+
+ appContainer.innerHTML = changePwdHtml;
+
+ // 绑定返回按钮
+ const backBtn = document.getElementById('changePwdBackBtn');
+ if (backBtn) {
+ backBtn.addEventListener('click', () => {
+ showPrivacyPage();
+ });
+ }
+
+ // 绑定提交按钮
+ const submitBtn = document.getElementById('changePwdSubmitBtn');
+ if (submitBtn) {
+ submitBtn.addEventListener('click', handleChangePassword);
+ }
+}
+
+function handleChangePassword() {
+ const currentPwd = document.getElementById('currentPassword')?.value;
+ const newPwd = document.getElementById('newPassword')?.value;
+ const confirmNewPwd = document.getElementById('confirmNewPassword')?.value;
+
+ // 验证
+ if (!currentPwd) {
+ showToast('请输入当前密码');
+ return;
+ }
+
+ if (!newPwd || newPwd.length < 6 || newPwd.length > 20) {
+ showToast('新密码需要6-20个字符');
+ return;
+ }
+
+ if (newPwd !== confirmNewPwd) {
+ showToast('两次密码不一致');
+ return;
+ }
+
+ // 验证当前密码
+ const users = JSON.parse(localStorage.getItem('registeredUsers') || '[]');
+ const user = users.find(u => u.username === currentUser.username);
+
+ if (!user || user.password !== currentPwd) {
+ showToast('当前密码错误');
+ return;
+ }
+
+ // 更新密码
+ user.password = newPwd;
+ localStorage.setItem('registeredUsers', JSON.stringify(users));
+
+ showToast('密码已修改');
+ showPrivacyPage();
+}
+
+function showAccountInfoDialog() {
+ const users = JSON.parse(localStorage.getItem('registeredUsers') || '[]');
+ const user = users.find(u => u.username === currentUser.username);
+
+ const registeredAt = user?.registeredAt ? new Date(user.registeredAt).toLocaleString('zh-CN') : '未知';
+ const phone = user?.phone || '未设置';
+ const email = user?.email || '未设置';
+
+ const dialogHtml = `
+
+
+
账号信息
+
+
+ 用户名
+ ${currentUser.username}
+
+
+ 手机号
+ ${phone}
+
+
+ 邮箱
+ ${email}
+
+
+ 注册时间
+ ${registeredAt}
+
+
+
+
+
+ `;
+
+ document.body.insertAdjacentHTML('beforeend', dialogHtml);
+
+ document.getElementById('closeAccountInfo')?.addEventListener('click', () => {
+ document.getElementById('accountInfoDialog')?.remove();
+ });
+
+ document.getElementById('accountInfoDialog')?.addEventListener('click', (e) => {
+ if (e.target.id === 'accountInfoDialog') {
+ document.getElementById('accountInfoDialog')?.remove();
+ }
+ });
+}
+
+// ==================== 帮助与反馈页面 ====================
+
+function showHelpPage() {
+ const helpHtml = `
+
+
+
+
+
+
使用帮助
+
+
+
💬
+
+ 如何开始对话
+ 点击对话页面的 + 按钮创建新对话
+
+
+
+
+
🤖
+
+ 如何使用智能体
+ 切换到智能体页面,选择想要使用的智能体
+
+
+
+
+
🔍
+
+ 如何搜索对话
+ 点击对话页面的搜索按钮输入关键词
+
+
+
+
+
⭐
+
+ 如何收藏智能体
+ 长按智能体卡片选择收藏,或去发现页面添加
+
+
+
+
+
+
+
+
+
+ `;
+
+ appContainer.innerHTML = helpHtml;
+
+ // 绑定返回按钮
+ const backBtn = document.getElementById('helpBackBtn');
+ if (backBtn) {
+ backBtn.addEventListener('click', () => {
+ switchPage('profile');
+ });
+ }
+
+ // 提交反馈
+ const submitBtn = document.getElementById('submitFeedbackBtn');
+ if (submitBtn) {
+ submitBtn.addEventListener('click', () => {
+ const content = document.getElementById('feedbackContent')?.value.trim();
+ if (!content) {
+ showToast('请输入反馈内容');
+ return;
+ }
+
+ // 保存反馈(模拟)
+ const feedbacks = JSON.parse(localStorage.getItem('feedbacks') || '[]');
+ feedbacks.push({
+ content,
+ userId: currentUser?.username || 'guest',
+ createdAt: Date.now()
+ });
+ localStorage.setItem('feedbacks', JSON.stringify(feedbacks));
+
+ showToast('感谢您的反馈');
+ document.getElementById('feedbackContent').value = '';
+ });
+ }
+}
+
+// ==================== 关于页面 ====================
+
+function showAboutPage() {
+ const aboutHtml = `
+
+
+
+
+
🤖
+
AI助手
+
v3.5.0
+
+
+
基于智谱 GLM-4.5-Air 大模型
+
提供智能对话、多种智能体服务
+
+
+
+
+ 开发者
+ OpenClaw Team
+
+
+ 更新日期
+ 2026-04-27
+
+
+
+
+
+ 检查更新
+ ›
+
+
+ 隐私政策
+ ›
+
+
+ 用户协议
+ ›
+
+
+
+
+ `;
+
+ appContainer.innerHTML = aboutHtml;
+
+ // 绑定返回按钮
+ const backBtn = document.getElementById('aboutBackBtn');
+ if (backBtn) {
+ backBtn.addEventListener('click', () => {
+ switchPage('profile');
+ });
+ }
+
+ // 检查更新
+ const checkUpdateBtn = document.getElementById('checkUpdateBtn');
+ if (checkUpdateBtn) {
+ checkUpdateBtn.addEventListener('click', () => {
+ showToast('当前已是最新版本');
+ });
+ }
+
+ // 隐私政策
+ const privacyPolicyBtn = document.getElementById('privacyPolicyBtn');
+ if (privacyPolicyBtn) {
+ privacyPolicyBtn.addEventListener('click', () => {
+ showToast('隐私政策页面待完善');
+ });
+ }
+
+ // 用户协议
+ const userAgreementBtn = document.getElementById('userAgreementBtn');
+ if (userAgreementBtn) {
+ userAgreementBtn.addEventListener('click', () => {
+ showToast('用户协议页面待完善');
+ });
+ }
+}
+
// ==================== 登录页面 ====================
function showLoginPage() {
diff --git a/www/index.html b/www/index.html
index a4516b4..6807564 100644
--- a/www/index.html
+++ b/www/index.html
@@ -8,12 +8,12 @@
AI助手
-
+
-
-
+
+