Compare commits
10 Commits
24fb2aa175
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
240e3283b3 | ||
|
|
d146fe9589 | ||
|
|
79568c0ea1 | ||
|
|
e37edd16b5 | ||
|
|
745e786fcd | ||
|
|
8a227785d1 | ||
|
|
2a64f28846 | ||
|
|
87079f3e89 | ||
|
|
f9e9128d5d | ||
|
|
b34742a76a |
@@ -8,3 +8,6 @@ module.exports = {
|
|||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ const config = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
h5: {
|
h5: {
|
||||||
|
// 默认会编译为 es5,修改为 es2017 或更高
|
||||||
|
esnext: true,
|
||||||
webpackChain(chain) {
|
webpackChain(chain) {
|
||||||
|
|
||||||
chain.output.filename("static/js/[name].[contenthash:8].js");
|
chain.output.filename("static/js/[name].[contenthash:8].js");
|
||||||
chain.output.chunkFilename("static/js/[name].[contenthash:8].js");
|
chain.output.chunkFilename("static/js/[name].[contenthash:8].js");
|
||||||
chain
|
chain
|
||||||
@@ -54,6 +57,7 @@ const config = {
|
|||||||
simplify: true, // 开启简化,提高性能
|
simplify: true, // 开启简化,提高性能
|
||||||
// 禁用对 async/await 的转换
|
// 禁用对 async/await 的转换
|
||||||
target: "browser", // 或设置为适合目标环境的 ECMAScript 版本
|
target: "browser", // 或设置为适合目标环境的 ECMAScript 版本
|
||||||
|
|
||||||
disableOptimizations: true, // 禁用某些优化来避免处理 async/await
|
disableOptimizations: true, // 禁用某些优化来避免处理 async/await
|
||||||
},
|
},
|
||||||
["**/*.js", "!node_modules/**"], // 避免对 node_modules 进行混淆
|
["**/*.js", "!node_modules/**"], // 避免对 node_modules 进行混淆
|
||||||
@@ -125,6 +129,10 @@ const config = {
|
|||||||
},
|
},
|
||||||
// 允许特定域名访问
|
// 允许特定域名访问
|
||||||
allowedHosts: ["nomadyt.com", "localhost", ".nomadyt.com"], // 允许所有 *.nomadyt.com 子域访问
|
allowedHosts: ["nomadyt.com", "localhost", ".nomadyt.com"], // 允许所有 *.nomadyt.com 子域访问
|
||||||
|
// ⬇️ 关键配置:禁用 overlay 错误弹出
|
||||||
|
client: {
|
||||||
|
overlay: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
htmlPluginOption: {
|
htmlPluginOption: {
|
||||||
favicon: path.resolve(__dirname, "..", "src", "images", "youtube.ico"), // 同样处理 favicon 路径
|
favicon: path.resolve(__dirname, "..", "src", "images", "youtube.ico"), // 同样处理 favicon 路径
|
||||||
@@ -135,7 +143,8 @@ const config = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
target: ["web", "browserslist:> 0.25%, not dead"],
|
// target: ["web", "browserslist:> 0.25%, not dead"],
|
||||||
|
target: ["web", "es2017"], // 关键点!
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.8.0",
|
"@babel/core": "^7.8.0",
|
||||||
|
"@babel/preset-env": "^7.26.9",
|
||||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
||||||
"@tarojs/cli": "3.6.20",
|
"@tarojs/cli": "3.6.20",
|
||||||
"@tarojs/taro-loader": "3.6.20",
|
"@tarojs/taro-loader": "3.6.20",
|
||||||
@@ -73,6 +74,7 @@
|
|||||||
"javascript-obfuscator": "^4.1.1",
|
"javascript-obfuscator": "^4.1.1",
|
||||||
"postcss": "^8.4.18",
|
"postcss": "^8.4.18",
|
||||||
"react-refresh": "^0.11.0",
|
"react-refresh": "^0.11.0",
|
||||||
|
"regenerator-runtime": "^0.14.1",
|
||||||
"stylelint": "9.3.0",
|
"stylelint": "9.3.0",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^4.1.0",
|
"typescript": "^4.1.0",
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import './app.scss'
|
|||||||
import 'animate.css';
|
import 'animate.css';
|
||||||
import 'taro-ui/dist/style/index.scss' // 全局引入一次即可
|
import 'taro-ui/dist/style/index.scss' // 全局引入一次即可
|
||||||
|
|
||||||
|
import 'core-js/stable';
|
||||||
|
import 'regenerator-runtime/runtime'; // 用于支持 async/await
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 有数埋点SDK 默认配置
|
* 有数埋点SDK 默认配置
|
||||||
* 使用方法请参考文档 https://mp.zhls.qq.com/youshu-docs/develop/sdk/Taro.html
|
* 使用方法请参考文档 https://mp.zhls.qq.com/youshu-docs/develop/sdk/Taro.html
|
||||||
@@ -68,7 +71,7 @@ class App extends Component {
|
|||||||
|
|
||||||
// this.props.children 是将要会渲染的页面
|
// this.props.children 是将要会渲染的页面
|
||||||
render () {
|
render () {
|
||||||
return this.props.children
|
return this.props?.children
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
src/images/11.gif
Normal file
BIN
src/images/11.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 321 KiB |
BIN
src/images/22.gif
Normal file
BIN
src/images/22.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 MiB |
BIN
src/images/baby.mp3
Normal file
BIN
src/images/baby.mp3
Normal file
Binary file not shown.
BIN
src/images/doro11.gif
Normal file
BIN
src/images/doro11.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 158 KiB |
@@ -1,43 +1,167 @@
|
|||||||
import { Component } from "react";
|
import { Component } from "react";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import { View, Text, Image, Button } from "@tarojs/components";
|
import { View, Text, Image, Button, Audio } from "@tarojs/components";
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
import { AtTabBar } from "taro-ui";
|
import React, { useCallback, useEffect, useState, useRef } from "react";
|
||||||
import React, { useCallback, useEffect, useState } from "react";
|
|
||||||
import { AtGrid } from "taro-ui";
|
|
||||||
import { Swiper, SwiperItem } from "@tarojs/components";
|
|
||||||
import { AtCard } from "taro-ui";
|
|
||||||
import { AtImagePicker } from "taro-ui";
|
|
||||||
import { AtButton } from "taro-ui";
|
|
||||||
import { AtSearchBar } from "taro-ui";
|
|
||||||
import { Picker } from "@tarojs/components";
|
|
||||||
import { AtList, AtListItem, AtNavBar, AtTag, AtMessage } from "taro-ui";
|
|
||||||
import {
|
import {
|
||||||
AtModal,
|
AtList,
|
||||||
AtModalHeader,
|
AtListItem,
|
||||||
AtModalContent,
|
AtNavBar,
|
||||||
AtModalAction,
|
AtTag,
|
||||||
AtAvatar,
|
AtMessage,
|
||||||
AtAccordion,
|
AtCurtain,
|
||||||
} from "taro-ui";
|
} from "taro-ui";
|
||||||
import { AtToast } from "taro-ui";
|
|
||||||
import { AtIcon } from "taro-ui";
|
|
||||||
import iphone from "../../images/iphone.jpg";
|
|
||||||
import gif11 from "../../images/11.gif";
|
import gif11 from "../../images/11.gif";
|
||||||
import confetti from "canvas-confetti";
|
|
||||||
import gif22 from "../../images/22.gif";
|
import gif22 from "../../images/22.gif";
|
||||||
import doro11 from "../../images/doro11.gif";
|
import doro11 from "../../images/doro11.gif";
|
||||||
|
import baby from "../../images/baby.mp3";
|
||||||
import testmpkv from "../../images/test.mp4";
|
import confetti from "canvas-confetti";
|
||||||
|
import { AtToast } from "taro-ui";
|
||||||
|
import { userinfoArr } from "./userinfoArr";
|
||||||
|
|
||||||
const Index = () => {
|
const Index = () => {
|
||||||
// ws://(或者 wss:// 对于 HTTPS 环境
|
// ws://(或者 wss:// 对于 HTTPS 环境
|
||||||
const [message, setMessage] = useState("");
|
const [message, setMessage] = useState("");
|
||||||
const [status, setStatus] = useState("0"); //0无状态,1是小新
|
const [status, setStatus] = useState("0"); //0无状态,1是小新
|
||||||
|
const [userInfoArr, setuserInfoArr] = useState([]); // 用户信息
|
||||||
|
const [giftUser, setGiftUser] = useState({}); // 用户信息
|
||||||
|
const [giftOpen, setGiftOpen] = useState(false); // 用户信息
|
||||||
|
|
||||||
const [messageArr, setMessageArr] = useState([]);
|
const [messageArr, setMessageArr] = useState([]);
|
||||||
|
|
||||||
|
// 记录最后一次真实观众进场时间戳
|
||||||
|
const lastRealJoinTime = useRef(Date.now());
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// const intervalId = setInterval(() => {
|
||||||
|
// speak(`欢迎进入直播间`);
|
||||||
|
// }, 3000);
|
||||||
|
|
||||||
|
// return () => {
|
||||||
|
// clearInterval(intervalId);
|
||||||
|
// };
|
||||||
|
// }, []);
|
||||||
|
|
||||||
|
// 随机取一个观众
|
||||||
|
const getRandomUser = () => {
|
||||||
|
const randomIndex = Math.floor(Math.random() * userinfoArr.length);
|
||||||
|
return {
|
||||||
|
...userinfoArr[randomIndex],
|
||||||
|
animate: true,
|
||||||
|
uid: Date.now() + Math.random(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// 3秒检测一次是否无人,插入假观众
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - lastRealJoinTime.current > 10000) {
|
||||||
|
// 超过10秒无人进入
|
||||||
|
const fakeUser = getRandomUser();
|
||||||
|
console.log("⚠️ 3秒无人进入,插入假观众:", fakeUser.nick_name);
|
||||||
|
|
||||||
|
setuserInfoArr((prev) => [fakeUser, ...prev]);
|
||||||
|
speak(`欢迎${fakeUser.nick_name} 进入直播间`);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
setuserInfoArr((prev) =>
|
||||||
|
prev.map((u) =>
|
||||||
|
u.uid === fakeUser.uid ? { ...u, animate: false } : u
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
// 重置 lastRealJoinTime 防止一直插入假观众
|
||||||
|
lastRealJoinTime.current = Date.now();
|
||||||
|
}
|
||||||
|
}, 6000);
|
||||||
|
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const confettiSvg = () => {
|
||||||
|
var scalar = 2;
|
||||||
|
var pineapple = confetti.shapeFromText({ text: "🍍", scalar });
|
||||||
|
|
||||||
|
confetti({
|
||||||
|
shapes: [pineapple],
|
||||||
|
scalar,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const stars = () => {
|
||||||
|
// note: you CAN only use a path for confetti.shapeFrompath(), but for
|
||||||
|
// performance reasons it is best to use it once in development and save
|
||||||
|
// the result to avoid the performance penalty at runtime
|
||||||
|
|
||||||
|
// pumpkin shape from https://thenounproject.com/icon/pumpkin-5253388/
|
||||||
|
var pumpkin = confetti.shapeFromPath({
|
||||||
|
path: "M449.4 142c-5 0-10 .3-15 1a183 183 0 0 0-66.9-19.1V87.5a17.5 17.5 0 1 0-35 0v36.4a183 183 0 0 0-67 19c-4.9-.6-9.9-1-14.8-1C170.3 142 105 219.6 105 315s65.3 173 145.7 173c5 0 10-.3 14.8-1a184.7 184.7 0 0 0 169 0c4.9.7 9.9 1 14.9 1 80.3 0 145.6-77.6 145.6-173s-65.3-173-145.7-173zm-220 138 27.4-40.4a11.6 11.6 0 0 1 16.4-2.7l54.7 40.3a11.3 11.3 0 0 1-7 20.3H239a11.3 11.3 0 0 1-9.6-17.5zM444 383.8l-43.7 17.5a17.7 17.7 0 0 1-13 0l-37.3-15-37.2 15a17.8 17.8 0 0 1-13 0L256 383.8a17.5 17.5 0 0 1 13-32.6l37.3 15 37.2-15c4.2-1.6 8.8-1.6 13 0l37.3 15 37.2-15a17.5 17.5 0 0 1 13 32.6zm17-86.3h-82a11.3 11.3 0 0 1-6.9-20.4l54.7-40.3a11.6 11.6 0 0 1 16.4 2.8l27.4 40.4a11.3 11.3 0 0 1-9.6 17.5z",
|
||||||
|
matrix: [
|
||||||
|
0.020491803278688523, 0, 0, 0.020491803278688523, -7.172131147540983,
|
||||||
|
-5.9016393442622945,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
// tree shape from https://thenounproject.com/icon/pine-tree-1471679/
|
||||||
|
var tree = confetti.shapeFromPath({
|
||||||
|
path: "M120 240c-41,14 -91,18 -120,1 29,-10 57,-22 81,-40 -18,2 -37,3 -55,-3 25,-14 48,-30 66,-51 -11,5 -26,8 -45,7 20,-14 40,-30 57,-49 -13,1 -26,2 -38,-1 18,-11 35,-25 51,-43 -13,3 -24,5 -35,6 21,-19 40,-41 53,-67 14,26 32,48 54,67 -11,-1 -23,-3 -35,-6 15,18 32,32 51,43 -13,3 -26,2 -38,1 17,19 36,35 56,49 -19,1 -33,-2 -45,-7 19,21 42,37 67,51 -19,6 -37,5 -56,3 25,18 53,30 82,40 -30,17 -79,13 -120,-1l0 41 -31 0 0 -41z",
|
||||||
|
matrix: [
|
||||||
|
0.03597122302158273, 0, 0, 0.03597122302158273, -4.856115107913669,
|
||||||
|
-5.071942446043165,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
// heart shape from https://thenounproject.com/icon/heart-1545381/
|
||||||
|
var heart = confetti.shapeFromPath({
|
||||||
|
path: "M167 72c19,-38 37,-56 75,-56 42,0 76,33 76,75 0,76 -76,151 -151,227 -76,-76 -151,-151 -151,-227 0,-42 33,-75 75,-75 38,0 57,18 76,56z",
|
||||||
|
matrix: [
|
||||||
|
0.03333333333333333, 0, 0, 0.03333333333333333, -5.566666666666666,
|
||||||
|
-5.533333333333333,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
scalar: 2,
|
||||||
|
spread: 180,
|
||||||
|
particleCount: 30,
|
||||||
|
origin: { y: -0.1 },
|
||||||
|
startVelocity: -35,
|
||||||
|
};
|
||||||
|
|
||||||
|
confetti({
|
||||||
|
...defaults,
|
||||||
|
shapes: [pumpkin],
|
||||||
|
colors: ["#ff9a00", "#ff7400", "#ff4d00"],
|
||||||
|
});
|
||||||
|
confetti({
|
||||||
|
...defaults,
|
||||||
|
shapes: [tree],
|
||||||
|
colors: ["#8d960f", "#be0f10", "#445404"],
|
||||||
|
});
|
||||||
|
confetti({
|
||||||
|
...defaults,
|
||||||
|
shapes: [heart],
|
||||||
|
colors: ["#f93963", "#a10864", "#ee0b93"],
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// var myCanvas = document.createElement("canvas");
|
||||||
|
// document.body.appendChild(myCanvas);
|
||||||
|
// var myConfetti = confetti.create(myCanvas, {
|
||||||
|
// resize: true,
|
||||||
|
// useWorker: true,
|
||||||
|
// });
|
||||||
|
// myConfetti({
|
||||||
|
// particleCount: 100,
|
||||||
|
// spread: 160,
|
||||||
|
// // any other options from the global
|
||||||
|
// // confetti function
|
||||||
|
// });
|
||||||
|
}, []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 创建 WebSocket 连接
|
// 创建 WebSocket 连接
|
||||||
const socket = new WebSocket("ws://127.0.0.1:8888"); // 注意使用 ws://
|
const socket = new WebSocket("ws://127.0.0.1:8888"); // 注意使用 ws://
|
||||||
@@ -50,25 +174,59 @@ const Index = () => {
|
|||||||
|
|
||||||
// WebSocket 接收到消息时触发
|
// WebSocket 接收到消息时触发
|
||||||
socket.onmessage = (event) => {
|
socket.onmessage = (event) => {
|
||||||
console.log("接收到消息:", event.data);
|
try {
|
||||||
setMessage(event.data); // 更新消息状态
|
const data = JSON.parse(event.data);
|
||||||
if (event.data.includes("【聊天msg】")) {
|
console.log("data.type---", data.type);
|
||||||
if (event.data?.includes("11")) {
|
if (data.type === "join") {
|
||||||
setStatus("1");
|
// const user = data.data; // 就是你后端推送的 user_data 字典
|
||||||
|
const user = {
|
||||||
|
...data.data,
|
||||||
|
animate: true,
|
||||||
|
uid: Date.now() + Math.random(), // 确保唯一
|
||||||
|
};
|
||||||
|
console.log("✅ 新观众进场:", user);
|
||||||
|
// 更新真实观众进场时间
|
||||||
|
lastRealJoinTime.current = Date.now();
|
||||||
|
|
||||||
|
// setuserInfoArr((prev) => [user, ...prev]);
|
||||||
|
// 更新 state
|
||||||
|
setuserInfoArr((prev) => {
|
||||||
|
const updated = [user, ...prev];
|
||||||
|
|
||||||
|
// 同步到 localStorage
|
||||||
|
localStorage.setItem("userInfoArr", JSON.stringify(updated));
|
||||||
|
return updated;
|
||||||
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setStatus("0");
|
setuserInfoArr((prev) =>
|
||||||
}, 1000); // 2秒后恢复
|
prev.map((u) =>
|
||||||
}
|
u.uid === user.uid ? { ...u, animate: false } : u
|
||||||
if (event.data?.includes("22")) {
|
)
|
||||||
setStatus("2");
|
);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
// ✅ 举例使用
|
||||||
|
speak(`欢迎${user?.nick_name} 进入直播间`);
|
||||||
|
} else if (data.type === "like") {
|
||||||
|
const user = data.data;
|
||||||
|
// 粒子特效
|
||||||
|
// confettiSvg();
|
||||||
|
stars();
|
||||||
|
} else if (data.type === "gift") {
|
||||||
|
stars();
|
||||||
|
const user = data.data;
|
||||||
|
// console.log("✅ 送礼:", user);
|
||||||
|
speak(`谢谢${user?.nick_name} 送小星星`);
|
||||||
|
//特殊特效
|
||||||
|
setGiftUser(user);
|
||||||
|
setGiftOpen(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setStatus("0");
|
setGiftOpen(false);
|
||||||
}, 5000); // 2秒后恢复
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("❌ 非 JSON 消息:", event.data);
|
||||||
}
|
}
|
||||||
// TTS播放
|
|
||||||
speak(event.data);
|
|
||||||
setMessageArr((messageArr) => [event.data, ...messageArr]); // 更新消息数组
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// WebSocket 关闭时触发
|
// WebSocket 关闭时触发
|
||||||
@@ -88,26 +246,81 @@ const Index = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// TTS播放语言
|
// TTS播放语言
|
||||||
|
// const speak = (text) => {
|
||||||
|
// const synth = window.speechSynthesis;
|
||||||
|
// const speakNow = () => {
|
||||||
|
// const utterance = new SpeechSynthesisUtterance(text);
|
||||||
|
// utterance.lang = "zh-CN";
|
||||||
|
// utterance.rate = 1;
|
||||||
|
// utterance.pitch = 1;
|
||||||
|
// synth.speak(utterance);
|
||||||
|
// };
|
||||||
|
|
||||||
|
// if (synth.getVoices().length === 0) {
|
||||||
|
// // 有些浏览器语音列表异步加载
|
||||||
|
// synth.onvoiceschanged = () => {
|
||||||
|
// speakNow();
|
||||||
|
// };
|
||||||
|
// } else {
|
||||||
|
// speakNow();
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
const speak = (text) => {
|
const speak = (text) => {
|
||||||
|
if (typeof window === "undefined" || !window.speechSynthesis) {
|
||||||
|
console.warn("当前环境不支持 speechSynthesis");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const synth = window.speechSynthesis;
|
const synth = window.speechSynthesis;
|
||||||
|
|
||||||
const speakNow = () => {
|
const speakNow = () => {
|
||||||
|
// 防止连续播放冲突
|
||||||
|
synth.cancel();
|
||||||
|
|
||||||
const utterance = new SpeechSynthesisUtterance(text);
|
const utterance = new SpeechSynthesisUtterance(text);
|
||||||
utterance.lang = "zh-CN";
|
utterance.lang = "zh-CN"; // 中文语音
|
||||||
utterance.rate = 1;
|
utterance.rate = 1;
|
||||||
utterance.pitch = 1;
|
utterance.pitch = 1;
|
||||||
|
utterance.volume = 1;
|
||||||
|
|
||||||
|
// ✅ 添加事件调试
|
||||||
|
utterance.onstart = () => console.log("开始播报:", text);
|
||||||
|
utterance.onend = () => console.log("播报结束");
|
||||||
|
utterance.onerror = (e) => console.error("播报失败:", e);
|
||||||
|
|
||||||
synth.speak(utterance);
|
synth.speak(utterance);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (synth.getVoices().length === 0) {
|
if (synth.getVoices().length === 0) {
|
||||||
// 有些浏览器语音列表异步加载
|
// ✅ 声音列表可能异步加载,监听一次
|
||||||
synth.onvoiceschanged = () => {
|
const handleVoicesChanged = () => {
|
||||||
|
console.log("voiceschanged 触发");
|
||||||
speakNow();
|
speakNow();
|
||||||
|
synth.removeEventListener("voiceschanged", handleVoicesChanged);
|
||||||
};
|
};
|
||||||
|
synth.addEventListener("voiceschanged", handleVoicesChanged);
|
||||||
} else {
|
} else {
|
||||||
speakNow();
|
speakNow();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const unlockTTS = () => {
|
||||||
|
try {
|
||||||
|
const utterance = new SpeechSynthesisUtterance("语音已解锁");
|
||||||
|
utterance.lang = "zh-CN";
|
||||||
|
window.speechSynthesis.speak(utterance);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("TTS 解锁失败:", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.removeEventListener("click", unlockTTS);
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener("click", unlockTTS);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isPC = window.innerWidth > 1600;
|
const isPC = window.innerWidth > 1600;
|
||||||
|
|
||||||
@@ -122,37 +335,135 @@ const Index = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// speak("欢迎使用"); // 语音播报
|
const innerAudioContext = Taro.createInnerAudioContext();
|
||||||
}, []);
|
innerAudioContext.src = baby;
|
||||||
|
innerAudioContext.loop = true;
|
||||||
|
|
||||||
// 在线测试地址
|
const handlePlay = () => {
|
||||||
// http://wstool.jackxiang.com/
|
innerAudioContext.play();
|
||||||
|
console.log("尝试播放音频");
|
||||||
|
document.removeEventListener("touchstart", handlePlay);
|
||||||
|
document.removeEventListener("click", handlePlay);
|
||||||
|
};
|
||||||
|
|
||||||
|
// document.addEventListener("touchstart", handlePlay, { once: true });
|
||||||
|
// document.addEventListener("click", handlePlay, { once: true });
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("touchstart", handlePlay);
|
||||||
|
document.removeEventListener("click", handlePlay);
|
||||||
|
innerAudioContext.destroy();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className="index">
|
<View className="index">
|
||||||
<View>扣 <span style={{color:'green'}}>11</span> 变小新</View>
|
<View
|
||||||
<View>扣 <span style={{color:'green'}}>22</span> 娜娜子</View>
|
className="giftKey"
|
||||||
|
style={{ color: "white", marginBottom: "20px", marginTop: "200px" }}
|
||||||
|
>
|
||||||
|
{/* <View>
|
||||||
|
👍 <span style={{ fontSize: "10px" }}>{`点赞`} </span> ➖{" "}
|
||||||
|
<span style={{ fontSize: "12px" }}>看烟花</span>
|
||||||
|
</View> */}
|
||||||
|
<View>
|
||||||
|
🩷 <span style={{ fontSize: "16px" }}>小星星</span> ➖{" "}
|
||||||
|
<span style={{ fontSize: "16px" }}>看烟花</span>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
<View className="messageArr">
|
<View className="userInfoArr">
|
||||||
{messageArr?.slice(0, 15)?.map((item, index) => (
|
{/* .slice(0, 5) */}
|
||||||
|
{userInfoArr?.map((item, index) => (
|
||||||
|
// <View
|
||||||
|
// key={index}
|
||||||
|
// className={index === 0 ? "message_item_first" : "message_item"}
|
||||||
|
// >
|
||||||
|
// <span style={{ color: "white", marginTop: "20px" }}>
|
||||||
|
// {/* ${item?.gender === "1" ? "👨" : "👩"} */}
|
||||||
|
// {`${item?.nick_name}`}
|
||||||
|
// </span>
|
||||||
|
// <View
|
||||||
|
// className={`avatar_box ${
|
||||||
|
// item.animate ? "animate__animated animate__tada" : ""
|
||||||
|
// }`}
|
||||||
|
// >
|
||||||
|
// <Image
|
||||||
|
// className="avatar_thumb"
|
||||||
|
// style="width:200px;height:200px"
|
||||||
|
// mode="scaleToFill"
|
||||||
|
// src={item?.avatar_thumb.url_list_list?.[0]}
|
||||||
|
// />
|
||||||
|
// </View>
|
||||||
|
// </View>
|
||||||
<View
|
<View
|
||||||
key={index}
|
key={index}
|
||||||
className={index === 0 ? "message_item_first" : "message_item"}
|
className={index === 0 ? "message_item_first" : "message_item"}
|
||||||
|
style={{ whiteSpace: "pre-wrap", textAlign: "center" }} // 允许文字换行,文字居中
|
||||||
>
|
>
|
||||||
{item}
|
<span
|
||||||
|
style={{ color: "white", marginTop: "20px", display: "block" }}
|
||||||
|
>
|
||||||
|
{`${item?.nick_name}`}
|
||||||
|
</span>
|
||||||
|
<View
|
||||||
|
className={`avatar_box ${
|
||||||
|
item.animate ? "animate__animated animate__tada" : ""
|
||||||
|
}`}
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "center",
|
||||||
|
marginTop: 10,
|
||||||
|
}} // 图片居中
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
className="avatar_thumb"
|
||||||
|
style={{ width: 200, height: 200 }}
|
||||||
|
mode="scaleToFill"
|
||||||
|
src={item?.avatar_thumb.url_list_list?.[0]}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
{/* <AtToast
|
||||||
|
className="AtToastDouyin"
|
||||||
|
isOpened={giftOpen}
|
||||||
|
text={giftUser?.nick_name ? `谢谢 ${giftUser?.nick_name} 送出礼物` : "11"}
|
||||||
|
icon={giftUser?.avatar_thumb?.url_list_list?.[0]}
|
||||||
|
></AtToast> */}
|
||||||
|
|
||||||
|
<AtCurtain
|
||||||
|
isOpened={giftOpen}
|
||||||
|
onClose={() => setGiftOpen(false)}
|
||||||
|
closeBtnPosition={"top"}
|
||||||
|
>
|
||||||
|
<div className="giftCurtain">
|
||||||
|
<span style={{ color: "yellow", fontSize: "20px" }}>
|
||||||
|
谢谢{" "}
|
||||||
|
<span style={{ color: "white", fontSize: "30px" }}>
|
||||||
|
{giftUser?.nick_name}
|
||||||
|
</span>{" "}
|
||||||
|
送🩷🩷🩷🩷🩷
|
||||||
|
</span>
|
||||||
|
<Image
|
||||||
|
style="width:300px;height:300px"
|
||||||
|
src={giftUser?.avatar_thumb?.url_list_list?.[0]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</AtCurtain>
|
||||||
|
|
||||||
{/* 添加doro的gif组合场景 */}
|
{/* 添加doro的gif组合场景 */}
|
||||||
|
|
||||||
<View className="gifImg">
|
{/* <View className="gifImg">
|
||||||
<Image
|
<Image
|
||||||
className="index_gif"
|
className="index_gif"
|
||||||
mode={"scaleToFill"}
|
mode={"scaleToFill"}
|
||||||
src={status === "1" ? gif11 :status === "2" ?gif22:doro11}
|
// src={status === "1" ? gif11 : status === "2" ? gif22 : doro11}
|
||||||
|
src={doro11}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View> */}
|
||||||
|
|
||||||
{/* <View className="index_backImg">
|
{/* <View className="index_backImg">
|
||||||
<Image className="index_backImg_bg" mode={"scaleToFill"} src={iphone} />
|
<Image className="index_backImg_bg" mode={"scaleToFill"} src={iphone} />
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
.index {
|
@media (max-width: 1000px) {
|
||||||
|
.index {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
// overflow: hidden; // 防止溢出
|
// overflow: hidden; // 防止溢出
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
background-color: black;
|
||||||
// justify-content: center;
|
// justify-content: center;
|
||||||
// background-image: url('../../images/iphone.jpg');
|
// background-image: url('../../images/iphone.jpg');
|
||||||
// background-size: cover; // 拉伸铺满容器
|
// background-size: cover; // 拉伸铺满容器
|
||||||
@@ -21,9 +23,9 @@
|
|||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message_item {}
|
.message_item {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.index_backImg {
|
.index_backImg {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -53,24 +55,45 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.gifImg {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// PC 浏览器下旋转
|
// PC 浏览器下旋转
|
||||||
@media (min-width: 1600px) {
|
@media (min-width: 1000px) {
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
#root,
|
||||||
|
#app {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: black;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
.index {
|
.index {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 750px; // 根据标准宽度调整
|
width: 750px; // 根据标准宽度调整
|
||||||
height: 1334px; // 保持竖屏比例
|
height: 1334px; // 保持竖屏比例
|
||||||
|
background-color: black;
|
||||||
|
|
||||||
// width: 100vw; // 使容器宽度始终填满视口
|
// width: 100vw; // 使容器宽度始终填满视口
|
||||||
// height: 100vh; // 使容器高度始终填满视口
|
// height: 100vh; // 使容器高度始终填满视口
|
||||||
|
|
||||||
|
// 旋转90度
|
||||||
transform: rotate(-90deg) translate(-100vh, 0);
|
transform: rotate(-90deg) translate(-100vh, 0);
|
||||||
transform-origin: top left;
|
transform-origin: top left;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
// justify-content: center;
|
// justify-content: center;
|
||||||
|
|
||||||
// background-image: url('../../images/iphone.jpg');
|
// background-image: url('../../images/iphone.jpg');
|
||||||
@@ -92,9 +115,9 @@
|
|||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message_item {}
|
.message_item {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.index_backImg {
|
.index_backImg {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -110,19 +133,34 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.index_video {
|
.AtToastDouyin {
|
||||||
position: absolute;
|
z-index: 999;
|
||||||
top: 0px;
|
|
||||||
width: 400px;
|
|
||||||
height: 200px;
|
|
||||||
|
|
||||||
.video_js {
|
|
||||||
width: 400px;
|
|
||||||
height: 200px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.giftCurtain {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: white;
|
||||||
|
font-size: 20px;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.at-curtain__btn-close {
|
||||||
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// .index_video {
|
||||||
|
// position: absolute;
|
||||||
|
// top: 0px;
|
||||||
|
// width: 400px;
|
||||||
|
// height: 200px;
|
||||||
|
|
||||||
|
// .video_js {
|
||||||
|
// width: 400px;
|
||||||
|
// height: 200px;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
108511
src/pages/index/userinfoArr.js
Normal file
108511
src/pages/index/userinfoArr.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -912,7 +912,7 @@
|
|||||||
"@babel/helper-create-regexp-features-plugin" "^7.25.9"
|
"@babel/helper-create-regexp-features-plugin" "^7.25.9"
|
||||||
"@babel/helper-plugin-utils" "^7.25.9"
|
"@babel/helper-plugin-utils" "^7.25.9"
|
||||||
|
|
||||||
"@babel/preset-env@^7.11.0", "@babel/preset-env@^7.14.5":
|
"@babel/preset-env@^7.11.0", "@babel/preset-env@^7.14.5", "@babel/preset-env@^7.26.9":
|
||||||
version "7.26.9"
|
version "7.26.9"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.26.9.tgz#2ec64e903d0efe743699f77a10bdf7955c2123c3"
|
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.26.9.tgz#2ec64e903d0efe743699f77a10bdf7955c2123c3"
|
||||||
integrity sha512-vX3qPGE8sEKEAZCWk05k3cpTAE3/nOYca++JA+Rd0z2NCNzabmYvEiSShKzm10zdquOIAVXsy2Ei/DTW34KlKQ==
|
integrity sha512-vX3qPGE8sEKEAZCWk05k3cpTAE3/nOYca++JA+Rd0z2NCNzabmYvEiSShKzm10zdquOIAVXsy2Ei/DTW34KlKQ==
|
||||||
@@ -11021,7 +11021,7 @@ regenerator-runtime@0.11:
|
|||||||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
|
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
|
||||||
integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==
|
integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==
|
||||||
|
|
||||||
regenerator-runtime@^0.14.0:
|
regenerator-runtime@^0.14.0, regenerator-runtime@^0.14.1:
|
||||||
version "0.14.1"
|
version "0.14.1"
|
||||||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f"
|
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f"
|
||||||
integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==
|
integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==
|
||||||
|
|||||||
Reference in New Issue
Block a user