This commit is contained in:
xu_yanfeng 2024-01-05 13:48:16 +08:00
parent b9a88e5ef1
commit d72e53815c
10 changed files with 7025 additions and 0 deletions

View File

@ -0,0 +1,63 @@
// @ts-ignore
import {
CocosPluginManifest,
CocosPluginOptions,
Panel,
PluginType,
} from "cc-plugin/src/declare";
const pkgName = "cc-inspector";
function i18n(key: string) {
return `i18n:${pkgName}.${key}`;
}
const manifest: CocosPluginManifest = {
name: pkgName,
version: "1.0.0",
description: "cc-inspector",
author: "xu_yanfeng",
main: "./src/main.ts",
panels: [
{
name: "main",
type: Panel.Type.DockAble,
main: "./src/panel/index.ts",
title: "cc-inspector",
width: 500,
height: 400,
minWidth: 50,
minHeight: 400,
},
],
menus: [
{
path: `cc-inspector/${i18n("title")}`,
message: {
name: "showPanel",
},
},
],
i18n_en: "./src/i18n/en.ts",
i18n_zh: "./src/i18n/zh.ts",
chrome: {
view_devtools: "",
view_options: "",
view_popup: "",
script_background: "",
script_content: "",
script_inject: "",
},
};
// 这里的options变量名暂时不支持修改发布时会进行必要的修改
const options: CocosPluginOptions = {
server: {
enabled: true,
port: 2022,
},
watchBuild: true,
outputProject: {
web: "./web",
},
};
export default { manifest, options };

View File

@ -0,0 +1,4 @@
{
"v2": "",
"v3": ""
}

21
cc-inspector/package.json Normal file
View File

@ -0,0 +1,21 @@
{
"author": "cc-plugin",
"description": "cocos creator plugin",
"devDependencies": {
"@types/fs-extra": "9.0.1",
"@types/node": "16.11.12",
"@xuyanfeng/cc-ui": "0.2.14",
"cc-plugin": "file:.yalc/cc-plugin"
},
"name": "cc-plugin-demo",
"scripts": {
"installForce": "yarn install --force",
"ccp-pack-v2": "cc-plugin pack cp-v2",
"ccp-pack-v3": "cc-plugin pack cp-v3",
"ccp-pack-web": "cc-plugin pack web",
"ccp-serve-v2": "cc-plugin serve cp-v2",
"ccp-serve-v3": "cc-plugin serve cp-v3",
"ccp-serve-web": "cc-plugin serve web"
},
"version": "1.0.0"
}

View File

@ -0,0 +1 @@
export const title = 'my first plugin'

View File

@ -0,0 +1 @@
export const title = '我的第一个插件'

19
cc-inspector/src/main.ts Normal file
View File

@ -0,0 +1,19 @@
import pluginConfig from '../cc-plugin.config';
import CCP from 'cc-plugin/src/ccp/entry-main';
import { BuilderOptions } from 'cc-plugin/src/declare'
CCP.init(pluginConfig, {
load: () => {
console.log('plugin load')
},
builder: {
onAfterBuild(target: BuilderOptions) {
}
},
messages: {
showPanel() {
CCP.Adaptation.Panel.open('self.main')
}
}
})

View File

@ -0,0 +1,15 @@
import { createApp } from 'vue'
import App from './index.vue'
import CCP from 'cc-plugin/src/ccp/entry-render';
import pluginConfig from '../../cc-plugin.config'
import ccui from '@xuyanfeng/cc-ui';
import '@xuyanfeng/cc-ui/dist/ccui.css';
import '@xuyanfeng/cc-ui/iconfont/iconfont.css';
export default CCP.init(pluginConfig, {
ready: function (rootElement: any, args: any) {
const app = createApp(App)
app.use(ccui)
app.mount(rootElement)
}
})

View File

@ -0,0 +1,38 @@
<template>
<div class="panel">
Hi, {{ msg }}
<CCButton @click="onClickBtn">btn click-{{ count }}</CCButton>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref, provide, nextTick } from 'vue';
import PluginConfig from '../../cc-plugin.config';
import ccui from '@xuyanfeng/cc-ui';
const { CCInput, CCButton } = ccui.components;
export default defineComponent({
name: 'index',
components: { CCButton },
setup(props, { emit }) {
onMounted(() => {
console.log('hi ~~~');
});
const msg = ref(PluginConfig.manifest.name);
const count = ref(0);
return {
msg,
count,
onClickBtn() {
count.value++;
console.log('click btn');
},
};
},
});
</script>
<style scoped lang="less">
.panel {
display: flex;
flex-direction: column;
}
</style>

View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"target": "ES6",
"module": "commonjs",
"baseUrl": "./src"
}
}

6854
cc-inspector/yarn.lock Normal file

File diff suppressed because it is too large Load Diff