Преглед на файлове

admin-2025-02-24 08:20:25

genlitex преди 2 месеца
родител
ревизия
39cfcf5f95
променени са 8 файла, в които са добавени 130 реда и са изтрити 66 реда
  1. 0 0
      dist/assets/index-CG5nvybr.css
  2. 0 4
      dist/assets/index-CfrRq4xW.js
  3. 0 0
      dist/assets/index-Dn3TNry4.css
  4. 4 0
      dist/assets/index-GjZ-KlC6.js
  5. 2 2
      dist/index.html
  6. 40 60
      src/assets/common.css
  7. 6 0
      src/router/index.js
  8. 78 0
      src/views/ChatView.vue

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/assets/index-CG5nvybr.css


Файловите разлики са ограничени, защото са твърде много
+ 0 - 4
dist/assets/index-CfrRq4xW.js


Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
dist/assets/index-Dn3TNry4.css


Файловите разлики са ограничени, защото са твърде много
+ 4 - 0
dist/assets/index-GjZ-KlC6.js


+ 2 - 2
dist/index.html

@@ -5,8 +5,8 @@
     <link rel="icon" type="image/svg+xml" href="/vite.svg" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>Vite + Vue</title>
-    <script type="module" crossorigin src="/ide/proxy/6009/assets/index-CfrRq4xW.js"></script>
-    <link rel="stylesheet" crossorigin href="/ide/proxy/6009/assets/index-Dn3TNry4.css">
+    <script type="module" crossorigin src="/ide/proxy/6002/assets/index-GjZ-KlC6.js"></script>
+    <link rel="stylesheet" crossorigin href="/ide/proxy/6002/assets/index-CG5nvybr.css">
   </head>
   <body>
     <div id="app"></div>

+ 40 - 60
src/assets/common.css

@@ -1,86 +1,66 @@
-#app {
-    width: 100%;
+/* 侧边栏 */
+.sidebar {
+  @apply w-64 bg-[#08002E] text-white flex flex-col;
 }
 
-@tailwind base;
-@tailwind components;
-@tailwind utilities;
-:root {
-    font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
-    line-height: 1.5;
-    font-weight: 400;
+.sidebar-title {
+  @apply p-4 text-center font-bold text-2xl;
+}
 
-    color-scheme: light dark;
-    color: rgba(255, 255, 255, 0.87);
-    background-color: #242424;
+.contact-item {
+  @apply flex items-center p-2;
+}
 
-    font-synthesis: none;
-    text-rendering: optimizeLegibility;
-    -webkit-font-smoothing: antialiased;
-    -moz-osx-font-smoothing: grayscale;
+.contact-item:hover, .contact-item.selected {
+  @apply bg-[#3D26A3];
 }
 
-a {
-    font-weight: 500;
-    color: #646cff;
-    text-decoration: inherit;
+.contact-item.selected {
+  @apply bg-[#2F197F];
 }
 
-a:hover {
-    color: #535bf2;
+.contact-avatar {
+  @apply w-8 h-8 rounded-full mr-2;
 }
 
-body {
-    margin: 0;
-    display: flex;
-    place-items: center;
-    min-width: 320px;
-    min-height: 100vh;
+.contact-name {
+  @apply ml-auto text-sm;
 }
 
-h1 {
-    font-size: 3.2em;
-    line-height: 1.1;
+/* 对话区域 */
+.chat-area {
+  @apply flex-1 bg-gray-100 flex flex-col;
 }
 
-button {
-    border-radius: 8px;
-    border: 1px solid transparent;
-    padding: 0.6em 1.2em;
-    font-size: 1em;
-    font-weight: 500;
-    font-family: inherit;
-    background-color: #1a1a1a;
-    cursor: pointer;
-    transition: border-color 0.25s;
+.chat-messages {
+  @apply flex-1 p-4 overflow-y-auto;
 }
 
-button:hover {
-    border-color: #646cff;
+.message-bubble {
+  @apply max-w-xs p-2 my-2;
 }
 
-button:focus,
-button:focus-visible {
-    outline: 4px auto -webkit-focus-ring-color;
+.message-bubble.me {
+  @apply bg-purple-100 float-right rounded-l-lg rounded-br-lg;
 }
 
-.card {
-    padding: 2em;
+.message-bubble.other {
+  @apply bg-gray-200 float-left rounded-r-lg rounded-bl-lg;
 }
 
+/* 输入框与发送按钮 */
+.chat-input {
+  @apply p-4 border-t border-gray-200 flex items-center;
+}
 
-@media (prefers-color-scheme: light) {
-    :root {
-        color: #213547;
-        background-color: #ffffff;
-    }
+.send-button {
+  @apply bg-purple-500 text-white px-4 py-2 rounded-l-lg;
+}
 
-    a:hover {
-        color: #747bff;
-    }
+.file-upload-button {
+  @apply bg-purple-500 text-white px-4 py-2 rounded-full ml-2 cursor-pointer;
+}
 
-    button {
-        background-color: #f9f9f9;
-    }
+.file-name {
+  @apply ml-2 text-sm;
 }
-  

+ 6 - 0
src/router/index.js

@@ -1,11 +1,17 @@
 import { createRouter, createWebHashHistory } from 'vue-router'
 import HomeView from '../views/HomeView.vue'
+import ChatView from '../views/ChatView.vue'
 
 const routes = [
   {
     path: '/',
     name: 'home',
     component: HomeView
+  },
+  {
+    path: '/chat',
+    name: 'chat',
+    component: ChatView
   }
 ]
 

+ 78 - 0
src/views/ChatView.vue

@@ -0,0 +1,78 @@
+<template>
+  <div class="flex h-screen">
+    <!-- 侧边栏 -->
+    <div class="w-64 bg-[#08002E] text-white flex flex-col">
+      <div class="p-4 text-center font-bold text-2xl">应用标题</div>
+      <ul class="flex-1 overflow-auto">
+        <li v-for="(contact, index) in contacts" :key="index" 
+            :class="{'bg-[#2F197F]': selectedContact === contact, 'hover:bg-[#3D26A3]': true}"
+            @click="selectContact(contact)">
+          <div class="flex items-center p-2">
+            <img :src="contact.avatar" alt="avatar" class="w-8 h-8 rounded-full mr-2"/>
+            <span>{{ contact.name }}</span>
+            <span class="ml-auto text-sm">{{ contact.lastMessageTime }}</span>
+          </div>
+        </li>
+      </ul>
+    </div>
+    <!-- 对话区域 -->
+    <div class="flex-1 bg-gray-100 flex flex-col">
+      <div class="flex-1 p-4 overflow-y-auto">
+        <div v-for="(message, index) in messages" :key="index" 
+             :class="{'bg-purple-100 float-right rounded-l-lg rounded-br-lg': message.sender === 'me', 'bg-gray-200 float-left rounded-r-lg rounded-bl-lg': message.sender !== 'me'}"
+             class="max-w-xs p-2 my-2">
+          {{ message.content }}
+        </div>
+      </div>
+      <div class="p-4 border-t border-gray-200 flex items-center">
+        <button class="bg-purple-500 text-white px-4 py-2 rounded-l-lg">发送</button>
+        <input type="text" v-model="newMessage" placeholder="输入消息..." class="flex-1 px-2 py-1 ml-2 rounded-r-lg" @keyup.enter="sendMessage" />
+        <label for="fileUpload" class="bg-purple-500 text-white px-4 py-2 rounded-full ml-2 cursor-pointer">上传文件
+          <input id="fileUpload" type="file" style="display: none;" @change="handleFileChange" />
+        </label>
+        <span v-if="selectedFile" class="ml-2 text-sm">{{ selectedFile.name }}</span>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'ChatView',
+  data() {
+    return {
+      contacts: [
+        { name: '张三', avatar: '/assets/img/avatar.png', lastMessageTime: '10分钟前' },
+        // 更多联系人...
+      ],
+      selectedContact: null,
+      messages: [],
+      newMessage: '',
+      selectedFile: null
+    };
+  },
+  methods: {
+    selectContact(contact) {
+      this.selectedContact = contact;
+    },
+    sendMessage() {
+      if (this.newMessage.trim()) {
+        this.messages.push({ content: this.newMessage, sender: 'me' });
+        this.newMessage = '';
+        // 自动滚动到底部
+        setTimeout(() => {
+          const chatContainer = document.querySelector('.overflow-y-auto');
+          chatContainer.scrollTop = chatContainer.scrollHeight;
+        }, 10);
+      }
+    },
+    handleFileChange(event) {
+      this.selectedFile = event.target.files[0];
+    }
+  }
+};
+</script>
+
+<style scoped>
+/* 添加自定义样式 */
+</style>

Някои файлове не бяха показани, защото твърде много файлове са промени