|
7 | 7 | <a-col :span="10">
|
8 | 8 | <div class="change-avatar">
|
9 | 9 | <div class="mb-2"> 头像 </div>
|
10 |
| - <img width="140" :src="headerImg" /> |
| 10 | + <img width="140" :src="avatar" /> |
11 | 11 | <Upload :showUploadList="false">
|
12 | 12 | <Button class="ml-5"> <Icon icon="feather:upload" />更换头像 </Button>
|
13 | 13 | </Upload>
|
|
19 | 19 | </template>
|
20 | 20 | <script lang="ts">
|
21 | 21 | import { Button, Upload, Row, Col } from 'ant-design-vue';
|
22 |
| - import { defineComponent, onMounted } from 'vue'; |
| 22 | + import { computed, defineComponent, onMounted } from 'vue'; |
23 | 23 | import { BasicForm, useForm } from '/@/components/Form/index';
|
24 | 24 | import { CollapseContainer } from '/@/components/Container/index';
|
25 | 25 | import Icon from '/@/components/Icon/index';
|
|
29 | 29 | import headerImg from '/@/assets/images/header.jpg';
|
30 | 30 | import { accountInfoApi } from '/@/api/demo/account';
|
31 | 31 | import { baseSetschemas } from './data';
|
| 32 | + import { useUserStore } from '/@/store/modules/user'; |
32 | 33 |
|
33 | 34 | export default defineComponent({
|
34 | 35 | components: {
|
|
42 | 43 | },
|
43 | 44 | setup() {
|
44 | 45 | const { createMessage } = useMessage();
|
| 46 | + const userStore = useUserStore(); |
45 | 47 |
|
46 | 48 | const [register, { setFieldsValue }] = useForm({
|
47 | 49 | labelWidth: 120,
|
|
54 | 56 | setFieldsValue(data);
|
55 | 57 | });
|
56 | 58 |
|
| 59 | + const avatar = computed(() => { |
| 60 | + const { avatar } = userStore.getUserInfo; |
| 61 | + return avatar || headerImg; |
| 62 | + }); |
| 63 | +
|
57 | 64 | return {
|
58 |
| - headerImg, |
| 65 | + avatar, |
59 | 66 | register,
|
60 | 67 | handleSubmit: () => {
|
61 | 68 | createMessage.success('更新成功!');
|
|
0 commit comments