MoeFurina c2871322d0
refactor: QR login and voice upload pages with improved UI and error handling
- Enhanced styling for better user experience on qrlogin-nocookie.html and qrlogin.html
- Added loading indicators and improved status messages during QR code login process
- Updated error handling for login status retrieval
- Refactored unblock_test.html for better layout and user interaction
- Improved voice upload page with a more intuitive design and better feedback for file uploads
- Added loading state management for voice list retrieval
- Enhanced accessibility and usability across all modified pages
2026-02-06 19:56:14 +08:00

327 lines
8.3 KiB
HTML

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>播客上传声音</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
min-height: 100vh;
background: #f5f5f5;
padding: 20px;
}
.container {
max-width: 900px;
margin: 0 auto;
background: white;
border-radius: 12px;
padding: 32px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
h1 {
font-size: 24px;
font-weight: 600;
color: #333;
margin-bottom: 24px;
}
.login-link {
display: block;
margin-bottom: 24px;
color: #666;
font-size: 14px;
text-decoration: none;
}
.login-link:hover {
color: #333;
text-decoration: underline;
}
.content {
display: flex;
gap: 24px;
flex-wrap: wrap;
}
.voice-list {
flex: 1;
min-width: 300px;
}
.voice-item {
padding: 12px 16px;
border: 1px solid #eee;
border-radius: 6px;
margin-bottom: 8px;
cursor: pointer;
transition: all 0.2s ease;
}
.voice-item:hover {
border-color: #333;
background: #f9f9f9;
}
.voice-item.active {
border-color: #333;
background: #f0f0f0;
}
.voice-header {
display: flex;
align-items: center;
gap: 12px;
}
.voice-cover {
width: 50px;
height: 50px;
border-radius: 4px;
object-fit: cover;
}
.voice-name {
font-size: 14px;
font-weight: 500;
color: #333;
}
.voice-tracks {
margin-top: 8px;
padding-left: 62px;
}
.voice-track {
font-size: 13px;
color: #666;
padding: 4px 0;
}
.upload-section {
flex: 1;
min-width: 300px;
}
.form-group {
margin-bottom: 16px;
}
label {
display: block;
font-size: 14px;
font-weight: 500;
color: #555;
margin-bottom: 8px;
}
input[type="text"], input[type="file"] {
width: 100%;
padding: 10px 14px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 14px;
outline: none;
}
input[type="text"]:focus {
border-color: #333;
}
.btn {
width: 100%;
padding: 12px;
background: #333;
color: white;
font-size: 15px;
font-weight: 500;
border: none;
border-radius: 6px;
cursor: pointer;
transition: background 0.2s ease;
}
.btn:hover {
background: #555;
}
.empty-state {
text-align: center;
padding: 40px 20px;
color: #999;
font-size: 14px;
}
.loading {
text-align: center;
padding: 20px;
color: #666;
}
</style>
</head>
<body>
<div class="container">
<h1>播客上传声音</h1>
<a href="/qrlogin-nocookie.html" class="login-link">还没登录?点击登录</a>
<div class="content">
<div class="voice-list">
<h3 style="font-size: 16px; font-weight: 600; color: #333; margin-bottom: 16px;">选择播客列表</h3>
<div v-if="loading" class="loading">加载中...</div>
<div v-else-if="voicelist.length > 0">
<div
v-for="(item, index) in voicelist"
:key="index"
@click="currentVoiceIndex = index"
:class="{ active: currentVoiceIndex === index }"
class="voice-item"
>
<div class="voice-header">
<img :src="item.coverUrl" class="voice-cover" alt="cover" />
<span class="voice-name">{{ item.voiceListName }}</span>
</div>
<div class="voice-tracks" v-if="item.voiceListData">
<div
v-for="(item2, index2) in item.voiceListData"
:key="index2"
class="voice-track"
>
{{ item2.voiceName }}
</div>
</div>
</div>
</div>
<div v-else class="empty-state">暂无播客列表</div>
</div>
<div class="upload-section">
<h3 style="font-size: 16px; font-weight: 600; color: #333; margin-bottom: 16px;">上传声音</h3>
<div class="form-group">
<label for="songName">声音名称</label>
<input id="songName" v-model="songName" placeholder="请输入声音名称" />
</div>
<div class="form-group">
<label for="description">介绍</label>
<input id="description" v-model="description" placeholder="请输入介绍" />
</div>
<div class="form-group">
<label>选择文件</label>
<input type="file" name="songFile" accept="audio/*" />
</div>
<button class="btn" @click="submit">上传</button>
</div>
</div>
</div>
<script src="https://fastly.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/vue@3"></script>
<script>
Vue.createApp({
data() {
return {
songName: '',
description: '',
voicelist: [],
cookieToken: '',
currentVoiceIndex: 0,
loading: false,
}
},
created() {
this.getData()
},
computed: {
currentVoice() {
return this.voicelist[this.currentVoiceIndex]
},
},
methods: {
submit() {
console.info('submit')
const file = document.querySelector('input[type=file]').files[0]
if (!file) {
alert('请选择文件')
return
}
this.upload(file)
},
async getData() {
this.loading = true
try {
const res = await axios({
url: `/voicelist/search?cookie=${localStorage.getItem('cookie')}`,
})
console.info(res.data.data)
this.voicelist = res.data.data.list || []
this.voicelist.forEach(async (i) => {
try {
const res2 = await axios({
url: `/voicelist/list?voiceListId=${i.voiceListId}&limit=5`,
})
i.voiceListData = res2.data.data.list || []
console.info(res2)
} catch (err) {
console.error('获取播客详情失败:', err)
}
})
} catch (err) {
console.error('获取播客列表失败:', err)
} finally {
this.loading = false
}
},
upload(file) {
if (!this.currentVoice) {
alert('请先选择播客列表')
return
}
var formData = new FormData()
formData.append('songFile', file)
axios({
method: 'post',
url: `/voice/upload?time=${Date.now()}&cookie=${localStorage.getItem(
'cookie',
)}&songName=${this.songName}&voiceListId=${
this.currentVoice.voiceListId
}&categoryId=${this.currentVoice.categoryId}&coverImgId=${
this.currentVoice.coverImgId
}&secondCategoryId=${
this.currentVoice.secondCategoryId
}&description=${this.description}&privacy=1`,
headers: {
'Content-Type': 'multipart/form-data',
},
data: formData,
})
.then((res) => {
alert(`${file.name} 上传成功`)
})
.catch((err) => {
console.error('上传失败:', err)
alert('上传失败,请重试')
})
},
},
}).mount('body')
</script>
</body>
</html>