Browse Source

修改成一个组件

layui
liaoxinyu 2 years ago
parent
commit
53532508ff
  1. 37
      src/components/GqlUsdt.vue
  2. 37
      src/components/OigeUsdt.vue
  3. 17
      src/components/PytnUsdt.vue
  4. 37
      src/components/RpnUsdt.vue
  5. 21
      src/router/index.js
  6. 54
      src/views/HomeView.vue

37
src/components/GqlUsdt.vue

@ -1,37 +0,0 @@
<template>
<div>
<div id="kc-container"></div>
</div>
</template>
<script>
// import $ from 'jquery';
export default {
name: "GqlUsdt",
props: ["title"],
data() {
return {
loadingIndex: null
}
},
mounted() {
this.init()
},
methods: {
init() {
kcStart({
containerId: 'kc-container',
symbol: this.title,
coinScale: parseInt('5'), //
volumeScale: parseInt('5'), //
interval: '15',
timezone: "America/Toronto",
language: 'zh_TW'
})
}
},
};
</script>
<style scoped>
</style>

37
src/components/OigeUsdt.vue

@ -1,37 +0,0 @@
<template>
<div>
<div id="kc-container"></div>
</div>
</template>
<script>
// import $ from 'jquery';
export default {
name: "OigeUsdt",
props: ["title"],
data() {
return {
loadingIndex: null
}
},
mounted() {
this.init()
},
methods: {
init() {
kcStart({
containerId: 'kc-container',
symbol: this.title,
coinScale: parseInt('5'), //
volumeScale: parseInt('5'), //
interval: '15',
timezone: "America/Toronto",
language: 'zh_TW'
})
}
},
};
</script>
<style scoped>
</style>

17
src/components/PytnUsdt.vue

@ -8,7 +8,6 @@
// import $ from 'jquery'; // import $ from 'jquery';
export default { export default {
name: "HelloWorld", name: "HelloWorld",
props: ["title"],
data() { data() {
return { return {
loadingIndex: null loadingIndex: null
@ -17,14 +16,26 @@
mounted() { mounted() {
this.init() this.init()
}, },
watch: {
'$route'(to, from) {
// 访tofrom
if(to.query.symbol!=from.query.symbol){
location.reload()
setTimeout(()=>{
this.init()
},1000)
}
}
},
methods: { methods: {
init() { init() {
kcStart({ kcStart({
containerId: 'kc-container', containerId: 'kc-container',
symbol: this.title, symbol: this.$route.query.symbol,
coinScale: parseInt('5'), // coinScale: parseInt('5'), //
volumeScale: parseInt('5'), // volumeScale: parseInt('5'), //
interval: '15', interval: sessionStorage.getItem('interval')|this.$route.query.interval,
timezone: "America/Toronto", timezone: "America/Toronto",
language: 'zh_TW' language: 'zh_TW'
}) })

37
src/components/RpnUsdt.vue

@ -1,37 +0,0 @@
<template>
<div>
<div id="kc-container"></div>
</div>
</template>
<script>
// import $ from 'jquery';
export default {
name: "RpnUsdt",
props: ["title"],
data() {
return {
loadingIndex: null
}
},
mounted() {
this.init()
},
methods: {
init() {
kcStart({
containerId: 'kc-container',
symbol: this.title,
coinScale: parseInt('5'), //
volumeScale: parseInt('5'), //
interval: '15',
timezone: "America/Toronto",
language: 'zh_TW'
})
}
},
};
</script>
<style scoped>
</style>

21
src/router/index.js

@ -7,34 +7,17 @@ Vue.use(VueRouter);
const routes = [ const routes = [
{ {
path: "", path: "",
redirect: "/PytnUsdt", redirect: "/KlineView",
}, },
{ {
path: "/", path: "/",
// name: "home", // name: "home",
component: HomeView, component: HomeView,
children: [ children: [
// {
// path: '',
// name: 'PyttnUsdt', // 默认子路由名称
// redirect: 'PyttnUsdt'
// },
{ {
path: 'PytnUsdt', path: 'KlineView',
// name: 'PyttnUsdt', // 默认子路由名称 // name: 'PyttnUsdt', // 默认子路由名称
component: () => import("../components/PytnUsdt.vue") component: () => import("../components/PytnUsdt.vue")
},
{
path: 'OigeUsdt',
component: () => import("../components/OigeUsdt.vue")
},
{
path: 'GqlUsdt',
component: () => import("../components/GqlUsdt.vue")
},
{
path: 'RpnUsdt',
component: () => import("../components/RpnUsdt.vue")
} }
] ]
} }

54
src/views/HomeView.vue

@ -61,12 +61,12 @@
import $ from 'jquery'; import $ from 'jquery';
// import 'layui-src/src/layui.js'; // import 'layui-src/src/layui.js';
// import 'layui-src/src/css/layui.css'; // import 'layui-src/src/css/layui.css';
import PytnUsdt from '@/components/PytnUsdt.vue'; import KlineView from '@/components/PytnUsdt.vue';
// import '../../static/kline/src/klineCharts.js'; // import '../../static/kline/src/klineCharts.js';
export default { export default {
name: "HomeView", name: "HomeView",
components: { components: {
PytnUsdt KlineView
}, },
data() { data() {
return { return {
@ -78,6 +78,9 @@
return window.innerWidth <= 768; // return window.innerWidth <= 768; //
} }
}, },
created() {
this.$router.replace({ path: '/KlineView', query: { symbol: this.title, interval: kcCurrentData.interval}});
},
mounted() { mounted() {
$('.interval_btn').on('click', function() { $('.interval_btn').on('click', function() {
if (kcChart != null || kcChart != undefined) { if (kcChart != null || kcChart != undefined) {
@ -130,10 +133,10 @@
}); });
window.addEventListener('resize', this.handleResize); window.addEventListener('resize', this.handleResize);
const title = sessionStorage.getItem('title'); // const title = sessionStorage.getItem('title');
if (!title&&this.$route.path !== '/PytnUsdt') { // if (!title&&this.$route.path !== '/KlineView') {
this.$router.replace({ path: '/PytnUsdt' }); // this.$router.replace({ path: '/KlineView' });
} // }
}, },
destroyed() { destroyed() {
window.removeEventListener('resize', this.handleResize); window.removeEventListener('resize', this.handleResize);
@ -147,29 +150,22 @@
handleClick(name) { handleClick(name) {
this.title = name this.title = name
sessionStorage.setItem('title',name) sessionStorage.setItem('title',name)
sessionStorage.setItem('interval',kcCurrentData.interval)
switch (name) { this.$router.replace({ path: '/KlineView', query: { symbol: this.title, interval: kcCurrentData.interval}});
case 'PYTN': // switch (name) {
this.$router.replace({ // case 'PYTN':
path: '/PytnUsdt'
}); // break;
break; // case 'OIGE':
case 'OIGE': // this.$router.replace({ path: '/KlineView', query: { symbol: this.title, interval: kcCurrentData.interval }});
this.$router.replace({ // break;
path: '/OigeUsdt' // case 'GQL':
}); // this.$router.replace({ path: '/KlineView', query: { symbol: this.title, interval: kcCurrentData.interval }});
break; // break;
case 'GQL': // default:
this.$router.replace({ // this.$router.replace({ path: '/KlineView', query: { symbol: this.title, interval: kcCurrentData.interval }});
path: '/GqlUsdt' // break;
}); // }
break;
default:
this.$router.replace({
path: '/RpnUsdt'
});
break;
}
} }
} }
}; };

Loading…
Cancel
Save