7 changed files with 344 additions and 204 deletions
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
import * as VueRouter from "vue-router"; |
||||
|
||||
import Index from "../pages/home/Index"; |
||||
import Attention from "../pages/home/Attention"; |
||||
import Message from "../pages/home/Message"; |
||||
import Me from "../pages/home/Me"; |
||||
import Me2 from "../pages/home/Me2"; |
||||
import Music from "../components/common/Music"; |
||||
import countryChoose from "../pages/login/countryChoose"; |
||||
import MyCard from "../pages/me/MyCard"; |
||||
import MyCollect from "../pages/me/MyCollect"; |
||||
|
||||
const routes = [ |
||||
// {path: '', component: Music},
|
||||
{path: '/', component: Index}, |
||||
{path: '/home', component: Index}, |
||||
{path: '/attention', component: Attention}, |
||||
{path: '/message', component: Message}, |
||||
{path: '/me', component: Me}, |
||||
{path: '/me2', component: Me2}, |
||||
{path: '/music', component: Music}, |
||||
{path: '/countryChoose', component: countryChoose}, |
||||
{path: '/MyCard', component: MyCard}, |
||||
{path: '/MyCollect', component: MyCollect}, |
||||
] |
||||
|
||||
export default VueRouter.createRouter({ |
||||
history: VueRouter.createWebHashHistory(), |
||||
routes, // `routes: routes` 的缩写
|
||||
}) |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
import * as Vuex from "vuex"; |
||||
|
||||
const store = Vuex.createStore({ |
||||
state: { |
||||
pageAnim: 'none', |
||||
playDuration: 60, |
||||
currentVideoId: null, |
||||
bodyHeight: document.body.clientHeight, |
||||
bodyWidth: document.body.clientWidth |
||||
}, |
||||
mutations: { |
||||
setPageAnim(state, states) { |
||||
state.pageAnim = states |
||||
}, |
||||
setPlayDuration(state, v) { |
||||
state.playDuration = v |
||||
}, |
||||
setCurrentVideoId(state, v) { |
||||
state.currentVideoId = v |
||||
}, |
||||
} |
||||
}) |
||||
|
||||
export default store |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
export default { |
||||
$stopPropagation(e) { |
||||
e.stopImmediatePropagation() |
||||
e.stopPropagation() |
||||
e.preventDefault() |
||||
}, |
||||
$getCss(curEle, attr) { |
||||
let val = null, reg = null |
||||
if ("getComputedStyle" in window) { |
||||
val = window.getComputedStyle(curEle, null)[attr] |
||||
} else { //ie6~8不支持上面属性
|
||||
//不兼容
|
||||
if (attr === "opacity") { |
||||
val = curEle.currentStyle["filter"] //'alpha(opacity=12,345)'
|
||||
reg = /^alphaopacity=(\d+(?:\.\d+)?)opacity=(\d+(?:\.\d+)?)$/i |
||||
val = reg.test(val) ? reg.exec(val)[1] / 100 : 1 |
||||
} else { |
||||
val = curEle.currentStyle[attr] |
||||
} |
||||
} |
||||
// reg = /^(-?\d+(\.\d)?)(px|pt|em|rem)?$/i
|
||||
// return reg.test(val) ? parseFloat(val) : val
|
||||
return parseFloat(val) |
||||
}, |
||||
$setCss(el, key, value) { |
||||
if (key === 'transform') { |
||||
//直接设置不生效
|
||||
el.style.webkitTransform = el.style.MsTransform = el.style.msTransform = el.style.MozTransform = el.style.OTransform = el.style.transform = value; |
||||
} else { |
||||
el.style[key] = value |
||||
} |
||||
}, |
||||
$nav(path, query = {}) { |
||||
this.$router.push({path, query}) |
||||
}, |
||||
$clone(v) { |
||||
return JSON.parse(JSON.stringify(v)) |
||||
}, |
||||
$console(v) { |
||||
return console.log(JSON.stringify(v, null, 4)) |
||||
}, |
||||
$duration(v) { |
||||
let m = Math.floor(v / 60) |
||||
// let s = v % 60
|
||||
let s = Math.round(v % 60) |
||||
let str = '' |
||||
if (m === 0) { |
||||
str = '00' |
||||
} else if (m > 0 && m < 10) { |
||||
str = '0' + m |
||||
} else { |
||||
str = m |
||||
} |
||||
str += ':' |
||||
if (s === 0) { |
||||
str += '00' |
||||
} else if (s > 0 && s < 10) { |
||||
str += '0' + s |
||||
} else { |
||||
str += s |
||||
} |
||||
return str |
||||
} |
||||
} |
Loading…
Reference in new issue