Skip to content

feat: add vip link #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/assets/icon-vip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/cmd/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export namespace Browser.Open.Cnb {

export namespace Browser.Open.User {
export const accountSetting = () => open('https://account.cnblogs.com/settings/account')
export const buyVip = () => open('https://cnblogs.vip/')

export async function blog() {
const blogApp = (await UserService.getUserInfo())?.blogApp
Expand Down
1 change: 1 addition & 0 deletions src/setup/setup-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export function setupCmd() {
regCmd(extName`.open.my-home`, Browser.Open.User.home),
regCmd(extName`.open.blog-console`, Browser.Open.User.blogConsole),
regCmd(extName`.open.account-setting`, Browser.Open.User.accountSetting),
regCmd(extName`.open.buy-vip`, Browser.Open.User.buyVip),
// ing list
regCmd(extName`.ing-list.next`, Ing.ListView.goNext),
regCmd(extName`.ing-list.prev`, Ing.ListView.goPrev),
Expand Down
59 changes: 41 additions & 18 deletions src/tree-view/provider/account-view-data-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ export class AccountViewDataProvider implements TreeDataProvider<TreeItem> {
async getChildren(el?: TreeItem) {
if (!(await AuthManager.isAuthed()) || el !== undefined) return []

const userName = (await UserService.getUserInfo())?.displayName
return [
{ label: userName, tooltip: '用户名', iconPath: new ThemeIcon('account') },
const user = await UserService.getUserInfo()
if (user == null) return []

const items = [
{ label: user.displayName, tooltip: '用户名', iconPath: new ThemeIcon('account') },
{
label: '账号设置',
command: {
Expand All @@ -27,22 +29,41 @@ export class AccountViewDataProvider implements TreeDataProvider<TreeItem> {
},
iconPath: new ThemeIcon('gear'),
},
{
label: '博客后台',
]

if (user.isVip !== true) {
items.push({
label: '购买会员',
command: {
title: '打开博客后台',
command: 'vscode-cnb.open.blog-console',
title: '购买博客园会员',
command: 'vscode-cnb.open.buy-vip',
},
iconPath: new ThemeIcon('console'),
},
{
label: '我的博客',
command: {
title: '打开我的博客',
command: 'vscode-cnb.open.my-blog',
iconPath: new ThemeIcon('heart'),
})
}

if (user.blogApp != null) {
items.push(
{
label: '博客后台',
command: {
title: '打开博客后台',
command: 'vscode-cnb.open.blog-console',
},
iconPath: new ThemeIcon('console'),
},
iconPath: new ThemeIcon('window'),
},
{
label: '我的博客',
command: {
title: '打开我的博客',
command: 'vscode-cnb.open.my-blog',
},
iconPath: new ThemeIcon('window'),
}
)
}

items.push(
{
label: '我的主页',
command: {
Expand All @@ -58,8 +79,10 @@ export class AccountViewDataProvider implements TreeDataProvider<TreeItem> {
command: 'vscode-cnb.logout',
},
iconPath: new ThemeIcon('log-out'),
},
]
}
)

return items
}

fireTreeDataChangedEvent() {
Expand Down