Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
luooooob committed Nov 29, 2021
1 parent 2f250f7 commit 3d6d266
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 210 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@luooooob"
}
"extends": "@luooooob"
}
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
{
"name": "asoul-notifications",
"displayName": "A-SOUL 提醒小助手",
"description": "A-SOUL 成员新动态提醒, 直播状态提醒",
"version": "0.6.4",
"description": "A-SOUL 成员新动态提醒, 直播状态提醒",
"publisher": "JiangYan",
"icon": "logo.png",
"repository": {
"type": "git",
"url": "https://github.com/luooooob/vscode-asoul-notifications.git"
},
"keywords": [
"asoul",
"bilibili",
Expand All @@ -18,6 +14,10 @@
"乃琳",
"珈乐"
],
"repository": {
"type": "git",
"url": "https://github.com/luooooob/vscode-asoul-notifications.git"
},
"engines": {
"vscode": "^1.60.0"
},
Expand Down Expand Up @@ -92,9 +92,13 @@
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"lint": "eslint .",
"test": "node ./out/test/runTest.js"
},
"dependencies": {
"axios": "^0.24.0",
"node-cron": "^3.0.0"
},
"devDependencies": {
"@luooooob/eslint-config": "^0.5.0",
"@types/glob": "^7.2.0",
Expand All @@ -108,9 +112,5 @@
"typescript": "^4.5.2",
"vsce": "^2.3.0",
"vscode-test": "^1.5.2"
},
"dependencies": {
"axios": "^0.24.0",
"node-cron": "^3.0.0"
}
}
}
35 changes: 17 additions & 18 deletions src/bilibiliDynamics.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
import axios from "axios";
import * as vscode from "vscode";
import type { BilibiliDynamic, BilibiliDynamicsResponse, RequstOptions } from "./types";
import axios from "axios"
import * as vscode from "vscode"
import type { BilibiliDynamic, BilibiliDynamicsResponse, RequstOptions } from "./types"

export const requestDynamics = async (bid: number): Promise<BilibiliDynamicsResponse> => {
const url = `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=${bid}`;
const url = `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=${bid}`
return axios
.get(url)
.then(res => res.data);
};
.then(res => res.data)
}

export const getDynamicsFromResponse = (res: BilibiliDynamicsResponse, nickname?: string): BilibiliDynamic[] => {
return res.data.cards.map(card => {
const { type, dynamic_id_str, user_profile } = card.desc;
const dynamicId = dynamic_id_str;
const { type, dynamic_id_str, user_profile } = card.desc
const dynamicId = dynamic_id_str

const { uname } = user_profile.info;
const name = nickname || uname;
const isVideo = type === 8 || type === 16;
const isArticle = type === 64;
const { uname } = user_profile.info
const name = nickname ?? uname
const isVideo = type === 8 || type === 16
const isArticle = type === 64
const message = isVideo
? `${name}投稿了新视频`
: isArticle
? `${name}投稿了新专栏`
: `${name}有了新动态`;
: `${name}有了新动态`

const commands: vscode.Command[] = [{
title: "前往动态",
command: "vscode.open",
arguments: [vscode.Uri.parse(`https://t.bilibili.com/${dynamic_id_str}`)]
}];
return { dynamicId, message, commands };
});
};

}]
return { dynamicId, message, commands }
})
}
44 changes: 21 additions & 23 deletions src/bilibiliLiveStatus.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
import * as vscode from "vscode";
import axios from "axios";
import {
import * as vscode from "vscode"
import axios from "axios"
import type {
BilibiliLiveStatusResponse,
BilibiliLiveStatus,
} from "./types";
BilibiliLiveStatus
} from "./types"

// export const makeLiveStatusRequstOptions = (bid: number) => ({
// url: `https://api.bilibili.com/x/space/acc/info?mid=${bid}`
// });

export const requestLiveStatus = async (bid: number): Promise<BilibiliLiveStatusResponse> => {
const url = `https://api.bilibili.com/x/space/acc/info?mid=${bid}`;
const url = `https://api.bilibili.com/x/space/acc/info?mid=${bid}`
return axios
.get(url)
.then(res => res.data);
};
.then(res => res.data)
}

export const getLiveStatusFromResponse = (res: BilibiliLiveStatusResponse, nickname: string | undefined): BilibiliLiveStatus => {
const name = nickname || res.data.name;
const isLive = res.data.live_room.liveStatus === 1;
const name = nickname ?? res.data.name
const isLive = res.data.live_room.liveStatus === 1
if (isLive) {
const url = res.data.live_room.url;
return { name, isLive, url };
const { url } = res.data.live_room
return { name, isLive, url }
}
return { name, isLive };
};
return { name, isLive }
}

export const displayStatusBar = (statusBarItem: vscode.StatusBarItem, liveStatus: BilibiliLiveStatus) => {
if (liveStatus.isLive) {
statusBarItem.text = `--${liveStatus.name}正在直播--`;
statusBarItem.tooltip = "前往直播间";
statusBarItem.text = `--${liveStatus.name}正在直播--`
statusBarItem.tooltip = "前往直播间"
statusBarItem.command = {
title: "To Liveroom",
command: 'vscode.open',
command: "vscode.open",
arguments: [vscode.Uri.parse(liveStatus.url)]
};
statusBarItem.show();
}
statusBarItem.show()
} else {
statusBarItem.hide();
statusBarItem.hide()
}
};


}

// export const getLiveroomUrl = (id: number) => {
// return `https://live.bilibili.com/${id}`;
Expand Down
28 changes: 14 additions & 14 deletions src/douyinVideos.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import axios from "axios";
import * as vscode from "vscode";
import type { DouyinVideo, DouyinVideosResponse } from "./types";
import axios from "axios"
import * as vscode from "vscode"
import type { DouyinVideo, DouyinVideosResponse } from "./types"

export const requestVideos = async (did: string): Promise<DouyinVideosResponse> => {
const url = `https://www.iesdouyin.com/web/api/v2/aweme/post/?sec_uid=${did}`;
const url = `https://www.iesdouyin.com/web/api/v2/aweme/post/?sec_uid=${did}`
return axios
.get(url)
.then(res => res.data);
};
.then(res => res.data)
}

export const getVideosFromResponse = (res: DouyinVideosResponse, nickname?: string): DouyinVideo[] => {
return res.aweme_list.map(aweme => {
const { aweme_id, author } = aweme;
const videoId = aweme_id;
const name = nickname || author.nickname;
const { aweme_id, author } = aweme
const videoId = aweme_id
const name = nickname ?? author.nickname

const message = `${name} 投稿了新抖音短视频`;
const message = `${name} 投稿了新抖音短视频`
const commands: vscode.Command[] = [{
title: "前往视频",
command: "vscode.open",
arguments: [vscode.Uri.parse(`https://www.douyin.com/video/${aweme_id}`)]
}];
return { videoId, message, commands };
});
};
}]
return { videoId, message, commands }
})
}
Loading

0 comments on commit 3d6d266

Please sign in to comment.