@smart100/spu-web-plugin 0.0.7 → 0.0.8
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/README.md +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/spu-web-plugin.mjs +2 -2
- package/package.json +3 -2
- package/src/index.ts +2 -1
- package/src/install.ts +0 -3
- package/src/login.ts +22 -12
- package/src/utils.ts +13 -1
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smart100/spu-web-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "rollup -c -w",
|
|
7
7
|
"build": "rollup -c && npm run build:types",
|
|
8
|
-
"build:types": "node script/build-types.js"
|
|
8
|
+
"build:types": "node script/build-types.js",
|
|
9
|
+
"docs": "cd ./docs && npm run docs"
|
|
9
10
|
},
|
|
10
11
|
"author": "tarymee <tarymee@qq.com>",
|
|
11
12
|
"type": "module",
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { getLocation, getDistance } from './location'
|
|
|
5
5
|
import { spuAxios, apaasAxios } from './axios'
|
|
6
6
|
import { spuConfig } from './spuConfig'
|
|
7
7
|
import { downloadService, uploadService } from './oss'
|
|
8
|
-
import { getUniqueid } from './utils'
|
|
8
|
+
import { getUniqueid, functionCheck } from './utils'
|
|
9
9
|
import AMapLoader from './AMapLoader'
|
|
10
10
|
import login from './login'
|
|
11
11
|
import { v4 as getUuid } from 'uuid'
|
|
@@ -44,6 +44,7 @@ export {
|
|
|
44
44
|
uploadService,
|
|
45
45
|
getUniqueid,
|
|
46
46
|
getUuid,
|
|
47
|
+
functionCheck,
|
|
47
48
|
AMapLoader,
|
|
48
49
|
getToken,
|
|
49
50
|
getTokenExpires,
|
package/src/install.ts
CHANGED
|
@@ -27,9 +27,6 @@ const install = (app: any, options: SPUWebPluginOptions) => {
|
|
|
27
27
|
urlquery.init()
|
|
28
28
|
login.startRefreshtoken()
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
30
|
// setTimeout(async () => {
|
|
34
31
|
// const a = await downloadService.getUrl({
|
|
35
32
|
// // source: 'a1b9954a-fb39-4bb2-aa0b-501f4af0d99e.jpeg',
|
package/src/login.ts
CHANGED
|
@@ -3,6 +3,7 @@ import jwtDecode from 'jwt-decode'
|
|
|
3
3
|
import { apaasAxios } from './axios'
|
|
4
4
|
import tenantInfo from './tenantInfo'
|
|
5
5
|
import { lsProxy } from './storageProxy'
|
|
6
|
+
// import { functionCheck } from './utils'
|
|
6
7
|
|
|
7
8
|
type JwtResult = {
|
|
8
9
|
LoginUser: IAny
|
|
@@ -191,6 +192,22 @@ class Login {
|
|
|
191
192
|
return haslogged
|
|
192
193
|
}
|
|
193
194
|
|
|
195
|
+
// 接口请求回来的 userInfo 有 functioncodes 以便做权限校验
|
|
196
|
+
async getAndSetUserInfo () {
|
|
197
|
+
return apaasAxios.post('/api/teapi/rolepermission/account/getaccountinfo', {
|
|
198
|
+
positionid: this.getUser('positioncode'),
|
|
199
|
+
deviceinfo: 'h5',
|
|
200
|
+
sysversion: 'h5',
|
|
201
|
+
clientversion: 'h5'
|
|
202
|
+
}).then((res: any) => {
|
|
203
|
+
// console.log(res)
|
|
204
|
+
// debugger
|
|
205
|
+
if (res.code === 200 && res.data) {
|
|
206
|
+
this.setUser(res.data)
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
|
|
194
211
|
// 单点登录
|
|
195
212
|
async singleLogin (query: IAny) {
|
|
196
213
|
// 自动登录
|
|
@@ -219,18 +236,11 @@ class Login {
|
|
|
219
236
|
delete query.context
|
|
220
237
|
}
|
|
221
238
|
|
|
222
|
-
// const tenant = await apassRequest.get('/api/auth/tenantlist', {}).then((res) => {
|
|
223
|
-
// return res?.data?.tenants?.[0]
|
|
224
|
-
// })
|
|
225
|
-
// if (tenant) {
|
|
226
|
-
// lsProxy.setItem('tenant', JSON.stringify(tenant))
|
|
227
|
-
// const normalizedTenant = tenantInfoApi.format(tenant as Tenant)
|
|
228
|
-
// normalizedTenant && tenantInfoApi.save(normalizedTenant)
|
|
229
|
-
// }
|
|
230
|
-
// console.log(tenant)
|
|
231
|
-
|
|
232
239
|
await tenantInfo.getAndSave()
|
|
233
|
-
|
|
240
|
+
await this.getAndSetUserInfo()
|
|
241
|
+
|
|
242
|
+
// const ischeck = functionCheck('1429379220684842752')
|
|
243
|
+
// console.log(ischeck)
|
|
234
244
|
} else {
|
|
235
245
|
console.error('query 中没有 token,无法单点登录。')
|
|
236
246
|
}
|
|
@@ -238,7 +248,7 @@ class Login {
|
|
|
238
248
|
delete query.token
|
|
239
249
|
delete query.refreshtoken
|
|
240
250
|
delete query.tokenexpires
|
|
241
|
-
|
|
251
|
+
// debugger
|
|
242
252
|
return {
|
|
243
253
|
query
|
|
244
254
|
}
|
package/src/utils.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import login from './login'
|
|
2
|
+
|
|
1
3
|
const isIOS = () => {
|
|
2
4
|
const ua = navigator.userAgent
|
|
3
5
|
return /(iPhone|iPad|iPod|IOS)/i.test(ua)
|
|
@@ -27,10 +29,20 @@ const getUniqueid = () => {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
|
|
32
|
+
const functionCheck = (functioncode?: string): boolean => {
|
|
33
|
+
if (!functioncode) return false
|
|
34
|
+
const functioncodes = login.getUser('functioncodes') || []
|
|
35
|
+
// console.log(functioncodes)
|
|
36
|
+
// debugger
|
|
37
|
+
const check = functioncodes.includes(functioncode)
|
|
38
|
+
return !!check
|
|
39
|
+
}
|
|
40
|
+
|
|
30
41
|
export {
|
|
31
42
|
isIOS,
|
|
32
43
|
isInWxwork,
|
|
33
44
|
isInPcWxwork,
|
|
34
45
|
isInAppWxwork,
|
|
35
|
-
getUniqueid
|
|
46
|
+
getUniqueid,
|
|
47
|
+
functionCheck
|
|
36
48
|
}
|