feat: update

This commit is contained in:
Rogee
2025-05-08 11:46:57 +08:00
parent 1199118fb4
commit f92429a9c6
6 changed files with 47 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
<script setup>
import { mediaService } from '@/api/mediaService';
import { postService } from '@/api/postService';
import { formatDate } from "@/utils/date";
import { formatDate, formatDuration } from "@/utils/date";
import { formatFileSize } from "@/utils/filesize";
import { getFileIcon, getFileTypeByMimeCN } from "@/utils/filetype";
import { useToast } from 'primevue/usetoast';
@@ -373,10 +373,16 @@ const loadHeadImagePreviews = async () => {
</div>
<div class="flex-1 overflow-hidden">
<div class="text-sm font-medium text-gray-900 truncate">{{ media.name }}
<div class="text-sm font-medium text-gray-900 truncate">
{{ media.name }}
</div>
<Badge :value="getFileTypeByMimeCN(media.mime_type)" />
<div class="flex gap-2">
<Badge :value="getFileTypeByMimeCN(media.mime_type)" />
<Badge v-if="media.metas?.short" severity="warn" value="试听" />
<Badge v-if="media.metas?.duration" severity="secondary"
:value="'时长:' + formatDuration(media.metas?.duration)" />
</div>
</div>
<Button icon="pi pi-times" class="p-button-rounded p-button-text p-button-sm"
@click="removeMedia(media)" aria-label="移除" />

View File

@@ -1,7 +1,7 @@
<script setup>
import { mediaService } from '@/api/mediaService';
import { postService } from '@/api/postService';
import { formatDate } from "@/utils/date";
import { formatDate, formatDuration } from "@/utils/date";
import { formatFileSize } from "@/utils/filesize";
import { getFileIcon, getFileTypeByMimeCN } from "@/utils/filetype";
import { useToast } from 'primevue/usetoast';
@@ -425,7 +425,14 @@ onMounted(() => {
<div class="text-sm font-medium text-gray-900 truncate">{{ media.name }}
</div>
<Badge :value="getFileTypeByMimeCN(media.mime_type)" />
<!-- <Badge :value="getFileTypeByMimeCN(media.mime_type)" /> -->
<div class="flex gap-2">
<Badge :value="getFileTypeByMimeCN(media.mime_type)" />
<Badge v-if="media.metas?.short" severity="warn" value="试听" />
<Badge v-if="media.metas?.duration" severity="secondary"
:value="'时长:' + formatDuration(media.metas?.duration)" />
</div>
</div>
<Button icon="pi pi-times" class="p-button-rounded p-button-text p-button-sm"
@click="removeMedia(media)" aria-label="移除" />

View File

@@ -1,4 +1,4 @@
import { createRouter, createWebHashHistory } from 'vue-router';
import { createRouter, createWebHistory } from 'vue-router';
import { useAuthStore } from './stores/auth';
// Define your routes here
@@ -62,8 +62,8 @@ const routes = [
// Create the router instance
export const router = createRouter({
// history: createWebHistory(),
history: createWebHashHistory(),
history: createWebHistory("/admin/"), // Use createWebHashHistory() if you want hash-based routing
// history: createWebHashHistory(),
routes
});

View File

@@ -14,3 +14,24 @@ dayjs.extend(timezone);
export function formatDate(date) {
return dayjs.tz(date, 'Asia/Shanghai').format('YYYY-MM-DD HH:mm:ss');
}
/**
* Format seconds to readable duration string
* @param {number} seconds - Number of seconds
* @returns {string} Formatted duration string (e.g., "2h 30m 15s")
*/
export function formatDuration(seconds) {
if (!seconds || seconds < 0) return '0 秒';
const hours = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const remainingSeconds = Math.floor(seconds % 60);
const parts = [];
if (hours > 0) parts.push(`${hours}`);
if (minutes > 0) parts.push(`${minutes}`);
if (remainingSeconds > 0 || parts.length === 0) parts.push(`${remainingSeconds}`);
return parts.join(' ');
}

View File

@@ -13,7 +13,7 @@ export default defineConfig({
}
}
},
base: "./",
base: "/admin",
minify: true,
sourceMap: true,
plugins: [
@@ -26,6 +26,8 @@ export default defineConfig({
}
},
server: {
host: '0.0.0.0',
allowedHosts: ['mp.jdwan.com'],
port: 3000,
open: true,
proxy: {