liyongli 1 vuosi sitten
vanhempi
commit
e9227803e2

+ 2 - 0
pnpm-lock.yaml

@@ -3839,6 +3839,7 @@ packages:
   /color-convert@2.0.1:
   /color-convert@2.0.1:
     resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
     resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
     engines: {node: '>=7.0.0'}
     engines: {node: '>=7.0.0'}
+    requiresBuild: true
     dependencies:
     dependencies:
       color-name: 1.1.4
       color-name: 1.1.4
     dev: true
     dev: true
@@ -5994,6 +5995,7 @@ packages:
   /has-flag@4.0.0:
   /has-flag@4.0.0:
     resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
     resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
     engines: {node: '>=8'}
     engines: {node: '>=8'}
+    requiresBuild: true
     dev: true
     dev: true
 
 
   /has-property-descriptors@1.0.0:
   /has-property-descriptors@1.0.0:

+ 20 - 15
src/view/allMedia/imageProcessing/index.vue

@@ -138,7 +138,7 @@ import header_local from '../components/header.vue';
 import { UploadFilled } from '@element-plus/icons-vue';
 import { UploadFilled } from '@element-plus/icons-vue';
 import { ElMessage, genFileId } from 'element-plus';
 import { ElMessage, genFileId } from 'element-plus';
 import { storeImg, historyImg, deleteRowImage } from '@/api/processing';
 import { storeImg, historyImg, deleteRowImage } from '@/api/processing';
-import { ref } from 'vue';
+import { ref,onUnmounted } from 'vue';
 import config from '../../../config/index';
 import config from '../../../config/index';
 import { useRouter } from 'vue-router';
 import { useRouter } from 'vue-router';
 const route = useRouter();
 const route = useRouter();
@@ -164,6 +164,21 @@ const status = {
 };
 };
 
 
 const tableData = ref([]);
 const tableData = ref([]);
+
+const getList = () => {
+  historyImg({
+    data: page_data.value
+  }).then(r => {
+    tableData.value = (r.records || []).map(v => {
+      return {
+        ...v,
+        createTime: v.createTime.replace('T', ' ')
+      };
+    });
+    page_data.value.total = r.total;
+  });
+};
+window.processing_getList = getList;
 getList();
 getList();
 
 
 function upProgress(par) {
 function upProgress(par) {
@@ -214,20 +229,6 @@ function upSuccess(res) {
   });
   });
 }
 }
 
 
-function getList() {
-  historyImg({
-    data: page_data.value
-  }).then(r => {
-    tableData.value = (r.records || []).map(v => {
-      return {
-        ...v,
-        createTime: v.createTime.replace('T', ' ')
-      };
-    });
-    page_data.value.total = r.total;
-  });
-}
-
 function detail(row) {
 function detail(row) {
   sessionStorage.setItem('Processing_detail', JSON.stringify(row));
   sessionStorage.setItem('Processing_detail', JSON.stringify(row));
   route.push({
   route.push({
@@ -246,6 +247,10 @@ function deleteRow(row) {
     ElMessage.success('删除成功');
     ElMessage.success('删除成功');
   });
   });
 }
 }
+
+onUnmounted(() => {
+  window.processing_getList = undefined;
+});
 </script>
 </script>
 
 
 <style>
 <style>

+ 50 - 25
src/view/allMedia/main.vue

@@ -23,19 +23,22 @@
         {{ item.title }}
         {{ item.title }}
       </div>
       </div>
     </div>
     </div>
-    <router-view class="rightMain" />
+    <router-view :isUp="isUp" class="rightMain" />
   </div>
   </div>
 </template>
 </template>
 
 
 <script setup>
 <script setup>
 // import header_local from './components/header.vue';
 // import header_local from './components/header.vue';
 import { ref } from 'vue';
 import { ref } from 'vue';
-import { ElMessage } from 'element-plus';
+import { ElNotification } from 'element-plus';
 import { useRoute, useRouter } from 'vue-router';
 import { useRoute, useRouter } from 'vue-router';
+import config from '../../config/index';
 
 
 const Router = useRouter();
 const Router = useRouter();
 const Route = useRoute();
 const Route = useRoute();
 const selectMenu = ref(Route.fullPath);
 const selectMenu = ref(Route.fullPath);
+const isUp = ref(0);
+let eventSource = null;
 
 
 const menu = JSON.parse(localStorage.getItem('menu') || '[]');
 const menu = JSON.parse(localStorage.getItem('menu') || '[]');
 
 
@@ -64,32 +67,54 @@ const selectMenuFunc = item => {
  * 3 如果用户还没有作出选择,返回值为default;
  * 3 如果用户还没有作出选择,返回值为default;
  */
  */
 function notificationFunc() {
 function notificationFunc() {
-  if (!Notification) return;
-  if (Notification.permission == 'denied') return;
-  if (Notification.permission === 'default') Notification.requestPermission();
+  return new Promise((resolve, reject) => {
+    if (!Notification) return resolve(false);
+    if (Notification.permission === 'granted') {
+      resolve(true);
+    } else {
+      Notification.requestPermission().then(() => {
+        resolve(true);
+      });
+    }
+  });
+}
+function sse() {
+  eventSource = new EventSource(
+    config.base.videoProcessing +
+      '/user/sse?token=' +
+      localStorage.getItem('token')
+  );
+  eventSource.addEventListener('message', event => {
+    // 处理来自服务器的消息
+    const data = JSON.parse(event.data);
+    isUp.value += 1;
+    window.processing_getList && window.processing_getList();
+    if (Notification) {
+      new Notification('提示', {
+        body: data.msg,
+        icon: '' // 可选的图标路径
+      });
+      return;
+    }
+
+    ElNotification({
+      title: '提示',
+      message: data.msg,
+      duration: 0
+    });
+  });
 
 
-  const permission = {
-    denied: '拒绝授权',
-    granted: '同意授权',
-    default: '不明授权'
+  eventSource.onerror = error => {
+    // 处理错误
+    console.error(error);
+    eventSource.close();
+    // sse();
   };
   };
-
-  console.log(permission[Notification.permission]);
-
-  //   if (Notification.permission === 'granted') {
-  //     // 如果用户允许系统提醒,则创建一个通知
-  //     var notification = new Notification('这是一个系统提醒', {
-  //       body: '这是提醒的正文内容',
-  //       icon: 'path/to/icon.png' // 可选的图标路径
-  //     });
-
-  //     // 可以在通知被点击时执行一些操作
-  //     notification.onclick = function () {
-  //       console.log('用户点击了系统提醒');
-  //     };
-  //   }
 }
 }
-notificationFunc();
+
+notificationFunc().then(isTrue => {
+  sse();
+});
 </script>
 </script>
 
 
 <style scoped>
 <style scoped>

+ 19 - 17
src/view/allMedia/videoProcessing/index.vue

@@ -158,11 +158,26 @@ const status = {
   REVIEW: 'warning',
   REVIEW: 'warning',
   NORMAL: 'success'
   NORMAL: 'success'
 };
 };
+
+const getList = () => {
+  historyVideo({
+    data: page_data.value
+  }).then(r => {
+    tableData.value = (r.records || []).map(v => {
+      return {
+        ...v,
+        createTime: v.createTime.replace('T', ' ')
+      };
+    });
+    page_data.value.total = r.total;
+  });
+};
+window.processing_getList = getList;
 getList();
 getList();
 
 
 function upProgress(par) {
 function upProgress(par) {
   // 上传进度
   // 上传进度
-  console.log(par);
+//   console.log(par);
 }
 }
 
 
 function handleExceed(files) {
 function handleExceed(files) {
@@ -202,20 +217,6 @@ function submit() {
     });
     });
 }
 }
 
 
-function getList() {
-  historyVideo({
-    data: page_data.value
-  }).then(r => {
-    tableData.value = (r.records || []).map(v => {
-      return {
-        ...v,
-        createTime: v.createTime.replace('T', ' ')
-      };
-    });
-    page_data.value.total = r.total;
-  });
-}
-
 function detail(row) {
 function detail(row) {
   sessionStorage.setItem('Processing_detail', JSON.stringify(row));
   sessionStorage.setItem('Processing_detail', JSON.stringify(row));
   route.push({
   route.push({
@@ -238,8 +239,9 @@ function deleteRow(row) {
   });
   });
 }
 }
 
 
-
-onUnmounted(() => {});
+onUnmounted(() => {
+  window.processing_getList = undefined;
+});
 
 
 // var notification = new Notification('这是一个系统提醒', {
 // var notification = new Notification('这是一个系统提醒', {
 //   body: '这是提醒的正文内容',
 //   body: '这是提醒的正文内容',