feat: 更新引入案例相关源码

This commit is contained in:
100gle
2022-04-19 20:57:50 +08:00
parent 16c27ff1b1
commit e9cc3c297a
4 changed files with 1892 additions and 0 deletions

25
code/02/fetchVideoStat.js Normal file
View File

@@ -0,0 +1,25 @@
(function () {
let api = window.__INITIAL_STATE__;
let stat = undefined;
try {
stat = api.videoData.stat;
} catch (e) {}
const cols = ["rank", "like", "coin", "collect", "share"];
let blankStat = {};
for (const col of cols) {
blankStat[col] = "";
}
if (stat === undefined) {
return blankStat;
}
return {
rank: stat.his_rank,
like: stat.like,
coin: stat.coin,
collect: stat.favorite,
share: stat.share,
};
})();