Skip to content

Commit 775268b

Browse files
author
Taois
committed
fix: 点播头部工具条时间动画错误
刷新立即生效
1 parent 0e7adf7 commit 775268b

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

dashboard/src/views/Video.vue

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,18 @@ const pageStateStore = usePageStateStore();
7979
const route = useRoute();
8080
const router = useRouter();
8181
82-
const currentDateTime = ref("");
82+
// 时间格式化函数
83+
const formatDate = (date) => {
84+
const year = date.getFullYear();
85+
const month = String(date.getMonth() + 1).padStart(2, '0');
86+
const day = String(date.getDate()).padStart(2, '0');
87+
const hours = String(date.getHours()).padStart(2, '0');
88+
const minutes = String(date.getMinutes()).padStart(2, '0');
89+
const seconds = String(date.getSeconds()).padStart(2, '0');
90+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
91+
};
92+
93+
const currentDateTime = ref(formatDate(new Date())); // 初始化时就设置当前时间
8394
const currentActiveKey = ref(""); // 当前选中的分类key
8495
const videoListRef = ref(null); // VideoList组件引用
8596
const form = reactive({
@@ -161,20 +172,6 @@ const checkNowSite = () => {
161172
}
162173
};
163174
164-
const formatDate = (date) => {
165-
const options = {
166-
weekday: "long", // 星期几
167-
year: "numeric",
168-
month: "numeric",
169-
day: "numeric",
170-
hour: "2-digit",
171-
minute: "2-digit",
172-
second: "2-digit",
173-
hour12: true, // 12小时制
174-
};
175-
return date.toLocaleString("zh-CN", options);
176-
};
177-
178175
// 启动定时器
179176
const startClock = () => {
180177
timer.value = setInterval(() => {

0 commit comments

Comments
 (0)