code
stringlengths
1
1.05M
repo_name
stringlengths
6
83
path
stringlengths
3
242
language
stringclasses
222 values
license
stringclasses
20 values
size
int64
1
1.05M
<!DOCTYPE html> <html lang=""> <head> <meta charset="UTF-8"> <link rel="icon" href="/favicon.ico"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <title>Vite App</title> </head> <body> <div id="app"></div> <script type="module" src="/src/main.js"></script> </body> </html>
2302_81331056/travel
index.html
HTML
unknown
634
<script setup> </script> <template> <RouterView /> </template> <style scoped> </style>
2302_81331056/travel
src/App.vue
Vue
unknown
93
import request from '@/utils/request' // 获取文章列表 export const getArticleList = async () => { try { const response = await request.get('/api/user/forum/article'); // 检查并处理响应数据,确保返回标准格式 if (response && response.data) { // 如果数据直接就是数组格式 if (Array.isArray(response.data)) { return { data: response.data }; } // 如果数据是包含列表的对象 else if (response.data.list && Array.isArray(response.data.list)) { return { data: response.data.list }; } else if (response.data.items && Array.isArray(response.data.items)) { return { data: response.data.items }; } else if (response.data.articles && Array.isArray(response.data.articles)) { return { data: response.data.articles }; } // 如果数据是其他结构,但有data字段是数组 else if (response.data.data && Array.isArray(response.data.data)) { return { data: response.data.data }; } // 未知格式,返回空数组 else { console.error('未能识别的API返回格式', response.data); return { data: [] }; } } return { data: [] }; } catch (error) { console.error('API请求失败:', error); throw error; } }; // 获取文章评论 export const getArticleComments = (articleId) => { // 保留/api前缀,因为系统已做重定向 return request.get('/api/user/forum/comment', { params: { articleId } }); }; // 添加评论 export const addArticleComment = (articleId, commentData) => { // 构造符合API要求的请求数据 const requestData = { // 文章ID(必需) articleId: articleId, // 用户ID(必需)- 这里使用commentData中的userId,或者从存储/context中获取 userId: commentData.userId || 1, // 默认使用1,实际应从用户会话中获取 // 评论内容(必需) content: commentData.content, // 可选参数 ...(commentData.id && { id: commentData.id }), ...(commentData.createTime && { createTime: commentData.createTime }) }; return request.post('/api/user/forum/comment', requestData); }; // 点赞文章 export const likeArticle = (articleId) => { return request.post(`/api/user/forum/article/${articleId}/like`); }; // 创建新帖子 export const createArticle = (articleData) => { // 转换为后端期望的格式 const requestData = { // 可选ID ...(articleData.id && { id: articleData.id }), // 用户ID - 用于获取用户信息 ...(articleData.userId && { userId: articleData.userId }), // 标题 title: articleData.title, // 富文本内容 richContent: articleData.content || articleData.richContent, // 可选参数-点赞数 ...(articleData.likeCount !== undefined && { likeCount: articleData.likeCount }), // 可选参数-创建时间(默认由后端生成) ...(articleData.createTime && { createTime: articleData.createTime }), // 分类信息 ...(articleData.category && { category: articleData.category }) }; return request.post('/api/user/forum/article', requestData); };
2302_81331056/travel
src/api/article.js
JavaScript
unknown
3,204
import request from '@/utils/request' /** * 发送聊天消息并接收流式响应 * @param {string} message - 用户发送的消息 * @param {string} sessionId - 当前会话ID,用于维持对话上下文 * @returns {Promise<ReadableStream>} - 返回可读流 */ export const sendChatMessage = async (message, sessionId) => { try { // 始终包含sessionId参数,即使它是空值 const requestData = { message, sessionId: sessionId || '' // 确保sessionId为空时传'' }; // 使用全局request实例的配置来发送流式请求 // axios不支持直接处理流式响应,所以需要使用fetch const token = localStorage.getItem('user_token'); // 创建与request.js一致的请求配置 const headers = { 'Content-Type': 'application/json', 'Accept': 'text/event-stream' // 接受SSE格式的响应 }; if (token) { headers['Authorization'] = `Bearer ${token}`; } // 根据Vite代理配置使用正确的API路径 // Vite配置中/api被重写到后端服务,所以请求路径应该包含/api前缀 const response = await fetch('/api/user/chat/stream', { method: 'POST', headers, body: JSON.stringify(requestData) }); if (!response.ok) { const errorData = await response.json().catch(() => ({})); throw new Error(errorData.message || `请求失败: ${response.status}`); } return response.body; } catch (error) { console.error('发送聊天消息出错:', error); throw error; } }; /** * 处理流式响应数据 * @param {ReadableStream} stream - 可读流 * @param {Function} onChunk - 每接收到一个数据块时的回调函数 * @param {Function} onError - 发生错误时的回调函数 * @param {Function} onComplete - 流结束时的回调函数 */ export const processStreamResponse = async (stream, onChunk, onError, onComplete) => { const reader = stream.getReader(); try { while (true) { const { done, value } = await reader.read(); if (done) break; // 将二进制数据转换为文本 const chunk = new TextDecoder().decode(value); // 处理可能的多个数据块 const lines = chunk.split('\n').filter(line => line.trim()); for (const line of lines) { try { // 处理SSE格式 - 检查并移除"data:"前缀 let jsonStr = line; if (line.startsWith('data:')) { jsonStr = line.substring(5); // 移除"data:"前缀 } // 解析JSON数据 const data = JSON.parse(jsonStr); onChunk(data); } catch (e) { console.error('解析JSON出错:', e, line); onError(e); } } } onComplete(); } catch (error) { console.error('处理流式响应出错:', error); onError(error); } }; /** * 创建旅行计划 * @param {Object} planData - 旅行计划数据 * @param {string} planData.title - 旅行主题 * @param {string} planData.text - 旅行需求 * @param {string} planData.startTime - 旅行开始时间 * @param {string} planData.endTime - 旅行结束时间 * @returns {Promise} - 返回请求结果 */ export const createTravelPlan = (planData) => { return request.post('/api/user/plan/create', planData); };
2302_81331056/travel
src/api/chat.js
JavaScript
unknown
3,378
import request from '@/utils/request' export const login = (data) => { return request.post('/api/user/login', data) } export const register = (data) => { return request.post('/api/user/register', data) }
2302_81331056/travel
src/api/login.js
JavaScript
unknown
216
import request from '@/utils/request' // 获取用户信息 - 需要认证的请求 export const getUserProfile = () => { return request.get('/api/user/info') } // 更新用户信息 - 需要认证的请求 export const updateUserProfile = (data) => { return request.put('/api/user/update', data) } // 获取用户统计信息 - 需要认证的请求 export const getUserStats = () => { return request.get('/api/user/stats') }
2302_81331056/travel
src/api/user.js
JavaScript
unknown
442
/* 清除所有标签的内外边距 */ * { margin: 0; padding: 0; box-sizing: border-box; /* 使用CSS3盒子模型 */ } /* 清除列表项的默认样式 */ ul, ol { list-style: none; } /* 设置图片的默认样式 */ img { border: 0; /* 去掉图片外边框 */ vertical-align: middle; /* 取消图片底侧空白缝隙 */ } /* 设置链接的默认样式 */ a { color: #666; text-decoration: none; } a:hover { color: #c81623; } /* 设置按钮和输入框的默认样式 */ button, input { /* font-family: Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, "宋体", sans-serif; */ border: 0; /* 去掉默认边框 */ outline: none; /* 去掉输入框的蓝色边框 */ cursor: pointer; /* 鼠标悬停时变成小手 */ } /* 设置body的默认样式 */ body { -webkit-font-smoothing: antialiased; /* 抗锯齿 */ background-color: #fff; /* font: 12px/1.5 Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, "宋体", sans-serif; */ color: #666; } /* 清除浮动 */ clearfix:after { visibility: hidden; clear: both; display: block; content: "."; height: 0; } .clearfix { /* *zoom: 1; 兼容IE */ /* 使用更现代的清除浮动方法 */ display: flow-root; }
2302_81331056/travel
src/assets/main.css
CSS
unknown
1,306
<script setup> import { defineProps } from 'vue'; const props = defineProps({ title: { type: String, required: true }, description: { type: String, default: '' }, icon: { type: String, default: '' }, showIcon: { type: Boolean, default: true } }); </script> <template> <div class="form-header"> <div v-if="showIcon && icon" class="header-icon"> <i :class="icon"></i> </div> <h2 class="header-title">{{ title }}</h2> <p v-if="description" class="header-description">{{ description }}</p> <div class="header-divider"></div> <slot></slot> </div> </template> <style scoped> .form-header { text-align: center; margin-bottom: 30px; } .header-icon { display: flex; justify-content: center; margin-bottom: 16px; } .header-icon i { width: 60px; height: 60px; background-color: rgba(0, 195, 137, 0.1); color: #00c389; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; } .header-title { font-size: 24px; font-weight: 600; color: #1F2937; margin-bottom: 8px; } .header-description { font-size: 16px; color: #6B7280; margin-bottom: 24px; max-width: 400px; margin-left: auto; margin-right: auto; } .header-divider { width: 60px; height: 4px; background-color: #00c389; border-radius: 2px; margin: 0 auto 24px; } </style>
2302_81331056/travel
src/components/com_login/FormHeader.vue
Vue
unknown
1,402
<script setup> const props = defineProps({ tabs: { type: Array, required: true, default: () => [] }, activeTab: { type: Number, default: 0 } }); const emit = defineEmits(['tab-change']); const switchTab = (index) => { emit('tab-change', index); }; </script> <template> <div class="form-tabs"> <div class="tabs-container"> <div v-for="(tab, index) in tabs" :key="index" :class="['tab', { active: index === activeTab }]" @click="switchTab(index)" > <i v-if="tab.icon" :class="tab.icon" class="tab-icon"></i> <span class="tab-text">{{ tab.label }}</span> </div> </div> <div class="tab-slider"> <div class="tab-slider-indicator" :style="{ transform: `translateX(${activeTab * 100}%)` }"></div> </div> </div> </template> <style scoped> .form-tabs { margin-bottom: 30px; position: relative; } .tabs-container { display: flex; border-bottom: 1px solid #E5E7EB; position: relative; } .tab { flex: 1; text-align: center; padding: 16px 0; cursor: pointer; font-weight: 500; color: #6B7280; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; gap: 8px; } .tab:hover { color: #00c389; } .tab.active { color: #00c389; font-weight: 600; } .tab-icon { font-size: 16px; } .tab-text { font-size: 16px; } .tab-slider { position: relative; height: 3px; margin-top: -2px; } .tab-slider-indicator { position: absolute; bottom: 0; left: 0; width: 50%; height: 3px; background-color: #00c389; transition: transform 0.3s ease; border-radius: 3px 3px 0 0; } </style>
2302_81331056/travel
src/components/com_login/FormTabs.vue
Vue
unknown
1,678
<script setup> import { ref, reactive } from 'vue'; import { useRouter } from 'vue-router'; import { useAuthStore } from '@/stores/auth'; // 定义表单数据 const loginForm = reactive({ username: '', password: '' }); // 表单验证错误 const errors = reactive({ username: '', password: '', general: '' }); // 加载状态 const isLoading = ref(false); // 密码可见性控制 const passwordVisible = ref(false); const togglePasswordVisibility = () => { passwordVisible.value = !passwordVisible.value; }; // 获取路由器实例和auth store const router = useRouter(); const authStore = useAuthStore(); // 定义emit以便通知父组件登录成功 const emit = defineEmits(['login-success']); // 验证表单 const validateForm = () => { let isValid = true; // 重置错误 errors.username = ''; errors.password = ''; errors.general = ''; // 验证用户名 if (!loginForm.username) { errors.username = '请输入用户名'; isValid = false; } else if (loginForm.username.length < 3) { errors.username = '用户名长度不能少于3个字符'; isValid = false; } // 验证密码 if (!loginForm.password) { errors.password = '请输入密码'; isValid = false; } else if (loginForm.password.length < 6) { errors.password = '密码长度不能少于6位'; isValid = false; } return isValid; }; // 处理登录表单提交 const handleLogin = async () => { if (!validateForm()) return; try { // 调用store中的登录方法 const result = await authStore.login({ username: loginForm.username, password: loginForm.password }); if (result.success) { console.log('登录成功,用户信息:', authStore.userInfo); // 通知父组件登录成功 emit('login-success', authStore.userInfo); // 跳转到首页 router.push('/'); } else { // 显示错误信息 errors.general = result.message; } } catch (error) { console.error('登录出错:', error); errors.general = '登录过程中发生错误,请稍后再试'; } }; </script> <template> <form @submit.prevent="handleLogin" class="login-form"> <!-- 一般错误信息 --> <div v-if="errors.general" class="error-message general"> <i class="fas fa-exclamation-circle"></i> {{ errors.general }} </div> <!-- 用户名输入框 --> <div class="form-group"> <label for="username" class="form-label">用户名</label> <div class="input-group"> <i class="fas fa-user input-icon"></i> <input id="username" v-model="loginForm.username" type="text" class="form-input" placeholder="请输入用户名" :class="{ 'error': errors.username }" /> </div> <p v-if="errors.username" class="error-message">{{ errors.username }}</p> </div> <!-- 密码输入框 --> <div class="form-group"> <label for="password" class="form-label">密码</label> <div class="input-group"> <i class="fas fa-lock input-icon"></i> <input id="password" v-model="loginForm.password" :type="passwordVisible ? 'text' : 'password'" class="form-input" placeholder="请输入密码" :class="{ 'error': errors.password }" /> <i :class="passwordVisible ? 'fas fa-eye' : 'fas fa-eye-slash'" class="toggle-password" @click="togglePasswordVisibility" ></i> </div> <p v-if="errors.password" class="error-message">{{ errors.password }}</p> </div> <!-- 登录按钮 --> <button type="submit" class="login-button" :disabled="isLoading" > <i v-if="isLoading" class="fas fa-spinner fa-spin"></i> <span v-else>登录</span> </button> </form> </template> <style scoped> .login-form { width: 100%; height: 100%; max-height: none; /* 移除最大高度限制 */ overflow-y: visible; /* 移除垂直滚动 */ padding-right: 0; /* 移除为滚动条预留的空间 */ } .form-group { margin-bottom: 15px; /* 增加表单项之间的间距 */ } .form-label { display: block; margin-bottom: 5px; /* 增加标签与输入框之间的间距 */ font-weight: 500; font-size: 0.9rem; color: #4B5563; } .input-group { position: relative; } /* 输入框左侧图标 */ .input-group .input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9CA3AF; } /* 密码可见性切换图标 */ .input-group .toggle-password { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #9CA3AF; cursor: pointer; font-size: 16px; z-index: 2; } /* 隐藏浏览器自带的密码显示按钮 */ input[type="password"]::-ms-reveal, input[type="password"]::-ms-clear { display: none; } input[type="password"]::-webkit-credentials-auto-fill-button, input[type="password"]::-webkit-contacts-auto-fill-button { visibility: hidden; display: none !important; pointer-events: none; position: absolute; right: 0; } .form-input { width: 100%; padding: 12px 40px 12px 40px; /* 增加输入框内边距 */ border: 1px solid #E5E7EB; border-radius: 8px; font-size: 14px; transition: all 0.3s ease; background-color: #F9FAFB; height: 42px; /* 固定高度确保一致性 */ } .form-input:focus { outline: none; border-color: #00c389; box-shadow: 0 0 0 3px rgba(0, 195, 137, 0.1); background-color: #fff; } .form-input::placeholder { color: #9CA3AF; } .form-input.error { border-color: #EF4444; } .error-message { color: #EF4444; font-size: 0.75rem; /* 缩小错误信息字体 */ margin-top: 1px; /* 减少错误信息上方间距 */ } .login-button { width: 100%; padding: 12px; /* 增加按钮内边距 */ background-color: #ff5a5a; color: white; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.3s ease; display: flex; justify-content: center; align-items: center; margin-top: 18px; /* 增加按钮上方间距 */ height: 45px; /* 固定按钮高度 */ } .login-button:hover { background-color: #ff3939; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(255, 90, 90, 0.3); } .login-button:disabled { opacity: 0.7; cursor: not-allowed; transform: none; box-shadow: none; } @media (max-width: 576px) { .form-input { padding: 10px 40px 10px 36px; font-size: 14px; } .input-group .input-icon, .input-group .toggle-password { font-size: 14px; } } /* 移除自定义滚动条样式 */ .login-form::-webkit-scrollbar, .login-form::-webkit-scrollbar-track, .login-form::-webkit-scrollbar-thumb, .login-form::-webkit-scrollbar-thumb:hover { display: none; } /* 添加一般错误信息样式 */ .error-message.general { background-color: rgba(239, 68, 68, 0.1); color: #EF4444; padding: 10px; border-radius: 6px; margin-bottom: 15px; display: flex; align-items: center; gap: 8px; } </style>
2302_81331056/travel
src/components/com_login/LoginForm.vue
Vue
unknown
7,149
<script setup> import { reactive, ref, computed } from 'vue'; import { useRouter } from 'vue-router'; import { useAuthStore } from '@/stores/auth'; // 定义props和emits const props = defineProps({ onSwitchToLogin: Function }); const emit = defineEmits(['register-success']); // 路由器和auth store const router = useRouter(); const authStore = useAuthStore(); // 表单状态 const formData = reactive({ username: '', email: '', password: '', firstName: '', lastName: '', gender: '', preferredLanguage: 'zh' }); // 错误信息 const errors = reactive({ username: '', email: '', password: '', firstName: '', lastName: '', gender: '', preferredLanguage: '', general: '' }); // 加载状态 const loading = ref(false); // 邮箱验证正则 const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; // 密码可见性控制 const passwordVisible = ref(false); const togglePasswordVisibility = () => { passwordVisible.value = !passwordVisible.value; }; // 表单验证 const validateForm = () => { let isValid = true; // 重置错误 errors.username = ''; errors.email = ''; errors.password = ''; errors.firstName = ''; errors.lastName = ''; errors.gender = ''; errors.preferredLanguage = ''; errors.general = ''; // 用户名验证 if (!formData.username.trim()) { errors.username = '请输入用户名'; isValid = false; } else if (formData.username.length < 3) { errors.username = '用户名长度不能少于3个字符'; isValid = false; } // 邮箱验证 if (!formData.email.trim()) { errors.email = '请输入邮箱'; isValid = false; } else if (!emailRegex.test(formData.email)) { errors.email = '请输入有效的邮箱地址'; isValid = false; } // 密码验证 if (!formData.password) { errors.password = '请输入密码'; isValid = false; } else if (formData.password.length < 6) { errors.password = '密码长度不能少于6个字符'; isValid = false; } return isValid; }; // 处理注册逻辑 const handleRegister = async () => { // 验证表单 if (!validateForm()) return; loading.value = true; try { // 准备请求数据 const requestData = { username: formData.username, email: formData.email, password: formData.password, firstName: formData.firstName, lastName: formData.lastName, gender: formData.gender, preferredLanguage: formData.preferredLanguage }; console.log('发送注册请求,数据:', requestData); // 调用auth store的注册方法 const result = await authStore.register(requestData); console.log('注册结果:', result); if (result.success) { console.log('注册成功,用户信息:', authStore.userInfo); // 发出注册成功事件 emit('register-success', authStore.userInfo); // 路由跳转到首页 router.push('/'); } else { // 处理字段特定的错误 if (result.field === 'username') { errors.username = result.message || '用户名已被使用'; } else if (result.field === 'email') { errors.email = result.message || '邮箱已被使用'; } else { errors.general = result.message || '注册失败,请稍后再试'; } } } catch (err) { console.error('注册处理错误:', err); errors.general = '注册过程中发生错误,请稍后再试'; } finally { loading.value = false; } }; </script> <template> <div class="register-form"> <!-- 错误信息提示 --> <div v-if="errors.general" class="error-message general"> <i class="fas fa-exclamation-circle"></i> {{ errors.general }} </div> <form @submit.prevent="handleRegister"> <!-- 用户名 --> <div class="form-group"> <label for="register-username">用户名</label> <div class="input-group"> <i class="fas fa-user"></i> <input id="register-username" v-model="formData.username" type="text" placeholder="请输入用户名" :class="{ 'error': errors.username }" > </div> <div v-if="errors.username" class="error-message"> {{ errors.username }} </div> </div> <!-- 姓名 --> <div class="form-row two-columns"> <div class="form-group"> <label for="firstName">名</label> <div class="input-group"> <i class="fas fa-user-tag"></i> <input id="firstName" v-model="formData.firstName" type="text" placeholder="请输入名字" :class="{ 'error': errors.firstName }" > </div> <div v-if="errors.firstName" class="error-message"> {{ errors.firstName }} </div> </div> <div class="form-group"> <label for="lastName">姓</label> <div class="input-group"> <i class="fas fa-user-tag"></i> <input id="lastName" v-model="formData.lastName" type="text" placeholder="请输入姓氏" :class="{ 'error': errors.lastName }" > </div> <div v-if="errors.lastName" class="error-message"> {{ errors.lastName }} </div> </div> </div> <!-- 邮箱 --> <div class="form-group"> <label for="register-email">邮箱</label> <div class="input-group"> <i class="fas fa-envelope"></i> <input id="register-email" v-model="formData.email" type="email" placeholder="请输入邮箱" :class="{ 'error': errors.email }" > </div> <div v-if="errors.email" class="error-message"> {{ errors.email }} </div> </div> <!-- 密码 --> <div class="form-group"> <label for="register-password">密码</label> <div class="input-group"> <i class="fas fa-lock"></i> <input id="register-password" v-model="formData.password" :type="passwordVisible ? 'text' : 'password'" placeholder="请输入密码" :class="{ 'error': errors.password }" > <i :class="passwordVisible ? 'fas fa-eye' : 'fas fa-eye-slash'" class="toggle-password" @click="togglePasswordVisibility" ></i> </div> <div v-if="errors.password" class="error-message"> {{ errors.password }} </div> </div> <!-- 性别与偏好语言 --> <div class="form-row two-columns"> <div class="form-group"> <label>性别</label> <div class="radio-group"> <label class="radio-label"> <input type="radio" value="male" v-model="formData.gender"> <span class="radio-custom"></span> <span>男</span> </label> <label class="radio-label"> <input type="radio" value="female" v-model="formData.gender"> <span class="radio-custom"></span> <span>女</span> </label> <label class="radio-label"> <input type="radio" value="other" v-model="formData.gender"> <span class="radio-custom"></span> <span>其他</span> </label> </div> <div v-if="errors.gender" class="error-message"> {{ errors.gender }} </div> </div> <div class="form-group"> <label for="language">偏好语言</label> <div class="select-wrapper"> <select id="language" v-model="formData.preferredLanguage"> <option value="zh">中文</option> <option value="en">英文</option> </select> <i class="fas fa-chevron-down select-arrow"></i> </div> </div> </div> <!-- 注册按钮 --> <button type="submit" class="btn-register" :disabled="loading"> <i v-if="loading" class="fas fa-spinner fa-spin"></i> <span v-else>注册</span> </button> </form> </div> </template> <style scoped> .register-form { width: 100%; height: 100%; max-height: none; /* 移除最大高度限制 */ overflow-y: visible; /* 移除垂直滚动 */ padding-right: 0; /* 移除为滚动条预留的空间 */ } .form-group { margin-bottom: 15px; /* 增加表单项之间的间距 */ } .form-group label { display: block; margin-bottom: 5px; /* 增加标签与输入框之间的间距 */ font-weight: 500; font-size: 0.9rem; color: #333; } .form-row { display: flex; gap: 8px; /* 减少水平间距 */ margin-bottom: 0; } .form-row.two-columns > .form-group { flex: 1; } .input-group { position: relative; display: flex; align-items: center; } /* 输入框左侧图标 */ .input-group i:not(.toggle-password) { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #888; font-size: 16px; } /* 密码可见性切换图标 */ .input-group .toggle-password { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #888; cursor: pointer; font-size: 16px; z-index: 2; } .input-group input, .select-wrapper select { width: 100%; padding: 12px 40px 12px 40px; /* 增加输入框内边距 */ border: 1px solid #ccc; border-radius: 6px; font-size: 14px; transition: border-color 0.3s, box-shadow 0.3s; height: 42px; /* 固定高度确保一致性 */ } .input-group input.no-left-icon { padding-left: 15px; } .input-group input:focus, .select-wrapper select:focus { outline: none; border-color: #00c389; box-shadow: 0 0 0 3px rgba(0, 195, 137, 0.1); } .input-group input.error { border-color: #ff5a5a; } /* 隐藏浏览器自带的密码显示按钮 */ input[type="password"]::-ms-reveal, input[type="password"]::-ms-clear { display: none; } input[type="password"]::-webkit-credentials-auto-fill-button, input[type="password"]::-webkit-contacts-auto-fill-button { visibility: hidden; display: none !important; pointer-events: none; position: absolute; right: 0; } .select-wrapper { position: relative; } .select-wrapper select { appearance: none; padding-right: 30px; background-color: white; } .select-arrow { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: #888; } .radio-group { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 2px; /* 减少单选按钮与标签间距 */ } .radio-label { display: flex; align-items: center; cursor: pointer; gap: 8px; } .radio-label input { position: absolute; opacity: 0; } .radio-custom { width: 16px; /* 减小单选按钮尺寸 */ height: 16px; border-radius: 50%; border: 1px solid #ccc; display: inline-block; position: relative; } .radio-label input:checked ~ .radio-custom::after { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 8px; /* 减小单选按钮内部圆点尺寸 */ height: 8px; border-radius: 50%; background-color: #00c389; } .radio-label input:checked ~ .radio-custom { border-color: #00c389; } .error-message { color: #ff5a5a; font-size: 0.75rem; /* 缩小错误信息字体 */ margin-top: 1px; /* 减少错误信息上方间距 */ } .error-message.general { padding: 6px; margin-bottom: 8px; font-size: 0.75rem; } .btn-register { width: 100%; padding: 12px; /* 增加按钮内边距 */ background-color: #ff5a5a; color: white; border: none; border-radius: 6px; font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.3s ease; display: flex; justify-content: center; align-items: center; margin-top: 18px; /* 增加按钮上方间距 */ height: 45px; /* 固定按钮高度 */ } .btn-register:hover { background-color: #ff3939; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(255, 90, 90, 0.3); } .btn-register:disabled { opacity: 0.7; cursor: not-allowed; transform: none; box-shadow: none; } @media (max-width: 576px) { .form-row { flex-direction: column; gap: 0; } .radio-group { gap: 12px; } .input-group input, .select-wrapper select { padding: 10px 40px 10px 36px; font-size: 14px; } .input-group i:not(.toggle-password), .input-group .toggle-password { font-size: 14px; } } /* 移除自定义滚动条样式 */ .register-form::-webkit-scrollbar, .register-form::-webkit-scrollbar-track, .register-form::-webkit-scrollbar-thumb, .register-form::-webkit-scrollbar-thumb:hover { display: none; } </style>
2302_81331056/travel
src/components/com_login/RegisterForm.vue
Vue
unknown
13,023
<script setup> import { defineProps, defineEmits } from 'vue'; const props = defineProps({ categories: { type: Array, required: true }, activeCategory: { type: String, required: true }, forumPosts: { type: Array, required: true } }); const emit = defineEmits(['update:activeCategory']); const setActiveCategory = (category) => { emit('update:activeCategory', category); }; </script> <template> <div class="categories-sidebar"> <h3 class="sidebar-title">Categories</h3> <div class="categories-list"> <div v-for="category in categories" :key="category.id" class="category-item" :class="{ 'active': activeCategory === category.id }" @click="setActiveCategory(category.id)" > <span class="category-icon">{{ category.icon }}</span> <span class="category-name">{{ category.name }}</span> <span class="category-count">{{ category.id === 'all' ? forumPosts.length : forumPosts.filter(post => post.category === category.id).length }}</span> </div> </div> <div class="forum-stats"> <h3 class="sidebar-title">Forum Stats</h3> <div class="stat-item"> <span class="stat-icon">👥</span> <span class="stat-label">Users</span> <span class="stat-value">3,245</span> </div> <div class="stat-item"> <span class="stat-icon">📝</span> <span class="stat-label">Topics</span> <span class="stat-value">1,567</span> </div> <div class="stat-item"> <span class="stat-icon">💬</span> <span class="stat-label">Replies</span> <span class="stat-value">12,890</span> </div> </div> </div> </template> <style scoped> /* 侧边栏样式 */ .categories-sidebar { width: 300px; flex-shrink: 0; } .sidebar-title { font-size: 1.2rem; color: #333; margin-bottom: 20px; font-weight: 600; } .categories-list { background-color: #f8f8f8; border-radius: 10px; overflow: hidden; margin-bottom: 30px; } .category-item { display: flex; align-items: center; padding: 15px 20px; cursor: pointer; transition: all 0.3s; position: relative; } .category-item:not(:last-child) { border-bottom: 1px solid #eeeeee; } .category-item:hover { background-color: #f0f0f0; } .category-item.active { background-color: #edf9f5; } .category-item.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background-color: #00c389; } .category-icon { margin-right: 12px; font-size: 1.2rem; } .category-name { flex-grow: 1; color: #333; } .category-count { background-color: #e4e4e4; color: #555; font-size: 0.85rem; padding: 3px 8px; border-radius: 10px; transition: all 0.3s; } .category-item.active .category-count { background-color: #00c389; color: white; } /* 统计信息样式 */ .forum-stats { background-color: #f8f8f8; border-radius: 10px; padding: 20px; } .stat-item { display: flex; align-items: center; margin-bottom: 15px; } .stat-item:last-child { margin-bottom: 0; } .stat-icon { margin-right: 10px; font-size: 1.1rem; } .stat-label { flex-grow: 1; color: #555; } .stat-value { font-weight: 600; color: #333; } @media (max-width: 1200px) { .categories-sidebar { width: 100%; margin-bottom: 30px; } .forum-stats { display: flex; justify-content: space-around; } .stat-item { margin-bottom: 0; } } @media (max-width: 768px) { .forum-stats { flex-direction: column; } .stat-item { margin-bottom: 15px; } } </style>
2302_81331056/travel
src/components/forum/CategorySidebar.vue
Vue
unknown
3,699
<script setup> import { defineProps } from 'vue'; import defaultAvatar from '@/assets/home/avatar1.jpg'; const props = defineProps({ comment: { type: Object, required: true } }); // 格式化时间 const formatDate = (dateString) => { if (!dateString) return '未知时间'; try { const date = new Date(dateString); if (isNaN(date.getTime())) return dateString; return date.toLocaleString('zh-CN', { year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' }); } catch (e) { console.error('日期格式化错误:', e); return dateString; } }; </script> <template> <div class="comment-item"> <div class="comment-avatar"> <img :src="comment.avatarUrl || defaultAvatar" :alt="comment.nickname || '用户头像'" @error="$event.target.src = defaultAvatar" loading="lazy" > </div> <div class="comment-content"> <div class="comment-header"> <span class="comment-author">{{ comment.nickname || comment.username || `用户${comment.userId}` }}</span> <span class="comment-time">{{ formatDate(comment.createTime) }}</span> </div> <div class="comment-text rich-content" v-html="comment.content"></div> </div> </div> </template> <style scoped> .comment-item { display: flex; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid #f0f0f0; } .comment-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; } .comment-avatar { width: 36px; height: 36px; margin-right: 12px; border-radius: 50%; overflow: hidden; } .comment-avatar img { width: 100%; height: 100%; object-fit: cover; } .comment-content { flex: 1; } .comment-header { display: flex; justify-content: space-between; margin-bottom: 5px; } .comment-author { font-weight: 500; color: #333; font-size: 0.9rem; } .comment-time { color: #999; font-size: 0.8rem; } .comment-text { font-size: 0.95rem; color: #555; line-height: 1.5; } /* 富文本内容样式 */ .rich-content :deep(img) { max-width: 100%; height: auto; border-radius: 4px; margin: 4px 0; } .rich-content :deep(a) { color: #00c389; text-decoration: none; } .rich-content :deep(a:hover) { text-decoration: underline; } .rich-content :deep(p) { margin: 0.25em 0; } .rich-content :deep(ul), .rich-content :deep(ol) { padding-left: 16px; margin: 0.25em 0; } .rich-content :deep(blockquote) { border-left: 3px solid #e0e0e0; padding-left: 12px; margin: 0.25em 0; color: #777; } .rich-content :deep(h1), .rich-content :deep(h2), .rich-content :deep(h3), .rich-content :deep(h4), .rich-content :deep(h5), .rich-content :deep(h6) { margin: 0.5em 0 0.25em; color: #333; font-size: 1em; } </style>
2302_81331056/travel
src/components/forum/CommentItem.vue
Vue
unknown
2,850
<script setup> import { defineProps, defineEmits, ref } from 'vue'; import CommentItem from './CommentItem.vue'; import { addArticleComment } from '@/api/article'; const props = defineProps({ comments: { type: Array, default: () => [] }, articleId: { type: [Number, String], required: true }, isLoading: { type: Boolean, default: false } }); const emit = defineEmits(['refresh-comments']); const newComment = ref(''); const isSubmitting = ref(false); const commentError = ref(''); const isFocused = ref(false); const submitComment = async () => { // 这是评论提交的唯一入口点,只通过提交按钮触发 if (!newComment.value.trim()) { commentError.value = '评论内容不能为空'; return; } isSubmitting.value = true; commentError.value = ''; try { // 创建评论数据对象 const commentData = { articleId: props.articleId, content: newComment.value, // 这里可以从store或localStorage中获取当前用户ID // 实际项目中应该从用户会话或存储中获取 userId: 1 // 默认使用1作为示例 }; // 发送评论请求 await addArticleComment(props.articleId, commentData); // 清空评论输入框 newComment.value = ''; // 刷新评论列表 emit('refresh-comments'); } catch (error) { console.error('提交评论失败:', error); commentError.value = '提交评论失败,请稍后再试'; } finally { isSubmitting.value = false; } }; // 文本框焦点事件处理 const handleFocus = () => { isFocused.value = true; }; const handleBlur = () => { isFocused.value = false; }; </script> <template> <div class="comments-container"> <h3 class="comments-title"> 评论 ({{ comments.length }}) </h3> <!-- 评论列表 --> <div v-if="isLoading" class="comments-loading"> <div class="comments-loading-spinner"></div> <p>加载评论中...</p> </div> <div v-else-if="comments.length === 0" class="no-comments"> 暂无评论,快来抢沙发吧 </div> <div v-else class="comments-list"> <CommentItem v-for="comment in comments" :key="comment.id" :comment="comment" /> </div> <!-- 发表评论 --> <div class="comment-form"> <div class="comment-editor-wrapper" :class="{'is-focused': isFocused}"> <textarea v-model="newComment" placeholder="写下你的想法..." class="comment-textarea" :disabled="isSubmitting" @focus="handleFocus" @blur="handleBlur" @keydown.ctrl.enter.prevent ></textarea> </div> <div v-if="commentError" class="comment-error"> <span class="error-icon">⚠️</span> {{ commentError }} </div> <div class="comment-submit-container"> <span class="comment-tips">请文明发言,共建和谐社区</span> <button class="comment-submit" @click="submitComment" :disabled="isSubmitting || !newComment.trim()" > <span v-if="isSubmitting" class="comment-spinner"></span> {{ isSubmitting ? '提交中...' : '发表评论' }} </button> </div> </div> </div> </template> <style scoped> .comments-container { margin-top: 25px; border-top: 1px solid #eee; padding-top: 20px; } .comments-title { font-size: 1.1rem; font-weight: 600; color: #333; margin-bottom: 20px; } .comments-loading { display: flex; flex-direction: column; align-items: center; padding: 20px 0; } .comments-loading-spinner { width: 30px; height: 30px; border: 3px solid #f3f3f3; border-top: 3px solid #00c389; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 10px; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } .no-comments { text-align: center; padding: 20px 0; color: #888; font-style: italic; } .comments-list { margin-bottom: 25px; } .comment-form { margin-top: 30px; } /* 评论输入框容器样式 */ .comment-editor-wrapper { display: flex; margin-bottom: 15px; transition: all 0.3s ease; position: relative; width: 100%; } .editor-container { flex-grow: 1; position: relative; } /* 普通文本框样式 */ .comment-textarea { width: 100%; min-height: 100px; padding: 15px; font-family: inherit; font-size: 0.95rem; line-height: 1.6; border: 1px solid #e0e0e0; border-radius: 8px; resize: vertical; background-color: #ffffff; color: #333; transition: all 0.3s ease; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); } .comment-textarea:focus { outline: none; border-color: #00c389; box-shadow: 0 4px 12px rgba(0, 195, 137, 0.1); } .comment-textarea::placeholder { color: #aaa; font-style: italic; } .comment-textarea:disabled { background-color: #f9f9f9; cursor: not-allowed; } /* 聚焦状态样式 */ .comment-editor-wrapper.is-focused .comment-textarea { border-color: #00c389; box-shadow: 0 4px 12px rgba(0, 195, 137, 0.1); } .comment-error { display: flex; align-items: center; color: #e74c3c; margin-bottom: 12px; font-size: 0.9rem; padding: 8px 12px; background-color: #fff8f8; border-radius: 6px; border-left: 3px solid #e74c3c; } .error-icon { margin-right: 6px; } .comment-submit-container { display: flex; justify-content: space-between; align-items: center; } .comment-tips { color: #888; font-size: 0.85rem; font-style: italic; } .comment-submit { display: flex; align-items: center; justify-content: center; padding: 10px 20px; background-color: #00c389; color: white; border: none; border-radius: 6px; font-size: 0.95rem; font-weight: 500; cursor: pointer; transition: all 0.3s; box-shadow: 0 2px 8px rgba(0, 195, 137, 0.2); } .comment-submit:hover:not(:disabled) { background-color: #00a873; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 195, 137, 0.3); } .comment-submit:active:not(:disabled) { transform: translateY(0); box-shadow: 0 2px 4px rgba(0, 195, 137, 0.2); } .comment-submit:disabled { opacity: 0.6; cursor: not-allowed; background-color: #aaa; box-shadow: none; } .comment-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: #fff; animation: spin 1s ease-in-out infinite; margin-right: 8px; } /* 响应式样式 */ @media (max-width: 576px) { .comment-editor-wrapper { flex-direction: column; } .comment-submit-container { flex-direction: column; gap: 10px; } .comment-tips { text-align: center; margin-bottom: 5px; } .comment-submit { width: 100%; } } </style>
2302_81331056/travel
src/components/forum/CommentsList.vue
Vue
unknown
6,894
<script setup> import { defineProps, defineEmits, ref, onMounted } from 'vue'; // 导入QuillEditor富文本编辑器组件 import { QuillEditor } from '@vueup/vue-quill'; import '@vueup/vue-quill/dist/vue-quill.snow.css'; // 导入样式 const props = defineProps({ show: { type: Boolean, default: false }, categories: { type: Array, required: true } }); const emit = defineEmits(['close', 'create-post']); const newPost = ref({ title: '', content: '', // 将在API调用时转换为richContent category: 'general', }); const isSubmitting = ref(false); const error = ref(''); const imageUploadMessage = ref(''); // 图片上传限制配置 const imageConfig = { maxWidth: 1200, // 最大宽度,单位像素 maxHeight: 1200, // 最大高度,单位像素 maxSize: 2, // 最大文件大小,单位MB quality: 0.8 // 压缩质量 }; // 处理图片上传 const handleImageUpload = function() { const input = this.container.querySelector('input.ql-image[type=file]'); if (input) { // 移除旧的监听器 input.removeEventListener('change', handleFileChange); // 添加新的监听器 input.addEventListener('change', handleFileChange); } }; // 处理文件选择事件 const handleFileChange = (e) => { imageUploadMessage.value = ''; const file = e.target.files[0]; // 检查文件类型 if (!file.type.match(/^image\/(jpeg|png|gif|webp|jpg)$/)) { imageUploadMessage.value = '只能上传图片文件(.jpg, .png, .gif, .webp)'; e.target.value = ''; return; } // 检查文件大小 const fileSizeMB = file.size / (1024 * 1024); if (fileSizeMB > imageConfig.maxSize) { imageUploadMessage.value = `图片大小不能超过${imageConfig.maxSize}MB`; e.target.value = ''; return; } // 创建图片对象并处理图片 const img = new Image(); img.onload = () => { // 检查图片尺寸 if (img.width > imageConfig.maxWidth || img.height > imageConfig.maxHeight) { // 创建Canvas进行缩放 const canvas = document.createElement('canvas'); let width = img.width; let height = img.height; // 计算缩放比例 if (width > imageConfig.maxWidth) { const ratio = imageConfig.maxWidth / width; width = imageConfig.maxWidth; height = height * ratio; } if (height > imageConfig.maxHeight) { const ratio = imageConfig.maxHeight / height; height = imageConfig.maxHeight; width = width * ratio; } canvas.width = width; canvas.height = height; // 将图片绘制到Canvas上,实现缩放 const ctx = canvas.getContext('2d'); ctx.drawImage(img, 0, 0, width, height); // 转换为Blob对象 canvas.toBlob((blob) => { const resizedFile = new File([blob], file.name, { type: file.type, lastModified: Date.now() }); // 上传处理后的图片 uploadImage(resizedFile); }, file.type, imageConfig.quality); imageUploadMessage.value = '图片已自动调整大小'; } else { // 如果图片尺寸符合要求,直接上传 uploadImage(file); } }; // 设置图片源 img.src = URL.createObjectURL(file); }; // 上传图片方法 const uploadImage = (file) => { // 这里应当实现上传逻辑,但目前使用本地URL模拟 const url = URL.createObjectURL(file); // 获取QuillEditor实例 const quill = document.querySelector('.ql-editor').parentElement.__vue__; // 获取当前光标位置 const range = quill.getSelection(); // 在光标位置插入图片 quill.insertEmbed(range.index, 'image', url); // 将光标移动到图片后 quill.setSelection(range.index + 1); }; // 富文本编辑器配置 const editorOptions = { theme: 'snow', modules: { toolbar: { container: [ ['bold', 'italic', 'underline', 'strike'], [{ 'list': 'ordered'}, { 'list': 'bullet' }], [{ 'header': [1, 2, 3, 4, 5, 6, false] }], [{ 'color': [] }, { 'background': [] }], ['link', 'image'], ['clean'] ], handlers: { image: handleImageUpload } } }, placeholder: '分享您的想法、问题或经历...' }; const createPost = async () => { if (newPost.value.title.trim() && newPost.value.content.trim()) { isSubmitting.value = true; error.value = ''; try { await emit('create-post', { ...newPost.value }); // 重置表单 newPost.value = { title: '', content: '', category: 'general' }; } catch (err) { error.value = '创建帖子失败,请稍后再试'; console.error('创建帖子出错:', err); } finally { isSubmitting.value = false; } } else { error.value = '请填写标题和内容'; } }; const closeModal = () => { if (!isSubmitting.value) { error.value = ''; emit('close'); } }; </script> <template> <div class="create-post-modal" v-if="show"> <div class="modal-overlay" @click="closeModal"></div> <div class="modal-container"> <div class="modal-header"> <h3 class="modal-title">创建新主题</h3> <button class="modal-close" @click="closeModal" :disabled="isSubmitting">×</button> </div> <div class="modal-body"> <div class="form-group"> <label for="post-title">标题</label> <input type="text" id="post-title" v-model="newPost.title" placeholder="输入主题标题..." class="form-control" :disabled="isSubmitting" > </div> <div class="form-group"> <label for="post-category">分类</label> <select id="post-category" v-model="newPost.category" class="form-control" :disabled="isSubmitting"> <option v-for="category in categories.filter(c => c.id !== 'all')" :key="category.id" :value="category.id"> {{ category.icon }} {{ category.name }} </option> </select> </div> <div class="form-group"> <label for="post-content">内容</label> <!-- 使用富文本编辑器替换普通文本区域 --> <QuillEditor v-model:content="newPost.content" :options="editorOptions" contentType="html" :disabled="isSubmitting" class="editor-container" /> <div v-if="imageUploadMessage" class="image-message"> <span class="image-message-icon">ℹ️</span> {{ imageUploadMessage }} </div> <div class="editor-tips"> 提示:图片大小不超过2MB,宽高不超过1200像素,超过限制将自动缩放 </div> </div> <div v-if="error" class="error-message"> {{ error }} </div> </div> <div class="modal-footer"> <button class="modal-cancel" @click="closeModal" :disabled="isSubmitting">取消</button> <button class="modal-submit" @click="createPost" :disabled="isSubmitting"> <span v-if="isSubmitting" class="spinner"></span> <span>{{ isSubmitting ? '发布中...' : '发布主题' }}</span> </button> </div> </div> </div> </template> <style scoped> /* 创建新帖子弹窗样式 */ .modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); z-index: 100; backdrop-filter: blur(3px); } .modal-container { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 800px; /* 增加宽度以适应编辑器 */ max-height: 90vh; /* 限制最大高度 */ overflow-y: auto; /* 添加滚动条 */ background-color: white; border-radius: 10px; z-index: 101; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); animation: modalFadeIn 0.3s forwards; } .modal-header { position: sticky; top: 0; background-color: white; padding: 20px 25px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; z-index: 1; } .modal-title { font-size: 1.3rem; color: #333; margin: 0; } .modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #999; transition: color 0.3s; } .modal-close:hover:not(:disabled) { color: #333; } .modal-close:disabled { opacity: 0.5; cursor: not-allowed; } .modal-body { padding: 25px; } .form-group { margin-bottom: 20px; } .form-group:last-child { margin-bottom: 0; } .form-group label { display: block; margin-bottom: 8px; font-weight: 500; color: #333; } .form-control { width: 100%; padding: 12px 15px; border: 1px solid #e0e0e0; border-radius: 5px; font-size: 1rem; transition: all 0.3s; } .form-control:focus:not(:disabled) { border-color: #00c389; box-shadow: 0 0 0 3px rgba(0, 195, 137, 0.1); } .form-control:disabled { background-color: #f9f9f9; cursor: not-allowed; } /* 富文本编辑器样式 */ .editor-container { border-radius: 5px; overflow: hidden; min-height: 200px; } .editor-tips { margin-top: 8px; font-size: 0.85rem; color: #888; font-style: italic; } .image-message { margin-top: 8px; padding: 6px 10px; background-color: #f0f8ff; border-radius: 4px; color: #0066cc; font-size: 0.9rem; display: flex; align-items: center; } .image-message-icon { margin-right: 6px; } /* 让编辑器在禁用状态下有明显的视觉提示 */ :deep(.ql-container.ql-disabled) { background-color: #f9f9f9; } :deep(.ql-toolbar) { border-top-left-radius: 5px; border-top-right-radius: 5px; background-color: #f9f9f9; } :deep(.ql-container) { border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; } :deep(.ql-editor img) { max-width: 100%; max-height: 500px; object-fit: contain; } .error-message { color: #e74c3c; font-size: 0.9rem; padding: 8px 12px; background-color: #fef2f2; border-radius: 5px; margin-top: 15px; } .modal-footer { position: sticky; bottom: 0; background-color: white; padding: 20px 25px; border-top: 1px solid #f0f0f0; display: flex; justify-content: flex-end; gap: 15px; z-index: 1; } .modal-cancel { padding: 10px 20px; background-color: #f8f8f8; border: 1px solid #e0e0e0; border-radius: 5px; cursor: pointer; font-size: 1rem; transition: all 0.3s; } .modal-cancel:hover:not(:disabled) { background-color: #f0f0f0; } .modal-cancel:disabled { opacity: 0.5; cursor: not-allowed; } .modal-submit { display: flex; align-items: center; justify-content: center; padding: 10px 25px; background-color: #00c389; color: white; border: none; border-radius: 5px; font-size: 1rem; font-weight: 500; cursor: pointer; transition: all 0.3s; } .modal-submit:hover:not(:disabled) { background-color: #00a873; } .modal-submit:disabled { opacity: 0.7; cursor: not-allowed; } .spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: #fff; animation: spin 1s ease-in-out infinite; margin-right: 8px; } @keyframes spin { to { transform: rotate(360deg); } } @keyframes modalFadeIn { 0% { opacity: 0; transform: translate(-50%, -48%); } 100% { opacity: 1; transform: translate(-50%, -50%); } } </style>
2302_81331056/travel
src/components/forum/CreatePostModal.vue
Vue
unknown
11,619
<script setup> import { defineProps, defineEmits, ref } from 'vue'; const props = defineProps({ isVisible: { type: Boolean, default: false } }); const emit = defineEmits(['update:searchQuery', 'create-post']); const searchQuery = ref(''); const updateSearch = (e) => { searchQuery.value = e.target.value; emit('update:searchQuery', searchQuery.value); }; const openCreatePostModal = () => { emit('create-post'); }; </script> <template> <div class="forum-actions" :class="{ 'animate': isVisible }"> <div class="search-wrapper"> <input type="text" :value="searchQuery" @input="updateSearch" placeholder="Search topics..." class="search-input" > <div class="search-icon">🔍</div> </div> <button class="create-post-btn" @click="openCreatePostModal"> <span class="btn-icon">✏️</span> <span class="btn-text">Create New Topic</span> </button> </div> </template> <style scoped> /* 操作区域样式 */ .forum-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease 0.2s; } .forum-actions.animate { opacity: 1; transform: translateY(0); } .search-wrapper { position: relative; width: 360px; } .search-input { width: 100%; height: 50px; padding: 0 20px 0 45px; border-radius: 25px; border: 1px solid #e0e0e0; background-color: #f8f8f8; font-size: 1rem; transition: all 0.3s; } .search-input:focus { border-color: #00c389; box-shadow: 0 0 0 3px rgba(0, 195, 137, 0.1); background-color: #ffffff; } .search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #999; } .create-post-btn { display: flex; align-items: center; justify-content: center; height: 50px; padding: 0 25px; background-color: #00c389; color: white; border: none; border-radius: 25px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.3s; box-shadow: 0 4px 12px rgba(0, 195, 137, 0.15); } .create-post-btn:hover { background-color: #00a873; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 195, 137, 0.2); } .btn-icon { margin-right: 8px; } @media (max-width: 768px) { .forum-actions { flex-direction: column; gap: 20px; } .search-wrapper { width: 100%; } .create-post-btn { width: 100%; } } </style>
2302_81331056/travel
src/components/forum/ForumActions.vue
Vue
unknown
2,495
<script setup> import { defineProps } from 'vue'; defineProps({ isVisible: { type: Boolean, default: false } }); </script> <template> <div class="forum-header" :class="{ 'animate': isVisible }"> <span class="subtitle">Community</span> <h2 class="title">相聚来华论坛,畅聊在华的那些事儿</h2> <p class="description"> Connect with fellow travelers, share experiences, and get advice from those who have already explored China. Our forum is the perfect place to ask questions and make your journey smoother. </p> </div> </template> <style scoped> /* 头部样式 */ .forum-header { text-align: center; margin-bottom: 50px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease; } .forum-header.animate { opacity: 1; transform: translateY(0); } .subtitle { font-size: 1.5rem; color: #00c389; font-weight: 600; display: block; margin-bottom: 16px; } .title { font-size: 2.5rem; color: #2a2d32; font-weight: 700; margin: 0 0 20px; } .description { max-width: 800px; margin: 0 auto; color: #666; font-size: 1.1rem; line-height: 1.6; } @media (max-width: 576px) { .subtitle { font-size: 1.2rem; } .title { font-size: 2rem; } .description { font-size: 1rem; } } </style>
2302_81331056/travel
src/components/forum/ForumHeader.vue
Vue
unknown
1,314
<script setup> import { defineProps, defineEmits } from 'vue'; const props = defineProps({ currentPage: { type: Number, default: 1 }, totalPages: { type: Number, default: 10 } }); const emit = defineEmits(['page-change']); const changePage = (page) => { if (page >= 1 && page <= props.totalPages) { emit('page-change', page); } }; </script> <template> <div class="pagination-container"> <button class="pagination-btn pagination-prev" @click="changePage(currentPage - 1)" :disabled="currentPage === 1" > Previous </button> <div class="pagination-numbers"> <!-- 第一页始终显示 --> <span class="pagination-number" :class="{ 'active': currentPage === 1 }" @click="changePage(1)" > 1 </span> <!-- 省略号(如果需要) --> <span v-if="currentPage > 3" class="pagination-dots">...</span> <!-- 当前页前后的页码 --> <template v-for="page in totalPages" :key="page"> <span v-if="page !== 1 && page !== totalPages && Math.abs(page - currentPage) <= 1" class="pagination-number" :class="{ 'active': currentPage === page }" @click="changePage(page)" > {{ page }} </span> </template> <!-- 省略号(如果需要) --> <span v-if="currentPage < totalPages - 2" class="pagination-dots">...</span> <!-- 最后一页始终显示 --> <span v-if="totalPages > 1" class="pagination-number" :class="{ 'active': currentPage === totalPages }" @click="changePage(totalPages)" > {{ totalPages }} </span> </div> <button class="pagination-btn pagination-next" @click="changePage(currentPage + 1)" :disabled="currentPage === totalPages" > Next </button> </div> </template> <style scoped> .pagination-container { display: flex; justify-content: center; align-items: center; margin-top: 40px; } .pagination-btn { padding: 8px 15px; background-color: #f8f8f8; border: 1px solid #e0e0e0; border-radius: 5px; cursor: pointer; transition: all 0.3s; } .pagination-btn:hover:not(:disabled) { background-color: #f0f0f0; } .pagination-btn:disabled { opacity: 0.5; cursor: not-allowed; } .pagination-numbers { display: flex; align-items: center; margin: 0 15px; } .pagination-number { width: 35px; height: 35px; display: flex; align-items: center; justify-content: center; margin: 0 5px; border-radius: 50%; cursor: pointer; transition: all 0.3s; } .pagination-number:hover { background-color: #f0f0f0; } .pagination-number.active { background-color: #00c389; color: white; cursor: default; } .pagination-dots { margin: 0 5px; } </style>
2302_81331056/travel
src/components/forum/Pagination.vue
Vue
unknown
2,896
<script setup> import { defineProps, ref, onMounted, computed } from 'vue'; import { getArticleComments, likeArticle } from '@/api/article'; // 导入默认头像 - 使用已有的头像作为默认 import defaultAvatar from '@/assets/home/avatar1.jpg'; // 导入评论列表组件 import CommentsList from './CommentsList.vue'; const props = defineProps({ post: { type: Object, required: true }, users: { type: Object, required: true }, categories: { type: Array, required: true } }); const isLikeLoading = ref(false); const comments = ref([]); const isLoadingComments = ref(false); const commentsError = ref(null); // 控制评论区域显示 const showComments = ref(false); // 控制内容展开/折叠状态 const isContentExpanded = ref(false); // 作者信息计算属性 const authorInfo = computed(() => { // 检查是否有原始数据中的作者信息 if (props.post.originalData) { const { firstName, lastName, avatarUrl, nickname, username } = props.post.originalData; // 创建作者名称,按优先级使用:nickname > firstName+lastName > username > userId let name = ''; if (nickname) { name = nickname; } else if (firstName || lastName) { name = [firstName, lastName].filter(Boolean).join(' '); } else if (username) { name = username; } else { name = `用户${props.post.author}`; } // 创建作者头像URL,如果avatarUrl不存在或无效,使用默认头像 // 注意:有时候后端可能返回空字符串或"null"字符串 const avatar = avatarUrl && avatarUrl !== 'null' && avatarUrl !== '' ? avatarUrl : getDefaultAvatar(props.post.author); // 返回作者信息 return { name, avatar }; } // 如果没有原始数据,则尝试从users对象获取 const userId = props.post.author; const userKey = typeof userId === 'string' ? userId : `user${userId}`; if (props.users && (props.users[userKey] || props.users[`user${userId}`] || props.users[`user_${userId}`])) { // 尝试几种可能的key格式 const userInfo = props.users[userKey] || props.users[`user${userId}`] || props.users[`user_${userId}`]; return userInfo; } // 如果都没有,返回默认值 return { name: `用户${userId}`, avatar: getDefaultAvatar(userId) }; }); // 获取默认头像的辅助函数 const getDefaultAvatar = (userId) => { // 如果有导入的默认头像,则使用它 if (defaultAvatar) { return defaultAvatar; } // 否则使用占位符 return 'https://via.placeholder.com/40'; }; // 获取文章评论 const fetchComments = async () => { // 如果评论区尚未显示,不加载评论数据 if (!showComments.value) return; // 验证文章ID是否有效 if (!props.post || !props.post.id) { console.warn('文章ID无效,无法获取评论'); return; } isLoadingComments.value = true; commentsError.value = null; try { const response = await getArticleComments(props.post.id); // 检查响应数据格式 if (response && response.data) { if (Array.isArray(response.data)) { comments.value = response.data; } else if (response.data.list && Array.isArray(response.data.list)) { comments.value = response.data.list; } else if (response.data.comments && Array.isArray(response.data.comments)) { comments.value = response.data.comments; } else if (response.data.data && Array.isArray(response.data.data)) { comments.value = response.data.data; } else { console.warn('评论数据格式不正确,使用空数组'); comments.value = []; } } else { comments.value = []; } // 更新评论数量 - 使用安全的方式更新 if (props.post) { props.post.comments = comments.value.length; } } catch (error) { console.error('获取评论失败:', error); commentsError.value = '获取评论数据失败,请稍后再试'; comments.value = []; // 确保在错误情况下设置为空数组 } finally { isLoadingComments.value = false; } }; // 点赞功能 const likePost = async () => { if (isLikeLoading.value || !props.post || !props.post.id) return; isLikeLoading.value = true; try { await likeArticle(props.post.id); // 确保post对象存在后再更新属性 if (props.post) { props.post.likes = (props.post.likes || 0) + 1; } // 添加点赞动画效果 const likeButton = document.querySelector(`.like-button-${props.post.id}`); if (likeButton) { likeButton.classList.add('liked'); setTimeout(() => { likeButton.classList.remove('liked'); }, 1000); } } catch (error) { console.error('点赞失败:', error); } finally { isLikeLoading.value = false; } }; // 切换评论区域显示 const toggleComments = () => { // 只切换评论区显示状态,不涉及评论发布功能 showComments.value = !showComments.value; // 如果打开评论区并且还没有加载过评论,则加载评论 if (showComments.value && comments.value.length === 0 && !commentsError.value) { fetchComments(); } }; // 切换内容展开/折叠状态 const toggleContent = () => { isContentExpanded.value = !isContentExpanded.value; }; // 处理富文本内容安全截取 const getFormattedContent = computed(() => { if (!props.post.content) return ''; // 如果内容已展开或内容少于150个字符,直接返回完整内容 if (isContentExpanded.value || props.post.content.length <= 150) { return props.post.content; } // 创建临时div解析HTML内容 const tempDiv = document.createElement('div'); tempDiv.innerHTML = props.post.content; // 获取纯文本内容长度 const textContent = tempDiv.textContent || tempDiv.innerText; if (textContent.length <= 150) { return props.post.content; } // 如果内容超长,尝试安全截取 // 创建新临时div用于截取 const truncDiv = document.createElement('div'); truncDiv.innerHTML = props.post.content; // 获取所有子节点 const allNodes = []; const getNodes = (node) => { if (node.nodeType === 3) { // 文本节点 allNodes.push(node); } else if (node.nodeType === 1) { // 元素节点 Array.from(node.childNodes).forEach(child => getNodes(child)); } }; Array.from(truncDiv.childNodes).forEach(node => getNodes(node)); // 计算总长度并截取 let totalLength = 0; let truncated = false; for (const node of allNodes) { const nodeText = node.textContent || node.nodeValue || ''; if (totalLength + nodeText.length > 150) { // 计算剩余可取字符数 const remainingLength = 150 - totalLength; if (remainingLength > 0) { node.textContent = nodeText.substring(0, remainingLength) + '...'; } else { node.textContent = ''; } truncated = true; break; } totalLength += nodeText.length; } // 如果截取了内容,移除截取点之后的所有节点 if (truncated) { const seenNodes = new Set(); for (const node of allNodes) { seenNodes.add(node); if (node.textContent && node.textContent.includes('...')) { // 移除该节点后的所有兄弟节点 let current = node.nextSibling; while (current) { const next = current.nextSibling; if (!seenNodes.has(current) && current.parentNode) { current.parentNode.removeChild(current); } current = next; } // 向上查找父节点并移除之后的兄弟节点 let parent = node.parentNode; while (parent && parent !== truncDiv) { let current = parent.nextSibling; while (current) { const next = current.nextSibling; if (current.parentNode) { current.parentNode.removeChild(current); } current = next; } parent = parent.parentNode; } break; } } } return truncDiv.innerHTML; }); // 检查内容是否需要折叠 const shouldShowExpandButton = computed(() => { if (!props.post.content) return false; const tempDiv = document.createElement('div'); tempDiv.innerHTML = props.post.content; const textContent = tempDiv.textContent || tempDiv.innerText; return textContent.length > 150; }); onMounted(() => { // 组件挂载时不自动获取评论数据,而是等用户点击时再加载 }); </script> <template> <div class="post-card" :class="{ 'pinned': post.pinned }" > <div class="post-header"> <div class="post-author"> <div class="author-avatar"> <img :src="authorInfo.avatar" :alt="authorInfo.name" class="avatar-img" @error="$event.target.src = defaultAvatar || 'https://via.placeholder.com/40'" loading="lazy" > </div> <div class="author-info"> <h4 class="author-name">{{ authorInfo.name }}</h4> </div> </div> <div class="post-meta"> <span class="post-date">{{ post.date || '未知日期' }}</span> <span v-if="post.pinned" class="post-pinned-badge">📌 置顶</span> </div> </div> <div class="post-content"> <h3 class="post-title">{{ post.title || '无标题' }}</h3> <div v-if="post.content" class="post-excerpt rich-content" v-html="getFormattedContent"></div> <p v-else class="post-excerpt">无内容</p> <!-- 展开/折叠按钮 --> <button v-if="shouldShowExpandButton" class="expand-button" @click="toggleContent" > {{ isContentExpanded ? '收起内容' : '展开阅读全文' }} </button> </div> <div class="post-footer"> <div class="post-category"> <span class="category-icon"> {{ categories.find(c => c.id === post.category)?.icon || '📂' }} </span> <span class="category-name"> {{ categories.find(c => c.id === post.category)?.name || '未分类' }} </span> </div> <div class="post-stats"> <div class="stat-item like-stat"> <button :class="`like-button-${post.id}`" class="like-button" @click="likePost" :disabled="isLikeLoading" > <span class="like-icon">❤️</span> <span class="like-count">{{ post.likes || 0 }}</span> </button> </div> <div class="stat-item"> <button class="comment-button" @click="toggleComments" :title="showComments ? '收起评论' : '查看评论'" > <span class="stat-icon">💬</span> <span class="stat-count"> <template v-if="isLoadingComments && !showComments">...</template> <template v-else>{{ post.comments || 0 }}</template> </span> </button> </div> <div class="stat-item"> <span class="stat-icon">👁️</span> <span class="stat-count">{{ post.views || 0 }}</span> </div> </div> </div> <!-- 评论区域 --> <div v-if="showComments" class="comments-section"> <CommentsList :comments="comments" :articleId="post.id" :isLoading="isLoadingComments" @refresh-comments="fetchComments" /> </div> <!-- 评论加载错误提示 --> <div v-if="commentsError" class="comments-error"> {{ commentsError }} </div> </div> </template> <style scoped> /* 帖子卡片样式 */ .post-card { background-color: #ffffff; border-radius: 10px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05); padding: 25px; transition: all 0.3s; border: 1px solid #f0f0f0; opacity: 0; transform: translateY(20px); animation: fadeInUp 0.5s forwards; } .post-card:hover { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08); transform: translateY(-3px); } .post-card.pinned { border-left: 4px solid #00c389; background-color: #f9fffe; } .post-header { display: flex; justify-content: space-between; margin-bottom: 20px; } .post-author { display: flex; align-items: center; } .author-avatar { width: 40px; height: 40px; margin-right: 12px; border-radius: 50%; overflow: hidden; } .avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; } .author-name { font-size: 1rem; color: #333; margin: 0 0 3px; } .post-meta { display: flex; align-items: center; } .post-date { color: #888; font-size: 0.9rem; } .post-pinned-badge { display: flex; align-items: center; margin-left: 10px; padding: 3px 8px; background-color: #f2fbfa; color: #00c389; border-radius: 4px; font-size: 0.85rem; font-weight: 500; } .post-content { margin-bottom: 20px; } .post-title { font-size: 1.25rem; color: #333; margin: 0 0 10px; font-weight: 600; } .post-excerpt { color: #666; line-height: 1.5; font-size: 1rem; } .post-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #f0f0f0; padding-top: 15px; } .post-category { display: flex; align-items: center; padding: 5px 12px; background-color: #f8f8f8; border-radius: 5px; } .post-stats { display: flex; gap: 15px; } .like-button { display: flex; align-items: center; background: none; border: none; padding: 0; cursor: pointer; transition: all 0.3s; } .like-button.liked .like-icon { animation: heartBeat 1s; } .like-button:disabled { opacity: 0.7; cursor: not-allowed; } .like-icon { font-size: 1.1rem; margin-right: 5px; } .comment-button { display: flex; align-items: center; background: none; border: none; padding: 0; cursor: pointer; transition: all 0.3s; } .comment-button:hover { color: #00c389; } .comments-section { margin-top: 15px; border-top: 1px solid #f0f0f0; padding-top: 15px; animation: fadeIn 0.3s ease-in-out; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } .comments-error { color: #e74c3c; font-size: 0.9rem; margin-top: 10px; padding: 8px; background-color: #fef2f2; border-radius: 5px; text-align: center; } @keyframes fadeInUp { 0% { opacity: 0; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } } @keyframes heartBeat { 0% { transform: scale(1); } 14% { transform: scale(1.3); } 28% { transform: scale(1); } 42% { transform: scale(1.3); } 70% { transform: scale(1); } } @media (max-width: 768px) { .post-header { flex-direction: column; gap: 15px; } .post-meta { justify-content: flex-end; } } @media (max-width: 576px) { .post-footer { flex-direction: column; gap: 15px; } .post-stats { width: 100%; justify-content: space-between; } } /* 富文本内容样式 */ .rich-content { overflow: hidden; } .rich-content :deep(img) { max-width: 100%; max-height: 500px; /* 限制图片最大高度 */ height: auto; border-radius: 4px; margin: 8px 0; object-fit: contain; /* 保持图片比例 */ } .rich-content :deep(a) { color: #00c389; text-decoration: none; } .rich-content :deep(a:hover) { text-decoration: underline; } .rich-content :deep(p) { margin: 0.5em 0; } .rich-content :deep(ul), .rich-content :deep(ol) { padding-left: 20px; margin: 0.5em 0; } .rich-content :deep(blockquote) { border-left: 4px solid #e0e0e0; padding-left: 16px; margin: 0.5em 0; color: #777; } .rich-content :deep(h1), .rich-content :deep(h2), .rich-content :deep(h3), .rich-content :deep(h4), .rich-content :deep(h5), .rich-content :deep(h6) { margin: 0.5em 0; color: #333; } /* 折叠/展开按钮样式 */ .expand-button { display: inline-block; margin-top: 10px; padding: 5px 15px; background-color: #f8f8f8; color: #00c389; border: 1px solid #e0e0e0; border-radius: 4px; font-size: 0.9rem; cursor: pointer; transition: all 0.3s; } .expand-button:hover { background-color: #00c389; color: white; border-color: #00c389; } </style>
2302_81331056/travel
src/components/forum/PostCard.vue
Vue
unknown
16,388
<script setup> import { defineProps, ref } from 'vue'; import PostCard from './PostCard.vue'; import Pagination from './Pagination.vue'; const props = defineProps({ posts: { type: Array, required: true }, users: { type: Object, required: true }, categories: { type: Array, required: true }, activeCategory: { type: String, required: true } }); const sortOption = ref('latest'); const currentPage = ref(1); const postsPerPage = 5; // 每页显示5个帖子 const sortOptions = [ { value: 'latest', label: 'Latest' }, { value: 'popular', label: 'Most Popular' }, { value: 'commented', label: 'Most Commented' } ]; // 根据选项排序帖子 const sortedPosts = () => { let sorted = [...props.posts]; // 先按固定帖子排序 sorted.sort((a, b) => { if (a.pinned && !b.pinned) return -1; if (!a.pinned && b.pinned) return 1; return 0; }); // 然后根据排序选项排序 switch (sortOption.value) { case 'latest': sorted.sort((a, b) => { const dateA = a.date ? new Date(a.date) : new Date(0); const dateB = b.date ? new Date(b.date) : new Date(0); return dateB - dateA; }); break; case 'popular': sorted.sort((a, b) => { const likesA = a.likes || 0; const likesB = b.likes || 0; return likesB - likesA; }); break; case 'commented': sorted.sort((a, b) => { const commentsA = a.comments || 0; const commentsB = b.comments || 0; return commentsB - commentsA; }); break; } return sorted; }; // 计算分页后的帖子 const paginatedPosts = () => { const start = (currentPage.value - 1) * postsPerPage; const end = start + postsPerPage; return sortedPosts().slice(start, end); }; // 计算总页数 const totalPages = () => { return Math.ceil(props.posts.length / postsPerPage); }; // 切换页码 const handlePageChange = (page) => { currentPage.value = page; }; </script> <template> <div class="posts-container"> <div class="posts-header"> <h3 class="posts-title">{{ activeCategory === 'all' ? '全部话题' : categories.find(c => c.id === activeCategory)?.name || '未分类话题' }}</h3> <div class="sorting-controls"> <span class="sort-label">排序方式:</span> <select v-model="sortOption" class="sort-dropdown"> <option value="latest">最新发布</option> <option value="popular">最多点赞</option> <option value="commented">最多评论</option> </select> </div> </div> <!-- 无内容提示 --> <div v-if="paginatedPosts().length === 0" class="no-posts-message"> 暂无相关话题,请尝试其他分类或搜索条件 </div> <div v-else class="posts-list"> <PostCard v-for="(post, index) in paginatedPosts()" :key="post.id" :post="post" :users="users" :categories="categories" :style="{ animationDelay: `${index * 0.1}s` }" /> </div> <Pagination v-if="paginatedPosts().length > 0" :current-page="currentPage" :total-pages="totalPages()" @page-change="handlePageChange" /> </div> </template> <style scoped> /* 帖子列表样式 */ .posts-container { flex-grow: 1; } .posts-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; } .posts-title { font-size: 1.5rem; font-weight: 600; color: #333; } .sorting-controls { display: flex; align-items: center; } .sort-label { color: #666; margin-right: 10px; } .sort-dropdown { padding: 8px 15px; border-radius: 5px; border: 1px solid #e0e0e0; background-color: #f8f8f8; cursor: pointer; } .posts-list { display: flex; flex-direction: column; gap: 20px; } @media (max-width: 576px) { .posts-header { flex-direction: column; align-items: flex-start; gap: 15px; } } .no-posts-message { text-align: center; padding: 40px 0; color: #666; font-size: 1.1rem; background-color: #f9f9f9; border-radius: 10px; margin: 20px 0; } </style>
2302_81331056/travel
src/components/forum/PostsList.vue
Vue
unknown
4,217
import ForumHeader from './ForumHeader.vue'; import ForumActions from './ForumActions.vue'; import CategorySidebar from './CategorySidebar.vue'; import PostsList from './PostsList.vue'; import PostCard from './PostCard.vue'; import Pagination from './Pagination.vue'; import CreatePostModal from './CreatePostModal.vue'; import CommentsList from './CommentsList.vue'; import CommentItem from './CommentItem.vue'; export { ForumHeader, ForumActions, CategorySidebar, PostsList, PostCard, Pagination, CreatePostModal, CommentsList, CommentItem };
2302_81331056/travel
src/components/forum/index.js
JavaScript
unknown
564
<script setup> import { ref, onMounted } from 'vue' import { useAuthStore } from '@/stores/auth' const authStore = useAuthStore() const tokenValue = ref('') const storeInfo = ref('') // 模拟解析JWT的函数 const parseJwt = (token) => { try { const base64Url = token.split('.')[1] const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/') const jsonPayload = decodeURIComponent(atob(base64).split('').map((c) => { return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2) }).join('')) return JSON.parse(jsonPayload) } catch (e) { console.error('解析JWT失败:', e) return { error: '无效的JWT格式' } } } // 加载状态 onMounted(() => { updateStoreInfo() }) // 更新store信息 const updateStoreInfo = () => { // 获取store当前状态 tokenValue.value = authStore.token const info = { isLoggedIn: authStore.isLoggedIn, username: authStore.username, token: authStore.token ? '已存储' : '未存储', tokenDecoded: authStore.token ? parseJwt(authStore.token) : null } storeInfo.value = JSON.stringify(info, null, 2) } // 清除token const clearToken = () => { authStore.logout() updateStoreInfo() } </script> <template> <div class="auth-store-demo"> <h2>Pinia Auth Store 演示</h2> <div class="status-section"> <h3>当前登录状态</h3> <div class="status-badge" :class="{ 'logged-in': authStore.isLoggedIn }"> {{ authStore.isLoggedIn ? '已登录' : '未登录' }} </div> </div> <div class="store-info"> <h3>Store 信息</h3> <pre>{{ storeInfo }}</pre> </div> <div class="actions"> <button class="refresh-btn" @click="updateStoreInfo">刷新状态</button> <button v-if="authStore.isLoggedIn" class="clear-btn" @click="clearToken">清除登录信息</button> <button v-else class="login-btn" @click="$router.push('/login')">去登录</button> </div> </div> </template> <style scoped> .auth-store-demo { max-width: 800px; margin: 0 auto; padding: 20px; background-color: #f9f9f9; border-radius: 8px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1); } h2 { color: #333; margin-bottom: 20px; text-align: center; } h3 { color: #555; margin-bottom: 10px; } .status-section { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; } .status-badge { background-color: #f44336; color: white; padding: 5px 10px; border-radius: 20px; font-weight: bold; } .status-badge.logged-in { background-color: #4caf50; } .store-info { margin-bottom: 20px; } pre { background-color: #f0f0f0; padding: 15px; border-radius: 4px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; } .actions { display: flex; gap: 10px; justify-content: center; } button { padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; transition: all 0.3s ease; } .refresh-btn { background-color: #2196f3; color: white; } .refresh-btn:hover { background-color: #0d8bf2; } .clear-btn { background-color: #f44336; color: white; } .clear-btn:hover { background-color: #e53935; } .login-btn { background-color: #4caf50; color: white; } .login-btn:hover { background-color: #43a047; } </style>
2302_81331056/travel
src/components/home/AuthStoreDemo.vue
Vue
unknown
3,337
<script setup> import { ref, onMounted } from 'vue'; const isVisible = ref(false); const sectionRef = ref(null); const email = ref(''); const submitForm = () => { // 表单提交逻辑 console.log('提交邮箱:', email.value); email.value = ''; }; onMounted(() => { const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { isVisible.value = true; observer.disconnect(); } }); }, { threshold: 0.2 }); if (sectionRef.value) { observer.observe(sectionRef.value); } }); </script> <template> <section ref="sectionRef" class="service-section"> <div class="service-container" :class="{ 'animate': isVisible }"> <!-- 背景装饰元素将通过CSS设置 --> <div class="content-wrapper"> <div class="text-container"> <h2 class="service-title">如有疑问,我们有24小时客服为您服务</h2> <form @submit.prevent="submitForm" class="email-form"> <input type="email" v-model="email" placeholder="Enter your email" required class="email-input" /> <button type="submit" class="submit-btn">联系我们</button> </form> </div> </div> </div> </section> </template> <style scoped> .service-section { width: 100%; overflow: hidden; display: flex; justify-content: center; align-items: center; background-color: #fff; padding: 40px 20px; } .service-container { width: 100%; max-width: 1296px; height: 376px; background-color: #00c389; position: relative; border-radius: 20px; overflow: hidden; opacity: 0; transform: translateY(20px); transition: all 0.6s ease-out; } .service-container.animate { opacity: 1; transform: translateY(0); } .content-wrapper { display: flex; height: 100%; position: relative; z-index: 10; padding: 0 60px; } .text-container { display: flex; flex-direction: column; justify-content: center; margin-left: auto; width: 50%; } .service-title { color: white; font-size: 2.4rem; font-weight: 700; margin-bottom: 30px; line-height: 1.3; } .email-form { display: flex; max-width: 500px; } .email-input { flex: 1; height: 54px; border: none; border-radius: 8px; padding: 0 20px; font-size: 1rem; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); } .submit-btn { height: 54px; background-color: #f05045; color: white; border: none; border-radius: 8px; padding: 0 24px; margin-left: 15px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.3s ease; } .submit-btn:hover { background-color: #d83b30; transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15); } /* 背景图片设置 */ .service-container::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; background-image: url('@/assets/CS-bg.png'); background-size: 100% 100%; background-position: left center; background-repeat: no-repeat; opacity: 0.9; } /* 左侧半透明遮罩,增强视觉效果 */ .service-container::after { content: ''; position: absolute; top: 0; right: 0; width: 50%; height: 100%; background: linear-gradient(to right, rgba(0, 195, 137, 0.1), rgba(0, 195, 137, 0.9)); z-index: 2; } @media (max-width: 992px) { .service-container { height: auto; min-height: 376px; } .service-container::before { opacity: 0.3; /* 让背景图片在小屏幕上变淡,以便文本更清晰 */ } .service-container::after { width: 100%; background: linear-gradient(to bottom, rgba(0, 195, 137, 0.2), rgba(0, 195, 137, 0.8)); } .content-wrapper { flex-direction: column; padding: 40px; } .text-container { width: 100%; margin-left: 0; } .service-title { font-size: 2rem; } } @media (max-width: 576px) { .service-section { padding: 20px 15px; } .content-wrapper { padding: 30px 20px; } .service-title { font-size: 1.6rem; } .email-form { flex-direction: column; } .email-input { width: 100%; margin-bottom: 15px; } .submit-btn { width: 100%; margin-left: 0; } } </style>
2302_81331056/travel
src/components/home/CustomerService.vue
Vue
unknown
4,354
<script setup> import { useI18n } from 'vue-i18n' import { ref, onMounted } from 'vue' const { t } = useI18n() const isVisible = ref(false) const sectionRef = ref(null) onMounted(() => { const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { isVisible.value = true observer.disconnect() } }) }, { threshold: 0.2 }) if (sectionRef.value) { observer.observe(sectionRef.value) } }) </script> <template> <section ref="sectionRef" class="entry-section"> <div class="entry-container"> <h2 class="entry-title" :class="{ 'animate': isVisible }"> <span class="english-title">3 steps for the perfect trip</span> <span class="chinese-title">三步解锁免签,轻松踏上中国之旅</span> </h2> <p class="entry-subtitle" :class="{ 'animate': isVisible }">An enim nullam tempor gravida donec enim congue magna at pretium purus pretium ligula rutrum luctus risusd diam eget risus varius blandit sit amet non magna.</p> <div class="entry-grid"> <div class="entry-card" :class="{ 'animate': isVisible }" :style="{ animationDelay: '0.1s' }" > <div class="card-content"> <div class="icon-wrapper"> <img src="@/assets/icons/luggage.svg" alt="确认免签资格" class="step-icon" /> </div> <h3>确认免签资格</h3> <p class="entry-description">您需先确认自己所属国家是否在当前中国免签政策覆盖范国之中。与此同时,要明确自身旅行目的是否符合免签规定中的商务、旅游观光、探亲访友以及过境等范畴。</p> </div> </div> <div class="entry-card" :class="{ 'animate': isVisible }" :style="{ animationDelay: '0.3s' }" > <div class="card-content"> <div class="icon-wrapper"> <img src="@/assets/icons/taxi.svg" alt="规划行程与准备材料" class="step-icon" /> </div> <h3>规划行程与准备材料</h3> <p class="entry-description">在确定符合免签资格之后,进行详细行程规划。涵盖确定抵达口岸、旅行路线以及停留时间等方面。护照的有效期需要在预计离境中国的日期之后仍然至少有 6 个月及以上。</p> </div> </div> <div class="entry-card" :class="{ 'animate': isVisible }" :style="{ animationDelay: '0.5s' }" > <div class="card-content"> <div class="icon-wrapper"> <img src="@/assets/icons/stars.svg" alt="入境通关" class="step-icon" /> </div> <h3>入境通关</h3> <p class="entry-description">携带好好的护照及相关材料,按规划行程抵达中国免签政策适用口岸。边检审核通过后,即可顺利入境中国,开启免签之旅。</p> </div> </div> </div> </div> </section> </template> <style scoped> /* 入境通关区域样式 */ .entry-section { padding: 80px 152px; background: rgba(242, 251, 250, 1); position: relative; overflow: hidden; width: 100%; height: 876px; } .entry-container { max-width: 1600px; width: 100%; height: 100%; margin: 0 auto; position: relative; z-index: 1; text-align: center; display: flex; flex-direction: column; justify-content: center; } .entry-title { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-bottom: 24px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease; } .entry-title.animate { opacity: 1; transform: translateY(0); } .english-title { color: #00c389; font-size: 1.5rem; font-weight: 600; } .chinese-title { font-size: 2.5rem; font-weight: 700; color: #2a2d32; } .entry-subtitle { font-size: 1.1rem; color: #6b7280; margin-bottom: 60px; max-width: 800px; line-height: 1.6; margin: 0 auto 60px; opacity: 0; transform: translateY(20px); transition: all 0.8s ease 0.2s; } .entry-subtitle.animate { opacity: 1; transform: translateY(0); } .entry-grid { display: grid; grid-template-columns: repeat(3, 416px); gap: 24px; position: relative; justify-content: center; } .entry-card { background: #fff; border-radius: 16px; height: 416px; padding: 48px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.05); transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1); position: relative; overflow: hidden; text-align: center; display: flex; flex-direction: column; align-items: center; opacity: 0; transform: translateY(50px); transition: opacity 0.8s ease, transform 0.8s ease, box-shadow 0.4s ease, transform 0.4s ease; } .entry-card.animate { opacity: 1; transform: translateY(0); } .entry-card:hover { transform: translateY(-8px); box-shadow: 0 12px 40px rgba(0, 195, 137, 0.15); } .icon-wrapper { width: 80px; height: 80px; position: relative; display: flex; align-items: center; justify-content: center; margin-bottom: 32px; transition: transform 0.5s ease; } .entry-card:hover .icon-wrapper { transform: scale(1.1) rotate(5deg); } .icon-wrapper::before { content: ''; position: absolute; width: 100%; height: 100%; background: currentColor; clip-path: polygon(50% 0%, 93.3% 25%, 93.3% 75%, 50% 100%, 6.7% 75%, 6.7% 25%); opacity: 0.1; border-radius: 24px; transform: scale(0.95); transition: transform 0.3s ease, opacity 0.3s ease; } .entry-card:hover .icon-wrapper::before { transform: scale(1); opacity: 0.2; } .entry-card:nth-child(1) .icon-wrapper { color: rgb(255, 107, 107); } .entry-card:nth-child(2) .icon-wrapper { color: rgb(82, 113, 255); } .entry-card:nth-child(3) .icon-wrapper { color: rgb(0, 195, 137); } .step-icon { width: 40px; height: 40px; position: relative; z-index: 1; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1)); transition: transform 0.5s ease; } .entry-card:hover .step-icon { transform: rotate(-10deg); filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15)); } .card-content { width: 100%; height: 100%; display: flex; flex-direction: column; gap: 24px; align-items: center; } .card-content h3 { font-size: 1.5rem; font-weight: 600; color: #2a2d32; text-align: center; position: relative; transition: color 0.3s ease; } .entry-card:hover .card-content h3 { color: #00c389; } .card-content h3::after { content: ''; position: absolute; width: 0; height: 2px; bottom: -8px; left: 50%; background-color: #00c389; transition: all 0.3s ease; transform: translateX(-50%); } .entry-card:hover .card-content h3::after { width: 40px; } .entry-description { color: #52565e; font-size: 1rem; line-height: 1.8; flex-grow: 1; text-align: left; transition: color 0.3s ease; } .entry-card:hover .entry-description { color: #333; } /* 响应式样式 */ @media (max-width: 1400px) { .entry-section { height: auto; min-height: 876px; } .entry-container { max-width: 100%; padding: 0 40px; } .entry-grid { grid-template-columns: repeat(3, 350px); } .entry-card { height: 350px; padding: 32px; } .icon-wrapper { width: 64px; height: 64px; margin-bottom: 24px; } .icon-wrapper::before { border-radius: 20px; } .step-icon { width: 32px; height: 32px; } } @media (max-width: 1200px) { .entry-section { padding: 60px 40px; height: auto; min-height: 876px; } .entry-grid { grid-template-columns: repeat(3, 300px); gap: 20px; } .entry-card { height: 300px; padding: 24px; } .chinese-title { font-size: 2.2rem; } .card-content { gap: 16px; } .card-content h3 { font-size: 1.3rem; } } @media (max-width: 992px) { .entry-section { height: auto; min-height: 876px; } .entry-grid { grid-template-columns: minmax(280px, 416px); max-width: 416px; margin: 0 auto; } .entry-card { height: auto; min-height: 300px; } .entry-card.animate { animation-delay: 0s !important; } } @media (max-width: 768px) { .entry-section { padding: 50px 30px; height: auto; min-height: 876px; } .english-title { font-size: 1.3rem; } .chinese-title { font-size: 2rem; } .entry-subtitle { font-size: 1rem; margin-bottom: 40px; } .entry-description { font-size: 0.95rem; } } @media (max-width: 576px) { .entry-section { padding: 40px 20px; height: auto; min-height: 876px; } .entry-grid { grid-template-columns: 1fr; } .entry-card { padding: 24px; min-height: 280px; } .chinese-title { font-size: 1.8rem; } .entry-subtitle { font-size: 0.9rem; } .icon-wrapper { width: 56px; height: 56px; margin-bottom: 20px; } .icon-wrapper::before { border-radius: 16px; } .step-icon { width: 28px; height: 28px; } } </style>
2302_81331056/travel
src/components/home/EntryGuide.vue
Vue
unknown
9,169
<script setup> import { useI18n } from 'vue-i18n' const { t } = useI18n() </script> <template> <section class="explore-china"> <div class="explore-container"> <h2 class="explore-title">探索中国</h2> <p class="explore-subtitle">这些热门目的地精彩纷呈</p> <div class="destination-grid"> <!-- 故宫 --> <div class="destination-card"> <div class="card-image"> <img src="@/assets/home/explore1.jpg" alt="故宫"> <button class="favorite-btn"> <span class="heart-icon">♡</span> </button> <span class="duration-tag">2-3 天</span> </div> <div class="card-content"> <h3 class="destination-title">故宫博物院</h3> <div class="location"> <span class="location-icon">📍</span> <span>北京市东城区景山前街4号</span> </div> <p class="description">中国明清两代的皇家宫殿,世界上现存规模最大、保存最完整的木质结构古建筑群。穿行于近万间古建筑中,感受600年的皇家历史。</p> <div class="features"> <span class="feature-tag">世界文化遗产</span> <span class="feature-tag">必游景点</span> </div> <div class="rating"> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> </div> <div class="price"> <span class="current-price">¥120</span> <span class="original-price">¥160</span> </div> </div> </div> <!-- 外滩 --> <div class="destination-card"> <div class="card-image"> <img src="@/assets/home/explore2.jpg" alt="外滩"> <button class="favorite-btn"> <span class="heart-icon">♡</span> </button> <span class="duration-tag">1-2 天</span> </div> <div class="card-content"> <h3 class="destination-title">外滩夜景</h3> <div class="location"> <span class="location-icon">📍</span> <span>上海市黄浦区中山东一路</span> </div> <p class="description">被誉为"万国建筑博览群"的外滩,汇集了各种风格的经典建筑,夜幕降临后的璀璨灯光秀更是不容错过的视觉盛宴。</p> <div class="features"> <span class="feature-tag">网红打卡</span> <span class="feature-tag">夜景推荐</span> </div> <div class="rating"> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> </div> <div class="price"> <span class="current-price">免费</span> </div> </div> </div> <!-- 陆家嘴 --> <div class="destination-card"> <div class="card-image"> <img src="@/assets/home/explore5.jpg" alt="重庆洪崖洞"> <button class="favorite-btn"> <span class="heart-icon">♡</span> </button> <span class="duration-tag">2-3 小时</span> </div> <div class="card-content"> <h3 class="destination-title">重庆洪崖洞</h3> <div class="location"> <span class="location-icon">📍</span> <span>重庆市渝中区解放碑沧白路88号</span> </div> <p class="description">依山就势而建的"山城明珠",集观光、餐饮、休闲于一体的立体式建筑群。夜幕降临后灯火通明,是重庆夜景最精华的代表。</p> <div class="features"> <span class="feature-tag">网红地标</span> <span class="feature-tag">美食天堂</span> </div> <div class="rating"> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> </div> <div class="price"> <span class="current-price">免费</span> </div> </div> </div> <!-- 橘子洲 --> <div class="destination-card"> <div class="card-image"> <img src="@/assets/home/explore4.jpg" alt="橘子洲"> <button class="favorite-btn"> <span class="heart-icon">♡</span> </button> <span class="duration-tag">半天</span> </div> <div class="card-content"> <h3 class="destination-title">橘子洲头</h3> <div class="location"> <span class="location-icon">📍</span> <span>湖南省长沙市岳麓区</span> </div> <p class="description">湘江中的地标性景区,青年毛泽东诗词《沁园春·长沙》的创作地。漫步于洲岛之上,感受诗意长沙,欣赏湘江两岸风光。</p> <div class="features"> <span class="feature-tag">人文景观</span> <span class="feature-tag">诗词圣地</span> </div> <div class="rating"> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> <span class="star">★</span> </div> <div class="price"> <span class="current-price">¥80</span> <span class="original-price">¥100</span> </div> </div> </div> </div> <div class="navigation-buttons"> <button class="nav-btn prev">←</button> <button class="nav-btn next">→</button> </div> </div> </section> </template> <style scoped> /* 探索中国区域样式 */ .explore-china { padding: 60px 152px; background-color: #ffffff; height: 938px; } .explore-container { max-width: 1296px; margin: 0 auto; padding: 0; position: relative; height: 100%; display: flex; flex-direction: column; } .explore-title { font-size: 2.5rem; font-weight: bold; color: #333; margin-bottom: 16px; } .explore-subtitle { font-size: 1.1rem; color: #666; margin-bottom: 40px; } .destination-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 40px; width: 1296px; height: 596px; } .destination-card { background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); transition: transform 0.3s ease; height: 100%; } .destination-card:hover { transform: translateY(-5px); } .card-image { position: relative; width: 100%; padding-top: 66%; } .card-image img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; } .favorite-btn { position: absolute; top: 12px; right: 12px; background: rgba(255, 255, 255, 0.9); border: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; } .favorite-btn:hover { background: #fff; transform: scale(1.1); } .heart-icon { font-size: 16px; color: #ff5a5a; } .duration-tag { position: absolute; left: 12px; top: 12px; background: rgba(0, 195, 137, 0.9); color: white; padding: 3px 10px; border-radius: 20px; font-size: 0.8rem; } .card-content { padding: 15px; } .destination-title { font-size: 1.1rem; font-weight: bold; margin-bottom: 8px; color: #333; } .location { display: flex; align-items: center; gap: 6px; color: #666; font-size: 0.8rem; margin-bottom: 8px; } .location-icon { color: #00c389; } .rating { margin-bottom: 8px; } .star { color: #ffcc33; font-size: 0.9rem; } .price { display: flex; align-items: center; gap: 10px; } .current-price { font-size: 1.2rem; font-weight: bold; color: #333; } .original-price { font-size: 0.9rem; color: #999; text-decoration: line-through; } .navigation-buttons { position: absolute; top: 0; right: 20px; display: flex; gap: 10px; } .nav-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid #e0e0e0; background: white; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; } .nav-btn:hover { background: #f5f5f5; border-color: #ccc; } /* 响应式样式 */ @media (max-width: 1200px) { .explore-china { height: auto; min-height: 938px; padding: 60px 40px; } .explore-container { padding-left: 0; padding-right: 0; } .destination-grid { width: 100%; height: auto; min-height: 596px; grid-template-columns: repeat(3, 1fr); } } @media (max-width: 992px) { .explore-china { height: auto; min-height: 938px; padding: 60px 30px; } .explore-container { padding-left: 0; padding-right: 0; } .destination-grid { width: 100%; height: auto; min-height: 596px; grid-template-columns: repeat(2, 1fr); } } @media (max-width: 768px) { .explore-china { height: auto; min-height: 938px; padding: 50px 30px; } .explore-title { font-size: 2rem; } .explore-subtitle { font-size: 1rem; } .destination-grid { gap: 20px; } } @media (max-width: 576px) { .explore-china { height: auto; min-height: 938px; padding: 40px 20px; } .explore-container { padding-left: 0; padding-right: 0; } .destination-grid { width: 100%; height: auto; min-height: 596px; grid-template-columns: repeat(1, 1fr); } .navigation-buttons { position: static; justify-content: center; margin-top: 20px; } } .description { font-size: 0.9rem; color: #666; margin: 12px 0; line-height: 1.5; } .features { display: flex; gap: 8px; margin-bottom: 12px; } .feature-tag { background-color: #f0f9ff; color: #0369a1; padding: 4px 8px; border-radius: 4px; font-size: 0.8rem; } </style>
2302_81331056/travel
src/components/home/ExploreChina.vue
Vue
unknown
10,613
<script setup> import { ref, onMounted, computed } from 'vue'; import { useI18n } from 'vue-i18n'; import { getArticleList, createArticle } from '@/api/article'; // 导入组件化的子组件 import { ForumHeader, ForumActions, CategorySidebar, PostsList, CreatePostModal } from '@/components/forum'; const { t } = useI18n(); const sectionRef = ref(null); const isVisible = ref(false); const activeCategory = ref('all'); const searchQuery = ref(''); const showCreatePost = ref(false); const isLoading = ref(false); const loadError = ref(null); // 引入头像图片 import avatar1 from '@/assets/home/avatar1.jpg'; import avatar2 from '@/assets/home/avatar2.jpg'; import avatar3 from '@/assets/home/avatar3.jpg'; import avatar4 from '@/assets/home/avatar4.jpg'; import avatar5 from '@/assets/home/avatar5.jpg'; import avatar6 from '@/assets/home/avatar6.jpg'; // 模拟用户数据 const users = { user1: { name: 'Sarah Johnson', avatar: avatar1, country: 'USA' }, user2: { name: 'Michael Chen', avatar: avatar2, country: 'Canada' }, user3: { name: 'Elena Petrova', avatar: avatar3, country: 'Russia' }, user4: { name: 'Carlos Rodriguez', avatar: avatar4, country: 'Spain' }, user5: { name: 'Akira Tanaka', avatar: avatar5, country: 'Japan' }, user6: { name: 'Li Wei', avatar: avatar6, country: 'China' }, }; // 论坛帖子数据 const forumPosts = ref([]); // 论坛分类 const categories = [ { id: 'all', name: 'All Topics', icon: '📑' }, { id: 'travel', name: 'Travel Tips', icon: '🧳' }, { id: 'food', name: 'Food & Cuisine', icon: '🍜' }, { id: 'transportation', name: 'Transportation', icon: '🚆' }, { id: 'practical', name: 'Practical Info', icon: '📱' }, { id: 'safety', name: 'Safety & Health', icon: '🛡️' }, { id: 'technology', name: 'Tech & Apps', icon: '📲' }, { id: 'general', name: 'General Discussion', icon: '💬' }, ]; // 获取文章列表 const fetchArticles = async () => { isLoading.value = true; loadError.value = null; try { // 调用API获取文章数据 const { data } = await getArticleList(); // 处理获取到的数据 forumPosts.value = data.map(article => { // 保存原始数据 const originalData = { ...article }; // 处理用户ID,确保格式一致 let author = article.userId; // 如果userId是数字,则格式化为"userX"格式 if (typeof author === 'number' || !isNaN(Number(author))) { author = `user${author}`; } // 转换为前端需要的格式 return { id: article.id, author: author, title: article.title, content: article.richContent, likes: article.likeCount || 0, date: article.createTime, pinned: article.isTop || false, category: article.category || 'general', // 默认分类 views: article.viewCount || 0, comments: article.commentCount || 0, // 存储原始数据,方便在其他组件中使用 originalData }; }); // 控制台输出检查数据结构 console.log('处理后的文章数据:', forumPosts.value); } catch (error) { console.error('获取文章列表失败:', error); forumPosts.value = []; // 确保发生错误时重置为空数组 loadError.value = '获取论坛数据失败,请稍后再试'; } finally { isLoading.value = false; } }; // 过滤显示的帖子 const filteredPosts = computed(() => { // 确保forumPosts.value是数组 if (!Array.isArray(forumPosts.value)) { console.warn('forumPosts.value不是数组,返回空数组'); return []; } return forumPosts.value.filter(post => { if (!post) return false; const matchesCategory = activeCategory.value === 'all' || (post.category && post.category === activeCategory.value); const matchesSearch = (post.title && post.title.toLowerCase().includes(searchQuery.value.toLowerCase())) || (post.content && post.content.toLowerCase().includes(searchQuery.value.toLowerCase())); return matchesCategory && matchesSearch; }); }); // 创建新帖子 const createPost = async (newPostData) => { if (newPostData.title.trim() && newPostData.content.trim()) { try { // 准备发送到后端的数据 const postData = { title: newPostData.title, content: newPostData.content, // 富文本HTML内容,API会转换为richContent category: newPostData.category, // 假设当前用户ID为1,实际项目中应从用户会话或存储中获取 userId: 1 }; const response = await createArticle(postData); // 如果后端返回了新创建的帖子数据,则直接使用 if (response.data) { // 将后端返回的数据转换为我们组件使用的格式 const newPost = { id: response.data.id || new Date().getTime(), title: response.data.title || newPostData.title, content: response.data.richContent || newPostData.content, author: `user${response.data.userId || 1}`, category: response.data.category || newPostData.category, likes: response.data.likeCount || 0, comments: response.data.commentCount || 0, views: response.data.viewCount || 0, date: response.data.createTime || new Date().toISOString(), pinned: false, // 默认不置顶 originalData: response.data }; forumPosts.value.unshift(newPost); } else { // 如果后端只返回成功状态但没有返回数据,则使用本地构建的数据对象 const post = { id: new Date().getTime(), title: newPostData.title, content: newPostData.content, author: 'user1', category: newPostData.category, likes: 0, comments: 0, views: 0, date: new Date().toISOString(), pinned: false }; forumPosts.value.unshift(post); } showCreatePost.value = false; } catch (error) { console.error('创建帖子失败:', error); alert('创建帖子失败,请稍后再试'); } } }; // 打开创建帖子弹窗 const openCreatePostModal = () => { showCreatePost.value = true; }; // 更新搜索内容 const updateSearchQuery = (query) => { searchQuery.value = query; }; onMounted(() => { // 监听页面可见性 const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { isVisible.value = true; observer.disconnect(); } }); }, { threshold: 0.1 }); if (sectionRef.value) { observer.observe(sectionRef.value); } // 获取文章列表 fetchArticles(); }); </script> <template> <section ref="sectionRef" class="forum-section"> <div class="forum-container"> <!-- 使用论坛头部组件 --> <ForumHeader :is-visible="isVisible" /> <!-- 使用论坛操作组件 --> <ForumActions :is-visible="isVisible" @update:search-query="updateSearchQuery" @create-post="openCreatePostModal" /> <div v-if="isLoading" class="loading-container"> <div class="loading-spinner"></div> <p>加载论坛数据中...</p> </div> <div v-else-if="loadError" class="error-container"> <p class="error-message">{{ loadError }}</p> <button class="retry-button" @click="fetchArticles">重试</button> </div> <div v-else class="forum-content" :class="{ 'animate': isVisible }"> <!-- 使用分类侧边栏组件 --> <CategorySidebar :categories="categories" :active-category="activeCategory" :forum-posts="forumPosts" @update:active-category="activeCategory = $event" /> <!-- 使用帖子列表组件 --> <PostsList :posts="filteredPosts" :users="users" :categories="categories" :active-category="activeCategory" /> </div> </div> <!-- 使用创建帖子弹窗组件 --> <CreatePostModal :show="showCreatePost" :categories="categories" @close="showCreatePost = false" @create-post="createPost" /> </section> </template> <style scoped> /* 论坛部分的基础样式 */ .forum-section { width: 100%; background-color: #ffffff; padding: 80px 0; position: relative; overflow: hidden; } .forum-container { max-width: 1600px; width: 100%; margin: 0 auto; padding: 0 20px; } /* 加载状态样式 */ .loading-container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 0; } .loading-spinner { width: 50px; height: 50px; border: 5px solid #f3f3f3; border-top: 5px solid #00c389; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 20px; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } /* 错误状态样式 */ .error-container { text-align: center; padding: 40px 0; } .error-message { color: #e74c3c; font-size: 1.1rem; margin-bottom: 20px; } .retry-button { padding: 10px 25px; background-color: #00c389; color: white; border: none; border-radius: 5px; font-size: 1rem; font-weight: 500; cursor: pointer; transition: all 0.3s; } .retry-button:hover { background-color: #00a873; } /* 主要内容区样式 */ .forum-content { display: flex; gap: 30px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease 0.4s; } .forum-content.animate { opacity: 1; transform: translateY(0); } /* 响应式样式 */ @media (max-width: 1200px) { .forum-content { flex-direction: column; } } </style>
2302_81331056/travel
src/components/home/Forum.vue
Vue
unknown
9,946
<script setup> import { useI18n } from 'vue-i18n' import { ref, onMounted } from 'vue' const { t } = useI18n() const isVisible = ref(false) const guideLeftRef = ref(null) const circleSmallRef = ref(null) const circleLargeRef = ref(null) const dotPatternLeftRef = ref(null) const dotPatternRightRef = ref(null) onMounted(() => { const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { isVisible.value = true observer.disconnect() } }) }, { threshold: 0.2 }) if (guideLeftRef.value) { observer.observe(guideLeftRef.value) } }) </script> <template> <section class="payment-guide-section"> <div class="payment-guide-container"> <div ref="guideLeftRef" class="guide-left" :class="{ 'animate': isVisible }" > <div class="compass-icon animate-bounce"> <img src="@/assets/icons/compass.png" alt="compass icon" class="compass-img"> </div> <div class="payment-text"> <span class="subtitle-green">About payment</span> <h2 class="guide-title">如何实现轻松支付</h2> <p class="guide-description"> 苹果支付,移动支付为首选,将微信或支付宝绑定银行卡可便捷消费。银联卡、国际信用卡、现金支付各有用武之地,结合使用更轻松。 </p> <ul class="features-list"> <li class="animate-item"><span class="check-icon">✓</span> Luctus risusd diam eget</li> <li class="animate-item"><span class="check-icon">✓</span> Donec enim congue magna</li> <li class="animate-item"><span class="check-icon">✓</span> Blandit sit amet non magna</li> </ul> </div> </div> </div> <div ref="circleLargeRef" class="circle-large" :class="{ 'animate': isVisible }"></div> <div ref="circleSmallRef" class="circle-small" :class="{ 'animate': isVisible }"></div> <div ref="dotPatternLeftRef" class="dot-pattern left" :class="{ 'animate': isVisible }"></div> <div ref="dotPatternRightRef" class="dot-pattern right" :class="{ 'animate': isVisible }"></div> </section> </template> <style scoped> .payment-guide-section { height: 938px; padding: 0; background-color: #FFFFFF; background-image: url('@/assets/PG-bg.png'); background-size: cover; background-position: center; background-repeat: no-repeat; position: relative; overflow: hidden; display: flex; align-items: center; } .payment-guide-section::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; } .payment-guide-container { width: 100%; max-width: 1920px; margin: 0 auto; display: flex; align-items: center; position: relative; z-index: 2; } .guide-left { margin-left: 152px; flex: 0 0 auto; display: flex; flex-direction: column; max-width: 650px; opacity: 0; transform: translateX(-50px); transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1); } .guide-left.animate { opacity: 1; transform: translateX(0); } .compass-icon { margin-bottom: 20px; width: 80px; height: 80px; display: flex; align-items: center; justify-content: center; } .animate-bounce { animation: bounce 2s infinite; } @keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } } .compass-img { width: 100%; height: 100%; object-fit: contain; } .payment-text { display: flex; flex-direction: column; } .subtitle-red { font-size: 1.75rem; color: #FD4C5C; font-weight: 600; margin-bottom: 4px; } .subtitle-green { font-size: 1.25rem; color: #00C389; font-weight: 500; margin-bottom: 16px; } .guide-title { font-size: 2.5rem; color: #2A2D32; font-weight: 700; margin-bottom: 20px; } .guide-description { font-size: 1.1rem; color: #52565E; line-height: 1.7; margin-bottom: 30px; max-width: 550px; } .features-list { list-style-type: none; padding: 0; margin: 0; } .features-list li { display: flex; align-items: center; margin-bottom: 12px; font-size: 1.1rem; color: #52565E; } .animate-item { opacity: 0; transform: translateX(-20px); transition: all 0.5s ease; } .guide-left.animate .animate-item:nth-child(1) { opacity: 1; transform: translateX(0); transition-delay: 0.3s; } .guide-left.animate .animate-item:nth-child(2) { opacity: 1; transform: translateX(0); transition-delay: 0.5s; } .guide-left.animate .animate-item:nth-child(3) { opacity: 1; transform: translateX(0); transition-delay: 0.7s; } .check-icon { color: #00C389; font-weight: bold; margin-right: 10px; font-size: 1.2rem; } .guide-right { display: none; } .circle-large { width: 467px; height: 610px; border-radius: 305px; background-image: url('@/assets/home/explore3.jpg'); background-size: cover; background-position: center; position: absolute; right: 140px; top: 116px; z-index: 2; border: 8px solid rgba(255, 255, 255, 0.2); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); opacity: 0; transform: scale(0.8) translateX(50px); transition: all 1s cubic-bezier(0.16, 1, 0.3, 1); } .circle-large.animate { opacity: 1; transform: scale(1) translateX(0); } .circle-small { width: 384px; height: 503px; border-radius: 252px; background-image: url('@/assets/home/explore4.jpg'); background-size: cover; background-position: center; position: absolute; right: 395px; top: 315px; z-index: 3; border: 8px solid rgba(255, 255, 255, 0.2); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); opacity: 0; transform: scale(0.8) translateX(50px); transition: all 1s cubic-bezier(0.16, 1, 0.3, 1) 0.2s; } .circle-small.animate { opacity: 1; transform: scale(1) translateX(0); animation: float 6s ease-in-out infinite; } @keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } } .dot-pattern { position: absolute; width: 80px; height: 360px; background-image: radial-gradient(#00C389 2px, transparent 2px); background-size: 12px 12px; z-index: 1; opacity: 0; transition: opacity 1.2s ease; } .dot-pattern.animate { opacity: 1; } .dot-pattern.left { left: 0; top: 50px; transition-delay: 0.8s; } .dot-pattern.right { right: 0; bottom: 50px; transition-delay: 1s; } /* 响应式样式 */ @media (max-width: 1400px) { .guide-left { margin-left: 100px; } .guide-right { margin-right: 100px; } .circle-large { width: 400px; height: 520px; border-radius: 260px; right: 100px; top: 100px; } .circle-small { width: 340px; height: 450px; border-radius: 225px; right: 70px; top: 70px; } } @media (max-width: 1200px) { .payment-guide-container { flex-direction: column; align-items: center; padding: 0 40px; } .guide-left { margin-left: 0; margin-bottom: 60px; align-items: center; text-align: center; } .guide-right { margin-right: 0; width: 100%; justify-content: center; } .guide-description { text-align: center; margin-left: auto; margin-right: auto; } .circle-large { right: 50%; transform: translateX(160px); width: 350px; height: 460px; border-radius: 230px; top: 80px; } .circle-large.animate { transform: translateX(160px); } .circle-small { right: 50%; transform: translateX(-100px); width: 300px; height: 400px; border-radius: 200px; } .circle-small.animate { transform: translateX(-100px); animation: float 6s ease-in-out infinite; } @keyframes float { 0%, 100% { transform: translateX(-100px) translateY(0); } 50% { transform: translateX(-100px) translateY(-15px); } } } @media (max-width: 768px) { .payment-guide-container { padding: 0 30px; } .guide-right { height: 300px; } .circle-large { width: 280px; height: 360px; border-radius: 180px; top: 50px; } .circle-small { width: 240px; height: 320px; border-radius: 160px; top: 50px; } } @media (max-width: 576px) { .payment-guide-container { padding: 0 20px; } .circle-small { width: 200px; height: 280px; border-radius: 140px; } .circle-large { width: 220px; height: 300px; border-radius: 150px; } } </style>
2302_81331056/travel
src/components/home/PaymentGuide.vue
Vue
unknown
8,550
<script setup> import { useI18n } from 'vue-i18n' import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { library } from '@fortawesome/fontawesome-svg-core' import { faMobileScreen, faCreditCard, faMoneyBillWave } from '@fortawesome/free-solid-svg-icons' // 添加图标到库中 library.add(faMobileScreen, faCreditCard, faMoneyBillWave) const { t } = useI18n() </script> <template> <section class="payment-section"> <div class="payment-container"> <div class="payment-option"> <div class="icon-hexagon"> <font-awesome-icon :icon="faMobileScreen" size="2x" class="fa-icon" /> </div> <h3 class="payment-title">移动支付</h3> <p class="payment-subtitle">Total Users</p> </div> <div class="payment-option"> <div class="icon-hexagon"> <font-awesome-icon :icon="faCreditCard" size="2x" class="fa-icon" /> </div> <h3 class="payment-title">银行卡支付</h3> <p class="payment-subtitle">Total Tours</p> </div> <div class="payment-option"> <div class="icon-hexagon"> <font-awesome-icon :icon="faMoneyBillWave" size="2x" class="fa-icon" /> </div> <h3 class="payment-title">现金支付</h3> <p class="payment-subtitle">Social Likes</p> </div> </div> </section> </template> <style scoped> .payment-section { background-color: #00C389; background-image: url('@/assets/PO-bg.png'); background-size: cover; background-position: center; background-repeat: no-repeat; padding: 0; width: 100%; height: 460px; display: flex; justify-content: center; align-items: center; position: relative; } .payment-section::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; } .payment-container { max-width: 1200px; width: 100%; display: flex; justify-content: space-around; align-items: center; margin: 0 auto; padding: 0 20px; position: relative; z-index: 2; } .payment-option { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 15px; flex: 1; } .icon-hexagon { width: 80px; height: 80px; background-color: rgba(255, 255, 255, 0.1); margin-bottom: 24px; position: relative; clip-path: polygon(50% 0%, 93.3% 25%, 93.3% 75%, 50% 100%, 6.7% 75%, 6.7% 25%); border-radius: 20px; display: flex; align-items: center; justify-content: center; } .fa-icon { color: white; font-size: 28px; } .payment-title { font-size: 2.5rem; color: white; font-weight: 600; margin-bottom: 8px; } .payment-subtitle { font-size: 1rem; color: rgba(255, 255, 255, 0.8); font-weight: 400; } .yuan-symbol { font-size: 42px; font-weight: bold; color: #ffffff; line-height: 1; } /* 响应式设计 */ @media (max-width: 992px) { .payment-section { height: auto; min-height: 460px; padding: 60px 0; } .payment-container { flex-direction: column; gap: 40px; } .payment-option { width: 100%; max-width: 300px; } } @media (max-width: 576px) { .payment-section { height: auto; min-height: 460px; padding: 40px 0; } .payment-title { font-size: 2rem; } .icon-hexagon { width: 60px; height: 60px; margin-bottom: 16px; } .fa-icon { font-size: 20px; } } </style>
2302_81331056/travel
src/components/home/PaymentOptions.vue
Vue
unknown
3,460
<script setup> import { ref, onMounted, onUnmounted } from 'vue'; // 导入头像图片 import avatar1 from '@/assets/home/avatar1.jpg'; import avatar2 from '@/assets/home/avatar2.jpg'; import avatar3 from '@/assets/home/avatar3.jpg'; import avatar4 from '@/assets/home/avatar4.jpg'; import avatar5 from '@/assets/home/avatar5.jpg'; import avatar6 from '@/assets/home/avatar6.jpg'; const isVisible = ref(false); const sectionRef = ref(null); const currentIndex = ref(0); const isScrolling = ref(false); const testimonials = [ { id: 1, content: "An enim nullam tempor gravida donec enim congue magna at pretium purus pretium ligula rutrum luctus risusd diam eget risus varius blandit sit amet non magna.", name: "Jenny Wilson", title: "Web Developer" }, { id: 2, content: "中国的美食丰富多样,从北方的面食到南方的米饭,每个地区都有独特的风味和特色。我特别喜欢川菜的麻辣口感和粤菜的鲜香。", name: "Michael Chen", title: "Food Blogger" }, { id: 3, content: "在中国旅行期间,我惊叹于古代建筑与现代都市的完美结合。从北京的长城到上海的摩天大楼,处处充满了历史与未来的对话。", name: "Sophie Martin", title: "Travel Writer" } ]; const avatars = [ { id: 1, image: avatar1, position: { top: '-40px', left: '10%' } }, { id: 2, image: avatar2, position: { bottom: '100px', left: '5%' } }, { id: 3, image: avatar3, position: { top: '100px', right: '15%' } }, { id: 4, image: avatar4, position: { bottom: '-20px', right: '20%' } }, { id: 5, image: avatar5, position: { top: '50%', left: '-20px' } }, { id: 6, image: avatar6, position: { top: '30%', right: '-20px' } } ]; const handleScroll = (event) => { if (!isVisible.value || isScrolling.value) return; // 阻止默认滚动行为 event.preventDefault(); isScrolling.value = true; // 判断滚动方向 if (event.deltaY > 0) { // 向下滚动 if (currentIndex.value < testimonials.length - 1) { currentIndex.value++; } else { // 已经是最后一个卡片,允许页面滚动 event.target.removeEventListener('wheel', handleScroll); return; } } else { // 向上滚动 if (currentIndex.value > 0) { currentIndex.value--; } else { // 已经是第一个卡片,允许页面滚动 event.target.removeEventListener('wheel', handleScroll); return; } } // 防抖,避免快速滚动导致卡片切换过快 setTimeout(() => { isScrolling.value = false; }, 500); }; const setSlide = (index) => { currentIndex.value = index; }; onMounted(() => { const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { isVisible.value = true; observer.disconnect(); // 当组件可见时添加滚动事件监听 if (sectionRef.value) { sectionRef.value.addEventListener('wheel', handleScroll, { passive: false }); } } }); }, { threshold: 0.2 }); if (sectionRef.value) { observer.observe(sectionRef.value); } }); onUnmounted(() => { if (sectionRef.value) { sectionRef.value.removeEventListener('wheel', handleScroll); } }); </script> <template> <section ref="sectionRef" class="testimonials-section"> <div class="background-pattern"></div> <div class="background-gradient"></div> <div class="floating-shapes"> <div class="shape shape-1"></div> <div class="shape shape-2"></div> <div class="shape shape-3"></div> <div class="shape shape-4"></div> <div class="shape shape-5"></div> </div> <div class="testimonials-container"> <div class="testimonials-header" :class="{ 'animate': isVisible }"> <span class="subtitle">用户体验</span> <h2 class="title">相聚来华论坛,畅聊在华的那些事儿</h2> </div> <div class="testimonials-carousel" :class="{ 'animate': isVisible }"> <div v-for="avatar in avatars" :key="avatar.id" class="avatar-circle" :style="{ top: avatar.position.top || 'auto', left: avatar.position.left || 'auto', right: avatar.position.right || 'auto', bottom: avatar.position.bottom || 'auto', animationDelay: `${avatar.id * 0.5}s` }" > <img :src="avatar.image" :alt="'User avatar ' + avatar.id"> </div> <div class="testimonial-cards-container"> <div v-for="(testimonial, index) in testimonials" :key="testimonial.id" class="testimonial-card" :class="{ 'active': index === currentIndex, 'prev': (index === currentIndex - 1) || (currentIndex === 0 && index === testimonials.length - 1), 'next': (index === currentIndex + 1) || (currentIndex === testimonials.length - 1 && index === 0) }" > <div class="quote-icon-top">"</div> <div class="testimonial-content"> <p>{{ testimonial.content }}</p> </div> <div class="testimonial-author"> <div class="author-avatar"> <img :src="avatar1" alt="Author avatar" v-if="index === 0"> <img :src="avatar2" alt="Author avatar" v-if="index === 1"> <img :src="avatar3" alt="Author avatar" v-if="index === 2"> </div> <div class="author-info"> <h3>{{ testimonial.name }}</h3> <p>{{ testimonial.title }}</p> </div> </div> </div> </div> <div class="testimonial-nav"> <button class="nav-arrow prev" @click="setSlide(currentIndex > 0 ? currentIndex - 1 : testimonials.length - 1)"> ← </button> <div class="nav-dots"> <div v-for="(testimonial, index) in testimonials" :key="testimonial.id" class="nav-dot" :class="{ 'active': index === currentIndex }" @click="setSlide(index)" ></div> </div> <button class="nav-arrow next" @click="setSlide(currentIndex < testimonials.length - 1 ? currentIndex + 1 : 0)"> → </button> </div> </div> </div> </section> </template> <style scoped> .testimonials-section { width: 100%; height: 854px; background-color: #f0f5fa; background-image: linear-gradient(135deg, #f0f5fa 0%, #f8f9fc 100%); padding: 80px 0; position: relative; overflow: hidden; } .background-pattern { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-image: radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 15%), radial-gradient(circle at 75% 75%, rgba(0, 195, 137, 0.05) 0%, rgba(0, 195, 137, 0) 20%); opacity: 0.6; z-index: 0; } .background-gradient { position: absolute; top: -50%; left: -20%; width: 140%; height: 200%; background: radial-gradient(circle at 30% 40%, rgba(0, 195, 137, 0.08) 0%, rgba(0, 195, 137, 0.04) 30%, rgba(0, 0, 0, 0) 70%); z-index: 0; transform: rotate(-10deg); } .floating-shapes { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; } .shape { position: absolute; border-radius: 50%; background: linear-gradient(145deg, rgba(0, 195, 137, 0.2), rgba(0, 195, 137, 0.05)); backdrop-filter: blur(2px); opacity: 0.3; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.03); } .shape-1 { width: 180px; height: 180px; top: 15%; left: 5%; animation: float-shape 20s infinite ease-in-out; } .shape-2 { width: 120px; height: 120px; top: 75%; left: 8%; animation: float-shape 15s infinite ease-in-out reverse; } .shape-3 { width: 150px; height: 150px; top: 20%; right: 10%; animation: float-shape 18s infinite ease-in-out 2s; } .shape-4 { width: 100px; height: 100px; top: 60%; right: 5%; animation: float-shape 12s infinite ease-in-out 1s; } .shape-5 { width: 200px; height: 200px; bottom: -5%; right: 40%; animation: float-shape 25s infinite ease-in-out 3s; } @keyframes float-shape { 0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); } 20% { transform: translate(-10px, 10px) rotate(3deg) scale(1.05); } 40% { transform: translate(15px, -5px) rotate(-2deg) scale(0.95); } 60% { transform: translate(-5px, -15px) rotate(4deg) scale(1.02); } 80% { transform: translate(10px, 5px) rotate(-3deg) scale(0.98); } } .testimonials-container { max-width: 1600px; width: 100%; height: 100%; margin: 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; z-index: 5; } .testimonials-header { text-align: center; margin-bottom: 60px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease; } .testimonials-header.animate { opacity: 1; transform: translateY(0); } .subtitle { position: relative; display: inline-block; font-size: 1.25rem; color: #00c389; font-weight: 600; margin-bottom: 16px; padding: 5px 20px; border-radius: 30px; background: rgba(0, 195, 137, 0.1); } .title { font-size: 2.5rem; color: #2a2d32; font-weight: 700; margin: 0; background: linear-gradient(120deg, #2a2d32, #4a5568); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; } .testimonials-carousel { width: 100%; max-width: 1000px; position: relative; display: flex; flex-direction: column; align-items: center; opacity: 0; transform: translateY(30px); transition: all 0.8s ease 0.3s; } .testimonials-carousel.animate { opacity: 1; transform: translateY(0); } .avatar-circle { position: absolute; width: 60px; height: 60px; border-radius: 50%; overflow: hidden; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); z-index: 6; animation: float 6s ease-in-out infinite; transition: transform 0.3s ease; cursor: pointer; border: 3px solid white; } .avatar-circle::before { content: ''; position: absolute; top: -4px; left: -4px; right: -4px; bottom: -4px; background: radial-gradient(circle at center, rgba(0, 195, 137, 0.2) 0%, rgba(0, 195, 137, 0) 70%); border-radius: 50%; z-index: -1; opacity: 0; transition: opacity 0.3s ease; } .avatar-circle:hover::before { opacity: 1; } .avatar-circle img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; } .avatar-circle:hover { transform: scale(1.1) translateY(-5px); box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15); z-index: 10; } .avatar-circle:hover img { transform: scale(1.1); } @keyframes float { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-15px) rotate(5deg); } } .testimonial-cards-container { position: relative; width: 100%; max-width: 800px; height: 320px; margin: 0 auto; perspective: 1200px; z-index: 20; } .testimonial-card { background: linear-gradient(145deg, #ffffff, #f9f9f9); border-radius: 24px; padding: 50px 40px 40px; width: 100%; max-width: 800px; box-shadow: 0 15px 40px rgba(0, 0, 0, 0.05), 0 5px 15px rgba(0, 0, 0, 0.03); position: absolute; top: 0; left: 0; right: 0; margin: 0 auto; transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1); opacity: 0; z-index: 0; transform: translateY(40px) scale(0.9); pointer-events: none; border: 1px solid rgba(255, 255, 255, 0.8); backdrop-filter: blur(5px); } .testimonial-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1)); border-radius: 24px; z-index: -1; } .testimonial-card.active { opacity: 1; transform: translateY(0) scale(1); z-index: 7; pointer-events: auto; } .testimonial-card.prev { opacity: 0.5; transform: translateX(-5%) translateY(-20px) scale(0.95) rotateY(-5deg); z-index: 2; filter: blur(2px); } .testimonial-card.next { opacity: 0.3; transform: translateX(5%) translateY(60px) scale(0.9) rotateY(5deg); z-index: 1; filter: blur(4px); } .quote-icon-top { position: absolute; top: 20px; left: 30px; font-size: 5rem; color: rgba(0, 195, 137, 0.1); font-family: 'Georgia', serif; line-height: 0.5; } .testimonial-content { margin-bottom: 30px; position: relative; } .testimonial-content p { font-size: 1.2rem; line-height: 1.8; color: #4a5568; margin: 0; font-style: italic; } .testimonial-author { display: flex; align-items: center; gap: 15px; border-top: 1px solid rgba(0, 0, 0, 0.05); padding-top: 20px; } .author-avatar { width: 50px; height: 50px; border-radius: 50%; overflow: hidden; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); border: 2px solid white; } .author-avatar img { width: 100%; height: 100%; object-fit: cover; } .author-info { flex: 1; } .author-info h3 { font-size: 1.2rem; color: #2d3748; margin: 0 0 5px 0; font-weight: 600; } .author-info p { font-size: 0.95rem; color: #00c389; margin: 0; font-weight: 500; } .testimonial-nav { display: flex; align-items: center; gap: 30px; margin-top: 40px; position: relative; z-index: 10; } .nav-dots { display: flex; gap: 12px; } .nav-dot { width: 12px; height: 12px; border-radius: 50%; background-color: #e2e8f0; cursor: pointer; transition: all 0.3s ease; } .nav-dot.active { background-color: #00c389; transform: scale(1.2); } .nav-dot:hover { background-color: #00c389; transform: scale(1.1); } .nav-arrow { width: 40px; height: 40px; border-radius: 50%; background-color: white; color: #4a5568; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s ease; border: 1px solid #e2e8f0; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); } .nav-arrow:hover { background-color: #00c389; color: white; transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); } /* 响应式样式 */ @media (max-width: 1200px) { .testimonials-section { height: auto; padding: 80px 40px; } .title { font-size: 2.2rem; } .testimonial-card { max-width: 700px; padding: 40px 35px 35px; } } @media (max-width: 992px) { .testimonials-section { padding: 60px 30px; } .subtitle { font-size: 1.1rem; } .title { font-size: 1.8rem; } .testimonial-content p { font-size: 1.1rem; } .avatar-circle { width: 50px; height: 50px; } .testimonial-cards-container { height: 350px; } } @media (max-width: 768px) { .testimonials-section { padding: 50px 20px; } .subtitle { font-size: 1rem; } .title { font-size: 1.6rem; } .testimonial-card { padding: 30px 25px 25px; } .testimonial-content p { font-size: 1rem; } .author-info h3 { font-size: 1.1rem; } .avatar-circle:nth-child(odd) { display: none; } .testimonial-cards-container { height: 400px; } .quote-icon-top { font-size: 4rem; } } @media (max-width: 576px) { .testimonials-section { padding: 40px 15px; } .testimonial-card { padding: 25px 20px 20px; } .testimonial-cards-container { height: 450px; } .avatar-circle { width: 40px; height: 40px; } .nav-arrow { width: 35px; height: 35px; } } </style>
2302_81331056/travel
src/components/home/Testimonials.vue
Vue
unknown
15,901
<script setup> import { ref, onMounted } from 'vue'; const isVisible = ref(false); const footerRef = ref(null); onMounted(() => { // 不再动态加载FontAwesome,改为在index.html中加载或通过npm包管理 const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { isVisible.value = true; observer.disconnect(); } }); }, { threshold: 0.2 }); if (footerRef.value) { observer.observe(footerRef.value); } }); </script> <template> <footer ref="footerRef" class="footer-section" :class="{ 'animate': isVisible }"> <div class="footer-container"> <div class="footer-top"> <!-- 公司信息区域 --> <div class="company-info"> <div class="logo"> <img src="@/assets/icons/logo.png" alt="TripGo Logo" /> </div> <p class="company-desc"> 探索中国之美,感受东方魅力。我们致力于为全球旅行者提供最地道的中国旅行体验,从历史古迹到现代都市,从北方雪景到南方水乡,带您领略多彩中国的独特魅力。 </p> <div class="social-icons"> <a href="#" class="social-icon" aria-label="微信"> <i class="fab fa-weixin"></i> </a> <a href="#" class="social-icon" aria-label="微博"> <i class="fab fa-weibo"></i> </a> <a href="#" class="social-icon" aria-label="抖音"> <i class="fab fa-tiktok"></i> </a> </div> </div> <!-- 支持信息区域 --> <div class="footer-links"> <h3 class="footer-heading">旅行支持</h3> <ul class="footer-nav"> <li><a href="#">旅行问答</a></li> <li><a href="#">隐私政策</a></li> <li><a href="#">紧急联系</a></li> <li><a href="#">旅游保险</a></li> </ul> </div> <!-- 关于我们区域 --> <div class="footer-links"> <h3 class="footer-heading">关于我们</h3> <ul class="footer-nav"> <li><a href="#">品牌故事</a></li> <li><a href="#">旅行攻略</a></li> <li><a href="#">加入我们</a></li> <li><a href="#">商务合作</a></li> <li><a href="#">媒体中心</a></li> </ul> </div> <!-- 联系信息区域 --> <div class="footer-contact"> <h3 class="footer-heading">联系我们</h3> <address class="contact-details"> <p><i class="fas fa-map-marker-alt contact-icon"></i> 武汉市</p> <p class="contact-phone"><i class="fas fa-phone contact-icon"></i> 400-888-8888</p> <p class="contact-email"><i class="fas fa-envelope contact-icon"></i> service@tripgo.cn</p> </address> </div> </div> <div class="footer-bottom"> <div class="copyright"> <p>© 2023 签悦中国 版权所有 | 京ICP备12345678号</p> </div> <div class="payment-methods"> <span class="payment-text">支持付款方式:</span> <span class="payment-type"> <i class="fab fa-alipay payment-icon"></i> 支付宝 </span> <span class="payment-type"> <i class="fab fa-weixin payment-icon"></i> 微信支付 </span> </div> </div> </div> </footer> </template> <style scoped> .footer-section { width: 100%; background-color: #ffffff; padding: 60px 0 30px; border-top: 1px solid #e9e9e9; } .footer-container { max-width: 1296px; margin: 0 auto; padding: 0 20px; } .footer-top { display: grid; grid-template-columns: repeat(4, 1fr); gap: 30px; margin-bottom: 50px; opacity: 0; transform: translateY(30px); transition: all 0.6s ease-out; } .animate .footer-top { opacity: 1; transform: translateY(0); } .company-info { max-width: 300px; } .logo { margin-bottom: 20px; } .logo img { height: 40px; } .company-desc { font-size: 0.95rem; line-height: 1.6; color: #666; margin-bottom: 20px; } .social-icons { display: flex; gap: 15px; } .social-icon { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background-color: #f5f5f5; color: #333; transition: all 0.3s ease; } .social-icon:hover { background-color: #00c389; color: white; } .footer-heading { font-size: 1.2rem; font-weight: 600; color: #333; margin-bottom: 20px; } .footer-nav { list-style: none; padding: 0; margin: 0; } .footer-nav li { margin-bottom: 12px; } .footer-nav a { color: #666; text-decoration: none; transition: color 0.3s ease; } .footer-nav a:hover { color: #00c389; } .contact-details { font-style: normal; color: #666; line-height: 1.6; } .contact-details p { margin-bottom: 8px; } .contact-phone, .contact-email { margin-top: 16px; } .footer-bottom { display: flex; justify-content: space-between; align-items: center; padding-top: 30px; border-top: 1px solid #e9e9e9; opacity: 0; transform: translateY(20px); transition: all 0.6s ease-out 0.2s; } .animate .footer-bottom { opacity: 1; transform: translateY(0); } .copyright { color: #888; font-size: 0.9rem; } .payment-text { color: #888; font-size: 0.9rem; margin-right: 10px; } .payment-type { display: flex; align-items: center; color: #666; font-size: 0.9rem; background-color: #f5f5f5; padding: 4px 8px; border-radius: 4px; margin: 0 5px; transition: all 0.3s ease; } .payment-type:hover { background-color: #e9e9e9; } .payment-methods { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; } .contact-icon { margin-right: 8px; width: 16px; color: #00c389; } .payment-icon { width: 20px; height: 20px; margin-right: 5px; vertical-align: middle; } /* 响应式设计 */ @media (max-width: 992px) { .footer-top { grid-template-columns: repeat(2, 1fr); } .company-info { grid-column: span 2; max-width: 100%; } } @media (max-width: 768px) { .footer-bottom { flex-direction: column; gap: 20px; } .payment-methods { flex-wrap: wrap; justify-content: center; } } @media (max-width: 576px) { .footer-top { grid-template-columns: 1fr; } .company-info { grid-column: 1; } .footer-section { padding: 40px 0 20px; } } </style>
2302_81331056/travel
src/components/home/TheFooter.vue
Vue
unknown
6,611
<script setup> import { ref, computed } from 'vue' import { useI18n } from 'vue-i18n' import { nextTick, onMounted } from 'vue' import { useRouter } from 'vue-router' import { isLoggedIn, getUserInfo, logout } from '@/utils/auth' const { t, locale } = useI18n() const router = useRouter() const showLanguagePopup = ref(false) const showUserPopup = ref(false) // 计算属性:判断用户是否已登录 const userLoggedIn = ref(isLoggedIn()) // 用户信息 const userInfo = ref(getUserInfo()) // 刷新登录状态 const refreshLoginStatus = () => { userLoggedIn.value = isLoggedIn() userInfo.value = getUserInfo() } const toggleLanguage = () => { showLanguagePopup.value = !showLanguagePopup.value if (showLanguagePopup.value) { showUserPopup.value = false } } const toggleUserPopup = () => { showUserPopup.value = !showUserPopup.value if (showUserPopup.value) { showLanguagePopup.value = false } } const selectLanguage = (lang) => { locale.value = lang localStorage.setItem('locale', lang) showLanguagePopup.value = false } const closeLanguagePopup = (event) => { const languageSelector = document.querySelector('.language-selector') const languagePopup = document.querySelector('.language-popup') if (showLanguagePopup.value && languageSelector && languagePopup && !languageSelector.contains(event.target) && !languagePopup.contains(event.target)) { showLanguagePopup.value = false } } const closeUserPopup = (event) => { const userProfile = document.querySelector('.user-profile') const userPopup = document.querySelector('.user-popup') if (showUserPopup.value && userProfile && userPopup && !userProfile.contains(event.target) && !userPopup.contains(event.target)) { showUserPopup.value = false } } const handleLogout = () => { logout() showUserPopup.value = false router.push('/login') } const navigateTo = (path) => { showUserPopup.value = false router.push(path) } onMounted(() => { document.addEventListener('click', closeLanguagePopup) document.addEventListener('click', closeUserPopup) // 监听登录状态变化 window.addEventListener('storage', function(e) { if (e.key === 'user_token' || e.key === 'user_info') { // 强制重新计算计算属性 refreshLoginStatus() } }) }) </script> <template> <header class="header"> <div class="header-content"> <div class="logo-container"> <router-link to="/" class="logo"> <img src="@/assets/icons/logo.png" alt="登悦中国" class="logo-image" /> </router-link> </div> <nav class="main-nav"> <router-link to="/">{{ t('navigation.home') }}</router-link> <router-link to="/visa">{{ t('navigation.visa') }}</router-link> <router-link to="/payment">{{ t('navigation.payment') }}</router-link> <router-link to="/travel">{{ t('navigation.travel') }}</router-link> <router-link to="/forum">{{ t('navigation.forum') }}</router-link> </nav> <div class="header-actions"> <div class="language-selector" @click="toggleLanguage"> {{ locale.toUpperCase() }} <span class="dropdown-arrow">▼</span> </div> <!-- 根据登录状态显示不同的内容 --> <template v-if="userLoggedIn"> <div class="user-profile" @click="toggleUserPopup"> <div class="avatar-container"> <i class="avatar-icon fas fa-user-circle"></i> </div> <span class="dropdown-arrow">▼</span> </div> </template> <template v-else> <router-link to="/login" class="login-button">{{ t('navigation.login') }}</router-link> </template> </div> </div> </header> <!-- 语言选择弹出框 --> <div class="language-popup" v-if="showLanguagePopup"> <div class="language-option" @click="selectLanguage('zh')"> {{ t('language.chinese') }} <span class="language-check" v-if="locale === 'zh'">✓</span> </div> <div class="language-option" @click="selectLanguage('en')"> {{ t('language.english') }} <span class="language-check" v-if="locale === 'en'">✓</span> </div> </div> <!-- 用户菜单弹出框 --> <div class="user-popup" v-if="showUserPopup && userLoggedIn"> <div class="user-popup-header"> <div class="large-avatar"> <i class="large-avatar-icon fas fa-user-circle"></i> </div> <div class="user-name">{{ userInfo?.username || '用户' }}</div> </div> <div class="user-options"> <div class="user-option" @click="navigateTo('/profile')"> <i class="fas fa-user"></i> 个人信息 </div> <div class="user-option" @click="navigateTo('/settings')"> <i class="fas fa-cog"></i> 设置 </div> <div class="user-option logout" @click="handleLogout"> <i class="fas fa-sign-out-alt"></i> 退出登录 </div> </div> </div> </template> <style scoped> /* 顶部导航栏样式 */ .header { width: 100%; height: 70px; background-color: #ffffff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); position: sticky; top: 0; z-index: 100; } .header-content { max-width: 1600px; height: 100%; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; } /* Logo 相关样式 */ .logo-container { display: flex; align-items: center; margin-left: 152px; } .logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; transition: transform 0.3s ease; } .logo:hover { transform: scale(1.05); } .logo-image { height: 40px; width: auto; } /* 导航菜单样式 */ .main-nav { display: flex; gap: 36px; } .main-nav a { text-decoration: none; color: #333; font-size: 1rem; position: relative; transition: color 0.3s; } .main-nav a:hover { color: #00c389; } .main-nav a::after { content: ''; position: absolute; width: 0; height: 2px; bottom: -5px; left: 50%; background-color: #00c389; transition: all 0.3s; transform: translateX(-50%); } .main-nav a:hover::after { width: 100%; } /* 头部操作区样式 */ .header-actions { display: flex; align-items: center; gap: 20px; } /* 语言选择器样式 */ .language-selector { padding: 5px 10px; border-radius: 4px; background: #f5f5f5; cursor: pointer; transition: all 0.3s; display: flex; align-items: center; gap: 5px; position: relative; } .language-selector:hover { background: #e0e0e0; } .dropdown-arrow { font-size: 0.7rem; margin-left: 2px; } /* 登录按钮样式 */ .login-button { padding: 10px 20px; background-color: #ff5a5a; color: #fff; border-radius: 5px; cursor: pointer; transition: background-color 0.3s; text-decoration: none; display: inline-block; text-align: center; } .login-button:hover { background-color: #ff3939; } /* 语言选择弹出框样式 */ .language-popup { position: absolute; top: 70px; right: 120px; background: white; border-radius: 5px; box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15); overflow: hidden; z-index: 200; animation: fadeIn 0.2s ease; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } .language-option { padding: 12px 25px; cursor: pointer; transition: background 0.3s; display: flex; align-items: center; justify-content: space-between; min-width: 150px; } .language-option:hover { background: #f5f8fa; } .language-check { color: #00c389; font-weight: bold; } /* 响应式样式 */ @media (max-width: 1200px) { .logo-container { margin-left: 100px; } } @media (max-width: 992px) { .logo-container { margin-left: 60px; } } @media (max-width: 768px) { .header-content { padding: 0 15px; } .main-nav { gap: 20px; } .logo-container { margin-left: 30px; } } @media (max-width: 576px) { .header-content { justify-content: center; } .logo-container { display: none; } .main-nav { gap: 15px; } .main-nav a { font-size: 0.9rem; } } /* 用户头像和下拉菜单样式 */ .user-profile { display: flex; align-items: center; gap: 8px; cursor: pointer; position: relative; transition: all 0.3s ease; } .user-profile:hover .avatar-container { transform: scale(1.05); box-shadow: 0 0 10px rgba(0, 195, 137, 0.2); } .avatar-container { width: 32px; height: 32px; border-radius: 50%; background-color: #f0f0f0; overflow: hidden; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; } .avatar-icon { font-size: 24px; color: #888888; transition: transform 0.3s ease; } .user-profile:hover .avatar-icon { transform: rotate(5deg); } .user-name { font-size: 0.9rem; color: #333; } .user-popup { position: absolute; top: 70px; right: 0; width: 280px; background: white; border-radius: 8px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); padding: 20px; z-index: 100; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; transform-origin: top right; } @keyframes popIn { from { opacity: 0; transform: scale(0.9) translateY(-10px); } to { opacity: 1; transform: scale(1) translateY(0); } } .user-popup-header { display: flex; align-items: center; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid #eee; } .large-avatar { width: 48px; height: 48px; border-radius: 50%; background-color: #f0f0f0; margin-right: 15px; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; } .large-avatar-icon { font-size: 36px; color: #888888; } .user-options { padding: 10px 0; } .user-option { display: flex; align-items: center; padding: 12px 20px; color: #555; font-size: 0.95rem; transition: all 0.3s ease; text-decoration: none; gap: 10px; border-radius: 6px; margin-bottom: 4px; animation: fadeInRight 0.5s ease forwards; opacity: 0; transform: translateX(-10px); } .user-option:nth-child(1) { animation-delay: 0.1s; } .user-option:nth-child(2) { animation-delay: 0.2s; } .user-option:nth-child(3) { animation-delay: 0.3s; } .user-option:nth-child(4) { animation-delay: 0.4s; } @keyframes fadeInRight { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } } .user-option:hover { background-color: #f5f8fa; color: #00c389; transform: translateY(-2px); } .user-option i { transition: transform 0.3s ease; } .user-option:hover i { transform: scale(1.2); } .user-option.logout { color: #ff5a5a; cursor: pointer; } .user-option.logout:hover { background-color: #fff8f8; color: #ff3939; } </style>
2302_81331056/travel
src/components/home/TheHeader.vue
Vue
unknown
10,953
<script setup> import { ref, onMounted } from 'vue' import { useI18n } from 'vue-i18n' import { useRouter } from 'vue-router' import PaymentGuide from './PaymentGuide.vue' const { t } = useI18n() const router = useRouter() const navigateTo = (path) => { router.push(path) } onMounted(() => { setTimeout(() => { document.querySelector('.hero-text').classList.add('animated') document.querySelector('.search-container').classList.add('animated') }, 300) }) </script> <template> <section class="hero-section"> <div class="hero-content"> <div class="hero-text"> <div class="year-tag">{{ t('hero.year') }}</div> <h1 class="main-title"> <span class="title-line">{{ t('hero.titleLine1') }}</span> <span class="title-line">{{ t('hero.titleLine2') }}</span> <span class="title-line">{{ t('hero.titleLine3') }}</span> </h1> <p class="subtitle">{{ t('hero.subtitle') }}</p> </div> </div> <!-- 搜索/选项卡区域 --> <div class="search-container"> <div class="search-tabs"> <div class="tab" @click="navigateTo('/visa')"> <div class="tab-icon"> <i class="fas fa-passport"></i> </div> <div class="tab-content"> <div class="tab-title">签证政策</div> <div class="tab-subtitle">免签入境中国</div> </div> </div> <div class="tab" @click="navigateTo('/payment')"> <div class="tab-icon"> <i class="fas fa-wallet"></i> </div> <div class="tab-content"> <div class="tab-title">支付指南</div> <div class="tab-subtitle">轻松支付无障碍</div> </div> </div> <div class="tab" @click="navigateTo('/travel')"> <div class="tab-icon"> <i class="fas fa-route"></i> </div> <div class="tab-content"> <div class="tab-title">智能行程</div> <div class="tab-subtitle">AI规划旅游路线</div> </div> </div> <div class="tab" @click="navigateTo('/forum')"> <div class="tab-icon"> <i class="fas fa-comments"></i> </div> <div class="tab-content"> <div class="tab-title">旅行论坛</div> <div class="tab-subtitle">分享旅行经验</div> </div> </div> </div> </div> </section> </template> <style scoped> /* 主横幅区域样式 */ .hero-section { width: 100%; min-height: calc(100vh - 70px); position: relative; background-image: url('@/assets/home/bg3.png'); background-size: cover; background-position: center; background-repeat: no-repeat; } .hero-section::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.4); z-index: 1; } .hero-content { max-width: 1600px; margin: 0 auto; padding: 60px 20px; display: flex; position: relative; z-index: 2; } .hero-text { width: 55%; padding-top: 40px; margin-left: 100px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease; } .hero-text.animated { opacity: 1; transform: translateY(0); } .year-tag { color: #ffffff; font-size: 1.5rem; margin-bottom: 20px; font-weight: 500; } .main-title { font-size: 3.5rem; font-weight: bold; line-height: 1.3; margin-bottom: 20px; color: #ffffff; } .title-line { display: block; } .subtitle { font-size: 1.2rem; color: #ffffff; margin-bottom: 50px; } /* 搜索/选项卡区域样式 */ .search-container { max-width: 840px; margin-left: 100px; background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(10px); border-radius: 16px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); position: relative; z-index: 10; overflow: hidden; opacity: 0; transform: translateY(30px); transition: all 0.8s ease 0.2s; border: 1px solid rgba(255, 255, 255, 0.18); } .search-container.animated { opacity: 1; transform: translateY(0); } .search-tabs { display: flex; width: 100%; } .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 25px 15px; cursor: pointer; transition: all 0.3s ease; color: #ffffff; position: relative; overflow: hidden; } .tab::before { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 0; height: 3px; background-color: #16a34a; transition: width 0.3s ease; } .tab:hover { background-color: rgba(255, 255, 255, 0.2); } .tab:hover::before { width: 60%; } .tab-icon { font-size: 28px; margin-bottom: 12px; color: #ffffff; transition: transform 0.3s ease; } .tab:hover .tab-icon { transform: translateY(-5px); } .tab-content { text-align: center; } .tab-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 5px; color: #ffffff; } .tab-subtitle { font-size: 0.85rem; color: rgba(255, 255, 255, 0.8); } /* 响应式样式 */ @media (max-width: 1200px) { .hero-text { margin-left: 80px; } .search-container { margin-left: 80px; } .main-title { font-size: 3rem; } } @media (max-width: 992px) { .hero-content { flex-direction: column; } .hero-text { margin-left: 60px; width: 100%; padding-top: 20px; } .search-container { margin-left: 60px; max-width: 90%; } .main-title { font-size: 2.5rem; } } @media (max-width: 768px) { .hero-text { margin-left: 40px; } .search-container { margin-left: 40px; } .main-title { font-size: 2rem; } .tab { padding: 20px 10px; } .tab-icon { font-size: 24px; margin-bottom: 8px; } .tab-title { font-size: 0.9rem; } .tab-subtitle { font-size: 0.75rem; } .search-tabs { flex-wrap: wrap; } .tab { flex: 0 0 50%; } } @media (max-width: 576px) { .hero-text { margin-left: 20px; } .search-container { margin-left: 20px; } .main-title { font-size: 1.8rem; } .subtitle { font-size: 1rem; } } </style>
2302_81331056/travel
src/components/home/TheHero.vue
Vue
unknown
6,150
<script setup> import { ref, onMounted } from 'vue'; // 导入图片 import explore1 from '@/assets/home/explore1.jpg' import explore2 from '@/assets/home/explore2.jpg' import explore4 from '@/assets/home/explore4.jpg' import explore5 from '@/assets/home/explore5.jpg' const activeTab = ref('visa'); const isVisible = ref(false); const sectionRef = ref(null); const destinations = [ { id: 1, name: '故宫', image: explore1, description: '世界上现存规模最大的古代宫殿建筑群' }, { id: 2, name: '外滩', image: explore2, description: '上海最著名的地标之一,万国建筑博览群' }, { id: 3, name: '橘子洲', image: explore4, description: '湘江中的诗意绿洲,毛泽东笔下的秀丽画卷' }, { id: 4, name: '重庆洪崖洞', image: explore5, description: '山城夜景的璀璨明珠,巴渝文化的精髓' } ]; const setActiveTab = (tab) => { activeTab.value = tab; }; onMounted(() => { const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { isVisible.value = true; observer.disconnect(); } }); }, { threshold: 0.2 }); if (sectionRef.value) { observer.observe(sectionRef.value); } }); </script> <template> <section ref="sectionRef" class="trip-planner-section"> <div class="trip-planner-container"> <h2 class="section-title" :class="{ 'animate': isVisible }">3 steps for the perfect trip</h2> <p class="section-description" :class="{ 'animate': isVisible }"> 只需站稳入旅行偏好,如神秘历史古迹、自然风光,或热爱美食体验,再设定旅行时间、预算等。 AI 智能综合海量数据,精准规划每日行程,游玩景点安排、交通路线与用餐住宿建议。 </p> <div class="trip-tabs" :class="{ 'animate': isVisible }"> <div class="tab-container"> <div class="tab"> <div class="tab-icon">🛂</div> <div class="tab-content"> <h3>政策</h3> <p>Where are you going?</p> </div> </div> <div class="tab"> <div class="tab-icon">📅</div> <div class="tab-content"> <h3>日程</h3> <p>Add Dates</p> </div> </div> <div class="tab"> <div class="tab-icon">🚗</div> <div class="tab-content"> <h3>交通</h3> <p>All Activity</p> </div> </div> <div class="tab"> <div class="tab-icon">👤</div> <div class="tab-content"> <h3>个人</h3> <p>Personal information</p> </div> </div> </div> </div> <div class="destinations-container" :class="{ 'animate': isVisible }"> <div class="destinations-grid"> <div v-for="(destination, index) in destinations" :key="destination.id" class="destination-card" :style="{ animationDelay: `${index * 0.15}s`, backgroundImage: `url(${destination.image})` }" :class="{ 'animate': isVisible }" > <div class="destination-content"> <h3 class="destination-name">{{ destination.name }}</h3> <p class="destination-desc">{{ destination.description }}</p> <button class="destination-btn">查看详情</button> </div> </div> </div> </div> <div class="view-more-container" :class="{ 'animate': isVisible }"> <button class="view-more-btn">查看更多</button> </div> </div> </section> </template> <style scoped> .trip-planner-section { width: 100%; height: 1096px; background-color: #1a1f3d; background-image: url('@/assets/tp-bg.png'); background-size: cover; background-position: center; background-repeat: no-repeat; position: relative; padding: 80px 0; display: flex; justify-content: center; align-items: center; } .trip-planner-container { max-width: 1600px; width: 100%; margin: 0 auto; padding: 0 20px; display: flex; flex-direction: column; align-items: center; } .section-title { font-size: 3rem; color: #00C389; text-align: center; margin-bottom: 40px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease; } .section-title.animate { opacity: 1; transform: translateY(0); } .section-description { max-width: 800px; text-align: center; color: #ffffff; font-size: 1.1rem; line-height: 1.6; margin-bottom: 60px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease 0.2s; } .section-description.animate { opacity: 1; transform: translateY(0); } .trip-tabs { width: 100%; max-width: 1000px; margin-bottom: 80px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease 0.4s; } .trip-tabs.animate { opacity: 1; transform: translateY(0); } .tab-container { display: flex; background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(10px); border-radius: 16px; overflow: hidden; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); } .tab { flex: 1; padding: 24px 20px; text-align: center; cursor: pointer; transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; gap: 12px; position: relative; } .tab:not(:last-child)::after { content: ''; position: absolute; right: 0; top: 20%; height: 60%; width: 1px; background: rgba(255, 255, 255, 0.2); } .tab:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-2px); } .tab-icon { font-size: 24px; opacity: 0.9; } .tab-content { text-align: left; } .tab h3 { font-size: 1.1rem; color: #ffffff; margin-bottom: 4px; font-weight: 500; transition: all 0.3s ease; } .tab p { font-size: 0.85rem; color: rgba(255, 255, 255, 0.8); transition: all 0.3s ease; white-space: nowrap; } .tab:hover h3 { transform: translateY(-1px); } .tab:hover p { color: rgba(255, 255, 255, 0.9); } .destinations-container { width: 100%; margin-bottom: 40px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease 0.6s; } .destinations-container.animate { opacity: 1; transform: translateY(0); } .destinations-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; } .destination-card { background-size: cover; background-position: center; background-repeat: no-repeat; border-radius: 10px; overflow: hidden; position: relative; height: 240px; display: flex; flex-direction: column; justify-content: flex-end; padding: 20px; transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); opacity: 0; transform: translateY(30px); } .destination-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.7)); z-index: 1; } .destination-content { position: relative; z-index: 2; } .destination-desc { color: rgba(255, 255, 255, 0.9); font-size: 0.9rem; margin: 8px 0 15px; line-height: 1.4; } .destination-card.animate { animation: fadeInUp 0.8s forwards; } @keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } } .destination-card:hover { transform: translateY(-5px); box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3); } .destination-name { color: #ffffff; font-size: 1.5rem; margin-bottom: 15px; position: relative; z-index: 1; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); } .destination-btn { background-color: #ffffff; color: #333; border: none; padding: 8px 16px; border-radius: 5px; font-size: 0.9rem; cursor: pointer; width: fit-content; position: relative; z-index: 1; transition: all 0.3s ease; overflow: hidden; } .destination-btn:hover { background-color: #00C389; color: white; transform: translateY(-2px); } .destination-btn:before { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent); transition: left 0.7s ease; } .destination-btn:hover:before { left: 100%; } .view-more-container { margin-top: 40px; opacity: 0; transform: translateY(30px); transition: all 0.8s ease 0.8s; } .view-more-container.animate { opacity: 1; transform: translateY(0); } .view-more-btn { background-color: transparent; color: #ffffff; border: 1px solid #ffffff; padding: 12px 30px; border-radius: 30px; font-size: 1rem; cursor: pointer; transition: all 0.3s ease; position: relative; overflow: hidden; } .view-more-btn:hover { background-color: rgba(255, 255, 255, 0.1); transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); } .view-more-btn:after { content: ''; position: absolute; width: 100%; height: 100%; top: 0; left: -100%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent); transition: left 0.7s ease; } .view-more-btn:hover:after { left: 100%; } /* 响应式样式 */ @media (max-width: 1400px) { .trip-planner-section { height: auto; } .section-title { font-size: 2.5rem; } .destinations-grid { grid-template-columns: repeat(3, 1fr); } } @media (max-width: 992px) { .destinations-grid { grid-template-columns: repeat(2, 1fr); } .section-title { font-size: 2rem; } .section-description { font-size: 1rem; } } @media (max-width: 768px) { .tab { padding: 16px 12px; flex-direction: column; gap: 8px; } .tab-content { text-align: center; } .tab h3 { font-size: 0.9rem; } .tab p { font-size: 0.75rem; } .tab-icon { font-size: 20px; } .destinations-grid { grid-template-columns: 1fr; } .section-title { font-size: 1.8rem; } } @media (max-width: 576px) { .trip-planner-section { padding: 50px 0; } .section-title { font-size: 1.5rem; } .section-description { font-size: 0.9rem; } .tab-container { flex-direction: column; } .tab { flex-direction: row; justify-content: flex-start; padding: 12px 16px; } .tab:not(:last-child)::after { right: 10%; top: auto; bottom: 0; width: 80%; height: 1px; } .tab-content { text-align: left; } } </style>
2302_81331056/travel
src/components/home/TripPlanner.vue
Vue
unknown
10,822
<script setup> import { computed } from 'vue' import { useRouter } from 'vue-router' import { useAuthStore } from '@/stores/auth' const authStore = useAuthStore() const router = useRouter() const isLoggedIn = computed(() => authStore.isLoggedIn) const username = computed(() => authStore.username) // 登出 const handleLogout = () => { authStore.logout() router.push('/login') } </script> <template> <div class="user-status"> <div v-if="isLoggedIn" class="user-status-logged-in"> <span class="welcome">欢迎,{{ username }}</span> <button class="logout-btn" @click="handleLogout">退出登录</button> </div> <div v-else class="user-status-logged-out"> <button class="login-btn" @click="router.push('/login')">登录</button> <button class="register-btn" @click="router.push('/login?register=true')">注册</button> </div> </div> </template> <style scoped> .user-status { display: flex; align-items: center; } .user-status-logged-in, .user-status-logged-out { display: flex; align-items: center; gap: 12px; } .welcome { font-weight: 500; color: #333; } button { padding: 8px 16px; border-radius: 4px; border: none; cursor: pointer; font-size: 14px; transition: all 0.3s ease; } .logout-btn { background-color: #f0f0f0; color: #555; } .logout-btn:hover { background-color: #e0e0e0; } .login-btn { background-color: #00c389; color: white; } .login-btn:hover { background-color: #00b07b; } .register-btn { background-color: #ff5a5a; color: white; } .register-btn:hover { background-color: #ff3939; } </style>
2302_81331056/travel
src/components/home/UserStatus.vue
Vue
unknown
1,615
<template> <section class="payment-guide"> <div class="container"> <!-- 头部区域 --> <div class="guide-header"> <span class="subtitle">{{ $t('payment.subtitle') }}</span> <h2 class="title">{{ $t('payment.title') }}</h2> <p class="description"> {{ $t('payment.description') }} </p> </div> <!-- 支付方式选择 --> <div class="payment-methods"> <div class="method-card" :class="{ active: activeMethod === 'wechat' }" @click="activeMethod = 'wechat'" > <div class="method-icon wechat-icon"> <wechat theme="outline" size="36" fill="#ffffff" /> </div> <h3>{{ $t('payment.wechat.title') }}</h3> <p>{{ $t('payment.wechat.description') }}</p> </div> <div class="method-card" :class="{ active: activeMethod === 'alipay' }" @click="activeMethod = 'alipay'" > <div class="method-icon alipay-icon"> <alipay theme="outline" size="36" fill="#ffffff" /> </div> <h3>{{ $t('payment.alipay.title') }}</h3> <p>{{ $t('payment.alipay.description') }}</p> </div> </div> <!-- 设置步骤 --> <div class="setup-steps"> <div class="steps-header"> <h3>{{ $t('payment.steps.title') }}</h3> <div class="step-progress"> <div v-for="step in totalSteps" :key="step" class="progress-dot" :class="{ active: currentStep >= step }" ></div> </div> </div> <!-- 微信支付设置步骤 --> <div v-if="activeMethod === 'wechat'" class="steps-content"> <div class="step" v-show="currentStep === 1"> <div class="step-number">1</div> <div class="step-content"> <h4>{{ $t('payment.steps.wechat.step1.title') }}</h4> <p>{{ $t('payment.steps.wechat.step1.desc') }}</p> <div class="step-image wechat-download"> <div class="mock-app-store"> <div class="app-icon wechat-color"> <wechat theme="filled" size="40" fill="#ffffff" /> </div> <div class="app-info"> <h5>WeChat</h5> <p>Tencent Inc.</p> <button class="download-btn"> <download-one theme="outline" size="16" :stroke-width="3" /> DOWNLOAD </button> </div> </div> </div> </div> </div> <div class="step" v-show="currentStep === 2"> <div class="step-number">2</div> <div class="step-content"> <h4>{{ $t('payment.steps.wechat.step2.title') }}</h4> <p>{{ $t('payment.steps.wechat.step2.desc') }}</p> <div class="step-image"> <div class="mock-screen wechat-color"> <div class="screen-header"> <div class="header-title">Register</div> </div> <div class="screen-body"> <div class="form-group"> <label> <phone theme="outline" size="16" :stroke-width="3" /> Phone Number </label> <div class="input-control">+1 XXX-XXX-XXXX</div> </div> <div class="form-group"> <button class="action-btn"> <mail theme="outline" size="16" :stroke-width="3" /> Get Verification Code </button> </div> </div> </div> </div> </div> </div> <div class="step" v-show="currentStep === 3"> <div class="step-number">3</div> <div class="step-content"> <h4>{{ $t('payment.steps.wechat.step3.title') }}</h4> <p>{{ $t('payment.steps.wechat.step3.desc') }}</p> <div class="step-image"> <div class="mock-screen wechat-color"> <div class="screen-header"> <div class="header-title">Add Card</div> </div> <div class="screen-body"> <div class="form-group"> <label> <bank-card theme="outline" size="16" :stroke-width="3" /> Card Number </label> <div class="input-control">XXXX XXXX XXXX XXXX</div> </div> <div class="form-group"> <label> <calendar theme="outline" size="16" :stroke-width="3" /> Expiry Date </label> <div class="input-control">MM/YY</div> </div> <div class="form-group"> <label> <lock theme="outline" size="16" :stroke-width="3" /> CVV </label> <div class="input-control">XXX</div> </div> <div class="form-group"> <button class="action-btn"> <add theme="outline" size="16" :stroke-width="3" /> Add Card </button> </div> </div> </div> </div> </div> </div> <div class="step" v-show="currentStep === 4"> <div class="step-number">4</div> <div class="step-content"> <h4>{{ $t('payment.steps.wechat.step4.title') }}</h4> <p>{{ $t('payment.steps.wechat.step4.desc') }}</p> <div class="step-image"> <div class="mock-screen wechat-color"> <div class="screen-header"> <div class="header-title">Identity Verification</div> </div> <div class="screen-body"> <div class="form-group"> <label> <user theme="outline" size="16" :stroke-width="3" /> Full Name </label> <div class="input-control">John Doe</div> </div> <div class="form-group"> <label> <id-card theme="outline" size="16" :stroke-width="3" /> ID Type </label> <div class="input-control">Passport</div> </div> <div class="form-group"> <label> <id-card theme="outline" size="16" :stroke-width="3" /> ID Number </label> <div class="input-control">XXXXXXXXX</div> </div> <div class="form-group"> <button class="action-btn"> <check theme="outline" size="16" :stroke-width="3" /> Verify </button> </div> </div> </div> </div> </div> </div> </div> <!-- 支付宝设置步骤 --> <div v-else class="steps-content"> <div class="step" v-show="currentStep === 1"> <div class="step-number">1</div> <div class="step-content"> <h4>{{ $t('payment.steps.alipay.step1.title') }}</h4> <p>{{ $t('payment.steps.alipay.step1.desc') }}</p> <div class="step-image"> <div class="mock-app-store"> <div class="app-icon alipay-color"> <alipay theme="filled" size="40" fill="#ffffff" /> </div> <div class="app-info"> <h5>Alipay</h5> <p>Ant Financial Services</p> <button class="download-btn"> <download-one theme="outline" size="16" :stroke-width="3" /> DOWNLOAD </button> </div> </div> </div> </div> </div> <div class="step" v-show="currentStep === 2"> <div class="step-number">2</div> <div class="step-content"> <h4>{{ $t('payment.steps.alipay.step2.title') }}</h4> <p>{{ $t('payment.steps.alipay.step2.desc') }}</p> <div class="step-image"> <div class="mock-screen alipay-color"> <div class="screen-header"> <div class="header-title">Register</div> </div> <div class="screen-body"> <div class="form-group"> <label> <phone theme="outline" size="16" :stroke-width="3" /> Phone Number </label> <div class="input-control">+1 XXX-XXX-XXXX</div> </div> <div class="form-group"> <button class="action-btn"> <mail theme="outline" size="16" :stroke-width="3" /> Get Verification Code </button> </div> </div> </div> </div> </div> </div> <div class="step" v-show="currentStep === 3"> <div class="step-number">3</div> <div class="step-content"> <h4>{{ $t('payment.steps.alipay.step3.title') }}</h4> <p>{{ $t('payment.steps.alipay.step3.desc') }}</p> <div class="step-image"> <div class="mock-screen alipay-color"> <div class="screen-header"> <div class="header-title">Add Card</div> </div> <div class="screen-body"> <div class="form-group"> <label> <bank-card theme="outline" size="16" :stroke-width="3" /> Card Number </label> <div class="input-control">XXXX XXXX XXXX XXXX</div> </div> <div class="form-group"> <label> <calendar theme="outline" size="16" :stroke-width="3" /> Expiry Date </label> <div class="input-control">MM/YY</div> </div> <div class="form-group"> <label> <lock theme="outline" size="16" :stroke-width="3" /> CVV </label> <div class="input-control">XXX</div> </div> <div class="form-group"> <button class="action-btn"> <add theme="outline" size="16" :stroke-width="3" /> Add Card </button> </div> </div> </div> </div> </div> </div> <div class="step" v-show="currentStep === 4"> <div class="step-number">4</div> <div class="step-content"> <h4>{{ $t('payment.steps.alipay.step4.title') }}</h4> <p>{{ $t('payment.steps.alipay.step4.desc') }}</p> <div class="step-image"> <div class="mock-screen alipay-color"> <div class="screen-header"> <div class="header-title">Identity Verification</div> </div> <div class="screen-body"> <div class="form-group"> <label> <user theme="outline" size="16" :stroke-width="3" /> Full Name </label> <div class="input-control">John Doe</div> </div> <div class="form-group"> <label> <id-card theme="outline" size="16" :stroke-width="3" /> ID Type </label> <div class="input-control">Passport</div> </div> <div class="form-group"> <label> <id-card theme="outline" size="16" :stroke-width="3" /> ID Number </label> <div class="input-control">XXXXXXXXX</div> </div> <div class="form-group"> <button class="action-btn"> <check theme="outline" size="16" :stroke-width="3" /> Verify </button> </div> </div> </div> </div> </div> </div> </div> <!-- 步骤控制按钮 --> <div class="step-controls"> <button class="step-btn prev" @click="prevStep" :disabled="currentStep === 1" > <left theme="outline" size="16" :stroke-width="3" /> {{ $t('payment.steps.prev') }} </button> <button class="step-btn next" @click="nextStep" :disabled="currentStep === totalSteps" > {{ $t('payment.steps.next') }} <right theme="outline" size="16" :stroke-width="3" /> </button> </div> </div> <!-- 使用提示 --> <div class="usage-tips"> <h3>{{ $t('payment.tips.title') }}</h3> <div class="tips-grid"> <div class="tip-card"> <div class="tip-icon"> <bank-card theme="filled" size="36" fill="#00c389" /> </div> <h4>{{ $t('payment.tips.cards.title') }}</h4> <p>{{ $t('payment.tips.cards.desc') }}</p> </div> <div class="tip-card"> <div class="tip-icon"> <shield theme="filled" size="36" fill="#00c389" /> </div> <h4>{{ $t('payment.tips.security.title') }}</h4> <p>{{ $t('payment.tips.security.desc') }}</p> </div> <div class="tip-card"> <div class="tip-icon"> <exchange theme="filled" size="36" fill="#00c389" /> </div> <h4>{{ $t('payment.tips.exchange.title') }}</h4> <p>{{ $t('payment.tips.exchange.desc') }}</p> </div> <div class="tip-card"> <div class="tip-icon"> <wallet theme="filled" size="36" fill="#00c389" /> </div> <h4>{{ $t('payment.tips.offline.title') }}</h4> <p>{{ $t('payment.tips.offline.desc') }}</p> </div> </div> </div> <!-- 常见问题 --> <div class="faq-section"> <h3>{{ $t('payment.faq.title') }}</h3> <div class="faq-list"> <div v-for="(faq, index) in faqs" :key="index" class="faq-item" :class="{ active: activeFaq === index }" @click="toggleFaq(index)" > <div class="faq-question"> <h4> <help theme="outline" size="18" :stroke-width="3" class="faq-icon" /> {{ faq.question }} </h4> <span class="toggle-icon">{{ activeFaq === index ? '−' : '+' }}</span> </div> <div class="faq-answer" v-show="activeFaq === index"> <p>{{ faq.answer }}</p> </div> </div> </div> </div> </div> </section> </template> <script setup> import { ref } from 'vue'; import { useI18n } from 'vue-i18n'; import { Wechat, Alipay, DownloadOne, Phone, Mail, BankCard, Calendar, Lock, Add, User, IdCard, Check, Left, Right, Exchange, Shield, Wallet, Help } from '@icon-park/vue-next'; const { t } = useI18n(); // 支付方式选择 const activeMethod = ref('wechat'); // 步骤控制 const currentStep = ref(1); const totalSteps = 4; const nextStep = () => { if (currentStep.value < totalSteps) { currentStep.value++; } }; const prevStep = () => { if (currentStep.value > 1) { currentStep.value--; } }; // FAQ控制 const activeFaq = ref(null); const toggleFaq = (index) => { activeFaq.value = activeFaq.value === index ? null : index; }; // FAQ数据 const faqs = ref([ { question: t('payment.faq.q1.question'), answer: t('payment.faq.q1.answer') }, { question: t('payment.faq.q2.question'), answer: t('payment.faq.q2.answer') }, { question: t('payment.faq.q3.question'), answer: t('payment.faq.q3.answer') }, { question: t('payment.faq.q4.question'), answer: t('payment.faq.q4.answer') } ]); </script> <style scoped> .payment-guide { padding: 80px 0; background-color: #f8fafc; } .container { max-width: 1200px; margin: 0 auto; padding: 0 20px; } /* 头部样式 */ .guide-header { text-align: center; margin-bottom: 60px; opacity: 0; transform: translateY(20px); animation: fadeInUp 0.8s forwards; } @keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } .subtitle { font-size: 1.2rem; color: #00c389; font-weight: 600; display: block; margin-bottom: 16px; } .title { font-size: 2.5rem; color: #1e293b; margin-bottom: 20px; } .description { max-width: 800px; margin: 0 auto; color: #64748b; font-size: 1.1rem; line-height: 1.6; } /* 支付方式选择 */ .payment-methods { display: flex; justify-content: center; gap: 30px; margin-bottom: 60px; opacity: 0; animation: fadeIn 0.8s 0.3s forwards; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } .method-card { flex: 1; max-width: 400px; padding: 30px; background: white; border-radius: 12px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); cursor: pointer; transition: all 0.3s; text-align: center; } .method-card:hover { transform: translateY(-5px); box-shadow: 0 8px 12px rgba(0, 0, 0, 0.1); } .method-card.active { border: 2px solid #00c389; background-color: #f0fdf4; } .method-icon { width: 80px; height: 80px; margin: 0 auto 20px; border-radius: 16px; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; } .wechat-icon { background-color: #07C160; } .alipay-icon { background-color: #00A0E9; } .method-card h3 { font-size: 1.5rem; color: #1e293b; margin-bottom: 10px; } .method-card p { color: #64748b; font-size: 1rem; } /* 设置步骤 */ .setup-steps { background: white; border-radius: 12px; padding: 40px; margin-bottom: 60px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); opacity: 0; animation: fadeIn 0.8s 0.6s forwards; } .steps-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; } .steps-header h3 { font-size: 1.5rem; color: #1e293b; } .step-progress { display: flex; gap: 8px; } .progress-dot { width: 12px; height: 12px; border-radius: 50%; background-color: #e2e8f0; transition: all 0.3s; } .progress-dot.active { background-color: #00c389; } .step { display: flex; gap: 30px; align-items: flex-start; } .step-number { width: 40px; height: 40px; background-color: #00c389; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; font-weight: 600; flex-shrink: 0; } .step-content { flex: 1; } .step-content h4 { font-size: 1.3rem; color: #1e293b; margin-bottom: 16px; } .step-content p { color: #64748b; margin-bottom: 20px; line-height: 1.6; } .step-image { width: 100%; max-width: 500px; margin: 0 auto; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); border-radius: 8px; overflow: hidden; } /* 模拟App Store页面 */ .mock-app-store { background: white; display: flex; padding: 20px; border-radius: 8px; } .app-icon { width: 80px; height: 80px; border-radius: 16px; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; margin-right: 20px; font-size: 0.9rem; flex-shrink: 0; } .wechat-color { background-color: #07C160; } .alipay-color { background-color: #00A0E9; } .app-info { flex: 1; } .app-info h5 { margin: 0 0 5px; font-size: 1.1rem; color: #1e293b; } .app-info p { margin: 0 0 10px; color: #64748b; font-size: 0.9rem; } .download-btn { background: #f1f5f9; border: none; padding: 8px 16px; border-radius: 16px; font-weight: bold; color: #1e293b; cursor: pointer; display: flex; align-items: center; gap: 5px; } /* 模拟手机屏幕 */ .mock-screen { border-radius: 8px; overflow: hidden; } .screen-header { height: 50px; color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; } .screen-body { background: white; padding: 20px; } .form-group { margin-bottom: 15px; } .form-group label { display: flex; align-items: center; gap: 5px; font-size: 0.9rem; color: #64748b; margin-bottom: 5px; } .input-control { background: #f1f5f9; padding: 10px 15px; border-radius: 6px; color: #1e293b; font-size: 0.9rem; } .action-btn { width: 100%; padding: 12px; background: #00c389; color: white; border: none; border-radius: 6px; font-weight: bold; margin-top: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; } .step-controls { display: flex; justify-content: center; gap: 20px; margin-top: 40px; } .step-btn { display: flex; align-items: center; gap: 6px; padding: 12px 30px; border-radius: 6px; font-size: 1rem; font-weight: 500; cursor: pointer; transition: all 0.3s; } .step-btn.prev { background-color: #f1f5f9; color: #64748b; border: none; } .step-btn.next { background-color: #00c389; color: white; border: none; } .step-btn:disabled { opacity: 0.5; cursor: not-allowed; } /* 使用提示 */ .usage-tips { margin-bottom: 60px; opacity: 0; animation: fadeIn 0.8s 0.9s forwards; } .usage-tips h3 { text-align: center; font-size: 1.5rem; color: #1e293b; margin-bottom: 40px; } .tips-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 30px; } .tip-card { background: white; padding: 30px; border-radius: 12px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); text-align: center; transition: all 0.3s ease; } .tip-card:hover { transform: translateY(-10px); box-shadow: 0 12px 20px rgba(0, 0, 0, 0.1); } .tip-icon { font-size: 2.5rem; margin-bottom: 20px; display: flex; justify-content: center; transition: all 0.3s ease; } .tip-card:hover .tip-icon { transform: scale(1.2); } .tip-card h4 { font-size: 1.2rem; color: #1e293b; margin-bottom: 12px; } .tip-card p { color: #64748b; line-height: 1.6; } /* FAQ部分 */ .faq-section { background: white; border-radius: 12px; padding: 40px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); opacity: 0; animation: fadeIn 0.8s 1.2s forwards; } .faq-section h3 { text-align: center; font-size: 1.5rem; color: #1e293b; margin-bottom: 40px; } .faq-list { max-width: 800px; margin: 0 auto; } .faq-item { border-bottom: 1px solid #e2e8f0; transition: all 0.3s ease; } .faq-item.active { background-color: #f8fafc; padding: 0 15px; margin: 0 -15px; border-radius: 8px; } .faq-question { padding: 20px 0; display: flex; justify-content: space-between; align-items: center; cursor: pointer; } .faq-question h4 { font-size: 1.1rem; color: #1e293b; margin: 0; display: flex; align-items: center; gap: 8px; transition: all 0.3s ease; } .faq-item:hover .faq-question h4 { color: #00c389; } .faq-icon { color: #00c389; transition: all 0.3s ease; } .toggle-icon { font-size: 1.5rem; color: #64748b; transition: all 0.3s ease; } .faq-item.active .faq-icon { transform: rotate(360deg); } .faq-answer { padding: 0 0 20px; max-height: 0; overflow: hidden; opacity: 0; transition: all 0.3s ease; } .faq-item.active .faq-answer { max-height: 300px; opacity: 1; padding: 10px 0 20px; } .faq-answer p { color: #64748b; line-height: 1.6; margin: 0; padding-left: 28px; } /* 响应式设计 */ @media (max-width: 768px) { .payment-methods { flex-direction: column; align-items: center; } .method-card { width: 100%; max-width: 100%; } .step { flex-direction: column; align-items: center; text-align: center; } .step-number { margin-bottom: 20px; } .tips-grid { grid-template-columns: 1fr; } } @media (max-width: 576px) { .title { font-size: 2rem; } .description { font-size: 1rem; } .setup-steps, .faq-section { padding: 20px; } .step-image { max-width: 100%; } } </style>
2302_81331056/travel
src/components/payment/PaymentGuide.vue
Vue
unknown
25,918
<script setup> defineProps({ type: { type: String, required: true, validator: (value) => ['success', 'error'].includes(value) }, message: { type: String, required: true }, show: { type: Boolean, default: false } }); </script> <template> <transition name="fade"> <div v-if="show" :class="['alert-message', type]"> <i :class="type === 'success' ? 'fas fa-check-circle' : 'fas fa-exclamation-circle'"></i> {{ message }} </div> </transition> </template> <style scoped> .alert-message { padding: 15px; border-radius: 8px; margin-bottom: 20px; display: flex; align-items: center; animation: fadeIn 0.3s ease-out forwards; } .alert-message.success { background-color: #e6f7ef; color: #00b07b; } .alert-message.error { background-color: #feeae9; color: #f44336; } .alert-message i { font-size: 1.2rem; margin-right: 10px; } .fade-enter-active, .fade-leave-active { transition: opacity 0.3s ease; } .fade-enter-from, .fade-leave-to { opacity: 0; } </style>
2302_81331056/travel
src/components/profile/AlertMessage.vue
Vue
unknown
1,047
<template> <!-- 这是一个无渲染组件,只用于提供全局样式 --> </template> <style> /* 重置基本样式,确保组件样式不被覆盖 */ .profile-container * { box-sizing: border-box; margin: 0; padding: 0; } /* 提高所有个人信息页组件的基本样式优先级 */ .profile-content .profile-sidebar, .profile-content .profile-form, .profile-form .form-section, .profile-form .form-group, .profile-form .form-actions { display: block !important; } /* 确保按钮样式 */ .profile-form button, .profile-sidebar button { cursor: pointer; outline: none; font-family: inherit; } /* 表单控件基础样式 */ .profile-form input, .profile-form select { box-sizing: border-box; font-family: inherit; font-size: 1rem; } /* 确保动画正常工作 */ @keyframes profileFadeIn { from { opacity: 0; } to { opacity: 1; } } /* 防止样式冲突 */ .profile-sidebar .menu-item, .profile-form .form-group, .profile-form .form-section { clear: both; } /* 强制使用正确的图标字体 */ .profile-container .fas { font-family: 'Font Awesome 6 Free' !important; font-weight: 900 !important; } </style>
2302_81331056/travel
src/components/profile/GlobalStyles.vue
Vue
unknown
1,161
<script setup> import { ref } from 'vue'; const notificationSettings = ref({ email: true, sms: false, push: true }); const handleSaveSettings = () => { // 这里实现通知设置保存逻辑 console.log('保存通知设置:', notificationSettings.value); // 实际项目中应该调用API }; </script> <template> <div class="form-section"> <h2 class="section-title">通知设置</h2> <div class="notification-item"> <div class="notification-info"> <h3>电子邮件通知</h3> <p>接收重要更新、订单确认和促销信息</p> </div> <div class="toggle-switch"> <input type="checkbox" id="toggle-email" v-model="notificationSettings.email"> <label for="toggle-email"></label> </div> </div> <div class="notification-item"> <div class="notification-info"> <h3>短信通知</h3> <p>接收旅行提醒和重要更新</p> </div> <div class="toggle-switch"> <input type="checkbox" id="toggle-sms" v-model="notificationSettings.sms"> <label for="toggle-sms"></label> </div> </div> <div class="notification-item"> <div class="notification-info"> <h3>应用推送</h3> <p>接收应用内推送通知</p> </div> <div class="toggle-switch"> <input type="checkbox" id="toggle-push" v-model="notificationSettings.push"> <label for="toggle-push"></label> </div> </div> <div class="form-actions"> <button class="save-btn" @click="handleSaveSettings">保存设置</button> </div> </div> </template> <style scoped> .form-section { animation: slideIn 0.6s ease-out forwards; opacity: 0.1; } @keyframes slideIn { 0% { opacity: 0.1; transform: translateX(20px); } 100% { opacity: 1; transform: translateX(0); } } .section-title { font-size: 1.4rem; color: #333; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid #eee; } .notification-item { display: flex; justify-content: space-between; align-items: center; padding: 20px; background-color: #f8f9fa; border-radius: 8px; margin-bottom: 15px; transition: all 0.3s ease; } .notification-item:hover { background-color: #f0f9f6; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); } .notification-info h3 { font-size: 1.1rem; color: #333; margin-bottom: 5px; } .notification-info p { font-size: 0.9rem; color: #666; } .toggle-switch { position: relative; width: 50px; height: 24px; } .toggle-switch input { opacity: 0; width: 0; height: 0; } .toggle-switch label { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ddd; border-radius: 24px; cursor: pointer; transition: 0.4s; } .toggle-switch label:before { position: absolute; content: ""; height: 16px; width: 16px; left: 4px; bottom: 4px; background-color: white; border-radius: 50%; transition: 0.4s; } .toggle-switch input:checked + label { background-color: #00c389; } .toggle-switch input:checked + label:before { transform: translateX(26px); } .form-actions { display: flex; gap: 15px; margin-top: 30px; animation: fadeUp 0.8s ease-out forwards; animation-delay: 0.4s; opacity: 0.1; } @keyframes fadeUp { 0% { opacity: 0.1; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } } .save-btn { padding: 12px 30px; background-color: #00c389; color: white; border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.3s ease; } .save-btn:hover { background-color: #00b07b; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 195, 137, 0.3); } </style>
2302_81331056/travel
src/components/profile/NotificationSettings.vue
Vue
unknown
3,810
<script setup> import { defineProps, defineEmits, ref, onMounted } from 'vue'; import { getUserProfile } from '@/api/user'; const props = defineProps({ formData: { type: Object, required: true } }); // 添加加载状态 const isLoading = ref(false); const isLoaded = ref(false); console.log(props.formData) const emit = defineEmits(['update:formData', 'save', 'reset']); // 控制确认对话框显示 const showConfirmDialog = ref(false); // 处理保存 const handleSave = () => { // 显示确认对话框 showConfirmDialog.value = true; }; // 确认保存后提交 const confirmSave = () => { showConfirmDialog.value = false; emit('save'); }; // 取消保存 const cancelSave = () => { showConfirmDialog.value = false; }; const handleReset = () => { emit('reset'); }; // 在onMounted函数中处理API返回的数据 onMounted(async () => { isLoading.value = true; try { // 调用API获取用户信息 const response = await getUserProfile(); console.log('获取用户信息响应:', response); // 处理API返回的数据 if (response.data && response.data.code === 200) { const userData = response.data.data; // 创建新的formData对象,而不是直接修改props const updatedFormData = { ...props.formData, username: userData.username || props.formData.username || '', lastName: userData.lastName || props.formData.lastName || '', firstName: userData.firstName || props.formData.firstName || '', email: userData.email || props.formData.email || '', phone: userData.phone || props.formData.phone || '', nationality: userData.nationality || props.formData.nationality || '', gender: userData.gender || props.formData.gender || '', // 注意:后端返回的是preferredLanguage,而不是language language: userData.preferredLanguage || props.formData.language || 'zh' }; // 通过emit事件更新父组件中的formData emit('update:formData', updatedFormData); console.log('表单数据已更新:', updatedFormData); } else { console.warn('获取用户信息失败:', response.data?.message); } } catch (error) { console.error('获取用户信息出错:', error); } finally { isLoading.value = false; // 设置页面加载状态,触发动画 setTimeout(() => { isLoaded.value = true; }, 300); } }); </script> <template> <div class="form-section"> <h2 class="section-title">基本信息</h2> <div class="form-group"> <label>用户名 <span class="required">*</span></label> <input type="text" v-model="formData.username" placeholder="请输入用户名" @input="$emit('update:formData', {...formData, username: $event.target.value})" > </div> <div class="form-row"> <div class="form-group"> <label>姓氏</label> <input type="text" v-model="formData.lastName" placeholder="请输入姓氏" @input="$emit('update:formData', {...formData, lastName: $event.target.value})" > </div> <div class="form-group"> <label>名字</label> <input type="text" v-model="formData.firstName" placeholder="请输入名字" @input="$emit('update:formData', {...formData, firstName: $event.target.value})" > </div> </div> <div class="form-row"> <div class="form-group"> <label>国籍</label> <select v-model="formData.nationality" @change="$emit('update:formData', {...formData, nationality: $event.target.value})" > <option value="">请选择国籍</option> <option value="china">中国</option> <option value="usa">美国</option> <option value="uk">英国</option> <option value="japan">日本</option> <option value="korea">韩国</option> <option value="other">其他</option> </select> </div> <div class="form-group"> <label>性别</label> <select v-model="formData.gender" @change="$emit('update:formData', {...formData, gender: $event.target.value})" > <option value="">请选择性别</option> <option value="male">男</option> <option value="female">女</option> <option value="other">其他</option> <option value="private">不愿透露</option> </select> </div> </div> <div class="form-group"> <label>电子邮箱</label> <input type="email" v-model="formData.email" placeholder="请输入电子邮箱" @input="$emit('update:formData', {...formData, email: $event.target.value})" > </div> <div class="form-group"> <label>手机号码</label> <input type="tel" v-model="formData.phone" placeholder="请输入手机号码" @input="$emit('update:formData', {...formData, phone: $event.target.value})" > </div> </div> <div class="form-section"> <h2 class="section-title">个人偏好</h2> <div class="form-group"> <label>语言偏好</label> <select v-model="formData.language" @change="$emit('update:formData', {...formData, language: $event.target.value})" > <option value="zh">中文</option> <option value="en">英文</option> </select> </div> </div> <div class="form-actions"> <button class="save-btn" @click="handleSave">保存更改</button> <button class="cancel-btn" @click="handleReset">重置</button> </div> <!-- 确认对话框 --> <div v-if="showConfirmDialog" class="confirm-dialog-overlay"> <div class="confirm-dialog"> <h3>确认保存</h3> <p>您确定要保存个人信息的更改吗?</p> <div class="confirm-actions"> <button class="confirm-btn" @click="confirmSave">确认</button> <button class="cancel-btn" @click="cancelSave">取消</button> </div> </div> </div> </template> <style scoped> .form-section { margin-bottom: 30px; animation: slideIn 0.6s ease-out forwards; opacity: 0.1; } .form-section:nth-child(1) { animation-delay: 0.2s; } .form-section:nth-child(2) { animation-delay: 0.4s; } @keyframes slideIn { 0% { opacity: 0.1; transform: translateX(20px); } 100% { opacity: 1; transform: translateX(0); } } .section-title { font-size: 1.4rem; color: #333; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid #eee; } .form-group { margin-bottom: 20px; } .form-row { display: flex; gap: 20px; } .form-row .form-group { flex: 1; } label { display: block; font-size: 0.95rem; color: #555; margin-bottom: 8px; } .required { color: #ff5a5a; margin-left: 4px; } input, select { width: 100%; height: 46px; padding: 0 15px; border: 1px solid #ddd; border-radius: 8px; font-size: 1rem; transition: border-color 0.3s, box-shadow 0.3s; } input:focus, select:focus { border-color: #00c389; box-shadow: 0 0 0 2px rgba(0, 195, 137, 0.2); outline: none; } .form-actions { display: flex; gap: 15px; margin-top: 30px; animation: fadeUp 0.8s ease-out forwards; animation-delay: 0.6s; opacity: 0.1; } @keyframes fadeUp { 0% { opacity: 0.1; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } } .save-btn { padding: 12px 30px; background-color: #00c389; color: white; border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.3s ease; } .save-btn:hover { background-color: #00b07b; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 195, 137, 0.3); } .cancel-btn { padding: 12px 30px; background-color: #f8f9fa; color: #555; border: 1px solid #ddd; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.3s ease; } .cancel-btn:hover { background-color: #f0f0f0; } /* 确认对话框样式 */ .confirm-dialog-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; } .confirm-dialog { background-color: white; border-radius: 10px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15); padding: 25px; width: 350px; animation: dialogFadeIn 0.3s ease-out; } @keyframes dialogFadeIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } } .confirm-dialog h3 { font-size: 1.3rem; margin-bottom: 15px; color: #333; } .confirm-dialog p { margin-bottom: 20px; color: #555; line-height: 1.5; } .confirm-actions { display: flex; justify-content: flex-end; gap: 10px; } .confirm-btn { padding: 8px 16px; background-color: #00c389; color: white; border: none; border-radius: 6px; cursor: pointer; transition: all 0.2s ease; } .confirm-btn:hover { background-color: #00b07b; } @media (max-width: 768px) { .form-row { flex-direction: column; gap: 0; } .confirm-dialog { width: 90%; max-width: 350px; } } </style>
2302_81331056/travel
src/components/profile/ProfileForm.vue
Vue
unknown
9,432
<script setup> import { defineProps, defineEmits } from 'vue'; const props = defineProps({ activeSection: { type: String, required: true }, avatar: { type: String, default: '' } }); const emit = defineEmits(['update:activeSection', 'avatar-upload']); const setActiveSection = (section) => { emit('update:activeSection', section); }; const handleAvatarUpload = () => { emit('avatar-upload'); }; </script> <template> <div class="profile-sidebar"> <div class="profile-avatar"> <div class="avatar-icon" v-if="avatar" :style="{ backgroundImage: `url(${avatar})` }"> </div> <div class="avatar-icon" v-else> <i class="fas fa-user"></i> </div> <button class="change-avatar-btn" @click="handleAvatarUpload">更换头像</button> </div> <div class="profile-menu"> <div class="menu-item" :class="{ 'active': activeSection === 'profile' }" @click="setActiveSection('profile')" > <i class="fas fa-user"></i> <span>个人资料</span> </div> <div class="menu-item" :class="{ 'active': activeSection === 'security' }" @click="setActiveSection('security')" > <i class="fas fa-shield-alt"></i> <span>账户安全</span> </div> <div class="menu-item" :class="{ 'active': activeSection === 'notifications' }" @click="setActiveSection('notifications')" > <i class="fas fa-bell"></i> <span>通知设置</span> </div> </div> </div> </template> <style scoped> .profile-sidebar { width: 280px; background-color: #f8f9fa; padding: 30px 0; border-right: 1px solid #eee; } .profile-avatar { display: flex; flex-direction: column; align-items: center; margin-bottom: 30px; padding: 0 20px; } .avatar-icon { width: 120px; height: 120px; border-radius: 50%; background-color: #e0e0e0; display: flex; align-items: center; justify-content: center; margin-bottom: 15px; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1); border: 3px solid #ffffff; transition: all 0.3s ease; background-size: cover; background-position: center; } .avatar-icon i { font-size: 60px; color: #999999; } .avatar-icon:hover { transform: scale(1.05); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15); } .change-avatar-btn { padding: 8px 16px; border: none; background-color: #fff; color: #00c389; border-radius: 20px; font-size: 0.9rem; cursor: pointer; transition: all 0.3s ease; border: 1px solid #00c389; } .change-avatar-btn:hover { background-color: #00c389; color: #fff; } .profile-menu { display: flex; flex-direction: column; } .menu-item { display: flex; align-items: center; padding: 15px 30px; cursor: pointer; transition: all 0.3s ease; position: relative; color: #555; } .menu-item:hover, .menu-item.active { background-color: #f0f9f6; color: #00c389; } .menu-item.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background-color: #00c389; } .menu-item i { margin-right: 15px; font-size: 1.1rem; width: 20px; text-align: center; } @media (max-width: 992px) { .profile-sidebar { width: 100%; border-right: none; border-bottom: 1px solid #eee; padding: 20px; } .profile-menu { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 10px; } .menu-item { padding: 10px 15px; border-radius: 8px; } .menu-item.active::before { display: none; } .menu-item.active { background-color: #00c389; color: white; } } </style>
2302_81331056/travel
src/components/profile/ProfileSidebar.vue
Vue
unknown
3,700
<script setup> import { ref } from 'vue'; const formData = ref({ currentPassword: '', newPassword: '', confirmPassword: '' }); const handleSavePassword = () => { // 这里实现密码修改逻辑 console.log('密码修改请求:', formData.value); // 实际项目中应该调用API }; const handleCancel = () => { formData.value = { currentPassword: '', newPassword: '', confirmPassword: '' }; }; </script> <template> <div class="form-section"> <h2 class="section-title">账户安全</h2> <div class="form-group"> <label>当前密码</label> <input type="password" placeholder="请输入当前密码" v-model="formData.currentPassword"> </div> <div class="form-group"> <label>新密码</label> <input type="password" placeholder="请输入新密码" v-model="formData.newPassword"> <div class="hint">密码至少包含8个字符,建议使用字母、数字和特殊字符的组合</div> </div> <div class="form-group"> <label>确认密码</label> <input type="password" placeholder="请再次输入新密码" v-model="formData.confirmPassword"> </div> <div class="form-actions"> <button class="save-btn" @click="handleSavePassword">修改密码</button> <button class="cancel-btn" @click="handleCancel">取消</button> </div> </div> </template> <style scoped> .form-section { animation: slideIn 0.6s ease-out forwards; opacity: 0.1; } @keyframes slideIn { 0% { opacity: 0.1; transform: translateX(20px); } 100% { opacity: 1; transform: translateX(0); } } .section-title { font-size: 1.4rem; color: #333; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid #eee; } .form-group { margin-bottom: 20px; } label { display: block; font-size: 0.95rem; color: #555; margin-bottom: 8px; } .hint { font-size: 0.85rem; color: #888; margin-top: 8px; } input { width: 100%; height: 46px; padding: 0 15px; border: 1px solid #ddd; border-radius: 8px; font-size: 1rem; transition: border-color 0.3s, box-shadow 0.3s; } input:focus { border-color: #00c389; box-shadow: 0 0 0 2px rgba(0, 195, 137, 0.2); outline: none; } .form-actions { display: flex; gap: 15px; margin-top: 30px; animation: fadeUp 0.8s ease-out forwards; animation-delay: 0.4s; opacity: 0.1; } @keyframes fadeUp { 0% { opacity: 0.1; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } } .save-btn { padding: 12px 30px; background-color: #00c389; color: white; border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.3s ease; } .save-btn:hover { background-color: #00b07b; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 195, 137, 0.3); } .cancel-btn { padding: 12px 30px; background-color: #f8f9fa; color: #555; border: 1px solid #ddd; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.3s ease; } .cancel-btn:hover { background-color: #f0f0f0; } </style>
2302_81331056/travel
src/components/profile/SecurityForm.vue
Vue
unknown
3,125
<template> <div class="travel-chat"> <div class="chat-header"> <h3>智能旅行助手</h3> <button class="save-chat-btn" @click="openSaveDialog"> <i class="fas fa-save"></i> 保存行程 </button> </div> <div class="chat-messages" ref="messageContainer"> <div v-for="(message, index) in messages" :key="index" class="message" :class="message.isUser ? 'user-message' : 'ai-message'"> <div class="message-content">{{ message.content }}</div> </div> <div v-if="isLoading" class="message ai-message"> <div class="message-content loading"> <span></span> <span></span> <span></span> </div> </div> </div> <div class="chat-input"> <input type="text" v-model="userInput" placeholder="输入您想了解的旅行信息..." @keyup.enter="sendMessage" /> <button @click="sendMessage" :disabled="isLoading || !userInput.trim()">发送</button> </div> <!-- 保存对话框 --> <div class="modal-overlay" v-if="showSaveDialog" @click="closeSaveDialog"> <div class="save-dialog" @click.stop> <h3>保存您的旅行计划</h3> <div class="form-group"> <label for="trip-title">旅行主题</label> <input type="text" id="trip-title" v-model="tripData.title" placeholder="例如:北京五日游" /> </div> <div class="form-group"> <label for="trip-requirements">旅行需求</label> <textarea id="trip-requirements" v-model="tripData.requirements" placeholder="描述您的具体需求,如预算、喜好等..." rows="3" ></textarea> </div> <div class="date-row"> <div class="form-group"> <label for="start-date">开始日期</label> <input type="date" id="start-date" v-model="tripData.startDate" /> </div> <div class="form-group"> <label for="end-date">结束日期</label> <input type="date" id="end-date" v-model="tripData.endDate" /> </div> </div> <div class="dialog-buttons"> <button class="cancel-btn" @click="closeSaveDialog">取消</button> <button class="save-btn" @click="saveTripData" :disabled="!isTripDataValid">保存</button> </div> </div> </div> </div> </template> <script setup> import { ref, reactive, onMounted, nextTick, watch, computed } from 'vue'; import { sendChatMessage, processStreamResponse } from '@/api/chat'; // 聊天消息数组 const messages = ref([ { content: "您好!我是您的旅行助手。请告诉我您想去哪里旅行,我可以为您提供路线规划和建议。", isUser: false } ]); // 用户输入 const userInput = ref(''); // 加载状态 const isLoading = ref(false); // 消息容器,用于自动滚动 const messageContainer = ref(null); // 当前会话ID const sessionId = ref(''); // 流式处理的临时消息存储 const currentStreamMessage = ref(''); // 保存对话框状态 const showSaveDialog = ref(false); // 旅行数据 const tripData = reactive({ title: '', requirements: '', startDate: '', endDate: '', chatHistory: [] }); // 验证旅行数据是否有效 const isTripDataValid = computed(() => { return tripData.title.trim() !== '' && tripData.startDate !== '' && tripData.endDate !== ''; }); // 打开保存对话框 const openSaveDialog = () => { // 将当前聊天记录复制到tripData tripData.chatHistory = [...messages.value]; // 设置默认日期(如果未设置) if (!tripData.startDate) { const today = new Date(); tripData.startDate = today.toISOString().split('T')[0]; // 默认结束日期为7天后 const endDate = new Date(); endDate.setDate(today.getDate() + 7); tripData.endDate = endDate.toISOString().split('T')[0]; } showSaveDialog.value = true; }; // 关闭保存对话框 const closeSaveDialog = () => { showSaveDialog.value = false; }; // 保存旅行数据 const saveTripData = () => { // 实际应该发送到后端保存 console.log('保存旅行数据:', tripData); // 创建一个成功消息 const successMessage = { content: `您的旅行计划「${tripData.title}」已保存成功!旅行日期:${tripData.startDate} 至 ${tripData.endDate}`, isUser: false }; // 添加到聊天记录 messages.value.push(successMessage); // 关闭对话框 closeSaveDialog(); // 滚动到底部以显示成功消息 scrollToBottom(); }; // 发送消息 const sendMessage = async () => { if (!userInput.value.trim() || isLoading.value) return; // 添加用户消息 const userMessage = userInput.value; messages.value.push({ content: userMessage, isUser: true }); // 清空输入框 userInput.value = ''; // 设置加载状态 isLoading.value = true; try { // 调用API发送消息,获取流式响应 // 首次请求不传sessionId,使用服务器生成的sessionId const stream = await sendChatMessage(userMessage, sessionId.value); // 初始化当前消息 currentStreamMessage.value = ''; // 创建一个空的AI回复消息 messages.value.push({ content: '', isUser: false }); // 处理流式响应 await processStreamResponse( stream, // 每次收到数据块的处理 (data) => { // 更新当前流消息 if (data.message !== undefined) { currentStreamMessage.value += data.message; // 更新最后一条AI消息的内容 const lastMessageIndex = messages.value.length - 1; messages.value[lastMessageIndex].content = currentStreamMessage.value; } // 如果是最后一个块,更新sessionId if (data.sessionId) { sessionId.value = data.sessionId; } }, // 错误处理 (error) => { console.error('处理响应出错:', error); }, // 完成处理 () => { isLoading.value = false; scrollToBottom(); } ); } catch (error) { console.error('发送消息出错:', error); messages.value.push({ content: "抱歉,我遇到了一些问题。请稍后再试。", isUser: false }); isLoading.value = false; scrollToBottom(); } }; // 滚动到底部 const scrollToBottom = async () => { await nextTick(); if (messageContainer.value) { messageContainer.value.scrollTop = messageContainer.value.scrollHeight; } }; // 监听消息变化,自动滚动 watch(messages, () => { scrollToBottom(); }, { deep: true }); // 组件挂载后初始化 onMounted(() => { // 如果需要在挂载时做一些初始化,可以在这里添加 scrollToBottom(); }); </script> <style scoped> .travel-chat { width: 100%; height: 100%; display: flex; flex-direction: column; border-radius: 12px; background-color: white; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); overflow: hidden; position: relative; /* 位置相对定位 */ max-height: 700px; /* 设置最大高度 */ } .chat-header { padding: 15px 20px; background-color: #16a34a; color: white; flex-shrink: 0; /* 防止头部被压缩 */ position: sticky; /* 固定在顶部 */ top: 0; z-index: 20; /* 确保在最上层 */ display: flex; /* 使用flex布局使标题和按钮水平对齐 */ justify-content: space-between; /* 标题靠左,按钮靠右 */ align-items: center; /* 垂直居中 */ } .chat-header h3 { margin: 0; font-size: 18px; font-weight: 500; } .save-chat-btn { background-color: rgba(255, 255, 255, 0.2); color: white; border: none; border-radius: 6px; padding: 8px 12px; font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: background-color 0.2s; } .save-chat-btn:hover { background-color: rgba(255, 255, 255, 0.3); } .chat-messages { flex: 1; padding: 16px; overflow-y: auto; /* 启用垂直滚动 */ display: flex; flex-direction: column; gap: 16px; scrollbar-width: thin; /* Firefox 滚动条样式 */ scrollbar-color: #d1d5db #f3f4f6; /* Firefox 滚动条颜色 */ position: relative; /* 为绝对定位的子元素提供参考 */ } /* Webkit浏览器的滚动条样式 */ .chat-messages::-webkit-scrollbar { width: 6px; } .chat-messages::-webkit-scrollbar-track { background: #f3f4f6; border-radius: 3px; } .chat-messages::-webkit-scrollbar-thumb { background-color: #d1d5db; border-radius: 3px; } .chat-messages::-webkit-scrollbar-thumb:hover { background-color: #9ca3af; } .message { max-width: 85%; /* 增加最大宽度,允许更多文本显示 */ padding: 12px 16px; border-radius: 12px; animation: fadeIn 0.3s ease-out; word-break: break-word; /* 在单词之间换行 */ white-space: pre-wrap; /* 保留空格和换行符 */ overflow-wrap: break-word; /* 确保长单词能够换行 */ hyphens: auto; /* 启用连字符 */ } .user-message { align-self: flex-end; background-color: #dcfce7; color: #166534; } .ai-message { align-self: flex-start; background-color: #f3f4f6; color: #1f2937; } .message-content { line-height: 1.5; word-break: break-word; max-height: 300px; /* 限制单个消息的最大高度 */ overflow-y: auto; /* 启用垂直滚动 */ scrollbar-width: thin; /* Firefox 滚动条样式 */ scrollbar-color: rgba(156, 163, 175, 0.5) transparent; /* Firefox 滚动条颜色 */ padding-right: 4px; /* 为滚动条预留空间 */ } /* 单个消息的滚动条样式 */ .message-content::-webkit-scrollbar { width: 4px; } .message-content::-webkit-scrollbar-track { background: transparent; } .message-content::-webkit-scrollbar-thumb { background-color: rgba(156, 163, 175, 0.5); border-radius: 2px; } .message-content::-webkit-scrollbar-thumb:hover { background-color: rgba(156, 163, 175, 0.8); } .chat-input { padding: 15px; display: flex; gap: 10px; border-top: 1px solid #e5e7eb; flex-shrink: 0; /* 防止输入框被压缩 */ background-color: white; /* 确保输入区域有背景色 */ position: sticky; /* 固定在底部 */ bottom: 0; z-index: 20; /* 确保在最上层 */ } .chat-input input { flex: 1; padding: 10px 16px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 16px; outline: none; transition: border-color 0.2s; } .chat-input input:focus { border-color: #16a34a; } .chat-input button { padding: 10px 24px; background-color: #16a34a; color: white; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; transition: background-color 0.2s; white-space: nowrap; /* 防止按钮文字换行 */ } .chat-input button:hover:not(:disabled) { background-color: #15803d; } .chat-input button:disabled { background-color: #94a3b8; cursor: not-allowed; } /* 加载动画 */ .loading { display: flex; gap: 5px; } .loading span { width: 10px; height: 10px; background-color: #94a3b8; border-radius: 50%; display: inline-block; animation: loadingBounce 1.4s infinite ease-in-out both; } .loading span:nth-child(1) { animation-delay: -0.32s; } .loading span:nth-child(2) { animation-delay: -0.16s; } /* 保存对话框样式 */ .modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 100; animation: fadeIn 0.2s ease-out; } .save-dialog { background-color: white; border-radius: 12px; width: 90%; max-width: 500px; padding: 24px; box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15); animation: dialogSlideIn 0.3s ease-out; } .save-dialog h3 { font-size: 20px; margin: 0 0 20px 0; color: #1f2937; text-align: center; } .form-group { margin-bottom: 16px; } .form-group label { display: block; font-size: 14px; font-weight: 500; color: #4b5563; margin-bottom: 6px; } .form-group input, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 15px; outline: none; transition: border-color 0.2s; } .form-group input:focus, .form-group textarea:focus { border-color: #16a34a; box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.1); } .date-row { display: flex; gap: 16px; } .date-row .form-group { flex: 1; } .dialog-buttons { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; } .cancel-btn { padding: 10px 16px; background-color: #f3f4f6; color: #4b5563; border: none; border-radius: 6px; font-size: 15px; cursor: pointer; transition: background-color 0.2s; } .cancel-btn:hover { background-color: #e5e7eb; } .save-btn { padding: 10px 20px; background-color: #16a34a; color: white; border: none; border-radius: 6px; font-size: 15px; font-weight: 500; cursor: pointer; transition: all 0.2s ease; } .save-btn:hover:not(:disabled) { background-color: #15803d; } .save-btn:disabled { background-color: #94a3b8; cursor: not-allowed; opacity: 0.7; } @keyframes dialogSlideIn { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: translateY(0); } } @keyframes loadingBounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } } @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } /* 平板和移动设备的响应式设计 */ @media (max-width: 768px) { .travel-chat { max-height: 500px; /* 移动设备上减小最大高度 */ } .message { max-width: 90%; } .chat-messages { padding: 12px; gap: 12px; } .chat-input { padding: 12px; } .date-row { flex-direction: column; gap: 8px; } .save-dialog { padding: 20px; width: 95%; } } </style>
2302_81331056/travel
src/components/travel/TravelChat.vue
Vue
unknown
14,284
<template> <section class="travel-hero"> <div class="container"> <div class="hero-content"> <h1 class="title">探索中国之美</h1> <h2 class="subtitle">AI智能规划您的完美旅程</h2> <p class="description">通过人工智能为您量身定制旅游路线,足不出户规划您的中国之旅</p> <div class="cta-buttons"> <button class="primary-btn">开始规划</button> <button class="secondary-btn">了解更多</button> </div> </div> </div> </section> </template> <script setup> // 组件逻辑可在此处添加 </script> <style scoped> .travel-hero { background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.3)), url('@/assets/bg2.png'); background-size: cover; background-position: center; background-repeat: no-repeat; height: 500px; display: flex; align-items: center; color: white; position: relative; } .hero-content { max-width: 800px; padding: 0 20px; } .title { font-size: 48px; font-weight: 700; margin-bottom: 16px; line-height: 1.2; } .subtitle { font-size: 28px; font-weight: 600; margin-bottom: 16px; color: #e2e8f0; } .description { font-size: 18px; margin-bottom: 32px; max-width: 600px; line-height: 1.6; color: #f8fafc; } .cta-buttons { display: flex; gap: 16px; } .primary-btn { background-color: #16a34a; color: white; padding: 12px 32px; border-radius: 8px; font-size: 16px; font-weight: 600; border: none; cursor: pointer; transition: all 0.3s ease; } .primary-btn:hover { background-color: #15803d; } .secondary-btn { background-color: transparent; color: white; border: 2px solid white; padding: 12px 32px; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.3s ease; } .secondary-btn:hover { background-color: rgba(255, 255, 255, 0.1); } @media (max-width: 768px) { .title { font-size: 36px; } .subtitle { font-size: 22px; } .description { font-size: 16px; } .cta-buttons { flex-direction: column; gap: 12px; } .primary-btn, .secondary-btn { width: 100%; } } </style>
2302_81331056/travel
src/components/travel/TravelHero.vue
Vue
unknown
2,205
<template> <div class="travel-map-container"> <div id="map-container" class="map-area"></div> <div class="map-controls"> <div class="control-panel"> <button class="map-btn zoom-in" @click="zoomIn">+</button> <button class="map-btn zoom-out" @click="zoomOut">-</button> </div> <div class="legend" v-if="hasRoute && showMarkers"> <div class="legend-item"> <span class="legend-marker attraction"></span> <span class="legend-text">景点</span> </div> <div class="legend-item"> <span class="legend-marker route"></span> <span class="legend-text">推荐路线</span> </div> </div> </div> <!-- 保存按钮 --> <div class="save-button-container"> <button class="save-button" @click="saveAndShowMarkers" v-if="!showMarkers && travelRoute"> <i class="fas fa-save"></i> 保存并显示路线 </button> <div class="save-success" v-if="showMarkers && saveSuccess"> <i class="fas fa-check-circle"></i> 已保存路线 </div> </div> <!-- 行程天数指示器 --> <div class="day-indicators" v-if="travelRoute && showMarkers"> <div v-for="(day, index) in travelDays" :key="day" class="day-indicator" :class="{ 'active': activeDay === index }" @click="setActiveDay(index)" > {{ day }} </div> </div> <!-- 路线信息展示 --> <div class="route-info" v-if="travelRoute && activeDay !== null && showMarkers"> <div class="route-info-header"> <h3>{{ travelRoute.itinerary[activeDay].theme }}</h3> <span class="day-label">{{ travelRoute.itinerary[activeDay].day }}</span> </div> <div class="route-info-content"> <div v-for="(event, index) in travelRoute.itinerary[activeDay].events" :key="index" class="event-item" > <div class="event-time">{{ event.time }}</div> <div class="event-content"> <div class="event-title">{{ event.activity }}</div> <div class="event-details" v-if="event.details"> <div v-if="event.details.highlights">{{ event.details.highlights }}</div> <div v-if="event.details.features">{{ event.details.features }}</div> <div v-if="event.details.essence">{{ event.details.essence }}</div> <div v-if="event.details.history">{{ event.details.history }}</div> <div v-if="event.details.transportation" class="transportation"> <span class="transport-icon">🚇</span> {{ event.details.transportation }} </div> </div> </div> </div> </div> </div> </div> </template> <script setup> import { ref, onMounted, computed, watch } from 'vue'; import { useAiRouteStore } from '@/stores/aiRouteStore'; const routeStore = useAiRouteStore(); const currentRoute = computed(() => routeStore.currentRoute); const hasRoute = computed(() => currentRoute.value.length > 0); const mapInstance = ref(null); const markerList = ref([]); const polyline = ref(null); const mapLoaded = ref(false); // 新增:控制是否显示标注点 const showMarkers = ref(false); const saveSuccess = ref(false); // 新增:保存并显示标注点的方法 const saveAndShowMarkers = () => { showMarkers.value = true; saveSuccess.value = true; // 3秒后隐藏保存成功提示 setTimeout(() => { saveSuccess.value = false; }, 3000); // 如果地图已加载且有路线,立即显示标注点 if (mapLoaded.value && travelRoute.value) { renderMapMarkers(); } }; // 存储旅游路线数据 const travelRoute = ref(null); const activeDay = ref(null); const travelDays = computed(() => { if (!travelRoute.value) return []; return travelRoute.value.itinerary.map(day => day.day); }); // 景点地理位置数据库 const attractionsDatabase = { // 已有的景点 '故宫博物院': { lng: 116.397, lat: 39.918, description: '中国明清两代的皇家宫殿,世界上现存规模最大、保存最完整的木质结构古建筑之一' }, '天安门广场': { lng: 116.404, lat: 39.909, description: '世界上最大的城市中心广场,可容纳一百万人举行盛大集会' }, '颐和园': { lng: 116.267, lat: 39.999, description: '中国现存规模最大、保存最完整的皇家园林,被誉为"皇家园林博物馆"' }, '八达岭长城': { lng: 116.024, lat: 40.362, description: '中国古代的伟大防御工程,八达岭长城是最受欢迎的旅游段落' }, '天坛': { lng: 116.407, lat: 39.882, description: '明清两代皇帝祭天、祈求五谷丰登的场所,是世界上最大的古代祭祀建筑群' }, '恭王府': { lng: 116.380, lat: 39.934, description: '清代规模最大的王府之一,曾是和珅、恭亲王奕訢的府邸' }, '什刹海': { lng: 116.380, lat: 39.940, description: '历史悠久的风景区,由前海、后海和西海组成,是老北京风貌的代表地区' }, '圆明园': { lng: 116.298, lat: 40.008, description: '清代大型皇家园林,被称为"万园之园",1860年被英法联军焚毁' }, '北海公园': { lng: 116.383, lat: 39.926, description: '中国现存最古老、最完整、最具代表性的皇家园林之一,始建于辽代' }, '鸟巢(国家体育场)': { lng: 116.397, lat: 39.993, description: '2008年北京奥运会的主会场,因外形酷似鸟巢而得名' }, '水立方(国家游泳中心)': { lng: 116.390, lat: 39.992, description: '2008年北京奥运会游泳比赛场馆,外观酷似水分子结构' }, '798艺术区': { lng: 116.495, lat: 39.984, description: '建于1950年代的原国营798厂等电子工业的老厂区改建而成的当代艺术中心' }, '南锣鼓巷': { lng: 116.403, lat: 39.936, description: '北京最古老的街区之一,保留了老北京胡同的风貌' }, '王府井': { lng: 116.418, lat: 39.914, description: '北京最著名、最繁华的商业街之一,有数百年历史' }, '景山公园': { lng: 116.397, lat: 39.928, description: '位于故宫北面的皇家园林,是俯瞰北京城全景的最佳地点之一' }, // 新增的景点 '首都机场': { lng: 116.597, lat: 40.080, description: '北京首都国际机场,中国最大的民用航空港之一' }, '奥林匹克森林公园': { lng: 116.390, lat: 40.020, description: '亚洲最大城中绿肺,夏季荷花遍野,北京奥运会配套设施' }, '北京动物园': { lng: 116.339, lat: 39.940, description: '拥有大熊猫馆和热带雨林馆,是北京最受欢迎的动物园' }, '十三陵水库': { lng: 116.244, lat: 40.260, description: '明十三陵附近的大型水库,景色优美,适合骑行' }, '北京植物园': { lng: 116.206, lat: 39.996, description: '收集保存了3000多种植物,是北京重要的科研和旅游胜地' }, '香山公园': { lng: 116.184, lat: 39.996, description: '以红叶闻名,春季山桃花溪,秋季红叶岭景色绝佳' }, '慕田峪长城': { lng: 116.569, lat: 40.429, description: '长城最精华的一段,人少景美,有"世界七大奇迹"之一的美誉' }, '朝阳公园': { lng: 116.483, lat: 39.933, description: '北京市区最大的综合性公园之一,免费开放,可租船/骑行' }, '前门大街': { lng: 116.395, lat: 39.899, description: '北京最古老的商业街之一,保留了清末民初的建筑风格' } }; onMounted(() => { // 动态引入百度地图脚本 const script = document.createElement('script'); script.src = 'https://api.map.baidu.com/api?v=3.0&ak=DpbJ4hDkZSlBHunZMkVrQ2h0cRrwfpr0&callback=initBMap'; document.head.appendChild(script); // 初始化地图的回调函数 window.initBMap = function() { initMap(); loadMockData(); }; }); // 修改初始化地图函数 const initMap = () => { const map = new BMap.Map('map-container'); const point = new BMap.Point(116.404, 39.915); // 北京中心点 map.centerAndZoom(point, 12); map.enableScrollWheelZoom(true); map.addControl(new BMap.NavigationControl()); map.addControl(new BMap.ScaleControl()); mapInstance.value = map; mapLoaded.value = true; // 只有当showMarkers为true时才渲染标记点 if (showMarkers.value && travelRoute.value) { renderMapMarkers(); } }; // 新增:从模拟数据加载路线 const loadMockData = () => { // 模拟从后端获取数据 const mockRouteData = { "overview": { "arrivalAirport": "北京首都国际机场(PEK)", "departureAirport": "北京首都国际机场(PEK)", "tripDuration": "7天6夜", "policy": "适用俄罗斯公民240小时免签政策", "transportation": "地铁 + 公交 + 共享单车", "transportationCost": "约150元" }, "itinerary": [ { "day": "第1天", "theme": "城市绿肺探索", "events": [ { "time": "08:30-09:30", "activity": "抵达首都机场", "details": { "transportation": "航班落地", "highlights": "办理入境手续,兑换人民币", "tip": "建议在机场兑换少量现金,其余使用移动支付" } }, { "time": "09:30-10:30", "activity": "前往市区", "details": { "transportation": "机场快轨", "features": "乘坐机场快轨前往三元桥站,换乘地铁", "cost": "约25元/人" } }, { "time": "10:30-11:00", "activity": "酒店办理入住", "details": { "highlights": "行李寄存(如无法立即入住)", "tip": "请务必保管好护照等证件" } }, { "time": "11:00-13:00", "activity": "奥林匹克公园", "details": { "highlights": "鸟巢和水立方外观参观", "transportation": "地铁8号线「奥林匹克公园站」", "features": "著名的2008年北京奥运会场馆", "tip": "可以花30元登上奥林匹克塔,俯瞰整个奥林匹克公园" } }, { "time": "13:00-14:00", "activity": "午餐", "details": { "dining": "奥林匹克公园附近的小吃街", "features": "品尝北京特色小吃", "recommendation": "品尝老北京炸酱面、豆汁或卤煮" } }, { "time": "14:00-16:30", "activity": "奥林匹克森林公园", "details": { "highlights": "亚洲最大城中绿肺,夏季荷花遍野", "transportation": "步行10分钟即可到达", "features": "宁静的湖泊、茂密的森林和各类运动设施", "activities": "划船、骑车、徒步都是不错的选择", "tip": "下午可租自行车环湖骑行,费用约20元/小时" } }, { "time": "17:00-19:00", "activity": "北京动物园", "details": { "features": "大熊猫馆+热带雨林馆(室内避暑)", "dining": "园内「熊猫咖啡厅」推荐熊猫造型甜品", "highlight": "中国本土珍稀动物展区", "transportation": "地铁4号线「动物园站」", "tip": "傍晚动物活动较多,游客较少" } }, { "time": "19:30-21:00", "activity": "晚餐与休息", "details": { "dining": "三里屯太古里美食广场", "transportation": "地铁10号线「三里屯站」", "features": "国际化餐饮体验", "tip": "此处也是北京著名的夜生活区域,可以感受现代北京的夜景" } } ] }, { "day": "第2天", "theme": "皇家园林之旅", "events": [ { "time": "08:30-12:00", "activity": "颐和园", "details": { "essence": "昆明湖划船+万寿山登高(建议租电瓶车)", "transportation": "地铁4号线「北宫门站」" } }, { "time": "14:00-17:00", "activity": "圆明园", "details": { "history": "西洋楼遗址的荷花景观(6-8月最佳)", "tip": "租借智能导览耳机了解遗址故事" } } ] }, { "day": "第3天", "theme": "山峦长城穿越", "events": [ { "time": "07:30-12:00", "activity": "八达岭长城", "details": { "highlights": "乘景区小火车「水关段」登顶(减少体力消耗)", "tip": "夏季紫外线强,建议携带登山杖" } }, { "time": "14:00-17:00", "activity": "十三陵水库", "details": { "features": "骑行环湖(景区提供自行车租赁)", "tip": "下午4点逆光拍摄水面最佳" } } ] }, { "day": "第4天", "theme": "生态秘境", "events": [ { "time": "09:00-16:00", "activity": "北京植物园+香山公园(联票游览)", "details": { "highlights": "春季山桃花溪(4月)、秋季红叶岭(10月)", "transportation": "地铁10号线转公交634路" } } ] }, { "day": "第5天", "theme": "泃河流域探秘", "events": [ { "time": "08:00-17:00", "activity": "慕田峪长城", "details": { "features": "人少景美,可选「西线野长城」徒步", "transportation": "公交916快+景区接驳车(全程约2小时)" } } ] }, { "day": "第6天", "theme": "城市休闲日", "events": [ { "time": "09:00-12:00", "activity": "朝阳公园", "details": { "features": "免费开放,可租船/骑行" } }, { "time": "14:00-17:00", "activity": "798艺术区", "details": { "essence": "从自然景观到现代艺术体验的转换" } } ] }, { "day": "第7天", "theme": "离境日", "events": [ { "time": "10:00-12:00", "activity": "前门大街", "details": { "features": "最后购物:同仁堂(特产)、全聚德(打包带走)" } }, { "time": "14:00", "activity": "返回首都机场", "details": { "transportation": "按航班时间" } } ] } ], "tips": { "visaValidity": "请在入境第7日18:00前离境", "weatherPreparation": "当前北京22°C晴朗,建议携带防晒霜+轻便外套", "transportTips": "下载「Metro大都会」APP可扫码乘坐所有公共交通", "emergencyContact": "+86-10-12301(北京旅游咨询热线)", "remarks": "需要中英双语版或调整景点顺序请随时告知!" } }; travelRoute.value = mockRouteData; activeDay.value = 0; // 默认选择第一天 }; // 修改:设置活动日期 const setActiveDay = (index) => { activeDay.value = index; // 如果地图已加载且显示标记点,则更新地图上的标记点 if (mapLoaded.value && showMarkers.value) { clearMapMarkers(); renderMapMarkers(); } }; // 修改:渲染地图标记点的方法 const renderMapMarkers = () => { if (!mapInstance.value || !travelRoute.value || activeDay.value === null) return; // 清除现有的标记点和路线 clearMapMarkers(); const dayEvents = travelRoute.value.itinerary[activeDay.value].events; const points = []; // 为每个事件创建标记点 dayEvents.forEach((event, index) => { const attractionName = extractAttractionName(event.activity); if (attractionName && attractionsDatabase[attractionName]) { const location = attractionsDatabase[attractionName]; const point = new BMap.Point(location.lng, location.lat); points.push(point); // 创建标记点 const marker = new BMap.Marker(point); mapInstance.value.addOverlay(marker); markerList.value.push(marker); // 创建信息窗口 const infoWindow = new BMap.InfoWindow(` <div class="marker-info"> <h4>${attractionName}</h4> <p>${location.description}</p> <div class="event-time">${event.time}</div> </div> `); // 点击标记点时显示信息窗口 marker.addEventListener('click', function() { this.openInfoWindow(infoWindow); }); // 如果是第一个点,将地图中心设为该点 if (index === 0) { mapInstance.value.centerAndZoom(point, 13); } } }); // 如果有多个点,绘制路线 if (points.length > 1) { const polylineObj = new BMap.Polyline(points, { strokeColor: '#16a34a', strokeWeight: 4, strokeOpacity: 0.7 }); mapInstance.value.addOverlay(polylineObj); polyline.value = polylineObj; } }; // 清除地图上的标记点和路线 const clearMapMarkers = () => { if (!mapInstance.value) return; // 清除标记点 markerList.value.forEach(marker => { mapInstance.value.removeOverlay(marker); }); markerList.value = []; // 清除路线 if (polyline.value) { mapInstance.value.removeOverlay(polyline.value); polyline.value = null; } }; // 从活动名称中提取景点名称 const extractAttractionName = (activity) => { for (const name in attractionsDatabase) { if (activity.includes(name)) { return name; } } return null; }; // 放大地图 const zoomIn = () => { if (mapInstance.value) { const zoom = mapInstance.value.getZoom(); mapInstance.value.setZoom(zoom + 1); } }; // 缩小地图 const zoomOut = () => { if (mapInstance.value) { const zoom = mapInstance.value.getZoom(); mapInstance.value.setZoom(zoom - 1); } }; </script> <style scoped> .travel-map-container { position: relative; width: 100%; height: 600px; margin: 20px 0; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); } .map-area { width: 100%; height: 100%; } .map-controls { position: absolute; bottom: 20px; left: 20px; z-index: 10; } .control-panel { display: flex; flex-direction: column; gap: 8px; margin-bottom: 15px; } .map-btn { width: 36px; height: 36px; background-color: white; border: 1px solid #ddd; border-radius: 4px; font-size: 18px; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); transition: all 0.2s ease; } .map-btn:hover { background-color: #f5f5f5; } .legend { background-color: white; padding: 12px; border-radius: 6px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); } .legend-item { display: flex; align-items: center; margin-bottom: 8px; } .legend-item:last-child { margin-bottom: 0; } .legend-marker { width: 16px; height: 16px; margin-right: 8px; border-radius: 50%; } .legend-marker.attraction { background-color: #16a34a; } .legend-marker.route { width: 16px; height: 4px; border-radius: 2px; background-color: #16a34a; } .legend-text { font-size: 14px; color: #333; } .day-indicators { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); display: flex; background-color: white; border-radius: 30px; padding: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); z-index: 10; max-width: 90%; overflow-x: auto; scrollbar-width: thin; } .day-indicators::-webkit-scrollbar { height: 4px; } .day-indicators::-webkit-scrollbar-thumb { background-color: rgba(22, 163, 74, 0.5); border-radius: 4px; } .day-indicator { padding: 10px 24px; border-radius: 20px; font-size: 15px; min-width: 100px; text-align: center; white-space: nowrap; cursor: pointer; transition: all 0.3s ease; margin: 0 4px; } .day-indicator:hover { background-color: #f0fdf4; } .day-indicator.active { background-color: #16a34a; color: white; font-weight: 500; } .route-info { position: absolute; top: 80px; right: 20px; width: 300px; max-height: calc(100% - 100px); background-color: white; border-radius: 8px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15); overflow-y: auto; z-index: 10; } .route-info-header { padding: 16px; background-color: #16a34a; color: white; display: flex; justify-content: space-between; align-items: center; border-top-left-radius: 8px; border-top-right-radius: 8px; } .route-info-header h3 { margin: 0; font-size: 18px; } .day-label { font-size: 14px; padding: 4px 8px; background-color: rgba(255, 255, 255, 0.2); border-radius: 4px; } .route-info-content { padding: 16px; } .event-item { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid #eee; } .event-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; } .event-time { font-size: 14px; color: #16a34a; font-weight: 600; margin-bottom: 8px; } .event-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; } .event-details { font-size: 14px; color: #555; line-height: 1.5; } .transportation { margin-top: 8px; display: flex; align-items: center; } .transport-icon { margin-right: 6px; } .marker-info { padding: 5px; } .marker-info h4 { margin: 0 0 5px 0; color: #16a34a; } .marker-info p { margin: 0 0 5px 0; font-size: 13px; } /* 新增:保存按钮样式 */ .save-button-container { position: absolute; top: 20px; right: 20px; z-index: 10; } .save-button { background-color: #16a34a; color: white; border: none; border-radius: 6px; padding: 10px 16px; font-size: 16px; font-weight: 500; display: flex; align-items: center; gap: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3); transition: all 0.3s ease; } .save-button:hover { background-color: #15803d; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4); } .save-success { background-color: white; color: #16a34a; border-radius: 6px; padding: 10px 16px; font-size: 16px; font-weight: 500; display: flex; align-items: center; gap: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); animation: fadeIn 0.3s ease; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } @media (max-width: 768px) { .route-info { width: calc(100% - 40px); top: auto; bottom: 70px; right: 20px; left: 20px; max-height: 200px; } .day-indicators { top: 70px; padding: 6px; max-width: 95%; } .day-indicator { padding: 8px 16px; min-width: 80px; font-size: 14px; } .save-button-container { top: 20px; right: 20px; } } </style>
2302_81331056/travel
src/components/travel/TravelMap.vue
Vue
unknown
23,858
<template> <section class="ports-map"> <div class="container"> <h2 class="section-title"> <font-awesome-icon :icon="faMapLocationDot" class="section-icon" /> 入境口岸地图 </h2> <p class="section-description">查看中国主要入境口岸位置,了解过境免签政策适用口岸</p> <div class="map-container"> <div id="map" class="map"></div> <div class="map-legend"> <div class="legend-item"> <span class="legend-marker airport"></span> <span class="legend-text">机场口岸</span> </div> <div class="legend-item"> <span class="legend-marker seaport"></span> <span class="legend-text">海港口岸</span> </div> <div class="legend-item"> <span class="legend-marker railway"></span> <span class="legend-text">铁路口岸</span> </div> </div> </div> <div class="ports-list"> <h3>主要入境口岸列表</h3> <div class="ports-grid"> <div class="port-card" v-for="port in ports" :key="port.id"> <div class="port-icon" :class="port.type"> <font-awesome-icon :icon="getPortIcon(port.type)" /> </div> <div class="port-info"> <h4>{{ port.name }}</h4> <p>{{ port.location }}</p> </div> </div> </div> </div> </div> </section> </template> <script setup> import { onMounted, ref } from 'vue'; import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { library } from '@fortawesome/fontawesome-svg-core' import { faMapLocationDot, faPlane, faShip, faTrain } from '@fortawesome/free-solid-svg-icons' library.add(faMapLocationDot, faPlane, faShip, faTrain) // 口岸数据 const ports = ref([ // 华北地区 { id: 1, name: '北京首都国际机场', location: '北京市', type: 'airport', coordinates: [116.597, 40.080] }, { id: 2, name: '北京大兴国际机场', location: '北京市', type: 'airport', coordinates: [116.410, 39.509] }, { id: 3, name: '天津滨海国际机场', location: '天津市', type: 'airport', coordinates: [117.346, 39.124] }, { id: 4, name: '天津港', location: '天津市', type: 'seaport', coordinates: [117.673, 39.040] }, { id: 5, name: '石家庄正定国际机场', location: '河北省', type: 'airport', coordinates: [114.697, 38.281] }, { id: 6, name: '太原武宿国际机场', location: '山西省', type: 'airport', coordinates: [112.628, 37.747] }, { id: 7, name: '呼和浩特白塔国际机场', location: '内蒙古自治区', type: 'airport', coordinates: [111.823, 40.849] }, { id: 8, name: '二连浩特口岸', location: '内蒙古自治区', type: 'railway', coordinates: [111.977, 43.653] }, { id: 9, name: '满洲里口岸', location: '内蒙古自治区', type: 'railway', coordinates: [117.379, 49.589] }, // 东北地区 { id: 10, name: '沈阳桃仙国际机场', location: '辽宁省', type: 'airport', coordinates: [123.483, 41.640] }, { id: 11, name: '大连周水子国际机场', location: '辽宁省', type: 'airport', coordinates: [121.539, 38.965] }, { id: 12, name: '大连港', location: '辽宁省', type: 'seaport', coordinates: [121.673, 38.917] }, { id: 13, name: '长春龙嘉国际机场', location: '吉林省', type: 'airport', coordinates: [125.685, 43.996] }, { id: 14, name: '哈尔滨太平国际机场', location: '黑龙江省', type: 'airport', coordinates: [126.250, 45.623] }, { id: 15, name: '绥芬河口岸', location: '黑龙江省', type: 'railway', coordinates: [131.152, 44.396] }, // 华东地区 { id: 16, name: '上海浦东国际机场', location: '上海市', type: 'airport', coordinates: [121.805, 31.144] }, { id: 17, name: '上海虹桥国际机场', location: '上海市', type: 'airport', coordinates: [121.336, 31.198] }, { id: 18, name: '上海港', location: '上海市', type: 'seaport', coordinates: [121.479, 31.230] }, { id: 19, name: '南京禄口国际机场', location: '江苏省', type: 'airport', coordinates: [118.872, 31.742] }, { id: 20, name: '无锡苏南硕放国际机场', location: '江苏省', type: 'airport', coordinates: [120.429, 31.494] }, { id: 21, name: '杭州萧山国际机场', location: '浙江省', type: 'airport', coordinates: [120.434, 30.229] }, { id: 22, name: '宁波栎社国际机场', location: '浙江省', type: 'airport', coordinates: [121.461, 29.826] }, { id: 23, name: '宁波港', location: '浙江省', type: 'seaport', coordinates: [121.713, 29.868] }, { id: 24, name: '合肥新桥国际机场', location: '安徽省', type: 'airport', coordinates: [117.298, 31.989] }, { id: 25, name: '福州长乐国际机场', location: '福建省', type: 'airport', coordinates: [119.663, 25.935] }, { id: 26, name: '厦门高崎国际机场', location: '福建省', type: 'airport', coordinates: [118.127, 24.544] }, { id: 27, name: '厦门港', location: '福建省', type: 'seaport', coordinates: [118.089, 24.479] }, { id: 28, name: '南昌昌北国际机场', location: '江西省', type: 'airport', coordinates: [115.900, 28.865] }, { id: 29, name: '济南遥墙国际机场', location: '山东省', type: 'airport', coordinates: [117.216, 36.857] }, { id: 30, name: '青岛流亭国际机场', location: '山东省', type: 'airport', coordinates: [120.374, 36.266] }, { id: 31, name: '青岛港', location: '山东省', type: 'seaport', coordinates: [120.319, 36.067] }, // 华中地区 { id: 32, name: '郑州新郑国际机场', location: '河南省', type: 'airport', coordinates: [113.841, 34.519] }, { id: 33, name: '武汉天河国际机场', location: '湖北省', type: 'airport', coordinates: [114.208, 30.784] }, { id: 34, name: '长沙黄花国际机场', location: '湖南省', type: 'airport', coordinates: [113.220, 28.189] }, // 华南地区 { id: 35, name: '广州白云国际机场', location: '广东省', type: 'airport', coordinates: [113.299, 23.392] }, { id: 36, name: '深圳宝安国际机场', location: '广东省', type: 'airport', coordinates: [113.819, 22.639] }, { id: 37, name: '广州港', location: '广东省', type: 'seaport', coordinates: [113.364, 23.099] }, { id: 38, name: '深圳港', location: '广东省', type: 'seaport', coordinates: [114.156, 22.543] }, { id: 39, name: '珠海金湾机场', location: '广东省', type: 'airport', coordinates: [113.376, 22.006] }, { id: 40, name: '南宁吴圩国际机场', location: '广西壮族自治区', type: 'airport', coordinates: [108.188, 22.608] }, { id: 41, name: '桂林两江国际机场', location: '广西壮族自治区', type: 'airport', coordinates: [110.039, 25.218] }, { id: 42, name: '海口美兰国际机场', location: '海南省', type: 'airport', coordinates: [110.459, 19.934] }, { id: 43, name: '三亚凤凰国际机场', location: '海南省', type: 'airport', coordinates: [109.412, 18.303] }, // 西南地区 { id: 44, name: '重庆江北国际机场', location: '重庆市', type: 'airport', coordinates: [106.634, 29.718] }, { id: 45, name: '成都双流国际机场', location: '四川省', type: 'airport', coordinates: [103.947, 30.578] }, { id: 46, name: '昆明长水国际机场', location: '云南省', type: 'airport', coordinates: [102.929, 24.992] }, { id: 47, name: '西双版纳嘎洒国际机场', location: '云南省', type: 'airport', coordinates: [100.760, 21.973] }, { id: 48, name: '瑞丽口岸', location: '云南省', type: 'railway', coordinates: [97.851, 24.008] }, { id: 49, name: '磨憨口岸', location: '云南省', type: 'railway', coordinates: [101.567, 21.448] }, { id: 50, name: '拉萨贡嘎国际机场', location: '西藏自治区', type: 'airport', coordinates: [90.912, 29.298] }, // 西北地区 { id: 51, name: '西安咸阳国际机场', location: '陕西省', type: 'airport', coordinates: [108.751, 34.447] }, { id: 52, name: '兰州中川国际机场', location: '甘肃省', type: 'airport', coordinates: [103.620, 36.515] }, { id: 53, name: '西宁曹家堡国际机场', location: '青海省', type: 'airport', coordinates: [102.042, 36.527] }, { id: 54, name: '银川河东国际机场', location: '宁夏回族自治区', type: 'airport', coordinates: [106.393, 38.322] }, { id: 55, name: '乌鲁木齐地窝堡国际机场', location: '新疆维吾尔自治区', type: 'airport', coordinates: [87.474, 43.907] }, { id: 56, name: '霍尔果斯口岸', location: '新疆维吾尔自治区', type: 'railway', coordinates: [80.420, 44.201] }, { id: 57, name: '阿拉山口口岸', location: '新疆维吾尔自治区', type: 'railway', coordinates: [82.568, 45.172] }, // 港澳台地区 { id: 58, name: '香港国际机场', location: '香港特别行政区', type: 'airport', coordinates: [113.936, 22.308] }, { id: 59, name: '澳门国际机场', location: '澳门特别行政区', type: 'airport', coordinates: [113.606, 22.156] }, { id: 60, name: '台北桃园国际机场', location: '台湾地区', type: 'airport', coordinates: [121.232, 25.080] } ]); // 获取口岸图标 const getPortIcon = (type) => { switch (type) { case 'airport': return faPlane; case 'seaport': return faShip; case 'railway': return faTrain; default: return faMapLocationDot; } }; onMounted(() => { // 动态引入百度地图脚本 const script = document.createElement('script'); script.src = 'https://api.map.baidu.com/api?v=3.0&ak=DpbJ4hDkZSlBHunZMkVrQ2h0cRrwfpr0&callback=initBMap'; document.head.appendChild(script); // 初始化地图 window.initBMap = function() { const map = new BMap.Map('map'); const point = new BMap.Point(116.404, 39.915); // 北京中心 map.centerAndZoom(point, 5); map.enableScrollWheelZoom(true); // 使用labelMarker代替标准marker ports.value.forEach(port => { // 基于口岸类型设置颜色 let markerColor; switch(port.type) { case 'airport': markerColor = '#3b82f6'; // 蓝色 break; case 'seaport': markerColor = '#10b981'; // 绿色 break; case 'railway': markerColor = '#f59e0b'; // 黄色 break; default: markerColor = '#3b82f6'; } // 创建自定义的覆盖物 const marker = new BMap.Marker(new BMap.Point(port.coordinates[0], port.coordinates[1])); map.addOverlay(marker); // 为每个marker添加自定义的svg标签作为label const label = new BMap.Label('', { position: new BMap.Point(port.coordinates[0], port.coordinates[1]), offset: new BMap.Size(-10, -10) }); // 创建SVG标记 const svgCircle = ` <div style=" width: 20px; height: 20px; border-radius: 50%; background-color: ${markerColor}; border: 2px solid white; box-shadow: 0 2px 5px rgba(0,0,0,0.2); "></div> `; label.setContent(svgCircle); label.setStyle({ border: 'none', backgroundColor: 'transparent' }); map.addOverlay(label); // 隐藏原始marker marker.hide(); // 创建信息窗体 const infoWindow = new BMap.InfoWindow(` <div class="info-window"> <h3>${port.name}</h3> <p>${port.location}</p> <p class="port-type">${getPortTypeName(port.type)}</p> </div> `); // 点击标签时显示信息窗体 label.addEventListener('click', () => { map.openInfoWindow(infoWindow, new BMap.Point(port.coordinates[0], port.coordinates[1])); map.panTo(new BMap.Point(port.coordinates[0], port.coordinates[1])); }); }); }; }); // 获取口岸类型名称 const getPortTypeName = (type) => { switch(type) { case 'airport': return '机场口岸'; case 'seaport': return '海港口岸'; case 'railway': return '铁路口岸'; default: return '其他口岸'; } }; </script> <style scoped> .ports-map { padding: 80px 0; background-color: #f8fafc; } .container { max-width: 1200px; margin: 0 auto; padding: 0 20px; } .section-title { text-align: center; font-size: 36px; color: #1a3a5f; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; gap: 12px; } .section-icon { font-size: 36px; color: #16a34a; } .section-description { text-align: center; color: #4a5568; margin-bottom: 50px; font-size: 18px; } .map-container { position: relative; height: 500px; margin-bottom: 40px; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); } .map { width: 100%; height: 100%; } .map-legend { position: absolute; top: 20px; right: 20px; background-color: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); } .legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; } .legend-item:last-child { margin-bottom: 0; } .legend-marker { width: 16px; height: 16px; border-radius: 50%; } .legend-marker.airport { background-color: #3b82f6; } .legend-marker.seaport { background-color: #10b981; } .legend-marker.railway { background-color: #f59e0b; } .legend-text { font-size: 14px; color: #4a5568; } .ports-list { background-color: white; border-radius: 12px; padding: 30px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); } .ports-list h3 { font-size: 24px; color: #1a3a5f; margin-bottom: 24px; } .ports-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; } .port-card { display: flex; align-items: center; gap: 16px; padding: 16px; background-color: #f8fafc; border-radius: 8px; transition: transform 0.2s ease; } .port-card:hover { transform: translateY(-2px); } .port-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; color: white; } .port-icon.airport { background-color: #3b82f6; } .port-icon.seaport { background-color: #10b981; } .port-icon.railway { background-color: #f59e0b; } .port-info h4 { font-size: 16px; color: #2d3748; margin-bottom: 4px; } .port-info p { font-size: 14px; color: #718096; margin: 0; } .info-window { padding: 12px; max-width: 200px; } .info-window h3 { font-size: 16px; color: #2d3748; margin-bottom: 4px; } .info-window p { font-size: 14px; color: #718096; margin: 0; } .port-type { font-size: 12px; color: #718096; margin-top: 4px; } @media (max-width: 768px) { .map-container { height: 400px; } .ports-grid { grid-template-columns: 1fr; } } </style>
2302_81331056/travel
src/components/visa/PortsMap.vue
Vue
unknown
15,017
<template> <div id="visa-countries" class="visa-countries"> <div class="container"> <h2 class="section-title">适用国家一览</h2> <p class="section-description">以下54个国家的公民可享受中国过境免签政策</p> <div class="country-groups"> <div class="country-group"> <h3 class="group-title"> <font-awesome-icon :icon="faEarthEurope" class="group-icon" /> 欧洲 </h3> <div class="countries-grid"> <div class="country-item" v-for="country in europeCountries" :key="country.code"> <div class="country-flag">{{ country.flag }}</div> <div class="country-name">{{ country.name }}</div> </div> </div> </div> <div class="country-group"> <h3 class="group-title"> <font-awesome-icon :icon="faEarthAmericas" class="group-icon" /> 美洲 </h3> <div class="countries-grid"> <div class="country-item" v-for="country in americaCountries" :key="country.code"> <div class="country-flag">{{ country.flag }}</div> <div class="country-name">{{ country.name }}</div> </div> </div> </div> <div class="country-group"> <h3 class="group-title"> <font-awesome-icon :icon="faEarthAsia" class="group-icon" /> 亚洲与大洋洲 </h3> <div class="countries-grid"> <div class="country-item" v-for="country in asiaOceaniaCountries" :key="country.code"> <div class="country-flag">{{ country.flag }}</div> <div class="country-name">{{ country.name }}</div> </div> </div> </div> </div> <div class="note-box"> <p>注意:此列表仅供参考,具体政策以中国移民管理局发布的最新公告为准。请在旅行前确认您所持护照是否符合免签要求。</p> </div> </div> </div> </template> <script setup> import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { library } from '@fortawesome/fontawesome-svg-core' import { faEarthEurope, faEarthAmericas, faEarthAsia } from '@fortawesome/free-solid-svg-icons' library.add(faEarthEurope, faEarthAmericas, faEarthAsia) const europeCountries = [ { name: '奥地利', code: 'AT', flag: '🇦🇹' }, { name: '比利时', code: 'BE', flag: '🇧🇪' }, { name: '保加利亚', code: 'BG', flag: '🇧🇬' }, { name: '克罗地亚', code: 'HR', flag: '🇭🇷' }, { name: '塞浦路斯', code: 'CY', flag: '🇨🇾' }, { name: '捷克', code: 'CZ', flag: '🇨🇿' }, { name: '丹麦', code: 'DK', flag: '🇩🇰' }, { name: '爱沙尼亚', code: 'EE', flag: '🇪🇪' }, { name: '芬兰', code: 'FI', flag: '🇫🇮' }, { name: '法国', code: 'FR', flag: '🇫🇷' }, { name: '德国', code: 'DE', flag: '🇩🇪' }, { name: '希腊', code: 'GR', flag: '🇬🇷' }, { name: '匈牙利', code: 'HU', flag: '🇭🇺' }, { name: '冰岛', code: 'IS', flag: '🇮🇸' }, { name: '爱尔兰', code: 'IE', flag: '🇮🇪' }, { name: '意大利', code: 'IT', flag: '🇮🇹' }, { name: '拉脱维亚', code: 'LV', flag: '🇱🇻' }, { name: '立陶宛', code: 'LT', flag: '🇱🇹' }, { name: '卢森堡', code: 'LU', flag: '🇱🇺' }, { name: '马耳他', code: 'MT', flag: '🇲🇹' }, { name: '荷兰', code: 'NL', flag: '🇳🇱' }, { name: '波兰', code: 'PL', flag: '🇵🇱' }, { name: '葡萄牙', code: 'PT', flag: '🇵🇹' }, { name: '罗马尼亚', code: 'RO', flag: '🇷🇴' }, { name: '俄罗斯', code: 'RU', flag: '🇷🇺' }, { name: '斯洛伐克', code: 'SK', flag: '🇸🇰' }, { name: '斯洛文尼亚', code: 'SI', flag: '🇸🇮' }, { name: '西班牙', code: 'ES', flag: '🇪🇸' }, { name: '瑞典', code: 'SE', flag: '🇸🇪' }, { name: '瑞士', code: 'CH', flag: '🇨🇭' }, { name: '英国', code: 'GB', flag: '🇬🇧' } ]; const americaCountries = [ { name: '美国', code: 'US', flag: '🇺🇸' }, { name: '加拿大', code: 'CA', flag: '🇨🇦' }, { name: '巴西', code: 'BR', flag: '🇧🇷' }, { name: '墨西哥', code: 'MX', flag: '🇲🇽' }, { name: '阿根廷', code: 'AR', flag: '🇦🇷' }, { name: '智利', code: 'CL', flag: '🇨🇱' } ]; const asiaOceaniaCountries = [ { name: '日本', code: 'JP', flag: '🇯🇵' }, { name: '韩国', code: 'KR', flag: '🇰🇷' }, { name: '新加坡', code: 'SG', flag: '🇸🇬' }, { name: '文莱', code: 'BN', flag: '🇧🇳' }, { name: '阿联酋', code: 'AE', flag: '🇦🇪' }, { name: '澳大利亚', code: 'AU', flag: '🇦🇺' }, { name: '新西兰', code: 'NZ', flag: '🇳🇿' }, { name: '卡塔尔', code: 'QA', flag: '🇶🇦' }, { name: '马来西亚', code: 'MY', flag: '🇲🇾' }, { name: '泰国', code: 'TH', flag: '🇹🇭' }, { name: '蒙古', code: 'MN', flag: '🇲🇳' }, { name: '菲律宾', code: 'PH', flag: '🇵🇭' }, { name: '印度尼西亚', code: 'ID', flag: '🇮🇩' }, { name: '乌克兰', code: 'UA', flag: '🇺🇦' }, { name: '白俄罗斯', code: 'BY', flag: '🇧🇾' }, { name: '阿曼', code: 'OM', flag: '🇴🇲' }, { name: '塞尔维亚', code: 'RS', flag: '🇷🇸' } ]; </script> <style scoped> .visa-countries { padding: 80px 0; background-color: #f8fafc; } .container { max-width: 1200px; margin: 0 auto; padding: 0 20px; } .section-title { text-align: center; font-size: 36px; color: #1a3a5f; margin-bottom: 16px; position: relative; } .section-description { text-align: center; color: #4a5568; margin-bottom: 50px; font-size: 18px; } .country-groups { display: flex; flex-direction: column; gap: 40px; } .country-group { background-color: white; border-radius: 12px; padding: 30px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); } .group-title { font-size: 24px; color: #2c5282; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid #e2e8f0; display: flex; align-items: center; gap: 10px; } .group-icon { font-size: 24px; color: #16a34a; } .countries-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; } .country-item { display: flex; align-items: center; padding: 10px; border-radius: 6px; transition: background-color 0.2s ease; } .country-item:hover { background-color: #f0fdf4; } .country-flag { font-size: 24px; margin-right: 10px; } .country-name { font-size: 16px; color: #2d3748; } .note-box { margin-top: 40px; padding: 20px; background-color: #fffbeb; border-left: 4px solid #f59e0b; border-radius: 6px; } .note-box p { color: #713f12; font-size: 15px; line-height: 1.5; } @media (max-width: 768px) { .countries-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } } @media (max-width: 480px) { .countries-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); } .country-flag { font-size: 20px; } .country-name { font-size: 14px; } } </style>
2302_81331056/travel
src/components/visa/VisaCountries.vue
Vue
unknown
7,261
<template> <section id="visa-faq" class="visa-faq"> <div class="container"> <h2 class="section-title"> <font-awesome-icon :icon="faQuestionCircle" class="section-icon" /> 常见问题解答 </h2> <p class="section-description">了解过境免签政策的常见问题和解答</p> <div class="faq-container"> <div class="faq-item" v-for="(item, index) in faqItems" :key="index"> <div class="faq-question" @click="toggleFaq(index)"> <h3>{{ item.question }}</h3> <font-awesome-icon :icon="faChevronDown" class="toggle-icon" :class="{ active: item.isOpen }" /> </div> <div class="faq-answer" :class="{ open: item.isOpen }"> <p v-html="item.answer"></p> </div> </div> </div> <div class="more-questions"> <h4> <font-awesome-icon :icon="faEnvelope" class="contact-icon" /> 还有其他问题? </h4> <p>如果您有其他关于中国入境政策的问题,请联系附近的中国使领馆或拨打我们的服务热线。</p> <button class="contact-btn">联系我们</button> </div> </div> </section> </template> <script setup> import { ref, reactive } from 'vue'; import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { library } from '@fortawesome/fontawesome-svg-core' import { faQuestionCircle, faChevronDown, faEnvelope } from '@fortawesome/free-solid-svg-icons' library.add(faQuestionCircle, faChevronDown, faEnvelope) const faqItems = reactive([ { question: "什么是过境免签政策?", answer: "过境免签政策是中国为便利外国旅客中转前往第三国而设立的政策。符合条件的外国人持有效国际旅行证件和前往第三国或地区已确定日期的联程机票,可在规定时间内免办签证停留在中国特定区域。", isOpen: true }, { question: "240小时免签政策适用哪些国家的公民?", answer: "240小时(10天)免签政策适用于54个国家的公民,包括美国、加拿大、英国、俄罗斯、澳大利亚、新西兰、日本、韩国以及大多数欧盟国家等。完整国家列表可在\"适用国家\"部分查看。", isOpen: false }, { question: "使用过境免签政策有哪些条件?", answer: "使用过境免签政策需要满足以下条件:<br>1. 持有54个适用国家之一的有效护照<br>2. 持有前往第三国或地区的已确定日期的联程机票<br>3. 从规定的入境口岸入境<br>4. 停留不超过240小时(10天)<br>5. 活动范围仅限于规定的24个省(区、市)内", isOpen: false }, { question: "持72小时或144小时过境免签政策还有效吗?", answer: "原有的72小时和144小时过境免签政策已升级为统一的240小时(10天)过境免签政策。如果您之前符合72小时或144小时过境免签政策的条件,现在可以享受更长的240小时免签停留时间。", isOpen: false }, { question: "入境后是否可以离开入境城市前往其他城市?", answer: "是的,新政策允许外国旅客在规定的24个省(区、市)范围内跨省域旅行,不再局限于入境口岸所在城市或省份。这意味着您可以更灵活地安排在中国的行程。", isOpen: false }, { question: "免签过境期间可以办理签证延长停留时间吗?", answer: "通常情况下,免签过境期间不能办理停留时间的延长。如果您计划在中国停留超过240小时,建议提前申请适当的签证。特殊情况下如遇不可抗力因素,可联系当地出入境管理机构寻求帮助。", isOpen: false } ]); const toggleFaq = (index) => { faqItems[index].isOpen = !faqItems[index].isOpen; }; </script> <style scoped> .visa-faq { padding: 80px 0; background-color: #f8fafc; } .container { max-width: 1200px; margin: 0 auto; padding: 0 20px; } .section-title { text-align: center; font-size: 36px; color: #1a3a5f; margin-bottom: 16px; display: flex; align-items: center; justify-content: center; gap: 12px; } .section-icon { font-size: 36px; color: #16a34a; } .section-description { text-align: center; color: #4a5568; margin-bottom: 50px; font-size: 18px; } .faq-container { max-width: 800px; margin: 0 auto 60px; } .faq-item { background-color: white; border-radius: 10px; margin-bottom: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); } .faq-question { padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: background-color 0.2s ease; } .faq-question:hover { background-color: #f0fdf4; } .faq-question h3 { font-size: 18px; font-weight: 500; color: #2d3748; margin: 0; } .toggle-icon { font-size: 16px; color: #16a34a; transition: transform 0.3s ease; } .toggle-icon.active { transform: rotate(180deg); } .faq-answer { max-height: 0; overflow: hidden; transition: max-height 0.3s ease, padding 0.3s ease; padding: 0 24px; } .faq-answer.open { max-height: 500px; padding: 0 24px 20px; } .faq-answer p { color: #4a5568; line-height: 1.6; margin: 0; } .more-questions { text-align: center; background-color: #f0fdf4; padding: 40px; border-radius: 12px; } .more-questions h4 { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 22px; color: #16a34a; margin-bottom: 16px; } .more-questions p { color: #4a5568; margin-bottom: 24px; } .contact-btn { background-color: #16a34a; color: white; padding: 12px 32px; border-radius: 8px; font-size: 16px; font-weight: 600; border: none; cursor: pointer; transition: all 0.3s ease; } .contact-btn:hover { background-color: #15803d; } .contact-icon { margin-right: 8px; font-size: 20px; } @media (max-width: 768px) { .faq-question h3 { font-size: 16px; } .more-questions { padding: 30px 20px; } } </style>
2302_81331056/travel
src/components/visa/VisaFAQ.vue
Vue
unknown
6,180
<script setup> import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { library } from '@fortawesome/fontawesome-svg-core' import { faGlobe, faFileLines } from '@fortawesome/free-solid-svg-icons' library.add(faGlobe, faFileLines) const scrollToCountries = () => { const countriesSection = document.getElementById('visa-countries') if (countriesSection) { countriesSection.scrollIntoView({ behavior: 'smooth' }) } } const scrollToFAQ = () => { const faqSection = document.getElementById('visa-faq') if (faqSection) { faqSection.scrollIntoView({ behavior: 'smooth' }) } } </script> <template> <section class="visa-hero"> <div class="container"> <div class="hero-content"> <h1 class="title">中国签证与入境政策</h1> <h2 class="subtitle">免签政策全面优化,欢迎探索中国之美</h2> <p class="description">即日起,过境免签停留时间延长至240小时(10天),适用54国公民</p> <div class="cta-buttons"> <button class="primary-btn" @click="scrollToCountries"> <font-awesome-icon :icon="faGlobe" class="btn-icon" /> 查看适用国家 </button> <button class="secondary-btn" @click="scrollToFAQ"> <font-awesome-icon :icon="faFileLines" class="btn-icon" /> 了解申请流程 </button> </div> </div> </div> </section> </template> <style scoped> .visa-hero { background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('@/assets/bg1.png'); background-size: cover; background-position: center; background-repeat: no-repeat; padding: 120px 0 80px; position: relative; overflow: hidden; } .hero-content { max-width: 720px; margin: 0 auto; text-align: center; } .title { font-size: 42px; font-weight: 700; color: #ffffff; margin-bottom: 20px; } .subtitle { font-size: 28px; font-weight: 500; color: #ffffff; margin-bottom: 24px; } .description { font-size: 18px; color: #ffffff; margin-bottom: 40px; line-height: 1.6; } .cta-buttons { display: flex; justify-content: center; gap: 16px; } .primary-btn { background-color: #16a34a; color: white; padding: 12px 32px; border-radius: 8px; font-size: 16px; font-weight: 600; border: none; cursor: pointer; transition: all 0.3s ease; } .primary-btn:hover { background-color: #15803d; } .secondary-btn { background-color: white; color: #16a34a; border: 2px solid #16a34a; padding: 12px 32px; border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.3s ease; } .secondary-btn:hover { background-color: #f0fdf4; } .btn-icon { margin-right: 8px; } .primary-btn, .secondary-btn { display: flex; align-items: center; justify-content: center; } </style>
2302_81331056/travel
src/components/visa/VisaHero.vue
Vue
unknown
2,867
<script setup> import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { library } from '@fortawesome/fontawesome-svg-core' import { faClock, faLocationDot, faMap, faPassport, faInfoCircle } from '@fortawesome/free-solid-svg-icons' library.add(faClock, faLocationDot, faMap, faPassport, faInfoCircle) </script> <template> <section class="visa-policy"> <div class="container"> <h2 class="section-title">最新过境免签政策</h2> <div class="policy-cards"> <div class="policy-card"> <div class="icon-container"> <font-awesome-icon :icon="faClock" class="policy-icon" /> </div> <h3>停留时间延长</h3> <p>过境免签停留时间由原72小时和144小时均延长至<strong>240小时(10天)</strong></p> </div> <div class="policy-card"> <div class="icon-container"> <font-awesome-icon :icon="faLocationDot" class="policy-icon" /> </div> <h3>扩大入境口岸</h3> <p>新增21个过境免签入出境口岸,适用口岸从39个增加至<strong>60个</strong></p> </div> <div class="policy-card"> <div class="icon-container"> <font-awesome-icon :icon="faMap" class="policy-icon" /> </div> <h3>扩大活动区域</h3> <p>活动区域扩大至<strong>24个省(区、市)</strong>,并允许在这些区域内跨省域旅行</p> </div> <div class="policy-card"> <div class="icon-container"> <font-awesome-icon :icon="faPassport" class="policy-icon" /> </div> <h3>适用54国公民</h3> <p>符合条件的<strong>俄罗斯、巴西、英国、美国、加拿大</strong>等54国公民可享受此政策</p> </div> </div> <div class="policy-notice"> <h4> <font-awesome-icon :icon="faInfoCircle" class="notice-icon" /> 政策说明 </h4> <p>此次放宽优化过境免签政策是中国为促进高水平对外开放、便利中外人员往来的重要举措,有利于加快推动人员跨境流动,促进对外交流合作,为经济社会高质量发展注入新动能。</p> <p class="source">信息来源:<a href="https://www.gov.cn/lianbo/bumen/202412/content_6993129.htm" target="_blank">中国政府网</a></p> </div> </div> </section> </template> <style scoped> .visa-policy { padding: 80px 0; background-color: white; } .container { max-width: 1200px; margin: 0 auto; padding: 0 20px; } .section-title { text-align: center; font-size: 36px; color: #1a3a5f; margin-bottom: 60px; position: relative; } .section-title:after { content: ''; position: absolute; bottom: -15px; left: 50%; transform: translateX(-50%); width: 80px; height: 4px; background-color: #16a34a; border-radius: 2px; } .policy-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 30px; margin-bottom: 60px; } .policy-card { background-color: #f8fafc; border-radius: 12px; padding: 30px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); transition: transform 0.3s ease, box-shadow 0.3s ease; } .policy-card:hover { transform: translateY(-5px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.09); } .icon-container { width: 70px; height: 70px; background-color: #e6f7ef; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; } .policy-card h3 { font-size: 20px; color: #2d3748; margin-bottom: 15px; } .policy-card p { color: #4a5568; line-height: 1.6; } .policy-notice { background-color: #f0fdf4; border-left: 4px solid #16a34a; padding: 30px; border-radius: 8px; margin-top: 40px; } .policy-notice h4 { font-size: 22px; color: #16a34a; margin-bottom: 15px; } .policy-notice p { color: #4a5568; line-height: 1.7; margin-bottom: 10px; } .source { font-size: 14px; color: #718096; margin-top: 20px; } .source a { color: #16a34a; text-decoration: none; } .source a:hover { text-decoration: underline; } .policy-icon { font-size: 32px; color: #16a34a; } .policy-notice h4 { display: flex; align-items: center; gap: 8px; } .notice-icon { font-size: 24px; color: #16a34a; } </style>
2302_81331056/travel
src/components/visa/VisaPolicy.vue
Vue
unknown
4,420
import { createI18n } from 'vue-i18n'; import zh from './locales/zh.js'; import en from './locales/en.js'; const i18n = createI18n({ legacy: false, // 使用Composition API模式 locale: localStorage.getItem('locale') || 'zh', // 默认语言 fallbackLocale: 'zh', // 备用语言 messages: { zh, en } }); export default i18n;
2302_81331056/travel
src/i18n/index.js
JavaScript
unknown
347
export default { navigation: { home: 'Home', visa: 'Visa', payment: 'Payment', travel: 'Travel', forum: 'Forum', login: 'Login/Register' }, hero: { year: '2025', titleLine1: 'Visa-Free Travel to China:', titleLine2: 'Citizens of 12 Countries', titleLine3: 'Explore China Without Barriers', subtitle: 'Enjoy your journey in China with new visa-free policy!' }, search: { placeholder: 'Search destinations, attractions, activities...', visa: { title: 'Visa', subtitle: 'Where are you going?' }, itinerary: { title: 'Itinerary', subtitle: 'Add Dates' }, transport: { title: 'Transport', subtitle: 'All Activity' }, personal: { title: 'Personal', subtitle: 'Personal information' } }, language: { chinese: '中文', english: 'English' }, login: { welcome: 'Welcome Back', subtitle: 'Login to your account to start exploring China', username: 'Username', password: 'Password', usernamePlace: 'Enter your username', passwordPlace: 'Enter your password', remember: 'Remember me', forgot: 'Forgot password?', button: 'Login', loading: 'Logging in...', error: 'Please enter username and password', divider: 'Or login with social accounts', noAccount: 'Don\'t have an account?', register: 'Register now' }, payment: { title: 'Convenient Payment for Your China Journey', subtitle: 'Payment Guide', description: 'In China, mobile payment has become the most common payment method. This guide will help you understand how to use WeChat Pay and Alipay to make your trip more convenient.', wechat: { title: 'WeChat Pay', description: 'China\'s most popular social payment platform' }, alipay: { title: 'Alipay', description: 'The payment platform of Alibaba Group' }, steps: { title: 'Setup Steps', next: 'Next', prev: 'Previous', wechat: { step1: { title: 'Download WeChat', desc: 'Download and install WeChat from App Store or Google Play' }, step2: { title: 'Register an Account', desc: 'Register a WeChat account with your phone number, preferably with international roaming' }, step3: { title: 'Link Bank Card', desc: 'Go to "Me" → "Pay" → "Wallet" to link your international credit card' }, step4: { title: 'Enable Payment', desc: 'Complete identity verification to enable payment function' } }, alipay: { step1: { title: 'Download Alipay', desc: 'Download and install Alipay from App Store or Google Play' }, step2: { title: 'Register an Account', desc: 'Register an Alipay account with your phone number' }, step3: { title: 'Link Bank Card', desc: 'Go to "Me" → "Bank Cards" to link your international credit card' }, step4: { title: 'Complete Verification', desc: 'Complete identity verification to enable payment function' } } }, tips: { title: 'Usage Tips', cards: { title: 'Supported International Cards', desc: 'Visa, Mastercard, American Express and other major international credit cards' }, security: { title: 'Secure Payment', desc: 'All transactions are encrypted to ensure payment security' }, exchange: { title: 'Currency Conversion', desc: 'Automatic conversion at real-time exchange rates' }, offline: { title: 'Offline Payment', desc: 'Some scenarios support offline payment without network connection' } }, faq: { title: 'Frequently Asked Questions', q1: { question: 'Do I need a Chinese phone number to register?', answer: 'No. You can register with an international phone number, but it\'s recommended to use international roaming to ensure you can receive verification codes.' }, q2: { question: 'Are there extra fees for linking international credit cards?', answer: 'Linking the card itself is free, but using the credit card for payment may incur cross-border transaction fees. Please consult your card issuer for details.' }, q3: { question: 'What are the payment limits?', answer: 'Payment limits vary based on your verification level and the type of bank card linked. Generally, single transaction limits range from 5,000 to 20,000 yuan.' }, q4: { question: 'What should I do if I encounter payment issues?', answer: 'You can call the customer service hotline (WeChat Pay: 95017, Alipay: 95188), or contact our customer service team for assistance.' } } } };
2302_81331056/travel
src/i18n/locales/en.js
JavaScript
unknown
4,941
export default { navigation: { home: '首页', visa: '政策', payment: '支付', travel: '旅行', forum: '论坛', login: '登录/注册' }, hero: { year: '2025', titleLine1: '免签开启中国之旅:', titleLine2: '12国公民', titleLine3: '畅行无阻游华夏', subtitle: 'Visa-free entry in 2025, come and visit China now!' }, search: { placeholder: '搜索目的地、景点、活动...', visa: { title: '政策', subtitle: 'Where are you going?' }, itinerary: { title: '日程', subtitle: 'Add Dates' }, transport: { title: '交通', subtitle: 'All Activity' }, personal: { title: '个人', subtitle: 'Personal information' } }, language: { chinese: '中文', english: 'English' }, login: { welcome: '欢迎回来', subtitle: '登录您的账户,开始探索中国之旅', username: '用户名', password: '密码', usernamePlace: '请输入用户名', passwordPlace: '请输入密码', remember: '记住我', forgot: '忘记密码?', button: '登录', loading: '登录中...', error: '请输入用户名和密码', divider: '或使用社交账号登录', noAccount: '还没有账号?', register: '立即注册' }, payment: { title: '便捷支付,轻松游中国', subtitle: '支付指南', description: '在中国,移动支付已成为最普遍的支付方式。本指南将帮助您了解如何使用微信支付和支付宝,让您的中国之旅更加便捷。', wechat: { title: '微信支付', description: '中国最受欢迎的社交支付平台' }, alipay: { title: '支付宝', description: '阿里巴巴旗下的支付平台' }, steps: { title: '设置步骤', next: '下一步', prev: '上一步', wechat: { step1: { title: '下载微信', desc: '从 App Store 或 Google Play 下载并安装微信(WeChat)' }, step2: { title: '注册账号', desc: '使用手机号注册微信账号,建议使用国际漫游号码' }, step3: { title: '绑定银行卡', desc: '在"我"→"支付"→"钱包"中绑定国际信用卡' }, step4: { title: '开通支付功能', desc: '完成实名认证,开通支付功能' } }, alipay: { step1: { title: '下载支付宝', desc: '从 App Store 或 Google Play 下载并安装支付宝(Alipay)' }, step2: { title: '注册账号', desc: '使用手机号注册支付宝账号' }, step3: { title: '绑定银行卡', desc: '在"我的"→"银行卡"中绑定国际信用卡' }, step4: { title: '完成认证', desc: '完成实名认证,开通支付功能' } } }, tips: { title: '使用提示', cards: { title: '支持的国际卡', desc: 'Visa、Mastercard、American Express等主流国际信用卡' }, security: { title: '安全支付', desc: '所有交易都经过加密处理,确保支付安全' }, exchange: { title: '汇率转换', desc: '自动按实时汇率进行货币转换' }, offline: { title: '离线支付', desc: '部分场景支持离线支付,无需网络连接' } }, faq: { title: '常见问题', q1: { question: '我需要中国手机号才能注册吗?', answer: '不需要。您可以使用国际手机号注册,但建议使用国际漫游号码以确保能收到验证码。' }, q2: { question: '绑定国际信用卡需要额外费用吗?', answer: '绑定信用卡本身是免费的,但使用信用卡支付可能会产生跨境交易手续费,具体费用请咨询您的发卡银行。' }, q3: { question: '支付限额是多少?', answer: '根据您的实名认证等级和绑定的银行卡类型,支付限额会有所不同。一般单笔支付限额在5000-20000元不等。' }, q4: { question: '如果遇到支付问题怎么办?', answer: '您可以拨打支付平台的客服热线(微信支付:95017,支付宝:95188),或联系我们的客服团队获取帮助。' } } } };
2302_81331056/travel
src/i18n/locales/zh.js
JavaScript
unknown
4,569
import '@/assets/main.css' import { createApp } from 'vue' import { createPinia } from 'pinia' // 导入FontAwesome相关库 import { library } from '@fortawesome/fontawesome-svg-core' import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' import { fas } from '@fortawesome/free-solid-svg-icons' import App from './App.vue' import router from './router' import i18n from './i18n' // 导入富文本编辑器样式 import '@vueup/vue-quill/dist/vue-quill.snow.css'; // 将所有图标添加到库中 library.add(fas) const app = createApp(App) app.use(createPinia()) app.use(router) app.use(i18n) // 注册FontAwesomeIcon为全局组件 app.component('font-awesome-icon', FontAwesomeIcon) app.mount('#app')
2302_81331056/travel
src/main.js
JavaScript
unknown
723
<script setup> import { ref, onMounted, computed } from 'vue'; import BaseLayout from '@/views/layout/BaseLayout.vue'; // ... existing code ... </script>
2302_81331056/travel
src/orders/index.vue
Vue
unknown
155
import { useAuthStore } from '@/stores/auth' /** * 需要身份验证的路由守卫 * 用于保护需要登录才能访问的路由 */ export const authGuard = async (to, from, next) => { const authStore = useAuthStore() // 使用增强的验证方法 const isValidLogin = await authStore.validateLogin() if (!isValidLogin) { // 用户未登录或登录状态无效,重定向到登录页面 console.log('登录验证失败,重定向到登录页面') next({ path: '/login', query: { redirect: to.fullPath } // 保存原本要访问的路径,便于登录后重定向 }) } else { console.log('登录验证成功,允许访问') // 用户已登录且验证通过,允许访问 next() } } /** * 游客路由守卫 * 用于限制已登录用户访问特定页面(如登录页) */ export const guestGuard = (to, from, next) => { const authStore = useAuthStore() if (authStore.isLoggedIn) { // 用户已登录,重定向到首页或之前尝试访问的页面 const redirectPath = to.query.redirect || '/' next({ path: redirectPath }) } else { // 用户未登录,允许访问 next() } } // 处理注册参数 export function handleRegisterParam(to, from, next) { // 如果URL中有register=true参数,则在组件中处理显示注册表单 if (to.path === '/login' && to.query.register === 'true') { to.params.showRegister = true } next() }
2302_81331056/travel
src/router/guards.js
JavaScript
unknown
1,459
import { createRouter, createWebHistory } from 'vue-router'; import { authGuard, guestGuard } from './guards'; import layout from '@/views/layout/index.vue'; import login from '@/views/login/index.vue'; import home from '@/views/layout/Home.vue'; import forum from '@/views/layout/Forum.vue'; import payment from '@/views/layout/Payment.vue'; import travel from '@/views/layout/travel.vue'; import visa from '@/views/layout/visa.vue'; import profile from '@/views/profile/index.vue'; import orders from '@/views/orders/index.vue'; import settings from '@/views/settings/index.vue'; const router = createRouter({ history: createWebHistory(), routes: [ { path: '/', component: home, meta: { title: '首页', requiresAuth: false, // 不需要身份验证 } }, { path: '/login', component: login, meta: { title: '登录/注册', guest: true, // 仅限游客访问 } }, { path: '/profile', component: profile, meta: { title: '个人资料', requiresAuth: true, // 需要身份验证 } }, { path: '/forum', component: forum, meta: { title: '旅游论坛', requiresAuth: false, // 不需要身份验证 } }, { path: '/payment', component: payment, meta: { title: '支付', requiresAuth: true, // 需要身份验证 } }, { path: '/travel', component: travel, meta: { title: '旅游', requiresAuth: false, // 不需要身份验证 } }, { path: '/visa', component: visa, meta: { title: '签证信息', requiresAuth: false, // 明确设置不需要身份验证 } }, { path: '/orders', component: orders, meta: { title: '我的订单', requiresAuth: true, // 需要身份验证 } }, { path: '/settings', component: settings, meta: { title: '设置', requiresAuth: true, // 需要身份验证 } }, { path: '/dashboard', component: layout, meta: { title: '控制面板', requiresAuth: true, // 需要身份验证 } }, { path: '/:pathMatch(.*)*', // 匹配所有未定义的路由 component: login, meta: { title: '页面不存在', } } ] }); // 全局前置守卫 router.beforeEach(async (to, from, next) => { // 设置页面标题 document.title = to.meta.title ? `${to.meta.title} - 旅行网站` : '旅行网站'; // 验证身份认证 if (to.meta.requiresAuth) { return authGuard(to, from, next); } // 验证游客状态 if (to.meta.guest) { return guestGuard(to, from, next); } // 其他情况直接放行 next(); }); export default router;
2302_81331056/travel
src/router/index.js
JavaScript
unknown
2,898
import { defineStore } from 'pinia'; import { ref } from 'vue'; export const useAiRouteStore = defineStore('aiRoute', () => { const currentRoute = ref([]); function setRoute(places) { currentRoute.value = places; } return { currentRoute, setRoute }; });
2302_81331056/travel
src/stores/aiRouteStore.js
JavaScript
unknown
279
import { defineStore } from 'pinia' import { ref, computed } from 'vue' import { login as loginApi, register as registerApi } from '@/api/login' // 认证信息持久化的localStorage键名 const TOKEN_KEY = 'user_token' const USER_INFO_KEY = 'user_info' export const useAuthStore = defineStore('auth', () => { // 状态 const token = ref(localStorage.getItem(TOKEN_KEY) || '') const userInfo = ref(JSON.parse(localStorage.getItem(USER_INFO_KEY) || '{}')) const isLoading = ref(false) const error = ref('') // getters const isLoggedIn = computed(() => { // 增强检查:确保token存在且userInfo不为空对象 return !!token.value && Object.keys(userInfo.value).length > 0 }) const username = computed(() => userInfo.value?.username || '') // actions // 设置token function setToken(newToken) { token.value = newToken localStorage.setItem(TOKEN_KEY, newToken) } // 设置用户信息 function setUserInfo(info) { userInfo.value = info localStorage.setItem(USER_INFO_KEY, JSON.stringify(info)) } // 登录 async function login(credentials) { isLoading.value = true error.value = '' try { const response = await loginApi(credentials) console.log('登录响应:', response) if (response.data && response.data.code === 200) { const data = response.data.data setToken(data.token) // 如果响应中包含用户信息,则保存 if (data.username) { setUserInfo({ username: data.username }) } return { success: true, data } } else { error.value = response.data?.message || '登录失败' return { success: false, message: error.value } } } catch (err) { console.error('登录错误:', err) error.value = err.response?.data?.message || '服务器连接失败' return { success: false, message: error.value } } finally { isLoading.value = false } } // 注册 async function register(userData) { isLoading.value = true error.value = '' try { const response = await registerApi(userData) if (response.data && response.data.code === 200) { const data = response.data.data // 如果注册后自动登录,保存token和用户信息 if (data.token) { setToken(data.token) } if (data.username) { setUserInfo({ username: data.username }) } return { success: true, data } } else { error.value = response.data?.message || '注册失败' return { success: false, message: error.value } } } catch (err) { console.error('注册错误:', err) error.value = err.response?.data?.message || '服务器连接失败' return { success: false, message: error.value, field: err.response?.data?.field } } finally { isLoading.value = false } } // 登出 function logout() { token.value = '' userInfo.value = {} localStorage.removeItem(TOKEN_KEY) localStorage.removeItem(USER_INFO_KEY) } // 验证登录状态 async function validateLogin() { // 如果本地没有token或用户信息,直接返回未登录状态 if (!token.value || Object.keys(userInfo.value).length === 0) { return false; } // 在这里可以添加对后端的token验证请求 // 如果有专门的验证接口,可以在这里调用 // 例如: /* try { const response = await api.validateToken(); return response.data?.code === 200; } catch (error) { console.error('验证登录状态出错:', error); // 验证失败,清除本地存储的登录信息 logout(); return false; } */ // 为了演示,这里暂时返回true return true; } return { // 状态 token, userInfo, isLoading, error, // getters isLoggedIn, username, // actions setToken, setUserInfo, login, register, logout, validateLogin } })
2302_81331056/travel
src/stores/auth.js
JavaScript
unknown
4,084
import { ref, computed } from 'vue' import { defineStore } from 'pinia' export const useCounterStore = defineStore('counter', () => { const count = ref(0) const doubleCount = computed(() => count.value * 2) function increment() { count.value++ } return { count, doubleCount, increment } })
2302_81331056/travel
src/stores/counter.js
JavaScript
unknown
306
import { defineStore } from 'pinia'; import axios from 'axios'; export const useUserStore = defineStore('user', { state: () => ({ token: localStorage.getItem('token') || '', user: JSON.parse(localStorage.getItem('user') || '{}'), }), getters: { isLoggedIn: (state) => !!state.token, userProfile: (state) => state.user, }, actions: { // 设置认证信息 setAuth(token, user) { this.token = token; this.user = user; // 保存到本地存储 localStorage.setItem('token', token); localStorage.setItem('user', JSON.stringify(user)); // 设置 axios 默认请求头 axios.defaults.headers.common['Authorization'] = `Bearer ${token}`; }, // 清除认证信息 clearAuth() { this.token = ''; this.user = {}; // 从本地存储中移除 localStorage.removeItem('token'); localStorage.removeItem('user'); // 移除请求头中的认证信息 delete axios.defaults.headers.common['Authorization']; }, // 登录操作 async login(credentials) { try { // 这里应该调用你的实际登录 API const response = await axios.post('/api/login', credentials); const { token, user } = response.data; this.setAuth(token, user); return true; } catch (error) { console.error('登录失败:', error); return false; } }, // 注册操作 async register(userData) { try { // 这里应该调用你的实际注册 API const response = await axios.post('/api/register', userData); const { token, user } = response.data; this.setAuth(token, user); return true; } catch (error) { console.error('注册失败:', error); return false; } }, // 登出操作 async logout() { try { // 如果需要,这里可以调用登出 API // await axios.post('/api/logout'); this.clearAuth(); return true; } catch (error) { console.error('登出失败:', error); return false; } }, // 初始化身份验证状态(在应用启动时调用) initAuth() { const token = localStorage.getItem('token'); if (token) { axios.defaults.headers.common['Authorization'] = `Bearer ${token}`; } } } });
2302_81331056/travel
src/stores/user.js
JavaScript
unknown
2,439
// 认证相关的工具函数 // 存储用户token的key const TokenKey = 'user_token' // 存储用户信息的key const UserKey = 'user_info' // 存储用户列表的key const UsersKey = 'users_list' // 存储是否首次访问的key const FirstVisitKey = 'first_visit' /** * 获取token * @returns {string|null} 返回存储的token或null */ export function getToken() { return localStorage.getItem(TokenKey) } /** * 设置token * @param {string} token 要存储的token */ export function setToken(token) { return localStorage.setItem(TokenKey, token) } /** * 移除token */ export function removeToken() { return localStorage.removeItem(TokenKey) } /** * 获取用户信息 * @returns {Object|null} 返回用户信息对象或null */ export function getUserInfo() { const userInfo = localStorage.getItem(UserKey) return userInfo ? JSON.parse(userInfo) : null } /** * 设置用户信息 * @param {Object} userInfo 用户信息对象 */ export function setUserInfo(userInfo) { return localStorage.setItem(UserKey, JSON.stringify(userInfo)) } /** * 移除用户信息 */ export function removeUserInfo() { return localStorage.removeItem(UserKey) } /** * 检查用户是否已登录 * @returns {boolean} 是否已登录 */ export function isLoggedIn() { const token = getToken(); const userInfo = getUserInfo(); // 检查token和用户信息是否都存在 if (!token || !userInfo) { return false; } // 如果token中包含过期时间信息,可以进一步检查 // 这里假设token可能是JWT格式,可以解析检查过期时间 try { // 如果需要解析JWT,可以添加相关逻辑 // 这里仅做简单检查,确保token和用户信息都存在 return true; } catch (error) { console.error('登录状态检查出错:', error); return false; } } /** * 用户登录 * @param {string} token 登录token * @param {Object} userInfo 用户信息 */ export function login(token, userInfo) { setToken(token) setUserInfo(userInfo) } /** * 用户登出 */ export function logout() { removeToken() removeUserInfo() } /** * 获取所有注册用户 * @returns {Array} 返回用户列表 */ export function getUsers() { const users = localStorage.getItem(UsersKey) return users ? JSON.parse(users) : [] } /** * 添加新用户 * @param {Object} user 用户信息对象 * @returns {boolean} 是否注册成功 */ export function register(user) { const users = getUsers() // 检查用户名是否已存在 if (users.some(existingUser => existingUser.username === user.username)) { return false } // 添加注册时间 user.registerTime = Date.now() // 添加新用户 users.push(user) localStorage.setItem(UsersKey, JSON.stringify(users)) return true } /** * 检查是否是首次访问 * @returns {boolean} 是否首次访问 */ export function isFirstVisit() { return localStorage.getItem(FirstVisitKey) === null } /** * 设置已访问标记 */ export function setVisited() { localStorage.setItem(FirstVisitKey, 'visited') } /** * 验证登录状态 - 用于在切换路由或刷新页面时重新验证 * @returns {Promise<boolean>} 是否通过验证 */ export function validateLoginState() { return new Promise((resolve) => { // 首先检查本地存储中的登录信息 if (!isLoggedIn()) { resolve(false); return; } // 在这里可以添加额外的验证逻辑,例如调用后端API验证token是否有效 // 如果有专门的验证接口,可以在这里调用 // 这里我们暂时返回true,表示验证通过 resolve(true); }); }
2302_81331056/travel
src/utils/auth.js
JavaScript
unknown
3,671
import axios from 'axios' import { ElMessage } from 'element-plus' import router from '@/router' // 创建axios实例 const instance = axios.create({ // baseURL 设置为空,使用相对路径,让Vite代理接管 baseURL: '', timeout: 10000, }) // 请求拦截器 - 不直接引入store,因为可能导致循环依赖 // 在请求时动态获取store中的token instance.interceptors.request.use( (config) => { // 尝试从localStorage获取token const token = localStorage.getItem('user_token') if (token) { config.headers['Authorization'] = `Bearer ${token}` } return config }, (error) => { return Promise.reject(error) } ) // 响应拦截器 instance.interceptors.response.use( (res) => { // 检查返回的数据结构 if (res.data) { return res // 返回整个响应,让调用方处理具体的业务逻辑 } return Promise.reject(res) // 拒绝promise并返回错误数据 }, (err) => { // 处理HTTP错误 let message = '请求失败' if (err.response) { // 服务器返回错误状态码 const status = err.response.status switch (status) { case 401: message = '未授权,请重新登录' // 可以在这里处理登出逻辑 localStorage.removeItem('user_token') localStorage.removeItem('user_info') // 重定向到登录页 router.push('/login') break case 403: message = '拒绝访问' break case 404: message = '请求的资源不存在' break case 500: message = '服务器内部错误' break default: message = `请求错误(${status})` } } else if (err.request) { // 请求发出但没有收到响应 message = '网络错误,服务器没有响应' } console.error('请求错误:', message, err) return Promise.reject(err) // 拒绝promise并返回错误 } ) export default instance
2302_81331056/travel
src/utils/request.js
JavaScript
unknown
2,357
<script setup> import { ref, computed, onMounted } from 'vue'; import { useRouter, useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; import TheHeader from '@/components/home/TheHeader.vue'; import TheFooter from '@/components/home/TheFooter.vue'; import { isFirstVisit, setVisited } from '@/utils/auth'; // 导入登录/注册相关组件 import FormTabs from '@/components/com_login/FormTabs.vue'; import FormHeader from '@/components/com_login/FormHeader.vue'; import LoginForm from '@/components/com_login/LoginForm.vue'; import RegisterForm from '@/components/com_login/RegisterForm.vue'; const { t } = useI18n(); const router = useRouter(); const route = useRoute(); // 页面加载时检查是否是首次访问,或者URL包含register参数 onMounted(() => { if (route.query.register === 'true') { activeTabIndex.value = 1; // 切换到注册表单 } else if (isFirstVisit()) { setVisited(); // 设置已访问标记 activeTabIndex.value = 1; // 切换到注册表单 } }); // 表单标签页配置 const tabs = [ { label: '登录', icon: 'fas fa-sign-in-alt' }, { label: '注册', icon: 'fas fa-user-plus' } ]; // 当前激活的标签页 const activeTabIndex = ref(0); // 处理标签页切换 const handleTabChange = (index) => { activeTabIndex.value = index; // 更新URL,但不重新加载页面 const query = index === 1 ? { register: 'true' } : {}; router.replace({ path: '/login', query }); }; // 处理登录成功 const handleLoginSuccess = (userData) => { // 显示登录成功提示 console.log('登录成功:', userData); // 如果有重定向参数,则跳转到该页面 if (route.query.redirect) { router.push(route.query.redirect); } else { // 否则跳转到首页 router.push('/'); } }; // 处理注册成功 const handleRegisterSuccess = () => { // 3秒后自动切换到登录表单 setTimeout(() => { router.replace('/login'); }, 3000); }; // 切换到注册表单 const switchToRegister = () => { handleTabChange(1); }; // 切换到登录表单 const switchToLogin = () => { handleTabChange(0); }; </script> <template> <div class="login-page"> <TheHeader /> <div class="login-content"> <div class="login-container"> <div class="login-form-wrapper"> <!-- 表单标签页 --> <FormTabs :tabs="tabs" :activeTab="activeTabIndex" @tab-change="handleTabChange" /> <!-- 登录表单 --> <div v-if="activeTabIndex === 0" class="form-container login-form-container"> <FormHeader title="欢迎回来" description="请登录您的账号,开始您的旅程" /> <LoginForm @login-success="handleLoginSuccess" /> </div> <!-- 注册表单 --> <div v-if="activeTabIndex === 1" class="form-container register-form-container"> <RegisterForm @register-success="handleRegisterSuccess" :onSwitchToLogin="switchToLogin" /> </div> </div> <div class="login-image"> <!-- 这里使用一个中国旅游相关的背景图 --> </div> </div> </div> <TheFooter /> </div> </template> <style scoped> .login-page { min-height: 100vh; background-color: #f5f8fa; display: flex; flex-direction: column; } .login-content { flex: 1; display: flex; justify-content: center; align-items: center; padding: 60px 20px; height: 800px; /* 固定高度 */ } .login-container { width: 1000px; /* 固定宽度 */ height: 680px; /* 固定高度 */ display: flex; border-radius: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08); overflow: hidden; background-color: #fff; } .login-form-wrapper { width: 500px; /* 固定宽度 */ padding: 30px 50px 50px; background-color: #fff; overflow-y: visible; /* 改为visible,不使用滚动条 */ height: 680px; /* 固定高度,与container一致 */ } .form-container { height: 100%; display: flex; flex-direction: column; } /* 登录表单容器样式 */ .login-form-container { padding-top: 10px; } /* 注册表单容器样式 */ .register-form-container { padding-top: 20px; /* 给注册表单一些顶部空间 */ } /* 调整表单头部比例 */ .form-container > .form-header { flex: 0 0 auto; margin-bottom: 20px; } /* 调整表单比例 */ .form-container > form, .form-container > .register-form, .form-container > .login-form { flex: 1 0 auto; } .login-image { width: 500px; /* 固定宽度 */ background-image: url('@/assets/login/login-bg1.jpg'); /* 使用占位图,后续替换 */ background-size: cover; background-position: center; position: relative; } .login-image::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; mix-blend-mode: multiply; } .register-link { text-align: center; font-size: 0.9rem; color: #666; margin-top: 20px; } .register-link a { color: #00c389; text-decoration: none; font-weight: 500; transition: color 0.3s; } .register-link a:hover { color: #00a572; text-decoration: underline; } /* 响应式样式 */ @media (max-width: 1100px) { .login-container { width: 800px; } .login-form-wrapper { width: 450px; } .login-image { width: 350px; } } @media (max-width: 992px) { .login-container { flex-direction: column-reverse; width: 500px; height: 700px; } .login-image { width: 100%; height: 200px; } .login-form-wrapper { width: 100%; height: 500px; padding: 30px 40px 40px; overflow-y: visible; /* 确保在中等屏幕也不使用滚动条 */ } } @media (max-width: 576px) { .login-content { padding: 30px 15px; height: auto; } .login-container { width: 100%; height: auto; min-height: 600px; } .login-form-wrapper { height: auto; min-height: 400px; padding: 20px 20px 30px; overflow-y: visible; /* 确保在小屏幕也不使用滚动条 */ } } </style>
2302_81331056/travel
src/views/login/index.vue
Vue
unknown
6,199
<script setup> import { ref, onMounted, computed } from 'vue'; import BaseLayout from '@/views/layout/BaseLayout.vue'; const isLoaded = ref(false); const activeTab = ref('all'); // 图片资源导入 const explore1 = new URL('@/assets/home/explore1.jpg', import.meta.url).href; const explore3 = new URL('@/assets/home/explore3.jpg', import.meta.url).href; const explore5 = new URL('@/assets/home/explore5.jpg', import.meta.url).href; // 模拟订单数据 const orders = ref([ { id: 'OD2023121501', title: '北京三日游', date: '2023-12-15', status: 'completed', amount: 1299, image: explore1 }, { id: 'OD2023121002', title: '上海外滩一日游', date: '2023-12-10', status: 'processing', amount: 499, image: explore3 }, { id: 'OD2023110503', title: '重庆两江夜游', date: '2023-11-05', status: 'canceled', amount: 299, image: explore5 } ]); const filteredOrders = computed(() => { if (activeTab.value === 'all') { return orders.value; } return orders.value.filter(order => order.status === activeTab.value); }); const setActiveTab = (tab) => { activeTab.value = tab; }; onMounted(() => { setTimeout(() => { isLoaded.value = true; }, 300); }); </script> <template> <BaseLayout> <div class="orders-container" :class="{ 'loaded': isLoaded }"> <div class="orders-header"> <h1 class="page-title">我的订单</h1> <p class="page-subtitle">查看和管理您的旅行订单</p> </div> <div class="orders-tabs"> <div class="tab-item" :class="{ 'active': activeTab === 'all' }" @click="setActiveTab('all')" > 全部订单 </div> <div class="tab-item" :class="{ 'active': activeTab === 'processing' }" @click="setActiveTab('processing')" > 进行中 </div> <div class="tab-item" :class="{ 'active': activeTab === 'completed' }" @click="setActiveTab('completed')" > 已完成 </div> <div class="tab-item" :class="{ 'active': activeTab === 'canceled' }" @click="setActiveTab('canceled')" > 已取消 </div> </div> <div class="orders-list"> <div v-for="(order, index) in filteredOrders" :key="order.id" class="order-card" :style="{ animationDelay: `${index * 0.1}s`, }" > <div class="order-image"> <img :src="order.image" :alt="order.title"> </div> <div class="order-content"> <div class="order-info"> <h3 class="order-title">{{ order.title }}</h3> <p class="order-id">订单号: {{ order.id }}</p> <p class="order-date">下单日期: {{ order.date }}</p> </div> <div class="order-status-price"> <span class="order-status" :class="{ 'completed': order.status === 'completed', 'processing': order.status === 'processing', 'canceled': order.status === 'canceled' }" > {{ order.status === 'completed' ? '已完成' : order.status === 'processing' ? '进行中' : '已取消' }} </span> <p class="order-price">¥{{ order.amount }}</p> </div> </div> <div class="order-actions"> <button class="action-btn details-btn">查看详情</button> <button class="action-btn" :class="{ 'review-btn': order.status === 'completed', 'cancel-btn': order.status === 'processing', 'rebuy-btn': order.status === 'canceled' }" > {{ order.status === 'completed' ? '评价' : order.status === 'processing' ? '取消' : '再次购买' }} </button> </div> </div> <div v-if="filteredOrders.length === 0" class="no-orders"> <i class="fas fa-file-alt no-orders-icon"></i> <p>没有找到订单</p> </div> </div> </div> </BaseLayout> </template> <style scoped> .orders-container { max-width: 1200px; margin: 40px auto; padding: 0 20px; opacity: 0; transform: translateY(20px); transition: all 0.5s ease; } .orders-container.loaded { opacity: 1; transform: translateY(0); } .orders-header { margin-bottom: 30px; text-align: center; animation: fadeIn 0.8s ease-out forwards; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } } .page-title { font-size: 2.4rem; color: #333; margin-bottom: 10px; } .page-subtitle { color: #666; font-size: 1.1rem; } .orders-tabs { display: flex; justify-content: center; margin-bottom: 30px; border-bottom: 1px solid #eee; } .tab-item { padding: 12px 25px; font-size: 1rem; color: #555; cursor: pointer; position: relative; transition: all 0.3s ease; } .tab-item:hover { color: #00c389; } .tab-item.active { color: #00c389; font-weight: 500; } .tab-item.active::after { content: ''; position: absolute; bottom: -1px; left: 0; width: 100%; height: 2px; background-color: #00c389; } .orders-list { display: flex; flex-direction: column; gap: 20px; } .order-card { display: flex; background-color: #fff; border-radius: 12px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05); overflow: hidden; transition: all 0.3s ease; animation: slideIn 0.5s ease-out forwards; opacity: 0; transform: translateY(20px); } @keyframes slideIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } .order-card:hover { transform: translateY(-5px); box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08); } .order-image { width: 180px; min-width: 180px; height: 140px; overflow: hidden; } .order-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; } .order-card:hover .order-image img { transform: scale(1.05); } .order-content { flex-grow: 1; padding: 20px; display: flex; justify-content: space-between; } .order-title { font-size: 1.2rem; color: #333; margin-bottom: 10px; } .order-id, .order-date { color: #666; font-size: 0.9rem; margin-bottom: 5px; } .order-status-price { text-align: right; } .order-status { display: inline-block; padding: 5px 10px; border-radius: 4px; font-size: 0.9rem; font-weight: 500; margin-bottom: 10px; } .order-status.completed { background-color: #e6f7ef; color: #00c389; } .order-status.processing { background-color: #e6f0ff; color: #4d7bf3; } .order-status.canceled { background-color: #feeae9; color: #f44336; } .order-price { font-size: 1.3rem; font-weight: 600; color: #333; } .order-actions { display: flex; flex-direction: column; justify-content: center; padding: 20px; gap: 10px; min-width: 120px; background-color: #f9f9f9; border-left: 1px solid #f0f0f0; } .action-btn { padding: 8px 0; border-radius: 6px; font-size: 0.9rem; cursor: pointer; transition: all 0.3s ease; border: none; width: 100%; } .details-btn { background-color: #f0f0f0; color: #555; } .details-btn:hover { background-color: #e0e0e0; } .review-btn { background-color: #00c389; color: white; } .review-btn:hover { background-color: #00b07b; } .cancel-btn { background-color: #ff5a5a; color: white; } .cancel-btn:hover { background-color: #ff3939; } .rebuy-btn { background-color: #4d7bf3; color: white; } .rebuy-btn:hover { background-color: #3d6ae3; } .no-orders { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 0; color: #888; animation: fadeIn 0.8s ease-out forwards; } .no-orders-icon { font-size: 4rem; margin-bottom: 20px; color: #ddd; } @media (max-width: 768px) { .order-card { flex-direction: column; } .order-image { width: 100%; height: 180px; } .order-content { flex-direction: column; } .order-status-price { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; text-align: left; } .order-actions { flex-direction: row; border-left: none; border-top: 1px solid #f0f0f0; } .action-btn { flex: 1; } .orders-tabs { overflow-x: auto; justify-content: flex-start; padding-bottom: 10px; } .tab-item { white-space: nowrap; padding: 10px 15px; } } </style>
2302_81331056/travel
src/views/orders/index.vue
Vue
unknown
9,012
<script setup> import { ref, reactive, onMounted, computed } from 'vue'; import { getUserInfo, setUserInfo } from '@/utils/auth'; import { getUserProfile, updateUserProfile } from '@/api/user'; import BaseLayout from '@/views/layout/BaseLayout.vue'; // 导入组件 import ProfileSidebar from '@/components/profile/ProfileSidebar.vue'; import ProfileForm from '@/components/profile/ProfileForm.vue'; import SecurityForm from '@/components/profile/SecurityForm.vue'; import NotificationSettings from '@/components/profile/NotificationSettings.vue'; import AlertMessage from '@/components/profile/AlertMessage.vue'; import GlobalStyles from '@/components/profile/GlobalStyles.vue'; // 获取用户信息 const currentUserInfo = getUserInfo() || {}; const isLoaded = ref(false); const activeSection = ref('profile'); const showSuccessMessage = ref(false); const showErrorMessage = ref(false); const errorMessage = ref(''); const isLoading = ref(false); // 添加加载状态 // 用户头像 const userAvatar = ref(currentUserInfo.avatar || ''); // 新选择的头像文件 const avatarFile = ref(null); // 头像预览数据 (用于本地预览,不发送到服务器) const avatarPreview = ref(''); // 服务器存储的头像URL const avatarUrl = ref(currentUserInfo.avatarUrl || currentUserInfo.avatar || ''); // 对话框状态 const showConfirmDialog = ref(false); // 表单数据 const formData = reactive({ username: currentUserInfo.username || '', lastName: '', firstName: '', email: '', phone: '', nationality: '', gender: '', travelPreference: '', language: 'zh' }); // 表单验证规则 const validateForm = () => { if (!formData.username.trim()) { errorMessage.value = '用户名不能为空'; showErrorMessage.value = true; return false; } if (formData.email && !isValidEmail(formData.email)) { errorMessage.value = '请输入有效的邮箱地址'; showErrorMessage.value = true; return false; } if (formData.phone && !isValidPhone(formData.phone)) { errorMessage.value = '请输入有效的手机号码'; showErrorMessage.value = true; return false; } return true; }; // 邮箱验证 const isValidEmail = (email) => { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return emailRegex.test(email); }; // 手机号验证 const isValidPhone = (phone) => { const phoneRegex = /^1[3-9]\d{9}$/; return phoneRegex.test(phone); }; // 保存防抖处理 let saveTimeout = null; // 保存用户信息 const saveUserInfo = async () => { // 防抖处理 if (saveTimeout) { clearTimeout(saveTimeout); } saveTimeout = setTimeout(async () => { // 重置消息状态 showSuccessMessage.value = false; showErrorMessage.value = false; if (!validateForm()) { return; } isLoading.value = true; try { // 准备请求数据 const requestData = { username: formData.username, lastName: formData.lastName, firstName: formData.firstName, email: formData.email, phone: formData.phone, nationality: formData.nationality, gender: formData.gender, preferredLanguage: formData.language, // 如果有新选择的头像,使用base64编码数据,否则使用现有URL avatarUrl: avatarPreview.value || avatarUrl.value }; console.log('正在保存用户数据:', requestData); // 调用API保存用户信息 const response = await updateUserProfile(requestData); console.log('更新用户信息响应:', response); if (response.data && response.data.code === 200) { // API调用成功,更新本地存储 const updatedUserInfo = { ...currentUserInfo, username: formData.username, lastName: formData.lastName, firstName: formData.firstName, email: formData.email, phone: formData.phone, nationality: formData.nationality, gender: formData.gender, preferredLanguage: formData.language, avatarUrl: avatarPreview.value || avatarUrl.value // 保存头像数据 }; // 将预览数据保存到URL变量中,因为现在它们都是base64编码 if (avatarPreview.value) { avatarUrl.value = avatarPreview.value; } // 清除头像文件缓存,但保留base64数据 avatarFile.value = null; avatarPreview.value = ''; setUserInfo(updatedUserInfo); showSuccessMessage.value = true; errorMessage.value = "个人信息已成功更新!"; // 3秒后隐藏成功消息 setTimeout(() => { showSuccessMessage.value = false; }, 3000); } else { // API调用失败,显示错误信息 errorMessage.value = response.data?.message || '保存信息失败,请稍后再试'; showErrorMessage.value = true; } } catch (error) { console.error('保存用户信息出错:', error); // 根据错误类型提供更详细的错误信息 if (error.response) { // 服务器返回了错误状态码 if (error.response.status === 401) { errorMessage.value = '登录已过期,请重新登录'; } else if (error.response.status === 403) { errorMessage.value = '您没有权限执行此操作'; } else if (error.response.status === 400) { errorMessage.value = error.response.data?.message || '请求数据格式不正确'; } else if (error.response.status === 500) { errorMessage.value = '服务器内部错误,请稍后再试'; } else { errorMessage.value = error.response.data?.message || '保存信息失败,请稍后再试'; } } else if (error.request) { // 请求已发送但没有收到响应 errorMessage.value = '网络连接失败,请检查您的网络连接'; } else { // 发送请求时出现错误 errorMessage.value = '保存失败,请稍后再试'; } showErrorMessage.value = true; } finally { isLoading.value = false; saveTimeout = null; } }, 300); // 300ms的防抖延迟 }; // 重置表单 const resetForm = () => { formData.username = currentUserInfo.username || ''; formData.lastName = currentUserInfo.lastName || ''; formData.firstName = currentUserInfo.firstName || ''; formData.email = currentUserInfo.email || ''; formData.phone = currentUserInfo.phone || ''; formData.nationality = currentUserInfo.nationality || ''; formData.gender = currentUserInfo.gender || ''; formData.language = currentUserInfo.preferredLanguage || 'zh'; // 重置头像为当前用户头像 avatarUrl.value = currentUserInfo.avatarUrl || currentUserInfo.avatar || ''; avatarPreview.value = ''; // 清除预览数据 avatarFile.value = null; showErrorMessage.value = false; showSuccessMessage.value = false; }; // 上传头像 const handleAvatarUpload = () => { // 创建文件输入元素 const fileInput = document.createElement('input'); fileInput.type = 'file'; fileInput.accept = 'image/*'; // 监听文件选择 fileInput.addEventListener('change', (e) => { if (e.target.files && e.target.files.length > 0) { const file = e.target.files[0]; // 文件类型检查 if (!file.type.startsWith('image/')) { errorMessage.value = '请选择图片文件'; showErrorMessage.value = true; return; } // 文件大小检查 (限制为2MB) if (file.size > 2 * 1024 * 1024) { errorMessage.value = '图片大小不能超过2MB'; showErrorMessage.value = true; return; } // 保存文件引用,等待与表单一起提交 avatarFile.value = file; // 为用户提供预览 const reader = new FileReader(); reader.onload = (event) => { avatarPreview.value = event.target.result; }; reader.readAsDataURL(file); showSuccessMessage.value = true; errorMessage.value = "头像已选择,点击保存更改按钮完成提交"; setTimeout(() => { showSuccessMessage.value = false; }, 3000); } }); // 触发文件选择 fileInput.click(); }; // 用户点击保存按钮 const handleSaveClick = () => { saveUserInfo(); }; onMounted(async () => { isLoading.value = true; try { // 调用API获取用户信息 const response = await getUserProfile(); console.log('获取用户信息响应:', response); // 处理API返回的数据 if (response.data && response.data.code === 200) { const userData = response.data.data; // 更新表单数据 formData.username = userData.username || currentUserInfo.username || ''; // 直接从用户数据中获取字段,而不是从profile对象 formData.lastName = userData.lastName || ''; formData.firstName = userData.firstName || ''; formData.email = userData.email || ''; formData.phone = userData.phone || ''; formData.nationality = userData.nationality || ''; formData.gender = userData.gender || ''; formData.language = userData.preferredLanguage || 'zh'; // 获取头像数据 - 现在是base64格式 if (userData.avatarUrl) { avatarUrl.value = userData.avatarUrl; } } else { // 如果API调用失败,尝试使用本地存储的用户信息 // 尝试直接从currentUserInfo获取 formData.lastName = currentUserInfo.lastName || ''; formData.firstName = currentUserInfo.firstName || ''; formData.email = currentUserInfo.email || ''; formData.phone = currentUserInfo.phone || ''; formData.nationality = currentUserInfo.nationality || ''; formData.gender = currentUserInfo.gender || ''; formData.language = currentUserInfo.preferredLanguage || 'zh'; // 如果还是找不到,再尝试旧的profile结构 if (currentUserInfo.profile) { if (!formData.lastName) formData.lastName = currentUserInfo.profile.lastName || ''; if (!formData.firstName) formData.firstName = currentUserInfo.profile.firstName || ''; if (!formData.email) formData.email = currentUserInfo.profile.email || ''; if (!formData.phone) formData.phone = currentUserInfo.profile.phone || ''; if (!formData.nationality) formData.nationality = currentUserInfo.profile.nationality || ''; if (!formData.gender) formData.gender = currentUserInfo.profile.gender || ''; if (formData.language === 'zh') formData.language = currentUserInfo.profile.language || 'zh'; } // 获取头像 if (currentUserInfo.avatarUrl) { avatarUrl.value = currentUserInfo.avatarUrl; } else if (currentUserInfo.avatar) { // 兼容旧数据 avatarUrl.value = currentUserInfo.avatar; } // 如果API返回了错误消息,可以选择显示 if (response.data?.message) { console.warn('获取用户信息失败:', response.data.message); } } } catch (error) { console.error('获取用户信息出错:', error); // 发生错误时尝试从本地用户信息直接获取 formData.lastName = currentUserInfo.lastName || ''; formData.firstName = currentUserInfo.firstName || ''; formData.email = currentUserInfo.email || ''; formData.phone = currentUserInfo.phone || ''; formData.nationality = currentUserInfo.nationality || ''; formData.gender = currentUserInfo.gender || ''; formData.language = currentUserInfo.preferredLanguage || 'zh'; // 再尝试旧的profile结构 if (currentUserInfo.profile) { if (!formData.lastName) formData.lastName = currentUserInfo.profile.lastName || ''; if (!formData.firstName) formData.firstName = currentUserInfo.profile.firstName || ''; if (!formData.email) formData.email = currentUserInfo.profile.email || ''; if (!formData.phone) formData.phone = currentUserInfo.profile.phone || ''; if (!formData.nationality) formData.nationality = currentUserInfo.profile.nationality || ''; if (!formData.gender) formData.gender = currentUserInfo.profile.gender || ''; if (formData.language === 'zh') formData.language = currentUserInfo.profile.language || 'zh'; } } finally { isLoading.value = false; // 设置页面加载状态,触发动画 setTimeout(() => { isLoaded.value = true; }, 300); } }); </script> <template> <BaseLayout> <!-- 引入全局样式组件 --> <GlobalStyles /> <div class="profile-container" :class="{ 'loaded': isLoaded }"> <div class="profile-header"> <h1 class="page-title">个人信息</h1> <p class="page-subtitle">管理您的个人资料和账户信息</p> </div> <!-- 加载状态指示器 --> <div v-if="isLoading" class="loading-overlay"> <div class="loading-spinner"> <i class="fas fa-circle-notch fa-spin"></i> <span>加载中...</span> </div> </div> <div class="profile-content"> <!-- 使用侧边栏组件,传递头像URL --> <ProfileSidebar :activeSection="activeSection" :avatar="avatarPreview || avatarUrl" @update:activeSection="activeSection = $event" @avatar-upload="handleAvatarUpload" /> <div class="profile-form"> <!-- 使用消息提示组件 --> <AlertMessage type="success" :message="errorMessage" :show="showSuccessMessage" /> <AlertMessage type="error" :message="errorMessage" :show="showErrorMessage" /> <!-- 根据活动菜单项显示不同的表单组件 --> <!-- 个人资料 --> <ProfileForm v-if="activeSection === 'profile'" :formData="formData" @update:formData="newData => Object.assign(formData, newData)" @save="handleSaveClick" @reset="resetForm" /> <!-- 账户安全 --> <SecurityForm v-if="activeSection === 'security'" /> <!-- 通知设置 --> <NotificationSettings v-if="activeSection === 'notifications'" /> </div> </div> </div> </BaseLayout> </template> <style scoped> /* 增加样式权重,确保样式正确应用 */ .profile-container { max-width: 1200px; margin: 40px auto; padding: 0 20px; opacity: 0.1; /* 改为0.1,确保内容在动画失败时仍然可见 */ transform: translateY(20px); transition: all 0.5s ease; position: relative; /* 添加相对定位,为加载指示器做准备 */ } .profile-container.loaded { opacity: 1 !important; /* 增加!important确保样式权重 */ transform: translateY(0) !important; } /* 加载状态指示器样式 */ .loading-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255, 255, 255, 0.8); display: flex; justify-content: center; align-items: center; z-index: 100; border-radius: 12px; } .loading-spinner { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #00c389; } .loading-spinner i { font-size: 3rem; } .loading-spinner span { font-size: 1rem; font-weight: 500; } .profile-header { margin-bottom: 30px; text-align: center; animation: fadeIn 0.8s ease-out forwards; } @keyframes fadeIn { 0% { opacity: 0.1; transform: translateY(-20px); } 100% { opacity: 1; transform: translateY(0); } } .page-title { font-size: 2.4rem !important; /* 增加!important确保样式权重 */ color: #333; margin-bottom: 10px; } .page-subtitle { color: #666; font-size: 1.1rem; } .profile-content { display: flex !important; /* 确保flex布局生效 */ gap: 30px; background-color: #fff; border-radius: 12px; box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05); overflow: hidden; } .profile-form { flex-grow: 1; padding: 30px; } @media (max-width: 992px) { .profile-content { flex-direction: column !important; } } @media (max-width: 768px) { .form-row { flex-direction: column; gap: 0; } .payment-buttons { flex-direction: column; } .add-payment-btn { width: 100%; } } </style>
2302_81331056/travel
src/views/profile/index.vue
Vue
unknown
16,635
<script setup> import { ref, onMounted } from 'vue'; import BaseLayout from '@/views/layout/BaseLayout.vue'; const isLoaded = ref(false); const activeSection = ref('account'); const setActiveSection = (section) => { activeSection.value = section; }; onMounted(() => { setTimeout(() => { isLoaded.value = true; }, 300); }); </script> <template> <BaseLayout> <div class="settings-container" :class="{ 'loaded': isLoaded }"> <div class="settings-header"> <h1 class="page-title">设置</h1> <p class="page-subtitle">管理您的账户设置和偏好</p> </div> <div class="settings-content"> <div class="settings-sidebar"> <div class="sidebar-item" :class="{ 'active': activeSection === 'account' }" @click="setActiveSection('account')" > <i class="fas fa-user-circle"></i> <span>账户设置</span> </div> <div class="sidebar-item" :class="{ 'active': activeSection === 'security' }" @click="setActiveSection('security')" > <i class="fas fa-shield-alt"></i> <span>安全与隐私</span> </div> <div class="sidebar-item" :class="{ 'active': activeSection === 'notifications' }" @click="setActiveSection('notifications')" > <i class="fas fa-bell"></i> <span>通知设置</span> </div> <div class="sidebar-item" :class="{ 'active': activeSection === 'preferences' }" @click="setActiveSection('preferences')" > <i class="fas fa-sliders-h"></i> <span>偏好设置</span> </div> </div> <div class="settings-main"> <!-- 账户设置 --> <div v-if="activeSection === 'account'" class="settings-section"> <h2 class="section-title">账户设置</h2> <div class="form-group"> <label>用户名</label> <input type="text" placeholder="您的用户名"> </div> <div class="form-group"> <label>电子邮箱</label> <input type="email" placeholder="您的电子邮箱"> <div class="hint">此邮箱地址将用于接收重要通知</div> </div> <div class="form-group"> <label>手机号码</label> <input type="tel" placeholder="您的手机号码"> </div> <button class="save-btn">保存更改</button> </div> <!-- 安全与隐私 --> <div v-if="activeSection === 'security'" class="settings-section"> <h2 class="section-title">安全与隐私</h2> <div class="form-group"> <label>更改密码</label> <input type="password" placeholder="当前密码"> <input type="password" placeholder="新密码" class="mt-3"> <input type="password" placeholder="确认新密码" class="mt-3"> </div> <div class="form-group toggle-group"> <label>双重认证</label> <div class="toggle-switch"> <input type="checkbox" id="toggle-2fa"> <label for="toggle-2fa"></label> </div> <div class="hint">启用双重认证后,登录时需要额外的验证步骤</div> </div> <div class="form-group toggle-group"> <label>隐私设置</label> <div class="toggle-switch"> <input type="checkbox" id="toggle-privacy" checked> <label for="toggle-privacy"></label> </div> <div class="hint">允许我们使用您的数据提供个性化服务</div> </div> <button class="save-btn">保存更改</button> </div> <!-- 通知设置 --> <div v-if="activeSection === 'notifications'" class="settings-section"> <h2 class="section-title">通知设置</h2> <div class="notification-group"> <div class="notification-item"> <div class="notification-info"> <h3>电子邮件通知</h3> <p>接收重要更新、订单确认和促销信息</p> </div> <div class="toggle-switch"> <input type="checkbox" id="toggle-email" checked> <label for="toggle-email"></label> </div> </div> <div class="notification-item"> <div class="notification-info"> <h3>短信通知</h3> <p>接收旅行提醒和重要更新</p> </div> <div class="toggle-switch"> <input type="checkbox" id="toggle-sms"> <label for="toggle-sms"></label> </div> </div> <div class="notification-item"> <div class="notification-info"> <h3>促销信息</h3> <p>接收关于特价优惠和新产品的信息</p> </div> <div class="toggle-switch"> <input type="checkbox" id="toggle-promo" checked> <label for="toggle-promo"></label> </div> </div> </div> <button class="save-btn">保存更改</button> </div> <!-- 偏好设置 --> <div v-if="activeSection === 'preferences'" class="settings-section"> <h2 class="section-title">偏好设置</h2> <div class="form-group"> <label>默认语言</label> <select> <option value="zh">中文</option> <option value="en">英文</option> </select> </div> <div class="form-group"> <label>旅行偏好</label> <select> <option value="">请选择旅行偏好</option> <option value="nature">自然风光</option> <option value="culture">历史文化</option> <option value="food">美食体验</option> <option value="adventure">冒险探索</option> <option value="relaxation">休闲放松</option> </select> </div> <button class="save-btn">保存更改</button> </div> </div> </div> </div> </BaseLayout> </template> <style scoped> .settings-container { max-width: 1200px; margin: 40px auto; padding: 0 20px; opacity: 0; transform: translateY(20px); transition: all 0.5s ease; } .settings-container.loaded { opacity: 1; transform: translateY(0); } .settings-header { margin-bottom: 30px; text-align: center; animation: fadeIn 0.8s ease-out forwards; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } } .page-title { font-size: 2.4rem; color: #333; margin-bottom: 10px; } .page-subtitle { color: #666; font-size: 1.1rem; } .settings-content { display: flex; gap: 30px; background-color: #fff; border-radius: 12px; box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05); overflow: hidden; } .settings-sidebar { width: 280px; background-color: #f8f9fa; padding: 20px 0; border-right: 1px solid #eee; } .sidebar-item { display: flex; align-items: center; padding: 15px 25px; cursor: pointer; transition: all 0.3s ease; position: relative; color: #555; } .sidebar-item i { margin-right: 15px; font-size: 1.1rem; width: 20px; text-align: center; } .sidebar-item:hover { background-color: #f0f9f6; color: #00c389; } .sidebar-item.active { background-color: #f0f9f6; color: #00c389; font-weight: 500; } .sidebar-item.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background-color: #00c389; } .settings-main { flex-grow: 1; padding: 30px; } .settings-section { animation: slideRight 0.5s ease-out forwards; } @keyframes slideRight { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } } .section-title { font-size: 1.5rem; color: #333; margin-bottom: 25px; padding-bottom: 15px; border-bottom: 1px solid #eee; } .form-group { margin-bottom: 25px; } label { display: block; font-size: 1rem; color: #555; margin-bottom: 10px; font-weight: 500; } input, select { width: 100%; height: 46px; padding: 0 15px; border: 1px solid #ddd; border-radius: 8px; font-size: 1rem; transition: border-color 0.3s, box-shadow 0.3s; } input:focus, select:focus { border-color: #00c389; box-shadow: 0 0 0 2px rgba(0, 195, 137, 0.2); outline: none; } .hint { font-size: 0.85rem; color: #888; margin-top: 8px; } .mt-3 { margin-top: 12px; } .save-btn { padding: 12px 30px; background-color: #00c389; color: white; border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; transition: all 0.3s ease; margin-top: 10px; } .save-btn:hover { background-color: #00b07b; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 195, 137, 0.3); } .toggle-group { display: flex; justify-content: space-between; align-items: flex-start; padding: 15px; background-color: #f8f9fa; border-radius: 8px; transition: all 0.3s ease; } .toggle-group:hover { background-color: #f0f9f6; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); } .toggle-switch { position: relative; width: 50px; height: 24px; margin-right: 15px; } .toggle-switch input { opacity: 0; width: 0; height: 0; } .toggle-switch label { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ddd; border-radius: 24px; cursor: pointer; transition: 0.4s; } .toggle-switch label:before { position: absolute; content: ""; height: 16px; width: 16px; left: 4px; bottom: 4px; background-color: white; border-radius: 50%; transition: 0.4s; } .toggle-switch input:checked + label { background-color: #00c389; } .toggle-switch input:checked + label:before { transform: translateX(26px); } .notification-group { display: flex; flex-direction: column; gap: 20px; } .notification-item { display: flex; justify-content: space-between; align-items: center; padding: 20px; background-color: #f8f9fa; border-radius: 8px; transition: all 0.3s ease; } .notification-item:hover { background-color: #f0f9f6; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); } .notification-info h3 { font-size: 1.1rem; color: #333; margin-bottom: 5px; } .notification-info p { font-size: 0.9rem; color: #666; } @media (max-width: 992px) { .settings-content { flex-direction: column; } .settings-sidebar { width: 100%; border-right: none; border-bottom: 1px solid #eee; padding: 0; } .sidebar-item { padding: 15px 20px; } .sidebar-item.active::before { width: 0; height: 3px; left: 0; right: 0; top: auto; bottom: 0; } } @media (max-width: 768px) { .settings-main { padding: 20px; } .toggle-group { flex-direction: column; gap: 15px; } } </style>
2302_81331056/travel
src/views/settings/index.vue
Vue
unknown
11,796
import { fileURLToPath, URL } from 'node:url' import path from 'path' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import vueDevTools from 'vite-plugin-vue-devtools' // https://vite.dev/config/ export default defineConfig({ plugins: [ vue(), ], resolve: { alias: { '@': path.resolve(__dirname, './src') }, }, server: { proxy: { '/api': { target: 'http://192.168.0.14:8000', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, '') } } }, build: { chunkSizeWarningLimit: 1000, // 提高警告限制为1000KB rollupOptions: { output: { manualChunks: { 'vendor': ['vue', 'vue-router', 'pinia', 'vue-i18n'], // 第三方库单独打包 'fontawesome': ['@fortawesome/fontawesome-svg-core', '@fortawesome/vue-fontawesome', '@fortawesome/free-solid-svg-icons'], 'ui-components': [ // 放入公共UI组件 './src/components/home/TheHeader.vue', './src/components/home/TheFooter.vue' ] }, // 自定义chunk文件名 chunkFileNames: 'assets/js/[name]-[hash].js', entryFileNames: 'assets/js/[name]-[hash].js', assetFileNames: (assetInfo) => { // 根据资源类型划分文件目录 const info = assetInfo.name.split('.'); let extType = info[info.length - 1]; if (/\.(png|jpe?g|gif|svg|webp|ico)(\?.*)?$/.test(assetInfo.name)) { extType = 'img'; } else if (/\.(woff2?|eot|ttf|otf)(\?.*)?$/i.test(assetInfo.name)) { extType = 'fonts'; } else if (/\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/.test(assetInfo.name)) { extType = 'media'; } else if (/\.css$/.test(assetInfo.name)) { extType = 'css'; } return `assets/${extType}/[name]-[hash][extname]`; } } } } })
2302_81331056/travel
vite.config.js
JavaScript
unknown
1,980
package com.example.myapplication import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 import org.junit.Test import org.junit.runner.RunWith import org.junit.Assert.* /** * Instrumented test, which will execute on an Android device. * * See [testing documentation](http://d.android.com/tools/testing). */ @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { @Test fun useAppContext() { // Context of the app under test. val appContext = InstrumentationRegistry.getInstrumentation().targetContext assertEquals("com.example.myapplication", appContext.packageName) } }
2401_84520185/work4
app/src/androidTest/java/com/example/myapplication/ExampleInstrumentedTest.kt
Kotlin
unknown
677
package com.example.myapplication import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.grid.GridCells import androidx.compose.foundation.lazy.grid.LazyVerticalGrid import androidx.compose.foundation.lazy.grid.items import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.example.myapplication.data.DataSource import com.example.myapplication.model.Topic class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { enableEdgeToEdge() super.onCreate(savedInstanceState) setContent { Surface( modifier = Modifier .fillMaxSize() .statusBarsPadding(), color = MaterialTheme.colorScheme.background ) { TopicGrid( modifier = Modifier.padding( start = 8.dp, top = 8.dp, end = 8.dp, ) ) } } } } @Composable fun TopicGrid(modifier: Modifier = Modifier) { LazyVerticalGrid( columns = GridCells.Fixed(2), verticalArrangement = Arrangement.spacedBy(8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = modifier ) { items(DataSource.topics) { topic -> TopicCard(topic) } } } @Composable fun TopicCard(topic: Topic, modifier: Modifier = Modifier) { Card( modifier = modifier, elevation = CardDefaults.cardElevation(defaultElevation = 4.dp) ) { Row( modifier = Modifier .fillMaxWidth() .padding(0.dp), verticalAlignment = Alignment.CenterVertically ) { Image( painter = painterResource(id = topic.imageRes), contentDescription = stringResource(id = topic.name), modifier = Modifier .size(68.dp), contentScale = ContentScale.Crop ) Column( modifier = Modifier .padding(start = 16.dp, end = 16.dp) .weight(1f) .padding(vertical = 16.dp), verticalArrangement = Arrangement.Center ) { Text( text = stringResource(id = topic.name), style = MaterialTheme.typography.bodyMedium, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onSurface, modifier = Modifier.padding(bottom = 8.dp) ) Row( verticalAlignment = Alignment.CenterVertically ) { Icon( painter = painterResource(R.drawable.ic_grain), contentDescription = null, modifier = Modifier.size(16.dp) ) Spacer(modifier = Modifier.width(8.dp)) Text( text = topic.availableCourses.toString(), style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.onSurfaceVariant ) } } } } } @Preview(showBackground = true, widthDp = 200, heightDp = 80) @Composable fun TopicPreview() { MaterialTheme { Surface { TopicCard( topic = Topic(R.string.photography, 321, R.drawable.photography) ) } } }
2401_84520185/work4
app/src/main/java/com/example/myapplication/MainActivity.kt
Kotlin
unknown
4,922
package com.example.myapplication.data import com.example.myapplication.R import com.example.myapplication.model.Topic object DataSource { val topics = listOf( Topic(R.string.architecture, 58, R.drawable.architecture), Topic(R.string.automotive, 30, R.drawable.automotive), Topic(R.string.biology, 90, R.drawable.biology), Topic(R.string.crafts, 121, R.drawable.crafts), Topic(R.string.business, 78, R.drawable.business), Topic(R.string.culinary, 118, R.drawable.culinary), Topic(R.string.design, 423, R.drawable.design), Topic(R.string.ecology, 28, R.drawable.ecology), Topic(R.string.engineering, 67, R.drawable.engineering), Topic(R.string.fashion, 92, R.drawable.fashion), Topic(R.string.finance, 100, R.drawable.finance), Topic(R.string.film, 165, R.drawable.film), Topic(R.string.gaming, 37, R.drawable.gaming), Topic(R.string.geology, 290, R.drawable.geology), Topic(R.string.drawing, 326, R.drawable.drawing), Topic(R.string.history, 189, R.drawable.history), Topic(R.string.journalism, 96, R.drawable.journalism), Topic(R.string.law, 58, R.drawable.law), Topic(R.string.lifestyle, 305, R.drawable.lifestyle), Topic(R.string.music, 212, R.drawable.music), Topic(R.string.painting, 172, R.drawable.painting), Topic(R.string.photography, 321, R.drawable.photography), Topic(R.string.physics, 41, R.drawable.physics), Topic(R.string.tech, 118, R.drawable.tech), ) }
2401_84520185/work4
app/src/main/java/com/example/myapplication/data/DataSource.kt
Kotlin
unknown
1,570
package com.example.myapplication.model import androidx.annotation.DrawableRes import androidx.annotation.StringRes data class Topic( @StringRes val name: Int, val availableCourses: Int, @DrawableRes val imageRes: Int )
2401_84520185/work4
app/src/main/java/com/example/myapplication/model/topic.kt
Kotlin
unknown
234
package com.example.myapplication.ui.theme import androidx.compose.ui.graphics.Color val Purple80 = Color(0xFFD0BCFF) val PurpleGrey80 = Color(0xFFCCC2DC) val Pink80 = Color(0xFFEFB8C8) val Purple40 = Color(0xFF6650a4) val PurpleGrey40 = Color(0xFF625b71) val Pink40 = Color(0xFF7D5260)
2401_84520185/work4
app/src/main/java/com/example/myapplication/ui/theme/Color.kt
Kotlin
unknown
289
package com.example.myapplication.ui.theme import android.app.Activity import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext private val DarkColorScheme = darkColorScheme( primary = Purple80, secondary = PurpleGrey80, tertiary = Pink80 ) private val LightColorScheme = lightColorScheme( primary = Purple40, secondary = PurpleGrey40, tertiary = Pink40 /* Other default colors to override background = Color(0xFFFFFBFE), surface = Color(0xFFFFFBFE), onPrimary = Color.White, onSecondary = Color.White, onTertiary = Color.White, onBackground = Color(0xFF1C1B1F), onSurface = Color(0xFF1C1B1F), */ ) @Composable fun MyApplicationTheme( darkTheme: Boolean = isSystemInDarkTheme(), // Dynamic color is available on Android 12+ dynamicColor: Boolean = true, content: @Composable () -> Unit ) { val colorScheme = when { dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { val context = LocalContext.current if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) } darkTheme -> DarkColorScheme else -> LightColorScheme } MaterialTheme( colorScheme = colorScheme, typography = Typography, content = content ) }
2401_84520185/work4
app/src/main/java/com/example/myapplication/ui/theme/Theme.kt
Kotlin
unknown
1,706
package com.example.myapplication.ui.theme import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp // Set of Material typography styles to start with val Typography = Typography( bodyLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 16.sp, lineHeight = 24.sp, letterSpacing = 0.5.sp ) /* Other default text styles to override titleLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 22.sp, lineHeight = 28.sp, letterSpacing = 0.sp ), labelSmall = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Medium, fontSize = 11.sp, lineHeight = 16.sp, letterSpacing = 0.5.sp ) */ )
2401_84520185/work4
app/src/main/java/com/example/myapplication/ui/theme/Type.kt
Kotlin
unknown
994
package com.example.myapplication import org.junit.Test import org.junit.Assert.* /** * Example local unit test, which will execute on the development machine (host). * * See [testing documentation](http://d.android.com/tools/testing). */ class ExampleUnitTest { @Test fun addition_isCorrect() { assertEquals(4, 2 + 2) } }
2401_84520185/work4
app/src/test/java/com/example/myapplication/ExampleUnitTest.kt
Kotlin
unknown
349
# This file is part of the openHiTLS project. # # openHiTLS is licensed under the Mulan PSL v2. # You can use this software according to the terms and conditions of the Mulan PSL v2. # You may obtain a copy of Mulan PSL v2 at: # # http://license.coscl.org.cn/MulanPSL2 # # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, # EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, # MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. # See the Mulan PSL v2 for more details. cmake_minimum_required(VERSION 3.16 FATAL_ERROR) project(openHiTLS) set(HiTLS_SOURCE_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}) if(DEFINED BUILD_DIR) set(HiTLS_BUILD_DIR ${BUILD_DIR}) else() set(HiTLS_BUILD_DIR ${HiTLS_SOURCE_ROOT_DIR}/build) endif() execute_process(COMMAND python3 ${HiTLS_SOURCE_ROOT_DIR}/configure.py -m --build_dir ${HiTLS_BUILD_DIR}) include(${HiTLS_BUILD_DIR}/modules.cmake) install(DIRECTORY ${HiTLS_SOURCE_ROOT_DIR}/include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/hitls/ FILES_MATCHING PATTERN "*.h")
2401_83913325/openHiTLS-examples_4041-bench2
CMakeLists.txt
CMake
unknown
1,079
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_CONF_H #define HITLS_APP_CONF_H #include <stdint.h> #include "bsl_obj.h" #include "bsl_conf.h" #include "hitls_pki_types.h" #include "hitls_pki_utils.h" #include "hitls_pki_csr.h" #include "hitls_pki_cert.h" #include "hitls_pki_crl.h" #include "hitls_pki_x509.h" #include "hitls_pki_pkcs12.h" #ifdef __cplusplus extern "C" { #endif /** * x509 v3 extensions */ #define HITLS_CFG_X509_EXT_AKI "authorityKeyIdentifier" #define HITLS_CFG_X509_EXT_SKI "subjectKeyIdentifier" #define HITLS_CFG_X509_EXT_BCONS "basicConstraints" #define HITLS_CFG_X509_EXT_KU "keyUsage" #define HITLS_CFG_X509_EXT_EXKU "extendedKeyUsage" #define HITLS_CFG_X509_EXT_SAN "subjectAltName" /* Key usage */ #define HITLS_CFG_X509_EXT_KU_DIGITAL_SIGN "digitalSignature" #define HITLS_CFG_X509_EXT_KU_NON_REPUDIATION "nonRepudiation" #define HITLS_CFG_X509_EXT_KU_KEY_ENCIPHERMENT "keyEncipherment" #define HITLS_CFG_X509_EXT_KU_DATA_ENCIPHERMENT "dataEncipherment" #define HITLS_CFG_X509_EXT_KU_KEY_AGREEMENT "keyAgreement" #define HITLS_CFG_X509_EXT_KU_KEY_CERT_SIGN "keyCertSign" #define HITLS_CFG_X509_EXT_KU_CRL_SIGN "cRLSign" #define HITLS_CFG_X509_EXT_KU_ENCIPHER_ONLY "encipherOnly" #define HITLS_CFG_X509_EXT_KU_DECIPHER_ONLY "decipherOnly" /* Extended key usage */ #define HITLS_CFG_X509_EXT_EXKU_SERVER_AUTH "serverAuth" #define HITLS_CFG_X509_EXT_EXKU_CLIENT_AUTH "clientAuth" #define HITLS_CFG_X509_EXT_EXKU_CODE_SING "codeSigning" #define HITLS_CFG_X509_EXT_EXKU_EMAIL_PROT "emailProtection" #define HITLS_CFG_X509_EXT_EXKU_TIME_STAMP "timeStamping" #define HITLS_CFG_X509_EXT_EXKU_OCSP_SIGN "OCSPSigning" /* Subject Alternative Name */ #define HITLS_CFG_X509_EXT_SAN_EMAIL "email" #define HITLS_CFG_X509_EXT_SAN_DNS "DNS" #define HITLS_CFG_X509_EXT_SAN_DIR_NAME "dirName" #define HITLS_CFG_X509_EXT_SAN_URI "URI" #define HITLS_CFG_X509_EXT_SAN_IP "IP" /* Authority key identifier */ #define HITLS_CFG_X509_EXT_AKI_KID (1 << 0) #define HITLS_CFG_X509_EXT_AKI_KID_ALWAYS (1 << 1) typedef struct { HITLS_X509_ExtAki aki; uint32_t flag; } HITLS_CFG_ExtAki; /** * @ingroup apps * * @brief Split String by character. * Remove spaces before and after separators. * * @param str [IN] String to be split. * @param separator [IN] Separator. * @param allowEmpty [IN] Indicates whether empty substrings can be contained. * @param strArr [OUT] String array. Only the first string needs to be released after use. * @param maxArrCnt [IN] String array. Only the first string needs to be released after use. * @param realCnt [OUT] Number of character strings after splitting。 * * @retval HITLS_APP_SUCCESS */ int32_t HITLS_APP_SplitString(const char *str, char separator, bool allowEmpty, char **strArr, uint32_t maxArrCnt, uint32_t *realCnt); /** * @ingroup apps * * @brief Process function of X509 extensions. * * @param cid [IN] Cid of extension * @param val [IN] Data pointer. * @param ctx [IN] Context. * * @retval HITLS_APP_SUCCESS */ typedef int32_t (*ProcExtCallBack)(BslCid cid, void *val, void *ctx); /** * @ingroup apps * * @brief Process function of X509 extensions. * * @param value [IN] conf * @param section [IN] The section name of x509 extension * @param extCb [IN] Callback function of one extension. * @param ctx [IN] Context of callback function. * * @retval HITLS_APP_SUCCESS */ int32_t HITLS_APP_CONF_ProcExt(BSL_CONF *cnf, const char *section, ProcExtCallBack extCb, void *ctx); /** * @ingroup apps * * @brief The callback function to add distinguish name * * @param ctx [IN] The context of callback function * @param nameList [IN] The linked list of subject name, the type is HITLS_X509_DN * * @retval HITLS_APP_SUCCESS */ typedef int32_t (*AddDnNameCb)(void *ctx, BslList *nameList); /** * @ingroup apps * * @brief The callback function to add subject name to csr * * @param ctx [IN] The context of callback function * @param nameList [IN] The linked list of subject name, the type is HITLS_X509_DN * * @retval HITLS_APP_SUCCESS */ int32_t HiTLS_AddSubjDnNameToCsr(void *csr, BslList *nameList); /** * @ingroup apps * * @brief Process distinguish name string. * The distinguish name format is /type0=value0/type1=value1/type2=... * * @param nameStr [IN] distinguish name string * @param cb [IN] The callback function to add distinguish name to csr or cert * @param ctx [IN] Context of callback function. * * @retval HITLS_APP_SUCCESS */ int32_t HITLS_APP_CFG_ProcDnName(const char *nameStr, AddDnNameCb cb, void *ctx); #ifdef __cplusplus } #endif #endif // HITLS_APP_CONF_H
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_conf.h
C
unknown
5,429
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_CRL_H #define HITLS_APP_CRL_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif int32_t HITLS_CrlMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_crl.h
C
unknown
734
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_DGST_H #define HITLS_APP_DGST_H #include <stdint.h> #include <stddef.h> #include "crypt_algid.h" #ifdef __cplusplus extern "C" { #endif typedef struct { const int mdId; const char *mdAlgName; } HITLS_AlgList; int32_t HITLS_DgstMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_dgst.h
C
unknown
866
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_ENC_H #define HITLS_APP_ENC_H #include <stdint.h> #include <linux/limits.h> #ifdef __cplusplus extern "C" { #endif #define REC_ITERATION_TIMES 10000 #define REC_MAX_FILE_LENGEN 512 #define REC_MAX_FILENAME_LENGTH PATH_MAX #define REC_MAX_MAC_KEY_LEN 64 #define REC_MAX_KEY_LENGTH 64 #define REC_MAX_IV_LENGTH 16 #define REC_HEX_BASE 16 #define REC_SALT_LEN 8 #define REC_HEX_BUF_LENGTH 8 #define REC_MIN_PRE_LENGTH 6 #define REC_DOUBLE 2 #define MAX_BUFSIZE 4096 #define XTS_MIN_DATALEN 16 #define BUF_SAFE_BLOCK 16 #define BUF_READABLE_BLOCK 32 #define IS_SUPPORT_GET_EOF 1 #define BSL_SUCCESS 0 typedef enum { HITLS_APP_OPT_CIPHER_ALG = 2, HITLS_APP_OPT_IN_FILE, HITLS_APP_OPT_OUT_FILE, HITLS_APP_OPT_DEC, HITLS_APP_OPT_ENC, HITLS_APP_OPT_MD, HITLS_APP_OPT_PASS, } HITLS_OptType; typedef struct { const int cipherId; const char *cipherAlgName; } HITLS_CipherAlgList; typedef struct { const int macId; const char *macAlgName; } HITLS_MacAlgList; int32_t HITLS_EncMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_enc.h
C
unknown
1,853
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_ERRNO_H #define HITLS_APP_ERRNO_H #ifdef __cplusplus extern "C" { #endif #define HITLS_APP_SUCCESS 0 // The return value of HITLS APP ranges from 0, 1, 3 to 125. // 3 to 125 are external error codes. enum HITLS_APP_ERROR { HITLS_APP_HELP = 0x1, /* *< the subcommand has the help option */ HITLS_APP_SECUREC_FAIL, /* *< error returned by the safe function */ HITLS_APP_MEM_ALLOC_FAIL, /* *< failed to apply for memory resources */ HITLS_APP_INVALID_ARG, /* *< invalid parameter */ HITLS_APP_INTERNAL_EXCEPTION, HITLS_APP_ENCODE_FAIL, /* *< encodeing failure */ HITLS_APP_CRYPTO_FAIL, HITLS_APP_PASSWD_FAIL, HITLS_APP_UIO_FAIL, HITLS_APP_STDIN_FAIL, /* *< incorrect stdin input */ HITLS_APP_INFO_CMP_FAIL, /* *< failed to match the received information with the parameter */ HITLS_APP_INVALID_DN_TYPE, HITLS_APP_INVALID_DN_VALUE, HITLS_APP_INVALID_GENERAL_NAME_TYPE, HITLS_APP_INVALID_GENERAL_NAME, HITLS_APP_INVALID_IP, HITLS_APP_ERR_CONF_GET_SECTION, HITLS_APP_NO_EXT, HITLS_APP_INIT_FAILED, HITLS_APP_COPY_ARGS_FAILED, HITLS_APP_OPT_UNKOWN, /* *< option error */ HITLS_APP_OPT_NAME_INVALID, /* *< the subcommand name is invalid */ HITLS_APP_OPT_VALUETYPE_INVALID, /* *< the parameter type of the subcommand is invalid */ HITLS_APP_OPT_TYPE_INVALID, /* *< the subcommand type is invalid */ HITLS_APP_OPT_VALUE_INVALID, /* *< the subcommand parameter value is invalid */ HITLS_APP_DECODE_FAIL, /* *< decoding failure */ HITLS_APP_CERT_VERIFY_FAIL, /* *< certificate verification failed */ HITLS_APP_X509_FAIL, /* *< x509-related error. */ HITLS_APP_SAL_FAIL, /* *< sal-related error. */ HITLS_APP_BSL_FAIL, /* *< bsl-related error. */ HITLS_APP_CONF_FAIL, /* *< conf-related error. */ HITLS_APP_LOAD_CERT_FAIL, /* *< Failed to load the cert. */ HITLS_APP_LOAD_CSR_FAIL, /* *< Failed to load the csr. */ HITLS_APP_LOAD_KEY_FAIL, /* *< Failed to load the public and private keys. */ HITLS_APP_ENCODE_KEY_FAIL, /* *< Failed to encode the public and private keys. */ HITLS_APP_MAX = 126, /* *< maximum of the error code */ }; #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_errno.h
C
unknown
3,087
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_FUNCTION_H #define HITLS_APP_FUNCTION_H #ifdef __cplusplus extern "C" { #endif typedef enum { FUNC_TYPE_NONE, // default FUNC_TYPE_GENERAL, // general command } HITLS_CmdFuncType; typedef struct { const char *name; // second-class command name HITLS_CmdFuncType type; // type of command int (*main)(int argc, char *argv[]); // second-class entry function } HITLS_CmdFunc; int AppGetProgFunc(const char *proName, HITLS_CmdFunc *func); void AppPrintFuncList(void); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_function.h
C
unknown
1,129
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_GENPKEY_H #define HITLS_APP_GENPKEY_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif int32_t HITLS_GenPkeyMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif // HITLS_APP_Genpkey_H
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_genpkey.h
C
unknown
769
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_GENRSA_H #define HITLS_APP_GENRSA_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif #define REC_MAX_PEM_FILELEN 65537 #define REC_MAX_PKEY_LENGTH 16384 #define REC_MIN_PKEY_LENGTH 512 #define REC_ALG_NUM_EACHLINE 4 typedef struct { const int id; const char *algName; } HITLS_APPAlgList; int32_t HITLS_GenRSAMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_genrsa.h
C
unknown
967
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_HELP_H #define HITLS_APP_HELP_H #ifdef __cplusplus extern "C" { #endif int HITLS_HelpMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_help.h
C
unknown
714
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_KDF_H #define HITLS_APP_KDF_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif int32_t HITLS_KdfMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_kdf.h
C
unknown
734
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_LIST_H #define HITLS_APP_LIST_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif typedef enum { HITLS_APP_LIST_OPT_ALL_ALG = 2, HITLS_APP_LIST_OPT_DGST_ALG, HITLS_APP_LIST_OPT_CIPHER_ALG, HITLS_APP_LIST_OPT_ASYM_ALG, HITLS_APP_LIST_OPT_MAC_ALG, HITLS_APP_LIST_OPT_RAND_ALG, HITLS_APP_LIST_OPT_KDF_ALG, HITLS_APP_LIST_OPT_CURVES } HITLSListOptType; int HITLS_ListMain(int argc, char *argv[]); int32_t HITLS_APP_GetCidByName(const char *name, int32_t type); const char *HITLS_APP_GetNameByCid(int32_t cid, int32_t type); #ifdef __cplusplus } #endif #endif // HITLS_APP_LIST_H
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_list.h
C
unknown
1,183
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_MAC_H #define HITLS_APP_MAC_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif int32_t HITLS_MacMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_mac.h
C
unknown
734
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_OPT_H #define HITLS_APP_OPT_H #include <stdint.h> #include "bsl_uio.h" #include "bsl_types.h" #ifdef __cplusplus extern "C" { #endif #define HILTS_APP_FORMAT_UNDEF 0 #define HITLS_APP_FORMAT_PEM BSL_FORMAT_PEM // 1 #define HITLS_APP_FORMAT_ASN1 BSL_FORMAT_ASN1 // 2 #define HITLS_APP_FORMAT_TEXT 3 #define HITLS_APP_FORMAT_BASE64 4 #define HITLS_APP_FORMAT_HEX 5 #define HITLS_APP_FORMAT_BINARY 6 #define HITLS_APP_PROV_ENUM \ HITLS_APP_OPT_PROVIDER, \ HITLS_APP_OPT_PROVIDER_PATH, \ HITLS_APP_OPT_PROVIDER_ATTR \ #define HITLS_APP_PROV_OPTIONS \ {"provider", HITLS_APP_OPT_PROVIDER, HITLS_APP_OPT_VALUETYPE_STRING, \ "Specify the cryptographic service provider"}, \ {"provider-path", HITLS_APP_OPT_PROVIDER_PATH, HITLS_APP_OPT_VALUETYPE_STRING, \ "Set the path to the cryptographic service provider"}, \ {"provider-attr", HITLS_APP_OPT_PROVIDER_ATTR, HITLS_APP_OPT_VALUETYPE_STRING, \ "Set additional attributes for the cryptographic service provider"} \ #define HITLS_APP_PROV_CASES(optType, provider) \ switch (optType) { \ case HITLS_APP_OPT_PROVIDER: \ (provider)->providerName = HITLS_APP_OptGetValueStr(); \ break; \ case HITLS_APP_OPT_PROVIDER_PATH: \ (provider)->providerPath = HITLS_APP_OptGetValueStr(); \ break; \ case HITLS_APP_OPT_PROVIDER_ATTR: \ (provider)->providerAttr = HITLS_APP_OptGetValueStr(); \ break; \ default: \ break; \ } typedef enum { HITLS_APP_OPT_VALUETYPE_NONE = 0, HITLS_APP_OPT_VALUETYPE_NO_VALUE = 1, HITLS_APP_OPT_VALUETYPE_IN_FILE, HITLS_APP_OPT_VALUETYPE_OUT_FILE, HITLS_APP_OPT_VALUETYPE_STRING, HITLS_APP_OPT_VALUETYPE_PARAMTERS, HITLS_APP_OPT_VALUETYPE_DIR, HITLS_APP_OPT_VALUETYPE_INT, HITLS_APP_OPT_VALUETYPE_UINT, HITLS_APP_OPT_VALUETYPE_POSITIVE_INT, HITLS_APP_OPT_VALUETYPE_LONG, HITLS_APP_OPT_VALUETYPE_ULONG, HITLS_APP_OPT_VALUETYPE_FMT_PEMDER, HITLS_APP_OPT_VALUETYPE_FMT_ANY, HITLS_APP_OPT_VALUETYPE_MAX, } HITLS_ValueType; typedef enum { HITLS_APP_OPT_VALUECLASS_NONE = 0, HITLS_APP_OPT_VALUECLASS_NO_VALUE = 1, HITLS_APP_OPT_VALUECLASS_STR, HITLS_APP_OPT_VALUECLASS_DIR, HITLS_APP_OPT_VALUECLASS_INT, HITLS_APP_OPT_VALUECLASS_LONG, HITLS_APP_OPT_VALUECLASS_FMT, HITLS_APP_OPT_VALUECLASS_MAX, } HITLS_ValueClass; typedef enum { HITLS_APP_OPT_ERR = -1, HITLS_APP_OPT_EOF = 0, HITLS_APP_OPT_PARAM = HITLS_APP_OPT_EOF, HITLS_APP_OPT_HELP = 1, } HITLS_OptChoice; typedef struct { const char *name; // option name const int optType; // option type int valueType; // options with parameters(type) const char *help; // description of this option } HITLS_CmdOption; /** * @ingroup HITLS_APP * @brief Initialization of command-line argument parsing (internal function) * * @param argc [IN] number of options * @param argv [IN] pointer to an array of options * @param opts [IN] command option table * * @retval command name of command-line argument */ int32_t HITLS_APP_OptBegin(int32_t argc, char **argv, const HITLS_CmdOption *opts); /** * @ingroup HITLS_APP * @brief Parse next command-line argument (internal function) * * @param void * * @retval int32 option type */ int32_t HITLS_APP_OptNext(void); /** * @ingroup HITLS_APP * @brief Finish parsing options * * @param void * * @retval void */ void HITLS_APP_OptEnd(void); /** * @ingroup HITLS_APP * @brief Print command line parsing * * @param opts command option table * * @retval void */ void HITLS_APP_OptHelpPrint(const HITLS_CmdOption *opts); /** * @ingroup HITLS_APP * @brief Get the number of remaining options * * @param void * * @retval int32 number of remaining options */ int32_t HITLS_APP_GetRestOptNum(void); /** * @ingroup HITLS_APP * @brief Get the remaining options * * @param void * * @retval char** the address of remaining options */ char **HITLS_APP_GetRestOpt(void); /** * @ingroup HITLS_APP * @brief Get command option * @param void * @retval char* command option */ char *HITLS_APP_OptGetValueStr(void); /** * @ingroup HITLS_APP * @brief option string to int * @param valueS [IN] string value * @param valueL [OUT] int value * @retval int32_t success or not */ int32_t HITLS_APP_OptGetInt(const char *valueS, int32_t *valueI); /** * @ingroup HITLS_APP * @brief option string to uint32_t * @param valueS [IN] string value * @param valueL [OUT] uint32_t value * @retval int32_t success or not */ int32_t HITLS_APP_OptGetUint32(const char *valueS, uint32_t *valueU); /** * @ingroup HITLS_APP * @brief Get the name of the current second-class command * * @param void * * @retval char* command name */ char *HITLS_APP_GetProgName(void); /** * @ingroup HITLS_APP * @brief option string to long * * @param valueS [IN] string value * @param valueL [OUT] long value * * @retval int32_t success or not */ int32_t HITLS_APP_OptGetLong(const char *valueS, long *valueL); /** * @ingroup HITLS_APP * @brief Get the format type from the option value * * @param valueS [IN] string of value * @param type [IN] value type * @param formatType [OUT] format type * * @retval int32_t success or not */ int32_t HITLS_APP_OptGetFormatType(const char *valueS, HITLS_ValueType type, BSL_ParseFormat *formatType); /** * @ingroup HITLS_APP * @brief Get UIO type from option value * * @param filename [IN] name of input file * @param mode [IN] method of opening a file * @param flag [OUT] whether the closing of the standard input/output window is bound to the UIO * * @retval BSL_UIO * when succeeded, NULL when failed */ BSL_UIO* HITLS_APP_UioOpen(const char* filename, char mode, int32_t flag); /** * @ingroup HITLS_APP * @brief Converts a character string to a character string in Base64 format and output the buf to UIO * * @param buf [IN] content to be encoded * @param inBufLen [IN] the length of content to be encoded * @param outBuf [IN] Encoded content * @param outBufLen [IN] the length of encoded content * * @retval int32_t success or not */ int32_t HITLS_APP_OptToBase64(uint8_t *buf, uint32_t inBufLen, char *outBuf, uint32_t outBufLen); /** * @ingroup HITLS_APP * @brief Converts a character string to a hexadecimal character string and output the buf to UIO * * @param buf [IN] content to be encoded * @param inBufLen [IN] the length of content to be encoded * @param outBuf [IN] Encoded content * @param outBufLen [IN] the length of encoded content * * @retval int32_t success or not */ int32_t HITLS_APP_OptToHex(uint8_t *buf, uint32_t inBufLen, char *outBuf, uint32_t outBufLen); /** * @ingroup HITLS_APP * @brief Output the buf to UIO * * @param uio [IN] output UIO * @param buf [IN] output buf * @param outLen [IN] the length of output buf * @param format [IN] output format * * @retval int32_t success or not */ int32_t HITLS_APP_OptWriteUio(BSL_UIO* uio, uint8_t* buf, uint32_t outLen, int32_t format); /** * @ingroup HITLS_APP * @brief Read the content in the UIO to the readBuf * * @param uio [IN] input UIO * @param readBuf [IN] buf which uio read * @param readBufLen [IN] the length of readBuf * @param maxBufLen [IN] the maximum length to be read. * * @retval int32_t success or not */ int32_t HITLS_APP_OptReadUio(BSL_UIO *uio, uint8_t **readBuf, uint64_t *readBufLen, uint64_t maxBufLen); /** * @ingroup HITLS_APP * @brief Get unknown option name * * @retval char* */ const char *HITLS_APP_OptGetUnKownOptName(); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_opt.h
C
unknown
8,603
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_PASSWD_H #define HITLS_APP_PASSWD_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif #define REC_MAX_ITER_TIMES 999999999 #define REC_DEF_ITER_TIMES 5000 #define REC_MAX_ARRAY_LEN 1025 #define REC_MIN_ITER_TIMES 1000 #define REC_SHA512_BLOCKSIZE 64 #define REC_HASH_BUF_LEN 64 #define REC_MIN_PREFIX_LEN 37 #define REC_MAX_SALTLEN 16 #define REC_SHA512_SALTLEN 16 #define REC_TEN 10 #define REC_PRE_ITER_LEN 8 #define REC_SEVEN 7 #define REC_SHA512_ALGTAG 6 #define REC_SHA256_ALGTAG 5 #define REC_PRE_TAG_LEN 3 #define REC_THREE 3 #define REC_TWO 2 #define REC_MD5_ALGTAG 1 int32_t HITLS_PasswdMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_passwd.h
C
unknown
1,429
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_PKCS12_H #define HITLS_APP_PKCS12_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif int32_t HITLS_PKCS12Main(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_pkcs12.h
C
unknown
745
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_PKEY_H #define HITLS_APP_PKEY_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif int32_t HITLS_PkeyMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif // HITLS_APP_PKEY_H
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_pkey.h
C
unknown
757
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_LOG_H #define HITLS_APP_LOG_H #include <stdio.h> #include <stdint.h> #include "bsl_uio.h" #ifdef __cplusplus extern "C" { #endif /** * @ingroup HITLS_APPS * @brief Print output to UIO * * @param uio [IN] UIO to be printed * @param format [IN] Log format character string * @param... [IN] format Parameter * @retval int32_t */ int32_t AppPrint(BSL_UIO *uio, const char *format, ...); /** * @ingroup HiTLS_APPS * @brief Print the output to stderr. * * @param format [IN] Log format character string * @param... [IN] format Parameter * @retval void */ void AppPrintError(const char *format, ...); /** * @ingroup HiTLS_APPS * @brief Initialize the PrintErrUIO. * * @param fp [IN] File pointer, for example, stderr. * @retval int32_t */ int32_t AppPrintErrorUioInit(FILE *fp); /** * @ingroup HiTLS_APPS * @brief Deinitialize the PrintErrUIO. * * @retval void */ void AppPrintErrorUioUnInit(void); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_print.h
C
unknown
1,527
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_PROVIDER_H #define HITLS_APP_PROVIDER_H #include <stdint.h> #include "crypt_types.h" #include "crypt_eal_provider.h" #ifdef __cplusplus extern "C" { #endif typedef struct { char *providerName; char *providerPath; char *providerAttr; } AppProvider; CRYPT_EAL_LibCtx *APP_Create_LibCtx(void); CRYPT_EAL_LibCtx *APP_GetCurrent_LibCtx(void); int32_t HITLS_APP_LoadProvider(const char *searchPath, const char *providerName); #define HITLS_APP_FreeLibCtx CRYPT_EAL_LibCtxFree #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_provider.h
C
unknown
1,083
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_RAND_H #define HITLS_APP_RAND_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif int32_t HITLS_RandMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_rand.h
C
unknown
737
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_REQ_H #define HITLS_APP_REQ_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif int32_t HITLS_ReqMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif // HITLS_APP_REQ_H
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_req.h
C
unknown
753
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_RSA_H #define HITLS_APP_RSA_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif int32_t HITLS_RsaMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_rsa.h
C
unknown
734
#ifndef HITLS_APP_SPEED_H #define HITLS_APP_SPEED_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif #define TEST_BLOCK_SIZES_LEN 6 //自动测试块数量 //自动测试块数组 static const int TEST_BLOCK_SIZES[TEST_BLOCK_SIZES_LEN] = {16, 64, 256, 1024, 8192, 16384}; #define SECONDS 3 //默认测试时长 #define MAX_KEY_LEN 64 //默认最大密钥长度 #define MAX_MAC_LEN 128 //默认最大MAX值长度 #define MAX_THREADS 32 //最大支持线程数 //加密算法列表结构体 typedef struct { const int cipherId; const char *cipherAlgName; } HITLS_CipherList; //MAC算法列表结构体 typedef struct { const int macId; const char *macAlgName; } HITLS_MacList; //性能测试主函数 int32_t HITLS_SpeedMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_speed.h
C
unknown
909
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef APP_UTILS_H #define APP_UTILS_H #include <stddef.h> #include <stdint.h> #include "bsl_ui.h" #include "bsl_types.h" #include "crypt_eal_pkey.h" #include "app_conf.h" #include "hitls_csr_local.h" #ifdef __cplusplus extern "C" { #endif #define APP_MAX_PASS_LENGTH 1024 #define APP_MIN_PASS_LENGTH 1 #define APP_FILE_MAX_SIZE_KB 256 #define APP_FILE_MAX_SIZE (APP_FILE_MAX_SIZE_KB * 1024) // 256KB #define DEFAULT_SALTLEN 16 #define DEFAULT_ITCNT 2048 void *ExpandingMem(void *oldPtr, size_t newSize, size_t oldSize); /** * @ingroup apps * * @brief Apps Function for Checking the Validity of Key Characters * * @attention If the key length needs to be limited, the caller needs to limit the key length outside the function. * * @param password [IN] Key entered by the user * @param passwordLen [IN] Length of the key entered by the user * * @retval The key is valid:HITLS_APP_SUCCESS * @retval The key is invalid:HITLS_APP_PASSWD_FAIL */ int32_t HITLS_APP_CheckPasswd(const uint8_t *password, const uint32_t passwordLen); /** * @ingroup apps * * @brief Apps Function for Verifying Passwd Received by the BSL_UI_ReadPwdUtil() * * @attention callBackData is the default callback structure APP_DefaultPassCBData. * * @param ui [IN] Input/Output Stream * @param buff [IN] Buffer for receiving passwd * @param buffLen [IN] Length of the buffer for receiving passwd * @param callBackData [IN] Key verification information. * * @retval The key is valid:HITLS_APP_SUCCESS * @retval The key is invalid:HITLS_APP_PASSWD_FAIL */ int32_t HITLS_APP_DefaultPassCB(BSL_UI *ui, char *buff, uint32_t buffLen, void *callBackData); int32_t HITLS_APP_Passwd(char *buf, int32_t bufMaxLen, int32_t flag, void *userdata); void HITLS_APP_PrintPassErrlog(void); /** * @ingroup apps * * @brief Obtain the password from the command line argument. * * @attention pass: The memory needs to be released automatically. * * @param passArg [IN] Command line password parameters * @param pass [OUT] Parsed password * * @retval The key is valid:HITLS_APP_SUCCESS * @retval The key is invalid:HITLS_APP_PASSWD_FAIL */ int32_t HITLS_APP_ParsePasswd(const char *passArg, char **pass); int32_t HITLS_APP_GetPasswd(BSL_UI_ReadPwdParam *param, char **passin, uint8_t **pass, uint32_t *passLen); /** * @ingroup apps * * @brief Load the public key. * * @attention If inFilePath is empty, it is read from the standard input. * * @param inFilePath [IN] file name * @param informat [IN] Public Key Format * * @retval CRYPT_EAL_PkeyCtx */ CRYPT_EAL_PkeyCtx *HITLS_APP_LoadPubKey(const char *inFilePath, BSL_ParseFormat informat); /** * @ingroup apps * * @brief Load the private key. * * @attention If inFilePath or passin is empty, it is read from the standard input. * * @param inFilePath [IN] file name * @param informat [IN] Private Key Format * @param passin [IN/OUT] Parsed password * * @retval CRYPT_EAL_PkeyCtx */ CRYPT_EAL_PkeyCtx *HITLS_APP_LoadPrvKey(const char *inFilePath, BSL_ParseFormat informat, char **passin); /** * @ingroup apps * * @brief Print the public key. * * @attention If outFilePath is empty, the standard output is displayed. * * @param pkey [IN] key * @param outFilePath [IN] file name * @param outformat [IN] Public Key Format * * @retval HITLS_APP_SUCCESS * @retval HITLS_APP_INVALID_ARG * @retval HITLS_APP_ENCODE_KEY_FAIL * @retval HITLS_APP_UIO_FAIL */ int32_t HITLS_APP_PrintPubKey(CRYPT_EAL_PkeyCtx *pkey, const char *outFilePath, BSL_ParseFormat outformat); /** * @ingroup apps * * @brief Print the private key. * * @attention If outFilePath is empty, the standard output is displayed, If passout is empty, it is read * from the standard input. * * @param pkey [IN] key * @param outFilePath [IN] file name * @param outformat [IN] Private Key Format * @param cipherAlgCid [IN] Encryption algorithm cid * @param passout [IN/OUT] encryption password * * @retval HITLS_APP_SUCCESS * @retval HITLS_APP_INVALID_ARG * @retval HITLS_APP_ENCODE_KEY_FAIL * @retval HITLS_APP_UIO_FAIL */ int32_t HITLS_APP_PrintPrvKey(CRYPT_EAL_PkeyCtx *pkey, const char *outFilePath, BSL_ParseFormat outformat, int32_t cipherAlgCid, char **passout); typedef struct { const char *name; BSL_ParseFormat outformat; int32_t cipherAlgCid; bool text; bool noout; } AppKeyPrintParam; int32_t HITLS_APP_PrintPrvKeyByUio(BSL_UIO *uio, CRYPT_EAL_PkeyCtx *pkey, AppKeyPrintParam *printKeyParam, char **passout); /** * @ingroup apps * * @brief Obtain and check the encryption algorithm. * * @param name [IN] encryption name * @param symId [IN/OUT] encryption algorithm cid * * @retval HITLS_APP_SUCCESS * @retval HITLS_APP_INVALID_ARG */ int32_t HITLS_APP_GetAndCheckCipherOpt(const char *name, int32_t *symId); /** * @ingroup apps * * @brief Load the cert. * * @param inPath [IN] cert path * @param inform [IN] cert format * * @retval HITLS_X509_Cert */ HITLS_X509_Cert *HITLS_APP_LoadCert(const char *inPath, BSL_ParseFormat inform); /** * @ingroup apps * * @brief Load the csr. * * @param inPath [IN] csr path * @param inform [IN] csr format * * @retval HITLS_X509_Csr */ HITLS_X509_Csr *HITLS_APP_LoadCsr(const char *inPath, BSL_ParseFormat inform); int32_t HITLS_APP_GetAndCheckHashOpt(const char *name, int32_t *hashId); int32_t HITLS_APP_PrintText(const BSL_Buffer *csrBuf, const char *outFileName); int32_t HITLS_APP_HexToByte(const char *hex, uint8_t **bin, uint32_t *len); CRYPT_EAL_PkeyCtx *HITLS_APP_GenRsaPkeyCtx(uint32_t bits); #ifdef __cplusplus } #endif #endif // APP_UTILS_H
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_utils.h
C
unknown
6,401
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef HITLS_APP_VERIFY_H #define HITLS_APP_VERIFY_H #include <stdint.h> #ifdef __cplusplus extern "C" { #endif int32_t HITLS_VerifyMain(int argc, char *argv[]); #ifdef __cplusplus } #endif #endif
2401_83913325/openHiTLS-examples_4041-bench2
apps/include/app_verify.h
C
unknown
744