feat:增加状态存储
This commit is contained in:
22
src/App.vue
22
src/App.vue
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
<!-- 英雄区域 -->
|
<!-- 英雄区域 -->
|
||||||
<HeroSection
|
<HeroSection
|
||||||
:personal-info="personalInfo"
|
|
||||||
@scroll-to-section="scrollToSection"
|
@scroll-to-section="scrollToSection"
|
||||||
></HeroSection>
|
></HeroSection>
|
||||||
|
|
||||||
@@ -33,13 +32,13 @@
|
|||||||
<!-- 联系方式 -->
|
<!-- 联系方式 -->
|
||||||
<ContactSection
|
<ContactSection
|
||||||
:contact-info="contactInfo"
|
:contact-info="contactInfo"
|
||||||
:social-links="personalInfo.socials"
|
:social-links="profileStore.personalInfo.socials"
|
||||||
section-id="contact"
|
section-id="contact"
|
||||||
></ContactSection>
|
></ContactSection>
|
||||||
|
|
||||||
<!-- 页脚 -->
|
<!-- 页脚 -->
|
||||||
<Footer
|
<Footer
|
||||||
:name="personalInfo.name"
|
:name="profileStore.personalInfo.name"
|
||||||
></Footer>
|
></Footer>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -54,6 +53,10 @@ import EducationSection from './components/EducationSection.vue'
|
|||||||
import ContactSection from './components/ContactSection.vue'
|
import ContactSection from './components/ContactSection.vue'
|
||||||
import Footer from './components/Footer.vue'
|
import Footer from './components/Footer.vue'
|
||||||
|
|
||||||
|
import { useProfileStore } from '@/store/profile.js'
|
||||||
|
|
||||||
|
const profileStore = useProfileStore()
|
||||||
|
|
||||||
// 滚动位置
|
// 滚动位置
|
||||||
const scrollPosition = ref(0)
|
const scrollPosition = ref(0)
|
||||||
|
|
||||||
@@ -78,19 +81,6 @@ const scrollToSection = (sectionId) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 个人信息数据
|
|
||||||
const personalInfo = {
|
|
||||||
name: '陈修翔',
|
|
||||||
title: '全栈工程师',
|
|
||||||
description: '拥有5年前端开发经验,专注于构建响应式、高性能的现代Web应用,精通JavaScript、React和Vue等前端技术栈。',
|
|
||||||
socials: [
|
|
||||||
{ name: 'GitHub', icon: 'fa-brands fa-github', url: '#' },
|
|
||||||
{ name: 'LinkedIn', icon: 'fa-brands fa-linkedin', url: '#' },
|
|
||||||
{ name: 'Twitter', icon: 'fa-brands fa-twitter', url: '#' },
|
|
||||||
{ name: 'Email', icon: 'fa-solid fa-envelope', url: '#' }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
// 技能数据
|
// 技能数据
|
||||||
const skills = [
|
const skills = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,14 +10,15 @@
|
|||||||
|
|
||||||
<div class="hero-info animate__animated animate__fadeIn animate__delay-300">
|
<div class="hero-info animate__animated animate__fadeIn animate__delay-300">
|
||||||
<h1>
|
<h1>
|
||||||
{{ personalInfo.name }} <span class="title-highlight">/ {{ personalInfo.title }}</span>
|
{{ profileStore.personalInfo.name }}
|
||||||
|
<span class="title-highlight">/ {{ profileStore.personalInfo.title }}</span>
|
||||||
</h1>
|
</h1>
|
||||||
<p class="description">{{ personalInfo.description }}</p>
|
<p class="description">{{ profileStore.personalInfo.description }}</p>
|
||||||
|
|
||||||
<!-- 社交媒体链接 -->
|
<!-- 社交媒体链接 -->
|
||||||
<div class="social-links">
|
<div class="social-links">
|
||||||
<a
|
<a
|
||||||
v-for="(social, index) in personalInfo.socials"
|
v-for="(social, index) in profileStore.personalInfo.socials"
|
||||||
:key="index"
|
:key="index"
|
||||||
:href="social.url"
|
:href="social.url"
|
||||||
:title="social.name"
|
:title="social.name"
|
||||||
@@ -52,16 +53,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps } from 'vue'
|
|
||||||
import { getAssetsImageFile } from '@/utils/index.js'
|
import { getAssetsImageFile } from '@/utils/index.js'
|
||||||
|
import { useProfileStore } from '@/store/profile.js'
|
||||||
|
|
||||||
// 接收个人信息属性
|
const profileStore = useProfileStore()
|
||||||
const props = defineProps({
|
|
||||||
personalInfo: {
|
|
||||||
type: Object,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 定义事件
|
// 定义事件
|
||||||
const emits = defineEmits(['scroll-to-section'])
|
const emits = defineEmits(['scroll-to-section'])
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
|
import { createPinia } from 'pinia'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
|
|
||||||
// 引入element-ui组件
|
// 引入element-ui组件
|
||||||
@@ -16,6 +17,7 @@ import 'animate.css'
|
|||||||
|
|
||||||
// 创建Vue3实例
|
// 创建Vue3实例
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
app.use(createPinia())
|
||||||
// 使用Element UI Plus
|
// 使用Element UI Plus
|
||||||
app.use(ElementPlus, { locale: zhCn })
|
app.use(ElementPlus, { locale: zhCn })
|
||||||
// 挂载到根组件上
|
// 挂载到根组件上
|
||||||
|
|||||||
20
src/store/profile.ts
Normal file
20
src/store/profile.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const useProfileStore = defineStore('profile', {
|
||||||
|
state: () => ({
|
||||||
|
personalInfo: {
|
||||||
|
name: '陈修翔',
|
||||||
|
title: '全栈工程师',
|
||||||
|
description: '拥有5年前端开发经验,专注于构建响应式、高性能的现代Web应用,精通JavaScript、React和Vue等前端技术栈。',
|
||||||
|
socials: [
|
||||||
|
{ name: 'GitHub', icon: 'fa-brands fa-github', url: '#' },
|
||||||
|
{ name: 'LinkedIn', icon: 'fa-brands fa-linkedin', url: '#' },
|
||||||
|
{ name: 'Twitter', icon: 'fa-brands fa-twitter', url: '#' },
|
||||||
|
{ name: 'Email', icon: 'fa-solid fa-envelope', url: '#' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
actions: {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user