Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -211,73 +211,72 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
211 |
msg = gr.Textbox(label="想对豌豆说啥?", placeholder="比如:你在干嘛?", lines=2)
|
212 |
btn = gr.Button("投喂")
|
213 |
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
.
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
<
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
<canvas id="fireworks" style="position:fixed;top:0;left:0;width:100vw;height:100vh;pointer-events:none;z-index:0;"></canvas>
|
281 |
|
282 |
<script>
|
283 |
const tracks = ["{music1}", "{music2}"];
|
@@ -320,7 +319,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
320 |
setTimeout(() => {{
|
321 |
ctx.beginPath();
|
322 |
ctx.arc(x, y, Math.random() * 3 + 2, 0, Math.PI * 2);
|
323 |
-
ctx.fillStyle =
|
324 |
ctx.fill();
|
325 |
}}, i * 20);
|
326 |
}}
|
@@ -328,7 +327,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
328 |
|
329 |
setInterval(firework, 1800);
|
330 |
</script>
|
331 |
-
|
|
|
332 |
# 替换掉HTML模板中的变量部分
|
333 |
html_content = html_content.replace("{background_css}", background_css)
|
334 |
html_content = html_content.replace("{avatar_url}", avatar_url)
|
|
|
211 |
msg = gr.Textbox(label="想对豌豆说啥?", placeholder="比如:你在干嘛?", lines=2)
|
212 |
btn = gr.Button("投喂")
|
213 |
|
214 |
+
html_content = f"""
|
215 |
+
<style>
|
216 |
+
body {{
|
217 |
+
margin: 0;
|
218 |
+
animation: backgroundCycle 60s infinite;
|
219 |
+
background-size: cover;
|
220 |
+
background-position: center;
|
221 |
+
transition: background-image 1s ease-in-out;
|
222 |
+
}}
|
223 |
+
@keyframes backgroundCycle {{
|
224 |
+
{background_css}
|
225 |
+
}}
|
226 |
+
.gr-chatbot {{
|
227 |
+
background: rgba(255, 255, 255, 0.5);
|
228 |
+
border-radius: 16px;
|
229 |
+
padding: 10px;
|
230 |
+
}}
|
231 |
+
.gr-textbox textarea {{
|
232 |
+
font-family: monospace;
|
233 |
+
font-size: 1.1em;
|
234 |
+
animation: typewriter 1s steps(40, end);
|
235 |
+
}}
|
236 |
+
@keyframes typewriter {{
|
237 |
+
from {{ width: 0 }}
|
238 |
+
to {{ width: 100% }}
|
239 |
+
}}
|
240 |
+
#sophia-avatar {{
|
241 |
+
position: fixed;
|
242 |
+
top: 40px;
|
243 |
+
left: 30px;
|
244 |
+
width: 80px;
|
245 |
+
height: 80px;
|
246 |
+
border-radius: 50%;
|
247 |
+
z-index: 9999;
|
248 |
+
cursor: grab;
|
249 |
+
animation: spinBounce 4s infinite;
|
250 |
+
}}
|
251 |
+
@keyframes spinBounce {{
|
252 |
+
0% {{ transform: rotate(0deg) translateY(0px); }}
|
253 |
+
50% {{ transform: rotate(180deg) translateY(-10px); }}
|
254 |
+
100% {{ transform: rotate(360deg) translateY(0px); }}
|
255 |
+
}}
|
256 |
+
#birthday-cake {{
|
257 |
+
position: fixed;
|
258 |
+
bottom: 20px;
|
259 |
+
right: 20px;
|
260 |
+
width: 80px;
|
261 |
+
animation: bounce 1.5s infinite;
|
262 |
+
z-index: 9999;
|
263 |
+
}}
|
264 |
+
@keyframes bounce {{
|
265 |
+
0% {{ transform: translateY(0); }}
|
266 |
+
50% {{ transform: translateY(-15px); }}
|
267 |
+
100% {{ transform: translateY(0); }}
|
268 |
+
}}
|
269 |
+
</style>
|
270 |
+
|
271 |
+
<!-- 动态头像 + 生日蛋糕 -->
|
272 |
+
<img id="sophia-avatar" src="{avatar_url}" />
|
273 |
+
<img id="birthday-cake" src="{cake_url}" />
|
274 |
+
<audio id="bg-music" autoplay loop>
|
275 |
+
<source src="{music1}" type="audio/mpeg" />
|
276 |
+
<source src="{music2}" type="audio/mpeg" />
|
277 |
+
</audio>
|
278 |
+
<audio id="bark" src="{bark_sound}"></audio>
|
279 |
+
<canvas id="fireworks" style="position:fixed;top:0;left:0;width:100vw;height:100vh;pointer-events:none;z-index:0;"></canvas>
|
|
|
280 |
|
281 |
<script>
|
282 |
const tracks = ["{music1}", "{music2}"];
|
|
|
319 |
setTimeout(() => {{
|
320 |
ctx.beginPath();
|
321 |
ctx.arc(x, y, Math.random() * 3 + 2, 0, Math.PI * 2);
|
322 |
+
ctx.fillStyle = 'hsl(' + (Math.random() * 360) + ', 100%, 60%)';
|
323 |
ctx.fill();
|
324 |
}}, i * 20);
|
325 |
}}
|
|
|
327 |
|
328 |
setInterval(firework, 1800);
|
329 |
</script>
|
330 |
+
"""
|
331 |
+
|
332 |
# 替换掉HTML模板中的变量部分
|
333 |
html_content = html_content.replace("{background_css}", background_css)
|
334 |
html_content = html_content.replace("{avatar_url}", avatar_url)
|