This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0
old
宇天 2019-08-06 21:11:41 +08:00
parent cce4ab3330
commit 3d38ed6b56
4 changed files with 21 additions and 15 deletions

View File

@ -11,16 +11,19 @@
"type": "git",
"url": "git+https://github.com/yutent/doui.git"
},
"keywords": ["doui", "Anot"],
"keywords": [
"doui",
"Anot"
],
"author": "yutent",
"license": "MIT",
"dependencies": {},
"devDependencies": {
"anot": "^2.0.0",
"es.shim": "^1.1.2",
"chalk": "^2.4.2",
"chokidar": "^1.7.0",
"iofs": "^1.1.0",
"es.shim": "^1.1.2",
"iofs": "^1.2.1",
"node-sass": "^4.12.0",
"uglify-es": "^3.3.9"
}

View File

@ -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;}
&.inner {position:absolute;}

View File

@ -483,6 +483,9 @@ class __layer__ {
layerDom[$id][1].classList.add('shift')
setTimeout(_ => {
$dom1.css(offsetStyle)
if (vm.$refs.input) {
vm.$refs.input.focus()
}
setTimeout(_ => {
try {
layerDom[$id][1].classList.remove('shift')
@ -656,7 +659,7 @@ const _layer = {
type: 3,
prompt: '',
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,
yes: yescb
}

View File

@ -22,10 +22,11 @@ function targetIsThisWindow(targetWindow) {
}
return false
}
//hash前缀正则
const PREFIX_REGEXP = /^(#!|#)[\/]?/
const TRIM_REGEXP = /(^[/]+)|([/]+$)/g
const DEFAULT_OPTIONS = {
mode: 'hash', // hash | history
prefix: /^(#!|#)[\/]?/, //hash前缀正则
allowReload: true //连续点击同一个链接是否重新加载
}
const LINKS = []
@ -59,7 +60,7 @@ class Router {
// 事件监听
__listen__() {
let { mode, prefix } = this.options
let { mode } = this.options
Anot.bind(window, 'load, popstate', ev => {
if (ev.type === 'load') {
@ -71,7 +72,9 @@ class Router {
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') {
this.go(path)
// hash模式要手动触发一下路由检测
@ -81,7 +84,6 @@ class Router {
} else {
// 因为pushState不会触发popstate事件,
// 所以这里只在hash模式或有ev.state的情况下才会主动触发路由检测
path = path.replace(/^[/]+?/, '')
if (mode === 'hash' || ev.state) {
this.__check__(path)
}
@ -121,7 +123,7 @@ class Router {
}
// hash地址,只管修正前缀即可, 会触发popstate事件,所以这里只处理非hash的情况
if (!prefix.test(href)) {
if (!PREFIX_REGEXP.test(href)) {
// 非hash地址,则需要阻止默认事件
// 并主动触发跳转, 同时强制清除hash
ev.preventDefault()
@ -199,11 +201,10 @@ class Router {
// 跳转到路由
go(path, forceCleanHash = false) {
path = path.replace(/^[/]+/, '')
let { mode, prefix } = this.options
path = path.trim().replace(TRIM_REGEXP, '')
let { mode } = this.options
if (mode === 'hash') {
path = path.trim().replace(prefix, '')
// 页面刷新时, 不主动添加空hash, 避免执行2次noMatch回调
if (!path && path === location.hash) {
return
@ -212,7 +213,6 @@ class Router {
} else {
let hash = forceCleanHash ? '' : location.hash
let search = forceCleanHash ? '' : location.search
path = path.replace(/^[/]+?/, '')
if (forceCleanHash) {
window.history.pushState({ path }, null, `/${path + search + hash}`)
} else {