使用html 和javascript 实现微信界面功能2

1.功能说明:

对上一篇的基础上进行了稍稍改造
主要修改点:
搜索功能:
在搜索框后面增加了搜索按钮。
搜索按钮调用performSearch函数来执行搜索操作。
表单形式的功能:
上传文件: 修改为表单形式,允许用户通过文件输入控件选择文件并上传。
发布朋友圈: 修改为表单形式,允许用户输入朋友圈内容并发布。
展示视频: 修改为表单形式,允许用户输入视频URL并展示。

2.代码展示

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>简易版微信</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f5f5f5;
        }
        .container {
            width: 80%;
            max-width: 1200px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            display: flex;
        }
        .sidebar {
            width: 25%;
            background: #e9ecef;
            padding: 20px;
            box-sizing: border-box;
        }
        .main-content {
            width: 75%;
            padding: 20px;
            box-sizing: border-box;
        }
        .search-area {
            margin-bottom: 20px;
            display: flex;
            align-items: center;
        }
        .search-area input {
            width: calc(100% - 80px);
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            outline: none;
        }
        .search-area button {
            padding: 10px 20px;
            border: none;
            background: #07c160;
            color: white;
            cursor: pointer;
            border-radius: 5px;
            margin-left: 10px;
        }
        .search-area button:hover {
            background: #06a352;
        }
        .friends-list, .favorites-list, .files-list, .moments-list, .videos-list {
            margin-top: 20px;
        }
        .item {
            padding: 10px;
            border-bottom: 1px solid #ddd;
            cursor: pointer;
        }
        .item:last-child {
            border-bottom: none;
        }
        .item:hover {
            background: #f1f1f1;
        }
        .video-item video {
            width: 100%;
            border-radius: 10px;
        }
        .disabled {
            opacity: 0.5;
            pointer-events: none;
        }
        .messages {
            max-height: 300px;
            overflow-y: auto;
            border-bottom: 1px solid #ddd;
            padding-bottom: 10px;
        }
        .message {
            margin-bottom: 10px;
        }
        .message.user {
            text-align: right;
        }
        .message.bot {
            text-align: left;
        }
        .input-area {
            display: flex;
            border-top: 1px solid #ddd;
        }
        .input-area input {
            flex-grow: 1;
            padding: 10px;
            border: none;
            outline: none;
        }
        .input-area button {
            padding: 10px;
            border: none;
            background: #07c160;
            color: white;
            cursor: pointer;
        }
        .input-area button:hover {
            background: #06a352;
        }
        .confirmation-message {
            margin-top: 20px;
            padding: 10px;
            background: #ffcccc;
            border: 1px solid #ff4d4d;
            border-radius: 5px;
        }
        .confirmation-message p {
            margin: 0;
        }
        .confirmation-buttons button {
            margin-right: 10px;
        }
        .friend-details img {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            object-fit: cover;
            margin-right: 10px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
        }
        .form-group input,
        .form-group textarea,
        .form-group select {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            outline: none;
        }
        .form-group button {
            padding: 10px 20px;
            border: none;
            background: #07c160;
            color: white;
            cursor: pointer;
            border-radius: 5px;
        }
        .form-group button:hover {
            background: #06a352;
        }
        .preview-image {
            width: 100px;
            height: 100px;
            border-radius: 50%;
            object-fit: cover;
            margin-top: 10px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="sidebar">
            <h3>搜索</h3>
            <div class="search-area">
                <input type="text" id="searchInput" placeholder="搜索...">
                <button onclick="performSearch()">搜索</button>
            </div>
            <h3>好友</h3>
            <div class="friends-list" id="friendsList">
                <div class="item" onclick="showFriends()">查看好友</div>
            </div>
            <h3>收藏</h3>
            <div class="favorites-list" id="favoritesList">
                <div class="item" onclick="showFavorites()">查看收藏</div>
            </div>
            <h3>文件</h3>
            <div class="files-list" id="filesList">
                <div class="item" onclick="showFiles()">查看文件</div>
            </div>
            <h3>朋友圈</h3>
            <div class="moments-list" id="momentsList">
                <div class="item" onclick="showMoments()">查看朋友圈</div>
            </div>
            <h3>视频号</h3>
            <div class="videos-list" id="videosList">
                <div class="item" onclick="showVideos()">查看视频</div>
            </div>
        </div>
        <div class="main-content">
            <h2 id="contentTitle">主界面</h2>
            <div id="contentArea"></div>
        </div>
    </div>

    <script>
        let friends = [];
        let favorites = [];
        let files = [];
        let moments = [];
        let videos = [];
        let confirmationCallback = null;

        function generateUniqueId() {
            return Math.random().toString(36).substr(2, 9);
        }

        function addFriendForm() {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>添加好友</h3>
                <form id="addFriendForm">
                    <div class="form-group">
                        <label for="friendNickname">网名:</label>
                        <input type="text" id="friendNickname" required>
                    </div>
                    <div class="form-group">
                        <label for="friendAge">年龄:</label>
                        <input type="number" id="friendAge" min="1" required>
                    </div>
                    <div class="form-group">
                        <label for="friendGender">性别:</label>
                        <select id="friendGender" required>
                            <option value="">请选择...</option>
                            <option value="male">男</option>
                            <option value="female">女</option>
                            <option value="other">其他</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="friendAddress">地址:</label>
                        <input type="text" id="friendAddress" required>
                    </div>
                    <div class="form-group">
                        <label for="friendAvatar">头像:</label>
                        <input type="file" id="friendAvatar" accept="image/*" required>
                        <img id="avatarPreview" class="preview-image" src="" alt="Avatar Preview" style="display:none;">
                    </div>
                    <button type="submit">添加好友</button>
                </form>
            `;
            document.getElementById('friendAvatar').addEventListener('change', function(event) {
                const file = event.target.files[0];
                if (file) {
                    const reader = new FileReader();
                    reader.onload = function(e) {
                        const previewImage = document.getElementById('avatarPreview');
                        previewImage.src = e.target.result;
                        previewImage.style.display = 'block';
                    };
                    reader.readAsDataURL(file);
                }
            });
            document.getElementById('addFriendForm').onsubmit = (event) => {
                event.preventDefault();
                const nickname = document.getElementById('friendNickname').value;
                const age = parseInt(document.getElementById('friendAge').value);
                const gender = document.getElementById('friendGender').value;
                const address = document.getElementById('friendAddress').value;
                const avatarFile = document.getElementById('friendAvatar').files[0];
                if (!avatarFile) {
                    showMessage('请上传头像');
                    return;
                }
                const friendId = generateUniqueId();
                const reader = new FileReader();
                reader.onloadend = () => {
                    const avatarUrl = reader.result;
                    friends.push({ id: friendId, nickname, age, gender, address, avatar: avatarUrl, blocked: false });
                    showMessage(`已添加好友 ${nickname}`);
                    showFriends();
                };
                reader.readAsDataURL(avatarFile);
            };
        }

        function deleteFriend(index) {
            confirmationCallback = () => {
                friends.splice(index, 1);
                showFriends();
            };
            showConfirmation(`确定要删除 ${friends[index].nickname} 吗?`);
        }

        function blockFriend(index) {
            friends[index].blocked = !friends[index].blocked;
            showMessage(`已将 ${friends[index].nickname} ${friends[index].blocked ? '拉黑' : '取消拉黑'}`);
            showFriends();
        }

        function addToFavoritesForm() {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>添加收藏</h3>
                <form id="addFavoriteForm">
                    <div class="form-group">
                        <label for="favoriteContent">收藏内容:</label>
                        <textarea id="favoriteContent" rows="4" required></textarea>
                    </div>
                    <button type="submit">添加收藏</button>
                </form>
            `;
            document.getElementById('addFavoriteForm').onsubmit = (event) => {
                event.preventDefault();
                const content = document.getElementById('favoriteContent').value;
                if (content) {
                    favorites.push({ content, likes: 0 });
                    showMessage(`已添加收藏`);
                    showFavorites();
                }
            };
        }

        function deleteFavorite(index) {
            confirmationCallback = () => {
                favorites.splice(index, 1);
                showFavorites();
            };
            showConfirmation(`确定要删除此收藏吗?`);
        }

        function likeFavorite(index) {
            favorites[index].likes++;
            showFavorites();
        }

        function uploadFileForm() {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>上传文件</h3>
                <form id="uploadFileForm">
                    <div class="form-group">
                        <label for="fileUpload">选择文件:</label>
                        <input type="file" id="fileUpload" required>
                    </div>
                    <button type="submit">上传文件</button>
                </form>
            `;
            document.getElementById('uploadFileForm').onsubmit = (event) => {
                event.preventDefault();
                const fileInput = document.getElementById('fileUpload');
                const file = fileInput.files[0];
                if (file) {
                    files.push(file);
                    showMessage(`${file.name} 已上传`);
                    showFiles();
                }
            };
        }

        function downloadFile(index) {
            const file = files[index];
            const url = URL.createObjectURL(file);
            const a = document.createElement('a');
            a.href = url;
            a.download = file.name;
            document.body.appendChild(a);
            a.click();
            a.remove();
        }

        function deleteFile(index) {
            confirmationCallback = () => {
                files.splice(index, 1);
                showFiles();
            };
            showConfirmation(`确定要删除此文件吗?`);
        }

        function postMomentForm() {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>发布朋友圈</h3>
                <form id="postMomentForm">
                    <div class="form-group">
                        <label for="momentContent">朋友圈内容:</label>
                        <textarea id="momentContent" rows="4" required></textarea>
                    </div>
                    <button type="submit">发布朋友圈</button>
                </form>
            `;
            document.getElementById('postMomentForm').onsubmit = (event) => {
                event.preventDefault();
                const content = document.getElementById('momentContent').value;
                if (content) {
                    moments.push({ content, likes: 0 });
                    showMessage(`已发布朋友圈`);
                    showMoments();
                }
            };
        }

        function deleteMoment(index) {
            confirmationCallback = () => {
                moments.splice(index, 1);
                showMoments();
            };
            showConfirmation(`确定要删除此朋友圈吗?`);
        }

        function likeMoment(index) {
            moments[index].likes++;
            showMoments();
        }

        function showVideoForm() {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>展示视频</h3>
                <form id="showVideoForm">
                    <div class="form-group">
                        <label for="videoUrl">视频URL:</label>
                        <input type="url" id="videoUrl" required>
                    </div>
                    <button type="submit">展示视频</button>
                </form>
            `;
            document.getElementById('showVideoForm').onsubmit = (event) => {
                event.preventDefault();
                const videoUrl = document.getElementById('videoUrl').value;
                if (videoUrl) {
                    videos.push({ url: videoUrl, likes: 0 });
                    showMessage(`已添加视频`);
                    showVideos();
                }
            };
        }

        function deleteVideo(index) {
            confirmationCallback = () => {
                videos.splice(index, 1);
                showVideos();
            };
            showConfirmation(`确定要删除此视频吗?`);
        }

        function likeVideo(index) {
            videos[index].likes++;
            showVideos();
        }

        function updateFriendsList() {
            const friendsList = document.getElementById('friendsList');
            friendsList.innerHTML = `
                <div class="item" οnclick="showFriends()">查看好友</div>
            `;
            if (friends.length > 0) {
                friends.forEach((friend, index) => {
                    const item = document.createElement('div');
                    item.className = 'item';
                    item.textContent = `${friend.nickname} (${friend.age}) ${friend.blocked ? '(已拉黑)' : ''}`;
                    item.onclick = () => showFriendDetails(index);
                    friendsList.appendChild(item);
                });
            }
        }

        function updateFavoritesList() {
            const favoritesList = document.getElementById('favoritesList');
            favoritesList.innerHTML = `
                <div class="item" οnclick="showFavorites()">查看收藏</div>
            `;
            if (favorites.length > 0) {
                favorites.forEach((favorite, index) => {
                    const item = document.createElement('div');
                    item.className = 'item';
                    item.textContent = `${favorite.content.substring(0, 50)}... (${favorite.likes} 点赞)`;
                    item.onclick = () => showFavoriteDetails(index);
                    favoritesList.appendChild(item);
                });
            }
        }

        function updateFilesList() {
            const filesList = document.getElementById('filesList');
            filesList.innerHTML = `
                <div class="item" οnclick="showFiles()">查看文件</div>
            `;
            if (files.length > 0) {
                files.forEach((file, index) => {
                    const item = document.createElement('div');
                    item.className = 'item';
                    item.textContent = `${file.name}`;
                    item.onclick = () => showFileDetails(index);
                    filesList.appendChild(item);
                });
            }
        }

        function updateMomentsList() {
            const momentsList = document.getElementById('momentsList');
            momentsList.innerHTML = `
                <div class="item" οnclick="showMoments()">查看朋友圈</div>
            `;
            if (moments.length > 0) {
                moments.forEach((moment, index) => {
                    const item = document.createElement('div');
                    item.className = 'item';
                    item.textContent = `${moment.content.substring(0, 50)}... (${moment.likes} 点赞)`;
                    item.onclick = () => showMomentDetails(index);
                    momentsList.appendChild(item);
                });
            }
        }

        function updateVideosList() {
            const videosList = document.getElementById('videosList');
            videosList.innerHTML = `
                <div class="item" οnclick="showVideos()">查看视频</div>
            `;
            if (videos.length > 0) {
                videos.forEach((video, index) => {
                    const item = document.createElement('div');
                    item.className = 'item';
                    item.innerHTML = `<video src="${video.url}" controls></video> (${video.likes} 点赞)`;
                    item.onclick = () => showVideoDetails(index);
                    videosList.appendChild(item);
                });
            }
        }

        function showFriends() {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>好友列表</h3>
                <button οnclick="addFriendForm()">添加好友</button>
                <div id="friendsContent"></div>
            `;
            const friendsContent = document.getElementById('friendsContent');
            friends.forEach((friend, index) => {
                const item = document.createElement('div');
                item.className = 'item';
                item.textContent = `${friend.nickname} (${friend.age}) ${genderMap[friend.gender]} ${friend.blocked ? '(已拉黑)' : ''}`;
                item.onclick = () => showFriendDetails(index);
                friendsContent.appendChild(item);
            });
        }

        function showFriendDetails(index) {
            const friend = friends[index];
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>${friend.nickname}</h3>
                <div class="friend-details">
                    <img src="${friend.avatar}" alt="${friend.nickname}'s Avatar">
                    <p>年龄: ${friend.age}</p>
                    <p>性别: ${genderMap[friend.gender]}</p>
                    <p>地址: ${friend.address}</p>
                    <p>状态: ${friend.blocked ? '已拉黑' : '正常'}</p>
                    <button οnclick="chatWithFriend(${index})" ${friend.blocked ? 'class="disabled"' : ''}>聊天</button>
                    <button οnclick="deleteFriend(${index})">删除好友</button>
                    <button οnclick="blockFriend(${index})">${friend.blocked ? '取消拉黑' : '拉黑好友'}</button>
                </div>
            `;
        }

        function chatWithFriend(index) {
            const friend = friends[index];
            if (friend.blocked) {
                showMessage('无法与已拉黑的好友聊天');
                return;
            }
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>与 ${friend.nickname} 聊天</h3>
                <div class="messages" id="friendMessages"></div>
                <div class="input-area">
                    <input type="text" id="friendMessageInput" placeholder="输入消息...">
                    <button οnclick="sendFriendMessage(${index})">发送</button>
                </div>
            `;
        }

        function sendFriendMessage(index) {
            const friendMessageInput = document.getElementById('friendMessageInput');
            const friendMessagesContainer = document.getElementById('friendMessages');
            const userMessage = friendMessageInput.value.trim();

            if (userMessage === '') return;

            // 创建用户消息元素
            const userMessageElement = document.createElement('div');
            userMessageElement.className = 'message user';
            userMessageElement.textContent = userMessage;
            friendMessagesContainer.appendChild(userMessageElement);

            // 添加撤回按钮
            const revokeButton = document.createElement('button');
            revokeButton.textContent = '撤回';
            revokeButton.onclick = () => {
                friendMessagesContainer.removeChild(userMessageElement);
            };
            userMessageElement.appendChild(revokeButton);

            // 清空输入框
            friendMessageInput.value = '';

            // 模拟好友回复
            setTimeout(() => {
                const friendReply = `收到:${userMessage}`;
                const friendMessageElement = document.createElement('div');
                friendMessageElement.className = 'message bot';
                friendMessageElement.textContent = friendReply;
                friendMessagesContainer.appendChild(friendMessageElement);

                // 自动滚动到底部
                friendMessagesContainer.scrollTop = friendMessagesContainer.scrollHeight;
            }, 1000);
        }

        function showFavoriteDetails(index) {
            const favorite = favorites[index];
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>收藏内容</h3>
                <p>${favorite.content}</p>
                <p>点赞数: ${favorite.likes}</p>
                <button οnclick="likeFavorite(${index})">点赞</button>
                <button οnclick="deleteFavorite(${index})">删除收藏</button>
            `;
        }

        function showFileDetails(index) {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>文件详情</h3>
                <p>文件名: ${files[index].name}</p>
                <button οnclick="downloadFile(${index})">下载文件</button>
                <button οnclick="deleteFile(${index})">删除文件</button>
            `;
        }

        function showMomentDetails(index) {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>朋友圈内容</h3>
                <p>${moments[index].content}</p>
                <p>点赞数: ${moments[index].likes}</p>
                <button οnclick="likeMoment(${index})">点赞</button>
                <button οnclick="deleteMoment(${index})">删除朋友圈</button>
            `;
        }

        function showVideoDetails(index) {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>视频详情</h3>
                <video src="${videos[index].url}" controls></video>
                <p>点赞数: ${videos[index].likes}</p>
                <button οnclick="likeVideo(${index})">点赞</button>
                <button οnclick="deleteVideo(${index})">删除视频</button>
            `;
        }

        function showFavorites() {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>收藏内容列表</h3>
                <button οnclick="addToFavoritesForm()">新增收藏内容</button>
                <div id="favoritesContent"></div>
            `;
            const favoritesContent = document.getElementById('favoritesContent');
            favorites.forEach((favorite, index) => {
                const item = document.createElement('div');
                item.className = 'item';
                item.textContent = `${favorite.content.substring(0, 50)}... (${favorite.likes} 点赞)`;
                item.onclick = () => showFavoriteDetails(index);
                favoritesContent.appendChild(item);
            });
        }

        function showFiles() {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>文件列表</h3>
                <button οnclick="uploadFileForm()">上传文件</button>
                <div id="filesContent"></div>
            `;
            const filesContent = document.getElementById('filesContent');
            files.forEach((file, index) => {
                const item = document.createElement('div');
                item.className = 'item';
                item.textContent = `${file.name}`;
                item.onclick = () => showFileDetails(index);
                filesContent.appendChild(item);
            });
        }

        function showMoments() {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>朋友圈列表</h3>
                <button οnclick="postMomentForm()">发布朋友圈</button>
                <div id="momentsContent"></div>
            `;
            const momentsContent = document.getElementById('momentsContent');
            moments.forEach((moment, index) => {
                const item = document.createElement('div');
                item.className = 'item';
                item.textContent = `${moment.content.substring(0, 50)}... (${moment.likes} 点赞)`;
                item.onclick = () => showMomentDetails(index);
                momentsContent.appendChild(item);
            });
        }

        function showVideos() {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>视频列表</h3>
                <button οnclick="showVideoForm()">展示视频</button>
                <div id="videosContent"></div>
            `;
            const videosContent = document.getElementById('videosContent');
            videos.forEach((video, index) => {
                const item = document.createElement('div');
                item.className = 'item';
                item.innerHTML = `<video src="${video.url}" controls></video> (${video.likes} 点赞)`;
                item.onclick = () => showVideoDetails(index);
                videosContent.appendChild(item);
            });
        }

        function showConfirmation(message) {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML += `
                <div class="confirmation-message" id="confirmationMessage">
                    <p>${message}</p>
                    <div class="confirmation-buttons">
                        <button οnclick="confirmAction()">确认</button>
                        <button οnclick="cancelAction()">取消</button>
                    </div>
                </div>
            `;
        }

        function confirmAction() {
            if (confirmationCallback) {
                confirmationCallback();
                confirmationCallback = null;
            }
            hideConfirmation();
        }

        function cancelAction() {
            confirmationCallback = null;
            hideConfirmation();
        }

        function hideConfirmation() {
            const confirmationMessage = document.getElementById('confirmationMessage');
            if (confirmationMessage) {
                confirmationMessage.remove();
            }
        }

        function showMessage(message) {
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML += `
                <div class="confirmation-message" id="confirmationMessage">
                    <p>${message}</p>
                </div>
            `;
            setTimeout(hideConfirmation, 3000); // Hide after 3 seconds
        }

        function searchFriends(query) {
            const filteredFriends = friends.filter(friend =>
                friend.nickname.toLowerCase().includes(query.toLowerCase())
            );
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>搜索结果</h3>
                <div id="searchResults"></div>
            `;
            const searchResults = document.getElementById('searchResults');
            if (filteredFriends.length > 0) {
                filteredFriends.forEach((friend, index) => {
                    const item = document.createElement('div');
                    item.className = 'item';
                    item.textContent = `${friend.nickname} (${friend.age}) ${genderMap[friend.gender]} ${friend.blocked ? '(已拉黑)' : ''}`;
                    item.onclick = () => showSearchFriendDetails(filteredFriends, index);
                    searchResults.appendChild(item);
                });
            } else {
                searchResults.innerHTML = '<p>没有找到匹配的好友</p>';
            }
        }

        function performSearch() {
            const query = document.getElementById('searchInput').value;
            if (query.trim()) {
                searchFriends(query);
            } else {
                showFriends(); // Reset to full list if search is cleared
            }
        }

        function showSearchFriendDetails(filteredFriends, index) {
            const friend = filteredFriends[index];
            const contentArea = document.getElementById('contentArea');
            contentArea.innerHTML = `
                <h3>${friend.nickname}</h3>
                <div class="friend-details">
                    <img src="${friend.avatar}" alt="${friend.nickname}'s Avatar">
                    <p>年龄: ${friend.age}</p>
                    <p>性别: ${genderMap[friend.gender]}</p>
                    <p>地址: ${friend.address}</p>
                    <p>状态: ${friend.blocked ? '已拉黑' : '正常'}</p>
                    <button οnclick="chatWithFriend(${friends.indexOf(friend)})" ${friend.blocked ? 'class="disabled"' : ''}>聊天</button>
                    <button οnclick="deleteFriend(${friends.indexOf(friend)})">删除好友</button>
                    <button οnclick="blockFriend(${friends.indexOf(friend)})">${friend.blocked ? '取消拉黑' : '拉黑好友'}</button>
                </div>
            `;
        }

        // Gender mapping
        const genderMap = {
            male: '男',
            female: '女',
            other: '其他'
        };

        // 初始化列表
        updateFriendsList();
        updateFavoritesList();
        updateFilesList();
        updateMomentsList();
        updateVideosList();
    </script>
</body>
</html>




3.效果展示

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/935329.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

vulhub复现CVE-2021-44228log4j漏洞

目录 一&#xff1a;漏洞概述 二&#xff1a;漏洞原理 三&#xff1a;漏洞利用 lookup功能&#xff1a; JNDI解析器&#xff1a; ldap服务&#xff1a; RMI&#xff1a; 四&#xff1a;漏洞复现 4.1靶场 4.2dnslog测试 4.3部署jndi-injection-exploit 4.4打开监听端口 4.5触发请…

数据库中的运算符

1.算术运算符 算术运算符主要用于数学运算&#xff0c;其可以连接运算符前后的两个数值或表达式&#xff0c;对数值或表达式进行加&#xff08;&#xff09;、减&#xff08;-&#xff09;、乘&#xff08;*&#xff09;、除&#xff08;/&#xff09;和取模&#xff08;%&…

Java项目实战II基于Java+Spring Boot+MySQL的社区帮扶对象管理系统的设计与实现(开发文档+数据库+源码)

目录 一、前言 二、技术介绍 三、系统实现 四、核心代码 五、源码获取 全栈码农以及毕业设计实战开发&#xff0c;CSDN平台Java领域新星创作者&#xff0c;专注于大学生项目实战开发、讲解和毕业答疑辅导。获取源码联系方式请查看文末 一、前言 在当前社会&#xff0c;随…

计算机的运维成本计算:运算的任务比例(电能消耗);机器成本C和服务率

计算机的运维成本计算&#xff1a;运算的任务比例&#xff08;电能消耗&#xff09;&#xff1b;机器成本C和服务率 “cost”指的是服务器的运维成本&#xff08;cost of operation and maintenance&#xff09;。提出的模型中&#xff0c;考虑了服务器运维成本以及平均队列等…

MSN文章精选2

大明灭亡时&#xff0c;数万名锦衣卫为何都消失不见&#xff0c;他们都去了哪里&#xff1f; (msn.cn)https://www.msn.cn/zh-cn/news/other/%E5%A4%A7%E6%98%8E%E7%81%AD%E4%BA%A1%E6%97%B6-%E6%95%B0%E4%B8%87%E5%90%8D%E9%94%A6%E8%A1%A3%E5%8D%AB%E4%B8%BA%E4%BD%95%E9%83%…

暴雨首发 Turin平台服务器亮相中国解决方案AMD峰会巡展

近期&#xff0c;AMD中国解决方案峰会分别在北京和深圳圆满落幕。作为AMD的战略合作伙伴&#xff0c;暴雨信息发展有限公司&#xff08;以下简称“暴雨”&#xff09;一直积极研发基于AMD芯片的产品&#xff0c;并在本次巡展上首次发布展出了最新的Turin平台的AI服务器产品算力…

算法日记48 day 图论(拓扑排序,dijkstra)

今天继续图论章节&#xff0c;主要是拓扑排序和dijkstra算法。 还是举例说明。 题目&#xff1a;软件构建 117. 软件构建 (kamacoder.com) 题目描述 某个大型软件项目的构建系统拥有 N 个文件&#xff0c;文件编号从 0 到 N - 1&#xff0c;在这些文件中&#xff0c;某些文件…

vue-echarts高度缩小时autoresize失效

背景 项目中采用动态给x-vue-echarts style赋值width&#xff0c;height的方式实现echarts图表尺寸的改变 <v-chart...autoresize></v-chart>给v-chart添加autoresize后&#xff0c;在图表宽度变化&#xff0c;高度增加时无异常&#xff0c;高度减小时图表并未缩…

40 list类 模拟实现

目录 一、list类简介 &#xff08;一&#xff09;概念 &#xff08;二&#xff09;list与string和vector的区别 二、list类使用 &#xff08;一&#xff09;构造函数 &#xff08;二&#xff09;迭代器 &#xff08;三&#xff09;list capacity &#xff08;四&#x…

vue3监听横向滚动条的位置;鼠标滚轮滑动控制滚动条滚动;监听滚动条到顶端

1.横向取值scrollLeft 竖向取值scrollTop 2.可以监听到最左最右侧 3.鼠标滚轮滑动控制滚动条滚动 效果 <template><div><div class"scrollable" ref"scrollableRef"><!-- 内容 --><div style"width: 2000px; height: 100…

【大模型】ChatGPT 创作各类高质量文案使用详解

目录 一、前言 二、ChatGPT文案创作的优势 三、ChatGPT 各类文案创作操作实战 3.1 ChatGPT创作产品文案 3.1.1 ChatGPT创作产品文案基本思路 3.1.2 ChatGPT 创作产品文案案例一 3.1.2.1 操作过程 3.1.3 ChatGPT 创作产品文案案例二 3.2 ChatGPT 创作视频脚本 3.2.1 Ch…

每日一刷——二叉树的构建——12.12

第一题&#xff1a;最大二叉树 题目描述&#xff1a;654. 最大二叉树 - 力扣&#xff08;LeetCode&#xff09; 我的想法&#xff1a; 我感觉这个题目最开始大家都能想到的暴力做法就是遍历找到数组中的最大值&#xff0c;然后再遍历一遍&#xff0c;把在它左边的依次找到最大…

蓝桥杯刷题——day2

蓝桥杯刷题——day2 题目一题干题目解析代码 题目二题干解题思路代码 题目一 题干 三步问题。有个小孩正在上楼梯&#xff0c;楼梯有n阶台阶&#xff0c;小孩一次可以上1阶、2阶或3阶。实现一种方法&#xff0c;计算小孩有多少种上楼梯的方式。结果可能很大&#xff0c;你需要…

中粮凤凰里共有产权看房记

中粮凤凰里看房是希望而来&#xff0c;失望而归。主要是对如下失望&#xff0c;下述仅个人看房感受&#xff1a; 1. 户型不喜欢&#xff1a;三房的厨房和餐厅位置很奇葩 2. 样板间在25楼&#xff1a;湖景一言难尽和有工厂噪声 3. 精装修的交房质量:阳台的推拉门用料很草率 …

负载均衡和tomcat

一、负载均衡 1.相关概念 nginx的反向代理<-->负载均衡 负载均衡 将四层或者是七层的请求分配到多台后端的服务器上&#xff0c;从而分担整个业务的负载。提高系统的稳定性&#xff0c;也可以提供高可用&#xff08;备灾&#xff0c;其中的一台后端服务器如果发生故障…

电子电工一课一得

首语 在现代社会中&#xff0c;电子电工技术已经渗透到我们生活的方方面面&#xff0c;从家用电器到工业自动化&#xff0c;从通信设备到智能系统&#xff0c;无一不依赖于电子电工技术。因此&#xff0c;掌握电子电工的基础知识&#xff0c;不仅对理工科学生至关重要&#xf…

Pyside6 --Qt设计师--简单了解各个控件的作用之:Buttons

目录 一、BUttons1.1 包含1.2 不同按钮的解释 二、具体应用2.1 Push Button2.2 Tool Button2.3 Radio Button2.4 Check Box2.5 Command Link Button2.6 Dialog Button Box2.6.1 直接显示代码如下2.6.2 可以修改ok&#xff0c;cancel 的内容 今天学习一下工具箱里面的Buttons&am…

网络基础 - TCP/IP 五层模型

文章目录 一、OSI 参考模型中各个分层的作用1、应用层2、表示层3、会话层4、传输层5、网络层6、数据链路层7、物理层 一、OSI 参考模型中各个分层的作用 1、应用层 2、表示层 负责设备固有数据格式和网络标准数据格式间的转换 3、会话层 4、传输层 负责连接的建立和断开&…

【git】git回退到之前版本+拓展git命令

一、问题 git提交有时候会出错&#xff0c;想回退到之前的版本 1、命令git reset --soft <commit_id> commit_id【回退到的编号】 2、git push --force-with-lease origin <branch_name> branch_name【分支名】 二、拓展 1、git bash 1、进入任意磁盘 cd 磁盘…