Skip to content

Commit 1b8aec2

Browse files
authored
Merge pull request #193 from cnblogs/fix-login-view-loading
fix: view loading order
2 parents be73427 + ee278f3 commit 1b8aec2

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

package.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,7 @@
3737
"stats": "npm run --silent package -- --env namedChunks=true --profile --json > ./dist/stats.json && webpack-bundle-analyzer ./dist/stats.json ./dist"
3838
},
3939
"activationEvents": [
40-
"workspaceContains:**",
41-
"onView:cnblogs-authorize",
42-
"onView:cnblogs-account",
43-
"onView:cnblogs-post-list",
44-
"onView:vscode-cnb-workspace",
45-
"onCommand:vscode-cnb.workspace.code-open",
46-
"onCommand:vscode-cnb.login.web",
47-
"onCommand:vscode-cnb.logout",
48-
"onCommand:vscode-cnb.ing-publish-select"
40+
"onStartupFinished"
4941
],
5042
"main": "./dist/extension.js",
5143
"contributes": {
@@ -769,13 +761,13 @@
769761
{
770762
"id": "cnblogs-authorize",
771763
"name": "登录/授权",
772-
"when": "!vscode-cnb.isAuthed",
764+
"when": "vscode-cnb.isUnauthorized",
773765
"visibility": "visible"
774766
},
775767
{
776768
"id": "vscode-cnb-workspace",
777769
"name": "工作空间",
778-
"when": "vscode-cnb.isAuthed",
770+
"when": "!vscode-cnb.isUnauthorized",
779771
"visibility": "collapsed"
780772
},
781773
{

src/auth/auth-manager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ export namespace AuthManager {
107107

108108
await execCmd('setContext', `${globalCtx.extName}.isAuthed`, isAuthed)
109109

110+
await execCmd('setContext', `${globalCtx.extName}.isUnauthorized`, !isAuthed)
111+
110112
if (!isAuthed) return
111113

112114
await execCmd('setContext', `${globalCtx.extName}.user`, {

src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export async function activate(ctx: ExtensionContext) {
1616
// WRN: For old version compatibility, NEVER remove this line
1717
void LocalState.delSecret('user')
1818

19+
await AuthManager.updateAuthStatus()
20+
1921
setupExtCmd()
2022
setupExtTreeView()
2123

@@ -28,8 +30,6 @@ export async function activate(ctx: ExtensionContext) {
2830

2931
window.registerUriHandler(extUriHandler)
3032

31-
await AuthManager.updateAuthStatus()
32-
3333
setupUi(LocalState.getExtCfg())
3434

3535
return { extendMarkdownIt }

0 commit comments

Comments
 (0)