Parcourir la source

zbytest003-2025-02-20 01:11:30

genlitex il y a 3 mois
Parent
commit
7a0baa5ae4

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
dist/assets/index-CXldBT1O.css


Fichier diff supprimé car celui-ci est trop grand
+ 4 - 0
dist/assets/index-Cf4e0BPj.js


Fichier diff supprimé car celui-ci est trop grand
+ 0 - 4
dist/assets/index-malWbV8K.js


+ 2 - 2
dist/index.html

@@ -4,8 +4,8 @@
     <meta charset="UTF-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>Prototype Design</title>
-    <script type="module" crossorigin src="/prototype/3000/assets/index-malWbV8K.js"></script>
-    <link rel="stylesheet" crossorigin href="/prototype/3000/assets/index-Btspm7_H.css">
+    <script type="module" crossorigin src="/ide/proxy/6007/assets/index-Cf4e0BPj.js"></script>
+    <link rel="stylesheet" crossorigin href="/ide/proxy/6007/assets/index-CXldBT1O.css">
   </head>
   <body>
     <div id="app"></div>

+ 12 - 0
src/router/index.js

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

+ 269 - 0
src/views/ChatView.vue

@@ -0,0 +1,269 @@
+<template>
+  <div class="chat-container">
+    <aside class="sidebar">
+      <div class="sidebar-header">
+        <h2>应用标题</h2>
+      </div>
+      <div class="user-info">
+        <p>用户名</p>
+      </div>
+      <div class="contact-list">
+        <a-list item-layout="horizontal" :data-source="contacts">
+          <template #renderItem="{ item }">
+            <a-list-item>
+              <a-list-item-meta>
+                <template #avatar>
+                  <a-avatar :src="item.avatar" />
+                </template>
+                <template #title>
+                  <a href="javascript:;" @click="selectContact(item)">{{ item.name }}</a>
+                </template>
+                <template #description>
+                  {{ item.lastMessage }}
+                </template>
+              </a-list-item-meta>
+            </a-list-item>
+          </template>
+        </a-list>
+      </div>
+    </aside>
+    <main class="chat-area">
+      <div class="message-container" ref="messageContainer">
+        <a-list item-layout="horizontal" :data-source="messages">
+          <template #renderItem="{ item }">
+            <a-list-item>
+              <a-list-item-meta>
+                <template #description>
+                  <div :class="['message-bubble', item.sender === 'self' ? 'self' : 'other']">
+                    <p>{{ item.text }}</p>
+                    <span class="timestamp">{{ item.timestamp }}</span>
+                  </div>
+                </template>
+              </a-list-item-meta>
+            </a-list-item>
+          </template>
+        </a-list>
+      </div>
+      <div class="input-area">
+        <a-input v-model:value="inputText" placeholder="输入消息..." @pressEnter="sendMessage" />
+        <a-button type="primary" @click="sendMessage">发送</a-button>
+        <a-upload :before-upload="handleUpload" :show-upload-list="false">
+          <a-button icon="upload">上传文件</a-button>
+        </a-upload>
+      </div>
+    </main>
+  </div>
+</template>
+
+<script>
+import { ref, reactive, onMounted, nextTick } from 'vue';
+import { message } from 'ant-design-vue';
+
+export default {
+  setup() {
+    const contacts = reactive([
+      { id: 1, avatar: '@/assets/img/user-avatar.png', name: '联系人1', lastMessage: '你好!' },
+      { id: 2, avatar: '@/assets/img/user-avatar.png', name: '联系人2', lastMessage: '最近怎么样?' },
+    ]);
+
+    const messages = reactive([]);
+    const inputText = ref('');
+    const selectedContact = ref(null);
+    const messageContainer = ref(null);
+
+    const selectContact = (contact) => {
+      selectedContact.value = contact;
+      // Load messages for the selected contact
+      messages.length = 0; // Clear previous messages
+      messages.push(
+        { sender: 'other', text: '你好!', timestamp: '10:00 AM' },
+        { sender: 'self', text: '你好!', timestamp: '10:01 AM' }
+      );
+      nextTick(() => {
+        scrollToBottom();
+      });
+    };
+
+    const sendMessage = () => {
+      if (inputText.value.trim()) {
+        messages.push({
+          sender: 'self',
+          text: inputText.value,
+          timestamp: new Date().toLocaleTimeString(),
+        });
+        inputText.value = '';
+        nextTick(() => {
+          scrollToBottom();
+        });
+      }
+    };
+
+    const handleUpload = (file) => {
+      message.info(`上传文件: ${file.name}`);
+      messages.push({
+        sender: 'self',
+        text: `上传了文件: ${file.name}`,
+        timestamp: new Date().toLocaleTimeString(),
+      });
+      nextTick(() => {
+        scrollToBottom();
+      });
+      return false; // Prevent default upload behavior
+    };
+
+    const scrollToBottom = () => {
+      if (messageContainer.value) {
+        messageContainer.value.scrollTop = messageContainer.value.scrollHeight;
+      }
+    };
+
+    onMounted(() => {
+      selectContact(contacts[0]); // Select the first contact by default
+    });
+
+    return {
+      contacts,
+      messages,
+      inputText,
+      selectedContact,
+      messageContainer,
+      selectContact,
+      sendMessage,
+      handleUpload,
+    };
+  },
+};
+</script>
+
+<style scoped>
+.chat-container {
+  display: flex;
+  height: 100vh;
+  background-color: #f0f0f0;
+}
+
+.sidebar {
+  width: 250px;
+  background-color: #08002e;
+  color: white;
+  display: flex;
+  flex-direction: column;
+}
+
+.sidebar-header {
+  background-color: #6a0dad;
+  padding: 10px 0;
+  text-align: center;
+}
+
+.sidebar-header h2 {
+  margin: 0;
+  font-size: 18px;
+  font-weight: bold;
+}
+
+.user-info {
+  display: flex;
+  align-items: center;
+  padding: 10px;
+  border-bottom: 1px solid #440088;
+}
+
+.user-info .avatar {
+  width: 40px;
+  height: 40px;
+  border-radius: 50%;
+  margin-right: 10px;
+}
+
+.contact-list {
+  flex: 1;
+  overflow-y: auto;
+}
+
+.chat-area {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+}
+
+.message-container {
+  flex: 1;
+  padding: 10px;
+  overflow-y: auto;
+  background-color: #f0f0f0;
+}
+
+.message-bubble {
+  max-width: 70%;
+  margin: 5px 0;
+  padding: 10px;
+  border-radius: 15px;
+  position: relative;
+}
+
+.message-bubble.self {
+  background-color: #e0c3fc;
+  align-self: flex-end;
+}
+
+.message-bubble.other {
+  background-color: #ffffff;
+  align-self: flex-start;
+}
+
+.message-bubble p {
+  margin: 0;
+}
+
+.timestamp {
+  font-size: 12px;
+  color: #888;
+  position: absolute;
+  bottom: -15px;
+  left: 50%;
+  transform: translateX(-50%);
+}
+
+.input-area {
+  display: flex;
+  padding: 10px;
+  background-color: #ffffff;
+  border-top: 1px solid #ddd;
+}
+
+.input-area .ant-input {
+  flex: 1;
+  margin-right: 10px;
+}
+
+.input-area .ant-btn {
+  background-color: #6a0dad;
+  color: white;
+  border: none;
+}
+
+.input-area .ant-btn:hover {
+  background-color: #5b008a;
+}
+
+.input-area .ant-upload.ant-upload-select {
+  margin-left: 10px;
+}
+
+.input-area .ant-upload-select-button {
+  background-color: #6a0dad;
+  color: white;
+  border: none;
+  border-radius: 50%;
+  width: 32px;
+  height: 32px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.input-area .ant-upload-select-button:hover {
+  background-color: #5b008a;
+}
+</style>

+ 118 - 0
src/views/LoginView.vue

@@ -0,0 +1,118 @@
+<template>
+  <div class="login-container">
+    <div class="login-form">
+      <div class="logo">
+        <h1>应用名称</h1>
+      </div>
+      <a-form :model="formState" name="login" @finish="handleFinish">
+        <a-form-item label="用户名" name="username" :rules="[{ required: true, message: '请输入用户名' }]">
+          <a-input v-model:value="formState.username" />
+        </a-form-item>
+        <a-form-item label="密码" name="password" :rules="[{ required: true, message: '请输入密码' }]">
+          <a-input-password v-model:value="formState.password" />
+        </a-form-item>
+        <a-form-item>
+          <a-checkbox v-model:checked="formState.remember">忘记我</a-checkbox>
+        </a-form-item>
+        <a-form-item>
+          <a-button type="primary" html-type="submit">登录</a-button>
+        </a-form-item>
+      </a-form>
+    </div>
+  </div>
+</template>
+
+<script>
+import { reactive } from 'vue';
+import { message } from 'ant-design-vue';
+import { useRouter } from 'vue-router';
+
+export default {
+  setup() {
+    const router = useRouter();
+    const formState = reactive({
+      username: '',
+      password: '',
+      remember: false,
+    });
+
+    const handleFinish = (values) => {
+      // 这里可以添加登录逻辑,例如调用API验证用户名和密码
+      if (values.username === 'admin' && values.password === 'password') {
+        message.success('登录成功');
+        // 重定向到聊天界面
+        router.push({ name: 'chat' });
+      } else {
+        message.error('用户名或密码错误');
+      }
+    };
+
+    return {
+      formState,
+      handleFinish,
+    };
+  },
+};
+</script>
+
+<style scoped>
+.login-container {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  height: 100vh;
+  background-color: #f0f0f0;
+}
+
+.login-form {
+  width: 60%;
+  max-width: 400px;
+  background-color: rgba(255, 255, 255, 0.9);
+  padding: 20px;
+  border-radius: 8px;
+  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
+}
+
+.logo {
+  text-align: center;
+  margin-bottom: 20px;
+}
+
+.logo img {
+  width: 100px;
+  height: 100px;
+  margin-bottom: 10px;
+}
+
+.logo h1 {
+  font-size: 24px;
+  font-weight: bold;
+  color: #333;
+}
+
+.ant-form-item-label {
+  font-size: 14px;
+}
+
+.ant-input {
+  border-radius: 4px;
+  border-color: #ccc;
+}
+
+.ant-checkbox {
+  font-size: 14px;
+  color: #333;
+}
+
+.ant-btn-primary {
+  background-color: #004085;
+  border-color: #004085;
+  font-size: 16px;
+  font-weight: bold;
+}
+
+.ant-btn-primary:hover {
+  background-color: #0056b3;
+  border-color: #0056b3;
+}
+</style>

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff