优化woker

This commit is contained in:
24kycj
2024-12-02 12:55:52 +08:00
parent ba2579642d
commit dd7bce6b40
5 changed files with 266 additions and 70 deletions
+55 -26
View File
@@ -5,53 +5,56 @@
</template>
<script>
const dayjs = require('dayjs')
export default {
name: 'App',
mounted() {
if (this.$store.getters.token) {
this.$store.dispatch('chat/initWebSocket') // 初始化websocket
let that = this
if (that.$store.getters.token) {
that.$store.dispatch('chat/initWebSocket') // 初始化websocket
}
},
watch: {
'$store.state.chat.printer_error': {
handler(val) {
console.log(val)
let that = this
const currentTime = dayjs().format('hh:mm:ss');
if (val.message) {
this.$message({
that.$message({
message: val.message,
type: val.type,
})
}
if (val.notify) {
this.$notify({
title: '温馨提示',
that.$notify({
title: '温馨提示' + currentTime,
message: val.notify,
type: val.type,
duration: 0
})
}
if (val.confirm) {
this.$confirm(val.confirm, '温馨提示', {
confirmButtonText: '重试',
closeOnClickModal: false,
closeOnPressEscape: false,
showClose: false,
type: 'warning'
}).then(() => {
if (val.req && val.req === 'continue_task') {
// 下一个任务
this.$store.dispatch('chat/websocketsend', {
req_name: 'continue_task',
req_type: 1,
req_info: {}
}).then(() => {
}).catch(() => {
})
that.$notify({
title: '温馨提示:' + currentTime,
duration: 0,
dangerouslyUseHTMLString: true,
message: `<div class="notify_text">${val.confirm}</div><div class="notify_btns"><div class="notify_btn notify_btn2" id="notifyAgain" data-type="continue_task">重试</div></div>`,
onClick(event) {
if (val.req && val.req === 'continue_task') {
// 下一个任务
that.$store.dispatch('chat/websocketsend', {
req_name: 'continue_task',
req_type: 1,
req_info: {}
}).then(() => {
}).catch(() => {
})
}
this.close()
}
}).catch(() => {
});
}
},
@@ -64,4 +67,30 @@ export default {
</script>
<style lang="scss">
@use './styles/index.scss'; // 全局自定义的css样式
.el-notification__group {
width: 100%;
}
.notify_btns{
display: flex;
align-items: center;
justify-content: end;
padding: 10px 0 0;
gap: 14px;
.notify_btn {
width: 60px;
height: 30px;
line-height: 30px;
text-align: center;
font-size: 14px;
border-radius: 4px;
cursor: pointer;
}
.notify_btn1 {
border: 1px solid #ccc;
}
.notify_btn2 {
background-color: #409EFF;
color: #fff;
}
}
</style>