Commit 0847609bfb9567e281ca165cc9a2617e3cbb4bc1

Authored by 杨泽宇
1 parent 7b23d907

欢迎页dashboard

src/assets/logo.png

6.69 KB | W: | H:

9.7 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
src/layout/enter.vue
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 * @module Enter 4 * @module Enter
5 * @author Tengxi 5 * @author Tengxi
6 */ 6 */
7 -import { ref, computed } from "vue"; 7 +import { ref } from "vue";
8 import Header from "./header.vue"; 8 import Header from "./header.vue";
9 import Menu from "./menu.vue"; 9 import Menu from "./menu.vue";
10 import * as store from "@/pinia/index"; 10 import * as store from "@/pinia/index";
@@ -22,7 +22,7 @@ let key = ref("/") @@ -22,7 +22,7 @@ let key = ref("/")
22 </div> 22 </div>
23 <!-- TIP 左侧菜单结束 --> 23 <!-- TIP 左侧菜单结束 -->
24 <!-- TIP 右侧具体页面内容 --> 24 <!-- TIP 右侧具体页面内容 -->
25 - <div class="page-container" :class="store.family.appStore().isCollapse? 'thinMenu': 'fatMenu'"> 25 + <div :class="store.family.appStore().isCollapse? 'thinMenu': 'fatMenu'">
26 <router-view v-slot="{ Component, route }"> 26 <router-view v-slot="{ Component, route }">
27 <transition :name="route.meta.transitionName"> 27 <transition :name="route.meta.transitionName">
28 <keep-alive v-if="route.meta.keepAlive"> 28 <keep-alive v-if="route.meta.keepAlive">
src/layout/header.vue
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 * @module Header 4 * @module Header
5 * @author Tengxi 5 * @author Tengxi
6 */ 6 */
7 -import { getCurrentInstance, computed } from "vue"; 7 +import { getCurrentInstance } from "vue";
8 import * as store from "@/pinia/index"; 8 import * as store from "@/pinia/index";
9 import { Fold, Expand } from "@element-plus/icons-vue"; 9 import { Fold, Expand } from "@element-plus/icons-vue";
10 import styles from '@/style/global.module.scss'; 10 import styles from '@/style/global.module.scss';
@@ -53,7 +53,7 @@ const toggleMenu = () =&gt; { @@ -53,7 +53,7 @@ const toggleMenu = () =&gt; {
53 height: 60px; 53 height: 60px;
54 line-height: 60px; 54 line-height: 60px;
55 background-color: white; 55 background-color: white;
56 - box-shadow: 0 5px 10px -5px #888888; 56 + box-shadow: 0 1px 4px rgba(0,21,41,.08);
57 .left-logo { 57 .left-logo {
58 float: left; 58 float: left;
59 margin-top: 10px; 59 margin-top: 10px;
src/main.ts
@@ -29,7 +29,7 @@ console.log(&#39;current api url: &#39;, import.meta.env.VITE_BASE_URL) @@ -29,7 +29,7 @@ console.log(&#39;current api url: &#39;, import.meta.env.VITE_BASE_URL)
29 29
30 const app = createApp(App) 30 const app = createApp(App)
31 31
32 -// TIP 全局静态变量挂载 32 +// TIP 全局静态变量、方法挂载
33 for(const i in globalVariable) { 33 for(const i in globalVariable) {
34 app.config.globalProperties[i] = globalVariable[i] 34 app.config.globalProperties[i] = globalVariable[i]
35 } 35 }
src/router/index.ts
1 import { createRouter, createWebHashHistory } from 'vue-router' 1 import { createRouter, createWebHashHistory } from 'vue-router'
2 import Layout from '@/layout/enter.vue' 2 import Layout from '@/layout/enter.vue'
3 const routes: Array<any> = [ 3 const routes: Array<any> = [
4 - { path: '/', redirect: { name: 'Home' } }, 4 + { path: '/', redirect: { path: '/dashboard' } },
5 { 5 {
6 path: '/home', 6 path: '/home',
7 name: 'Home', 7 name: 'Home',
@@ -21,6 +21,18 @@ const routes: Array&lt;any&gt; = [ @@ -21,6 +21,18 @@ const routes: Array&lt;any&gt; = [
21 // component: () => import(/* webpackChunkName: "About" */ '@/views/tengxi/about.vue') 21 // component: () => import(/* webpackChunkName: "About" */ '@/views/tengxi/about.vue')
22 }, 22 },
23 { 23 {
  24 + path: '/',
  25 + component: Layout,
  26 + name: 'Dashboard',
  27 + children: [{
  28 + path: 'Dashboard',
  29 + name: 'Dashboard',
  30 + component: () => import(/* webpackChunkName: "About" */ '@/views/dashboard/index.vue'),
  31 + meta: { title: '欢迎访问' }
  32 + }]
  33 + // component: () => import(/* webpackChunkName: "About" */ '@/views/tengxi/about.vue')
  34 + },
  35 + {
24 path: '/login', 36 path: '/login',
25 name: 'Login', 37 name: 'Login',
26 component: () => import(/* webpackChunkName: "About" */ '@/views/user/login.vue') 38 component: () => import(/* webpackChunkName: "About" */ '@/views/user/login.vue')
src/style/menu.scss
@@ -7,10 +7,10 @@ @@ -7,10 +7,10 @@
7 left: 0; 7 left: 0;
8 top: 0; 8 top: 0;
9 } 9 }
10 - .page-container {  
11 - padding: 20px;  
12 - margin-left: $sideBarWidthThin;  
13 - } 10 +}
  11 +
  12 +.el-menu-vertical-demo {
  13 + min-height: calc(100vh - 60px);
14 } 14 }
15 15
16 .fatMenu { 16 .fatMenu {
src/style/reset.scss
@@ -65,3 +65,7 @@ div:focus { @@ -65,3 +65,7 @@ div:focus {
65 max-width: 99% !important; 65 max-width: 99% !important;
66 margin-top: 20px; 66 margin-top: 20px;
67 } 67 }
  68 +
  69 +.page-container {
  70 + padding: 30px;
  71 +}
src/utils/tool.ts
@@ -130,4 +130,27 @@ export function formatTime(time, option) { @@ -130,4 +130,27 @@ export function formatTime(time, option) {
130 '分' 130 '分'
131 ) 131 )
132 } 132 }
  133 +}
  134 +
  135 +/**
  136 + * @typeof {object} EnumData
  137 + * @property {number} value
  138 + * @property {string} label
  139 + */
  140 +/**
  141 + * 表格中枚举值filter
  142 + * @param {number} value
  143 + * @param {Array.EnumData} groupData
  144 + * @returns {string}
  145 + */
  146 +interface EnumData {
  147 + value: number,
  148 + label: string
  149 +}
  150 +export function globalFilters (value: number, groupData: EnumData[]) {
  151 + if(groupData.length && (value === 0 || !!value)) {
  152 + return groupData.find(item => item.value === value)['label']
  153 + } else {
  154 + return value
  155 + }
133 } 156 }
134 \ No newline at end of file 157 \ No newline at end of file
src/views/dashboard/index.vue 0 → 100644
  1 +<script setup lang="ts">
  2 +import {ref} from 'vue'
  3 +const title = ref(import.meta.env.VITE_APP_TITLE).value
  4 +</script>
  5 +
  6 +<template>
  7 + <div class="dashboard-container">
  8 + <div class="dashboard-logo"></div>
  9 + <h1>欢迎访问 -- {{title}}</h1>
  10 + </div>
  11 +</template>
  12 +
  13 +<style lang="scss" scoped>
  14 +.dashboard {
  15 + &-container {
  16 + padding-top: 200px;
  17 + min-height: calc(100vh - 60px);
  18 + background: #f0f2f5;
  19 + }
  20 + &-logo {
  21 + width: 200px;
  22 + height: 200px;
  23 + margin: 0 auto;
  24 + background-color: pink;
  25 + background-image: url('@/assets/logo.png');
  26 + background-repeat: no-repeat;
  27 + background-size: contain;
  28 + background-position: 0;
  29 + }
  30 +}
  31 +</style>
src/views/tengxi/about.vue
1 <script setup lang="ts"> 1 <script setup lang="ts">
2 -import { reactive } from "vue"; 2 +import { reactive,getCurrentInstance } from "vue";
  3 +import {globalFilters} from '@/utils/tool'
3 // import {tengxiTestStore} from '@/pinia/index' 4 // import {tengxiTestStore} from '@/pinia/index'
4 import * as all from '@/pinia/index' 5 import * as all from '@/pinia/index'
5 console.log(all) 6 console.log(all)
@@ -10,23 +11,50 @@ const data = reactive([ @@ -10,23 +11,50 @@ const data = reactive([
10 date: "2016-05-02", 11 date: "2016-05-02",
11 name: "王小虎1", 12 name: "王小虎1",
12 address: "上海市普陀区金沙江路 1518 弄", 13 address: "上海市普陀区金沙江路 1518 弄",
  14 + status: 1
13 }, 15 },
14 { 16 {
15 date: "2016-05-04", 17 date: "2016-05-04",
16 name: "王小虎", 18 name: "王小虎",
17 address: "上海市普陀区金沙江路 1517 弄", 19 address: "上海市普陀区金沙江路 1517 弄",
  20 + status: 2
18 }, 21 },
19 { 22 {
20 date: "2016-05-01", 23 date: "2016-05-01",
21 name: "王小虎", 24 name: "王小虎",
22 address: "上海市普陀区金沙江路 1519 弄", 25 address: "上海市普陀区金沙江路 1519 弄",
  26 + status: null
23 }, 27 },
24 { 28 {
25 date: "2016-05-03", 29 date: "2016-05-03",
26 name: "王小虎", 30 name: "王小虎",
27 address: "上海市普陀区金沙江路 1516 弄", 31 address: "上海市普陀区金沙江路 1516 弄",
  32 + status: 0
28 }, 33 },
29 ]); 34 ]);
  35 +
  36 +const statusArray = [{
  37 + label: '启用',
  38 + value: 1
  39 +}, {
  40 + label: '禁用',
  41 + value: 2
  42 +}, {
  43 + label: '舍弃',
  44 + value: 0
  45 +}, {
  46 + label: '上线',
  47 + value: 3
  48 +}]
  49 +
  50 +// const filterStatus = (status) => {
  51 +// return statusArray.find(item => ~~item.value == ~~status)['label']
  52 +// }
  53 +
  54 +const thisLine = (obj) => {
  55 + console.log(obj.status)
  56 +}
  57 +
30 // const addAge = () => { 58 // const addAge = () => {
31 // console.log('add one age') 59 // console.log('add one age')
32 // console.log(store.age) 60 // console.log(store.age)
@@ -39,15 +67,27 @@ const data = reactive([ @@ -39,15 +67,27 @@ const data = reactive([
39 </script> 67 </script>
40 68
41 <template> 69 <template>
42 - <!-- <p class="tengxi">Tengxi About Page</p>  
43 - <el-button type="primary">成功</el-button>  
44 - <p>测试pinia数据:{{all.family.dataStore().data1}}</p> -->  
45 - <!-- <el-button @click="addAge">长一岁</el-button>  
46 - <el-button @click="initPinia">初始化pinia</el-button> --> 70 + <div class="page-container">
  71 + <!-- <p class="tengxi">Tengxi About Page</p>
  72 + <el-button type="primary">成功</el-button>
  73 + <p>测试pinia数据:{{all.family.dataStore().data1}}</p> -->
  74 + <!-- <el-button @click="addAge">长一岁</el-button>
  75 + <el-button @click="initPinia">初始化pinia</el-button> -->
47 76
48 - <el-table :data="data" style="width: 100%">  
49 - <el-table-column prop="date" label="日期" width="180"> </el-table-column>  
50 - <el-table-column prop="name" label="姓名" width="180"> </el-table-column>  
51 - <el-table-column prop="address" label="地址"> </el-table-column>  
52 - </el-table> 77 + <el-table :data="data" style="width: 100%" border>
  78 + <el-table-column prop="date" label="日期" width="180"> </el-table-column>
  79 + <el-table-column prop="name" label="姓名" width="180"> </el-table-column>
  80 + <el-table-column prop="address" label="地址"> </el-table-column>
  81 + <el-table-column prop="status" label="状态">
  82 + <template #default="scope">
  83 + {{globalFilters(scope.row.status, statusArray)}}
  84 + </template>
  85 + </el-table-column>
  86 + <el-table-column label="按钮">
  87 + <template #default="scope">
  88 + <el-button type="primary" @click="thisLine(scope.row)">哈哈</el-button>
  89 + </template>
  90 + </el-table-column>
  91 + </el-table>
  92 + </div>
53 </template> 93 </template>