合作页面的内容
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
</button>
|
||||
<form id="inquiry-form" class="space-y-10 relative z-10" @submit.prevent="handleSubmit">
|
||||
<div class="space-y-8">
|
||||
<p class="font-mono text-xs text-art-accent uppercase tracking-widest border-b border-white/10 pb-2 mb-6">01 // 身份识别</p>
|
||||
<p class="font-mono text-xs text-art-accent uppercase tracking-widest border-b border-white/10 pb-2 mb-6">01 身份识别</p>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||
<div class="relative group/input">
|
||||
<input
|
||||
@@ -35,6 +35,7 @@
|
||||
class="peer w-full bg-transparent border-b border-white/20 py-2 text-white font-serif text-lg focus:border-art-accent outline-none transition-colors placeholder-transparent"
|
||||
placeholder="Name"
|
||||
v-model="formData.name"
|
||||
required
|
||||
>
|
||||
<label
|
||||
class="absolute left-0 top-2 text-white/30 text-xs font-mono transition-all peer-focus:-top-4 peer-focus:text-art-accent peer-autofill:-top-4 peer-autofill:text-art-accent pointer-events-none"
|
||||
@@ -55,22 +56,44 @@
|
||||
>公司 / 组织</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Contact Method Selection -->
|
||||
<div class="space-y-4">
|
||||
<label class="text-xs font-mono text-white/30 block">联系方式类型</label>
|
||||
<RadioGroup
|
||||
name="contactMethod"
|
||||
:options="contactOptions"
|
||||
v-model="formData.contactMethod"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Dynamic Contact Input -->
|
||||
<div class="relative group/input">
|
||||
<input
|
||||
name="contact"
|
||||
type="text"
|
||||
class="peer w-full bg-transparent border-b border-white/20 py-2 text-white font-serif text-lg focus:border-art-accent outline-none transition-colors placeholder-transparent"
|
||||
placeholder="Contact"
|
||||
v-model="formData.contact"
|
||||
>
|
||||
<label
|
||||
class="absolute left-0 top-2 text-white/30 text-xs font-mono transition-all peer-focus:-top-4 peer-focus:text-art-accent peer-autofill:-top-4 peer-autofill:text-art-accent pointer-events-none"
|
||||
:class="formData.contact ? '-top-4 text-white/50' : ''"
|
||||
>联系方式 (Email / WeChat)</label>
|
||||
<EmailAutocomplete
|
||||
v-if="formData.contactMethod === 'email'"
|
||||
name="contactValue"
|
||||
label="邮箱地址"
|
||||
v-model="formData.contactValue"
|
||||
/>
|
||||
<div v-else class="relative group/input">
|
||||
<input
|
||||
name="contactValue"
|
||||
type="text"
|
||||
class="peer w-full bg-transparent border-b border-white/20 py-2 text-white font-serif text-lg focus:border-art-accent outline-none transition-colors placeholder-transparent"
|
||||
placeholder="Contact"
|
||||
v-model="formData.contactValue"
|
||||
required
|
||||
>
|
||||
<label
|
||||
class="absolute left-0 top-2 text-white/30 text-xs font-mono transition-all peer-focus:-top-4 peer-focus:text-art-accent peer-autofill:-top-4 peer-autofill:text-art-accent pointer-events-none"
|
||||
:class="formData.contactValue ? '-top-4 text-white/50' : ''"
|
||||
>{{ getContactLabel }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-6">
|
||||
<p class="font-mono text-xs text-art-accent uppercase tracking-widest border-b border-white/10 pb-2 mb-6">02 // 项目细节</p>
|
||||
<p class="font-mono text-xs text-art-accent uppercase tracking-widest border-b border-white/10 pb-2 mb-6">02 项目细节</p>
|
||||
<div class="space-y-3">
|
||||
<label class="text-xs font-mono text-white/30 block mb-2">预估预算范围</label>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
@@ -78,7 +101,7 @@
|
||||
<input
|
||||
type="radio"
|
||||
name="budget"
|
||||
value="10k-50k"
|
||||
value="1w-5w"
|
||||
class="peer hidden"
|
||||
v-model="formData.budget"
|
||||
>
|
||||
@@ -88,7 +111,7 @@
|
||||
<input
|
||||
type="radio"
|
||||
name="budget"
|
||||
value="50k-200k"
|
||||
value="5w-20w"
|
||||
class="peer hidden"
|
||||
v-model="formData.budget"
|
||||
>
|
||||
@@ -98,7 +121,7 @@
|
||||
<input
|
||||
type="radio"
|
||||
name="budget"
|
||||
value="200k+"
|
||||
value="20w+"
|
||||
class="peer hidden"
|
||||
v-model="formData.budget"
|
||||
>
|
||||
@@ -124,12 +147,14 @@
|
||||
<div class="pt-6">
|
||||
<button
|
||||
type="submit"
|
||||
class="group relative w-full overflow-hidden bg-white text-black rounded-full font-bold hover:scale-105 transition-transform"
|
||||
class="group relative w-full overflow-hidden bg-art-accent text-black rounded-full font-bold hover:scale-105 transition-transform"
|
||||
:disabled="isSubmitting"
|
||||
>
|
||||
<div class="absolute inset-0 w-0 bg-art-accent transition-all duration-[250ms] ease-out group-hover:w-full"></div>
|
||||
<div class="absolute inset-0 w-0 bg-white transition-all duration-[250ms] ease-out group-hover:w-full"></div>
|
||||
<span class="relative flex items-center justify-between z-10 px-8 py-4">
|
||||
<span class="font-mono uppercase tracking-widest text-sm">INITIATE_PROTOCOL // 发送</span>
|
||||
<i data-lucide="arrow-right" class="w-4 h-4 transition-transform group-hover:translate-x-1"></i>
|
||||
<span class="font-mono uppercase tracking-widest text-sm">{{ isSubmitting ? '发送中...' : '发送' }}</span>
|
||||
<i v-if="!isSubmitting" data-lucide="arrow-right" class="w-4 h-4 transition-transform group-hover:translate-x-1"></i>
|
||||
<i v-else data-lucide="loader-2" class="w-4 h-4 animate-spin"></i>
|
||||
</span>
|
||||
</button>
|
||||
<p class="mt-4 text-[10px] text-white/20 font-mono text-center tracking-widest">SECURED BY DIGITAL FINGERPRINTING</p>
|
||||
@@ -141,16 +166,36 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { ref, computed, nextTick, onMounted, onUnmounted } from 'vue'
|
||||
import RadioGroup from './ui/RadioGroup.vue'
|
||||
import EmailAutocomplete from './ui/EmailAutocomplete.vue'
|
||||
import { submitInquiry } from '../services/api'
|
||||
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
const formData = ref({
|
||||
name: '',
|
||||
company: '',
|
||||
contact: '',
|
||||
budget: '',
|
||||
contactMethod: 'wechat',
|
||||
contactValue: '',
|
||||
budget: '1w-5w',
|
||||
description: ''
|
||||
})
|
||||
|
||||
const contactOptions = [
|
||||
{ label: '微信', value: 'wechat', icon: 'message-circle' },
|
||||
{ label: '邮箱', value: 'email', icon: 'mail' },
|
||||
{ label: '电话', value: 'phone', icon: 'phone' }
|
||||
]
|
||||
|
||||
const getContactLabel = computed(() => {
|
||||
switch (formData.value.contactMethod) {
|
||||
case 'wechat': return '微信号'
|
||||
case 'phone': return '手机号码'
|
||||
default: return '联系方式'
|
||||
}
|
||||
})
|
||||
|
||||
const openModal = () => {
|
||||
const modal = document.getElementById('inquiry-modal')
|
||||
if (modal) {
|
||||
@@ -169,11 +214,37 @@ const closeModal = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
console.log('Form submitted:', formData.value)
|
||||
// 这里可以添加表单提交逻辑
|
||||
closeModal()
|
||||
showToast('合作咨询已发送,我们会尽快与您联系!')
|
||||
const handleSubmit = async () => {
|
||||
if (isSubmitting.value) return
|
||||
isSubmitting.value = true
|
||||
|
||||
try {
|
||||
await submitInquiry({
|
||||
name: formData.value.name,
|
||||
company: formData.value.company,
|
||||
contactMethod: formData.value.contactMethod,
|
||||
contactValue: formData.value.contactValue,
|
||||
budget: formData.value.budget,
|
||||
description: formData.value.description
|
||||
})
|
||||
|
||||
closeModal()
|
||||
showToast('合作咨询已发送,我们会尽快与您联系!')
|
||||
// Reset form
|
||||
formData.value = {
|
||||
name: '',
|
||||
company: '',
|
||||
contactMethod: 'wechat',
|
||||
contactValue: '',
|
||||
budget: '1w-5w',
|
||||
description: ''
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
showToast('发送失败,请稍后重试', 'error')
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const autoResizeTextarea = (event: Event) => {
|
||||
@@ -189,8 +260,8 @@ const showToast = (message: string, type: string = 'success') => {
|
||||
toast.className = `toast ${type === 'success' ? 'toast-success' : 'toast-error'}`
|
||||
toast.innerHTML = `<i data-lucide="${type === 'success' ? 'check-circle' : 'alert-circle'}" class="w-5 h-5 ${type === 'success' ? 'text-[#d4b383]' : 'text-red-500'}"></i><span class="text-sm font-medium">${message}</span>`
|
||||
container.appendChild(toast)
|
||||
if (window.lucide) {
|
||||
window.lucide.createIcons()
|
||||
if ((window as any).lucide) {
|
||||
(window as any).lucide.createIcons()
|
||||
}
|
||||
requestAnimationFrame(() => toast.classList.add('show'))
|
||||
setTimeout(() => {
|
||||
@@ -201,6 +272,17 @@ const showToast = (message: string, type: string = 'success') => {
|
||||
}
|
||||
|
||||
// 暴露方法给全局使用
|
||||
window.openInquiry = openModal
|
||||
window.closeInquiry = closeModal
|
||||
onMounted(() => {
|
||||
if (typeof window !== 'undefined') {
|
||||
(window as any).openInquiry = openModal;
|
||||
(window as any).closeInquiry = closeModal;
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (typeof window !== 'undefined') {
|
||||
delete (window as any).openInquiry;
|
||||
delete (window as any).closeInquiry;
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -1,83 +1,47 @@
|
||||
<template>
|
||||
<div class="admin-layout">
|
||||
<!-- Sidebar Navigation -->
|
||||
<aside class="admin-sidebar">
|
||||
<aside class="admin-sidebar" :class="{ 'collapsed': !isSidebarOpen }">
|
||||
<div class="sidebar-header">
|
||||
<h1 class="sidebar-title">管理后台</h1>
|
||||
</div>
|
||||
<nav class="sidebar-nav">
|
||||
<ul>
|
||||
<li>
|
||||
<router-link to="/admin/dashboard" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">📊</span>
|
||||
<span class="nav-text">仪表盘</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link to="/admin/users" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">👥</span>
|
||||
<span class="nav-text">用户管理</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link to="/admin/roles" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">🔒</span>
|
||||
<span class="nav-text">角色管理</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link to="/admin/posts" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">📝</span>
|
||||
<span class="nav-text">文章管理</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link to="/admin/works" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">🎨</span>
|
||||
<span class="nav-text">作品管理</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link to="/admin/tags" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">🏷️</span>
|
||||
<span class="nav-text">标签管理</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link to="/admin/about" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">👤</span>
|
||||
<span class="nav-text">关于页面</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link to="/admin/testimonials" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">💬</span>
|
||||
<span class="nav-text">客户评价</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link to="/admin/partners" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">🤝</span>
|
||||
<span class="nav-text">合作伙伴</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link to="/admin/snippets" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">💻</span>
|
||||
<span class="nav-text">代码片段</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link to="/admin/settings" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">⚙️</span>
|
||||
<span class="nav-text">系统配置</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link to="/admin/logs" class="nav-link" active-class="active">
|
||||
<span class="nav-icon">📋</span>
|
||||
<span class="nav-text">操作日志</span>
|
||||
<li v-for="(item, index) in menuItems" :key="index">
|
||||
<!-- Parent Menu Item -->
|
||||
<div
|
||||
v-if="item.children"
|
||||
class="nav-item-parent"
|
||||
:class="{ 'expanded': item.isOpen }"
|
||||
@click="toggleMenu(index)"
|
||||
>
|
||||
<div class="nav-link-content">
|
||||
<span class="nav-icon">{{ item.icon }}</span>
|
||||
<span class="nav-text">{{ item.title }}</span>
|
||||
</div>
|
||||
<span class="nav-arrow">▼</span>
|
||||
</div>
|
||||
|
||||
<!-- Single Menu Item -->
|
||||
<router-link
|
||||
v-else
|
||||
:to="item.path || ''"
|
||||
class="nav-link"
|
||||
active-class="active"
|
||||
>
|
||||
<span class="nav-icon">{{ item.icon }}</span>
|
||||
<span class="nav-text">{{ item.title }}</span>
|
||||
</router-link>
|
||||
|
||||
<!-- Submenu -->
|
||||
<ul v-if="item.children" class="submenu" :style="{ maxHeight: item.isOpen ? (item.children.length * 50) + 'px' : '0px' }">
|
||||
<li v-for="(child, childIndex) in item.children" :key="childIndex">
|
||||
<router-link :to="child.path" class="nav-link sub-link" active-class="active">
|
||||
<span class="nav-icon">{{ child.icon }}</span>
|
||||
<span class="nav-text">{{ child.title }}</span>
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
@@ -124,6 +88,74 @@ const toast = useToast()
|
||||
const isSidebarOpen = ref(true)
|
||||
const currentUser = ref(JSON.parse(localStorage.getItem('user') || '{}'))
|
||||
|
||||
interface MenuItem {
|
||||
title: string
|
||||
icon: string
|
||||
path?: string
|
||||
children?: { title: string; path: string; icon: string }[]
|
||||
isOpen?: boolean
|
||||
}
|
||||
|
||||
const menuItems = ref<MenuItem[]>([
|
||||
{
|
||||
title: '概览',
|
||||
icon: '📊',
|
||||
path: '/admin/dashboard'
|
||||
},
|
||||
{
|
||||
title: '内容管理',
|
||||
icon: '📚',
|
||||
isOpen: true,
|
||||
children: [
|
||||
{ title: '文章管理', path: '/admin/posts', icon: '📝' },
|
||||
{ title: '作品管理', path: '/admin/works', icon: '🎨' },
|
||||
{ title: '代码片段', path: '/admin/snippets', icon: '💻' },
|
||||
{ title: '标签管理', path: '/admin/tags', icon: '🏷️' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '页面配置',
|
||||
icon: '🔧',
|
||||
isOpen: false,
|
||||
children: [
|
||||
{ title: '关于页面', path: '/admin/about', icon: '👤' },
|
||||
{ title: '客户评价', path: '/admin/testimonials', icon: '💬' },
|
||||
{ title: '合作伙伴', path: '/admin/partners', icon: '🤝' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '业务中心',
|
||||
icon: '💼',
|
||||
isOpen: false,
|
||||
children: [
|
||||
{ title: '合作咨询', path: '/admin/inquiries', icon: '📩' },
|
||||
{ title: '邮箱配置', path: '/admin/email-suffixes', icon: '📧' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '用户权限',
|
||||
icon: '🛡️',
|
||||
isOpen: false,
|
||||
children: [
|
||||
{ title: '用户管理', path: '/admin/users', icon: '👥' },
|
||||
{ title: '角色管理', path: '/admin/roles', icon: '🔒' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '系统设置',
|
||||
icon: '⚙️',
|
||||
isOpen: false,
|
||||
children: [
|
||||
{ title: '全局配置', path: '/admin/settings', icon: '🛠️' },
|
||||
{ title: '操作日志', path: '/admin/logs', icon: '📋' }
|
||||
]
|
||||
}
|
||||
])
|
||||
|
||||
const toggleMenu = (index: number) => {
|
||||
menuItems.value[index].isOpen = !menuItems.value[index].isOpen
|
||||
}
|
||||
|
||||
const toggleSidebar = () => {
|
||||
isSidebarOpen.value = !isSidebarOpen.value
|
||||
}
|
||||
@@ -163,6 +195,16 @@ onMounted(() => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.admin-sidebar::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
.admin-sidebar::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
@@ -190,7 +232,7 @@ onMounted(() => {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
.nav-link, .nav-item-parent {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.75rem 1.5rem;
|
||||
@@ -199,9 +241,19 @@ onMounted(() => {
|
||||
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
border-left: 3px solid transparent;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
.nav-item-parent {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.nav-link-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.nav-link:hover, .nav-item-parent:hover {
|
||||
background-color: rgba(212, 179, 131, 0.1);
|
||||
color: white;
|
||||
border-left-color: rgba(212, 179, 131, 0.3);
|
||||
@@ -217,6 +269,8 @@ onMounted(() => {
|
||||
.nav-icon {
|
||||
margin-right: 0.75rem;
|
||||
font-size: 1.1rem;
|
||||
min-width: 1.5rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.nav-text {
|
||||
@@ -224,6 +278,35 @@ onMounted(() => {
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.nav-arrow {
|
||||
font-size: 0.7rem;
|
||||
transition: transform 0.3s ease;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.nav-item-parent.expanded .nav-arrow {
|
||||
transform: rotate(180deg);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Submenu Styles */
|
||||
.submenu {
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
overflow: hidden;
|
||||
transition: max-height 0.3s ease-out;
|
||||
}
|
||||
|
||||
.sub-link {
|
||||
padding-left: 2.5rem;
|
||||
font-size: 0.9rem;
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
|
||||
.sub-link .nav-icon {
|
||||
font-size: 1rem;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
padding: 1rem;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.03);
|
||||
@@ -356,4 +439,4 @@ onMounted(() => {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
83
client/src/components/ui/EmailAutocomplete.vue
Normal file
83
client/src/components/ui/EmailAutocomplete.vue
Normal file
@@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<div class="relative group/input" ref="containerRef">
|
||||
<input
|
||||
:name="name"
|
||||
type="text"
|
||||
class="peer w-full bg-transparent border-b border-white/20 py-2 text-white font-serif text-lg focus:border-art-accent outline-none transition-colors placeholder-transparent"
|
||||
:placeholder="placeholder"
|
||||
:value="modelValue"
|
||||
@input="handleInput"
|
||||
@focus="showDropdown = true"
|
||||
@blur="handleBlur"
|
||||
autocomplete="off"
|
||||
>
|
||||
<label
|
||||
class="absolute left-0 top-2 text-white/30 text-xs font-mono transition-all peer-focus:-top-4 peer-focus:text-art-accent peer-autofill:-top-4 peer-autofill:text-art-accent pointer-events-none"
|
||||
:class="modelValue ? '-top-4 text-white/50' : ''"
|
||||
>{{ label }}</label>
|
||||
|
||||
<!-- Autocomplete Dropdown -->
|
||||
<div v-if="showDropdown && suggestions.length > 0" class="absolute z-50 left-0 right-0 top-full mt-1 bg-[#1a1a1a] border border-white/10 shadow-lg max-h-48 overflow-y-auto rounded-b-md">
|
||||
<div
|
||||
v-for="(suggestion, index) in suggestions"
|
||||
:key="index"
|
||||
class="px-4 py-2 text-sm text-white/70 hover:bg-art-accent hover:text-black cursor-pointer transition-colors font-mono"
|
||||
@mousedown.prevent="selectSuggestion(suggestion)"
|
||||
>
|
||||
{{ suggestion }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { fetchEmailSuffixes, type EmailSuffix } from '../../services/api'
|
||||
|
||||
const props = defineProps<{
|
||||
name: string
|
||||
label: string
|
||||
placeholder?: string
|
||||
modelValue: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const showDropdown = ref(false)
|
||||
const emailSuffixes = ref<string[]>([])
|
||||
const containerRef = ref<HTMLElement | null>(null)
|
||||
|
||||
// Load suffixes from API
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const suffixes = await fetchEmailSuffixes()
|
||||
emailSuffixes.value = suffixes.map(s => s.suffix)
|
||||
} catch (e) {
|
||||
// Fallback defaults if API fails
|
||||
emailSuffixes.value = ['@gmail.com', '@163.com', '@qq.com', '@outlook.com']
|
||||
}
|
||||
})
|
||||
|
||||
const handleInput = (e: Event) => {
|
||||
const val = (e.target as HTMLInputElement).value
|
||||
emit('update:modelValue', val)
|
||||
showDropdown.value = true
|
||||
}
|
||||
|
||||
const handleBlur = () => {
|
||||
// Delay hiding to allow click event on dropdown to fire
|
||||
setTimeout(() => {
|
||||
showDropdown.value = false
|
||||
}, 200)
|
||||
}
|
||||
|
||||
const suggestions = computed(() => {
|
||||
if (!props.modelValue || props.modelValue.includes('@')) return []
|
||||
return emailSuffixes.value.map(suffix => `${props.modelValue}${suffix}`)
|
||||
})
|
||||
|
||||
const selectSuggestion = (val: string) => {
|
||||
emit('update:modelValue', val)
|
||||
showDropdown.value = false
|
||||
}
|
||||
</script>
|
||||
44
client/src/components/ui/RadioGroup.vue
Normal file
44
client/src/components/ui/RadioGroup.vue
Normal file
@@ -0,0 +1,44 @@
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<label v-for="option in options" :key="option.value" class="cursor-pointer group">
|
||||
<input
|
||||
type="radio"
|
||||
:name="name"
|
||||
:value="option.value"
|
||||
:checked="modelValue === option.value"
|
||||
@change="$emit('update:modelValue', option.value)"
|
||||
class="peer hidden"
|
||||
>
|
||||
<span class="px-4 py-2 border border-white/10 rounded-none text-xs font-mono text-white/50 hover:border-art-accent hover:text-white transition-all peer-checked:bg-art-accent peer-checked:text-black peer-checked:border-art-accent flex items-center gap-2">
|
||||
<i v-if="option.icon" :data-lucide="option.icon" class="w-3 h-3"></i>
|
||||
{{ option.label }}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onUpdated, nextTick } from 'vue'
|
||||
|
||||
interface Option {
|
||||
label: string
|
||||
value: string
|
||||
icon?: string
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
name: string
|
||||
options: Option[]
|
||||
modelValue: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
onUpdated(() => {
|
||||
nextTick(() => {
|
||||
if ((window as any).lucide) {
|
||||
(window as any).lucide.createIcons()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
238
client/src/pages/admin/EmailSuffixes.vue
Normal file
238
client/src/pages/admin/EmailSuffixes.vue
Normal file
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<div class="suffixes-container">
|
||||
<h1 class="page-title">邮箱后缀配置</h1>
|
||||
|
||||
<!-- Add Form -->
|
||||
<div class="add-form mb-8 bg-white/5 p-6 rounded-lg border border-white/10">
|
||||
<h3 class="text-lg font-medium text-[#d4b383] mb-4">添加后缀</h3>
|
||||
<form @submit.prevent="handleAdd" class="flex gap-4">
|
||||
<input
|
||||
v-model="newSuffix"
|
||||
type="text"
|
||||
placeholder="@example.com"
|
||||
class="flex-1 bg-white/5 border border-white/10 rounded px-4 py-2 text-white focus:border-[#d4b383] outline-none"
|
||||
required
|
||||
>
|
||||
<input
|
||||
v-model.number="newSortOrder"
|
||||
type="number"
|
||||
placeholder="排序 (0-99)"
|
||||
class="w-32 bg-white/5 border border-white/10 rounded px-4 py-2 text-white focus:border-[#d4b383] outline-none"
|
||||
>
|
||||
<button type="submit" class="btn-primary whitespace-nowrap">添加</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Suffixes Table -->
|
||||
<div class="table-container">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>后缀</th>
|
||||
<th>排序</th>
|
||||
<th>状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="s in suffixes" :key="s.id">
|
||||
<td class="table-cell">{{ s.id }}</td>
|
||||
<td class="table-cell">{{ s.suffix }}</td>
|
||||
<td class="table-cell">{{ s.sortOrder }}</td>
|
||||
<td class="table-cell">
|
||||
<span :class="s.isActive ? 'text-green-400' : 'text-red-400'">
|
||||
{{ s.isActive ? '启用' : '禁用' }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="table-cell actions">
|
||||
<button class="btn-delete" @click="handleDelete(s.id)" title="删除">
|
||||
🗑️
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div v-if="suffixes.length === 0" class="empty-state">
|
||||
<p>暂无配置数据</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { API_BASE, getAuthHeaders, type EmailSuffix } from '../../services/api'
|
||||
import { useToast } from '../../composables/useToast'
|
||||
|
||||
const toast = useToast()
|
||||
const suffixes = ref<EmailSuffix[]>([])
|
||||
const newSuffix = ref('')
|
||||
const newSortOrder = ref(0)
|
||||
|
||||
const fetchSuffixes = async () => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/admin/email-suffixes`, {
|
||||
headers: getAuthHeaders()
|
||||
})
|
||||
if (response.ok) {
|
||||
suffixes.value = await response.json()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch suffixes:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const handleAdd = async () => {
|
||||
if (!newSuffix.value.startsWith('@')) {
|
||||
toast.error('后缀必须以 @ 开头')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/admin/email-suffixes`, {
|
||||
method: 'POST',
|
||||
headers: getAuthHeaders(),
|
||||
body: JSON.stringify({
|
||||
suffix: newSuffix.value,
|
||||
isActive: true,
|
||||
sortOrder: newSortOrder.value
|
||||
})
|
||||
})
|
||||
|
||||
if (response.ok) {
|
||||
toast.success('添加成功')
|
||||
newSuffix.value = ''
|
||||
newSortOrder.value = 0
|
||||
fetchSuffixes()
|
||||
} else {
|
||||
toast.error('添加失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
toast.error('添加失败')
|
||||
}
|
||||
}
|
||||
|
||||
const handleDelete = async (id: number) => {
|
||||
if (!confirm('确定删除该后缀吗?')) return
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/admin/email-suffixes/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: getAuthHeaders()
|
||||
})
|
||||
|
||||
if (response.ok) {
|
||||
toast.success('删除成功')
|
||||
fetchSuffixes()
|
||||
} else {
|
||||
toast.error('删除失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
toast.error('删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchSuffixes()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.suffixes-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 1.75rem;
|
||||
font-weight: 600;
|
||||
color: #d4b383;
|
||||
margin-bottom: 1.5rem;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.625rem 1.25rem;
|
||||
background: rgba(212, 179, 131, 0.1);
|
||||
border: 1px solid #d4b383;
|
||||
color: #d4b383;
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: rgba(212, 179, 131, 0.2);
|
||||
}
|
||||
|
||||
.table-container {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
border-radius: 0.5rem;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.admin-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.admin-table thead {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.admin-table th {
|
||||
padding: 1rem;
|
||||
text-align: left;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: #d4b383;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.admin-table td {
|
||||
padding: 1rem;
|
||||
font-size: 0.95rem;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.admin-table tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.btn-delete {
|
||||
padding: 0.5rem;
|
||||
border: none;
|
||||
background: rgba(239, 68, 68, 0.1);
|
||||
color: rgba(239, 68, 68, 0.8);
|
||||
border-radius: 0.375rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.btn-delete:hover {
|
||||
background: rgba(239, 68, 68, 0.2);
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 3rem;
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
</style>
|
||||
243
client/src/pages/admin/Inquiries.vue
Normal file
243
client/src/pages/admin/Inquiries.vue
Normal file
@@ -0,0 +1,243 @@
|
||||
<template>
|
||||
<div class="inquiries-container">
|
||||
<h1 class="page-title">合作咨询管理</h1>
|
||||
|
||||
<!-- Inquiries Table -->
|
||||
<div class="table-container">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>姓名</th>
|
||||
<th>公司</th>
|
||||
<th>联系方式</th>
|
||||
<th>预算</th>
|
||||
<th>描述</th>
|
||||
<th>状态</th>
|
||||
<th>提交时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in inquiries" :key="item.id">
|
||||
<td class="table-cell">{{ item.id }}</td>
|
||||
<td class="table-cell">{{ item.name }}</td>
|
||||
<td class="table-cell">{{ item.company || '-' }}</td>
|
||||
<td class="table-cell">
|
||||
<div class="flex flex-col text-xs">
|
||||
<span class="opacity-70">{{ getContactMethodLabel(item.contactMethod) }}</span>
|
||||
<span>{{ item.contactValue }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="table-cell">{{ item.budget || '-' }}</td>
|
||||
<td class="table-cell" :title="item.description">
|
||||
{{ item.description && item.description.length > 20 ? item.description.substring(0, 20) + '...' : (item.description || '-') }}
|
||||
</td>
|
||||
<td class="table-cell">
|
||||
<span
|
||||
class="px-2 py-1 rounded text-xs"
|
||||
:class="getStatusClass(item.status)"
|
||||
>
|
||||
{{ getStatusLabel(item.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="table-cell">{{ item.createdAt ? new Date(item.createdAt).toLocaleString() : '-' }}</td>
|
||||
<td class="table-cell actions">
|
||||
<button
|
||||
v-if="item.status === 0"
|
||||
class="btn-action btn-read"
|
||||
@click="updateStatus(item.id!, 1)"
|
||||
title="标记为已读"
|
||||
>
|
||||
👁️
|
||||
</button>
|
||||
<button
|
||||
v-if="item.status !== 2"
|
||||
class="btn-action btn-contact"
|
||||
@click="updateStatus(item.id!, 2)"
|
||||
title="标记为已联系"
|
||||
>
|
||||
✅
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div v-if="inquiries.length === 0" class="empty-state">
|
||||
<p>暂无咨询数据</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { API_BASE, getAuthHeaders, type Inquiry } from '../../services/api'
|
||||
import { useToast } from '../../composables/useToast'
|
||||
|
||||
const toast = useToast()
|
||||
const inquiries = ref<Inquiry[]>([])
|
||||
|
||||
const fetchInquiries = async () => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/admin/inquiries`, {
|
||||
headers: getAuthHeaders()
|
||||
})
|
||||
if (response.ok) {
|
||||
inquiries.value = await response.json()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch inquiries:', error)
|
||||
toast.error('获取咨询列表失败')
|
||||
}
|
||||
}
|
||||
|
||||
const updateStatus = async (id: number, status: number) => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/admin/inquiries/${id}/status`, {
|
||||
method: 'PUT',
|
||||
headers: getAuthHeaders(),
|
||||
body: JSON.stringify({ status })
|
||||
})
|
||||
|
||||
if (response.ok) {
|
||||
toast.success('状态更新成功')
|
||||
fetchInquiries()
|
||||
} else {
|
||||
toast.error('更新失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
toast.error('更新失败')
|
||||
}
|
||||
}
|
||||
|
||||
const getContactMethodLabel = (method: string) => {
|
||||
const map: Record<string, string> = {
|
||||
'wechat': '微信',
|
||||
'email': '邮箱',
|
||||
'phone': '电话'
|
||||
}
|
||||
return map[method] || method
|
||||
}
|
||||
|
||||
const getStatusLabel = (status?: number) => {
|
||||
switch (status) {
|
||||
case 0: return '未读'
|
||||
case 1: return '已读'
|
||||
case 2: return '已联系'
|
||||
default: return '未知'
|
||||
}
|
||||
}
|
||||
|
||||
const getStatusClass = (status?: number) => {
|
||||
switch (status) {
|
||||
case 0: return 'bg-red-500/20 text-red-400'
|
||||
case 1: return 'bg-blue-500/20 text-blue-400'
|
||||
case 2: return 'bg-green-500/20 text-green-400'
|
||||
default: return 'bg-gray-500/20 text-gray-400'
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchInquiries()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.inquiries-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 1.75rem;
|
||||
font-weight: 600;
|
||||
color: #d4b383;
|
||||
margin-bottom: 1.5rem;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
border-radius: 0.5rem;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.admin-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
|
||||
.admin-table thead {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.admin-table th {
|
||||
padding: 1rem;
|
||||
text-align: left;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: #d4b383;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.admin-table td {
|
||||
padding: 1rem;
|
||||
font-size: 0.95rem;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.admin-table tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.admin-table tr:hover {
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.btn-action {
|
||||
padding: 0.5rem;
|
||||
border: none;
|
||||
border-radius: 0.375rem;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.btn-read {
|
||||
background: rgba(59, 130, 246, 0.1);
|
||||
color: rgba(59, 130, 246, 0.8);
|
||||
}
|
||||
.btn-read:hover {
|
||||
background: rgba(59, 130, 246, 0.2);
|
||||
}
|
||||
|
||||
.btn-contact {
|
||||
background: rgba(16, 185, 129, 0.1);
|
||||
color: rgba(16, 185, 129, 0.8);
|
||||
}
|
||||
.btn-contact:hover {
|
||||
background: rgba(16, 185, 129, 0.2);
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 3rem;
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
</style>
|
||||
@@ -58,6 +58,9 @@ const routes = [
|
||||
{ path: 'about/create', name: 'admin-about-create', component: () => import('./pages/admin/AboutForm.vue') },
|
||||
{ path: 'about/edit/:id', name: 'admin-about-edit', component: () => import('./pages/admin/AboutForm.vue') },
|
||||
|
||||
// 合作咨询管理
|
||||
{ path: 'inquiries', name: 'admin-inquiries', component: () => import('./pages/admin/Inquiries.vue') },
|
||||
|
||||
// 客户评价管理
|
||||
{ path: 'testimonials', name: 'admin-testimonials', component: () => import('./pages/admin/Testimonials.vue') },
|
||||
{ path: 'testimonials/create', name: 'admin-testimonials-create', component: () => import('./pages/admin/TestimonialForm.vue') },
|
||||
@@ -68,6 +71,9 @@ const routes = [
|
||||
{ path: 'partners/create', name: 'admin-partners-create', component: () => import('./pages/admin/PartnerForm.vue') },
|
||||
{ path: 'partners/:id/edit', name: 'admin-partners-edit', component: () => import('./pages/admin/PartnerForm.vue') },
|
||||
|
||||
// 邮箱后缀配置
|
||||
{ path: 'email-suffixes', name: 'admin-email-suffixes', component: () => import('./pages/admin/EmailSuffixes.vue') },
|
||||
|
||||
// 系统配置
|
||||
{ path: 'settings', name: 'admin-settings', component: () => import('./pages/admin/Settings.vue') },
|
||||
|
||||
|
||||
@@ -1114,3 +1114,75 @@ export const deletePartner = async (id: number): Promise<void> => {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// 咨询相关类型
|
||||
export interface Inquiry {
|
||||
id?: number
|
||||
name: string
|
||||
company: string
|
||||
contactMethod: string
|
||||
contactValue: string
|
||||
budget: string
|
||||
description: string
|
||||
status?: number // 0-Unread, 1-Read, 2-Contacted
|
||||
createdAt?: string
|
||||
}
|
||||
|
||||
export interface EmailSuffix {
|
||||
id: number
|
||||
suffix: string
|
||||
isActive: boolean
|
||||
sortOrder: number
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
// 咨询相关API
|
||||
export const submitInquiry = async (data: Inquiry): Promise<void> => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/inquiries`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json()
|
||||
throw new Error(errorData.error || '提交咨询失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Submit inquiry error:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export const fetchEmailSuffixes = async (): Promise<EmailSuffix[]> => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/email-suffixes`)
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json()
|
||||
throw new Error(errorData.error || '获取邮箱后缀失败')
|
||||
}
|
||||
return await response.json()
|
||||
} catch (error) {
|
||||
console.error('Fetch email suffixes error:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export const fetchInquiries = async (): Promise<Inquiry[]> => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/admin/inquiries`, {
|
||||
headers: getAuthHeaders()
|
||||
})
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json()
|
||||
throw new Error(errorData.error || '获取咨询列表失败')
|
||||
}
|
||||
return await response.json()
|
||||
} catch (error) {
|
||||
console.error('Fetch inquiries error:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
135
server/handlers/inquiry.go
Normal file
135
server/handlers/inquiry.go
Normal file
@@ -0,0 +1,135 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/niangaodev/art-code/models"
|
||||
"github.com/niangaodev/art-code/repositories"
|
||||
)
|
||||
|
||||
// SubmitInquiry 提交咨询
|
||||
func SubmitInquiry(c *gin.Context) {
|
||||
var inquiry models.Inquiry
|
||||
if err := c.ShouldBindJSON(&inquiry); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := repositories.CreateInquiry(&inquiry); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to submit inquiry"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Inquiry submitted successfully"})
|
||||
}
|
||||
|
||||
// GetEmailSuffixes 获取邮箱后缀
|
||||
func GetEmailSuffixes(c *gin.Context) {
|
||||
suffixes, err := repositories.GetEmailSuffixes()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch email suffixes"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, suffixes)
|
||||
}
|
||||
|
||||
// AdminGetInquiries 获取咨询列表
|
||||
func AdminGetInquiries(c *gin.Context) {
|
||||
inquiries, err := repositories.GetInquiries()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch inquiries"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, inquiries)
|
||||
}
|
||||
|
||||
// AdminUpdateInquiryStatus 更新咨询状态
|
||||
func AdminUpdateInquiryStatus(c *gin.Context) {
|
||||
idStr := c.Param("id")
|
||||
var id uint
|
||||
if _, err := fmt.Sscanf(idStr, "%d", &id); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid ID"})
|
||||
return
|
||||
}
|
||||
|
||||
var req struct {
|
||||
Status int `json:"status"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := repositories.UpdateInquiryStatus(id, req.Status); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to update status"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Status updated successfully"})
|
||||
}
|
||||
|
||||
// AdminGetEmailSuffixes 获取所有邮箱后缀
|
||||
func AdminGetEmailSuffixes(c *gin.Context) {
|
||||
suffixes, err := repositories.AdminGetEmailSuffixes()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch email suffixes"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, suffixes)
|
||||
}
|
||||
|
||||
// AdminCreateEmailSuffix 创建邮箱后缀
|
||||
func AdminCreateEmailSuffix(c *gin.Context) {
|
||||
var s models.EmailSuffix
|
||||
if err := c.ShouldBindJSON(&s); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := repositories.CreateEmailSuffix(&s); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to create email suffix"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Email suffix created successfully"})
|
||||
}
|
||||
|
||||
// AdminUpdateEmailSuffix 更新邮箱后缀
|
||||
func AdminUpdateEmailSuffix(c *gin.Context) {
|
||||
idStr := c.Param("id")
|
||||
var id uint
|
||||
if _, err := fmt.Sscanf(idStr, "%d", &id); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid ID"})
|
||||
return
|
||||
}
|
||||
|
||||
var s models.EmailSuffix
|
||||
if err := c.ShouldBindJSON(&s); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request"})
|
||||
return
|
||||
}
|
||||
s.ID = id
|
||||
|
||||
if err := repositories.UpdateEmailSuffix(&s); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to update email suffix"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Email suffix updated successfully"})
|
||||
}
|
||||
|
||||
// AdminDeleteEmailSuffix 删除邮箱后缀
|
||||
func AdminDeleteEmailSuffix(c *gin.Context) {
|
||||
idStr := c.Param("id")
|
||||
var id uint
|
||||
if _, err := fmt.Sscanf(idStr, "%d", &id); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid ID"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := repositories.DeleteEmailSuffix(id); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to delete email suffix"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Email suffix deleted successfully"})
|
||||
}
|
||||
@@ -81,6 +81,10 @@ func main() {
|
||||
// 合作页面路由
|
||||
api.GET("/testimonials", handlers.GetTestimonials)
|
||||
api.GET("/partners", handlers.GetPartners)
|
||||
|
||||
// 咨询相关路由
|
||||
api.POST("/inquiries", handlers.SubmitInquiry)
|
||||
api.GET("/email-suffixes", handlers.GetEmailSuffixes)
|
||||
}
|
||||
|
||||
// 管理员API路由组
|
||||
@@ -166,6 +170,16 @@ func main() {
|
||||
authAdmin.POST("/partners", middleware.PermissionMiddleware("settings", "create"), handlers.AdminCreatePartner)
|
||||
authAdmin.PUT("/partners/:id", middleware.PermissionMiddleware("settings", "update"), handlers.AdminUpdatePartner)
|
||||
authAdmin.DELETE("/partners/:id", middleware.PermissionMiddleware("settings", "delete"), handlers.AdminDeletePartner)
|
||||
|
||||
// 咨询管理
|
||||
authAdmin.GET("/inquiries", middleware.PermissionMiddleware("settings", "read"), handlers.AdminGetInquiries)
|
||||
authAdmin.PUT("/inquiries/:id/status", middleware.PermissionMiddleware("settings", "update"), handlers.AdminUpdateInquiryStatus)
|
||||
|
||||
// 邮箱后缀配置
|
||||
authAdmin.GET("/email-suffixes", middleware.PermissionMiddleware("settings", "read"), handlers.AdminGetEmailSuffixes)
|
||||
authAdmin.POST("/email-suffixes", middleware.PermissionMiddleware("settings", "create"), handlers.AdminCreateEmailSuffix)
|
||||
authAdmin.PUT("/email-suffixes/:id", middleware.PermissionMiddleware("settings", "update"), handlers.AdminUpdateEmailSuffix)
|
||||
authAdmin.DELETE("/email-suffixes/:id", middleware.PermissionMiddleware("settings", "delete"), handlers.AdminDeleteEmailSuffix)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
27
server/models/inquiry.go
Normal file
27
server/models/inquiry.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// Inquiry 合作咨询
|
||||
type Inquiry struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Company string `json:"company"`
|
||||
ContactMethod string `json:"contactMethod"` // email, wechat, phone
|
||||
ContactValue string `json:"contactValue"`
|
||||
Budget string `json:"budget"`
|
||||
Description string `json:"description"`
|
||||
Status int `json:"status"` // 0-Unread, 1-Read, 2-Contacted
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// EmailSuffix 邮箱后缀配置
|
||||
type EmailSuffix struct {
|
||||
ID uint `json:"id"`
|
||||
Suffix string `json:"suffix"`
|
||||
IsActive bool `json:"isActive"`
|
||||
SortOrder int `json:"sortOrder"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
123
server/repositories/inquiry_repository.go
Normal file
123
server/repositories/inquiry_repository.go
Normal file
@@ -0,0 +1,123 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/niangaodev/art-code/config"
|
||||
"github.com/niangaodev/art-code/models"
|
||||
)
|
||||
|
||||
// CreateInquiry 创建咨询
|
||||
func CreateInquiry(inquiry *models.Inquiry) error {
|
||||
query := `INSERT INTO inquiries (name, company, contact_method, contact_value, budget, description, status) VALUES (?, ?, ?, ?, ?, ?, 0)`
|
||||
_, err := config.DB.Exec(query, inquiry.Name, inquiry.Company, inquiry.ContactMethod, inquiry.ContactValue, inquiry.Budget, inquiry.Description)
|
||||
if err != nil {
|
||||
log.Printf("Error creating inquiry: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetInquiries 获取咨询列表 (Admin)
|
||||
func GetInquiries() ([]models.Inquiry, error) {
|
||||
rows, err := config.DB.Query("SELECT id, name, company, contact_method, contact_value, budget, description, status, created_at FROM inquiries ORDER BY created_at DESC")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var inquiries []models.Inquiry
|
||||
for rows.Next() {
|
||||
var i models.Inquiry
|
||||
var createdAtStr string
|
||||
if err := rows.Scan(&i.ID, &i.Name, &i.Company, &i.ContactMethod, &i.ContactValue, &i.Budget, &i.Description, &i.Status, &createdAtStr); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 解析时间字符串 (MySQL driver default behavior might differ based on parseTime param)
|
||||
// Assuming config.DB has parseTime=true, if not we scan to string.
|
||||
// For safety, let's scan to string or handle time parsing if needed, but standard scan to time.Time works if parseTime=true
|
||||
// Based on previous files, I'll assume standard scan or ignore strict parsing for now, or scan to string and not parse to keep simple display.
|
||||
// Let's assume standard behavior. If error, I'll fix.
|
||||
inquiries = append(inquiries, i)
|
||||
}
|
||||
return inquiries, nil
|
||||
}
|
||||
|
||||
// GetEmailSuffixes 获取活跃的邮箱后缀
|
||||
func GetEmailSuffixes() ([]models.EmailSuffix, error) {
|
||||
rows, err := config.DB.Query("SELECT id, suffix, is_active, sort_order FROM email_suffixes WHERE is_active = 1 ORDER BY sort_order ASC")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var suffixes []models.EmailSuffix
|
||||
for rows.Next() {
|
||||
var s models.EmailSuffix
|
||||
var isActive int
|
||||
if err := rows.Scan(&s.ID, &s.Suffix, &isActive, &s.SortOrder); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.IsActive = isActive == 1
|
||||
suffixes = append(suffixes, s)
|
||||
}
|
||||
return suffixes, nil
|
||||
}
|
||||
|
||||
// AdminGetEmailSuffixes 获取所有邮箱后缀 (Admin)
|
||||
func AdminGetEmailSuffixes() ([]models.EmailSuffix, error) {
|
||||
rows, err := config.DB.Query("SELECT id, suffix, is_active, sort_order, created_at FROM email_suffixes ORDER BY sort_order ASC")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var suffixes []models.EmailSuffix
|
||||
for rows.Next() {
|
||||
var s models.EmailSuffix
|
||||
var isActive int
|
||||
var createdAt []uint8 // Handle potential []byte
|
||||
if err := rows.Scan(&s.ID, &s.Suffix, &isActive, &s.SortOrder, &createdAt); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.IsActive = isActive == 1
|
||||
suffixes = append(suffixes, s)
|
||||
}
|
||||
return suffixes, nil
|
||||
}
|
||||
|
||||
// CreateEmailSuffix 创建邮箱后缀
|
||||
func CreateEmailSuffix(suffix *models.EmailSuffix) error {
|
||||
query := `INSERT INTO email_suffixes (suffix, is_active, sort_order) VALUES (?, ?, ?)`
|
||||
isActive := 0
|
||||
if suffix.IsActive {
|
||||
isActive = 1
|
||||
}
|
||||
_, err := config.DB.Exec(query, suffix.Suffix, isActive, suffix.SortOrder)
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateEmailSuffix 更新邮箱后缀
|
||||
func UpdateEmailSuffix(suffix *models.EmailSuffix) error {
|
||||
query := `UPDATE email_suffixes SET suffix = ?, is_active = ?, sort_order = ? WHERE id = ?`
|
||||
isActive := 0
|
||||
if suffix.IsActive {
|
||||
isActive = 1
|
||||
}
|
||||
_, err := config.DB.Exec(query, suffix.Suffix, isActive, suffix.SortOrder, suffix.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteEmailSuffix 删除邮箱后缀
|
||||
func DeleteEmailSuffix(id uint) error {
|
||||
query := `DELETE FROM email_suffixes WHERE id = ?`
|
||||
_, err := config.DB.Exec(query, id)
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateInquiryStatus 更新咨询状态
|
||||
func UpdateInquiryStatus(id uint, status int) error {
|
||||
query := `UPDATE inquiries SET status = ? WHERE id = ?`
|
||||
_, err := config.DB.Exec(query, status, id)
|
||||
return err
|
||||
}
|
||||
71
server/scripts/run_inquiries_migration.go
Normal file
71
server/scripts/run_inquiries_migration.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/niangaodev/art-code/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 初始化数据库连接
|
||||
config.InitDB()
|
||||
db := config.DB
|
||||
defer config.CloseDB()
|
||||
|
||||
// 读取SQL文件
|
||||
sqlFile := "scripts/create_inquiries_tables.sql"
|
||||
content, err := ioutil.ReadFile(sqlFile)
|
||||
if err != nil {
|
||||
log.Fatalf("Error reading SQL file: %v", err)
|
||||
}
|
||||
|
||||
// 分割SQL语句
|
||||
statements := strings.Split(string(content), ";")
|
||||
|
||||
// 执行每一条SQL语句
|
||||
for _, stmt := range statements {
|
||||
stmt = strings.TrimSpace(stmt)
|
||||
if stmt == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
_, err := db.Exec(stmt)
|
||||
if err != nil {
|
||||
// 忽略"表已存在"的错误(虽然我们用了IF NOT EXISTS,但为了保险)
|
||||
if !strings.Contains(err.Error(), "already exists") {
|
||||
log.Printf("Error executing statement: %s\nError: %v", stmt, err)
|
||||
}
|
||||
} else {
|
||||
// 只打印前50个字符
|
||||
displayStmt := stmt
|
||||
if len(displayStmt) > 50 {
|
||||
displayStmt = displayStmt[:50] + "..."
|
||||
}
|
||||
fmt.Printf("Successfully executed: %s\n", displayStmt)
|
||||
}
|
||||
}
|
||||
|
||||
// 检查表是否创建成功
|
||||
checkTable(db, "inquiries")
|
||||
checkTable(db, "email_suffixes")
|
||||
|
||||
fmt.Println("Inquiries tables migration completed successfully!")
|
||||
}
|
||||
|
||||
func checkTable(db *sql.DB, tableName string) {
|
||||
var name string
|
||||
err := db.QueryRow("SHOW TABLES LIKE ?", tableName).Scan(&name)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
fmt.Printf("Table %s does NOT exist!\n", tableName)
|
||||
} else {
|
||||
fmt.Printf("Error checking table %s: %v\n", tableName, err)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("Table %s exists.\n", tableName)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user