mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-05-31 05:14:02 +00:00
将刷新游戏的逻辑剥离
This commit is contained in:
parent
6638c80619
commit
16f100cbd1
@ -31,6 +31,7 @@ import Memory from "./memory.vue";
|
||||
import Shortkeys from "./shortkeys.vue";
|
||||
import { appStore } from "./store";
|
||||
import { sendGaEvent } from "./util";
|
||||
import { freshEditor } from "../inject/util";
|
||||
declare const cc: any;
|
||||
const { CCDialog, CCMenu } = ccui.components;
|
||||
interface ListItem {
|
||||
@ -363,32 +364,7 @@ export default defineComponent({
|
||||
break;
|
||||
}
|
||||
case shortKeyGameFresh: {
|
||||
let router = "";
|
||||
let isCreator2X = false;
|
||||
if (typeof cc !== "undefined" && cc && typeof cc.ENGINE_VERSION !== "undefined") {
|
||||
if (cc.ENGINE_VERSION.startsWith("3.")) {
|
||||
isCreator2X = false;
|
||||
router = "asset-db/refresh";
|
||||
} else {
|
||||
isCreator2X = true;
|
||||
router = "update-db";
|
||||
}
|
||||
}
|
||||
const url = new URL(window.location.href);
|
||||
const port = Number(url.port) || 7456;
|
||||
fetch(`http://localhost:${port}/${router}`)
|
||||
.then((res) => {
|
||||
res.text().then((a: string) => {
|
||||
window.location.reload();
|
||||
if (isCreator2X === false && a === "success") {
|
||||
// 3.x
|
||||
}
|
||||
if (isCreator2X === true && a === "Changes submitted") {
|
||||
// 2.x
|
||||
}
|
||||
});
|
||||
})
|
||||
.then((data) => {});
|
||||
freshEditor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,50 @@
|
||||
declare const cc: any;
|
||||
|
||||
export function isVersion3() {
|
||||
if (typeof cc.ENGINE_VERSION === "string") {
|
||||
if (typeof cc !== "undefined" && cc && typeof cc.ENGINE_VERSION === "string") {
|
||||
const version: string = cc.ENGINE_VERSION;
|
||||
return version.startsWith("3.")
|
||||
return version.startsWith("3.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isHasProperty(base: Object, key: string): boolean {
|
||||
let ret = Object.getOwnPropertyDescriptor(base, key)
|
||||
let ret = Object.getOwnPropertyDescriptor(base, key);
|
||||
if (ret) {
|
||||
return true;
|
||||
} else {
|
||||
let proto = Object.getPrototypeOf(base);
|
||||
if (proto) {
|
||||
return isHasProperty(proto, key)
|
||||
return isHasProperty(proto, key);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function freshEditor() {
|
||||
let router = "";
|
||||
let isCreator2X = false;
|
||||
if (isVersion3()) {
|
||||
isCreator2X = false;
|
||||
router = "asset-db/refresh";
|
||||
} else {
|
||||
isCreator2X = true;
|
||||
router = "update-db";
|
||||
}
|
||||
const url = new URL(window.location.href);
|
||||
const port = Number(url.port) || 7456;
|
||||
fetch(`http://localhost:${port}/${router}`)
|
||||
.then((res) => {
|
||||
res.text().then((a: string) => {
|
||||
window.location.reload();
|
||||
if (isCreator2X === false && a === "success") {
|
||||
// 3.x
|
||||
}
|
||||
if (isCreator2X === true && a === "Changes submitted") {
|
||||
// 2.x
|
||||
}
|
||||
});
|
||||
})
|
||||
.then((data) => {});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user