Parcourir la source

远程打印(4个来源, 支持批量), 配网优化

“shengjie.huang” il y a 1 an
Parent
commit
5a4169c764

+ 1 - 0
package.json

@@ -102,6 +102,7 @@
     "@dcloudio/uni-mp-xhs": "3.0.0-4020920240930001",
     "@dcloudio/uni-quickapp-webview": "3.0.0-4020920240930001",
     "dayjs": "1.11.10",
+    "event-source-polyfill": "^1.0.31",
     "pinia": "2.0.36",
     "pinia-plugin-persistedstate": "3.2.1",
     "qs": "6.5.3",

+ 8 - 0
pnpm-lock.yaml

@@ -59,6 +59,9 @@ importers:
       dayjs:
         specifier: 1.11.10
         version: 1.11.10
+      event-source-polyfill:
+        specifier: ^1.0.31
+        version: 1.0.31
       pinia:
         specifier: 2.0.36
         version: 2.0.36(typescript@5.7.2)(vue@3.4.21(typescript@5.7.2))
@@ -3026,6 +3029,9 @@ packages:
     resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==}
     engines: {node: '>= 0.6'}
 
+  event-source-polyfill@1.0.31:
+    resolution: {integrity: sha512-4IJSItgS/41IxN5UVAVuAyczwZF7ZIEsM1XAoUzIHA6A+xzusEZUutdXz2Nr+MQPLxfTiCvqE79/C8HT8fKFvA==}
+
   eventemitter3@5.0.1:
     resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==}
 
@@ -9482,6 +9488,8 @@ snapshots:
 
   etag@1.8.1: {}
 
+  event-source-polyfill@1.0.31: {}
+
   eventemitter3@5.0.1: {}
 
   execa@5.1.1:

+ 8 - 0
src/pages.json

@@ -124,6 +124,14 @@
       "style": {
         "navigationBarTitleText": "上传文件"
       }
+    },
+    {
+      "path": "pages/webview/sse",
+      "type": "page",
+      "layout": "default",
+      "style": {
+        "navigationBarTitleText": "打印任务"
+      }
     }
   ],
   "subPackages": []

+ 11 - 22
src/pages/connect/index.vue

@@ -19,7 +19,7 @@
         <view v-if="currentWifi" class="check-result">{{ `设备当前连接WiFi: ${currentWifi}` }}</view>
         <wd-button @click="getConnectedWifi()">重新检查</wd-button>
       </view>
-      <view v-if="!checkWiFiFlag">{{ `请先连接WiFi:${targetWifi}` }}</view>
+      <view v-if="!checkWiFiFlag">{{ `请先连接以 "${targetWifi}" 开头的WiFi` }}</view>
     </view>
 
     <view class="form-title">
@@ -67,14 +67,13 @@
 </template>
 
 <script lang="ts" setup>
-import { getWifiStatus, getWifis, connectWifi } from '@/service/api/index'
+import { testConnect, getWifiStatus, getWifis, connectWifi } from '@/service/api/index'
 import { useToast } from 'wot-design-uni'
 
 const loading = ref(false)
 const deviceImg = ref('/static/images/device.png')
 const toast = useToast()
-const targetWifi = "maoer-printer-hub"
-// const targetWifi = "ZBA_1813"
+const targetWifi = "maoer-hub"
 const checkWiFiFlag = ref(false)
 const checkIPFlag = ref(false)
 // 设备当前连接的wifi
@@ -107,20 +106,12 @@ function getConnectedWifi(isFirst = false) {
     setTimeout(() => {
       uni.getConnectedWifi({
         success: (res) => {
-          // 示例
-          // {
-          //   BSSID: "08:9b:4b:11:ce:b6"
-          //   SSID: "ZBA_1813"
-          //   frequency: 5785
-          //   signalStrength: 99
-          // }
+          // 当前手机连接的wifi信息
           wifiInfo.value = res.wifi || {}
-          console.log('WiFi res: ', res.wifi);
           checkWifi()
           if (checkWiFiFlag.value) checkIP(isFirst)
         },
         fail: (err) => {
-          console.log('WiFi err: ', err);
           toast.error('获取WiFi信息失败')
         }
       })
@@ -129,12 +120,10 @@ function getConnectedWifi(isFirst = false) {
 }
 
 // 局域网通信: 检查IP地址是否请求成功
-function checkIP(isFirst: boolean) {
-  console.log("checkIP");
-  getWifiStatus().then((res: any) => {
-    console.log('当前连接WiFi: ', res);
-    currentWifi.value = res.body || ""
+function checkIP(isFirst: boolean = false) {
+  testConnect().then((res: any) => {
     checkIPFlag.value = true
+    getDeviceWifiStatus()
     if (isFirst) getWifiList()
   }).catch((err)=> {})
 }
@@ -142,23 +131,23 @@ function checkIP(isFirst: boolean) {
 // 局域网通信: 获取设备当前连接wifi
 function getDeviceWifiStatus() {
   getWifiStatus().then((res: any) => {
+    console.log('当前连接WiFi: ', res);
     currentWifi.value = res.body || ""
   }).catch((err)=> {})
 }
 
 // 局域网通信: 获取可连接wifi列表
 function getWifiList() {
+  toast.loading('加载无线列表中...')
   loading.value = true
-  uni.showLoading({
-    title: '加载无线列表中...'
-  });
   getWifis().then((res: any) => {
     console.log('wifi列表: ', res.body);
     wifiList.value = (res.body || []).filter((i: any) => i.ssid)
+    toast.success('已刷新无线列表')
   }).catch((err)=> {})
   .finally(() => {
     loading.value = false
-    uni.hideLoading()
+    toast.close()
   })
 }
 

+ 3 - 0
src/pages/login/index.vue

@@ -44,6 +44,7 @@ const qrToken = ref<string>('') // web端扫小程序码 登录带入的令牌
 async function init() {
   token.value = ""
   const code = await getLoginCode()
+  toast.loading("登录中...")
   let params = {
     code,
     qrToken: qrToken.value
@@ -73,6 +74,7 @@ async function init() {
 
 function handleToken(token) {
   if (token) {
+    toast.success("登录成功")
     useUserStore().setToken(token)
     // useUserStore().initUserInfo()
     uni.reLaunch({
@@ -116,6 +118,7 @@ function onGetPhoneNumber(detail) {
 
 // 根据code换取手机号, 进行绑定 (必须绑定)
 function handlePhoneNumberLogin(code) {
+  toast.loading("登录中...")
   let params = {
     code,
     token: token.value || '',

+ 2 - 2
src/pages/personal/index.vue

@@ -50,7 +50,7 @@
 import { logout } from '@/service/api/index'
 import { useUserStore } from '@/store'
 import { useToast } from 'wot-design-uni'
-import { toLogin } from '@/utils'
+import { toLogin, toLoginWait } from '@/utils'
 
 // 获取屏幕边界到安全区域距离
 const { safeAreaInsets } = uni.getSystemInfoSync()
@@ -95,7 +95,7 @@ function handleLogout() {
   // })
   useUserStore().clearUserInfo()
   toast.success('退出登录成功')
-  toLogin(1500)
+  toLoginWait(1500)
 }
 
 function initFn() {

+ 141 - 4
src/pages/print/index.vue

@@ -140,6 +140,7 @@
       </wd-cell-group>
 
       <view class="form-footer">
+        <!-- <wd-button type="success" size="large" block @click="connectSSE()">测试SSE</wd-button> -->
         <wd-button type="primary" size="large" block @click="handleSubmit()">确认打印</wd-button>
       </view>
     </wd-form>
@@ -153,7 +154,25 @@
 import { useToast, useMessage } from 'wot-design-uni'
 import { getUserHubPrints, getUserHubAttr, getInvoiceInfo, getInvoiceBatch } from '@/service/api'
 import { getEnvBaseUrl, redirectToUpload, reLaunchToHome } from '@/utils'
+import { useUserStore } from '@/store'
+// 基于小程序的 uni.request 方式改造 --- 可行
+// 基于 renderjs 仅支持APP和h5 
+// import { uniEventSource } from '@/utils/eventSourceRequest.js'
 
+// 开源项目js文件 给不支持该对象的浏览器提供兼容 v1.0.31
+// 编译报错 "EventSourcePolyfill" is not exported by "src/utils/eventsource.min.js"
+// import { EventSourcePolyfill } from "@/utils/eventsource.js";
+
+// 开源项目的 npm包管理 eventsource-polyfill  v0.9.6
+// 报错 Cannot read property 'XDomainRequest' of undefined
+// import { EventSourcePolyfill } from 'eventsource-polyfill';
+
+// event-source-polyfill  v1.0.31
+// 小程序环境缺少 xmlhttprequest 
+// import { EventSourcePolyfill } from 'event-source-polyfill';
+
+const userStore = useUserStore()
+const token = userStore.token
 const baseUrl = getEnvBaseUrl()
 const toast = useToast()
 const message = useMessage()
@@ -196,6 +215,9 @@ const srcMap = {
 }
 
 // SSE连接
+const finishList = ref([])
+const info = ref({})
+const eventSource: any = ref({})
 
 defineOptions({
   name: 'Print',
@@ -271,7 +293,7 @@ function selectFile() {
   switch(accept.value) {
     case "msg":
       uni.chooseMessageFile({
-        count: 1,
+        count: 10,
         type: "all",
         success (res) {
           console.log('chooseMessageFile res: ', res);
@@ -297,7 +319,7 @@ function selectFile() {
       break;
     case "image":
       uni.chooseImage({
-        count: 1,
+        count: 10,
         sourceType: ['album', 'camera'],
         sizeType: ['original', 'compressed'],
         extension: ['png', 'jpg', 'jpeg', 'gif', 'webp'],
@@ -460,7 +482,10 @@ function handlePrint(filePath) {
           toast.warning('上传打印异常, 请重试')
         }
       } else {
-        // 批量打印完成
+        // 批量打印 完成一个
+        finishList.value.push({
+          filePath,
+        })
       }
     },
     fail: (error) => {
@@ -482,10 +507,27 @@ function handleSubmit() {
   form.value.validate().then(({ valid }) => {
     if (valid) {
       // TODO: 批量打印提示
+      finishList.value = []
       if (fileList.value.length == 1) {
         handlePrint(fileList.value[0].filePath)
       } else {
-        message.alert(`本次打印文件 ${fileList.value.length} 个`)
+        message.confirm({
+          // msg: `本次打印文件 ${fileList.value.length} 个, ${fileList.value.length == finishList.value.length ? '已全部上传' : `正在上传第 ${finishList.value.length + 1} 个, 是否继续打印?`}`,
+          msg: `本次打印文件 ${fileList.value.length} 个, 是否继续打印?`,
+          closeOnClickModal: false,
+        }).then(() => {
+          fileList.value = []
+          printerOptions.value = []
+          formData.value = {
+            printer: ""
+          }
+          if (accept.value == "all") {
+            redirectToUpload()
+          }
+        }).catch((error) => {
+          reLaunchToHome()
+        })
+
         fileList.value.forEach(item => {
           handlePrint(item.filePath)
         })
@@ -513,6 +555,101 @@ function base64ToTempFilePath(fileName, base64Data, success, fail) {
   })
 }
 
+// 连接SSE
+function connectSSE() {
+  // 基于库 import { EventSourcePolyfill } from 'event-source-polyfill';
+  // 报错 小程序没有 xmlhttprequest
+  // const url = `https://service.1ai.ltd/maoer-api/print/see/connection?token=${token}`
+  // const eventSource = new EventSourcePolyfill(url);
+
+  // eventSource.onopen = (event) =>{
+  //   console.log("连接成功", event);
+  // };
+  // // 监听自定义事件 'update'
+  // eventSource.addEventListener('update', (event) => {
+  //   console.log('Update event:', event.data);
+  // });
+
+  // // 监听默认的 'message' 事件
+  // eventSource.onmessage = (event) => {
+  //   console.log('Message event:', event.data);
+  // };
+
+  // // 监听错误事件
+  // eventSource.onerror = (error) => {
+  //   console.error('EventSource encountered an error:', error);
+  // };
+
+
+
+  // 基于 .js / min.js 中的 EventSourcePolyfill
+  // 仅支持APP + H5 ?
+  // let url = `https://service.1ai.ltd/maoer-api/print/see/connection?token=${token}`
+  // eventSource.value = new EventSourcePolyfill(url, {
+  //   headers: {
+  //     "X-ACCESS-TOKEN": token,
+  //     "Content-Type": "text/event-stream;charset=UTF-8",
+  //     "Cache-Control": "no-cache",
+  //     Connection: "keep-alive",
+  //   },
+  //   //重连时间间隔,单位:毫秒,默认45000毫秒,这里设置为10分钟
+  //   heartbeatTimeout: 10 * 60 * 1000,
+  // });
+
+  // eventSource.value.onopen = () => {
+  //   console.log("建立连接");
+  // };
+  // eventSource.value.onmessage = (e) => {
+  //   console.log("接收到消息:", e);
+  // };
+  // eventSource.value.onerror = (e) => {
+  //   if (e.readyState == EventSource.CLOSED) {
+  //     console.log("连接关闭:", e);
+  //   } else if (eventSource.value.readyState == EventSource.CONNECTING) {
+  //     console.log("正在重连:", e);
+  //   } else {
+  //     console.log("其他异常:", e);
+  //   }
+  // };
+  
+
+  // 基于 renderjs 兼容性仅支持APP(vue) H5
+  // const eventSource = new EventSource(`https://service.1ai.ltd/maoer-api/print/see/connection?token=${token}`); // 确保这是你的服务器地址和端口
+  // eventSource.onmessage = (event) => {
+  //   const data = JSON.parse(event.data);
+  //   console.log('data: ', data);
+  //   // msgList.push(data); // 将接收到的消息添加到数据数组中
+  // };
+  // eventSource.onerror = (error) => {
+  //   console.error('EventSource failed:', error);
+  //   eventSource.close(); // 关闭连接并重新尝试连接等逻辑可以放在这里
+  // };
+
+  // 基于 uni.request
+  // let data = ""
+  // let format = ""
+  // let eventSource = uniEventSource({
+  //   url: `https://service.1ai.ltd/maoer-api/print/see/connection?token=${token}`,
+  //   data: {
+  //     data: data,
+  //     format: format
+  //   },
+  //   onopen: () => {
+  //     console.log("SERVER OPEN")
+  //   },
+  //   onmessage: (res) => {
+  //     console.log(res, "onMessage")
+  //   },
+  //   onerror: (err) => {
+  //     console.error(err)
+  //   },
+  //   onclose: () => {
+  //     console.log("SERVER CLOSE")
+  //   }
+  // })
+  // console.log("EVENTSOURCE::", eventSource)
+}
+
 onLoad((option) => {
   if (option && option.accept) {
     accept.value = option.accept

+ 1 - 1
src/pages/webview/index.vue

@@ -25,7 +25,7 @@ function handleMessage(data) {
 }
 
 onLoad((option) => {
-  if (option && option.url) url.value = decodeURIComponent(option.url)
+  if (option && option.url) url.value = decodeURIComponent(option.url) + "?t=" + new Date().getTime()
 })
 </script>
 

+ 25 - 0
src/pages/webview/sse.vue

@@ -0,0 +1,25 @@
+<route lang="json5" type="page">
+{
+  layout: 'default',
+  style: {
+    navigationBarTitleText: '打印任务',
+  },
+}
+</route>
+
+<template>
+  <view class="">
+    <web-view :src="url"></web-view>
+  </view>
+</template>
+
+<script lang="ts" setup>
+const url = ref("")
+
+onLoad((option) => {
+  if (option && option.url) url.value = decodeURIComponent(option.url) + "?t=" + new Date().getTime()
+})
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 7 - 0
src/service/api/index.ts

@@ -198,6 +198,13 @@ export const deleteUserHubJobs = (data) => {
  *  密码: 0123456789
  *  IP:   192.168.90.1 */
 
+export const testConnect = () => {
+  return http<any>({
+    url: "http://192.168.90.1:5002/api/test",
+    method: "GET",
+  })
+}
+
 export const getWifiStatus = () => {
   return http<any>({
     url: "http://192.168.90.1:5002/api/wifi-status",

+ 2 - 1
src/types/uni-pages.d.ts

@@ -15,7 +15,8 @@ interface NavigateToOptions {
        "/pages/print/jobDetail" |
        "/pages/printer/index" |
        "/pages/test/index" |
-       "/pages/webview/index";
+       "/pages/webview/index" |
+       "/pages/webview/sse";
 }
 interface RedirectToOptions extends NavigateToOptions {}
 

Fichier diff supprimé car celui-ci est trop grand
+ 1048 - 0
src/utils/eventsource.js


Fichier diff supprimé car celui-ci est trop grand
+ 6 - 0
src/utils/eventsource.min.js


+ 0 - 145
src/utils/formData.js

@@ -1,145 +0,0 @@
-import mimeMap from './mimeMap'
- 
-function FormData(){
-  let fileManager = wx.getFileSystemManager();
-  let data = {};
-  let files = [];
- 
-  this.append = (name, value)=>{
-    data[name] = value;
-    return true;
-  }
- 
-  this.appendFile = (name, path)=>{
-    let buffer = fileManager.readFileSync(path);
-    if(Object.prototype.toString.call(buffer).indexOf("ArrayBuffer") < 0){
-      return false;
-    }
-    files.push({
-      name: name,
-      buffer: buffer,
-      fileName: getFileNameFromPath(path)
-    });
-    return true;
-  }
- 
-  this.getData = ()=>convert(data, files)
-}
- 
-function getFileNameFromPath(path){
-  let idx=path.lastIndexOf("/");
-  return path.substr(idx+1);
-}
- 
-function convert(data, files){
-  let boundaryKey = 'wxmpFormBoundary' + randString(); // 数据分割符,一般是随机的字符串
-  let boundary = '--' + boundaryKey;
-  let endBoundary = boundary + '--';
- 
-  let postArray = [];
-  //拼接参数
-  if(data && Object.prototype.toString.call(data) == "[object Object]"){
-    for(let key in data){
-      postArray = postArray.concat(formDataArray(boundary, key, data[key]));
-    }
-  }
-  //拼接文件
-  if(files && Object.prototype.toString.call(files) == "[object Array]"){
-    for(let i in files){
-      let file = files[i];
-      postArray = postArray.concat(formDataArray(boundary, file.name, file.buffer, file.fileName));
-    }
-  }
-  //结尾
-  let endBoundaryArray = [];
-  for (var i = 0; i < endBoundary.length; i++) { // 最后取出结束boundary的charCode
-    endBoundaryArray.push(...endBoundary.utf8CodeAt(i));
-  }
-  postArray = postArray.concat(endBoundaryArray);
-  return {
-    contentType: 'multipart/form-data; boundary=' + boundaryKey,
-    buffer: new Uint8Array(postArray).buffer
-  }
-}
- 
-function randString() {
-  let res = "";
-  for (let i = 0; i < 17; i++) {
-    let n = parseInt(Math.random() * 62);
-    if (n <= 9) {
-      res += n;
-    }
-    else if (n <= 35) {
-      res += String.fromCharCode(n + 55);
-    }
-    else {
-      res += String.fromCharCode(n + 61);
-    }
-  }
-  return res;
-}
- 
-function formDataArray(boundary, name, value, fileName){
-  let dataString = '';
-  let isFile = !!fileName;
- 
-  dataString += boundary + '\r\n';
-  dataString += 'Content-Disposition: form-data; name="' + name + '"';
-  if (isFile){
-    dataString += '; filename="' + fileName + '"' + '\r\n';
-    dataString += 'Content-Type: ' + getFileMime(fileName) + '\r\n\r\n';
-  }
-  else{
-    dataString += '\r\n\r\n';
-    dataString += value;
-  }
- 
-  var dataArray = [];
-  for (var i = 0; i < dataString.length; i++) { // 取出文本的charCode(10进制)
-    dataArray.push(...dataString.utf8CodeAt(i));
-  }
- 
-  if (isFile) {
-    let fileArray = new Uint8Array(value);
-    dataArray = dataArray.concat(Array.prototype.slice.call(fileArray));
-  }
-  dataArray.push(..."\r".utf8CodeAt());
-  dataArray.push(..."\n".utf8CodeAt());
- 
-  return dataArray;
-}
- 
-function getFileMime(fileName){
-  let idx = fileName.lastIndexOf(".");
-  let mime = mimeMap[fileName.substr(idx)];
-  return mime?mime:"application/octet-stream"
-}
- 
-String.prototype.utf8CodeAt = function(i) {
-  var str = this;
-  var out = [], p = 0;
-  var c = str.charCodeAt(i);
-  if (c < 128) {
-    out[p++] = c;
-  } else if (c < 2048) {
-    out[p++] = (c >> 6) | 192;
-    out[p++] = (c & 63) | 128;
-  } else if (
-      ((c & 0xFC00) == 0xD800) && (i + 1) < str.length &&
-      ((str.charCodeAt(i + 1) & 0xFC00) == 0xDC00)) {
-    // Surrogate Pair
-    c = 0x10000 + ((c & 0x03FF) << 10) + (str.charCodeAt(++i) & 0x03FF);
-    out[p++] = (c >> 18) | 240;
-    out[p++] = ((c >> 12) & 63) | 128;
-    out[p++] = ((c >> 6) & 63) | 128;
-    out[p++] = (c & 63) | 128;
-  } else {
-    out[p++] = (c >> 12) | 224;
-    out[p++] = ((c >> 6) & 63) | 128;
-    out[p++] = (c & 63) | 128;
-  }
-  return out;
-};
- 
- 
-export default FormData;

+ 11 - 1
src/utils/index.ts

@@ -231,8 +231,17 @@ export function uniqueItems(items: any) {
   return uniqueData
 }
 
-// 跳转至登录页(自动登录)
+// 跳转至登录页(自动登录)
 export function toLogin(duration = 0) {
+  setTimeout(() => {
+    uni.reLaunch({
+      url: `/pages/login/index`,
+    })
+  }, duration)
+}
+
+// 跳转至登录页(不自动登录)
+export function toLoginWait(duration = 0) {
   setTimeout(() => {
     uni.reLaunch({
       url: `/pages/login/index?isLogout=1`,
@@ -240,6 +249,7 @@ export function toLogin(duration = 0) {
   }, duration)
 }
 
+
 // 重定向到上传系统文件
 export function redirectToUpload() {
   const url = "https://service.1ai.ltd/upload-file/index.html"

+ 0 - 345
src/utils/mimeMap.js

@@ -1,345 +0,0 @@
-const mimeMap = {
-  "0.001": "application/x-001",
-  "0.323": "text/h323",
-  "0.907": "drawing/907",
-  ".acp": "audio/x-mei-aac",
-  ".aif": "audio/aiff",
-  ".aiff": "audio/aiff",
-  ".asa": "text/asa",
-  ".asp": "text/asp",
-  ".au": "audio/basic",
-  ".awf": "application/vnd.adobe.workflow",
-  ".bmp": "application/x-bmp",
-  ".c4t": "application/x-c4t",
-  ".cal": "application/x-cals",
-  ".cdf": "application/x-netcdf",
-  ".cel": "application/x-cel",
-  ".cg4": "application/x-g4",
-  ".cit": "application/x-cit",
-  ".cml": "text/xml",
-  ".cmx": "application/x-cmx",
-  ".crl": "application/pkix-crl",
-  ".csi": "application/x-csi",
-  ".cut": "application/x-cut",
-  ".dbm": "application/x-dbm",
-  ".dcd": "text/xml",
-  ".der": "application/x-x509-ca-cert",
-  ".dib": "application/x-dib",
-  ".doc": "application/msword",
-  ".drw": "application/x-drw",
-  ".dwf": "Model/vnd.dwf",
-  ".dwg": "application/x-dwg",
-  ".dxf": "application/x-dxf",
-  ".emf": "application/x-emf",
-  ".ent": "text/xml",
-  ".eps": "application/x-ps",
-  ".etd": "application/x-ebx",
-  ".fax": "image/fax",
-  ".fif": "application/fractals",
-  ".frm": "application/x-frm",
-  ".gbr": "application/x-gbr",
-  ".gif": "image/gif",
-  ".gp4": "application/x-gp4",
-  ".hmr": "application/x-hmr",
-  ".hpl": "application/x-hpl",
-  ".hrf": "application/x-hrf",
-  ".htc": "text/x-component",
-  ".html": "text/html",
-  ".htx": "text/html",
-  ".ico": "image/x-icon",
-  ".iff": "application/x-iff",
-  ".igs": "application/x-igs",
-  ".img": "application/x-img",
-  ".isp": "application/x-internet-signup",
-  ".java": "java/*",
-  ".jpe": "image/jpeg",
-  ".jpeg": "image/jpeg",
-  ".jpg": "application/x-jpg",
-  ".jsp": "text/html",
-  ".lar": "application/x-laplayer-reg",
-  ".lavs": "audio/x-liquid-secure",
-  ".lmsff": "audio/x-la-lms",
-  ".ltr": "application/x-ltr",
-  ".m2v": "video/x-mpeg",
-  ".m4e": "video/mpeg4",
-  ".man": "application/x-troff-man",
-  ".mdb": "application/msaccess",
-  ".mfp": "application/x-shockwave-flash",
-  ".mhtml": "message/rfc822",
-  ".mid": "audio/mid",
-  ".mil": "application/x-mil",
-  ".mnd": "audio/x-musicnet-download",
-  ".mocha": "application/x-javascript",
-  ".mp1": "audio/mp1",
-  ".mp2v": "video/mpeg",
-  ".mp4": "video/mpeg4",
-  ".mpd": "application/vnd.ms-project",
-  ".mpeg": "video/mpg",
-  ".mpga": "audio/rn-mpeg",
-  ".mps": "video/x-mpeg",
-  ".mpv": "video/mpg",
-  ".mpw": "application/vnd.ms-project",
-  ".mtx": "text/xml",
-  ".net": "image/pnetvue",
-  ".nws": "message/rfc822",
-  ".out": "application/x-out",
-  ".p12": "application/x-pkcs12",
-  ".p7c": "application/pkcs7-mime",
-  ".p7r": "application/x-pkcs7-certreqresp",
-  ".pc5": "application/x-pc5",
-  ".pcl": "application/x-pcl",
-  ".pdf": "application/pdf",
-  ".pdx": "application/vnd.adobe.pdx",
-  ".pgl": "application/x-pgl",
-  ".pko": "application/vnd.ms-pki.pko",
-  ".plg": "text/html",
-  ".plt": "application/x-plt",
-  ".png": "application/x-png",
-  ".ppa": "application/vnd.ms-powerpoint",
-  ".pps": "application/vnd.ms-powerpoint",
-  ".ppt": "application/x-ppt",
-  ".prf": "application/pics-rules",
-  ".prt": "application/x-prt",
-  ".ps": "application/postscript",
-  ".pwz": "application/vnd.ms-powerpoint",
-  ".ra": "audio/vnd.rn-realaudio",
-  ".ras": "application/x-ras",
-  ".rdf": "text/xml",
-  ".red": "application/x-red",
-  ".rjs": "application/vnd.rn-realsystem-rjs",
-  ".rlc": "application/x-rlc",
-  ".rm": "application/vnd.rn-realmedia",
-  ".rmi": "audio/mid",
-  ".rmm": "audio/x-pn-realaudio",
-  ".rms": "application/vnd.rn-realmedia-secure",
-  ".rmx": "application/vnd.rn-realsystem-rmx",
-  ".rp": "image/vnd.rn-realpix",
-  ".rsml": "application/vnd.rn-rsml",
-  ".rtf": "application/msword",
-  ".rv": "video/vnd.rn-realvideo",
-  ".sat": "application/x-sat",
-  ".sdw": "application/x-sdw",
-  ".slb": "application/x-slb",
-  ".slk": "drawing/x-slk",
-  ".smil": "application/smil",
-  ".snd": "audio/basic",
-  ".sor": "text/plain",
-  ".spl": "application/futuresplash",
-  ".ssm": "application/streamingmedia",
-  ".stl": "application/vnd.ms-pki.stl",
-  ".sty": "application/x-sty",
-  ".swf": "application/x-shockwave-flash",
-  ".tg4": "application/x-tg4",
-  ".tif": "image/tiff",
-  ".tiff": "image/tiff",
-  ".top": "drawing/x-top",
-  ".tsd": "text/xml",
-  ".uin": "application/x-icq",
-  ".vcf": "text/x-vcard",
-  ".vdx": "application/vnd.visio",
-  ".vpg": "application/x-vpeg005",
-  ".vsd": "application/x-vsd",
-  ".vst": "application/vnd.visio",
-  ".vsw": "application/vnd.visio",
-  ".vtx": "application/vnd.visio",
-  ".wav": "audio/wav",
-  ".wb1": "application/x-wb1",
-  ".wb3": "application/x-wb3",
-  ".wiz": "application/msword",
-  ".wk4": "application/x-wk4",
-  ".wks": "application/x-wks",
-  ".wma": "audio/x-ms-wma",
-  ".wmf": "application/x-wmf",
-  ".wmv": "video/x-ms-wmv",
-  ".wmz": "application/x-ms-wmz",
-  ".wpd": "application/x-wpd",
-  ".wpl": "application/vnd.ms-wpl",
-  ".wr1": "application/x-wr1",
-  ".wrk": "application/x-wrk",
-  ".ws2": "application/x-ws",
-  ".wsdl": "text/xml",
-  ".xdp": "application/vnd.adobe.xdp",
-  ".xfd": "application/vnd.adobe.xfd",
-  ".xhtml": "text/html",
-  ".xml": "text/xml",
-  ".xq": "text/xml",
-  ".xquery": "text/xml",
-  ".xsl": "text/xml",
-  ".xwd": "application/x-xwd",
-  ".sis": "application/vnd.symbian.install",
-  ".x_t": "application/x-x_t",
-  ".apk": "application/vnd.android.package-archive",
-  "0.301": "application/x-301",
-  "0.906": "application/x-906",
-  ".a11": "application/x-a11",
-  ".ai": "application/postscript",
-  ".aifc": "audio/aiff",
-  ".anv": "application/x-anv",
-  ".asf": "video/x-ms-asf",
-  ".asx": "video/x-ms-asf",
-  ".avi": "video/avi",
-  ".biz": "text/xml",
-  ".bot": "application/x-bot",
-  ".c90": "application/x-c90",
-  ".cat": "application/vnd.ms-pki.seccat",
-  ".cdr": "application/x-cdr",
-  ".cer": "application/x-x509-ca-cert",
-  ".cgm": "application/x-cgm",
-  ".class": "java/*",
-  ".cmp": "application/x-cmp",
-  ".cot": "application/x-cot",
-  ".crt": "application/x-x509-ca-cert",
-  ".css": "text/css",
-  ".dbf": "application/x-dbf",
-  ".dbx": "application/x-dbx",
-  ".dcx": "application/x-dcx",
-  ".dgn": "application/x-dgn",
-  ".dll": "application/x-msdownload",
-  ".dot": "application/msword",
-  ".dtd": "text/xml",
-  ".dwf": "application/x-dwf",
-  ".dxb": "application/x-dxb",
-  ".edn": "application/vnd.adobe.edn",
-  ".eml": "message/rfc822",
-  ".epi": "application/x-epi",
-  ".eps": "application/postscript",
-  ".exe": "application/x-msdownload",
-  ".fdf": "application/vnd.fdf",
-  ".fo": "text/xml",
-  ".g4": "application/x-g4",
-  ".tif": "image/tiff",
-  ".gl2": "application/x-gl2",
-  ".hgl": "application/x-hgl",
-  ".hpg": "application/x-hpgl",
-  ".hqx": "application/mac-binhex40",
-  ".hta": "application/hta",
-  ".htm": "text/html",
-  ".htt": "text/webviewhtml",
-  ".icb": "application/x-icb",
-  ".ico": "application/x-ico",
-  ".ig4": "application/x-g4",
-  ".iii": "application/x-iphone",
-  ".ins": "application/x-internet-signup",
-  ".IVF": "video/x-ivf",
-  ".jfif": "image/jpeg",
-  ".jpe": "application/x-jpe",
-  ".jpg": "image/jpeg",
-  ".js": "application/x-javascript",
-  ".la1": "audio/x-liquid-file",
-  ".latex": "application/x-latex",
-  ".lbm": "application/x-lbm",
-  ".ls": "application/x-javascript",
-  ".m1v": "video/x-mpeg",
-  ".m3u": "audio/mpegurl",
-  ".mac": "application/x-mac",
-  ".math": "text/xml",
-  ".mdb": "application/x-mdb",
-  ".mht": "message/rfc822",
-  ".mi": "application/x-mi",
-  ".midi": "audio/mid",
-  ".mml": "text/xml",
-  ".mns": "audio/x-musicnet-stream",
-  ".movie": "video/x-sgi-movie",
-  ".mp2": "audio/mp2",
-  ".mp3": "audio/mp3",
-  ".mpa": "video/x-mpg",
-  ".mpe": "video/x-mpeg",
-  ".mpg": "video/mpg",
-  ".mpp": "application/vnd.ms-project",
-  ".mpt": "application/vnd.ms-project",
-  ".mpv2": "video/mpeg",
-  ".mpx": "application/vnd.ms-project",
-  ".mxp": "application/x-mmxp",
-  ".nrf": "application/x-nrf",
-  ".odc": "text/x-ms-odc",
-  ".p10": "application/pkcs10",
-  ".p7b": "application/x-pkcs7-certificates",
-  ".p7m": "application/pkcs7-mime",
-  ".p7s": "application/pkcs7-signature",
-  ".pci": "application/x-pci",
-  ".pcx": "application/x-pcx",
-  ".pdf": "application/pdf",
-  ".pfx": "application/x-pkcs12",
-  ".pic": "application/x-pic",
-  ".pl": "application/x-perl",
-  ".pls": "audio/scpls",
-  ".png": "image/png",
-  ".pot": "application/vnd.ms-powerpoint",
-  ".ppm": "application/x-ppm",
-  ".ppt": "application/vnd.ms-powerpoint",
-  ".pr": "application/x-pr",
-  ".prn": "application/x-prn",
-  ".ps": "application/x-ps",
-  ".ptn": "application/x-ptn",
-  ".r3t": "text/vnd.rn-realtext3d",
-  ".ram": "audio/x-pn-realaudio",
-  ".rat": "application/rat-file",
-  ".rec": "application/vnd.rn-recording",
-  ".rgb": "application/x-rgb",
-  ".rjt": "application/vnd.rn-realsystem-rjt",
-  ".rle": "application/x-rle",
-  ".rmf": "application/vnd.adobe.rmf",
-  ".rmj": "application/vnd.rn-realsystem-rmj",
-  ".rmp": "application/vnd.rn-rn_music_package",
-  ".rmvb": "application/vnd.rn-realmedia-vbr",
-  ".rnx": "application/vnd.rn-realplayer",
-  ".rpm": "audio/x-pn-realaudio-plugin",
-  ".rt": "text/vnd.rn-realtext",
-  ".rtf": "application/x-rtf",
-  ".sam": "application/x-sam",
-  ".sdp": "application/sdp",
-  ".sit": "application/x-stuffit",
-  ".sld": "application/x-sld",
-  ".smi": "application/smil",
-  ".smk": "application/x-smk",
-  ".sol": "text/plain",
-  ".spc": "application/x-pkcs7-certificates",
-  ".spp": "text/xml",
-  ".sst": "application/vnd.ms-pki.certstore",
-  ".stm": "text/html",
-  ".svg": "text/xml",
-  ".tdf": "application/x-tdf",
-  ".tga": "application/x-tga",
-  ".tif": "application/x-tif",
-  ".tld": "text/xml",
-  ".torrent": "application/x-bittorrent",
-  ".txt": "text/plain",
-  ".uls": "text/iuls",
-  ".vda": "application/x-vda",
-  ".vml": "text/xml",
-  ".vsd": "application/vnd.visio",
-  ".vss": "application/vnd.visio",
-  ".vst": "application/x-vst",
-  ".vsx": "application/vnd.visio",
-  ".vxml": "text/xml",
-  ".wax": "audio/x-ms-wax",
-  ".wb2": "application/x-wb2",
-  ".wbmp": "image/vnd.wap.wbmp",
-  ".wk3": "application/x-wk3",
-  ".wkq": "application/x-wkq",
-  ".wm": "video/x-ms-wm",
-  ".wmd": "application/x-ms-wmd",
-  ".wml": "text/vnd.wap.wml",
-  ".wmx": "video/x-ms-wmx",
-  ".wp6": "application/x-wp6",
-  ".wpg": "application/x-wpg",
-  ".wq1": "application/x-wq1",
-  ".wri": "application/x-wri",
-  ".ws": "application/x-ws",
-  ".wsc": "text/scriptlet",
-  ".wvx": "video/x-ms-wvx",
-  ".xdr": "text/xml",
-  ".xfdf": "application/vnd.adobe.xfdf",
-  ".xls": "application/vnd.ms-excel",
-  ".xlw": "application/x-xlw",
-  ".xpl": "audio/scpls",
-  ".xql": "text/xml",
-  ".xsd": "text/xml",
-  ".xslt": "text/xml",
-  ".x_b": "application/x-x_b",
-  ".sisx": "application/vnd.symbian.install",
-  ".ipa": "application/vnd.iphone",
-  ".xap": "application/x-silverlight-app",
-  ".zip": "application/x-zip-compressed",
-}
-export default mimeMap;

+ 2 - 1
tsconfig.json

@@ -36,6 +36,7 @@
     "src/**/*.jsx",
     "src/**/*.vue",
     "src/**/*.json",
-    "src/utils/formData.js"
+    "src/utils/eventsource.js",
+    "src/utils/eventsource.min.js",
   ]
 }