@smart100/spu-web-plugin 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart100/spu-web-plugin",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "rollup -c -w",
package/src/index.ts CHANGED
@@ -4,6 +4,10 @@ import { lsProxy, ssProxy } from './storageProxy'
4
4
  import { getLocation, getDistance } from './location'
5
5
  import { spuAxios, apaasAxios } from './axios'
6
6
  import { downloadService, uploadService } from './oss'
7
+ import { getUniqueid } from './utils'
8
+ import AMapLoader from './AMapLoader'
9
+ import login from './login'
10
+ import { v4 as getUuid } from 'uuid'
7
11
  // import { downloadService } from './oss'
8
12
 
9
13
  // class SPUWebPlugin {
@@ -18,6 +22,14 @@ const SPUWebPlugin = {
18
22
  version
19
23
  }
20
24
 
25
+
26
+ const getToken = login.getToken.bind(login)
27
+ const getTokenExpires = login.getTokenExpires.bind(login)
28
+ const getRefreshToken = login.getRefreshToken.bind(login)
29
+ const getUser = login.getUser.bind(login)
30
+ const checkLogin = login.checkLogin.bind(login)
31
+
32
+
21
33
  export {
22
34
  SPUWebPlugin as default,
23
35
  lsProxy,
@@ -27,5 +39,13 @@ export {
27
39
  spuAxios,
28
40
  apaasAxios,
29
41
  downloadService,
30
- uploadService
42
+ uploadService,
43
+ getUniqueid,
44
+ getUuid,
45
+ AMapLoader,
46
+ getToken,
47
+ getTokenExpires,
48
+ getRefreshToken,
49
+ getUser,
50
+ checkLogin
31
51
  }
package/src/location.ts CHANGED
@@ -181,6 +181,25 @@ const getDistance = async (p1: [number, number], p2: [number, number]) => {
181
181
  return AMap.GeometryUtil.distance(p1, p2)
182
182
  }
183
183
 
184
+
185
+ // // 两个经纬度距离计算
186
+ // function getDistance (latlng1, latlng2) {
187
+ // console.log(latlng1)
188
+ // console.log(latlng2)
189
+ // const lng1 = Number(latlng1[0])
190
+ // const lat1 = Number(latlng1[1])
191
+ // const lng2 = Number(latlng2[0])
192
+ // const lat2 = Number(latlng2[1])
193
+ // const radLat1 = (lat1 * Math.PI) / 180.0
194
+ // const radLat2 = (lat2 * Math.PI) / 180.0
195
+ // const a = radLat1 - radLat2
196
+ // const b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0
197
+ // let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)))
198
+ // s = s * 6378.137 // EARTH_RADIUS
199
+ // s = Math.round(s * 10000) / 10000
200
+ // return s * 1000
201
+ // }
202
+
184
203
  export {
185
204
  getLocation,
186
205
  getDistance
@@ -60,6 +60,15 @@ const getContentType = (suffix: string) => {
60
60
 
61
61
 
62
62
  type Cope = { width?: number, height?: number } | string | boolean
63
+ interface IDownload {
64
+ type?: 'att' | 'img',
65
+ source: string,
66
+ datetime: string | number,
67
+ storagetype?: StorageType,
68
+ cope?: Cope
69
+ }
70
+
71
+
63
72
 
64
73
  const getNormalizeAliOssCope = (cope?: Cope) => {
65
74
  let copeObj = ''
@@ -83,13 +92,7 @@ const getNormalizeAliOssCope = (cope?: Cope) => {
83
92
  }
84
93
 
85
94
 
86
- interface IDownload {
87
- type?: 'att' | 'img',
88
- source: string,
89
- datetime: string | number,
90
- storagetype?: StorageType,
91
- cope?: Cope
92
- }
95
+
93
96
 
94
97
  // 根据文件信息最后生成一个云文件服务可以用的链接http://xxxxx.xxx.jpg
95
98
  const getUrl = async ({
package/src/utils.ts CHANGED
@@ -1,3 +1,8 @@
1
+ const isIOS = () => {
2
+ const ua = navigator.userAgent
3
+ return /(iPhone|iPad|iPod|IOS)/i.test(ua)
4
+ }
5
+
1
6
  // 是否企微软件内 包括电脑端和APP端
2
7
  const isInWxwork = () => {
3
8
  return navigator.userAgent.indexOf('wxwork') >= 0
@@ -13,8 +18,19 @@ const isInAppWxwork = () => {
13
18
  return isInWxwork() && navigator.userAgent.indexOf('Mobile') >= 0
14
19
  }
15
20
 
21
+ // 生成唯一id
22
+ const getUniqueid = () => {
23
+ const random = Math.ceil(Math.random() * 100000)
24
+ // TODO:生成的id不能以0开头,在数据库存储转换长整型会被消除,导致唯一编码错误存储
25
+ // TODO: 不能与服务端返回的idarray在未来产生重叠,用9开头(应该够用许多年了?)
26
+ return `9${Date.now()}${random}`
27
+ }
28
+
29
+
16
30
  export {
31
+ isIOS,
17
32
  isInWxwork,
18
33
  isInPcWxwork,
19
- isInAppWxwork
34
+ isInAppWxwork,
35
+ getUniqueid
20
36
  }
@@ -1,28 +0,0 @@
1
- import type { App } from 'vue'
2
- // import type { AxiosInstance } from 'axios'
3
-
4
- interface SPUWebPluginOptions {
5
- modulekey: string;
6
- modulename: string;
7
- moduleversion: string;
8
- router: any;
9
- }
10
-
11
- export const lsProxy: any
12
- export const ssProxy: any
13
- export const getLocation: any
14
- export const getDistance: any
15
- export const spuAxios: any
16
- // export const spuAxios: AxiosInstance
17
- export const apaasAxios: any
18
- export const downloadService: any
19
- export const uploadService: any
20
-
21
-
22
- interface ISPUWebPlugin {
23
- install (app: App, option: SPUWebPluginOptions): void
24
- // install: any
25
- version: string
26
- }
27
- declare const SPUWebPlugin: ISPUWebPlugin
28
- export default SPUWebPlugin