diff --git a/source/src/background.ts b/source/src/background.ts index c27c228..338d6e9 100644 --- a/source/src/background.ts +++ b/source/src/background.ts @@ -3,7 +3,7 @@ import * as PluginMsg from "./core/plugin-msg" let Devtools: chrome.runtime.Port | null = null; let DevtoolsPanel: chrome.runtime.Port | null = null; let Content: chrome.runtime.Port | null = null; -console.error('on background') +console.log('on background') function shortConnectionLink(request: any, sender: any, sendResponse: any) { // console.log(`%c[短连接|id:${sender.id}|url:${sender.url}]\n${JSON.stringify(request)}`, 'background:#aaa;color:#BD4E19') @@ -90,7 +90,7 @@ function createPluginMenus() { } else if (info.menuItemId === "notify") { chrome.notifications.create("null", { type: "basic", - iconUrl: "icon/icon48.png", + iconUrl: "icons/48.png", title: "通知", message: "测试通知", }) diff --git a/source/src/content.ts b/source/src/content.ts index eb280e5..9e28817 100644 --- a/source/src/content.ts +++ b/source/src/content.ts @@ -1 +1 @@ -console.log('11') +console.log('content code') diff --git a/source/src/devtools/panel/ccType/ComponentsProperty.vue b/source/src/devtools/ccType/ComponentsProperty.vue similarity index 100% rename from source/src/devtools/panel/ccType/ComponentsProperty.vue rename to source/src/devtools/ccType/ComponentsProperty.vue diff --git a/source/src/devtools/panel/ccType/NodeBaseProperty.vue b/source/src/devtools/ccType/NodeBaseProperty.vue similarity index 100% rename from source/src/devtools/panel/ccType/NodeBaseProperty.vue rename to source/src/devtools/ccType/NodeBaseProperty.vue diff --git a/source/src/devtools/panel/ccType/SceneProperty.vue b/source/src/devtools/ccType/SceneProperty.vue similarity index 100% rename from source/src/devtools/panel/ccType/SceneProperty.vue rename to source/src/devtools/ccType/SceneProperty.vue diff --git a/source/src/devtools/panel/ccType/ui-prop.vue b/source/src/devtools/ccType/ui-prop.vue similarity index 100% rename from source/src/devtools/panel/ccType/ui-prop.vue rename to source/src/devtools/ccType/ui-prop.vue diff --git a/source/src/devtools/panel/evalCodeString.js b/source/src/devtools/evalCodeString.js similarity index 100% rename from source/src/devtools/panel/evalCodeString.js rename to source/src/devtools/evalCodeString.js diff --git a/source/src/devtools/panel/index.ts b/source/src/devtools/index.ts similarity index 75% rename from source/src/devtools/panel/index.ts rename to source/src/devtools/index.ts index bbf0bfb..104400b 100644 --- a/source/src/devtools/panel/index.ts +++ b/source/src/devtools/index.ts @@ -2,8 +2,9 @@ import Vue from "vue"; import ElementUI from "element-ui" import "element-ui/lib/theme-chalk/index.css" import index from "./index.vue"; +import './register-panel'; -Vue.use(ElementUI); +Vue.use(ElementUI, {size: "mini"}); new Vue({ el: "#app", render: h => h(index) diff --git a/source/src/devtools/panel/index.vue b/source/src/devtools/index.vue similarity index 99% rename from source/src/devtools/panel/index.vue rename to source/src/devtools/index.vue index 8ea2db4..29be2d1 100644 --- a/source/src/devtools/panel/index.vue +++ b/source/src/devtools/index.vue @@ -48,7 +48,7 @@ // import EvalCode from "./evalCodeString.js"; - const PluginMsg = require("../../core/plugin-msg"); + const PluginMsg = require("../core/plugin-msg"); export default { data() { @@ -329,7 +329,7 @@ }, onBtnClickTest3() { // chrome.devtools.inspectedWindow.eval(`window.ccinspector.testMsg3()`) - let f = require("../../core/event-mgr"); + let f = require("../core/event-mgr"); console.log(f.id); }, onMemoryTest() { diff --git a/source/src/devtools/main.ts b/source/src/devtools/main.ts deleted file mode 100644 index 7a54b97..0000000 --- a/source/src/devtools/main.ts +++ /dev/null @@ -1,31 +0,0 @@ -import * as PluginMsg from '../core/plugin-msg' -console.log('on devtools') -debugger -import Manifest from '../manifest.json' -Manifest.devtools_page - -// 对应的是Elements面板的边栏 -chrome.devtools.panels.elements.createSidebarPane('Cocos', function (sidebar) { - sidebar.setObject({some_data: "some data to show!"}); -}); -// 创建devtools-panel -chrome.devtools.panels.create("Cocos", "icon/icon48.png", "pages/devtools_panel.html", function (panel: chrome.devtools.panels.ExtensionPanel) { - console.log("[CC-Inspector] Dev Panel Created!"); - let conn = chrome.runtime.connect({name: PluginMsg.Page.DevToolsPanel}); - conn.onMessage.addListener(function (event, sender) { - // debugger - }); - - panel.onShown.addListener((window) => { - console.log("panel show"); - conn.postMessage({msg: PluginMsg.Msg.UrlChange, data: {}}) - }); - panel.onHidden.addListener(() => { - console.log("panel hide"); - }); - panel.onSearch.addListener(function (action, query) { - console.log("panel search!"); - }); - } -); - diff --git a/source/src/devtools/register-panel.ts b/source/src/devtools/register-panel.ts new file mode 100644 index 0000000..7cfe7e2 --- /dev/null +++ b/source/src/devtools/register-panel.ts @@ -0,0 +1,33 @@ +import * as PluginMsg from '../core/plugin-msg' +import Manifest from '../manifest.json' + + +if (chrome && chrome.devtools) { + // 对应的是Elements面板的边栏 + chrome.devtools.panels.elements.createSidebarPane('Cocos', function (sidebar) { + sidebar.setObject({some_data: "some data to show!"}); + }); +// 创建devtools-panel + chrome.devtools.panels.create("Cocos", "icons/48.png", Manifest.devtools_page, (panel: chrome.devtools.panels.ExtensionPanel) => { + console.log("[CC-Inspector] Dev Panel Created!"); + let conn = chrome.runtime.connect({name: PluginMsg.Page.DevToolsPanel}); + conn.onMessage.addListener(function (event, sender) { + // debugger + }); + + panel.onShown.addListener((window) => { + console.log("panel show"); + conn.postMessage({msg: PluginMsg.Msg.UrlChange, data: {}}) + }); + panel.onHidden.addListener(() => { + console.log("panel hide"); + }); + panel.onSearch.addListener(function (action, query) { + console.log("panel search!"); + }); + } + ); + + +} + diff --git a/source/src/manifest.json b/source/src/manifest.json index 8381a81..84fbc8e 100644 --- a/source/src/manifest.json +++ b/source/src/manifest.json @@ -25,7 +25,7 @@ "icons": { "48": "icons/48.png" }, - "devtools_page": "devtools_panel.html", + "devtools_page": "devtools.html", "background": { "scripts": [ "js/background.js" diff --git a/source/vue.config.js b/source/vue.config.js index e616a2b..802f76f 100644 --- a/source/vue.config.js +++ b/source/vue.config.js @@ -4,21 +4,14 @@ module.exports = { publicPath: "/", outputDir: "dist", pages: { - popup: { - entry: "src/popup/index.ts", - template: "public/index.html", - filename: "popup.html", - title: "popup", - }, + popup: "src/popup/index.ts", options: "src/options/index.ts", - devtools_panel: "src/devtools/panel/index.ts", - test: "src/test/index.ts", + devtools: "src/devtools/index.ts", }, pluginOptions: { browserExtension: { components: { background: true, - devtools: true, contentScripts: true, }, componentOptions: { @@ -29,29 +22,8 @@ module.exports = { }, background: { entry: "src/background.ts", - }, - devtools: { - entry: "src/devtools/main.ts", } } } }, - // configureWebpack: { - // mode: "development", - // devtool: "#source-map", - // entry: { - // content: Path.join(__dirname, "src/content.ts"), - // background: Path.join(__dirname, "src/background.ts"), - // inject: Path.join(__dirname, "src/inject.js"), - // devtools: Path.join(__dirname, "src/devtools/main.ts"), - // }, - // output: { - // filename: "js/[name].js?t=[hash]" - // }, - // plugins: [ - // new ChromeManifest({ - // manifest: Path.join(__dirname, "src/manifest/index.js") - // }), - // ] - // } };