zhuhao_dev #33

Merged
zhuhao merged 8 commits from zhuhao_dev into main 2024-07-17 21:25:06 +08:00
13 changed files with 276 additions and 41 deletions
Showing only changes of commit 36989c5ba3 - Show all commits

View File

@ -8,8 +8,8 @@ File({ app, shell, BrowserWindow, ipcMain })
function createWindow() { function createWindow() {
// Create the browser window. // Create the browser window.
const mainWindow = new BrowserWindow({ const mainWindow = new BrowserWindow({
width: 1050, width: 888,
height: 650, height: 520,
show: false, show: false,
frame: false, frame: false,
autoHideMenuBar: true, autoHideMenuBar: true,
@ -107,4 +107,5 @@ ipcMain.on('close-window', () => {
ipcMain.on('set-winsize', (e, {x, y})=>{ ipcMain.on('set-winsize', (e, {x, y})=>{
const win = BrowserWindow.getFocusedWindow(); const win = BrowserWindow.getFocusedWindow();
win.setSize(x,y); win.setSize(x,y);
win.center()
}) })

View File

@ -8,7 +8,6 @@
import { ref } from 'vue' import { ref } from 'vue'
const size = ref('default') const size = ref('default')
// const size = computed(() => store.state.app.elementSize)
</script> </script>
<style> <style>

View File

@ -8,3 +8,12 @@ export const listEvaluation = (params)=> {
params params
}) })
} }
export const addFileToPrepare = (params) => {
return request({
url: '/smarttalk/file/addFileToPrepare',
method: 'post',
params
})
}

View File

@ -38,3 +38,12 @@ export function getUserProfile() {
data: data data: data
}) })
} }
// 修改用户,这个不涉及到用户的权限、角色更新
export function updateUserInfo(data) {
return request({
url: '/system/user/updateUserInfo',
method: 'put',
data: data
})
}

View File

@ -305,6 +305,7 @@ onMounted(() => {
border-bottom: solid #f4f5f7 1px; border-bottom: solid #f4f5f7 1px;
font-size: 15px; font-size: 15px;
font-weight: 600; font-weight: 600;
border-radius: 10px 10px 0 0;
} }
.book-list { .book-list {

View File

@ -0,0 +1,149 @@
<template>
<el-dialog v-model="dialogVisible" append-to-body :show-close="false" width="500"
top="25vh"
:close-on-click-modal="false"
:close-on-press-escape="false"
style="border-radius: 5px;padding-top: 0;">
<div class="dialog-title flex">
<span>选择你的年级学科</span>
</div>
<div class="dialog-content">
<el-form :inline="true">
<el-form-item label="年级">
<el-select v-model="gradeVal" style="width: 120px;" @change="changeGrade">
<el-option v-for="item in gradeList" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="学科">
<el-select v-model="subjectVal" style="width: 130px;">
<el-option v-for="item in subjectList" :key="item.id" :label="item.itemtitle" :value="item.itemtitle" />
</el-select>
</el-form-item>
</el-form>
</div>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="editUserInfo">
确定
</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import { ref, onMounted, watch, defineProps, defineEmits } from 'vue'
import { listEvaluation } from '@/api/subject'
import { updateUserInfo } from '@/api/system/user'
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
const { userId, userName } = userStore.user
const props = defineProps({
modelValue: {
type: Boolean,
default: false
},
})
// emit
const emit = defineEmits(['update:modelValue', 'onSuccess'])
const gradeList = ref([
{
label: '高中',
value: '高中'
},
{
label: '初中',
value: '初中'
},
{
label: '小学',
value: '小学'
},
{
label: '幼儿园',
value: '幼儿园'
},
]
)
const subjectVal = ref('')
const gradeVal = ref('')
//
gradeVal.value = gradeList.value[0].value
//
const subjectList = ref([])
const allSubject = ref([])
const dialogVisible = ref(false)
watch(() => props.modelValue, (newVal) => {
dialogVisible.value = newVal
})
//
const changeGrade = ()=>{
//
subjectList.value = allSubject.value.filter( item => item.edustage == gradeVal.value)
if(!subjectList.value.length){
subjectVal.value = ''
return
}
//
subjectVal.value = subjectList.value[0].itemtitle
}
//
const getSubject = async ()=>{
const { rows } = await listEvaluation({ itemkey: "subject", pageSize: 500 })
//
allSubject.value = rows;
// (gradeVal)
subjectList.value = rows.filter( item => item.edustage == gradeVal.value)
if(!subjectList.value.length) return
//
subjectVal.value = subjectList.value[0].itemtitle
}
//
const editUserInfo = async () =>{
const data = {
userId,
userName,
edustage: subjectVal.value,
edusubject: gradeVal.value
}
await updateUserInfo(data)
await userStore.getInfo()
emit('onSuccess')
}
onMounted(getSubject)
</script>
<style lang="scss" scoped>
.dialog-title {
justify-content: space-between;
font-size: 16px;
font-weight: 600;
color: #000;
.icon-close {
cursor: pointer;
}
}
.dialog-content {
padding: 30px 20px 10px 30px;
}
.dialog-footer{
text-align: center;
padding-bottom: 10px;
}
</style>

View File

@ -17,6 +17,9 @@ import Uploader from './components/Uploader.vue'
import uploaderState from '@/store/modules/uploader' import uploaderState from '@/store/modules/uploader'
import { ref } from 'vue' import { ref } from 'vue'
let uploaderStore = ref(uploaderState()) let uploaderStore = ref(uploaderState())
const { ipcRenderer } = window.electron || {}
ipcRenderer ? ipcRenderer .send('set-winsize', { x: 1200, y: 700 }) : ''
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -12,7 +12,7 @@ export const constantRoutes = [
{ {
path: '/', path: '/',
component: Layout, component: Layout,
redirect: '/resource', redirect: '/login',
children: [ children: [
{ {
path: '/resource', path: '/resource',

View File

@ -33,6 +33,8 @@
</el-form> </el-form>
</div> </div>
</div> </div>
<!--选择学科-->
<SelectSubject v-model="isSubject" v-if="isSubject" class="select-subject" @onSuccess="successEditSubject" />
</template> </template>
<script setup> <script setup>
import { onMounted, reactive, ref } from 'vue' import { onMounted, reactive, ref } from 'vue'
@ -42,13 +44,15 @@ import Cookies from 'js-cookie'
import { encrypt, decrypt } from '@/utils/jsencrypt' import { encrypt, decrypt } from '@/utils/jsencrypt'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import leftBg2 from '@/assets/images/login/left-bg2.png' import leftBg2 from '@/assets/images/login/left-bg2.png'
import SelectSubject from '@/components/select-subject/index.vue'
const { ipcRenderer } = window.electron || {}
const formRef = ref() const formRef = ref()
const userStore = useUserStore() const userStore = useUserStore()
const router = useRouter() const router = useRouter()
const { ipcRenderer } = window.electron || {}
const isMaxSize = ref(false) const isMaxSize = ref(false)
const btnLoading = ref(false) const btnLoading = ref(false)
const isSubject = ref(false)
// //
const loginForm = reactive({ const loginForm = reactive({
username: '', username: '',
@ -61,6 +65,8 @@ const rules = reactive({
password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }] password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }]
}) })
ipcRenderer ? ipcRenderer.send('set-winsize', { x: 888, y: 520 }) : ''
// //
const submitForm = async (formEl) => { const submitForm = async (formEl) => {
if (!formEl) return if (!formEl) return
@ -81,8 +87,14 @@ const submitForm = async (formEl) => {
try{ try{
await userStore.login(loginForm) await userStore.login(loginForm)
await userStore.getInfo() await userStore.getInfo()
if(userStore.user.edustage || userStore.user.edusubject){
ElMessage.success('登录成功') ElMessage.success('登录成功')
router.push('/resource') router.push('/resource')
}
else{
isSubject.value = true
}
}finally{ }finally{
btnLoading.value = false btnLoading.value = false
@ -91,6 +103,12 @@ const submitForm = async (formEl) => {
}) })
} }
const successEditSubject = ()=>{
isSubject.value = false
ElMessage.success('登录成功')
router.push('/resource')
}
const getCookie = () => { const getCookie = () => {
const username = Cookies.get('username') const username = Cookies.get('username')
const password = Cookies.get('password') const password = Cookies.get('password')
@ -101,7 +119,6 @@ const getCookie = () => {
} }
onMounted(()=>{ onMounted(()=>{
// ipcRenderer.send('set-winsize',{x:888,y: 520})
getCookie() getCookie()
}) })
// //
@ -206,4 +223,7 @@ const closeWindow = () => {
.el-form-item { .el-form-item {
margin-bottom: 40px; margin-bottom: 40px;
} }
.select-subject{
-webkit-app-region: drag;
}
</style> </style>

View File

@ -5,12 +5,12 @@
<ul> <ul>
<li class="list-item" v-for="item in sourceStore.result.list" :key="item.id"> <li class="list-item" v-for="item in sourceStore.result.list" :key="item.id">
<div class="item-left flex"> <div class="item-left flex">
<FileImage :fileName="item.fileName" :size="50" /> <FileImage :fileName="item.fileShowName" :size="50" />
<div class="flex item-left-content"> <div class="flex item-left-content">
<div class="name flex">{{ item.fileShowName }}</div> <div class="name flex">{{ item.fileShowName }}</div>
<div class="item-tags flex"> <div class="item-tags flex">
<el-tag type="info" class="mr-10">{{ item.fileFlag }}</el-tag> <el-tag type="info" class="mr-10">{{ item.fileFlag }}</el-tag>
<el-tag type="info" class="mr-10">{{ getFileSuffix(item.fileName) }}</el-tag> <el-tag type="info" class="mr-10">{{ getFileSuffix(item.fileShowName) }}</el-tag>
<span class="gray-text mr-10">{{ item.uploadTime }}上传</span> <span class="gray-text mr-10">{{ item.uploadTime }}上传</span>
<!-- <span class="line mr-10"></span> <!-- <span class="line mr-10"></span>
<span class="gray-text mr-10">下载3次</span> --> <span class="gray-text mr-10">下载3次</span> -->
@ -37,15 +37,11 @@
<i class="iconfont icon-xiazai"></i> <i class="iconfont icon-xiazai"></i>
<span>下载</span> <span>下载</span>
</div> </div>
<div class="item-popover-item" @click="moveFile(item)">
<i class="iconfont icon-xiazai"></i>
<span>移动至</span>
</div>
</div> </div>
</template> </template>
</el-popover> </el-popover>
<el-button size="small" plain round type="primary" @click="addLesson(item)">
<el-button size="small" plain round type="primary">
<i class="iconfont icon-jiahao"></i> <i class="iconfont icon-jiahao"></i>
备课</el-button> 备课</el-button>
</div> </div>
@ -63,23 +59,32 @@
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { toRaw } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import FileImage from '@/components/file-image/index.vue' import FileImage from '@/components/file-image/index.vue'
import { deleteSmarttalk, updateSmarttalk } from '@/api/file' import { deleteSmarttalk, updateSmarttalk } from '@/api/file'
import { addFileToPrepare } from '@/api/subject'
import { getFileSuffix } from '@/utils/ruoyi' import { getFileSuffix } from '@/utils/ruoyi'
import useResoureStore from '../store' import useResoureStore from '../store'
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
const sourceStore = useResoureStore() const sourceStore = useResoureStore()
const handleSizeChange = () => { }
const handleCurrentChange = () => { } // change
const handleSizeChange = (limit) => {
sourceStore.query.pageSize = limit
sourceStore.handleQuery()
}
const handleCurrentChange = (page) => {
sourceStore.query.pageNum = page
sourceStore.handleQuery()
}
// //
const downloadFile = (item) => { const downloadFile = (item) => {
ipcRenderer.send('save-as', item.fileFullPath, item.fileShowName) ipcRenderer.send('save-as', item.fileFullPath, item.fileShowName)
} }
//
const editRow = (item) => { const editRow = (item) => {
console.log(item.fileShowName.substring(0, item.fileShowName.lastIndexOf('.'))) console.log(item.fileShowName.substring(0, item.fileShowName.lastIndexOf('.')))
ElMessageBox.prompt('请输入新的名称', '重命名', { ElMessageBox.prompt('请输入新的名称', '重命名', {
@ -114,10 +119,31 @@ const delRow = (item) => {
} }
} }
// //
const moveFile = (item) => { const addLesson = ({ id }) => {
moveDialogVisible.value = true let data = {
id,
fileRoot: '资源',
...(toRaw(sourceStore.nodeData)),
} }
//
for (let key in data) {
if (!data[key]) {
delete data[key]
}
}
try {
sourceStore.loading = true
addFileToPrepare(data).then(() => {
ElMessage.success('操作成功')
})
}
finally {
sourceStore.loading = false
}
}
</script> </script>

View File

@ -13,8 +13,8 @@
</el-row> </el-row>
<el-row class="resoure-btns"> <el-row class="resoure-btns">
<el-col :span="24" class="query-row flex"> <el-col :span="24" class="query-row flex">
<div class="flex row-left"> <el-select v-model="sourceStore.query.fileSuffix" <div class="flex row-left"> <el-select v-model="sourceStore.query.fileSuffix" @change="sourceStore.changeSuffix"
style="width: 100px"> style="width: 110px">
<el-option v-for="item in sourceStore.resourceFormatList" :key="item.value" :label="item.label" <el-option v-for="item in sourceStore.resourceFormatList" :key="item.value" :label="item.label"
:value="item.value" /> :value="item.value" />
</el-select> </el-select>

View File

@ -16,7 +16,6 @@
</div> </div>
<!-- 上传弹窗 --> <!-- 上传弹窗 -->
<uploadDialog v-model="isDialogOpen" @submitFile="submitFile" /> <uploadDialog v-model="isDialogOpen" @submitFile="submitFile" />
<!-- <MoveFile v-model="isDialogOpen" @onSubmit="onSubmit" /> -->
</template> </template>
<script setup> <script setup>
@ -26,14 +25,11 @@ import ChooseTextbook from '@/components/choose-textbook/index.vue'
import ResoureSearch from './container/resoure-search.vue' import ResoureSearch from './container/resoure-search.vue'
import ResoureList from './container/resoure-list.vue' import ResoureList from './container/resoure-list.vue'
import uploadDialog from '@/components/upload-dialog/index.vue' import uploadDialog from '@/components/upload-dialog/index.vue'
import MoveFile from '@/components/move-file/index.vue'
import uploaderState from '@/store/modules/uploader' import uploaderState from '@/store/modules/uploader'
const sourceStore = useResoureStore() const sourceStore = useResoureStore()
const isDialogOpen = ref(false) const isDialogOpen = ref(false)
const { ipcRenderer } = window.electron || {}
// ipcRenderer.send('set-winsize',{x:1100,y: 700})
const openDialog = () => { const openDialog = () => {
isDialogOpen.value = true isDialogOpen.value = true
@ -55,24 +51,32 @@ const nodeClick = (data) => {
// //
const getData = (data) => { const getData = (data) => {
const { textBook, node } = data const { textBook, node } = data
let textBookId = textBook.curBookId
let textbookId = textBook.curBookId
console.log(textbookId)
let levelFirstId = node.id let levelFirstId = node.id
let levelSecondId = node.parentNode ? node.parentNode.id : '' let levelSecondId = node.parentNode ? node.parentNode.id : ''
sourceStore.query = { sourceStore.query = {
textBookId,
levelFirstId, levelFirstId,
levelSecondId, levelSecondId,
...sourceStore.query ...sourceStore.query
} }
sourceStore.query.textbookId = textbookId
sourceStore.nodeData = {
textbookId,
levelFirstId,
levelSecondId,
}
sourceStore.handleQuery() sourceStore.handleQuery()
} }
// //
const submitFile = (data) => { const submitFile = (data) => {
let fileList = toRaw(data) let fileList = toRaw(data)
const { textBookId, levelFirstId, levelSecondId, fileSource, fileRoot } = sourceStore.query const { textbookId, levelFirstId, levelSecondId, fileSource, fileRoot } = sourceStore.query
// //
let fileData = { textBookId, levelFirstId, levelSecondId, fileSource, fileRoot } let fileData = { textbookId, levelFirstId, levelSecondId, fileSource, fileRoot }
fileList.forEach(item => { fileList.forEach(item => {
fileData.fileShowName = item.fileData.fileShowName fileData.fileShowName = item.fileData.fileShowName
fileData.fileFlag = item.fileData.fileFlag fileData.fileFlag = item.fileData.fileFlag

View File

@ -15,7 +15,7 @@ const resourceTypeList = [
const resourceFormatList = [ const resourceFormatList = [
{ {
label: '资源格式', label: '资源格式',
value: '' value: -1
}, },
...resourceFormat ...resourceFormat
] ]
@ -42,11 +42,17 @@ export default defineStore('resource', {
searchKey: '', searchKey: '',
// 新建资源 // 新建资源
isCreate: false, isCreate: false,
//节点数据
nodeData:{},
loading: false, loading: false,
//查询条件 //查询条件
query: { query: {
textbookId: '',
fileSource: '平台', fileSource: '平台',
fileSuffix: '', //资源格式 mp3 ppt ...
fileSuffix: -1,
// 资源类型 课件 素材 教案
fileFlag: '', fileFlag: '',
fileRoot: '资源', fileRoot: '资源',
orderByColumn: 'uploadTime', orderByColumn: 'uploadTime',
@ -62,7 +68,11 @@ export default defineStore('resource', {
handleQuery() { handleQuery() {
try { try {
this.loading = true this.loading = true
getSmarttalkPage(this.query).then((res) => { let data = {...this.query}
if(data.fileSuffix == -1){
data.fileSuffix = ''
}
getSmarttalkPage(data).then((res) => {
this.result.total = res.total this.result.total = res.total
this.result.list = res.rows this.result.list = res.rows
}) })
@ -77,6 +87,10 @@ export default defineStore('resource', {
changeType(val) { changeType(val) {
this.query.fileFlag = val this.query.fileFlag = val
this.handleQuery() this.handleQuery()
},
changeSuffix(val){
this.query.fileSuffix = val
this.handleQuery()
} }
} }
}) })