Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Accustomed_
hello uni-app x
提交
ca11f03a
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看板
提交
ca11f03a
编写于
11月 07, 2023
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(upgrade-center): 商店跳转、版本号
上级
650952e3
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
143 addition
and
80 deletion
+143
-80
pages/tabBar/component.uvue
pages/tabBar/component.uvue
+30
-35
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
+20
-21
uni_modules/uni-upgrade-center-app/utils/utils.uts
uni_modules/uni-upgrade-center-app/utils/utils.uts
+17
-0
未找到文件。
pages/tabBar/component.uvue
浏览文件 @
ca11f03a
...
...
@@ -40,7 +40,7 @@
</template>
</uni-collapse>
<
!-- <upgradePopup ref="upgradePopup" @close="upgradePopupClose" /> --
>
<
uni-upgrade-center-app ref="upgradePopup" @close="upgradePopupClose" /
>
</view>
<!-- #ifdef APP -->
</scroll-view>
...
...
@@ -48,8 +48,7 @@
</template>
<script lang="uts">
/* 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' */
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
type Page = {
name : string
...
...
@@ -271,9 +270,6 @@ export default {
arrowRightIcon: '/static/icons/arrow-right.png',
}
},
/* components: {
upgradePopup: upgradePopup
}, */
methods: {
goDetailPage(e : Page) {
if (e.enable == false) {
...
...
@@ -293,13 +289,12 @@ export default {
console.log('upgradePopup close');
}
},
/* ,
onReady() {
checkUpdate(this.$refs['upgradePopup'] as
ComponentPublicInstance)
checkUpdate(this.$refs['upgradePopup'] as
UniUpgradeCenterAppComponentPublicInstance)
},
beforeUnmount() {
uni.showTabBar()?.catch(_ => {})
}
*/
}
}
</script>
...
...
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
浏览文件 @
ca11f03a
...
...
@@ -11,7 +11,7 @@
<view class="content-body">
<view class="content-body-title">
<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 class="body">
<scroll-view class="box-des-scroll" scroll-y="true">
...
...
@@ -41,22 +41,16 @@
</view>
</view>
<button v-else class="content-button"
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">
<button v-else class="content-button" @click="updateApp">
{{downLoadBtnText}}
</button>
</template>
<button v-else-if="downloadSuccess && !installed" class="content-button"
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">
<button v-else-if="downloadSuccess && !installed" class="content-button" :loading="installing" :disabled="installing" @click="installPackage">
{{installing ? '正在安装……' : '下载完成,立即安装'}}
</button>
<button v-else-if="installed" class="content-button"
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 v-else-if="installed" class="content-button" :disabled="true">
安装完成后,请重启应用
</button>
</template>
...
...
@@ -64,8 +58,7 @@
</view>
<view class="content-bottom">
<image v-if="!is_mandatory" class="close-img" mode="widthFix"
src="/uni_modules/uni-upgrade-center-app/static/app_update_close.png" @click="closeUpdate">
<image v-if="!is_mandatory" class="close-img" mode="widthFix" src="/uni_modules/uni-upgrade-center-app/static/app_update_close.png" @click="closeUpdate">
</image>
</view>
</view>
...
...
@@ -73,12 +66,14 @@
</template>
<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 platform_iOS = 'iOS';
const requiredKey = ['version', 'url', 'type']
let downloadTask : DownloadTask | null = null;
let openSchemePromise: Promise<boolean> | null = null;
/**
* 对比版本号,如需要,请自行修改判断规则
...
...
@@ -148,6 +143,7 @@
// 默认安装包信息
title: '更新日志',
contents: '',
version: '',
is_mandatory: false,
// 可自定义属性
...
...
@@ -157,7 +153,8 @@
downLoadingText: '安装包下载中,请稍后',
url: "",
platform: [] as string[]
platform: [] as string[],
store_list: null as StoreListItem[] | null
}
},
computed: {
...
...
@@ -184,6 +181,8 @@
this.contents = localPackageInfo.contents
this.is_mandatory = localPackageInfo.is_mandatory
this.platform = localPackageInfo.platform
this.version = localPackageInfo.version
this.store_list = localPackageInfo.store_list
this.shown = shown
},
closeUpdate() {
...
...
@@ -230,14 +229,43 @@
this.$emit('close')
},
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() {
//下载包
downloadTask = uni.downloadFile({
url: this.url,
success: res => {
console.log('downloadFile res: ',res);
console.log('downloadFile res: ',
res);
if (res.statusCode == 200) {
this.tempFilePath = res.tempFilePath
this.downLoadComplete()
...
...
@@ -367,6 +395,21 @@
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 {
font-size: 32rpx;
font-weight: bold;
...
...
@@ -416,6 +459,8 @@
}
.content-button {
border: none;
color: #fff;
width: 100%;
height: 80rpx;
line-height: 80rpx;
...
...
@@ -427,6 +472,7 @@
text-align: center;
background-color: #1785ff;
}
.flex-column {
...
...
uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
浏览文件 @
ca11f03a
...
...
@@ -245,8 +245,12 @@
uni
.
navigateBack
()
},
updateApp
()
{
this
.
checkStoreScheme
().
catch
(()
=>
{
this
.
checkStoreScheme
()
.
catch
(()
=>
{
this
.
downloadPackage
()
})
.
finally
(()
=>
{
openSchemePromise
=
null
})
},
// 跳转应用商店
...
...
uni_modules/uni-upgrade-center-app/utils/call-check-version.ts
浏览文件 @
ca11f03a
...
...
@@ -76,18 +76,20 @@ export default function (): Promise<UniUpgradeCenterResult> {
name
:
'
uni-upgrade-center
'
,
data
:
data
}).
then
(
res
=>
{
const
result
=
JSON
.
parse
<
UniUpgradeCenterResult
>
(
JSON
.
stringify
(
res
.
result
))
if
(
result
===
null
)
{
const
code
=
res
.
result
[
'
code
'
]
if
([
'
Int
'
,
'
Long
'
,
'
number
'
].
includes
(
typeof
code
)
&&
(
code
as
number
)
<
0
)
{
reject
({
code
:
res
.
result
[
'
code
'
],
message
:
res
.
result
[
'
message
'
]
})
}
else
{
const
result
=
JSON
.
parse
<
UniUpgradeCenterResult
>
(
JSON
.
stringify
(
res
.
result
))
as
UniUpgradeCenterResult
resolve
(
result
)
}
}).
catch
<
void
>
((
err
:
any
|
null
)
=>
{
console
.
log
(
'
err:
'
,
err
);
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
)
})
}
catch
(
e
)
{
...
...
uni_modules/uni-upgrade-center-app/utils/check-update.ts
浏览文件 @
ca11f03a
...
...
@@ -22,7 +22,7 @@ export default function () : Promise<UniUpgradeCenterResult> {
// const platform = uniUpgradeCenterResult.platform // 安装包平台
// const type = uniUpgradeCenterResult.type // 安装包类型
// 此处逻辑仅为实
例,可自行编写
// 此处逻辑仅为示
例,可自行编写
if
(
code
>
0
)
{
// 腾讯云和阿里云下载链接不同,需要处理一下,阿里云会原样返回
const
tcbRes
=
await
uniCloud
.
getTempFileURL
({
fileList
:
[
url
]
});
...
...
@@ -61,12 +61,11 @@ export default function () : Promise<UniUpgradeCenterResult> {
return
resolve
(
uniUpgradeCenterResult
)
}).
catch
((
err
)
=>
{
// TODO 云函数报错处理
console
.
error
(
err
)
reject
(
err
)
})
});
// #endif
}
}
// #ifdef UNI-APP-X
/**
...
...
uni_modules/uni-upgrade-center-app/utils/utils.uts
0 → 100644
浏览文件 @
ca11f03a
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录