Skip to content

Commit da8f7b2

Browse files
committed
feat: add vip link
1 parent 0f39f28 commit da8f7b2

File tree

4 files changed

+62
-18
lines changed

4 files changed

+62
-18
lines changed

src/assets/icon-vip.svg

Lines changed: 19 additions & 0 deletions
Loading

src/cmd/browser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export namespace Browser.Open.Cnb {
1818

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

2223
export async function blog() {
2324
const blogApp = (await UserService.getUserInfo())?.blogApp

src/setup/setup-cmd.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export function setupCmd() {
110110
regCmd(extName`.open.my-home`, Browser.Open.User.home),
111111
regCmd(extName`.open.blog-console`, Browser.Open.User.blogConsole),
112112
regCmd(extName`.open.account-setting`, Browser.Open.User.accountSetting),
113+
regCmd(extName`.open.buy-vip`, Browser.Open.User.buyVip),
113114
// ing list
114115
regCmd(extName`.ing-list.next`, Ing.ListView.goNext),
115116
regCmd(extName`.ing-list.prev`, Ing.ListView.goPrev),

src/tree-view/provider/account-view-data-provider.ts

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ export class AccountViewDataProvider implements TreeDataProvider<TreeItem> {
1616
async getChildren(el?: TreeItem) {
1717
if (!(await AuthManager.isAuthed()) || el !== undefined) return []
1818

19-
const userName = (await UserService.getUserInfo())?.displayName
20-
return [
21-
{ label: userName, tooltip: '用户名', iconPath: new ThemeIcon('account') },
19+
const user = await UserService.getUserInfo()
20+
if (user == null) return []
21+
22+
const items = [
23+
{ label: user.displayName, tooltip: '用户名', iconPath: new ThemeIcon('account') },
2224
{
2325
label: '账号设置',
2426
command: {
@@ -27,22 +29,41 @@ export class AccountViewDataProvider implements TreeDataProvider<TreeItem> {
2729
},
2830
iconPath: new ThemeIcon('gear'),
2931
},
30-
{
31-
label: '博客后台',
32+
]
33+
34+
if (user.isVip !== true) {
35+
items.push({
36+
label: '购买会员',
3237
command: {
33-
title: '打开博客后台',
34-
command: 'vscode-cnb.open.blog-console',
38+
title: '购买博客园会员',
39+
command: 'vscode-cnb.open.buy-vip',
3540
},
36-
iconPath: new ThemeIcon('console'),
37-
},
38-
{
39-
label: '我的博客',
40-
command: {
41-
title: '打开我的博客',
42-
command: 'vscode-cnb.open.my-blog',
41+
iconPath: new ThemeIcon('heart'),
42+
})
43+
}
44+
45+
if (user.blogApp != null) {
46+
items.push(
47+
{
48+
label: '博客后台',
49+
command: {
50+
title: '打开博客后台',
51+
command: 'vscode-cnb.open.blog-console',
52+
},
53+
iconPath: new ThemeIcon('console'),
4354
},
44-
iconPath: new ThemeIcon('window'),
45-
},
55+
{
56+
label: '我的博客',
57+
command: {
58+
title: '打开我的博客',
59+
command: 'vscode-cnb.open.my-blog',
60+
},
61+
iconPath: new ThemeIcon('window'),
62+
}
63+
)
64+
}
65+
66+
items.push(
4667
{
4768
label: '我的主页',
4869
command: {
@@ -58,8 +79,10 @@ export class AccountViewDataProvider implements TreeDataProvider<TreeItem> {
5879
command: 'vscode-cnb.logout',
5980
},
6081
iconPath: new ThemeIcon('log-out'),
61-
},
62-
]
82+
}
83+
)
84+
85+
return items
6386
}
6487

6588
fireTreeDataChangedEvent() {

0 commit comments

Comments
 (0)