优化布局
This commit is contained in:
@@ -139,8 +139,12 @@
|
||||
<div id="now-playing" class="now-playing hidden">
|
||||
<h3>Now Playing</h3>
|
||||
<p id="current-video-title">video.mp4</p>
|
||||
<button id="transcode-btn" class="play-btn hidden">Start Transcode</button>
|
||||
<button id="stop-transcode-btn" class="play-btn stop-btn hidden">Stop Transcode</button>
|
||||
<div style="display: flex; gap: 0.5rem; margin-top: 1rem; align-items: center; flex-wrap: wrap;">
|
||||
<button id="transcode-btn" class="play-btn hidden">Start Transcode</button>
|
||||
<button id="stop-transcode-btn" class="play-btn stop-btn hidden">Stop Transcode</button>
|
||||
<button id="clear-playing-download-cache-btn" class="action-btn danger hidden">清空下载缓存</button>
|
||||
<button id="clear-playing-transcode-cache-btn" class="action-btn danger hidden">清空转码缓存</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
24
server.js
24
server.js
@@ -566,9 +566,11 @@ app.get('/api/videos', async (req, res) => {
|
||||
const safeBucket = bucket.replace(/[^a-z0-9]/gi, '_');
|
||||
const safeKeySegments = key.split('/').map(segment => segment.replace(/[^a-z0-9]/gi, '_'));
|
||||
const hlsDir = path.join(CACHE_DIR, `hls-${safeBucket}-${safeKeySegments.join('-')}`);
|
||||
const tmpInputPath = path.join(CACHE_DIR, `s3-input-${safeBucket}-${safeKeySegments.join('-')}.tmp`);
|
||||
return {
|
||||
key: key,
|
||||
hasTranscodeCache: fs.existsSync(hlsDir)
|
||||
hasTranscodeCache: fs.existsSync(hlsDir),
|
||||
hasDownloadCache: fs.existsSync(tmpInputPath)
|
||||
};
|
||||
});
|
||||
|
||||
@@ -639,6 +641,26 @@ app.post('/api/clear-video-transcode-cache', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/clear-video-download-cache', async (req, res) => {
|
||||
try {
|
||||
const { bucket, key } = req.body;
|
||||
if (!bucket || !key) {
|
||||
return res.status(400).json({ error: 'Bucket and key are required' });
|
||||
}
|
||||
const safeBucket = bucket.replace(/[^a-z0-9]/gi, '_');
|
||||
const safeKeySegments = key.split('/').map(segment => segment.replace(/[^a-z0-9]/gi, '_'));
|
||||
const tmpInputPath = path.join(CACHE_DIR, `s3-input-${safeBucket}-${safeKeySegments.join('-')}.tmp`);
|
||||
|
||||
if (fs.existsSync(tmpInputPath)) {
|
||||
fs.rmSync(tmpInputPath, { force: true });
|
||||
}
|
||||
res.json({ message: 'Download cache cleared for video' });
|
||||
} catch (error) {
|
||||
console.error('Error clearing video download cache:', error);
|
||||
res.status(500).json({ error: 'Failed to clear download cache', detail: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/stop-transcode', (req, res) => {
|
||||
try {
|
||||
const { key } = req.body;
|
||||
|
||||
Reference in New Issue
Block a user