diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue index 50c4d75..d167419 100644 --- a/src/components/HelloWorld.vue +++ b/src/components/HelloWorld.vue @@ -1,32 +1,6 @@ diff --git a/src/store/index.js b/src/store/index.js index ceffa8e..a2980e3 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,17 +1,42 @@ import Vue from 'vue' import Vuex from 'vuex' +import user from "@/store/modules/user"; +import test from "@/store/modules/test"; Vue.use(Vuex) export default new Vuex.Store({ state: { + count: 0 }, + getters: { + doubleCount: state => state.count * 2 }, + mutations: { + increment(state) { + state.count++ + }, + + reset(state) { + state.count = 0 + }, + + setValue(state, value) { + state.count = value + } }, + actions: { + asyncIncrement({commit}) { + setTimeout(() => { + commit('increment') + }, 1000) + } }, modules: { + user, + test } }) diff --git a/src/store/modules/test.js b/src/store/modules/test.js new file mode 100644 index 0000000..60d72eb --- /dev/null +++ b/src/store/modules/test.js @@ -0,0 +1,32 @@ +export default { + namespaced: true, + state: { + count: 0 + }, + + getters: { + doubleCount: state => state.count * 2 + }, + + mutations: { + increment(state) { + state.count++ + }, + + reset(state) { + state.count = 0 + }, + + setValue(state, value) { + state.count = value + } + }, + + actions: { + asyncIncrement({commit}) { + setTimeout(() => { + commit('increment') + }, 1000) + } + } +} \ No newline at end of file diff --git a/src/store/modules/user.js b/src/store/modules/user.js new file mode 100644 index 0000000..0101ef4 --- /dev/null +++ b/src/store/modules/user.js @@ -0,0 +1,14 @@ +export default { + namespaced: true, + state: { + userList: [] + }, + getters: { + userList: state => state.userList + }, + mutations: { + + }, + actions: {}, + modules: {} +} diff --git a/src/template/ChildTemplate.vue b/src/template/ChildTemplate.vue new file mode 100644 index 0000000..788c332 --- /dev/null +++ b/src/template/ChildTemplate.vue @@ -0,0 +1,72 @@ + + + + + \ No newline at end of file diff --git a/src/template/FatherTemplate.vue b/src/template/FatherTemplate.vue new file mode 100644 index 0000000..ee980fb --- /dev/null +++ b/src/template/FatherTemplate.vue @@ -0,0 +1,133 @@ + + + + + \ No newline at end of file diff --git a/src/template/cssTemplate.css b/src/template/cssTemplate.css new file mode 100644 index 0000000..b9bdd85 --- /dev/null +++ b/src/template/cssTemplate.css @@ -0,0 +1,398 @@ +/* ===== 布局样式 ===== */ + +/* + * 居中容器 + * 用途:创建一个水平居中的容器,有最大宽度限制 + * 适用场景:页面主内容区域,卡片容器等 + */ +.container { + max-width: 1200px; /* 最大宽度限制 */ + margin: 0 auto; /* 水平居中 */ + padding: 0 20px; /* 两侧内边距,确保小屏幕有边距 */ +} + +/* + * Flexbox布局 - 水平排列 + * 用途:创建灵活的水平排列布局 + * 适用场景:导航菜单,工具栏,卡片列表等 + */ +.flex-row { + display: flex; /* 启用弹性布局 */ + flex-direction: row; /* 水平方向排列(默认) */ + flex-wrap: wrap; /* 允许换行 */ + gap: 20px; /* 项目间距 */ +} + +/* + * Flexbox布局 - 垂直排列 + * 用途:创建灵活的垂直排列布局 + * 适用场景:侧边栏菜单,表单布局等 + */ +.flex-column { + display: flex; + flex-direction: column; /* 垂直方向排列 */ + gap: 15px; /* 项目间距 */ +} + +/* + * 网格布局 - 自动响应式列 + * 用途:创建自动调整的多列布局 + * 适用场景:图片库,产品列表,卡片网格等 + */ +.grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); /* 自动填充列,最小250px */ + gap: 20px; /* 网格间距 */ +} + +/* + * 两列布局 - 侧边栏和主内容 + * 用途:创建经典的侧边栏+主内容布局 + * 适用场景:管理界面,博客布局等 + */ +.two-column-layout { + display: grid; + grid-template-columns: 250px 1fr; /* 固定宽度侧边栏 + 自适应主内容 */ + gap: 30px; /* 列间距 */ +} + +/* ===== 定位样式 ===== */ + +/* + * 绝对居中定位 + * 用途:将元素精确居中于父容器 + * 适用场景:模态框,加载指示器,弹出提示等 + */ +.absolute-center { + position: absolute; /* 绝对定位 */ + top: 50%; /* 顶部50% */ + left: 50%; /* 左侧50% */ + transform: translate(-50%, -50%); /* 向左上偏移自身50%,实现精确居中 */ +} + +/* + * 固定顶部导航 + * 用途:创建始终固定在视口顶部的导航栏 + * 适用场景:网站主导航,固定标题栏等 + */ +.fixed-top { + position: fixed; /* 固定定位 */ + top: 0; /* 顶部对齐 */ + left: 0; /* 左侧对齐 */ + right: 0; /* 右侧对齐,确保宽度填满 */ + z-index: 1000; /* 确保显示在其他内容上方 */ + background-color: white; /* 背景色 */ + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* 轻微阴影 */ +} + +/* + * 粘性定位 + * 用途:元素在滚动到特定位置时固定 + * 适用场景:分类标题,导航菜单等 + */ +.sticky-element { + position: sticky; /* 粘性定位 */ + top: 20px; /* 距顶部20px时固定 */ + z-index: 100; /* 层叠顺序 */ +} + +/* ===== 卡片和容器样式 ===== */ + +/* + * 基础卡片 + * 用途:创建带阴影和圆角的卡片容器 + * 适用场景:内容卡片,信息展示,产品项等 + */ +.card { + background-color: white; + border-radius: 8px; /* 圆角 */ + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* 阴影效果 */ + padding: 20px; + margin-bottom: 20px; +} + +/* + * 带边框的容器 + * 用途:创建带边框的内容容器 + * 适用场景:分组内容,设置区域等 + */ +.bordered-container { + border: 1px solid #e0e0e0; /* 浅灰色边框 */ + border-radius: 4px; /* 轻微圆角 */ + padding: 15px; + margin-bottom: 15px; +} + +/* + * 分割线 + * 用途:创建内容分隔线 + * 适用场景:分隔不同内容区域 + */ +.divider { + height: 1px; + background-color: #e0e0e0; /* 浅灰色 */ + margin: 20px 0; /* 上下外边距 */ + width: 100%; +} + +/* ===== 按钮样式 ===== */ + +/* + * 主要按钮 + * 用途:突出显示主要操作按钮 + * 适用场景:提交按钮,确认按钮等 + */ +.btn-primary { + background-color: #4caf50; /* 绿色 */ + color: white; + border: none; + border-radius: 4px; + padding: 10px 20px; + font-size: 16px; + cursor: pointer; + transition: background-color 0.3s; /* 过渡效果 */ +} + +.btn-primary:hover { + background-color: #45a049; /* 深绿色 */ +} + +/* + * 次要按钮 + * 用途:次要操作按钮 + * 适用场景:取消按钮,返回按钮等 + */ +.btn-secondary { + background-color: #f5f5f5; /* 浅灰色 */ + color: #333; + border: 1px solid #ddd; + border-radius: 4px; + padding: 10px 20px; + font-size: 16px; + cursor: pointer; + transition: background-color 0.3s; +} + +.btn-secondary:hover { + background-color: #e0e0e0; /* 深灰色 */ +} + +/* + * 危险按钮 + * 用途:表示危险或删除操作 + * 适用场景:删除按钮,危险操作等 + */ +.btn-danger { + background-color: #f44336; /* 红色 */ + color: white; + border: none; + border-radius: 4px; + padding: 10px 20px; + font-size: 16px; + cursor: pointer; + transition: background-color 0.3s; +} + +.btn-danger:hover { + background-color: #d32f2f; /* 深红色 */ +} + +/* ===== 表单样式 ===== */ + +/* + * 表单组 + * 用途:为表单元素创建一致的布局 + * 适用场景:登录表单,注册表单等 + */ +.form-group { + margin-bottom: 20px; +} + +/* + * 表单标签 + * 用途:为表单元素创建标签 + * 适用场景:任何需要标签的表单元素 + */ +.form-label { + display: block; + margin-bottom: 5px; + font-weight: 500; + color: #333; +} + +/* + * 表单输入框 + * 用途:创建一致样式的输入框 + * 适用场景:文本输入,邮箱输入等 + */ +.form-input { + width: 100%; + padding: 10px; + border: 1px solid #ddd; + border-radius: 4px; + font-size: 16px; + transition: border-color 0.3s; +} + +.form-input:focus { + border-color: #4caf50; /* 聚焦时边框变色 */ + outline: none; /* 移除默认聚焦轮廓 */ +} + +/* + * 表单错误状态 + * 用途:显示输入错误状态 + * 适用场景:表单验证失败 + */ +.form-input.error { + border-color: #f44336; /* 红色边框 */ +} + +.error-message { + color: #f44336; + font-size: 14px; + margin-top: 5px; +} + +/* ===== 响应式工具 ===== */ + +/* + * 响应式隐藏类 + * 用途:在不同屏幕尺寸隐藏元素 + * 适用场景:响应式设计,移动优先设计 + */ +@media (max-width: 768px) { + .hide-on-mobile { + display: none !important; + } +} + +@media (min-width: 769px) { + .hide-on-desktop { + display: none !important; + } +} + +/* + * 响应式文本对齐 + * 用途:在不同屏幕尺寸改变文本对齐方式 + * 适用场景:响应式排版 + */ +@media (max-width: 768px) { + .text-center-mobile { + text-align: center !important; + } +} + +/* ===== 辅助工具类 ===== */ + +/* + * 文本截断 (单行) + * 用途:截断过长文本并显示省略号 + * 适用场景:卡片标题,列表项等 + */ +.text-truncate { + white-space: nowrap; /* 禁止换行 */ + overflow: hidden; /* 隐藏溢出内容 */ + text-overflow: ellipsis; /* 显示省略号 */ +} + +/* + * 文本截断 (多行) + * 用途:截断多行文本并显示省略号 + * 适用场景:卡片描述,文章摘要等 + */ +.text-truncate-multiline { + display: -webkit-box; + -webkit-line-clamp: 3; /* 显示行数 */ + -webkit-box-orient: vertical; + overflow: hidden; +} + +/* + * 图片响应式 + * 用途:使图片自适应容器宽度 + * 适用场景:文章图片,产品图片等 + */ +.img-responsive { + max-width: 100%; /* 最大宽度为容器宽度 */ + height: auto; /* 保持宽高比 */ + display: block; /* 块级显示 */ +} + +/* + * 圆形图片 + * 用途:创建圆形图片 + * 适用场景:头像,图标等 + */ +.img-circle { + border-radius: 50%; /* 圆形 */ + object-fit: cover; /* 保持宽高比并填充 */ +} + +/* + * 阴影效果 + * 用途:为元素添加阴影 + * 适用场景:卡片,按钮,弹窗等 + */ +.shadow-sm { + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); /* 小阴影 */ +} + +.shadow { + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* 中等阴影 */ +} + +.shadow-lg { + box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1); /* 大阴影 */ +} + +/* + * 间距工具 + * 用途:快速添加外边距和内边距 + * 适用场景:任何需要调整间距的元素 + */ +.m-0 { + margin: 0 !important; +} + +.mt-1 { + margin-top: 0.25rem !important; +} + +.mb-2 { + margin-bottom: 0.5rem !important; +} + +.ml-3 { + margin-left: 1rem !important; +} + +.mr-4 { + margin-right: 1.5rem !important; +} + +.mx-auto { + margin-left: auto !important; + margin-right: auto !important; +} + +.p-0 { + padding: 0 !important; +} + +.pt-1 { + padding-top: 0.25rem !important; +} + +.pb-2 { + padding-bottom: 0.5rem !important; +} + +.pl-3 { + padding-left: 1rem !important; +} + +.pr-4 { + padding-right: 1.5rem !important; +} \ No newline at end of file diff --git a/src/template/storeTemplate.js b/src/template/storeTemplate.js new file mode 100644 index 0000000..b815467 --- /dev/null +++ b/src/template/storeTemplate.js @@ -0,0 +1,36 @@ +import Vue from 'vue' +import Vuex from 'vuex' + +Vue.use(Vuex) + +export default new Vuex.Store({ + state: { + count: 0 + }, + + getters: { + doubleCount: state => state.count * 2 + }, + + mutations: { + increment(state) { + state.count++ + }, + + reset(state) { + state.count = 0 + }, + + setValue(state, value) { + state.count = value + } + }, + + actions: { + asyncIncrement({ commit }) { + setTimeout(() => { + commit('increment') + }, 1000) + } + } +}) \ No newline at end of file diff --git a/src/views/AboutView.vue b/src/views/AboutView.vue index 3fa2807..d47aa35 100644 --- a/src/views/AboutView.vue +++ b/src/views/AboutView.vue @@ -1,5 +1,128 @@ + + + + + \ No newline at end of file diff --git a/src/views/ChildComponent.vue b/src/views/ChildComponent.vue new file mode 100644 index 0000000..788c332 --- /dev/null +++ b/src/views/ChildComponent.vue @@ -0,0 +1,72 @@ + + + + + \ No newline at end of file diff --git a/src/views/Father.vue b/src/views/Father.vue new file mode 100644 index 0000000..f04c176 --- /dev/null +++ b/src/views/Father.vue @@ -0,0 +1,90 @@ + + + + + \ No newline at end of file