提交 9441910c 编写于 作者: R root

Auto Commit

上级 aa50c4cb
<script setup>
import HelloWorld from './components/HelloWorld.vue'
import TheWelcome from './components/TheWelcome.vue'
import HelloWorld from './components/CreativeCenter.vue'
</script>
<template>
<header>
<img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" />
<!-- <img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" /> -->
<div class="wrapper">
<HelloWorld msg="You did it!" />
......
<template>
<div class="creation-center">
<header class="header">
<h1>创作中心</h1>
<button class="btn-primary" @click="openNewProjectModal">新建作品</button>
</header>
<section class="projects-section">
<h2>我的作品</h2>
<div v-if="projects.length === 0" class="empty-state">
你还没有作品,快去创作吧!
</div>
<div class="projects-grid">
<div v-for="project in projects" :key="project.id" class="project-card">
<div class="project-cover" :style="{ backgroundImage: 'url(' + project.cover + ')' }"></div>
<div class="project-info">
<h3>{{ project.title }}</h3>
<p>{{ project.description }}</p>
</div>
<div class="project-actions">
<button @click="editProject(project)">编辑</button>
<button @click="deleteProject(project.id)" class="btn-danger">删除</button>
</div>
</div>
</div>
</section>
<div v-if="showModal" class="modal-overlay" @click.self="closeModal">
<div class="modal">
<h3>{{ isEditing ? '编辑作品' : '新建作品' }}</h3>
<form @submit.prevent="submitProject">
<label>
标题:
<input v-model="form.title" type="text" required maxlength="50" />
</label>
<label>
描述:
<textarea v-model="form.description" rows="3" maxlength="200"></textarea>
</label>
<label>
封面图片URL:
<input v-model="form.cover" type="url" placeholder="https://..." />
</label>
<div class="modal-actions">
<button type="submit" class="btn-primary">{{ isEditing ? '保存' : '创建' }}</button>
<button type="button" @click="closeModal">取消</button>
</div>
</form>
</div>
</div>
</div>
</template>
<script setup>
import { ref, reactive } from 'vue'
const projects = ref([
{
id: 1,
title: '我的第一部作品',
description: '这是一个精彩的创作示例。',
cover: 'https://images.unsplash.com/photo-1506744038136-46273834b3fb?auto=format&fit=crop&w=400&q=80'
},
{
id: 2,
title: '旅行日记',
description: '记录我的旅行故事和美景。',
cover: 'https://images.unsplash.com/photo-1500534623283-312aade485b7?auto=format&fit=crop&w=400&q=80'
}
])
const showModal = ref(false)
const isEditing = ref(false)
const currentEditId = ref(null)
const form = reactive({
title: '',
description: '',
cover: ''
})
function openNewProjectModal() {
isEditing.value = false
currentEditId.value = null
form.title = ''
form.description = ''
form.cover = ''
showModal.value = true
}
function closeModal() {
showModal.value = false
}
function submitProject() {
if (isEditing.value) {
const index = projects.value.findIndex(p => p.id === currentEditId.value)
if (index !== -1) {
projects.value[index] = {
id: currentEditId.value,
title: form.title,
description: form.description,
cover: form.cover || 'https://via.placeholder.com/400x200?text=No+Image'
}
}
} else {
const newId = projects.value.length ? Math.max(...projects.value.map(p => p.id)) + 1 : 1
projects.value.push({
id: newId,
title: form.title,
description: form.description,
cover: form.cover || 'https://via.placeholder.com/400x200?text=No+Image'
})
}
closeModal()
}
function editProject(project) {
isEditing.value = true
currentEditId.value = project.id
form.title = project.title
form.description = project.description
form.cover = project.cover
showModal.value = true
}
function deleteProject(id) {
if (confirm('确定要删除该作品吗?')) {
projects.value = projects.value.filter(p => p.id !== id)
}
}
</script>
<style scoped>
.creation-center {
max-width: 960px;
margin: 40px auto;
padding: 0 20px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #333;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
}
.header h1 {
font-weight: 700;
font-size: 2.4rem;
color: #2c3e50;
}
.btn-primary {
background: #42b983;
border: none;
color: white;
padding: 10px 18px;
font-size: 1rem;
border-radius: 5px;
cursor: pointer;
transition: background 0.3s ease;
}
.btn-primary:hover {
background: #369870;
}
.projects-section h2 {
font-size: 1.8rem;
margin-bottom: 20px;
border-bottom: 2px solid #42b983;
padding-bottom: 6px;
}
.empty-state {
font-style: italic;
color: #999;
text-align: center;
margin-top: 40px;
}
.projects-grid {
display: grid;
grid-template-columns: repeat(auto-fill,minmax(280px,1fr));
gap: 20px;
}
.project-card {
background: #fff;
border-radius: 10px;
box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
overflow: hidden;
display: flex;
flex-direction: column;
transition: transform 0.2s ease;
}
.project-card:hover {
transform: translateY(-6px);
}
.project-cover {
height: 140px;
background-size: cover;
background-position: center;
}
.project-info {
padding: 15px 20px;
flex-grow: 1;
}
.project-info h3 {
margin: 0 0 8px;
font-size: 1.2rem;
color: #2c3e50;
}
.project-info p {
font-size: 0.9rem;
color: #666;
line-height: 1.3;
}
.project-actions {
padding: 10px 20px;
border-top: 1px solid #eee;
display: flex;
justify-content: flex-end;
gap: 10px;
}
.project-actions button {
background: transparent;
border: 1px solid #42b983;
color: #42b983;
padding: 6px 14px;
border-radius: 5px;
cursor: pointer;
font-size: 0.9rem;
transition: all 0.3s ease;
}
.project-actions button:hover {
background: #42b983;
color: white;
}
.btn-danger {
border-color: #e74c3c;
color: #e74c3c;
}
.btn-danger:hover {
background: #e74c3c;
color: white;
}
/* Modal 样式 */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(44, 62, 80, 0.6);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
}
.modal {
background: white;
border-radius: 12px;
padding: 30px 30px 20px;
width: 400px;
max-width: 90vw;
box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.modal h3 {
margin-top: 0;
margin-bottom: 20px;
color: #2c3e50;
}
.modal form label {
display: block;
margin-bottom: 15px;
font-weight: 600;
color: #34495e;
}
.modal form input[type="text"],
.modal form input[type="url"],
.modal form textarea {
width: 100%;
padding: 8px 10px;
border: 1px solid #ccc;
border-radius: 6px;
font-size: 1rem;
font-family: inherit;
resize: vertical;
transition: border-color 0.3s ease;
}
.modal form input[type="text"]:focus,
.modal form input[type="url"]:focus,
.modal form textarea:focus {
border-color: #42b983;
outline: none;
}
.modal-actions {
display: flex;
justify-content: flex-end;
gap: 12px;
margin-top: 25px;
}
.modal-actions button {
padding: 8px 18px;
border-radius: 6px;
font-size: 1rem;
cursor: pointer;
border: none;
transition: background 0.3s ease;
}
.modal-actions .btn-primary {
background: #42b983;
color: white;
}
.modal-actions .btn-primary:hover {
background: #369870;
}
.modal-actions button[type="button"] {
background: #ccc;
color: #444;
}
.modal-actions button[type="button"]:hover {
background: #bbb;
}
</style>
<script setup>
defineProps({
msg: {
type: String,
required: true
}
})
</script>
<template>
<div class="greetings">
<h1 class="green">{{ msg }}</h1>
<h3>
You’ve successfully created a project with
<a target="_blank" href="https://vitejs.dev/">Vite</a> +
<a target="_blank" href="https://vuejs.org/">Vue 3</a>.
</h3>
</div>
</template>
<style scoped>
h1 {
font-weight: 500;
font-size: 2.6rem;
top: -10px;
}
h3 {
font-size: 1.2rem;
}
.greetings h1,
.greetings h3 {
text-align: center;
}
@media (min-width: 1024px) {
.greetings h1,
.greetings h3 {
text-align: left;
}
}
</style>
<script setup>
import WelcomeItem from './WelcomeItem.vue'
import DocumentationIcon from './icons/IconDocumentation.vue'
import ToolingIcon from './icons/IconTooling.vue'
import EcosystemIcon from './icons/IconEcosystem.vue'
import CommunityIcon from './icons/IconCommunity.vue'
import SupportIcon from './icons/IconSupport.vue'
</script>
<template>
<WelcomeItem>
<template #icon>
<DocumentationIcon />
</template>
<template #heading>Documentation</template>
Vue’s
<a target="_blank" href="https://vuejs.org/">official documentation</a>
provides you with all information you need to get started.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<ToolingIcon />
</template>
<template #heading>Tooling</template>
This project is served and bundled with
<a href="https://vitejs.dev/guide/features.html" target="_blank">Vite</a>. The recommended IDE
setup is <a href="https://code.visualstudio.com/" target="_blank">VSCode</a> +
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>. If you need to test
your components and web pages, check out
<a href="https://www.cypress.io/" target="_blank">Cypress</a> and
<a href="https://on.cypress.io/component" target="_blank"
>Cypress Component Testing</a
>.
<br />
More instructions are available in <code>README.md</code>.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<EcosystemIcon />
</template>
<template #heading>Ecosystem</template>
Get official tools and libraries for your project:
<a target="_blank" href="https://pinia.vuejs.org/">Pinia</a>,
<a target="_blank" href="https://router.vuejs.org/">Vue Router</a>,
<a target="_blank" href="https://test-utils.vuejs.org/">Vue Test Utils</a>, and
<a target="_blank" href="https://github.com/vuejs/devtools">Vue Dev Tools</a>. If you need more
resources, we suggest paying
<a target="_blank" href="https://github.com/vuejs/awesome-vue">Awesome Vue</a>
a visit.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<CommunityIcon />
</template>
<template #heading>Community</template>
Got stuck? Ask your question on
<a target="_blank" href="https://chat.vuejs.org">Vue Land</a>, our official Discord server, or
<a target="_blank" href="https://stackoverflow.com/questions/tagged/vue.js">StackOverflow</a>.
You should also subscribe to
<a target="_blank" href="https://news.vuejs.org">our mailing list</a> and follow the official
<a target="_blank" href="https://twitter.com/vuejs">@vuejs</a>
twitter account for latest news in the Vue world.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<SupportIcon />
</template>
<template #heading>Support Vue</template>
As an independent project, Vue relies on community backing for its sustainability. You can help
us by
<a target="_blank" href="https://vuejs.org/sponsor/">becoming a sponsor</a>.
</WelcomeItem>
</template>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册