diff --git a/src/api/myPage.js b/src/api/myPage.js index aea0ab7..924f8ab 100644 --- a/src/api/myPage.js +++ b/src/api/myPage.js @@ -23,4 +23,3 @@ export function doGetVideoDetialById(id) { method: 'get', }) } - diff --git a/src/utils/deepCopy.js b/src/utils/deepCopy.js deleted file mode 100644 index 4cc9287..0000000 --- a/src/utils/deepCopy.js +++ /dev/null @@ -1,8 +0,0 @@ -/** -* @description:使用JSON进行深度拷贝 -*/ -const deepCopy = data => { - const copyData = JSON.stringify(data) - return JSON.parse(copyData) -} -export default deepCopy \ No newline at end of file diff --git a/src/utils/timestampToTime.js b/src/utils/index.js similarity index 60% rename from src/utils/timestampToTime.js rename to src/utils/index.js index f26ae46..82b4dd2 100644 --- a/src/utils/timestampToTime.js +++ b/src/utils/index.js @@ -1,3 +1,64 @@ +/** +* @description:使用JSON进行深度拷贝 +*/ +export function deepCopy(data) { + const copyData = JSON.stringify(data) + return JSON.parse(copyData) +} + +/** +* @description 将bytes转化 +* @param {number} bytes +* @return string +*/ +export function bytesToSize(bytes) { + if (bytes === 0) return '0 B'; + var k = 1000, // or 1024 + sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], + i = Math.floor(Math.log(bytes) / Math.log(k)); + + return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i]; +} + +/** +* @description 秒转时分秒 +* @param {number} seconds +* @return string +*/ +export function formatSeconds(value) { + var theTime = parseInt(value);// 秒 + var theTime1 = 0;// 分 + var theTime2 = 0;// 小时 + if (theTime > 60) { + theTime1 = parseInt(theTime / 60); + theTime = parseInt(theTime % 60); + if (theTime1 > 60) { + theTime2 = parseInt(theTime1 / 60); + theTime1 = parseInt(theTime1 % 60); + } + } + var result = "" + parseInt(theTime) + "秒"; + if (theTime1 > 0) { + result = "" + parseInt(theTime1) + "分" + result; + } + if (theTime2 > 0) { + result = "" + parseInt(theTime2) + "小时" + result; + } + return result; +} + +/** +* @description:滚动到对应id的位置 +* @param {type} id +*/ +export function scrollToID(id) { + document.querySelector("#" + id).scrollIntoView({ + behavior: "smooth", + block: "start", + inline: "nearest", + }); +} + /** * @description 根据时间戳获取时间 * @param {*} timestamp 必传,number类型,时间戳数据(10位及以下,10位至13位) @@ -5,7 +66,7 @@ * @returns 根据要求的时间格式 * @version V 1.0, Created by YWQ, 2022.10.20 */ -const timestampToTime = (timestamp, format) => { +export function timestampToTime(timestamp, format) { //时间戳为10位需*1000,时间戳为13位不需乘1000 const length = timestamp.length if (length <= 10) { @@ -44,4 +105,4 @@ const timestampToTime = (timestamp, format) => { return Y + "-" + M + "-" + D } } -export default timestampToTime \ No newline at end of file + diff --git a/src/utils/request.js b/src/utils/request.js index 6f8489d..62398c8 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -38,10 +38,12 @@ request.interceptors.response.use( router.push("/login"); Toast.fail("登录过期,请重新登录!"); return + } else if (code == 1053) { router.push("/login"); Toast.fail("请您先登录!"); return + } else if (code == 500) { Toast.fail("系统异常,请稍后再试"); return Promise.reject(response.data) diff --git a/src/utils/scrollToID.js b/src/utils/scrollToID.js deleted file mode 100644 index 446cb57..0000000 --- a/src/utils/scrollToID.js +++ /dev/null @@ -1,12 +0,0 @@ -/** -* @description:滚动到对应id的位置 -* @param {type} id -*/ -const scrollToID = id => { - document.querySelector("#" + id).scrollIntoView({ - behavior: "smooth", - block: "start", - inline: "nearest", - }); -} -export default scrollToID \ No newline at end of file diff --git a/src/views/login/login.vue b/src/views/login/login.vue index aa656ba..46e3d5d 100644 --- a/src/views/login/login.vue +++ b/src/views/login/login.vue @@ -104,7 +104,7 @@ import Vue from "vue"; import { mapState, mapActions } from "vuex"; import { Toast } from "vant"; -import scrollToID from "../../utils/scrollToID"; +import { scrollToID } from "../../utils"; import { getCodeByPhone, doLoginByPhone, diff --git a/src/views/model/chooseModel.vue b/src/views/model/chooseModel.vue index b2637d1..ce81cbc 100644 --- a/src/views/model/chooseModel.vue +++ b/src/views/model/chooseModel.vue @@ -49,8 +49,7 @@ import Vue from "vue"; import { mapState, mapActions } from "vuex"; import HeadTop from "./../../components/common/head.vue"; import { Toast } from "vant"; -import baseUrl from "../../api/baseUrl"; -import scrollToID from "../../utils/scrollToID"; +import { scrollToID } from "../../utils"; import { getModeList, getModeDetailById, diff --git a/src/views/model/downloadVideo.vue b/src/views/model/downloadVideo.vue index 092963a..8bd9789 100644 --- a/src/views/model/downloadVideo.vue +++ b/src/views/model/downloadVideo.vue @@ -28,8 +28,7 @@ import Vue from "vue"; import { Toast } from "vant"; import { mapState, mapActions } from "vuex"; import HeadTop from "./../../components/common/head.vue"; -import scrollToID from "../../utils/scrollToID"; -import deepCopy from "../../utils/deepCopy"; +import { scrollToID, deepCopy } from "../../utils"; import { doGetVideoDetialById } from "../../api/downloadVideo"; diff --git a/src/views/model/generateVideo.vue b/src/views/model/generateVideo.vue index b5550ff..ffa8df1 100644 --- a/src/views/model/generateVideo.vue +++ b/src/views/model/generateVideo.vue @@ -87,8 +87,7 @@ import Vue from "vue"; import { Toast } from "vant"; import { mapState, mapActions } from "vuex"; import HeadTop from "./../../components/common/head.vue"; -import scrollToID from "../../utils/scrollToID"; -import deepCopy from "../../utils/deepCopy"; +import { scrollToID, deepCopy } from "../../utils"; import { doCreateVideo, diff --git a/src/views/model/getPaper.vue b/src/views/model/getPaper.vue index 77ed896..38f092d 100644 --- a/src/views/model/getPaper.vue +++ b/src/views/model/getPaper.vue @@ -30,7 +30,7 @@ import Vue from "vue"; import { Toast } from "vant"; import { mapState, mapActions } from "vuex"; import HeadTop from "./../../components/common/head.vue"; -import scrollToID from "../../utils/scrollToID"; +import { scrollToID } from "../../utils"; import { getModelDetailById, diff --git a/src/views/model/modelDetail.vue b/src/views/model/modelDetail.vue deleted file mode 100644 index 2f86115..0000000 --- a/src/views/model/modelDetail.vue +++ /dev/null @@ -1,242 +0,0 @@ - - - - - diff --git a/src/views/model/selectSound.vue b/src/views/model/selectSound.vue deleted file mode 100644 index b71787e..0000000 --- a/src/views/model/selectSound.vue +++ /dev/null @@ -1,171 +0,0 @@ - - - - - diff --git a/src/views/myPage/myPage.vue b/src/views/myPage/myPage.vue index ffd5528..d7e61a8 100644 --- a/src/views/myPage/myPage.vue +++ b/src/views/myPage/myPage.vue @@ -29,7 +29,7 @@ {{ item.title || "暂无" }}
视频时长:{{ item.videoTime }}
-
视频容量:{{ "46.5Mb" }}
+
视频容量:{{ item.videoSize }}
创建时间:{{ changeTime(item.createDate, "YYYY-MM-DD hh:mm:ss") }}
@@ -49,12 +49,14 @@