mwy2.0
This commit is contained in:
@@ -1,5 +1,2 @@
|
||||
# 使用 Vite 代理时保持默认 /api 即可
|
||||
VITE_API_BASE_URL=/api
|
||||
|
||||
# 网易云外链播放器 src(整段 iframe 亦可,会自动提取 src)
|
||||
# VITE_NETEASE_PLAYER_SRC=https://music.163.com/outchain/player?type=2&id=2054353432&auto=1&height=66
|
||||
|
||||
@@ -8,7 +8,7 @@ server {
|
||||
gzip_types text/plain text/css application/javascript application/json image/svg+xml;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://backend:8000;
|
||||
proxy_pass http://backend:8963;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
@@ -17,7 +17,7 @@ server {
|
||||
}
|
||||
|
||||
location /media/ {
|
||||
proxy_pass http://backend:8000;
|
||||
proxy_pass http://backend:8963;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
||||
@@ -54,7 +54,6 @@ export interface StatusPayload {
|
||||
unlocked: boolean
|
||||
unlock_at: string | null
|
||||
together_since: string
|
||||
bgm_enabled: boolean
|
||||
site_title: string
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ async function submit() {
|
||||
<div class="flex items-center gap-2 text-rose-deep">
|
||||
<Heart class="h-5 w-5" fill="currentColor" aria-hidden="true" />
|
||||
<h2 id="guestbook-title" class="font-brush text-3xl text-lokta-deep sm:text-4xl">
|
||||
给她的一句话
|
||||
给他的一句话
|
||||
</h2>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-ink-muted">
|
||||
@@ -69,7 +69,7 @@ async function submit() {
|
||||
rows="5"
|
||||
maxlength="2000"
|
||||
class="mt-1 w-full resize-y rounded-xl border border-paper-shadow bg-paper/80 px-4 py-3 text-ink shadow-inner outline-none transition focus:border-rose-soft/60 focus:ring-2 focus:ring-rose-soft/25"
|
||||
placeholder="写下你想说的话…"
|
||||
placeholder="写下你想说的话…,例如:谢谢你陪伴我度过了这么多美好的时光!"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="error" class="text-sm text-rose-deep">
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
/** 后端已规范为 https://music.163.com/... 的播放器地址 */
|
||||
src: string
|
||||
}>()
|
||||
|
||||
const safeSrc = computed(() => {
|
||||
let u = (props.src || '').trim()
|
||||
if (!u) return ''
|
||||
if (u.startsWith('//')) u = `https:${u}`
|
||||
try {
|
||||
const url = new URL(u)
|
||||
if (url.protocol !== 'https:') return ''
|
||||
const h = url.hostname.toLowerCase()
|
||||
if (h !== 'music.163.com') return ''
|
||||
return url.href.split('#')[0]
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="safeSrc"
|
||||
class="overflow-hidden rounded-xl border border-lokta-deep/15 bg-white/80 shadow-sm"
|
||||
>
|
||||
<iframe
|
||||
:src="safeSrc"
|
||||
title="网易云音乐"
|
||||
frameborder="no"
|
||||
border="0"
|
||||
marginwidth="0"
|
||||
marginheight="0"
|
||||
width="330"
|
||||
height="86"
|
||||
class="mx-auto block border-0"
|
||||
allow="autoplay; encrypted-media; fullscreen"
|
||||
referrerpolicy="strict-origin-when-cross-origin"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,17 +0,0 @@
|
||||
/**
|
||||
* 网易云外链播放器:在前端配置,不经过 Django。
|
||||
*
|
||||
* 在 `frontend/.env` / `.env.development` 中设置:
|
||||
* VITE_NETEASE_PLAYER_SRC=https://music.163.com/outchain/player?type=2&id=…&auto=1&height=66
|
||||
* 也可粘贴整段 `<iframe … src="…">`,会自动取出 src。
|
||||
*/
|
||||
function extractIframeSrc(raw: string): string {
|
||||
const t = raw.trim()
|
||||
if (!t) return ''
|
||||
const m = /\bsrc\s*=\s*["']([^"']+)["']/i.exec(t)
|
||||
return (m ? m[1] : t).trim()
|
||||
}
|
||||
|
||||
const fromEnv = (import.meta.env.VITE_NETEASE_PLAYER_SRC as string | undefined)?.trim() ?? ''
|
||||
|
||||
export const NETEASE_PLAYER_SRC = extractIframeSrc(fromEnv)
|
||||
@@ -2,11 +2,9 @@
|
||||
import { RefreshCw } from 'lucide-vue-next'
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { fetchMemories, fetchStatus, type Memory, type StatusPayload } from '../api/client'
|
||||
import { NETEASE_PLAYER_SRC } from '../config/neteasePlayer'
|
||||
import MessageForm from '../components/MessageForm.vue'
|
||||
import NepalChapterBand from '../components/NepalChapterBand.vue'
|
||||
import NepalPageContainer from '../components/NepalPageContainer.vue'
|
||||
import NeteaseEmbed from '../components/NeteaseEmbed.vue'
|
||||
import TogetherCounter from '../components/TogetherCounter.vue'
|
||||
|
||||
const status = ref<StatusPayload | null>(null)
|
||||
@@ -20,19 +18,6 @@ const serverOffsetMs = ref(0)
|
||||
let statusPoll: ReturnType<typeof setInterval> | undefined
|
||||
|
||||
const siteTitle = computed(() => status.value?.site_title ?? 'Nepal Journey: Our Story')
|
||||
const bgmEnabled = computed(() => status.value?.bgm_enabled ?? true)
|
||||
const neteaseSrc = NETEASE_PLAYER_SRC
|
||||
const showNetease = computed(() => {
|
||||
if (!bgmEnabled.value || !neteaseSrc) return false
|
||||
try {
|
||||
let u = neteaseSrc.trim()
|
||||
if (u.startsWith('//')) u = `https:${u}`
|
||||
const url = new URL(u)
|
||||
return url.protocol === 'https:' && url.hostname.toLowerCase() === 'music.163.com'
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
const showAppChrome = computed(() => !busy.value && status.value !== null)
|
||||
|
||||
@@ -99,7 +84,7 @@ const counterMilestones = computed(() =>
|
||||
v-if="showAppChrome && status"
|
||||
class="sticky top-0 z-40 border-b border-lokta-deep/10 bg-gradient-to-r from-lokta-cream/90 via-paper/90 to-lokta-teal/15 backdrop-blur-md"
|
||||
>
|
||||
<div class="mx-auto max-w-3xl space-y-3 px-4 py-3 sm:px-6">
|
||||
<div class="mx-auto max-w-3xl px-4 py-3 sm:px-6">
|
||||
<div class="min-w-0">
|
||||
<p class="truncate font-brush text-2xl text-lokta-deep sm:text-3xl">
|
||||
{{ siteTitle }}
|
||||
@@ -109,15 +94,7 @@ const counterMilestones = computed(() =>
|
||||
:server-offset-ms="serverOffsetMs"
|
||||
:milestones="counterMilestones"
|
||||
/>
|
||||
|
||||
</div>
|
||||
<NeteaseEmbed v-if="showNetease" :src="neteaseSrc" />
|
||||
<p
|
||||
v-else-if="bgmEnabled && !neteaseSrc"
|
||||
class="rounded-lg border border-dashed border-lokta-deep/20 bg-white/50 px-3 py-2 text-xs text-ink-muted"
|
||||
>
|
||||
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=2054353432&auto=1&height=66"></iframe>
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ export default defineConfig({
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://127.0.0.1:8000',
|
||||
target: 'http://127.0.0.1:8963',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/media': {
|
||||
target: 'http://127.0.0.1:8000',
|
||||
target: 'http://127.0.0.1:8963',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user