添加开关

This commit is contained in:
nextfu 2022-08-02 21:12:45 +08:00
parent 6aeca4583e
commit 90baadd0aa
12 changed files with 168 additions and 121 deletions

View File

@ -1,2 +1,2 @@
<div id="app" style="width: 400px;height: 100%;display: flex;flex-direction: column;justify-content: center;"></div>
<div id="dev-app" style="width: 400px;height: 100%;display: none;flex-direction: column;justify-content: center;"></div>
<script type="module" src="/src/main.ts"></script>

View File

@ -7,7 +7,8 @@
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"package": "node scripts/package.js"
"package": "node scripts/package.js",
"setup": "node scripts/setup.js"
},
"dependencies": {
"element-plus": "^2.2.6",
@ -17,6 +18,7 @@
"devDependencies": {
"@vitejs/plugin-vue": "^2.3.3",
"adm-zip": "^0.5.9",
"fs-extra": "^10.1.0",
"typescript": "^4.5.4",
"unplugin-auto-import": "^0.9.3",
"unplugin-vue-components": "^0.21.1",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
<script type="module" crossorigin src="/dist/assets/index.bec476d0.js"></script>
<link rel="stylesheet" href="/dist/assets/index.1d01bced.css">
<div id="app"></div>
<script type="module" crossorigin src="/dist/assets/index.1b8a852c.js"></script>
<link rel="stylesheet" href="/dist/assets/index.a2551c8e.css">
<div id="dev-app" style="width: 400px;height: 100%;display: none;flex-direction: column;justify-content: center;"></div>

View File

@ -18,7 +18,7 @@
<link rel="stylesheet" type="text/css" href="./index.css" />
</head>
<body>
<%- include(cocosToolBar, {config: config}) %>
<%- include('./toolbar', {config: config}) %>
<div style="display: flex;flex: auto;align-items: center;">
<%- include ./dist/index.html %>
<div id="content" class="content">

View File

@ -36,10 +36,12 @@
<script>
const devtoolsBtn = document.getElementById('btn-show-devtools');
devtoolsBtn.addEventListener('click', () => {
cc.showDevtools = !cc.showDevtools;
if (cc.showDevtools) {
const devApp = document.getElementById('dev-app');
if (devApp.style.display === 'none') {
devApp.style.display = 'flex';
devtoolsBtn.classList.add('checked');
} else {
devApp.style.display = 'none';
devtoolsBtn.classList.remove('checked');
}
}, false);

15
scripts/setup.js Normal file
View File

@ -0,0 +1,15 @@
const fse = require('fs-extra');
const path = require('path');
const localTemplatePath = path.join(__dirname, '../release/');
const projectTemplatePath = '/Users/next/projects/cocos/example352/';
if (!fse.existsSync(projectTemplatePath)) {
console.error('project path not exist');
return;
}
fse.copy(localTemplatePath, projectTemplatePath).then(() => {
console.log('更新预览模板成功');
}).catch(err => {
console.error('更新预览模板失败', err);
});

View File

@ -3,4 +3,4 @@ import App from './App.vue';
import 'element-plus/theme-chalk/dark/css-vars.css';
import vfmPlugin from 'vue-final-modal'
createApp(App).use(vfmPlugin).mount('#app');
createApp(App).use(vfmPlugin).mount('#dev-app');

View File

@ -502,6 +502,15 @@ fill-range@^7.0.1:
dependencies:
to-regex-range "^5.0.1"
fs-extra@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf"
integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==
dependencies:
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^2.0.0"
fsevents@~2.3.2:
version "2.3.2"
resolved "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
@ -519,6 +528,11 @@ glob-parent@^5.1.2, glob-parent@~5.1.2:
dependencies:
is-glob "^4.0.1"
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
version "4.2.10"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c"
integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==
has@^1.0.3:
version "1.0.3"
resolved "https://registry.npmmirror.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796"
@ -562,6 +576,15 @@ jsonc-parser@^3.0.0:
resolved "https://registry.npmmirror.com/jsonc-parser/-/jsonc-parser-3.1.0.tgz#73b8f0e5c940b83d03476bc2e51a20ef0932615d"
integrity sha512-DRf0QjnNeCUds3xTjKlQQ3DpJD51GvDjJfnxUVWg6PZTo2otSm+slzNAxU/35hF8/oJIKoG9slq30JYOsF2azg==
jsonfile@^6.0.1:
version "6.1.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
dependencies:
universalify "^2.0.0"
optionalDependencies:
graceful-fs "^4.1.6"
local-pkg@^0.4.1, local-pkg@^0.4.2:
version "0.4.2"
resolved "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.2.tgz#13107310b77e74a0e513147a131a2ba288176c2f"
@ -787,6 +810,11 @@ unimport@^0.4.5:
strip-literal "^0.4.0"
unplugin "^0.7.2"
universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
unplugin-auto-import@^0.9.3:
version "0.9.3"
resolved "https://registry.npmmirror.com/unplugin-auto-import/-/unplugin-auto-import-0.9.3.tgz#bdcfe8f40cf74eece7bad2b37ad319ae4e019b97"