@@ -79,7 +79,18 @@ const pageStateStore = usePageStateStore();
7979const route = useRoute ();
8080const 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 ())); // 初始化时就设置当前时间
8394const currentActiveKey = ref (" " ); // 当前选中的分类key
8495const videoListRef = ref (null ); // VideoList组件引用
8596const 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// 启动定时器
179176const startClock = () => {
180177 timer .value = setInterval (() => {
0 commit comments