Browse Source

fix ts eslint

pujiaming 2 years ago
parent
commit
a3514c84b8

+ 0 - 38
src/components/HelloWorld.vue

@@ -1,38 +0,0 @@
-<script setup lang="ts">
-import { ref } from 'vue'
-
-defineProps<{ msg: string }>()
-
-const count = ref(0)
-</script>
-
-<template>
-  <h1>{{ msg }}</h1>
-
-  <div class="card">
-    <button type="button" @click="count++">count is {{ count }}</button>
-    <p>
-      Edit
-      <code>components/HelloWorld.vue</code> to test HMR
-    </p>
-  </div>
-
-  <p>
-    Check out
-    <a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
-      >create-vue</a
-    >, the official Vue + Vite starter
-  </p>
-  <p>
-    Install
-    <a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
-    in your IDE for a better DX
-  </p>
-  <p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
-</template>
-
-<style scoped>
-.read-the-docs {
-  color: #888;
-}
-</style>

+ 3 - 4
src/components/layout/header.vue

@@ -79,7 +79,7 @@
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, onMounted, watch, inject, computed } from 'vue'
+import { ref, reactive, onMounted, watch, computed } from 'vue'
 import { useRouter, useRoute } from 'vue-router'
 import { useStore } from '@/store'
 import Message from '@/utils/Message'
@@ -88,7 +88,7 @@ import { getGameList } from '@/api/index'
 import { Search } from '@element-plus/icons-vue'
 import { getAssetsFile } from '@/utils/imgResolve'
 
-const img:any = inject('img')
+// const img:any = inject('img')
 const router = useRouter()
 const route = useRoute()
 const { user } = useStore()
@@ -120,7 +120,7 @@ onMounted(() => {
 const logOut = () => {
   // console.log(22);
   localStorage.removeItem('token')
-  router.push({ path: 'p_login' })
+  router.push({ path: '/login' })
   hasToken.value = ''
 }
 const toSetting = () => {
@@ -173,7 +173,6 @@ const searchChange = async(str: string, cb: (arg: any) => void) => {
 
 const handleSelect = (item: LinkItem) => {
   if (item) {
-    const { value } = item
     if (route.path !== 'search') {
       router.push({ path: '/search' })
     }

+ 9 - 9
src/components/layout/index.vue

@@ -6,18 +6,18 @@
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, onMounted, computed, inject } from 'vue'
-import { useRouter, useRoute } from 'vue-router'
-import { useStore } from '@/store'
+import { onMounted } from 'vue'
+// import { useRouter, useRoute } from 'vue-router'
+// import { useStore } from '@/store'
 import headerVue from './header.vue'
 import mainVue from './main.vue'
-import { showSuccessToast, showFailToast } from 'vant'
-import Message from '@/utils/Message'
+// import { showSuccessToast, showFailToast } from 'vant'
+// import Message from '@/utils/Message'
 
-const img:any = inject('img')
-const router = useRouter()
-const route = useRoute()
-const { user } = useStore()
+// const img:any = inject('img')
+// const router = useRouter()
+// const route = useRoute()
+// const { user } = useStore()
 // showSuccessToast('成功文案')
 // showFailToast('失败文案')
 onMounted(() => {

+ 4 - 4
src/components/vantList.vue

@@ -18,7 +18,7 @@
 </template>
 
 <script setup lang="ts">
-import { Notify } from 'vant'
+import { showNotify } from 'vant'
 import { ref } from 'vue'
 const list = ref<any[]>([])
 const refreshing = ref(false)
@@ -50,7 +50,7 @@ const onLoad = async(flag?:any, pa?:any) => {
   // console.log(props.param)
 
   paramCopy.value = pa || { ...(props.param ? props.param : {}) }
-  await props.request({ ...paramCopy.value, ...paginationCopy.value }).then(res => {
+  await props.request({ ...paramCopy.value, ...paginationCopy.value }).then((res:any) => {
     // console.log('列表res', res.data)
     if (!res.data.total) {
       finished.value = true
@@ -60,9 +60,9 @@ const onLoad = async(flag?:any, pa?:any) => {
     // list.value = [...list.value, ...(res.data.data ? res.data.data : [])]
     console.log('list', list.value)
     if (!list.value.length) emit('noData')
-  }).catch(err => {
+  }).catch((err:any) => {
     console.log(err)
-    Notify({ type: 'danger', message: err.data })
+    showNotify({ type: 'danger', message: err.data })
     finished.value = true
     error.value = true
   })

+ 1 - 0
src/router/index.ts

@@ -109,6 +109,7 @@ router.beforeEach((to, from, next) => {
   // ...
   // 返回 false 以取消导航
   // return false
+  console.log(to, from)
 
   // const token = sessionStorage.getItem('token')
   // if (!token && to.path !== '/login') {

+ 1 - 1
src/utils/bytesFormatter.ts

@@ -13,7 +13,7 @@ export const bytesChange = (limit:number) => {
   const sizeStr = size + '' // 转成字符串
   const index = sizeStr.indexOf('.') // 获取小数点处的索引
   const dou = sizeStr.substr(index + 1, 2) // 获取小数点后两位的值
-  if (dou == '00') { // 判断后两位是否为00,如果是则删除00
+  if (dou === '00') { // 判断后两位是否为00,如果是则删除00
     return sizeStr.substring(0, index) + sizeStr.substr(index + 3, 2)
   }
   return size

+ 400 - 400
src/utils/index.ts

@@ -1,400 +1,400 @@
-/**
- * Created by PanJiaChen on 16/11/18.
- */
-
-/**
- * Parse the time to string
- * @param {(Object|string|number)} time
- * @param {string} cFormat
- * @returns {string | null}
- */
-export function parseTime(time:any, cFormat:any) {
-  if (arguments.length === 0 || !time) {
-    return null
-  }
-  const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
-  let date
-  if (typeof time === 'object') {
-    date = time
-  } else {
-    if ((typeof time === 'string')) {
-      if ((/^[0-9]+$/.test(time))) {
-        // support "1548221490638"
-        time = parseInt(time)
-      } else {
-        // support safari
-        // https://stackoverflow.com/questions/4310953/invalid-date-in-safari
-        time = time.replace(new RegExp(/-/gm), '/')
-      }
-    }
-
-    if ((typeof time === 'number') && (time.toString().length === 10)) {
-      time = time * 1000
-    }
-    date = new Date(time)
-  }
-  const formatObj:any = {
-    y: date.getFullYear(),
-    m: date.getMonth() + 1,
-    d: date.getDate(),
-    h: date.getHours(),
-    i: date.getMinutes(),
-    s: date.getSeconds(),
-    a: date.getDay()
-  }
-  const time_str = format.replace(/{([ymdhisa])+}/g, (result:any, key:any) => {
-    const value = formatObj[key]
-    // Note: getDay() returns 0 on Sunday
-    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
-    return value.toString().padStart(2, '0')
-  })
-  return time_str
-}
-
-/**
- * @param {number} time
- * @param {string} option
- * @returns {string}
- */
-export function formatTime(time:any, option:any) {
-  if (('' + time).length === 10) {
-    time = parseInt(time) * 1000
-  } else {
-    time = +time
-  }
-  const d = new Date(time)
-  const now = Date.now()
-
-  const diff = (now - d.getTime()) / 1000
-
-  if (diff < 30) {
-    return '刚刚'
-  } else if (diff < 3600) {
-    // less 1 hour
-    return Math.ceil(diff / 60) + '分钟前'
-  } else if (diff < 3600 * 24) {
-    return Math.ceil(diff / 3600) + '小时前'
-  } else if (diff < 3600 * 24 * 2) {
-    return '1天前'
-  }
-  if (option) {
-    return parseTime(time, option)
-  } else {
-    return (
-      d.getMonth() +
-      1 +
-      '月' +
-      d.getDate() +
-      '日' +
-      d.getHours() +
-      '时' +
-      d.getMinutes() +
-      '分'
-    )
-  }
-}
-
-/**
- * @param {string} url
- * @returns {Object}
- */
-export function getQueryObject(url:string) {
-  url = url == null ? window.location.href : url
-  const search = url.substring(url.lastIndexOf('?') + 1)
-  const obj:any = {}
-  const reg = /([^?&=]+)=([^?&=]*)/g
-  search.replace(reg, (rs, $1, $2) => {
-    const name = decodeURIComponent($1)
-    let val = decodeURIComponent($2)
-    val = String(val)
-    obj[name as keyof typeof obj] = val
-    return rs
-  })
-  return obj
-}
-
-/**
- * @param {string} input value
- * @returns {number} output value
- */
-export function byteLength(str:any) {
-  // returns the byte length of an utf8 string
-  let s = str.length
-  for (let i = str.length - 1; i >= 0; i--) {
-    const code = str.charCodeAt(i)
-    if (code > 0x7f && code <= 0x7ff) s++
-    else if (code > 0x7ff && code <= 0xffff) s += 2
-    if (code >= 0xDC00 && code <= 0xDFFF) i--
-  }
-  return s
-}
-
-/**
- * @param {Array} actual
- * @returns {Array}
- */
-export function cleanArray(actual:any) {
-  const newArray = []
-  for (let i = 0; i < actual.length; i++) {
-    if (actual[i]) {
-      newArray.push(actual[i])
-    }
-  }
-  return newArray
-}
-
-/**
- * @param {Object} json
- * @returns {Array}
- */
-export function param(json:any) {
-  if (!json) return ''
-  return cleanArray(
-    Object.keys(json).map(key => {
-      if (json[key] === undefined) return ''
-      return encodeURIComponent(key) + '=' + encodeURIComponent(json[key])
-    })
-  ).join('&')
-}
-
-/**
- * @param {string} url
- * @returns {Object}
- */
-export function param2Obj(url:any) {
-  const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
-  if (!search) {
-    return {}
-  }
-  const obj:any = {}
-  const searchArr = search.split('&')
-  searchArr.forEach(v => {
-    const index = v.indexOf('=')
-    if (index !== -1) {
-      const name = v.substring(0, index)
-      const val = v.substring(index + 1, v.length)
-      obj[name] = val
-    }
-  })
-  return obj
-}
-
-/**
- * @param {string} val
- * @returns {string}
- */
-export function html2Text(val:any) {
-  const div = document.createElement('div')
-  div.innerHTML = val
-  return div.textContent || div.innerText
-}
-
-/**
- * Merges two objects, giving the last one precedence
- * @param {Object} target
- * @param {(Object|Array)} source
- * @returns {Object}
- */
-export function objectMerge(target:any, source:any) {
-  if (typeof target !== 'object') {
-    target = {}
-  }
-  if (Array.isArray(source)) {
-    return source.slice()
-  }
-  Object.keys(source).forEach(property => {
-    const sourceProperty = source[property]
-    if (typeof sourceProperty === 'object') {
-      target[property] = objectMerge(target[property], sourceProperty)
-    } else {
-      target[property] = sourceProperty
-    }
-  })
-  return target
-}
-
-/**
- * @param {HTMLElement} element
- * @param {string} className
- */
-export function toggleClass(element:any, className:any) {
-  if (!element || !className) {
-    return
-  }
-  let classString = element.className
-  const nameIndex = classString.indexOf(className)
-  if (nameIndex === -1) {
-    classString += '' + className
-  } else {
-    classString =
-      classString.substr(0, nameIndex) +
-      classString.substr(nameIndex + className.length)
-  }
-  element.className = classString
-}
-
-/**
- * @param {string} type
- * @returns {Date}
- */
-export function getTime(type:any) {
-  if (type === 'start') {
-    return new Date().getTime() - 3600 * 1000 * 24 * 90
-  } else {
-    return new Date(new Date().toDateString())
-  }
-}
-
-/**
- * @param {Function} func
- * @param {number} wait
- * @param {boolean} immediate
- * @return {*}
- */
-// export function debounce(func:any, wait:any, immediate:any) {
-//   let timeout:any, args:any, context:any, timestamp:any, result:any
-
-//   const later = function() {
-//     // 据上一次触发时间间隔
-//     const last = +new Date() - timestamp
-
-//     // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
-//     if (last < wait && last > 0) {
-//       timeout = setTimeout(later, wait - last)
-//     } else {
-//       timeout = null
-//       // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
-//       if (!immediate) {
-//         result = func.apply(context, args)
-//         if (!timeout) context = args = null
-//       }
-//     }
-//   }
-
-//   return function(...args:any) {
-//     /* eslint-disable */
-//     context = this
-//     timestamp = +new Date()
-//     const callNow = immediate && !timeout
-//     // 如果延时不存在,重新设定延时
-//     if (!timeout) timeout = setTimeout(later, wait)
-//     if (callNow) {
-//       result = func.apply(context, args)
-//       context = args = null
-//     }
-
-//     return result
-//   }
-// }
-
-/**
- * This is just a simple version of deep copy
- * Has a lot of edge cases bug
- * If you want to use a perfect deep copy, use lodash's _.cloneDeep
- * @param {Object} source
- * @returns {Object}
- */
-// export function deepClone(source:any) {
-//   if (!source && typeof source !== 'object') {
-//     throw new Error('error arguments', 'deepClone')
-//   }
-//   const targetObj:any = source.constructor === Array ? [] : {}
-//   Object.keys(source).forEach(keys => {
-//     if (source[keys] && typeof source[keys] === 'object') {
-//       targetObj[keys] = deepClone(source[keys])
-//     } else {
-//       targetObj[keys] = source[keys]
-//     }
-//   })
-//   return targetObj
-// }
-
-/**
- * @param {Array} arr
- * @returns {Array}
- */
-export function uniqueArr(arr:any) {
-  return Array.from(new Set(arr))
-}
-
-/**
- * @returns {string}
- */
-export function createUniqueString() {
-  const timestamp = +new Date() + ''
-  const randomNum = parseInt(((1 + Math.random()) * 65536).toString()) + ''
-  return (+(randomNum + timestamp)).toString(32)
-}
-
-/**
- * Check if an element has a class
- * @param {HTMLElement} elm
- * @param {string} cls
- * @returns {boolean}
- */
-export function hasClass(ele:any, cls:any) {
-  return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
-}
-
-/**
- * Add class to element
- * @param {HTMLElement} elm
- * @param {string} cls
- */
-export function addClass(ele:any, cls:any) {
-  if (!hasClass(ele, cls)) ele.className += ' ' + cls
-}
-
-/**
- * Remove class from element
- * @param {HTMLElement} elm
- * @param {string} cls
- */
-export function removeClass(ele:any, cls:any) {
-  if (hasClass(ele, cls)) {
-    const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
-    ele.className = ele.className.replace(reg, ' ')
-  }
-}
-
-/**
- * 时间日期格式化
- * @param dateObj
- * @param format
- * @returns {*}
- */
-export const dateFormat = function(dateObj:any, format:any) {
-  const date = {
-    'M+': dateObj.getMonth() + 1,
-    'd+': dateObj.getDate(),
-    'h+': dateObj.getHours(),
-    'm+': dateObj.getMinutes(),
-    's+': dateObj.getSeconds(),
-    'q+': Math.floor((dateObj.getMonth() + 3) / 3),
-    'S+': dateObj.getMilliseconds()
-  }
-  if (/(y+)/i.test(format)) {
-    format = format.replace(RegExp.$1, (dateObj.getFullYear() + '').substr(4 - RegExp.$1.length))
-  }
-  for (const k in date) {
-    if (new RegExp('(' + k + ')').test(format)) {
-      format = format.replace(RegExp.$1, RegExp.$1.length === 1
-        ? date[k as keyof typeof date] : ('00' + date[k as keyof typeof date]).substr(('' + date[k as keyof typeof date]).length))
-    }
-  }
-  return format
-}
-
-export function dateFormat2(date:Date) {
-  const year = date.getFullYear()
-  let month:number|string = date.getMonth() + 1
-  let day:number|string = date.getDate()
-
-  if (month < 10) {
-    month = '0' + month
-  }
-  if (day < 10) {
-    day = '0' + day
-  }
-  return (year + '-' + month + '-' + day)
-}
+/**
+ * Created by PanJiaChen on 16/11/18.
+ */
+
+/**
+ * Parse the time to string
+ * @param {(Object|string|number)} time
+ * @param {string} cFormat
+ * @returns {string | null}
+ */
+export function parseTime(time:any, cFormat:any) {
+  if (arguments.length === 0 || !time) {
+    return null
+  }
+  const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
+  let date
+  if (typeof time === 'object') {
+    date = time
+  } else {
+    if ((typeof time === 'string')) {
+      if ((/^[0-9]+$/.test(time))) {
+        // support "1548221490638"
+        time = parseInt(time)
+      } else {
+        // support safari
+        // https://stackoverflow.com/questions/4310953/invalid-date-in-safari
+        time = time.replace(new RegExp(/-/gm), '/')
+      }
+    }
+
+    if ((typeof time === 'number') && (time.toString().length === 10)) {
+      time = time * 1000
+    }
+    date = new Date(time)
+  }
+  const formatObj:any = {
+    y: date.getFullYear(),
+    m: date.getMonth() + 1,
+    d: date.getDate(),
+    h: date.getHours(),
+    i: date.getMinutes(),
+    s: date.getSeconds(),
+    a: date.getDay()
+  }
+  const time_str = format.replace(/{([ymdhisa])+}/g, (key:any) => {
+    const value = formatObj[key]
+    // Note: getDay() returns 0 on Sunday
+    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
+    return value.toString().padStart(2, '0')
+  })
+  return time_str
+}
+
+/**
+ * @param {number} time
+ * @param {string} option
+ * @returns {string}
+ */
+export function formatTime(time:any, option:any) {
+  if (('' + time).length === 10) {
+    time = parseInt(time) * 1000
+  } else {
+    time = +time
+  }
+  const d = new Date(time)
+  const now = Date.now()
+
+  const diff = (now - d.getTime()) / 1000
+
+  if (diff < 30) {
+    return '刚刚'
+  } else if (diff < 3600) {
+    // less 1 hour
+    return Math.ceil(diff / 60) + '分钟前'
+  } else if (diff < 3600 * 24) {
+    return Math.ceil(diff / 3600) + '小时前'
+  } else if (diff < 3600 * 24 * 2) {
+    return '1天前'
+  }
+  if (option) {
+    return parseTime(time, option)
+  } else {
+    return (
+      d.getMonth() +
+      1 +
+      '月' +
+      d.getDate() +
+      '日' +
+      d.getHours() +
+      '时' +
+      d.getMinutes() +
+      '分'
+    )
+  }
+}
+
+/**
+ * @param {string} url
+ * @returns {Object}
+ */
+export function getQueryObject(url:string) {
+  url = url == null ? window.location.href : url
+  const search = url.substring(url.lastIndexOf('?') + 1)
+  const obj:any = {}
+  const reg = /([^?&=]+)=([^?&=]*)/g
+  search.replace(reg, (rs, $1, $2) => {
+    const name = decodeURIComponent($1)
+    let val = decodeURIComponent($2)
+    val = String(val)
+    obj[name as keyof typeof obj] = val
+    return rs
+  })
+  return obj
+}
+
+/**
+ * @param {string} input value
+ * @returns {number} output value
+ */
+export function byteLength(str:any) {
+  // returns the byte length of an utf8 string
+  let s = str.length
+  for (let i = str.length - 1; i >= 0; i--) {
+    const code = str.charCodeAt(i)
+    if (code > 0x7f && code <= 0x7ff) s++
+    else if (code > 0x7ff && code <= 0xffff) s += 2
+    if (code >= 0xDC00 && code <= 0xDFFF) i--
+  }
+  return s
+}
+
+/**
+ * @param {Array} actual
+ * @returns {Array}
+ */
+export function cleanArray(actual:any) {
+  const newArray = []
+  for (let i = 0; i < actual.length; i++) {
+    if (actual[i]) {
+      newArray.push(actual[i])
+    }
+  }
+  return newArray
+}
+
+/**
+ * @param {Object} json
+ * @returns {Array}
+ */
+export function param(json:any) {
+  if (!json) return ''
+  return cleanArray(
+    Object.keys(json).map(key => {
+      if (json[key] === undefined) return ''
+      return encodeURIComponent(key) + '=' + encodeURIComponent(json[key])
+    })
+  ).join('&')
+}
+
+/**
+ * @param {string} url
+ * @returns {Object}
+ */
+export function param2Obj(url:any) {
+  const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
+  if (!search) {
+    return {}
+  }
+  const obj:any = {}
+  const searchArr = search.split('&')
+  searchArr.forEach(v => {
+    const index = v.indexOf('=')
+    if (index !== -1) {
+      const name = v.substring(0, index)
+      const val = v.substring(index + 1, v.length)
+      obj[name] = val
+    }
+  })
+  return obj
+}
+
+/**
+ * @param {string} val
+ * @returns {string}
+ */
+export function html2Text(val:any) {
+  const div = document.createElement('div')
+  div.innerHTML = val
+  return div.textContent || div.innerText
+}
+
+/**
+ * Merges two objects, giving the last one precedence
+ * @param {Object} target
+ * @param {(Object|Array)} source
+ * @returns {Object}
+ */
+export function objectMerge(target:any, source:any) {
+  if (typeof target !== 'object') {
+    target = {}
+  }
+  if (Array.isArray(source)) {
+    return source.slice()
+  }
+  Object.keys(source).forEach(property => {
+    const sourceProperty = source[property]
+    if (typeof sourceProperty === 'object') {
+      target[property] = objectMerge(target[property], sourceProperty)
+    } else {
+      target[property] = sourceProperty
+    }
+  })
+  return target
+}
+
+/**
+ * @param {HTMLElement} element
+ * @param {string} className
+ */
+export function toggleClass(element:any, className:any) {
+  if (!element || !className) {
+    return
+  }
+  let classString = element.className
+  const nameIndex = classString.indexOf(className)
+  if (nameIndex === -1) {
+    classString += '' + className
+  } else {
+    classString =
+      classString.substr(0, nameIndex) +
+      classString.substr(nameIndex + className.length)
+  }
+  element.className = classString
+}
+
+/**
+ * @param {string} type
+ * @returns {Date}
+ */
+export function getTime(type:any) {
+  if (type === 'start') {
+    return new Date().getTime() - 3600 * 1000 * 24 * 90
+  } else {
+    return new Date(new Date().toDateString())
+  }
+}
+
+/**
+ * @param {Function} func
+ * @param {number} wait
+ * @param {boolean} immediate
+ * @return {*}
+ */
+// export function debounce(func:any, wait:any, immediate:any) {
+//   let timeout:any, args:any, context:any, timestamp:any, result:any
+
+//   const later = function() {
+//     // 据上一次触发时间间隔
+//     const last = +new Date() - timestamp
+
+//     // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
+//     if (last < wait && last > 0) {
+//       timeout = setTimeout(later, wait - last)
+//     } else {
+//       timeout = null
+//       // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
+//       if (!immediate) {
+//         result = func.apply(context, args)
+//         if (!timeout) context = args = null
+//       }
+//     }
+//   }
+
+//   return function(...args:any) {
+//     /* eslint-disable */
+//     context = this
+//     timestamp = +new Date()
+//     const callNow = immediate && !timeout
+//     // 如果延时不存在,重新设定延时
+//     if (!timeout) timeout = setTimeout(later, wait)
+//     if (callNow) {
+//       result = func.apply(context, args)
+//       context = args = null
+//     }
+
+//     return result
+//   }
+// }
+
+/**
+ * This is just a simple version of deep copy
+ * Has a lot of edge cases bug
+ * If you want to use a perfect deep copy, use lodash's _.cloneDeep
+ * @param {Object} source
+ * @returns {Object}
+ */
+// export function deepClone(source:any) {
+//   if (!source && typeof source !== 'object') {
+//     throw new Error('error arguments', 'deepClone')
+//   }
+//   const targetObj:any = source.constructor === Array ? [] : {}
+//   Object.keys(source).forEach(keys => {
+//     if (source[keys] && typeof source[keys] === 'object') {
+//       targetObj[keys] = deepClone(source[keys])
+//     } else {
+//       targetObj[keys] = source[keys]
+//     }
+//   })
+//   return targetObj
+// }
+
+/**
+ * @param {Array} arr
+ * @returns {Array}
+ */
+export function uniqueArr(arr:any) {
+  return Array.from(new Set(arr))
+}
+
+/**
+ * @returns {string}
+ */
+export function createUniqueString() {
+  const timestamp = +new Date() + ''
+  const randomNum = parseInt(((1 + Math.random()) * 65536).toString()) + ''
+  return (+(randomNum + timestamp)).toString(32)
+}
+
+/**
+ * Check if an element has a class
+ * @param {HTMLElement} elm
+ * @param {string} cls
+ * @returns {boolean}
+ */
+export function hasClass(ele:any, cls:any) {
+  return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
+}
+
+/**
+ * Add class to element
+ * @param {HTMLElement} elm
+ * @param {string} cls
+ */
+export function addClass(ele:any, cls:any) {
+  if (!hasClass(ele, cls)) ele.className += ' ' + cls
+}
+
+/**
+ * Remove class from element
+ * @param {HTMLElement} elm
+ * @param {string} cls
+ */
+export function removeClass(ele:any, cls:any) {
+  if (hasClass(ele, cls)) {
+    const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
+    ele.className = ele.className.replace(reg, ' ')
+  }
+}
+
+/**
+ * 时间日期格式化
+ * @param dateObj
+ * @param format
+ * @returns {*}
+ */
+export const dateFormat = function(dateObj:any, format:any) {
+  const date = {
+    'M+': dateObj.getMonth() + 1,
+    'd+': dateObj.getDate(),
+    'h+': dateObj.getHours(),
+    'm+': dateObj.getMinutes(),
+    's+': dateObj.getSeconds(),
+    'q+': Math.floor((dateObj.getMonth() + 3) / 3),
+    'S+': dateObj.getMilliseconds()
+  }
+  if (/(y+)/i.test(format)) {
+    format = format.replace(RegExp.$1, (dateObj.getFullYear() + '').substr(4 - RegExp.$1.length))
+  }
+  for (const k in date) {
+    if (new RegExp('(' + k + ')').test(format)) {
+      format = format.replace(RegExp.$1, RegExp.$1.length === 1
+        ? date[k as keyof typeof date] : ('00' + date[k as keyof typeof date]).substr(('' + date[k as keyof typeof date]).length))
+    }
+  }
+  return format
+}
+
+export function dateFormat2(date:Date) {
+  const year = date.getFullYear()
+  let month:number|string = date.getMonth() + 1
+  let day:number|string = date.getDate()
+
+  if (month < 10) {
+    month = '0' + month
+  }
+  if (day < 10) {
+    day = '0' + day
+  }
+  return (year + '-' + month + '-' + day)
+}

+ 0 - 145
src/utils/oss.ts

@@ -1,145 +0,0 @@
-'use strict'
-import { dateFormat } from '@/utils/index'
-import { getOssSts } from '@/api/api'
-import { showFailToast } from 'vant'
-import OSS from 'ali-oss'
-
-export default {
-
-  /**
-     * 创建随机字符串
-     * @param num
-     * @returns {string}
-     */
-  randomString(num:number) {
-    const chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
-    let res = ''
-    for (let i = 0; i < num; i++) {
-      const id = Math.ceil(Math.random() * 35)
-      res += chars[id]
-    }
-    return res
-  },
-
-  /**
-     * 创建oss客户端对象
-     * @returns {*}
-     */
-  createOssClient() {
-    return getOssSts().then(
-      success => {
-        const data = success.data.data
-        console.log('success.data.data', data)
-
-        return new Promise((resolve, reject:any) => {
-          const client = new OSS({
-            region: 'oss-cn-hangzhou',
-            accessKeyId: data.credentials.AccessKeyId,
-            accessKeySecret: data.credentials.AccessKeySecret,
-            stsToken: data.credentials.SecurityToken,
-            bucket: data.config.BucketName,
-            secure: true
-          })
-          resolve(client)
-        })
-      },
-      error => {
-        showFailToast(error)
-        // this.$message.error(error)
-      }
-    )
-  },
-  /**
-     * 文件上传
-     * @param option
-     */
-  ossUploadFile(option:any) {
-    const file = option.file
-    /* eslint-disable*/
-    const self = this
-    /* eslint-enable*/
-    return new Promise((resolve, reject) => {
-      const date = dateFormat(new Date(), 'yyyyMMdd') // 当前时间
-      const dateTime = dateFormat(new Date(), 'yyyyMMddhhmmss') // 当前时间
-      const randomStr = self.randomString(4)//  4位随机字符串
-      const extensionName = file.name.substr(file.name.indexOf('.')) // 文件扩展名
-      const fileName = 'backend/' + date + '/' + dateTime + '_' + randomStr + extensionName // 文件名字(相对于根目录的路径 + 文件名)
-      // 执行上传
-      self.createOssClient().then((client:any) => {
-        // 异步上传,返回数据
-        // 上传处理
-        // 分片上传文件
-        client.multipartUpload(fileName, file, {
-          progress: function(p:any) {
-            const e:any = {}
-            e.percent = Math.floor(p * 100)
-            console.log('Progress: ' + p)
-            option.onProgress(e)
-          }
-        }).then((val:any) => {
-          console.log(val)
-          if (val.res.statusCode === 200) {
-            option.onSuccess(val)
-            resolve({
-              fileName: file.name,
-              fileUrl: 'https://' + val.bucket + '.oss-cn-hangzhou.aliyuncs.com/' + fileName
-            })
-            return val
-          } else {
-            option.onError('上传失败')
-          }
-        }, (err:any) => {
-          option.onError('上传失败')
-          reject(err)
-        })
-      })
-    })
-  },
-  /**
-     * base64上传
-     * @param option
-     */
-  ossUploadBase(file:any) {
-    // const file = option.file
-    /* eslint-disable*/
-    const self = this
-    /* eslint-enable*/
-    return new Promise((resolve, reject) => {
-      const date = dateFormat(new Date(), 'yyyyMMdd') // 当前时间
-      const dateTime = dateFormat(new Date(), 'yyyyMMddhhmmss') // 当前时间
-      const randomStr = self.randomString(4)//  4位随机字符串
-      const extensionName = file.name.substr(file.name.indexOf('.')) // 文件扩展名
-      const fileName = 'backend/' + date + '/' + dateTime + '_' + randomStr + extensionName // 文件名字(相对于根目录的路径 + 文件名)
-      // 执行上传
-      self.createOssClient().then((client:any) => {
-        // 异步上传,返回数据
-        // 上传处理
-        // 分片上传文件
-        client.multipartUpload(fileName, file, {
-          progress: function(p:any) {
-            const e:any = {}
-            e.percent = Math.floor(p * 100)
-            console.log('Progress: ' + p)
-            // option.onProgress(e)
-          }
-        }).then((val:any) => {
-          console.log(val)
-          if (val.res.statusCode === 200) {
-            // option.onSuccess(val)
-            resolve({
-              fileName: file.name,
-              fileUrl: 'https://' + val.bucket + '.oss-cn-hangzhou.aliyuncs.com/' + fileName
-            })
-            return val
-          } else {
-            // option.onError('上传失败')
-          }
-        }, (err:any) => {
-          // option.onError('上传失败')
-          reject(err)
-        })
-      })
-    })
-  }
-
-}

+ 5 - 3
src/views/category.vue

@@ -41,7 +41,7 @@
       </van-dropdown-menu>
     </div>
     <el-divider class="divide" />
-    <ul>
+    <ul v-if="gameLis.length">
       <li class="hot-item" v-for="(item,index) in gameLis" :key="index">
         <img class="game-logo" :src="prefix + item.logopic"  :onerror="logoErrorFun" alt=""/>
         <van-button type="primary" class="down-btn" :disabled="item.download_url === ''" size="small" round color="#14b9c7"  @click="downGame(item.download_url, item.download_url === '')">下载</van-button>
@@ -61,7 +61,7 @@
             v-for="(tag, tIndex) in item.tags"
             :key="tIndex"
           >
-            {{ tagArr.findIndex((i)=>i.id === tag)>=0 ? tagArr.find((i:any)=>i.id === tag).name :''  }}
+            {{ tagArr.findIndex((i:any)=>i.id === tag)>=0 ? tagArr.find((i:any)=>i.id === tag).name :''  }}
           </el-tag>
         </div>
         <img  :src="prefix + item.logopic" class="game-poster" :onerror="posterErrorFun" alt=""/>
@@ -71,6 +71,8 @@
         </div>
       </li>
     </ul>
+    <el-empty v-else :image-size="200" />
+
     <div class="more-action">
       <el-button v-if="params.page*params.pagesize < total" type="info" @click="loadMore">更多</el-button>
       <el-divider v-else>没有更多了</el-divider>
@@ -170,7 +172,7 @@ const allData = async() => {
   await getGameList(params).then(resp => {
     // console.log('resp===>', resp);
     if (resp.data.code === 200 && resp.data.data) {
-      gameLis.value = resp.data.data.lists.filter(item => {
+      gameLis.value = resp.data.data.lists.filter((item:any) => {
         // 如果标签为全部  类型不为全部 返回匹配的类型数据
         if (params.tag_id === 0) {
           return item.type === params.type

+ 8 - 9
src/views/ecoin.vue

@@ -42,18 +42,17 @@
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, onMounted, computed, inject } from 'vue'
-import { useRouter, useRoute } from 'vue-router'
-import { useStore } from '@/store'
-import { showSuccessToast, showFailToast } from 'vant'
+import { ref, reactive, onMounted } from 'vue'
+// import { useRouter, useRoute } from 'vue-router'
+// import { useStore } from '@/store'
 import Message from '@/utils/Message'
 import { userEcoin } from '@/api/index'
 import vantList from '@/components/vantList.vue'
-import type { ListInstance } from 'vant'
-const img:any = inject('img')
-const router = useRouter()
-const route = useRoute()
-const { user } = useStore()
+
+// const img:any = inject('img')
+// const router = useRouter()
+// const route = useRoute()
+// const { user } = useStore()
 // showSuccessToast('成功文案')
 // showFailToast('失败文案')
 const gameHot: any = ref([])

+ 10 - 8
src/views/home.vue

@@ -2,7 +2,7 @@
   <div class="left-list">
     <div class="list-part">
       <span style="margin-bottom: 1rem;display: block;">今日热游</span>
-      <ul>
+      <ul v-if="gameHot.length">
         <li class="hot-item" v-for="(item,index) in gameHot" :key="index">
           <img :src="prefix + item.screenshot" class="game-poster" :onerror="posterErrorFun" alt=""/>
           <div class="detail">
@@ -21,10 +21,11 @@
           </div>
         </li>
       </ul>
+      <el-empty v-else :image-size="200" />
     </div>
     <div class="list-part">
       <span style="margin-bottom: 1rem;display: block;">推荐游戏</span>
-      <ul>
+      <ul v-if="gameRecommand.length">
         <li class="hot-item" v-for="(item,index) in gameRecommand" :key="index">
           <img :src="prefix + item.screenshot" class="game-poster" :onerror="posterErrorFun" alt=""/>
           <div class="detail">
@@ -43,6 +44,7 @@
           </div>
         </li>
       </ul>
+      <el-empty v-else :image-size="200" />
     </div>
   </div>
   <div class="right-action">
@@ -106,7 +108,7 @@
         <div>排行榜</div>
       </div>
       <el-divider />
-      <ul>
+      <ul v-if="gameRecommand.length">
         <li class="rank-item" v-for="(item,index) in gameRecommand" :key="index">
           <el-tag size="small" round>{{ index+1 }}</el-tag>
           <img :src="prefix + item.logopic" class="game-logo" :onerror="logoErrorFun" alt=""/>
@@ -121,6 +123,8 @@
           </div>
         </li>
       </ul>
+      <el-empty v-else :image-size="200" />
+
     </div>
   </div>
   <div class="mob-page">
@@ -180,17 +184,15 @@
   </div>
 </template>
 <script setup lang="ts">
-import { ref, reactive, onMounted, computed, inject } from 'vue'
-import { useRouter, useRoute } from 'vue-router'
+import { ref, onMounted, inject } from 'vue'
+import { useRouter } from 'vue-router'
 import { useStore } from '@/store'
-import { showSuccessToast, showFailToast } from 'vant'
-import Message from '@/utils/Message'
+import { showFailToast } from 'vant'
 import { getIndexGameHot, getIndexGameRecommand, getGameTag } from '@/api/index'
 import { bytesChange } from '@/utils/bytesFormatter'
 
 const img:any = inject('img')
 const router = useRouter()
-const route = useRoute()
 const { user } = useStore()
 // showSuccessToast('成功文案')
 // showFailToast('失败文案')

+ 7 - 6
src/views/login.vue

@@ -178,6 +178,7 @@ import { useRouter } from 'vue-router'
 import { useStore } from '@/store/index'
 import local from '@/utils/local'
 
+declare let md5: any
 const transWidth = ref('0vw')
 const { user } = useStore()
 const router = useRouter()
@@ -222,6 +223,7 @@ const submitForm = async(formEl: FormInstance | undefined) => {
       if (login_typ.value === 'pwd') {
         // 登录密码加密
         let md5Pwd: any = document.querySelector('#md5_password')
+        // eslint-disable-next-line no-undef
         md5Pwd = md5(md5(md5(loginForm.password)) + loginForm.timestamp)
 
         const params = {
@@ -236,7 +238,7 @@ const submitForm = async(formEl: FormInstance | undefined) => {
             // 保存用户信息 和 token
             sessionStorage.setItem('token', res.data.data.token)
             sessionStorage.setItem('account', loginForm.account)
-            sessionStorage.setItem('from', '1')
+            localStorage.setItem('from', '1')
             await user.getUserProfile()
             // 跳转我的游戏页面
             setTimeout(() => {
@@ -261,7 +263,7 @@ const submitForm = async(formEl: FormInstance | undefined) => {
             Message.success('登录成功')
             sessionStorage.setItem('token', res.data.data.token)
             sessionStorage.setItem('account', loginForm.account)
-            sessionStorage.setItem('from', '2')
+            localStorage.setItem('from', '2')
             await user.getUserProfile()
             setTimeout(() => {
               router.push({ path: '/my_game', query: { account: loginForm.account }})
@@ -284,6 +286,7 @@ const submitFormM = async() => {
   if (login_typ.value === 'pwd') {
     // 登录密码加密
     let md5Pwd: any = document.querySelector('#md5_password')
+    // eslint-disable-next-line no-undef
     md5Pwd = md5(md5(md5(loginForm.password)) + loginForm.timestamp)
 
     const params = {
@@ -298,7 +301,7 @@ const submitFormM = async() => {
         // 保存用户信息 和 token
         sessionStorage.setItem('token', res.data.data.token)
         sessionStorage.setItem('account', loginForm.account)
-        sessionStorage.setItem('from', '1')
+        localStorage.setItem('from', '1')
         await user.getUserProfile()
         // 跳转我的游戏页面
         setTimeout(() => {
@@ -360,7 +363,7 @@ const getCaptcha = async() => {
   })
 }
 const settimes = () => {
-  var interval
+  var interval:any
   const setTimeFn = () => {
     (smsMessage.value as number)--
     if (smsMessage.value as number < 0 || can_send.value === true) {
@@ -469,9 +472,7 @@ onMounted(() => {
     .trans{
       margin-top: 30px;
     }
-    .tel-login{
 
-    }
     .pwd-login{
       transform: translateX(-100vw);
     }

+ 9 - 9
src/views/ncoin.vue

@@ -42,18 +42,18 @@
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, onMounted, computed, inject } from 'vue'
-import { useRouter, useRoute } from 'vue-router'
-import { useStore } from '@/store'
-import { showSuccessToast, showFailToast } from 'vant'
+import { ref, reactive, onMounted } from 'vue'
+// import { useRouter, useRoute } from 'vue-router'
+// import { useStore } from '@/store'
+// import { showSuccessToast, showFailToast } from 'vant'
 import Message from '@/utils/Message'
 import { userNcoin } from '@/api/index'
 import vantList from '@/components/vantList.vue'
-import type { ListInstance } from 'vant'
-const img:any = inject('img')
-const router = useRouter()
-const route = useRoute()
-const { user } = useStore()
+
+// const img:any = inject('img')
+// const router = useRouter()
+// const route = useRoute()
+// const { user } = useStore()
 // showSuccessToast('成功文案')
 // showFailToast('失败文案')
 const gameHot: any = ref([])

+ 9 - 9
src/views/order.vue

@@ -66,25 +66,25 @@
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, onMounted, computed, inject } from 'vue'
-import { useRouter, useRoute } from 'vue-router'
-import { useStore } from '@/store'
-import { showSuccessToast, showFailToast } from 'vant'
+import { ref, reactive, onMounted } from 'vue'
+// import { useRouter, useRoute } from 'vue-router'
+// import { useStore } from '@/store'
+// import { showSuccessToast, showFailToast } from 'vant'
 import Message from '@/utils/Message'
 import { userOrder } from '@/api/index'
 import vantList from '@/components/vantList.vue'
 import { parseTime } from '@/utils/index'
 
-const img:any = inject('img')
-const router = useRouter()
-const route = useRoute()
-const { user } = useStore()
+// const img:any = inject('img')
+// const router = useRouter()
+// const route = useRoute()
+// const { user } = useStore()
 // showSuccessToast('成功文案')
 // showFailToast('失败文案')
 const gameHot: any = ref([])
 const isLoading = ref<boolean>(false)
 const vanList = ref<any>()
-const token = ref<string | null>(localStorage.getItem('token'))
+// const token = ref<string | null>(localStorage.getItem('token'))
 // const user = useStore('user')
 
 const pageConfig = reactive({

+ 8 - 8
src/views/search.vue

@@ -43,19 +43,19 @@
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, onMounted, computed, inject } from 'vue'
-import { useRouter, useRoute } from 'vue-router'
+import { onMounted, inject } from 'vue'
+// import { useRouter, useRoute } from 'vue-router'
 import { useStore } from '@/store'
-import { showSuccessToast, showFailToast } from 'vant'
-import Message from '@/utils/Message'
-import { getGameList } from '@/api/index'
+// import { showSuccessToast, showFailToast } from 'vant'
+// import Message from '@/utils/Message'
+// import { getGameList } from '@/api/index'
 import { bytesChange } from '@/utils/bytesFormatter'
 import { Download } from '@element-plus/icons-vue'
 
 const img:any = inject('img')
-const router = useRouter()
-const route = useRoute()
-const { user } = useStore()
+// const router = useRouter()
+// const route = useRoute()
+// const { user } = useStore()
 const { search } = useStore()
 // showSuccessToast('成功文案')
 // showFailToast('失败文案')

+ 6 - 1
src/views/settings.vue

@@ -234,7 +234,9 @@ const blurValidate = (formEl: FormInstance | undefined) => {
     console.log(error)
   })
 }
-const checkAge = (rule: any, value: any, callback: any) => {
+const checkAge = (a:any, b:any, callback: any) => {
+  console.log(a, b)
+
   if (!ruleForm.new_password2.length || !ruleForm.new_password.length) {
     return callback()
   }
@@ -281,6 +283,7 @@ const submitForm = async(formEl: FormInstance | undefined) => {
   await formEl.validate(async(valid, fields) => {
     if (valid) {
       console.log('submit!')
+
       if (from.value === 1) {
         // 账号密码登录
         await resetPassword({ old_pass: ruleForm.old_password, new_pass: ruleForm.new_password }).then((res) => {
@@ -488,6 +491,8 @@ const pattern2 = ref<RegExp>(/^(?:(?:\+|00)86)?1[3-9]\d{9}$/)
 const account = ref<string>('')
 onMounted(async() => {
   from.value = parseInt(localStorage.getItem('from') as string)as 1 | 2
+  console.log(from.value)
+
   await user.getUserProfile()
   ruleForm2.account = user.profile?.user_name
   ruleForm3.mobile = user.profile?.mobile

+ 1 - 1
src/vite-env.d.ts

@@ -21,4 +21,4 @@ interface ImportMeta {
 }
 
 declare module 'element-plus/dist/locale/zh-cn.mjs'
-// declare module 'vant'
+