Commit d9b5230d authored by chenghong_tao's avatar chenghong_tao

fix session store and loading don't resatrt

parent cf2005b2
...@@ -18,13 +18,15 @@ ...@@ -18,13 +18,15 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, onMounted, nextTick } from 'vue' import { ref, onMounted, nextTick, onUnmounted, onBeforeUnmount } from 'vue'
import Chat from './Chat.vue' import Chat from './Chat.vue'
import HistoryList from './HistoryList.vue' import HistoryList from './HistoryList.vue'
import difyApi from '../apis/difyApi' import difyApi from '../apis/difyApi'
import { useAppStore } from '../store/app' import { useAppStore } from '../store/app'
import { useTaskStore } from '../store/task'
const appStore = useAppStore() const appStore = useAppStore()
const taskStore = useTaskStore()
const chatRef = ref(null) const chatRef = ref(null)
const sideBarHidden = ref(false) const sideBarHidden = ref(false)
const getSideBarStatus = (status) => { const getSideBarStatus = (status) => {
...@@ -89,9 +91,18 @@ const getUserId = () => { ...@@ -89,9 +91,18 @@ const getUserId = () => {
} }
} }
const clearTaskStore = (event) => {
taskStore.clear()
}
onMounted(() => { onMounted(() => {
initAppInfo() initAppInfo()
getUserId() getUserId()
window.addEventListener('beforeunload', clearTaskStore);
})
onBeforeUnmount(() => {
window.removeEventListener('beforeunload', clearTaskStore);
}) })
</script> </script>
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
:icon="Refresh" :icon="Refresh"
size="small" size="small"
circle circle
:disabled="isLoading"
@click="reStartSSE" @click="reStartSSE"
/> />
<el-button <el-button
......
...@@ -22,5 +22,8 @@ export const useAppStore = defineStore('app', { ...@@ -22,5 +22,8 @@ export const useAppStore = defineStore('app', {
this.userId = userId this.userId = userId
} }
}, },
persist: true persist: {
key: 'app',
storage: sessionStorage
}
}) })
\ No newline at end of file
...@@ -31,5 +31,8 @@ export const useTaskStore = defineStore('task', { ...@@ -31,5 +31,8 @@ export const useTaskStore = defineStore('task', {
this.workflow_run_id = '' this.workflow_run_id = ''
} }
}, },
persist: true persist: {
key: 'task',
storage: sessionStorage
}
}) })
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment