2024-12-09 19:25:06 +08:00
|
|
|
<template>
|
|
|
|
<div v-if="show" class="test">
|
2024-12-25 17:16:11 +08:00
|
|
|
<CCSection name="功能测试" :expand="config.expandTest" @change="onExpandTest">
|
2024-12-09 19:25:06 +08:00
|
|
|
<CCButton @click="onClickHasCocosGame">Has CocosGame</CCButton>
|
|
|
|
<CCButton @click="onClickNoCocosGame">No CocosGame</CCButton>
|
2024-12-09 20:49:02 +08:00
|
|
|
<CCButton @click="onTestTree">init tree data</CCButton>
|
2024-12-12 20:13:50 +08:00
|
|
|
<CCButton @click="onFrames">test frame</CCButton>
|
2024-12-16 10:10:05 +08:00
|
|
|
<CCButton @click="onTestNodeInfo">test node info</CCButton>
|
2024-12-18 09:03:59 +08:00
|
|
|
<CCButton @click="onNull">test null</CCButton>
|
2024-12-25 17:16:11 +08:00
|
|
|
<CCButton @click="onTerminal">onTerminal</CCButton>
|
2024-12-09 19:25:06 +08:00
|
|
|
</CCSection>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import ccui from "@xuyanfeng/cc-ui";
|
2024-12-09 20:49:02 +08:00
|
|
|
import { ITreeData } from "@xuyanfeng/cc-ui/types/cc-tree/const";
|
2024-12-09 19:25:06 +08:00
|
|
|
import { defineComponent, ref } from "vue";
|
2024-12-09 21:37:07 +08:00
|
|
|
import { Msg, Page, PluginEvent } from "../../../core/types";
|
2024-12-24 21:09:13 +08:00
|
|
|
import { bridge } from "../bridge";
|
2024-12-25 17:16:11 +08:00
|
|
|
import { appStore, RefreshType } from "../store";
|
|
|
|
import { storeToRefs } from "pinia";
|
2024-12-18 09:03:59 +08:00
|
|
|
import { FrameDetails, Group, Info, InvalidData, NodeInfoData, TreeData } from "../data";
|
2024-12-12 20:13:50 +08:00
|
|
|
import { testServer, TestServer } from "./server";
|
2024-12-25 17:16:11 +08:00
|
|
|
import { Terminal } from "../../../scripts/terminal";
|
2024-12-09 19:25:06 +08:00
|
|
|
const { CCButton, CCSection } = ccui.components;
|
|
|
|
export default defineComponent({
|
|
|
|
name: "test",
|
|
|
|
components: { CCButton, CCSection },
|
|
|
|
emits: ["validGame"],
|
|
|
|
props: {
|
|
|
|
isCocosGame: { type: Boolean, default: false },
|
|
|
|
},
|
|
|
|
setup(props, { emit }) {
|
2024-12-25 17:16:11 +08:00
|
|
|
const { config } = storeToRefs(appStore());
|
2024-12-09 19:25:06 +08:00
|
|
|
const show = ref(__DEV__);
|
2024-12-16 10:10:05 +08:00
|
|
|
// 测试发送的是纯数据
|
|
|
|
const testData = {
|
|
|
|
uuid: "d1NHXHs35F1rbFJZKeigkl",
|
|
|
|
group: [
|
|
|
|
{
|
|
|
|
id: "d1NHXHs35F1rbFJZKeigkl",
|
|
|
|
name: "cc.Scene",
|
|
|
|
data: [
|
|
|
|
{
|
|
|
|
name: "position",
|
|
|
|
value: {
|
|
|
|
id: "b9068b6f-8c1c-4d88-ac52-52cc09b37c1c",
|
|
|
|
type: "Vec3",
|
|
|
|
readonly: false,
|
|
|
|
path: [],
|
|
|
|
data: [
|
|
|
|
{ name: "x", value: { id: "be42ab63-d767-466e-8ba4-fb1b21201c54", type: "Number", readonly: false, path: ["d1NHXHs35F1rbFJZKeigkl", "x"], data: 0 } },
|
|
|
|
{ name: "y", value: { id: "498db9b2-e4a5-4c91-a546-1c3233e9bb50", type: "Number", readonly: false, path: ["d1NHXHs35F1rbFJZKeigkl", "y"], data: 0 } },
|
|
|
|
{ name: "z", value: { id: "400e184f-d754-4b66-aeb9-9f1feb1136a3", type: "Number", readonly: false, path: ["d1NHXHs35F1rbFJZKeigkl", "z"], data: 0 } },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2024-12-09 19:25:06 +08:00
|
|
|
return {
|
2024-12-25 17:16:11 +08:00
|
|
|
config,
|
2024-12-09 19:25:06 +08:00
|
|
|
show,
|
2024-12-25 17:16:11 +08:00
|
|
|
onExpandTest(v: boolean) {
|
|
|
|
console.log(v);
|
|
|
|
config.value.expandTest = v;
|
|
|
|
appStore().save();
|
|
|
|
},
|
2024-12-09 19:25:06 +08:00
|
|
|
onClickHasCocosGame() {
|
|
|
|
emit("validGame", true);
|
|
|
|
},
|
|
|
|
onClickNoCocosGame() {
|
|
|
|
emit("validGame", false);
|
|
|
|
},
|
2024-12-25 17:16:11 +08:00
|
|
|
onTerminal() {
|
|
|
|
const t = new Terminal("flag");
|
|
|
|
const event = new PluginEvent(Page.Background, Page.Background, Msg.NodeInfo, "");
|
|
|
|
console.log(...t.message("1"));
|
|
|
|
console.log(...t.log("newline", true));
|
|
|
|
console.log(...t.log("oneline", false));
|
|
|
|
console.log(...t.disconnect("disconnect"));
|
|
|
|
console.log(...t.connect("connect"));
|
|
|
|
console.log(...t.red("red"));
|
|
|
|
console.log(...t.green("green"));
|
|
|
|
console.log(...t.blue("blue"));
|
|
|
|
console.log(...t.chunk(event.toChunk()));
|
|
|
|
},
|
2024-12-09 20:49:02 +08:00
|
|
|
onTestTree() {
|
|
|
|
const data: TreeData = {
|
|
|
|
id: "1",
|
|
|
|
text: "root",
|
|
|
|
active: true,
|
|
|
|
children: [],
|
|
|
|
};
|
|
|
|
const event = new PluginEvent(Page.Inject, Page.Devtools, Msg.TreeInfo, data);
|
2024-12-24 21:09:13 +08:00
|
|
|
bridge.doMessage(event);
|
2024-12-09 20:49:02 +08:00
|
|
|
},
|
2024-12-12 20:13:50 +08:00
|
|
|
onFrames() {
|
|
|
|
const data: FrameDetails[] = [
|
|
|
|
{ url: "url1", frameID: 1 },
|
|
|
|
{ url: "url2", frameID: 2 },
|
|
|
|
];
|
|
|
|
const event = new PluginEvent(Page.Background, Page.Devtools, Msg.UpdateFrames, data);
|
|
|
|
testServer.send(event);
|
|
|
|
},
|
2024-12-16 10:10:05 +08:00
|
|
|
onTestNodeInfo() {
|
|
|
|
const event = new PluginEvent(Page.Background, Page.Devtools, Msg.NodeInfo, testData);
|
|
|
|
testServer.send(event);
|
|
|
|
},
|
2024-12-18 09:03:59 +08:00
|
|
|
onNull() {
|
|
|
|
const data = new NodeInfoData("", [new Group("", "1").buildProperty("dependAssets", new InvalidData("Null"))]);
|
|
|
|
const event = new PluginEvent(Page.Background, Page.Devtools, Msg.NodeInfo, data);
|
|
|
|
testServer.send(event);
|
|
|
|
},
|
2024-12-09 19:25:06 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
|
|
.test {
|
|
|
|
color: rgb(192, 56, 56);
|
|
|
|
font-size: 11%;
|
|
|
|
}
|
|
|
|
</style>
|