feat: diy模式区分入口
1
.gitignore
vendored
|
@ -9,6 +9,7 @@ lerna-debug.log*
|
||||||
|
|
||||||
node_modules
|
node_modules
|
||||||
# dist
|
# dist
|
||||||
|
diy-dist
|
||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.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",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
"dev:diy": "vite --config diy/diy.vite.config.ts",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
|
"build:diy": "tsc && vite build --config diy/diy.vite.config.ts",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"prepare": "husky install",
|
"prepare": "husky install",
|
||||||
"release:first": "standard-version -- --first-release",
|
"release:first": "standard-version -- --first-release",
|
||||||
|
|
47
src/App.tsx
|
@ -41,6 +41,7 @@ const App: FC<{ theme: Theme<any> }> = ({ theme: initTheme }) => {
|
||||||
|
|
||||||
// 生产环境才统计
|
// 生产环境才统计
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (__DIY__) return;
|
||||||
console.log(import.meta.env.MODE);
|
console.log(import.meta.env.MODE);
|
||||||
if (import.meta.env.PROD) {
|
if (import.meta.env.PROD) {
|
||||||
const busuanziScript = document.createElement('script');
|
const busuanziScript = document.createElement('script');
|
||||||
|
@ -71,31 +72,39 @@ const App: FC<{ theme: Theme<any> }> = ({ theme: initTheme }) => {
|
||||||
/>
|
/>
|
||||||
<PersonalInfo />
|
<PersonalInfo />
|
||||||
<div className={'flex-spacer'} />
|
<div className={'flex-spacer'} />
|
||||||
<p style={{ textAlign: 'center', fontSize: 10, opacity: 0.5 }}>
|
{!__DIY__ && (
|
||||||
<span id="busuanzi_container_site_pv">
|
<p
|
||||||
累计访问:
|
style={{
|
||||||
<span id="busuanzi_value_site_pv" />次
|
textAlign: 'center',
|
||||||
</span>
|
fontSize: 10,
|
||||||
<br />
|
opacity: 0.5,
|
||||||
<BeiAn />
|
}}
|
||||||
</p>
|
>
|
||||||
<Suspense fallback={<span>Loading</span>}>
|
<span id="busuanzi_container_site_pv">
|
||||||
{!theme.pure && (
|
累计访问:
|
||||||
<>
|
<span id="busuanzi_value_site_pv" />次
|
||||||
<Info />
|
</span>
|
||||||
<ThemeChanger
|
<br />
|
||||||
changeTheme={changeTheme}
|
<BeiAn />
|
||||||
onDiyClick={() => setDiyDialogShow(true)}
|
</p>
|
||||||
/>
|
)}
|
||||||
|
{!__DIY__ && !theme.pure && (
|
||||||
|
<>
|
||||||
|
<Info />
|
||||||
|
<ThemeChanger
|
||||||
|
changeTheme={changeTheme}
|
||||||
|
onDiyClick={() => setDiyDialogShow(true)}
|
||||||
|
/>
|
||||||
|
<Suspense fallback={<span>Loading</span>}>
|
||||||
{diyDialogShow && (
|
{diyDialogShow && (
|
||||||
<ConfigDialog
|
<ConfigDialog
|
||||||
closeMethod={() => setDiyDialogShow(false)}
|
closeMethod={() => setDiyDialogShow(false)}
|
||||||
previewMethod={previewTheme}
|
previewMethod={previewTheme}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</Suspense>
|
||||||
)}
|
</>
|
||||||
</Suspense>
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -142,8 +142,9 @@ const Symbol: FC<SymbolProps> = ({ x, y, icon, isCover, status, onClick }) => {
|
||||||
style={{ opacity: isCover ? 0.4 : 1 }}
|
style={{ opacity: isCover ? 0.4 : 1 }}
|
||||||
>
|
>
|
||||||
{typeof icon.content === 'string' ? (
|
{typeof icon.content === 'string' ? (
|
||||||
icon.content.startsWith('http') ? (
|
icon.content.startsWith('http') ||
|
||||||
/*图片外链*/
|
icon.content.startsWith('/') ? (
|
||||||
|
/*图片地址*/
|
||||||
<img src={icon.content} alt="" />
|
<img src={icon.content} alt="" />
|
||||||
) : (
|
) : (
|
||||||
/*字符表情*/
|
/*字符表情*/
|
||||||
|
|
|
@ -57,6 +57,8 @@ Bmob.initialize(
|
||||||
import.meta.env.VITE_BMOB_SECCODE
|
import.meta.env.VITE_BMOB_SECCODE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log(import.meta.env);
|
||||||
|
|
||||||
const loadTheme = () => {
|
const loadTheme = () => {
|
||||||
// 请求主题
|
// 请求主题
|
||||||
if (customThemeIdFromPath) {
|
if (customThemeIdFromPath) {
|
||||||
|
|
1
src/vite-env.d.ts
vendored
|
@ -1 +1,2 @@
|
||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
declare const __DIY__: boolean;
|
||||||
|
|
|
@ -8,4 +8,7 @@ export default defineConfig({
|
||||||
host: true,
|
host: true,
|
||||||
port: 5555,
|
port: 5555,
|
||||||
},
|
},
|
||||||
|
define: {
|
||||||
|
__DIY__: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|