feat: diy模式区分入口
1
.gitignore
vendored
|
@ -9,6 +9,7 @@ lerna-debug.log*
|
|||
|
||||
node_modules
|
||||
# dist
|
||||
diy-dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
|
|
98
diy/diy.theme.json
Normal file
|
@ -0,0 +1,98 @@
|
|||
{
|
||||
"title": "标题",
|
||||
"desc": "描述",
|
||||
"bgm": "/sound-disco.mp3",
|
||||
"dark": true,
|
||||
"backgroundColor": "#8dac85",
|
||||
"pure": true,
|
||||
"backgroundBlur": false,
|
||||
"icons": [
|
||||
{
|
||||
"name": "1",
|
||||
"content": "/1.png",
|
||||
"clickSound": "button-click",
|
||||
"tripleSound": "triple"
|
||||
},
|
||||
{
|
||||
"name": "2",
|
||||
"content": "/2.png",
|
||||
"clickSound": "button-click",
|
||||
"tripleSound": "triple"
|
||||
},
|
||||
{
|
||||
"name": "3",
|
||||
"content": "/3.png",
|
||||
"clickSound": "button-click",
|
||||
"tripleSound": "triple"
|
||||
},
|
||||
{
|
||||
"name": "4",
|
||||
"content": "/4.png",
|
||||
"clickSound": "button-click",
|
||||
"tripleSound": "triple"
|
||||
},
|
||||
{
|
||||
"name": "5",
|
||||
"content": "/5.png",
|
||||
"clickSound": "button-click",
|
||||
"tripleSound": "triple"
|
||||
},
|
||||
{
|
||||
"name": "6",
|
||||
"content": "/6.png",
|
||||
"clickSound": "button-click",
|
||||
"tripleSound": "triple"
|
||||
},
|
||||
{
|
||||
"name": "7",
|
||||
"content": "/7.png",
|
||||
"clickSound": "button-click",
|
||||
"tripleSound": "triple"
|
||||
},
|
||||
{
|
||||
"name": "8",
|
||||
"content": "/8.png",
|
||||
"clickSound": "button-click",
|
||||
"tripleSound": "triple"
|
||||
},
|
||||
{
|
||||
"name": "9",
|
||||
"content": "/9.png",
|
||||
"clickSound": "button-click",
|
||||
"tripleSound": "triple"
|
||||
},
|
||||
{
|
||||
"name": "10",
|
||||
"content": "/10.png",
|
||||
"clickSound": "button-click",
|
||||
"tripleSound": "triple"
|
||||
}
|
||||
],
|
||||
"sounds": [
|
||||
{
|
||||
"name": "sound-undo",
|
||||
"src": "/sound-undo.mp3"
|
||||
},
|
||||
{
|
||||
"name": "sound-shift",
|
||||
"src": "/sound-shift.mp3"
|
||||
},
|
||||
{
|
||||
"name": "sound-wash",
|
||||
"src": "/sound-wash.mp3"
|
||||
},
|
||||
{
|
||||
"name": "button-click",
|
||||
"src": "/sound-button-click.mp3"
|
||||
},
|
||||
{
|
||||
"name": "triple",
|
||||
"src": "/sound-triple.mp3"
|
||||
}
|
||||
],
|
||||
"operateSoundMap": {
|
||||
"shift": "sound-shift",
|
||||
"undo": "sound-undo",
|
||||
"wash": "sound-wash"
|
||||
}
|
||||
}
|
19
diy/diy.vite.config.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
root: 'diy',
|
||||
publicDir: './public',
|
||||
build: {
|
||||
outDir: 'diy-dist',
|
||||
},
|
||||
define: {
|
||||
__DIY__: true,
|
||||
},
|
||||
server: {
|
||||
host: true,
|
||||
port: 5556,
|
||||
},
|
||||
});
|
38
diy/index.html
Normal file
|
@ -0,0 +1,38 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="./public/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta
|
||||
name="description"
|
||||
content="无限道具版羊了个羊、可以通关的羊了个羊"
|
||||
/>
|
||||
<title>有解的羊了个羊</title>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: white;
|
||||
transition: background-color 0.3s 0.4s;
|
||||
color: rgb(0 0 0 / 60%);
|
||||
}
|
||||
a {
|
||||
color: currentColor;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
#root {
|
||||
transition: opacity 0.5s;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script>
|
||||
// vite没有global,手动声明
|
||||
var global = global || window;
|
||||
</script>
|
||||
<script type="module" src="./main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
15
diy/main.tsx
Normal file
|
@ -0,0 +1,15 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import App from '../src/App';
|
||||
import '../src/styles/global.scss';
|
||||
import '../src/styles/utils.scss';
|
||||
import { domRelatedOptForTheme } from '../src/utils';
|
||||
import theme from './diy.theme.json';
|
||||
|
||||
domRelatedOptForTheme(theme);
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<App theme={theme} />
|
||||
</React.StrictMode>
|
||||
);
|
BIN
diy/public/1.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
diy/public/10.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
diy/public/2.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
diy/public/3.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
diy/public/4.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
diy/public/5.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
diy/public/6.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
diy/public/7.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
diy/public/8.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
diy/public/9.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
diy/public/favicon.ico
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
diy/public/sound-button-click.mp3
Normal file
BIN
diy/public/sound-disco.mp3
Normal file
BIN
diy/public/sound-shift.mp3
Normal file
BIN
diy/public/sound-triple.mp3
Normal file
BIN
diy/public/sound-undo.mp3
Normal file
BIN
diy/public/sound-wash.mp3
Normal file
|
@ -5,7 +5,9 @@
|
|||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"dev:diy": "vite --config diy/diy.vite.config.ts",
|
||||
"build": "tsc && vite build",
|
||||
"build:diy": "tsc && vite build --config diy/diy.vite.config.ts",
|
||||
"preview": "vite preview",
|
||||
"prepare": "husky install",
|
||||
"release:first": "standard-version -- --first-release",
|
||||
|
|
17
src/App.tsx
|
@ -41,6 +41,7 @@ const App: FC<{ theme: Theme<any> }> = ({ theme: initTheme }) => {
|
|||
|
||||
// 生产环境才统计
|
||||
useEffect(() => {
|
||||
if (__DIY__) return;
|
||||
console.log(import.meta.env.MODE);
|
||||
if (import.meta.env.PROD) {
|
||||
const busuanziScript = document.createElement('script');
|
||||
|
@ -71,7 +72,14 @@ const App: FC<{ theme: Theme<any> }> = ({ theme: initTheme }) => {
|
|||
/>
|
||||
<PersonalInfo />
|
||||
<div className={'flex-spacer'} />
|
||||
<p style={{ textAlign: 'center', fontSize: 10, opacity: 0.5 }}>
|
||||
{!__DIY__ && (
|
||||
<p
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
fontSize: 10,
|
||||
opacity: 0.5,
|
||||
}}
|
||||
>
|
||||
<span id="busuanzi_container_site_pv">
|
||||
累计访问:
|
||||
<span id="busuanzi_value_site_pv" />次
|
||||
|
@ -79,23 +87,24 @@ const App: FC<{ theme: Theme<any> }> = ({ theme: initTheme }) => {
|
|||
<br />
|
||||
<BeiAn />
|
||||
</p>
|
||||
<Suspense fallback={<span>Loading</span>}>
|
||||
{!theme.pure && (
|
||||
)}
|
||||
{!__DIY__ && !theme.pure && (
|
||||
<>
|
||||
<Info />
|
||||
<ThemeChanger
|
||||
changeTheme={changeTheme}
|
||||
onDiyClick={() => setDiyDialogShow(true)}
|
||||
/>
|
||||
<Suspense fallback={<span>Loading</span>}>
|
||||
{diyDialogShow && (
|
||||
<ConfigDialog
|
||||
closeMethod={() => setDiyDialogShow(false)}
|
||||
previewMethod={previewTheme}
|
||||
/>
|
||||
)}
|
||||
</Suspense>
|
||||
</>
|
||||
)}
|
||||
</Suspense>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -142,8 +142,9 @@ const Symbol: FC<SymbolProps> = ({ x, y, icon, isCover, status, onClick }) => {
|
|||
style={{ opacity: isCover ? 0.4 : 1 }}
|
||||
>
|
||||
{typeof icon.content === 'string' ? (
|
||||
icon.content.startsWith('http') ? (
|
||||
/*图片外链*/
|
||||
icon.content.startsWith('http') ||
|
||||
icon.content.startsWith('/') ? (
|
||||
/*图片地址*/
|
||||
<img src={icon.content} alt="" />
|
||||
) : (
|
||||
/*字符表情*/
|
||||
|
|
|
@ -57,6 +57,8 @@ Bmob.initialize(
|
|||
import.meta.env.VITE_BMOB_SECCODE
|
||||
);
|
||||
|
||||
console.log(import.meta.env);
|
||||
|
||||
const loadTheme = () => {
|
||||
// 请求主题
|
||||
if (customThemeIdFromPath) {
|
||||
|
|
1
src/vite-env.d.ts
vendored
|
@ -1 +1,2 @@
|
|||
/// <reference types="vite/client" />
|
||||
declare const __DIY__: boolean;
|
||||
|
|
|
@ -8,4 +8,7 @@ export default defineConfig({
|
|||
host: true,
|
||||
port: 5555,
|
||||
},
|
||||
define: {
|
||||
__DIY__: false,
|
||||
},
|
||||
});
|
||||
|
|