Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Accustomed_
hello uni-app x
提交
9b4c7961
H
hello uni-app x
项目概览
Accustomed_
/
hello uni-app x
与 Fork 源项目一致
Fork自
DCloud / hello uni-app x
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9b4c7961
编写于
11月 07, 2023
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(upgrade-center): 商店跳转、版本号
上级
a089887d
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
97 addition
and
33 deletion
+97
-33
pages/tabBar/component.uvue
pages/tabBar/component.uvue
+2
-6
uni_modules/uni-upgrade-center-app/components/uni-upgrade-center-app/uni-upgrade-center-app.uvue
...onents/uni-upgrade-center-app/uni-upgrade-center-app.uvue
+63
-17
uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
+7
-3
uni_modules/uni-upgrade-center-app/utils/call-check-version.ts
...odules/uni-upgrade-center-app/utils/call-check-version.ts
+6
-4
uni_modules/uni-upgrade-center-app/utils/check-update.ts
uni_modules/uni-upgrade-center-app/utils/check-update.ts
+2
-3
uni_modules/uni-upgrade-center-app/utils/utils.uts
uni_modules/uni-upgrade-center-app/utils/utils.uts
+17
-0
未找到文件。
pages/tabBar/component.uvue
浏览文件 @
9b4c7961
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
</template>
</template>
</uni-collapse>
</uni-collapse>
<u
pgradePopu
p ref="upgradePopup" @close="upgradePopupClose" />
<u
ni-upgrade-center-ap
p ref="upgradePopup" @close="upgradePopupClose" />
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
</scroll-view>
</scroll-view>
...
@@ -49,7 +49,6 @@
...
@@ -49,7 +49,6 @@
<script lang="uts">
<script lang="uts">
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
import upgradePopup from '@/uni_modules/uni-upgrade-center-app/pages/upgrade-popup-uts.uvue'
type Page = {
type Page = {
name : string
name : string
...
@@ -271,9 +270,6 @@ export default {
...
@@ -271,9 +270,6 @@ export default {
arrowRightIcon: '/static/icons/arrow-right.png',
arrowRightIcon: '/static/icons/arrow-right.png',
}
}
},
},
components: {
upgradePopup: upgradePopup
},
methods: {
methods: {
goDetailPage(e : Page) {
goDetailPage(e : Page) {
if (e.enable == false) {
if (e.enable == false) {
...
@@ -294,7 +290,7 @@ export default {
...
@@ -294,7 +290,7 @@ export default {
}
}
},
},
onReady() {
onReady() {
checkUpdate(this.$refs['upgradePopup'] as ComponentPublicInstance)
checkUpdate(this.$refs['upgradePopup'] as
UniUpgradeCenterApp
ComponentPublicInstance)
},
},
beforeUnmount() {
beforeUnmount() {
uni.showTabBar()?.catch(_ => {})
uni.showTabBar()?.catch(_ => {})
...
...
uni_modules/uni-upgrade-center-app/
pages/upgrade-popup-uts
.uvue
→
uni_modules/uni-upgrade-center-app/
components/uni-upgrade-center-app/uni-upgrade-center-app
.uvue
浏览文件 @
9b4c7961
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
<view class="content-body">
<view class="content-body">
<view class="content-body-title">
<view class="content-body-title">
<text class="text title">{{subTitle}}</text>
<text class="text title">{{subTitle}}</text>
<
!-- <text style="padding-left:20rpx;font-size: 0.5em;color: #666;">v.{{version}}</text> --
>
<
text class="text version">v{{version}}</text
>
</view>
</view>
<view class="body">
<view class="body">
<scroll-view class="box-des-scroll" scroll-y="true">
<scroll-view class="box-des-scroll" scroll-y="true">
...
@@ -41,22 +41,16 @@
...
@@ -41,22 +41,16 @@
</view>
</view>
</view>
</view>
<button v-else class="content-button"
<button v-else class="content-button" @click="updateApp">
style="border: none; color: #fff;width: 100%;height: 80rpx;line-height: 80rpx;font-size: 30rpx;font-weight: 400;border-radius: 40rpx;text-align: center;background: #1785ff"
:plain="true" @click="updateApp">
{{downLoadBtnText}}
{{downLoadBtnText}}
</button>
</button>
</template>
</template>
<button v-else-if="downloadSuccess && !installed" class="content-button"
<button v-else-if="downloadSuccess && !installed" class="content-button" :loading="installing" :disabled="installing" @click="installPackage">
style="border: none; color: #fff;width: 100%;height: 80rpx;line-height: 80rpx;font-size: 30rpx;font-weight: 400;border-radius: 40rpx;text-align: center;background: #1785ff"
:plain="true" :loading="installing" :disabled="installing" @click="installPackage">
{{installing ? '正在安装……' : '下载完成,立即安装'}}
{{installing ? '正在安装……' : '下载完成,立即安装'}}
</button>
</button>
<button v-else-if="installed" class="content-button"
<button v-else-if="installed" class="content-button" :disabled="true">
style="border: none; color: #ccc;width: 100%;height: 80rpx;line-height: 80rpx;font-size: 30rpx;font-weight: 400;border-radius: 40rpx;text-align: center;background: #1785ff"
:plain="true" :disabled="true">
安装完成后,请重启应用
安装完成后,请重启应用
</button>
</button>
</template>
</template>
...
@@ -64,8 +58,7 @@
...
@@ -64,8 +58,7 @@
</view>
</view>
<view class="content-bottom">
<view class="content-bottom">
<image v-if="!is_mandatory" class="close-img" mode="widthFix"
<image v-if="!is_mandatory" class="close-img" mode="widthFix" src="/uni_modules/uni-upgrade-center-app/static/app_update_close.png" @click="closeUpdate">
src="/uni_modules/uni-upgrade-center-app/static/app_update_close.png" @click="closeUpdate">
</image>
</image>
</view>
</view>
</view>
</view>
...
@@ -73,12 +66,14 @@
...
@@ -73,12 +66,14 @@
</template>
</template>
<script>
<script>
import { UniUpgradeCenterResult } from '../utils/call-check-version'
import { UniUpgradeCenterResult, StoreListItem } from '../../utils/call-check-version'
import { openSchema } from '../../utils/utils.uts'
const localFilePathKey = 'UNI_ADMIN_UPGRADE_CENTER_LOCAL_FILE_PATH'
const localFilePathKey = 'UNI_ADMIN_UPGRADE_CENTER_LOCAL_FILE_PATH'
const platform_iOS = 'iOS';
const platform_iOS = 'iOS';
const requiredKey = ['version', 'url', 'type']
const requiredKey = ['version', 'url', 'type']
let downloadTask : DownloadTask | null = null;
let downloadTask : DownloadTask | null = null;
let openSchemePromise: Promise<boolean> | null = null;
/**
/**
* 对比版本号,如需要,请自行修改判断规则
* 对比版本号,如需要,请自行修改判断规则
...
@@ -148,6 +143,7 @@
...
@@ -148,6 +143,7 @@
// 默认安装包信息
// 默认安装包信息
title: '更新日志',
title: '更新日志',
contents: '',
contents: '',
version: '',
is_mandatory: false,
is_mandatory: false,
// 可自定义属性
// 可自定义属性
...
@@ -157,7 +153,8 @@
...
@@ -157,7 +153,8 @@
downLoadingText: '安装包下载中,请稍后',
downLoadingText: '安装包下载中,请稍后',
url: "",
url: "",
platform: [] as string[]
platform: [] as string[],
store_list: null as StoreListItem[] | null
}
}
},
},
computed: {
computed: {
...
@@ -184,6 +181,8 @@
...
@@ -184,6 +181,8 @@
this.contents = localPackageInfo.contents
this.contents = localPackageInfo.contents
this.is_mandatory = localPackageInfo.is_mandatory
this.is_mandatory = localPackageInfo.is_mandatory
this.platform = localPackageInfo.platform
this.platform = localPackageInfo.platform
this.version = localPackageInfo.version
this.store_list = localPackageInfo.store_list
this.shown = shown
this.shown = shown
},
},
closeUpdate() {
closeUpdate() {
...
@@ -230,14 +229,43 @@
...
@@ -230,14 +229,43 @@
this.$emit('close')
this.$emit('close')
},
},
updateApp() {
updateApp() {
this.downloadPackage()
const checkStoreScheme = this.checkStoreScheme()
if (checkStoreScheme !== null) {
checkStoreScheme
.then(_ => { })
.catch(() => { this.downloadPackage() })
.finally(() => {
openSchemePromise = null
})
} else { this.downloadPackage() }
},
// 跳转应用商店
checkStoreScheme(): Promise<boolean> | null {
if (this.store_list !== null) {
const storeList: StoreListItem[] = this.store_list!.filter((item: StoreListItem): boolean => item.enable)
if (storeList.length > 0) {
if (openSchemePromise === null) {
openSchemePromise = Promise.reject() as Promise<boolean>
}
storeList
.sort((cur: StoreListItem, next: StoreListItem): number => next.priority - cur.priority)
.map((item: StoreListItem): string => item.scheme)
.reduce((promise: Promise<boolean>, cur: string): Promise<boolean> => {
openSchemePromise = promise.catch((): Promise<boolean> => openSchema(cur))
return openSchemePromise!
}, openSchemePromise!)
return openSchemePromise!
}
}
return null
},
},
downloadPackage() {
downloadPackage() {
//下载包
//下载包
downloadTask = uni.downloadFile({
downloadTask = uni.downloadFile({
url: this.url,
url: this.url,
success: res => {
success: res => {
console.log('downloadFile res: ',res);
console.log('downloadFile res: ',
res);
if (res.statusCode == 200) {
if (res.statusCode == 200) {
this.tempFilePath = res.tempFilePath
this.tempFilePath = res.tempFilePath
this.downLoadComplete()
this.downLoadComplete()
...
@@ -367,6 +395,21 @@
...
@@ -367,6 +395,21 @@
border-bottom-right-radius: 30rpx;
border-bottom-right-radius: 30rpx;
}
}
.content-body-title {
flex-direction: row;
align-items: center;
}
.content-body-title .version {
padding-left: 20rpx;
color: #fff;
font-size: 20rpx;
margin-left: 10rpx;
padding: 4rpx 8rpx;
border-radius: 20rpx;
background: #50aefd;
}
.title {
.title {
font-size: 32rpx;
font-size: 32rpx;
font-weight: bold;
font-weight: bold;
...
@@ -416,6 +459,8 @@
...
@@ -416,6 +459,8 @@
}
}
.content-button {
.content-button {
border: none;
color: #fff;
width: 100%;
width: 100%;
height: 80rpx;
height: 80rpx;
line-height: 80rpx;
line-height: 80rpx;
...
@@ -427,6 +472,7 @@
...
@@ -427,6 +472,7 @@
text-align: center;
text-align: center;
background-color: #1785ff;
background-color: #1785ff;
}
}
.flex-column {
.flex-column {
...
...
uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
浏览文件 @
9b4c7961
...
@@ -245,8 +245,12 @@
...
@@ -245,8 +245,12 @@
uni
.
navigateBack
()
uni
.
navigateBack
()
},
},
updateApp
()
{
updateApp
()
{
this
.
checkStoreScheme
().
catch
(()
=>
{
this
.
checkStoreScheme
()
.
catch
(()
=>
{
this
.
downloadPackage
()
this
.
downloadPackage
()
})
.
finally
(()
=>
{
openSchemePromise
=
null
})
})
},
},
// 跳转应用商店
// 跳转应用商店
...
...
uni_modules/uni-upgrade-center-app/utils/call-check-version.ts
浏览文件 @
9b4c7961
...
@@ -76,18 +76,20 @@ export default function (): Promise<UniUpgradeCenterResult> {
...
@@ -76,18 +76,20 @@ export default function (): Promise<UniUpgradeCenterResult> {
name
:
'
uni-upgrade-center
'
,
name
:
'
uni-upgrade-center
'
,
data
:
data
data
:
data
}).
then
(
res
=>
{
}).
then
(
res
=>
{
const
result
=
JSON
.
parse
<
UniUpgradeCenterResult
>
(
JSON
.
stringify
(
res
.
result
))
const
code
=
res
.
result
[
'
code
'
]
if
(
result
===
null
)
{
if
([
'
Int
'
,
'
Long
'
,
'
number
'
].
includes
(
typeof
code
)
&&
(
code
as
number
)
<
0
)
{
reject
({
reject
({
code
:
res
.
result
[
'
code
'
],
code
:
res
.
result
[
'
code
'
],
message
:
res
.
result
[
'
message
'
]
message
:
res
.
result
[
'
message
'
]
})
})
}
else
{
}
else
{
const
result
=
JSON
.
parse
<
UniUpgradeCenterResult
>
(
JSON
.
stringify
(
res
.
result
))
as
UniUpgradeCenterResult
resolve
(
result
)
resolve
(
result
)
}
}
}).
catch
<
void
>
((
err
:
any
|
null
)
=>
{
}).
catch
<
void
>
((
err
:
any
|
null
)
=>
{
console
.
log
(
'
err:
'
,
err
);
const
error
=
err
as
UniCloudError
const
error
=
err
as
UniCloudError
if
(
error
.
errMsg
==
'
未匹配到云函数[uni-upgrade-center]
'
)
error
.
errMsg
=
'
【uni-upgrade-center-app】未配置uni-upgrade-center,无法升级。参考: https://uniapp.dcloud.net.cn/uniCloud/upgrade-center.html
'
reject
(
error
.
errMsg
)
reject
(
error
.
errMsg
)
})
})
}
catch
(
e
)
{
}
catch
(
e
)
{
...
...
uni_modules/uni-upgrade-center-app/utils/check-update.ts
浏览文件 @
9b4c7961
...
@@ -22,7 +22,7 @@ export default function (component : ComponentPublicInstance | null = null) : Pr
...
@@ -22,7 +22,7 @@ export default function (component : ComponentPublicInstance | null = null) : Pr
// const platform = uniUpgradeCenterResult.platform // 安装包平台
// const platform = uniUpgradeCenterResult.platform // 安装包平台
// const type = uniUpgradeCenterResult.type // 安装包类型
// const type = uniUpgradeCenterResult.type // 安装包类型
// 此处逻辑仅为
实
例,可自行编写
// 此处逻辑仅为
示
例,可自行编写
if
(
code
>
0
)
{
if
(
code
>
0
)
{
// 腾讯云和阿里云下载链接不同,需要处理一下,阿里云会原样返回
// 腾讯云和阿里云下载链接不同,需要处理一下,阿里云会原样返回
const
tcbRes
=
await
uniCloud
.
getTempFileURL
({
fileList
:
[
url
]
});
const
tcbRes
=
await
uniCloud
.
getTempFileURL
({
fileList
:
[
url
]
});
...
@@ -61,7 +61,6 @@ export default function (component : ComponentPublicInstance | null = null) : Pr
...
@@ -61,7 +61,6 @@ export default function (component : ComponentPublicInstance | null = null) : Pr
return
resolve
(
uniUpgradeCenterResult
)
return
resolve
(
uniUpgradeCenterResult
)
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
// TODO 云函数报错处理
// TODO 云函数报错处理
console
.
error
(
err
)
reject
(
err
)
reject
(
err
)
})
})
});
});
...
...
uni_modules/uni-upgrade-center-app/utils/utils.uts
0 → 100644
浏览文件 @
9b4c7961
import Intent from 'android.content.Intent';
import Uri from 'android.net.Uri';
export function openSchema(url : string) : Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
try {
const context = UTSAndroid.getUniActivity()!;
const uri = Uri.parse(url)
const intent = new Intent(Intent.ACTION_VIEW, uri)
intent.setData(uri);
context.startActivity(intent);
resolve(true)
} catch (e) {
reject(e)
}
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录