🎨 增加 Go 后端

This commit is contained in:
江西小徐
2024-04-07 11:08:05 +08:00
parent 04c82ab25d
commit 61275be2bf
165 changed files with 7043 additions and 3599 deletions
+28
View File
@@ -0,0 +1,28 @@
export const formatTimeAgo = (dateString: string) => {
const now = new Date();
const date = new Date(dateString);
const seconds = Math.floor((now.getTime() - date.getTime()) / 1000);
let interval = seconds / 31536000;
if (interval > 1) {
return Math.floor(interval) + " 年前";
}
interval = seconds / 2592000;
if (interval > 1) {
return Math.floor(interval) + " 月前";
}
interval = seconds / 86400;
if (interval > 1) {
return Math.floor(interval) + " 天前";
}
interval = seconds / 3600;
if (interval > 1) {
return Math.floor(interval) + " 小时前";
}
interval = seconds / 60;
if (interval > 1) {
return Math.floor(interval) + " 分钟前";
}
return Math.floor(seconds) + " 秒前";
};
+12
View File
@@ -0,0 +1,12 @@
// 自动导出
export const useHttp = {
post<T = any>(url: string, config?: any): Promise<T> {
const runtimeConfig = useRuntimeConfig()
const baseUrl = runtimeConfig.public.baseUrl
return $fetch(url, {
baseURL: baseUrl,
method: 'POST',
body: config,
})
},
}