From e3b5d7ca543cbb4e268d70a44bc78269d54547fe Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期二, 26 十一月 2024 13:25:37 +0800
Subject: [PATCH] update 优化 菜单面包屑导航支持多层级显示
---
src/views/system/user/profile/userAvatar.vue | 53 ++++++++++++++++++++++++++---------------------------
1 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/src/views/system/user/profile/userAvatar.vue b/src/views/system/user/profile/userAvatar.vue
index 0796765..32b6f5c 100644
--- a/src/views/system/user/profile/userAvatar.vue
+++ b/src/views/system/user/profile/userAvatar.vue
@@ -1,20 +1,20 @@
<template>
<div class="user-info-head" @click="editCropper()">
- <img :src="options.img as string" title="鐐瑰嚮涓婁紶澶村儚" class="img-circle img-lg" />
- <el-dialog :title="title" v-model="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog">
+ <img :src="options.img" title="鐐瑰嚮涓婁紶澶村儚" class="img-circle img-lg" />
+ <el-dialog v-model="open" :title="title" width="800px" append-to-body @opened="modalOpened" @close="closeDialog">
<el-row>
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
<vue-cropper
+ v-if="visible"
ref="cropper"
:img="options.img"
:info="true"
- :autoCrop="options.autoCrop"
- :autoCropWidth="options.autoCropWidth"
- :autoCropHeight="options.autoCropHeight"
- :fixedBox="options.fixedBox"
- :outputType="options.outputType"
- @realTime="realTime"
- v-if="visible"
+ :auto-crop="options.autoCrop"
+ :auto-crop-width="options.autoCropWidth"
+ :auto-crop-height="options.autoCropHeight"
+ :fixed-box="options.fixedBox"
+ :output-type="options.outputType"
+ @real-time="realTime"
/>
</el-col>
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
@@ -56,13 +56,14 @@
</template>
<script setup lang="ts">
-import "vue-cropper/dist/index.css";
-import { VueCropper } from "vue-cropper";
-import { uploadAvatar } from "@/api/system/user";
-import useUserStore from "@/store/modules/user";
+import 'vue-cropper/dist/index.css';
+import { VueCropper } from 'vue-cropper';
+import { uploadAvatar } from '@/api/system/user';
+import useUserStore from '@/store/modules/user';
+import { UploadRawFile } from 'element-plus';
interface Options {
- img: string | ArrayBuffer | null; // 瑁佸壀鍥剧墖鐨勫湴鍧�
+ img: string | any; // 瑁佸壀鍥剧墖鐨勫湴鍧�
autoCrop: boolean; // 鏄惁榛樿鐢熸垚鎴浘妗�
autoCropWidth: number; // 榛樿鐢熸垚鎴浘妗嗗搴�
autoCropHeight: number; // 榛樿鐢熸垚鎴浘妗嗛珮搴�
@@ -73,13 +74,12 @@
visible: boolean;
}
-
const userStore = useUserStore();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const open = ref(false);
const visible = ref(false);
-const title = ref("淇敼澶村儚");
+const title = ref('淇敼澶村儚');
const cropper = ref<any>({});
//鍥剧墖瑁佸壀鏁版嵁
@@ -89,8 +89,8 @@
autoCropWidth: 200,
autoCropHeight: 200,
fixedBox: true,
- outputType: "png",
- fileName: "",
+ outputType: 'png',
+ fileName: '',
previews: {},
visible: false
});
@@ -104,8 +104,7 @@
visible.value = true;
};
/** 瑕嗙洊榛樿涓婁紶琛屼负 */
-const requestUpload = (): any => {
-};
+const requestUpload = (): any => {};
/** 鍚戝乏鏃嬭浆 */
const rotateLeft = () => {
cropper.value.rotateLeft();
@@ -120,9 +119,9 @@
cropper.value.changeScale(num);
};
/** 涓婁紶棰勫鐞� */
-const beforeUpload = (file: any) => {
- if (file.type.indexOf("image/") == -1) {
- proxy?.$modal.msgError("鏂囦欢鏍煎紡閿欒锛岃涓婁紶鍥剧墖绫诲瀷,濡傦細JPG锛孭NG鍚庣紑鐨勬枃浠躲��");
+const beforeUpload = (file: UploadRawFile): any => {
+ if (file.type.indexOf('image/') == -1) {
+ proxy?.$modal.msgError('鏂囦欢鏍煎紡閿欒锛岃涓婁紶鍥剧墖绫诲瀷,濡傦細JPG锛孭NG鍚庣紑鐨勬枃浠躲��');
} else {
const reader = new FileReader();
reader.readAsDataURL(file);
@@ -136,12 +135,12 @@
const uploadImg = async () => {
cropper.value.getCropBlob(async (data: any) => {
let formData = new FormData();
- formData.append("avatarfile", data, options.fileName);
+ formData.append('avatarfile', data, options.fileName);
const res = await uploadAvatar(formData);
open.value = false;
options.img = res.data.imgUrl;
- userStore.avatar = options.img as string
- proxy?.$modal.msgSuccess("淇敼鎴愬姛");
+ userStore.setAvatar(options.img);
+ proxy?.$modal.msgSuccess('淇敼鎴愬姛');
visible.value = false;
});
};
@@ -164,7 +163,7 @@
}
.user-info-head:hover:after {
- content: "+";
+ content: '+';
position: absolute;
left: 0;
right: 0;
--
Gitblit v1.9.3