diff --git a/src/renderer/src/components/choose-textbook/index.vue b/src/renderer/src/components/choose-textbook/index.vue
index 7f3c178..5b5cf59 100644
--- a/src/renderer/src/components/choose-textbook/index.vue
+++ b/src/renderer/src/components/choose-textbook/index.vue
@@ -6,7 +6,7 @@
-
@@ -109,6 +109,8 @@ const getSubjectContent = async () => {
evaluationList.value = JSON.parse(localStorage.getItem('evaluationList'))
}
else{
+ localStorage.removeItem('defaultExpandedKeys')
+ localStorage.removeItem('currentNodeId')
const { rows } = await listEvaluation(params)
localStorage.setItem('evaluationList', JSON.stringify(rows))
evaluationList.value = rows
@@ -134,6 +136,10 @@ const changeBook = ({ id, itemtitle, avartar, fileurl }) => {
curBookName.value = itemtitle
curBookImg.value = BaseUrl + avartar
curBookPath.value = fileurl
+
+ localStorage.removeItem('defaultExpandedKeys')
+ localStorage.removeItem('currentNodeId')
+ localStorage.setItem('curBook', JSON.stringify({id, itemtitle, avartar, fileurl}))
getTreeData()
setTimeout(() => {
dialogVisible.value = false
@@ -144,7 +150,6 @@ const getTreeData = () => {
//数据过滤
let upData = transData(evaluationList.value)
-
if(upData.length){
treeData.value = [...upData]
}
@@ -153,10 +158,22 @@ const getTreeData = () => {
return
}
nextTick(() => {
- defaultExpandedKeys.value = [treeData.value[0].id]
- currentNode.data = getLastLevelData(treeData.value)[0]
- currentNodeId.value = getLastLevelData(treeData.value)[0].id
- currentNodeName.value = getLastLevelData(treeData.value)[0].label
+
+ let defaultCurNodeId = localStorage.getItem('currentNodeId')
+ if(defaultCurNodeId){
+ defaultCurNodeId = JSON.parse(defaultCurNodeId)
+ const data = findNode(defaultCurNodeId)
+ currentNode.data = findNode(defaultCurNodeId)
+ currentNodeId.value = data.id
+ currentNodeName.value = data.label
+ }
+ else{
+ defaultExpandedKeys.value = [treeData.value[0].id]
+ currentNode.data = getLastLevelData(treeData.value)[0]
+ currentNodeId.value = getLastLevelData(treeData.value)[0].id
+ currentNodeName.value = getLastLevelData(treeData.value)[0].label
+ }
+
emitChangeBook()
})
@@ -183,6 +200,9 @@ const emitChangeBook = () => {
},
node: curNode
}
+
+ localStorage.setItem('defaultExpandedKeys', JSON.stringify(defaultExpandedKeys.value))
+ localStorage.setItem('currentNodeId', JSON.stringify(currentNodeId.value))
emit('changeBook', data)
}
@@ -230,6 +250,11 @@ const findParentByChildId = (treeData, targetNodeId) => {
return null;
}
+const findNode = (id) =>{
+ if(!id) return
+ return evaluationList.value.find( item => item.id == id)
+}
+
const transData = (data) => {
let ary = []
data.forEach(item => {
@@ -281,10 +306,21 @@ const getSubject = async () => {
// 默认第一个
if(!subjectList.value.length) return
- curBookName.value = subjectList.value[0].itemtitle
- curBookId.value = subjectList.value[0].id
- curBookImg.value = BaseUrl + subjectList.value[0].avartar
- curBookPath.value = subjectList.value[0].fileurl
+ let curBook = localStorage.getItem('curBook')
+ if(curBook){
+ curBook = JSON.parse(curBook)
+ curBookName.value = curBook.itemtitle
+ curBookId.value = curBook.id
+ curBookImg.value = BaseUrl + curBook.avartar
+ curBookPath.value = curBook.fileurl
+ }
+ else{
+ curBookName.value = subjectList.value[0].itemtitle
+ curBookId.value = subjectList.value[0].id
+ curBookImg.value = BaseUrl + subjectList.value[0].avartar
+ curBookPath.value = subjectList.value[0].fileurl
+ localStorage.setItem('curBookId', curBookId.value)
+ }
}
@@ -321,7 +357,12 @@ const handleNodeClick = (data, node) => {
node: toRaw(nodeData)
}
currentNode.data = curData
+
+ localStorage.setItem('defaultExpandedKeys', nodeData.parentNode ? JSON.stringify([parentNode.id]) : JSON.stringify([data.id]))
+ localStorage.setItem('currentNodeId', JSON.stringify(data.id))
+
emit('nodeClick', curData)
+
}
onMounted(() => {
getSubjectContent()
diff --git a/src/renderer/src/views/desktop/index.vue b/src/renderer/src/views/desktop/index.vue
index 95679c4..ae33213 100644
--- a/src/renderer/src/views/desktop/index.vue
+++ b/src/renderer/src/views/desktop/index.vue
@@ -85,7 +85,7 @@ const menuList = [{
// path: '/prepare'
// },
{
- name: '教学实施',
+ name: '教学实践',
icon: 'icon-jiaoxuefenxi',
path: '/prepare'
},