mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-16 07:01:03 +00:00
只有cocos游戏的页面才注入插件推荐页面
This commit is contained in:
parent
5d4f81fce8
commit
05edad10f7
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="ad" v-show="ads.length && isShow">
|
<div class="ad" v-show="ads.length && isShow">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="title">Creator Plugin Recommendation</div>
|
<div class="title">Recommend</div>
|
||||||
<div style="flex: 1"></div>
|
<div class="line"></div>
|
||||||
<div class="close" @click="onClose" :title="closeTitle">
|
<div class="close" @click="onClose" :title="closeTitle">
|
||||||
<i class="icon iconfont icon_close"></i>
|
<i class="icon iconfont icon_close"></i>
|
||||||
</div>
|
</div>
|
||||||
@ -150,12 +150,13 @@ export default defineComponent({
|
|||||||
right: 0;
|
right: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
//overflow: hidden;
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
.title {
|
.title {
|
||||||
|
box-shadow: 0px 0px 2px 0px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
@ -163,7 +164,13 @@ export default defineComponent({
|
|||||||
border-top-right-radius: 5px;
|
border-top-right-radius: 5px;
|
||||||
padding: 3px 9px;
|
padding: 3px 9px;
|
||||||
}
|
}
|
||||||
|
.line {
|
||||||
|
height: 1px;
|
||||||
|
flex: 1;
|
||||||
|
box-shadow: 0px 0px 2px 0px;
|
||||||
|
}
|
||||||
.close {
|
.close {
|
||||||
|
box-shadow: 0px 0px 3px 0px;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border-top-left-radius: 10px;
|
border-top-left-radius: 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { InjectView } from "./inject-view";
|
|
||||||
import { Inspector } from "./inspector";
|
import { Inspector } from "./inspector";
|
||||||
const inspector = new Inspector();
|
const inspector = new Inspector();
|
||||||
inspector.init();
|
inspector.init();
|
||||||
window["CCInspector"] = inspector;
|
window["CCInspector"] = inspector;
|
||||||
const ad = new InjectView();
|
|
||||||
|
@ -5,28 +5,44 @@ import { createApp } from "vue";
|
|||||||
import { DocumentEvent } from "../const";
|
import { DocumentEvent } from "../const";
|
||||||
import App from "../inject-view/app.vue";
|
import App from "../inject-view/app.vue";
|
||||||
export class InjectView {
|
export class InjectView {
|
||||||
|
private _inited = false;
|
||||||
|
private css: string[] = [];
|
||||||
constructor() {
|
constructor() {
|
||||||
|
document.addEventListener(DocumentEvent.LoadInjectCss, (event: CustomEvent) => {
|
||||||
|
const cssArray: string[] = event.detail;
|
||||||
|
this.css = cssArray;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public init() {
|
||||||
|
if (this._inited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._inited = true;
|
||||||
|
this.createUI();
|
||||||
|
}
|
||||||
|
private createUI() {
|
||||||
const el = document.createElement("div");
|
const el = document.createElement("div");
|
||||||
el.attachShadow({ mode: "closed" });
|
|
||||||
el.style.position = "absolute";
|
el.style.position = "absolute";
|
||||||
el.style.zIndex = "99999";
|
el.style.zIndex = "99999";
|
||||||
el.style.bottom = "0";
|
el.style.bottom = "0";
|
||||||
el.style.right = "0";
|
el.style.right = "0";
|
||||||
el.style.left = "0";
|
el.style.left = "0";
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
|
const shadowRoot = el.attachShadow({ mode: "open" });
|
||||||
|
// load css
|
||||||
|
this.css.forEach((css) => {
|
||||||
|
const link = document.createElement("link");
|
||||||
|
link.href = css;
|
||||||
|
link.rel = "stylesheet";
|
||||||
|
shadowRoot.appendChild(link);
|
||||||
|
});
|
||||||
|
// vue
|
||||||
|
const root = document.createElement("div");
|
||||||
|
shadowRoot.appendChild(root);
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
// ccui.uiElement.setDoc(document);
|
// ccui.uiElement.setDoc(document);
|
||||||
app.use(ccui);
|
app.use(ccui);
|
||||||
app.mount(el);
|
app.mount(root);
|
||||||
|
|
||||||
document.addEventListener(DocumentEvent.LoadInjectCss, (event: CustomEvent) => {
|
|
||||||
const cssArray: string[] = event.detail;
|
|
||||||
cssArray.forEach((css) => {
|
|
||||||
const link = document.createElement("link");
|
|
||||||
link.href = css;
|
|
||||||
link.rel = "stylesheet";
|
|
||||||
el.appendChild(link);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const injectView = new InjectView();
|
||||||
|
@ -3,6 +3,7 @@ import { uniq } from "lodash";
|
|||||||
import { Msg, PluginEvent, RequestLogData, RequestNodeInfoData, RequestSetPropertyData, ResponseGameInfoData, ResponseNodeInfoData, ResponseSetPropertyData, ResponseSupportData, ResponseTreeInfoData } from "../../core/types";
|
import { Msg, PluginEvent, RequestLogData, RequestNodeInfoData, RequestSetPropertyData, ResponseGameInfoData, ResponseNodeInfoData, ResponseSetPropertyData, ResponseSupportData, ResponseTreeInfoData } from "../../core/types";
|
||||||
import { ArrayData, BoolData, ColorData, DataType, EngineData, Group, ImageData, Info, InvalidData, NodeInfoData, NumberData, ObjectCircleData, ObjectData, Property, StringData, TreeData, Vec2Data, Vec3Data, Vec4Data } from "../../views/devtools/data";
|
import { ArrayData, BoolData, ColorData, DataType, EngineData, Group, ImageData, Info, InvalidData, NodeInfoData, NumberData, ObjectCircleData, ObjectData, Property, StringData, TreeData, Vec2Data, Vec3Data, Vec4Data } from "../../views/devtools/data";
|
||||||
import { InjectEvent } from "./event";
|
import { InjectEvent } from "./event";
|
||||||
|
import { injectView } from "./inject-view";
|
||||||
import { getValue, trySetValueWithConfig } from "./setValue";
|
import { getValue, trySetValueWithConfig } from "./setValue";
|
||||||
import { BuildArrayOptions, BuildImageOptions, BuildObjectOptions, BuildVecOptions } from "./types";
|
import { BuildArrayOptions, BuildImageOptions, BuildObjectOptions, BuildVecOptions } from "./types";
|
||||||
import { isHasProperty } from "./util";
|
import { isHasProperty } from "./util";
|
||||||
@ -122,6 +123,7 @@ export class Inspector extends InjectEvent {
|
|||||||
const b = this._isCocosGame();
|
const b = this._isCocosGame();
|
||||||
if (b) {
|
if (b) {
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
|
injectView.init();
|
||||||
const version = this.getEngineVersion();
|
const version = this.getEngineVersion();
|
||||||
if (b && version) {
|
if (b && version) {
|
||||||
this.uploadEngineVersion(version);
|
this.uploadEngineVersion(version);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user