提交 52516324 编写于 作者: yma16's avatar yma16

perf: 封装挑战榜的事件点击

上级 85cea1e0
<template> <template>
<div id="app"> <div id="app">
<el-container> <el-container>
<el-aside v-if="navigate_flag ? false : true"> <el-aside v-if="!navigate_flag">
<router-link to="/"> <router-link to="/">
<svg <svg
class="icon" class="icon"
...@@ -78,9 +78,9 @@ ...@@ -78,9 +78,9 @@
>{{ authSlogan }}</span >{{ authSlogan }}</span
></a ></a
> >
<i style="font-weight: bold; font-style: normal" v-if="chat_flag" <!-- <i style="font-weight: bold; font-style: normal" v-if="chat_flag"-->
>&nbsp;&nbsp;在线聊天室</i <!-- >&nbsp;&nbsp;在线聊天室</i-->
> <!-- >-->
<div style="float: right; overflow: hidden;display: flex;justify-items: center;align-items:center;word-spacing: 16px;"> <div style="float: right; overflow: hidden;display: flex;justify-items: center;align-items:center;word-spacing: 16px;">
<a href="https://codechina.csdn.net/qq_38870145/myblogvue" <a href="https://codechina.csdn.net/qq_38870145/myblogvue"
><img ><img
......
...@@ -5,15 +5,15 @@ const _products = [ ...@@ -5,15 +5,15 @@ const _products = [
] ]
export default { export default {
getProducts(cb) { getProducts (cb) {
setTimeout(() => cb(_products), 100) setTimeout(() => cb(_products), 100)
}, },
buyProducts(products, cb, errorCb) { buyProducts (products, cb, errorCb) {
setTimeout(() => { setTimeout(() => {
// simulate random checkout failure. // simulate random checkout failure.
(Math.random() > 0.5 || navigator.webdriver) ? (Math.random() > 0.5 || navigator.webdriver)
cb(): errorCb() ? cb() : errorCb()
}, 100) }, 100)
} }
} }
...@@ -62,17 +62,17 @@ ...@@ -62,17 +62,17 @@
> >
<h1>{{ day_challenge }}</h1> <h1>{{ day_challenge }}</h1>
<ul <ul
v-for="(item, index) in challenge_data" v-for="(item, index) in challengeConfig"
:key="item" :key="index"
class="ul_style" class="ul_style"
> >
<div <div
v-bind:class="[ v-bind:class="[
{ li_active: index == challenge_loc }, { li_active: index === challenge_loc },
li_errorClass, li_errorClass,
]" ]"
> >
<li @click="cssPage(index)">{{ item }}</li> <li @click="clickChallengeEvent(item,index)">{{ item.title }}</li>
</div> </div>
</ul> </ul>
</el-card> </el-card>
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
shadow="always" shadow="always"
style="position: static; margin-top: 2%;text-align: center" style="position: static; margin-top: 2%;text-align: center"
> >
<span style="line-height: 30px;" class="uni-font">爬取天气预报</span> <span style="line-height: 30px;" class="uni-font">未来天气</span>
<div style="positon: relative; width: 100%; height: 100%"> <div style="positon: relative; width: 100%; height: 100%">
<EchartWeather> </EchartWeather> <EchartWeather> </EchartWeather>
</div> </div>
...@@ -148,17 +148,17 @@ ...@@ -148,17 +148,17 @@
> >
<h1>{{ day_challenge }}</h1> <h1>{{ day_challenge }}</h1>
<ul <ul
v-for="(item, index) in challenge_data" v-for="(item, index) in challengeConfig"
:key="item" :key="index"
class="ul_style" class="ul_style"
> >
<div <div
v-bind:class="[ v-bind:class="[
{ li_active: index == challenge_loc }, { li_active: index === challenge_loc },
li_errorClass, li_errorClass,
]" ]"
> >
<li @click="cssPage(index)">{{ item }}</li> <li @click="clickChallengeEvent(item,index)">{{ item.title }}</li>
</div> </div>
</ul> </ul>
</el-card> </el-card>
...@@ -199,7 +199,6 @@ ...@@ -199,7 +199,6 @@
/></a> /></a>
</el-card> </el-card>
</div> </div>
<!-- 上滑滚动图标 --> <!-- 上滑滚动图标 -->
<div class="rightclass"> <div class="rightclass">
...@@ -274,13 +273,51 @@ export default { ...@@ -274,13 +273,51 @@ export default {
msg: '内容', msg: '内容',
commmentSlogan: '评论区', commmentSlogan: '评论区',
day_challenge: '训练营', day_challenge: '训练营',
challenge_data: [ challengeConfig: [
'css挑战', {
'websocket聊天', title: 'css挑战',
'echarts地图配置', order: 1,
'vue3测试平台', isJumpPath: true,
'数据可视化平台', isJumpUrl: false,
'更新中' path: '/css'
},
{
title: 'websocket聊天',
order: 2,
isJumpPath: true,
isJumpUrl: false,
path: '/onlinewebsocket'
},
{
title: 'echarts地图配置',
order: 3,
isJumpPath: true,
isJumpUrl: false,
path: '/home'
},
{
title: 'vue3测试平台',
order: 4,
isJumpPath: false,
isJumpUrl: true,
url: 'http://yongma16.xyz/emoji_api/',
path: ''
},
{
title: '数据可视化平台',
order: 5,
isJumpPath: false,
isJumpUrl: true,
url: 'https://yongma16.xyz/fund-web',
path: ''
},
{
title: '更新中',
order: 6,
isJumpPath: false,
isJumpUrl: false,
path: ''
}
], ],
md_data: [], md_data: [],
md_title: [], md_title: [],
...@@ -435,45 +472,18 @@ export default { ...@@ -435,45 +472,18 @@ export default {
} }
}, },
li_errorClass: function () {}, li_errorClass: function () {},
cssPage: function (index) { clickChallengeEvent: function (item, index) {
this.challenge_loc = index this.challenge_loc = index
let name = this.challenge_data[index] if (item.isJumpPath) {
switch (name) {
case 'css挑战':
this.$router this.$router
.push({ .push({
path: '/css' path: item.path
}) })
.catch((error) => { .catch((error) => {
throw Error(error) throw Error(error)
}) })
break } else if (item.isJumpUrl) {
case 'echarts地图配置': window.open(item.url)
this.$router
.push({
path: '/home'
})
.catch((error) => {
throw Error(error)
})
break
case 'websocket聊天':
this.$router
.push({
path: '/onlinewebsocket'
})
.catch((error) => {
throw Error(error)
})
break
case 'vue3测试平台':
window.open('http://yongma16.xyz/emoji_api/')
break
case '数据可视化平台':
window.open('https://yongma16.xyz/fund-web')
break
default:
break
} }
}, },
open_message: function () { open_message: function () {
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</template> </template>
<script> <script>
// import * as echarts from 'echarts' import * as echarts from 'echarts'
export default { export default {
name: 'Map', name: 'Map',
......
// The Vue build version to load with the `import` command // The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
//vue cdn // vue cdn
// import Vue from 'vue' import Vue from 'vue'
// import VueRouter from 'vue-router' import VueRouter from 'vue-router'
// import axios from 'axios' import axios from 'axios'
// import hljs from 'highlight.js' import hljs from 'highlight.js'
// import * as echarts from 'echarts' import * as echarts from 'echarts'
// import importElementComponents from './importElement' import importElementComponents from './importElement'
// import importEchartsComponents from './importEchartsComponents' import importEchartsComponents from './importEchartsComponents'
// 样式cnd // 样式cnd
// import 'github-markdown-css/github-markdown.css' import 'github-markdown-css/github-markdown.css'
// import 'nprogress/nprogress.css' import 'nprogress/nprogress.css'
// 无需cdn // 无需cdn
import useRouter from './router' import useRouter from './router'
import cookies from 'vue-cookies' import cookies from 'vue-cookies'
...@@ -57,11 +57,11 @@ if (env === 'production') { ...@@ -57,11 +57,11 @@ if (env === 'production') {
// 路由 // 路由
const router = useRouter(Vue, VueRouter) const router = useRouter(Vue, VueRouter)
// // 按需引入elementui // 按需引入elementui
// importElementComponents(Vue) importElementComponents(Vue)
//
// // 按需引入echarts // 按需引入echarts
// importEchartsComponents(Vue) importEchartsComponents(Vue)
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(cookies) Vue.use(cookies)
......
// import Vue from 'vue' import Vue from 'vue'
// import Vuex from 'vuex' import Vuex from 'vuex'
// import createLogger from '../../../src/plugins/logger' // import createLogger from '../../../src/plugins/logger'
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</template> </template>
<script> <script>
// import * as echarts from 'echarts' import * as echarts from 'echarts'
export default { export default {
name: 'EchartWeather', name: 'EchartWeather',
data () { data () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册