cross-magic
Version:
跨平台公共模块
51 lines (42 loc) • 1.02 kB
text/typescript
import UiConfig from './uiConfig'
import UiMgr, { PageParams } from './uiMgr'
import { RawLocation } from 'vue-router/types'
import getRunTime from '@/core/runTime'
export default class WebUiMgr extends UiMgr {
constructor(config: UiConfig) {
super(config)
}
protected init() {}
pushPage(location: RawLocation, { onComplete, onAbort }: PageParams = {}) {
if (!this.router) {
return
}
this.router.push(location, onComplete, onAbort)
}
popPage() {
if (!this.router) {
return
}
this.router.go(-1)
}
gotoPage(n: number) {
if (!n) {
return
}
if (!this.router) {
return
}
this.router.go(n)
}
redirectPage(location: RawLocation, { onComplete, onAbort }: PageParams = {}) {
if (!this.router) {
return
}
this.router.replace(location, onComplete, onAbort)
}
goHomePage() {
const runTime = getRunTime()
const historyLength = (runTime.g as Window).history.length
this.gotoPage(1 - historyLength)
}
}