-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
373143c
commit e43e918
Showing
2 changed files
with
60 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import axios from "axios"; | ||
// import { getDecode } from "@/utils/coverage"; | ||
|
||
// 用于文件base64解码后的格式化 | ||
function getDecode(str: string) { | ||
return decodeURIComponent( | ||
atob(str) | ||
.split("") | ||
.map(function (c) { | ||
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2); | ||
}) | ||
.join(""), | ||
); | ||
} | ||
export const handleSelect = ({ projectID, sha, filepath }) => { | ||
return Promise.all([ | ||
axios.get("/api/cov/map", { | ||
params: { | ||
project_id: projectID, | ||
sha, | ||
filepath, | ||
}, | ||
}), | ||
axios | ||
.get("/api/sourcecode", { | ||
params: { | ||
project_id: projectID, | ||
sha, | ||
filepath, | ||
}, | ||
}) | ||
.catch((err) => { | ||
return { | ||
data: { | ||
content: "", | ||
}, | ||
}; | ||
}), | ||
]).then(([res1, res2]) => { | ||
return { | ||
fileCoverage: res1.data[filepath], | ||
fileContent: getDecode(res2.data.content), | ||
}; | ||
}); | ||
}; |