create-young-proj 1.6.1 → 1.7.0
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/CHANGELOG.md +28 -0
- package/package.json +1 -1
- package/template-nuxt-admin/nuxt.config.ts +3 -1
- package/template-uni-app/README.md +6 -1
- package/template-uni-app/_env +2 -1
- package/template-uni-app/auto-imports.d.ts +0 -4
- package/template-uni-app/custom-plugins/multiconf.ts +13 -1
- package/template-uni-app/package.json +17 -17
- package/template-uni-app/pnpm-lock.yaml +565 -985
- package/template-uni-app/src/App.vue +11 -1
- package/template-uni-app/src/apis/index.ts +9 -2
- package/template-uni-app/src/components/young-loading/young-loading.vue +4 -2
- package/template-uni-app/src/env.d.ts +7 -2
- package/template-uni-app/src/utils/auth.ts +24 -1
- package/template-uni-app/src/utils/index.ts +1 -2
- package/template-uni-app/src/utils/system.ts +6 -1
- package/template-uni-app/src/utils/map.ts +0 -98
@@ -1,7 +1,7 @@
|
|
1
1
|
<!--
|
2
2
|
* @Author: zhangyang
|
3
3
|
* @Date: 2023-02-13 14:58:26
|
4
|
-
* @LastEditTime:
|
4
|
+
* @LastEditTime: 2024-02-01 11:09:23
|
5
5
|
* @Description:
|
6
6
|
-->
|
7
7
|
<script setup lang="ts">
|
@@ -17,9 +17,17 @@ onLaunch(async () => {
|
|
17
17
|
setUuid()
|
18
18
|
|
19
19
|
await getSystemInfo()
|
20
|
+
|
21
|
+
// #ifdef APP-PLUS
|
22
|
+
/**
|
23
|
+
* App 热更新
|
24
|
+
* 参见:https://ask.dcloud.net.cn/article/35667
|
25
|
+
*/
|
26
|
+
// #endif
|
20
27
|
})
|
21
28
|
|
22
29
|
onShow(async () => {
|
30
|
+
// #ifdef MP
|
23
31
|
/**
|
24
32
|
* 自动更新
|
25
33
|
*/
|
@@ -46,6 +54,8 @@ onShow(async () => {
|
|
46
54
|
// 新版本下载失败
|
47
55
|
showModal({ title: '更新提示', content: '新版本下载失败', showCancel: false })
|
48
56
|
})
|
57
|
+
// #endif
|
58
|
+
|
49
59
|
console.log('App Show')
|
50
60
|
})
|
51
61
|
|
@@ -17,8 +17,15 @@ const EnvConfig = {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
export function getReqUrl(): string {
|
20
|
-
|
21
|
-
|
20
|
+
let url = import.meta.env.VITE_API_BASE_URL
|
21
|
+
|
22
|
+
// #ifdef MP-WEIXIN
|
23
|
+
if (__wxConfig && __wxConfig.envVersion && EnvConfig[__wxConfig.envVersion])
|
24
|
+
url = EnvConfig[__wxConfig.envVersion]
|
25
|
+
|
26
|
+
// #endif
|
27
|
+
|
28
|
+
return url
|
22
29
|
}
|
23
30
|
|
24
31
|
const http = useHttp({
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<!--
|
2
2
|
* @Author: zhangyang
|
3
3
|
* @Date: 2023-07-19 12:12:29
|
4
|
-
* @LastEditTime:
|
4
|
+
* @LastEditTime: 2024-02-01 11:15:49
|
5
5
|
* @Description:
|
6
6
|
-->
|
7
7
|
<script lang="ts" setup>
|
@@ -15,8 +15,10 @@ withDefaults(defineProps<{
|
|
15
15
|
*/
|
16
16
|
tip?: string
|
17
17
|
}>(), {
|
18
|
+
// #ifdef MP-WEIXIN
|
18
19
|
// @ts-expect-error
|
19
20
|
loadingGif: __wxConfig.accountInfo.icon,
|
21
|
+
// #endif
|
20
22
|
tip: '加载中...',
|
21
23
|
})
|
22
24
|
|
@@ -28,7 +30,7 @@ const { fullscreenLoading } = storeToRefs(useHttpLoading())
|
|
28
30
|
v-show="fullscreenLoading"
|
29
31
|
class="w100vw h100vh fixed left-0 top-0 z-999999 bg-white flex flex-col items-center justify-center"
|
30
32
|
>
|
31
|
-
<image :src="loadingGif" class="w140rpx h140rpx mb-32rpx" />
|
33
|
+
<image v-if="loadingGif" :src="loadingGif" class="w140rpx h140rpx mb-32rpx" />
|
32
34
|
<text class="text-[#999] text-24rpx leading-36rpx">
|
33
35
|
{{ tip }}
|
34
36
|
</text>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* @Author: zhangyang
|
3
3
|
* @Date: 2023-07-19 08:41:05
|
4
|
-
* @LastEditTime:
|
4
|
+
* @LastEditTime: 2024-02-01 11:28:01
|
5
5
|
* @Description:
|
6
6
|
*/
|
7
7
|
/// <reference types="vite/client" />
|
@@ -25,10 +25,15 @@ declare interface ImportMetaEnv {
|
|
25
25
|
VITE_CUSTOM_LOADING: boolean
|
26
26
|
|
27
27
|
/**
|
28
|
-
*
|
28
|
+
* appid
|
29
29
|
*/
|
30
30
|
VITE_APPID: string
|
31
31
|
|
32
|
+
/**
|
33
|
+
* 应用名称
|
34
|
+
*/
|
35
|
+
VITE_APPNAME: string
|
36
|
+
|
32
37
|
/**
|
33
38
|
* 接口请求地址
|
34
39
|
*/
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* @Author: zhangyang
|
3
3
|
* @Date: 2023-07-18 14:28:16
|
4
|
-
* @LastEditTime:
|
4
|
+
* @LastEditTime: 2024-02-01 10:31:14
|
5
5
|
* @Description: 权限相关
|
6
6
|
*/
|
7
7
|
/**
|
@@ -66,6 +66,7 @@ export function locate(cancelback = true) {
|
|
66
66
|
*/
|
67
67
|
export async function authLocation(cancelback = true, isShowModal = true) {
|
68
68
|
return new Promise<UniApp.GetLocationSuccess>(async (resolve, reject) => {
|
69
|
+
// #ifdef MP
|
69
70
|
uni.getSetting({
|
70
71
|
withSubscriptions: true,
|
71
72
|
success: async (conf) => {
|
@@ -128,6 +129,11 @@ export async function authLocation(cancelback = true, isShowModal = true) {
|
|
128
129
|
reject(false)
|
129
130
|
},
|
130
131
|
})
|
132
|
+
// #endif
|
133
|
+
// #ifndef MP
|
134
|
+
console.error('this method can only used in miniprogram !')
|
135
|
+
reject(false)
|
136
|
+
// #endif
|
131
137
|
})
|
132
138
|
}
|
133
139
|
|
@@ -137,6 +143,7 @@ export async function authLocation(cancelback = true, isShowModal = true) {
|
|
137
143
|
export async function getAuthInfo() {
|
138
144
|
return new Promise<UniApp.CheckIsSupportSoterAuthenticationRes['supportMode'] | false>(
|
139
145
|
(resolve) => {
|
146
|
+
// #ifdef APP-PLUS || MP-WEIXIN
|
140
147
|
uni.checkIsSupportSoterAuthentication({
|
141
148
|
success(res) {
|
142
149
|
resolve(res.supportMode)
|
@@ -146,6 +153,12 @@ export async function getAuthInfo() {
|
|
146
153
|
resolve(false)
|
147
154
|
},
|
148
155
|
})
|
156
|
+
// #endif
|
157
|
+
|
158
|
+
// #ifndef APP-PLUS || MP-WEIXIN
|
159
|
+
resolve(false)
|
160
|
+
console.error('this method can only used in app and mp-weixin !')
|
161
|
+
// #endif
|
149
162
|
},
|
150
163
|
)
|
151
164
|
}
|
@@ -155,11 +168,16 @@ export async function getAuthInfo() {
|
|
155
168
|
*/
|
156
169
|
export async function checkFingerPrint() {
|
157
170
|
return new Promise<boolean>((resolve) => {
|
171
|
+
// #ifdef APP-PLUS || MP-WEIXIN
|
158
172
|
uni.checkIsSoterEnrolledInDevice({
|
159
173
|
checkAuthMode: 'fingerPrint',
|
160
174
|
success: () => resolve(true),
|
161
175
|
fail: () => resolve(false),
|
162
176
|
})
|
177
|
+
// #endif
|
178
|
+
// #ifndef APP-PLUS || MP-WEIXIN
|
179
|
+
resolve(false)
|
180
|
+
// #endif
|
163
181
|
})
|
164
182
|
}
|
165
183
|
|
@@ -168,6 +186,7 @@ export async function checkFingerPrint() {
|
|
168
186
|
*/
|
169
187
|
export async function fingerPrintAuth(signStr: string, authContent = '请验证本机指纹') {
|
170
188
|
return new Promise<boolean>(async (resolve) => {
|
189
|
+
// #ifdef APP-PLUS || MP-WEIXIN
|
171
190
|
const authMethods = await getAuthInfo()
|
172
191
|
if (authMethods && authMethods.includes('fingerPrint')) {
|
173
192
|
uni.checkIsSupportSoterAuthentication({
|
@@ -200,5 +219,9 @@ export async function fingerPrintAuth(signStr: string, authContent = '请验证
|
|
200
219
|
else {
|
201
220
|
resolve(false)
|
202
221
|
}
|
222
|
+
// #endif
|
223
|
+
// #ifndef APP-PLUS || MP-WEIXIN
|
224
|
+
resolve(false)
|
225
|
+
// #endif
|
203
226
|
})
|
204
227
|
}
|
@@ -1,11 +1,10 @@
|
|
1
1
|
/*
|
2
2
|
* @Author: zhangyang
|
3
3
|
* @Date: 2023-07-18 14:12:16
|
4
|
-
* @LastEditTime:
|
4
|
+
* @LastEditTime: 2024-02-01 10:20:17
|
5
5
|
* @Description:
|
6
6
|
*/
|
7
7
|
export * from './modal'
|
8
8
|
export * from './auth'
|
9
|
-
export * from './map'
|
10
9
|
export * from './system'
|
11
10
|
export * from './route'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* @Author: zhangyang
|
3
3
|
* @Date: 2023-07-18 14:24:35
|
4
|
-
* @LastEditTime:
|
4
|
+
* @LastEditTime: 2024-02-01 10:26:40
|
5
5
|
* @Description:
|
6
6
|
*/
|
7
7
|
import type { SubscribeMessage } from '@/config'
|
@@ -10,6 +10,7 @@ import type { SubscribeMessage } from '@/config'
|
|
10
10
|
* 订阅指定的消息
|
11
11
|
*/
|
12
12
|
export function subscribeMessage(tmplIds: SubscribeMessage[]) {
|
13
|
+
// #ifdef MP-WEIXIN
|
13
14
|
return new Promise((resolve) => {
|
14
15
|
uni.requestSubscribeMessage({
|
15
16
|
tmplIds,
|
@@ -22,6 +23,10 @@ export function subscribeMessage(tmplIds: SubscribeMessage[]) {
|
|
22
23
|
complete: () => resolve(true),
|
23
24
|
})
|
24
25
|
})
|
26
|
+
// #endif
|
27
|
+
// #ifndef MP-WEIXIN
|
28
|
+
throw new Error('subscribeMessage 仅微信小程序支持')
|
29
|
+
// #endif
|
25
30
|
}
|
26
31
|
|
27
32
|
/**
|
@@ -1,98 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: zhangyang
|
3
|
-
* @Date: 2023-07-18 14:29:41
|
4
|
-
* @LastEditTime: 2023-07-19 16:51:26
|
5
|
-
* @Description: 地图相关(基于腾讯地图)
|
6
|
-
*/
|
7
|
-
export interface TxLocationSearchRes {
|
8
|
-
address: string
|
9
|
-
title: string
|
10
|
-
_distance: number
|
11
|
-
id: string
|
12
|
-
location: {
|
13
|
-
lat: number
|
14
|
-
lng: number
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
export interface TxLocationSearch {
|
19
|
-
/**
|
20
|
-
* 分页信息
|
21
|
-
*/
|
22
|
-
page_size: number
|
23
|
-
page_index: number
|
24
|
-
/**
|
25
|
-
* 搜索关键字
|
26
|
-
*/
|
27
|
-
keyword: string
|
28
|
-
|
29
|
-
/**
|
30
|
-
* 经纬度
|
31
|
-
*/
|
32
|
-
latitude: number
|
33
|
-
longitude: number
|
34
|
-
}
|
35
|
-
|
36
|
-
/**
|
37
|
-
* 地点搜索
|
38
|
-
*/
|
39
|
-
export function searchLoaction(args: TxLocationSearch) {
|
40
|
-
const { page_size, page_index, keyword, latitude, longitude } = args
|
41
|
-
|
42
|
-
return new Promise<TxLocationSearchRes[]>((resolve, reject): void => {
|
43
|
-
uni.request({
|
44
|
-
url: `https://apis.map.qq.com/ws/place/v1/search?boundary=nearby(${latitude},${longitude},1000)${
|
45
|
-
keyword ? `&keyword=${keyword}` : ''
|
46
|
-
}&page_size=${page_size}&page_index=${page_index}&key=${getMapApiKey()}`,
|
47
|
-
success: (res) => {
|
48
|
-
resolve((res.data as unknown as { data: TxLocationSearchRes[] }).data)
|
49
|
-
},
|
50
|
-
fail: (err) => {
|
51
|
-
console.log(err)
|
52
|
-
reject()
|
53
|
-
},
|
54
|
-
complete: (err) => {
|
55
|
-
console.log(err)
|
56
|
-
reject()
|
57
|
-
},
|
58
|
-
})
|
59
|
-
})
|
60
|
-
}
|
61
|
-
|
62
|
-
export interface GeoCoderRes {
|
63
|
-
province_code: string
|
64
|
-
city_code: string
|
65
|
-
city: string
|
66
|
-
province: string
|
67
|
-
location: {
|
68
|
-
lat: number
|
69
|
-
lng: number
|
70
|
-
}
|
71
|
-
}
|
72
|
-
|
73
|
-
/**
|
74
|
-
* 逆地址解析(坐标位置描述)
|
75
|
-
*/
|
76
|
-
export function geocoderLocation(latitude: number, longitude: number) {
|
77
|
-
return new Promise<GeoCoderRes>((resolve, reject): void => {
|
78
|
-
uni.request({
|
79
|
-
url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${getMapApiKey()}&get_poi=1`,
|
80
|
-
success: (res) => {
|
81
|
-
const ad_info = (res.data as any).result.ad_info
|
82
|
-
resolve({
|
83
|
-
...ad_info,
|
84
|
-
province_code: ad_info.adcode.slice(0, 2),
|
85
|
-
city_code: ad_info.adcode.slice(0, 4),
|
86
|
-
})
|
87
|
-
},
|
88
|
-
fail: (err) => {
|
89
|
-
console.log(err)
|
90
|
-
reject()
|
91
|
-
},
|
92
|
-
complete: (err) => {
|
93
|
-
console.log(err)
|
94
|
-
reject()
|
95
|
-
},
|
96
|
-
})
|
97
|
-
})
|
98
|
-
}
|