You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spring-boot-online-exam/frontend/src/views/account/settings/BaseSetting.vue

170 lines
4.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div class="account-settings-info-view">
<!-- 使用a-row和a-col组件创建一个两列的布局 -->
<a-row :gutter="16">
<!-- 左侧列占据24/24的宽度在lg及以上屏幕上占据16/24的宽度 -->
<a-col :md="24" :lg="16">
<!-- 使用a-form组件创建一个垂直布局的表单 -->
<a-form layout="vertical">
<!-- 表单项用于输入昵称 -->
<a-form-item
label="昵称"
>
<a-input placeholder="给自己起个名字" />
</a-form-item>
<!-- 表单项用于输入Bio -->
<a-form-item
label="Bio"
>
<a-textarea rows="4" placeholder="You are not alone."/>
</a-form-item>
<!-- 表单项用于输入电子邮件 -->
<a-form-item
label="电子邮件"
:required="false"
>
<a-input placeholder="exp@admin.com"/>
</a-form-item>
<!-- 表单项用于输入登录密码 -->
<a-form-item
label="登录密码"
:required="false"
>
<a-input placeholder="密码"/>
</a-form-item>
<!-- 表单项用于提交和保存按钮 -->
<a-form-item>
<a-button type="primary">提交</a-button>
<a-button style="margin-left: 8px">保存</a-button>
</a-form-item>
</a-form>
</a-col>
<!-- 右侧列占据24/24的宽度在lg及以上屏幕上占据8/24的宽度最小高度为180px -->
<a-col :md="24" :lg="8" :style="{ minHeight: '180px' }">
<!-- 使用ant-upload-preview组件创建一个头像预览框 -->
<div class="ant-upload-preview" @click="$refs.modal.edit(1)" >
<!-- 使用a-icon组件创建一个上传图标 -->
<a-icon type="cloud-upload-o" class="upload-icon"/>
<!-- 使用mask组件创建一个遮罩层 -->
<div class="mask">
<!-- 使用a-icon组件创建一个加号图标 -->
<a-icon type="plus" />
</div>
<!-- 显示头像图片 -->
<img :src="option.img"/>
</div>
</a-col>
</a-row>
<!-- 使用avatar-modal组件创建一个头像模态框 -->
<avatar-modal ref="modal">
</avatar-modal>
</div>
</template>
<script>
// 引入AvatarModal组件
import AvatarModal from './AvatarModal'
export default {
components: {
AvatarModal
},
data () {
return {
// cropper
preview: {},
option: {
// 头像图片路径
img: '/avatar2.jpg',
// 是否显示信息
info: true,
// 输出图片大小
size: 1,
// 输出图片类型
outputType: 'jpeg',
// 是否可以缩放
canScale: false,
// 是否自动截图
autoCrop: true,
// 只有自动截图开启 宽度高度才生效
autoCropWidth: 180,
autoCropHeight: 180,
// 固定截图框大小
fixedBox: true,
// 开启宽度和高度比例
fixed: true,
// 宽高比例
fixedNumber: [1, 1]
}
}
},
methods: {
}
}
</script>
<style lang="less" scoped>
.avatar-upload-wrapper {
height: 200px;
width: 100%;
}
.ant-upload-preview {
position: relative;
margin: 0 auto;
width: 100%;
max-width: 180px;
border-radius: 50%;
box-shadow: 0 0 4px #ccc;
.upload-icon {
position: absolute;
top: 0;
right: 10px;
font-size: 1.4rem;
padding: 0.5rem;
background: rgba(222, 221, 221, 0.7);
border-radius: 50%;
border: 1px solid rgba(0, 0, 0, 0.2);
}
.mask {
opacity: 0;
position: absolute;
background: rgba(0,0,0,0.4);
cursor: pointer;
transition: opacity 0.4s;
&:hover {
opacity: 1;
}
i {
font-size: 2rem;
position: absolute;
top: 50%;
left: 50%;
margin-left: -1rem;
margin-top: -1rem;
color: #d6d6d6;
}
}
img, .mask {
width: 100%;
max-width: 180px;
height: 100%;
border-radius: 50%;
overflow: hidden;
}
}
</style>