update
parent
cce4ab3330
commit
3d38ed6b56
|
@ -11,16 +11,19 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/yutent/doui.git"
|
"url": "git+https://github.com/yutent/doui.git"
|
||||||
},
|
},
|
||||||
"keywords": ["doui", "Anot"],
|
"keywords": [
|
||||||
|
"doui",
|
||||||
|
"Anot"
|
||||||
|
],
|
||||||
"author": "yutent",
|
"author": "yutent",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"anot": "^2.0.0",
|
"anot": "^2.0.0",
|
||||||
"es.shim": "^1.1.2",
|
|
||||||
"chalk": "^2.4.2",
|
"chalk": "^2.4.2",
|
||||||
"chokidar": "^1.7.0",
|
"chokidar": "^1.7.0",
|
||||||
"iofs": "^1.1.0",
|
"es.shim": "^1.1.2",
|
||||||
|
"iofs": "^1.2.1",
|
||||||
"node-sass": "^4.12.0",
|
"node-sass": "^4.12.0",
|
||||||
"uglify-es": "^3.3.9"
|
"uglify-es": "^3.3.9"
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
&.mask {position:fixed;z-index:65534;left:0;top:0;width:100%;height:100%;background:transparent;
|
&.mask {position:fixed;z-index:65534;left:0;top:0;width:100%;height:100%;background:transparent;backdrop-filter:blur(5px);
|
||||||
|
|
||||||
&.shift {transition: all .5s ease-out;}
|
&.shift {transition: all .5s ease-out;}
|
||||||
&.inner {position:absolute;}
|
&.inner {position:absolute;}
|
||||||
|
|
|
@ -483,6 +483,9 @@ class __layer__ {
|
||||||
layerDom[$id][1].classList.add('shift')
|
layerDom[$id][1].classList.add('shift')
|
||||||
setTimeout(_ => {
|
setTimeout(_ => {
|
||||||
$dom1.css(offsetStyle)
|
$dom1.css(offsetStyle)
|
||||||
|
if (vm.$refs.input) {
|
||||||
|
vm.$refs.input.focus()
|
||||||
|
}
|
||||||
setTimeout(_ => {
|
setTimeout(_ => {
|
||||||
try {
|
try {
|
||||||
layerDom[$id][1].classList.remove('shift')
|
layerDom[$id][1].classList.remove('shift')
|
||||||
|
@ -656,7 +659,7 @@ const _layer = {
|
||||||
type: 3,
|
type: 3,
|
||||||
prompt: '',
|
prompt: '',
|
||||||
title,
|
title,
|
||||||
content: `<input class="prompt-value" data-duplex-focus :class="{alert: !prompt}" :duplex="prompt" />`,
|
content: `<input class="prompt-value" ref="input" :class="{alert: !prompt}" :duplex="prompt" />`,
|
||||||
fixed: true,
|
fixed: true,
|
||||||
yes: yescb
|
yes: yescb
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,11 @@ function targetIsThisWindow(targetWindow) {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
//hash前缀正则
|
||||||
|
const PREFIX_REGEXP = /^(#!|#)[\/]?/
|
||||||
|
const TRIM_REGEXP = /(^[/]+)|([/]+$)/g
|
||||||
const DEFAULT_OPTIONS = {
|
const DEFAULT_OPTIONS = {
|
||||||
mode: 'hash', // hash | history
|
mode: 'hash', // hash | history
|
||||||
prefix: /^(#!|#)[\/]?/, //hash前缀正则
|
|
||||||
allowReload: true //连续点击同一个链接是否重新加载
|
allowReload: true //连续点击同一个链接是否重新加载
|
||||||
}
|
}
|
||||||
const LINKS = []
|
const LINKS = []
|
||||||
|
@ -59,7 +60,7 @@ class Router {
|
||||||
|
|
||||||
// 事件监听
|
// 事件监听
|
||||||
__listen__() {
|
__listen__() {
|
||||||
let { mode, prefix } = this.options
|
let { mode } = this.options
|
||||||
|
|
||||||
Anot.bind(window, 'load, popstate', ev => {
|
Anot.bind(window, 'load, popstate', ev => {
|
||||||
if (ev.type === 'load') {
|
if (ev.type === 'load') {
|
||||||
|
@ -71,7 +72,9 @@ class Router {
|
||||||
|
|
||||||
let path = mode === 'hash' ? location.hash : location.pathname
|
let path = mode === 'hash' ? location.hash : location.pathname
|
||||||
|
|
||||||
path = path.replace(prefix, '').trim()
|
path = path.replace(PREFIX_REGEXP, '').trim()
|
||||||
|
path = path.replace(TRIM_REGEXP, '')
|
||||||
|
|
||||||
if (ev.type === 'load') {
|
if (ev.type === 'load') {
|
||||||
this.go(path)
|
this.go(path)
|
||||||
// hash模式要手动触发一下路由检测
|
// hash模式要手动触发一下路由检测
|
||||||
|
@ -81,7 +84,6 @@ class Router {
|
||||||
} else {
|
} else {
|
||||||
// 因为pushState不会触发popstate事件,
|
// 因为pushState不会触发popstate事件,
|
||||||
// 所以这里只在hash模式或有ev.state的情况下才会主动触发路由检测
|
// 所以这里只在hash模式或有ev.state的情况下才会主动触发路由检测
|
||||||
path = path.replace(/^[/]+?/, '')
|
|
||||||
if (mode === 'hash' || ev.state) {
|
if (mode === 'hash' || ev.state) {
|
||||||
this.__check__(path)
|
this.__check__(path)
|
||||||
}
|
}
|
||||||
|
@ -121,7 +123,7 @@ class Router {
|
||||||
}
|
}
|
||||||
|
|
||||||
// hash地址,只管修正前缀即可, 会触发popstate事件,所以这里只处理非hash的情况
|
// hash地址,只管修正前缀即可, 会触发popstate事件,所以这里只处理非hash的情况
|
||||||
if (!prefix.test(href)) {
|
if (!PREFIX_REGEXP.test(href)) {
|
||||||
// 非hash地址,则需要阻止默认事件
|
// 非hash地址,则需要阻止默认事件
|
||||||
// 并主动触发跳转, 同时强制清除hash
|
// 并主动触发跳转, 同时强制清除hash
|
||||||
ev.preventDefault()
|
ev.preventDefault()
|
||||||
|
@ -199,11 +201,10 @@ class Router {
|
||||||
|
|
||||||
// 跳转到路由
|
// 跳转到路由
|
||||||
go(path, forceCleanHash = false) {
|
go(path, forceCleanHash = false) {
|
||||||
path = path.replace(/^[/]+/, '')
|
path = path.trim().replace(TRIM_REGEXP, '')
|
||||||
let { mode, prefix } = this.options
|
let { mode } = this.options
|
||||||
|
|
||||||
if (mode === 'hash') {
|
if (mode === 'hash') {
|
||||||
path = path.trim().replace(prefix, '')
|
|
||||||
// 页面刷新时, 不主动添加空hash, 避免执行2次noMatch回调
|
// 页面刷新时, 不主动添加空hash, 避免执行2次noMatch回调
|
||||||
if (!path && path === location.hash) {
|
if (!path && path === location.hash) {
|
||||||
return
|
return
|
||||||
|
@ -212,7 +213,6 @@ class Router {
|
||||||
} else {
|
} else {
|
||||||
let hash = forceCleanHash ? '' : location.hash
|
let hash = forceCleanHash ? '' : location.hash
|
||||||
let search = forceCleanHash ? '' : location.search
|
let search = forceCleanHash ? '' : location.search
|
||||||
path = path.replace(/^[/]+?/, '')
|
|
||||||
if (forceCleanHash) {
|
if (forceCleanHash) {
|
||||||
window.history.pushState({ path }, null, `/${path + search + hash}`)
|
window.history.pushState({ path }, null, `/${path + search + hash}`)
|
||||||
} else {
|
} else {
|
||||||
|
|
Reference in New Issue