mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-06-01 13:54:05 +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 Shortkeys from "./shortkeys.vue";
|
||||||
import { appStore } from "./store";
|
import { appStore } from "./store";
|
||||||
import { sendGaEvent } from "./util";
|
import { sendGaEvent } from "./util";
|
||||||
|
import { freshEditor } from "../inject/util";
|
||||||
declare const cc: any;
|
declare const cc: any;
|
||||||
const { CCDialog, CCMenu } = ccui.components;
|
const { CCDialog, CCMenu } = ccui.components;
|
||||||
interface ListItem {
|
interface ListItem {
|
||||||
@ -363,32 +364,7 @@ export default defineComponent({
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case shortKeyGameFresh: {
|
case shortKeyGameFresh: {
|
||||||
let router = "";
|
freshEditor();
|
||||||
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) => {});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,50 @@
|
|||||||
declare const cc: any;
|
declare const cc: any;
|
||||||
|
|
||||||
export function isVersion3() {
|
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;
|
const version: string = cc.ENGINE_VERSION;
|
||||||
return version.startsWith("3.")
|
return version.startsWith("3.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isHasProperty(base: Object, key: string): boolean {
|
export function isHasProperty(base: Object, key: string): boolean {
|
||||||
let ret = Object.getOwnPropertyDescriptor(base, key)
|
let ret = Object.getOwnPropertyDescriptor(base, key);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
let proto = Object.getPrototypeOf(base);
|
let proto = Object.getPrototypeOf(base);
|
||||||
if (proto) {
|
if (proto) {
|
||||||
return isHasProperty(proto, key)
|
return isHasProperty(proto, key);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
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