change h5 to web

This commit is contained in:
pengfei.zhou
2019-12-31 18:31:47 +08:00
committed by osborn
parent 1b0695d317
commit 08654fb1fe
38 changed files with 6 additions and 6 deletions

View File

@@ -0,0 +1,36 @@
import { DoricElement } from "../DoricElement"
export class NavigationElement extends HTMLElement {
elementStack: DoricElement[] = []
get currentNode() {
for (let i = 0; i < this.childNodes.length; i++) {
if (this.childNodes[i] instanceof DoricElement) {
return this.childNodes[i] as DoricElement
}
}
return undefined
}
push(element: DoricElement) {
const currentNode = this.currentNode
if (currentNode) {
this.elementStack.push(currentNode)
this.replaceChild(element, currentNode)
} else {
this.appendChild(element)
}
}
pop() {
const lastElement = this.elementStack.pop()
const currentNode = this.currentNode
if (lastElement && currentNode) {
this.replaceChild(lastElement, currentNode)
currentNode.onDestroy()
} else {
window.history.back()
}
}
}

View File

@@ -0,0 +1,34 @@
import { DoricPlugin } from "../DoricPlugin";
import { DoricElement } from "../DoricElement";
import { NavigationElement } from "./NavigationElement";
export class NavigatorPlugin extends DoricPlugin {
navigation: NavigationElement | undefined = document.getElementsByTagName('doric-navigation')[0] as (NavigationElement | undefined)
push(args: {
scheme: string,
config?: {
alias?: string,
extra?: string,
}
}) {
if (this.navigation) {
const div = new DoricElement
div.src = args.scheme
div.alias = args.config?.alias || args.scheme
this.navigation.push(div)
return Promise.resolve()
} else {
return Promise.reject('Not implemented')
}
}
pop() {
if (this.navigation) {
this.navigation.pop()
return Promise.resolve()
} else {
return Promise.reject('Not implemented')
}
}
}