Skip to content

Commit 441a390

Browse files
authored
Merge pull request #42 from luoqiz/feat-update-windows-title
feat: 添加用户头像显示 close #41
2 parents 8633d71 + 93f37a5 commit 441a390

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

src-tauri/config.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"cburl":[],"http_server_port":10080,"wsurl":"","file_dir":"","front_msg_show":true}
1+
{"cburl":[],"http_server_port":10010,"wsurl":"","file_dir":"","front_msg_show":true}

src/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ declare module 'vue' {
1010
404: typeof import('./components/404.vue')['default']
1111
BaseHeader: typeof import('./components/layouts/BaseHeader.vue')['default']
1212
ElAutoResizer: typeof import('element-plus/es')['ElAutoResizer']
13+
ElAvatar: typeof import('element-plus/es')['ElAvatar']
1314
ElButton: typeof import('element-plus/es')['ElButton']
1415
ElCard: typeof import('element-plus/es')['ElCard']
1516
ElCol: typeof import('element-plus/es')['ElCol']

src/components/layouts/BaseHeader.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const startOrStop = async () => {
2727
await wechatStore.stop();
2828
} else {
2929
await wechatStore.start();
30+
var getUserInfoTask = window.setInterval(async function logname() {
31+
await wechatStore.updateSlefInfo();
32+
clearInterval(getUserInfoTask)
33+
}, 5000);
3034
}
3135
} catch (err: any) {
3236
console.error(err);
@@ -72,11 +76,9 @@ onMounted(async () => {
7276
<i inline-flex i="dark:ep-moon ep-sunny" />
7377
</button>
7478
</el-menu-item>
75-
<!-- <el-menu-item>
76-
<a-link href="https://github.com/lich0821/WeChatFerry" status="success" target="_blank">
77-
<icon-github :style="{ fontSize: '32px' }" />
78-
</a-link>
79-
</el-menu-item> -->
79+
<el-menu-item v-if="!!wechatStore.selfInfo.small_head_url">
80+
<el-avatar shape="square" :size="36" :src="wechatStore.selfInfo.small_head_url" />
81+
</el-menu-item>
8082
</el-menu>
8183
</div>
8284
</template>

src/store/modules/wechat.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@ export const useWechatStore = defineStore('wechat', {
1414
this.selfInfo = selfInfo;
1515
sessionStorage.setItem('selfInfo', JSON.stringify(selfInfo));
1616
},
17+
async updateSlefInfo() {
18+
if(this.isServerRunning){
19+
this.selfInfo = await wcf_api.userinfo();
20+
console.log(this.selfInfo);
21+
}
22+
},
1723
async getRunningFlag() {
1824
this.isServerRunning = await wcf.is_http_server_running();
1925
},
2026
async start() {
2127
await wcf.start_server('0.0.0.0', 10010);
2228
this.isServerRunning = await wcf.is_http_server_running();
23-
this.selfInfo = await wcf_api.userinfo();
24-
console.log(this.selfInfo);
2529
},
2630
async stop() {
2731
await wcf.stop_server();
2832
this.isServerRunning = await wcf.is_http_server_running();
33+
this.setSelfInfo({});
2934
},
3035
},
3136
});

0 commit comments

Comments
 (0)