feat: refresh notification

This commit is contained in:
redhoodsu
2020-04-18 23:19:29 +08:00
parent 7f5f5c9549
commit 488f382dab
8 changed files with 65 additions and 19 deletions

View File

@@ -17,7 +17,7 @@ const postcssLoader = {
plugins: [ plugins: [
prefixer({ prefixer({
prefix: '_', prefix: '_',
ignore: [/luna-object-viewer/] ignore: [/luna-object-viewer/, /luna-notification/]
}), }),
autoprefixer, autoprefixer,
clean() clean()

View File

@@ -61,6 +61,7 @@
"karma-sourcemap-loader": "^0.3.7", "karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.2", "karma-webpack": "^4.0.2",
"licia": "^1.19.0", "licia": "^1.19.0",
"luna-notification": "^0.1.2",
"luna-object-viewer": "^0.1.1", "luna-object-viewer": "^0.1.1",
"node-sass": "^4.13.1", "node-sass": "^4.13.1",
"postcss-clean": "^1.1.0", "postcss-clean": "^1.1.0",

View File

@@ -15,6 +15,7 @@ import {
isDarkMode isDarkMode
} from '../lib/util' } from '../lib/util'
import evalCss from '../lib/evalCss' import evalCss from '../lib/evalCss'
import LunaNotification from 'luna-notification'
export default class DevTools extends Emitter { export default class DevTools extends Emitter {
constructor($container) { constructor($container) {
@@ -33,6 +34,7 @@ export default class DevTools extends Emitter {
this._appendTpl() this._appendTpl()
this._initNavBar() this._initNavBar()
this._initNotification()
this._bindEvent() this._bindEvent()
} }
show() { show() {
@@ -176,7 +178,9 @@ export default class DevTools extends Emitter {
}) })
.separator() .separator()
} }
notify(content, options) {
this._notification.notify(content, options)
}
destroy() { destroy() {
evalCss.remove(this._style) evalCss.remove(this._style)
this.removeAll() this.removeAll()
@@ -206,6 +210,14 @@ export default class DevTools extends Emitter {
this._navBar = new NavBar(this._$el.find('.eruda-nav-bar-container')) this._navBar = new NavBar(this._$el.find('.eruda-nav-bar-container'))
this._navBar.on('showTool', name => this.showTool(name)) this._navBar.on('showTool', name => this.showTool(name))
} }
_initNotification() {
this._notification = new LunaNotification(this._$el.get(0), {
position: {
x: 'center',
y: 'top'
}
})
}
_bindEvent() { _bindEvent() {
const $navBar = this._$el.find('.eruda-nav-bar') const $navBar = this._$el.find('.eruda-nav-bar')
const startListener = e => { const startListener = e => {

View File

@@ -216,7 +216,10 @@ export default class Elements extends Tool {
const $bottomBar = this._$el.find('.eruda-bottom-bar') const $bottomBar = this._$el.find('.eruda-bottom-bar')
$bottomBar $bottomBar
.on('click', '.eruda-refresh', () => this._render()) .on('click', '.eruda-refresh', () => {
this._render()
container.notify('Refreshed')
})
.on('click', '.eruda-highlight', () => this._toggleHighlight()) .on('click', '.eruda-highlight', () => this._toggleHighlight())
.on('click', '.eruda-select', () => this._toggleSelect()) .on('click', '.eruda-select', () => this._toggleSelect())
.on('click', '.eruda-reset', () => this.set(this._htmlEl)) .on('click', '.eruda-reset', () => this.set(this._htmlEl))

View File

@@ -220,25 +220,34 @@ export default class Resources extends Tool {
const container = this._container const container = this._container
$el $el
.on('click', '.eruda-refresh-local-storage', () => .on('click', '.eruda-refresh-local-storage', () => {
container.notify('Refreshed')
this.refreshLocalStorage()._render() this.refreshLocalStorage()._render()
) })
.on('click', '.eruda-refresh-session-storage', () => .on('click', '.eruda-refresh-session-storage', () => {
container.notify('Refreshed')
this.refreshSessionStorage()._render() this.refreshSessionStorage()._render()
) })
.on('click', '.eruda-refresh-cookie', () => .on('click', '.eruda-refresh-cookie', () => {
container.notify('Refreshed')
this.refreshCookie()._render() this.refreshCookie()._render()
) })
.on('click', '.eruda-refresh-script', () => .on('click', '.eruda-refresh-script', () => {
container.notify('Refreshed')
this.refreshScript()._render() this.refreshScript()._render()
) })
.on('click', '.eruda-refresh-stylesheet', () => .on('click', '.eruda-refresh-stylesheet', () => {
container.notify('Refreshed')
this.refreshStylesheet()._render() this.refreshStylesheet()._render()
) })
.on('click', '.eruda-refresh-iframe', () => .on('click', '.eruda-refresh-iframe', () => {
container.notify('Refreshed')
this.refreshIframe()._render() this.refreshIframe()._render()
) })
.on('click', '.eruda-refresh-image', () => this.refreshImage()._render()) .on('click', '.eruda-refresh-image', () => {
container.notify('Refreshed')
this.refreshImage()._render()
})
.on('click', '.eruda-search', function() { .on('click', '.eruda-search', function() {
const $this = $(this) const $this = $(this)
const type = $this.data('type') const type = $this.data('type')

View File

@@ -199,6 +199,7 @@ export default {
evalCss( evalCss(
require('luna-object-viewer/luna-object-viewer.css') + require('luna-object-viewer/luna-object-viewer.css') +
require('luna-notification/luna-notification.css') +
require('./style/style.scss') + require('./style/style.scss') +
require('./style/reset.scss') + require('./style/reset.scss') +
require('./style/icon.css') require('./style/icon.css')

View File

@@ -35,3 +35,26 @@
border-top-color: transparent; border-top-color: transparent;
border-left-color: var(--foreground); border-left-color: var(--foreground);
} }
.luna-notification {
pointer-events: none !important;
padding: $padding;
z-index: 1000;
}
.luna-notification-item {
z-index: 500;
color: var(--foreground);
background: var(--background);
box-shadow: none;
padding: 5px 10px;
border: 1px solid var(--border);
}
.luna-notification-upper {
margin-bottom: 10px;
}
.luna-notification-lower {
margin-top: 10px;
}

View File

@@ -1,7 +1,4 @@
.container { .container {
html,
body,
div,
span, span,
applet, applet,
object, object,