Skip to content

Commit

Permalink
init code
Browse files Browse the repository at this point in the history
  • Loading branch information
huoxue1 committed Dec 4, 2021
1 parent 4aac660 commit 72f0ea0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions router/view/src/utils/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@ const { v4: uuidv4 } = require('uuid');

module.exports = {
base: process.env.VUE_APP_API,

get_files:async function(work_id){
let resp = await axios.post(this.base+"/public/get_files/" + work_id)
return resp.data.data
},

get_works:async function(){
let resp = await axios.post(this.base+"/public/get_works")
return resp.data.data
},

get_work:async function(work_id){
let resp = await axios.post(this.base+"/public/get_work/"+work_id)
return resp.data.data
},

upload:async function(file){
let resp = await axios.post(this.base+"/public/upload",file)
return resp.data
},

get_token:function(){
let token = localStorage.getItem("token");
if (token === null){
Expand All @@ -29,16 +34,20 @@ module.exports = {
return token
}
},

handRemove: async function (id,token){
let resp = await axios.post(this.base+"/public/remove_file/"+id+"?token="+token)
return resp.data
},

create_work:async function(data){
let resp = await axios.post(this.base+"/admin/create_work?token="+this.get_token(),data)
return resp.data
},

delete_work:async function(id){
let resp = await axios.post(this.base+"/admin/delete_work/"+id+"?token="+this.get_token())
return resp.data
}

}
4 changes: 2 additions & 2 deletions router/view/src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ module.exports = {
return ''
}
},

get_size:function getfilesize(size) {
if (!size)
return "";

const num = 1024.00; //byte

if (size < num)
return size + "B";
if (size < Math.pow(num, 2))
Expand All @@ -30,6 +29,7 @@ module.exports = {
return (size / Math.pow(num, 3)).toFixed(2) + "G"; //G
return (size / Math.pow(num, 4)).toFixed(2) + "T"; //T
},

fileToBase64: function (file,callback) {
let reader = new FileReader();
// 传入一个参数对象即可得到基于该参数对象的文本内容
Expand Down

0 comments on commit 72f0ea0

Please sign in to comment.