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

Commit

Permalink
add bgmtv access token config for request some private api (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
chivehao authored Nov 24, 2022
1 parent b921990 commit 6005de1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/api/tripartite.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import request from '@/utils/request'

const api = {
testQbittorrentConnect: '/tripartite/qbittorrent/connect/test'
testQbittorrentConnect: '/tripartite/qbittorrent/connect/test',
getBgmTvMe: '/tripartite/bgmtv/token/user/me'
}

export function testQbittorrentConnect () {
Expand All @@ -10,3 +11,10 @@ export function testQbittorrentConnect () {
mentions: 'get'
})
}

export function getBgmTvMe () {
return request({
url: api.getBgmTvMe,
method: 'get'
})
}
40 changes: 38 additions & 2 deletions src/views/system/SystemOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,25 @@
/>
<a-switch :checked="bgmtv.ENABLE_PROXY | str2boolean" @change="changeBgmTvEnableProxySwitch" />
</a-form-model-item>
<a-form-model-item label="Token">
<a-alert
message="需要在番组计划官网申请令牌,链接:https://bgm.tv/group/topic/370315"
banner
closable
/>
<a-input-password v-model="bgmtv.ACCESS_TOKEN" allowClear placeholder="token"/>
</a-form-model-item>
<a-form-model-item>
<a-button type="primary" @click="saveOption('BGMTV')">
保存番组计划设置
</a-button>
<a-button
type="primary"
:loading="testBgmTvTokenButtonLoading"
@click="testBgmTvToken"
style="margin: 0px 5px">
测试令牌
</a-button>
</a-form-model-item>
</a-form-model>
</a-tab-pane>
Expand Down Expand Up @@ -193,7 +208,7 @@ import { listPlaces } from '@/api/file'
import {
getOptionList, saveOptionWithRequest
} from '@/api/options'
import { testQbittorrentConnect } from '@/api/tripartite'
import { testQbittorrentConnect, getBgmTvMe } from '@/api/tripartite'
import { testProxyConnect } from '@/api/network'
export default {
Expand All @@ -215,7 +230,8 @@ export default {
loading: false
},
testConnectQbittorrentButtonLoading: false,
testConnectProxyButtonLoading: false
testConnectProxyButtonLoading: false,
testBgmTvTokenButtonLoading: false
}
},
created () {
Expand Down Expand Up @@ -274,6 +290,7 @@ export default {
if (category === 'BGMTV') {
this.bgmtv = entity.kvMap
// this.$log.debug('bgmtv', this.bgmtv)
}
if (category === 'MIKAN') {
Expand Down Expand Up @@ -395,6 +412,25 @@ export default {
.finally(() => {
this.testConnectProxyButtonLoading = false
})
},
testBgmTvToken () {
this.testBgmTvTokenButtonLoading = true
getBgmTvMe()
.then(rsp => {
const bgmTvUserInfo = rsp.result
if (bgmTvUserInfo) {
this.$message.success('你好, ' + bgmTvUserInfo.nickname + '!')
} else {
this.$message.error('测试番组计划令牌失败')
}
})
.catch(error => {
this.$log.error('test bgmtv token fail', error)
this.$message.error('测试番组计划令牌失败')
})
.finally(() => {
this.testBgmTvTokenButtonLoading = false
})
}
}
}
Expand Down

0 comments on commit 6005de1

Please sign in to comment.