From caabc6ffb96404d9b5ac937f50ebca60c13535b1 Mon Sep 17 00:00:00 2001 From: redhoodsu Date: Fri, 12 Jul 2024 17:30:58 +0800 Subject: [PATCH] feat: inline mode --- src/Console/Console.js | 2 +- src/DevTools/DevTools.js | 4 ++++ src/Elements/Detail.js | 2 +- src/Elements/Elements.js | 9 ++++++--- src/Info/Info.js | 2 +- src/Network/Detail.js | 2 +- src/Network/Network.js | 2 +- src/Resources/Cookie.js | 4 ++-- src/Resources/Resources.js | 8 ++++---- src/Resources/Storage.js | 4 ++-- src/eruda.js | 3 ++- src/style/luna.scss | 7 +++++++ test/inline.html | 2 +- 13 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/Console/Console.js b/src/Console/Console.js index fd64b38e9..21864314a 100644 --- a/src/Console/Console.js +++ b/src/Console/Console.js @@ -248,7 +248,7 @@ export default class Console extends Tool { }) .on('click', c('.copy'), () => { this._selectedLog.copy() - container.notify('Copied') + container.notify('Copied', { icon: 'success' }) }) $inputBtns diff --git a/src/DevTools/DevTools.js b/src/DevTools/DevTools.js index 120f252df..1d8c49ec4 100644 --- a/src/DevTools/DevTools.js +++ b/src/DevTools/DevTools.js @@ -78,6 +78,10 @@ export default class DevTools extends Emitter { return this } hide() { + if (this._inline) { + return + } + this._isShow = false this.emit('hide') diff --git a/src/Elements/Detail.js b/src/Elements/Detail.js index 82d5e1462..59c9f0e76 100644 --- a/src/Elements/Detail.js +++ b/src/Elements/Detail.js @@ -319,7 +319,7 @@ export default class Detail { .on('click', c('.back'), this.hide) .on('click', c('.refresh'), () => { this._render() - devtools.notify('Refreshed') + devtools.notify('Refreshed', { icon: 'success' }) }) } _initObserver() { diff --git a/src/Elements/Elements.js b/src/Elements/Elements.js index 58bb83f70..900e8e67e 100644 --- a/src/Elements/Elements.js +++ b/src/Elements/Elements.js @@ -229,7 +229,7 @@ export default class Elements extends Tool { copy(node.nodeValue) } - this._container.notify('Copied') + this._container.notify('Copied', { icon: 'success' }) } _toggleSelect = () => { this._$el.find(c('.select')).toggleClass(c('active')) @@ -261,8 +261,11 @@ export default class Elements extends Tool { _inspectNodeRequested = ({ backendNodeId }) => { this._container.show() this._toggleSelect() - const { node } = chobitsu.domain('DOM').getNode({ nodeId: backendNodeId }) - this.select(node) + try { + const { node } = chobitsu.domain('DOM').getNode({ nodeId: backendNodeId }) + this.select(node) + /* eslint-disable no-empty */ + } catch (e) {} } _setNode = (node) => { if (node === this._curNode) return diff --git a/src/Info/Info.js b/src/Info/Info.js index d566b02c1..b3387100f 100644 --- a/src/Info/Info.js +++ b/src/Info/Info.js @@ -112,7 +112,7 @@ export default class Info extends Tool { const name = $li.find(c('.title')).text() const content = $li.find(c('.content')).text() copy(`${name}: ${content}`) - container.notify('Copied') + container.notify('Copied', { icon: 'success' }) }) } _renderHtml(html) { diff --git a/src/Network/Detail.js b/src/Network/Detail.js index 1c829b4a7..0abb862c5 100644 --- a/src/Network/Detail.js +++ b/src/Network/Detail.js @@ -118,7 +118,7 @@ export default class Detail extends Emitter { } copy(data) - this._devtools.notify('Copied') + this._devtools.notify('Copied', { icon: 'success' }) } _bindEvent() { const devtools = this._devtools diff --git a/src/Network/Network.js b/src/Network/Network.js index 0881f4bcf..3da476051 100644 --- a/src/Network/Network.js +++ b/src/Network/Network.js @@ -232,7 +232,7 @@ export default class Network extends Tool { }) ) - this._container.notify('Copied') + this._container.notify('Copied', { icon: 'success' }) } _updateButtons() { const $control = this._$control diff --git a/src/Resources/Cookie.js b/src/Resources/Cookie.js index b09a19b81..e65a78591 100644 --- a/src/Resources/Cookie.js +++ b/src/Resources/Cookie.js @@ -126,7 +126,7 @@ export default class Cookie { this._$container .on('click', c('.refresh-cookie'), () => { - devtools.notify('Refreshed') + devtools.notify('Refreshed', { icon: 'success' }) this.refresh() }) .on('click', c('.clear-cookie'), () => { @@ -154,7 +154,7 @@ export default class Cookie { .on('click', c('.copy-cookie'), () => { const key = this._selectedItem copy(this._getVal(key)) - devtools.notify('Copied') + devtools.notify('Copied', { icon: 'success' }) }) .on('click', c('.filter'), () => { LunaModal.prompt('Filter').then((filter) => { diff --git a/src/Resources/Resources.js b/src/Resources/Resources.js index f34986703..75b8c3738 100644 --- a/src/Resources/Resources.js +++ b/src/Resources/Resources.js @@ -291,19 +291,19 @@ export default class Resources extends Tool { $el .on('click', '.eruda-refresh-script', () => { - container.notify('Refreshed') + container.notify('Refreshed', { icon: 'success' }) this.refreshScript() }) .on('click', '.eruda-refresh-stylesheet', () => { - container.notify('Refreshed') + container.notify('Refreshed', { icon: 'success' }) this.refreshStylesheet() }) .on('click', '.eruda-refresh-iframe', () => { - container.notify('Refreshed') + container.notify('Refreshed', { icon: 'success' }) this.refreshIframe() }) .on('click', '.eruda-refresh-image', () => { - container.notify('Refreshed') + container.notify('Refreshed', { icon: 'success' }) this.refreshImage() }) .on('click', '.eruda-img-link', function () { diff --git a/src/Resources/Storage.js b/src/Resources/Storage.js index 1b1ccdb04..0590135ce 100644 --- a/src/Resources/Storage.js +++ b/src/Resources/Storage.js @@ -155,7 +155,7 @@ export default class Storage { this._$container .on('click', c('.refresh-storage'), () => { - devtools.notify('Refreshed') + devtools.notify('Refreshed', { icon: 'success' }) this.refresh() }) .on('click', c('.clear-storage'), () => { @@ -181,7 +181,7 @@ export default class Storage { .on('click', c('.copy-storage'), () => { const key = this._selectedItem copy(this._getVal(key)) - devtools.notify('Copied') + devtools.notify('Copied', { icon: 'success' }) }) .on('click', c('.filter'), () => { LunaModal.prompt('Filter').then((filter) => { diff --git a/src/eruda.js b/src/eruda.js index c534ba5b2..3c3f01a11 100644 --- a/src/eruda.js +++ b/src/eruda.js @@ -215,7 +215,8 @@ export default { require('luna-console/luna-console.css') + require('luna-object-viewer/luna-object-viewer.css') + require('luna-dom-viewer/luna-dom-viewer.css') + - require('luna-text-viewer/luna-text-viewer.css') + require('luna-text-viewer/luna-text-viewer.css') + + require('luna-notification/luna-notification.css') ) el = document.createElement('div') diff --git a/src/style/luna.scss b/src/style/luna.scss index 997e2ec1c..0fd7f114a 100644 --- a/src/style/luna.scss +++ b/src/style/luna.scss @@ -276,6 +276,13 @@ padding-left: 15px !important; } +.inline { + .luna-modal, + .luna-notification { + position: absolute; + } +} + .luna-modal { z-index: 9999999; } diff --git a/test/inline.html b/test/inline.html index 202949854..cee213fad 100644 --- a/test/inline.html +++ b/test/inline.html @@ -16,7 +16,7 @@