Merge branch 'main' into lyc-dev

This commit is contained in:
lyc 2024-07-18 11:11:04 +08:00
commit b9c9269452
8 changed files with 310 additions and 277 deletions

View File

@ -29,7 +29,7 @@
"jsencrypt": "^3.3.2",
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1",
"vue-cropper": "^1.1.3",
"vue-cropper": "^1.0.3",
"vue-router": "^4.4.0"
},
"devDependencies": {

View File

@ -8,7 +8,7 @@
http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
/> -->
<meta http-equiv="Content-Security-Policy" content="connect-src *; default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:" />
<meta http-equiv="Content-Security-Policy" content="connect-src *; default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:" />
</head>

View File

@ -34,6 +34,9 @@ export function getUserProfile() {
export function uploadAvatar(data) {
return request({
url: '/system/user/profile/avatar',
headers: {
'Content-Type': 'multipart/form-data'
},
method: 'post',
data: data
})

View File

@ -8,3 +8,13 @@ export const isHaveLocalFile = async (fileNewName)=>{
})
})
}
export const parseCataByNode = (node) => {
if (node.parentNode) {
let arr = parseCataByNode(node.parentNode)
arr.push(node.id)
return arr
} else {
return [node.id]
}
}

View File

@ -77,7 +77,7 @@ import FileListItem from '@/views/prepare/container/file-list-item.vue'
import { getSmarttalkPage, moveSmarttalk } from '@/api/file'
import { toTimeText } from '@/utils/date'
import { ElMessage } from 'element-plus'
import { isHaveLocalFile } from '@/utils/talkFile'
import { isHaveLocalFile, parseCataByNode } from '@/utils/talkFile'
import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue'
const { ipcRenderer } = window.electron || {}
export default {
@ -192,7 +192,7 @@ export default {
id: ids.join(),
textbookId: cataData.textBook.curBookId
}
let cata = this.parseCataByNode(cataData.node)
let cata = parseCataByNode(cataData.node)
if (
this.uploadData.levelFirstId == cata[0] &&
this.uploadData.levelSecondId == cata[1] &&
@ -250,7 +250,7 @@ export default {
nodeClick(data) {
if (this.currentNode.id === data.node.id) return
this.checkFileList = []
let cata = this.parseCataByNode(data.node)
let cata = parseCataByNode(data.node)
this.currentNode = data.node
this.uploadData.levelFirstId = cata[0]
this.uploadData.levelSecondId = cata[1]
@ -276,15 +276,6 @@ export default {
console.log(res)
this.isLoading = false
})
},
parseCataByNode(node) {
if (node.parentNode) {
let arr = this.parseCataByNode(node.parentNode)
arr.push(node.id)
return arr
} else {
return [node.id]
}
}
}
}

View File

@ -31,10 +31,10 @@
</template>
<script setup>
import { ref, reactive } from 'vue'
import { ref, reactive, getCurrentInstance } from 'vue'
import { updateUserPwd } from '@/api/system/user'
// const { proxy } = getCurrentInstance();
const { proxy } = getCurrentInstance()
const user = reactive({
oldPassword: undefined,

View File

@ -1,7 +1,14 @@
<template>
<div class="user-info-head" @click="editCropper()">
<img :src="options.img" title="点击上传头像" class="img-circle" />
<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
:title="title"
v-model="open"
width="800px"
append-to-body
@opened="modalOpened"
@close="closeDialog"
>
<el-row>
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
<vue-cropper
@ -19,7 +26,7 @@
</el-col>
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
<div class="avatar-upload-preview">
<img :src="options.previews.url" :style="options.previews.img" />
<el-image style="width: 100px; height: 100px" :src="options.previews.url" :style="options.previews.img"/>
</div>
</el-col>
</el-row>
@ -56,103 +63,110 @@
</el-row>
</el-dialog>
</div>
</template>
</template>
<script setup>
import { Upload, Plus, Minus, RefreshLeft, RefreshRight } from '@element-plus/icons-vue'
import { ref, reactive } from 'vue'
import "vue-cropper/dist/index.css";
import { VueCropper } from "vue-cropper";
import { uploadAvatar } from "@/api/system/user";
import useUserStore from "@/store/modules/user";
import { Upload, Plus, Minus, RefreshLeft, RefreshRight } from '@element-plus/icons-vue'
import { ref, reactive, getCurrentInstance } from 'vue'
import 'vue-cropper/dist/index.css'
import { VueCropper } from 'vue-cropper'
import { uploadAvatar } from '@/api/system/user'
import useUserStore from '@/store/modules/user'
import { ElMessage } from 'element-plus'
const userStore = useUserStore();
// const { proxy } = getCurrentInstance();
const userStore = useUserStore()
const { proxy } = getCurrentInstance()
const open = ref(false);
const visible = ref(false);
const title = ref("修改头像");
const open = ref(false)
const visible = ref(false)
const title = ref('修改头像')
//
const options = reactive({
//
const options = reactive({
img: userStore.avatar, //
autoCrop: true, //
autoCropWidth: 200, //
autoCropHeight: 200, //
fixedBox: true, //
outputType: "png", // PNG
outputType: 'png', // PNG
previews: {} //
});
})
/** 编辑头像 */
function editCropper() {
open.value = true;
}
/** 打开弹出层结束时的回调 */
function modalOpened() {
visible.value = true;
}
/** 覆盖默认上传行为 */
function requestUpload() {}
/** 向左旋转 */
function rotateLeft() {
proxy.$refs.cropper.rotateLeft();
}
/** 向右旋转 */
function rotateRight() {
proxy.$refs.cropper.rotateRight();
}
/** 图片缩放 */
function changeScale(num) {
num = num || 1;
proxy.$refs.cropper.changeScale(num);
}
/** 上传预处理 */
function beforeUpload(file) {
if (file.type.indexOf("image/") == -1) {
proxy.$modal.msgError("文件格式错误,请上传图片类型,如JPGPNG后缀的文件。");
/** 编辑头像 */
function editCropper() {
open.value = true
}
/** 打开弹出层结束时的回调 */
function modalOpened() {
visible.value = true
}
/** 覆盖默认上传行为 */
function requestUpload() {}
/** 向左旋转 */
function rotateLeft() {
proxy.$refs.cropper.rotateLeft()
}
/** 向右旋转 */
function rotateRight() {
proxy.$refs.cropper.rotateRight()
}
/** 图片缩放 */
function changeScale(num) {
num = num || 1
proxy.$refs.cropper.changeScale(num)
}
/** 上传预处理 */
function beforeUpload(file) {
if (file.type.indexOf('image/') == -1) {
ElMessage({
message: '文件格式错误,请上传图片类型,如JPGPNG后缀的文件。',
type: 'error',
})
} else {
const reader = new FileReader();
reader.readAsDataURL(file);
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = () => {
options.img = reader.result;
};
options.img = reader.result
}
}
/** 上传图片 */
function uploadImg() {
proxy.$refs.cropper.getCropBlob(data => {
let formData = new FormData();
formData.append("avatarfile", data);
uploadAvatar(formData).then(response => {
open.value = false;
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
userStore.avatar = options.img;
proxy.$modal.msgSuccess("修改成功");
visible.value = false;
});
});
}
/** 实时预览 */
function realTime(data) {
options.previews = data;
}
/** 关闭窗口 */
function closeDialog() {
options.img = userStore.avatar;
options.visible = false;
}
</script>
}
/** 上传图片 */
function uploadImg() {
proxy.$refs.cropper.getCropBlob((data) => {
let formData = new FormData()
formData.append('avatarfile', data)
uploadAvatar(formData).then((response) => {
open.value = false
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl
userStore.avatar = options.img
ElMessage({
message: '上传成功',
type: 'success',
})
visible.value = false
})
})
}
/** 实时预览 */
function realTime(data) {
options.previews = data
}
/** 关闭窗口 */
function closeDialog() {
options.img = userStore.avatar
options.visible = false
}
</script>
<style lang='scss' scoped>
.user-info-head {
.user-info-head {
position: relative;
display: inline-block;
height: 120px;
}
}
.user-info-head:hover:after {
content: "+";
.user-info-head:hover:after {
content: '+';
position: absolute;
left: 0;
right: 0;
@ -167,9 +181,9 @@
cursor: pointer;
line-height: 110px;
border-radius: 50%;
}
.img-circle {
}
.img-circle {
height: 120px;
width: auto
}
</style>
width: auto;
}
</style>

View File

@ -10,80 +10,95 @@
<el-input v-model="user.email" maxlength="50" />
</el-form-item>
<el-form-item label="性别">
<el-radio-group >
<el-radio label="0"></el-radio>
<el-radio label="1"></el-radio>
<el-radio-group v-model="user.sex">
<el-radio value="0"></el-radio>
<el-radio value="1"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="任教学科">
<el-radio-group v-model="user.edusubject">
<template v-for="item in subjectList">
<el-radio v-if="item.edustage==user.edustage" :label="item.itemtitle">{{ item.itemtitle }}</el-radio>
<template v-for="(item,index) in subjectList" :key="index">
<el-radio v-if="item.edustage == user.edustage" :value="item.itemtitle">
{{item.itemtitle }}
</el-radio>
</template>
</el-radio-group>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit">保存</el-button>
<el-button type="primary" @click="handleclick1">测验</el-button>
</el-form-item>
</el-form>
</template>
</template>
<script setup>
import { ref } from 'vue'
import { updateUserProfile } from "@/api/system/user";
import { listEvaluation } from "@/api/subject/index";
import { ref, getCurrentInstance } from 'vue'
import { updateUserProfile } from '@/api/system/user'
import { listEvaluation } from '@/api/subject/index'
const props = defineProps({
const props = defineProps({
user: {
type: Object
}
});
})
// const { proxy } = getCurrentInstance();
const { proxy } = getCurrentInstance()
const rules = ref({
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
email: [{ required: true, message: "邮箱地址不能为空", trigger: "blur" }, { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
phonenumber: [{ required: true, message: "手机号码不能为空", trigger: "blur" }, { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }],
});
const rules = ref({
nickName: [{ required: true, message: '用户昵称不能为空', trigger: 'blur' }],
email: [
{ required: true, message: '邮箱地址不能为空', trigger: 'blur' },
{ type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
],
phonenumber: [
{ required: true, message: '手机号码不能为空', trigger: 'blur' },
{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请输入正确的手机号码', trigger: 'blur' }
]
})
const subjectList = ref([]);
const subjectList = ref([])
function handleclick1() {
console.log(props.user.edudegree)
}
//
listEvaluation({ itemkey: "subject", pageSize: 500 }).then((res) => {
subjectList.value = res.rows;
});
setTimeout(() => {
//
listEvaluation({ itemkey: 'subject', pageSize: 500 }).then((res) => {
subjectList.value = res.rows
})
setTimeout(() => {
if (props.user.edudegree != '') {
var upcaseName = ['一年级', '二年级', '三年级', '四年级', '五年级', '六年级', '初一', '初二', '初三', '高一', '高二', '高三'];
var d = parseInt(props.user.edudegree.replace('年级', ''));
var upcaseName = [
'一年级',
'二年级',
'三年级',
'四年级',
'五年级',
'六年级',
'初一',
'初二',
'初三',
'高一',
'高二',
'高三'
]
var d = parseInt(props.user.edudegree.replace('年级', ''))
if (d <= 6) {
props.user.edustage = '小学';
props.user.edustage = '小学'
} else if (d >= 7 && d <= 9) {
props.user.edustage = '初中';
props.user.edustage = '初中'
} else if (d >= 9 && d <= 12) {
props.user.edustage = '高中';
props.user.edustage = '高中'
}
props.user.stagelabel = upcaseName[d-1];
props.user.stagelabel = upcaseName[d - 1]
}
}, 1000);
}, 1000)
/** 提交按钮 */
function submit() {
proxy.$refs.userRef.validate(valid => {
/** 提交按钮 */
function submit() {
proxy.$refs.userRef.validate((valid) => {
if (valid) {
console.log(props.user);
updateUserProfile(props.user).then(response => {
proxy.$modal.msgSuccess("修改成功");
});
console.log(props.user)
updateUserProfile(props.user).then((response) => {
proxy.$modal.msgSuccess('修改成功')
})
}
});
};
</script>
})
}
</script>