提交 74a9be23 编写于 作者: D DCloud_LXH

chore(harmony): 上架做无网处理

上级 333d04b2
<script lang="uts">
import { state, setLifeCycleNum,checkSystemTheme } from '@/store/index.uts'
import { state, setLifeCycleNum, checkSystemTheme, setNetless } from '@/store/index.uts'
// #ifdef APP-ANDROID
let firstBackTime = 0
......@@ -69,9 +69,20 @@
}
}
})
// #ifdef APP-HARMONY
uni.getNetworkType({
success(res) {
setNetless(res.networkType === 'none')
}
// #endif
})
uni.onNetworkStatusChange((res) => {
setNetless(res.isConnected === false)
})
// #endif
}
// #endif
// 获取系统主题
checkSystemTheme();
......
......@@ -81,8 +81,25 @@
},
isDarkMode() : boolean {
return state.isDarkMode
},
netless() : boolean {
return state.netless
}
},
// #ifdef APP-HARMONY
watch: {
'netless': {
immediate: true,
handler(netless) {
if (netless) {
this.menu = this.menu.filter(item => {
return !['unicloud'].includes(item.id)
})
}
}
}
},
// #endif
methods: {
goPage(url : string) {
if (url == '/set-tab-bar') {
......
......@@ -69,8 +69,25 @@
},
isDarkMode() : boolean {
return state.isDarkMode
},
netless() : boolean {
return state.netless
}
},
// #ifdef APP-HARMONY
watch: {
'netless': {
immediate: true,
handler(netless) {
if (netless) {
this.menu = this.menu.filter(item => {
return !['unicloud'].includes(item.id)
})
}
}
}
},
// #endif
methods: {
goPage(url : string) {
if (this.hasLeftWin) {
......
......@@ -251,8 +251,25 @@
},
isDarkMode() : boolean {
return state.isDarkMode
},
netless() : boolean {
return state.netless
}
},
// #ifdef APP-HARMONY
watch: {
'netless': {
immediate: true,
handler(netless) {
if (netless) {
this.list = this.list.filter(item => {
return !['list-news'].includes(item.id)
})
}
}
}
},
// #endif
methods: {
triggerCollapse(index : number, item : ListItem) {
if (item.pages.length == 0) {
......
......@@ -31,6 +31,7 @@
let page : number = 0,
currentPageIsShow : boolean = true;
import { state, setNetless } from '@/store/index.uts'
export default {
components: {},
data() {
......@@ -45,8 +46,17 @@
}
},
created() {
// #ifdef APP-HARMONY
uni.getNetworkType({
success: (res) => {
setNetless(res.networkType === 'none')
// #endif
this.list = this.getData()
this.visibleList = this.list.slice(0, 3)
// #ifdef APP-HARMONY
}
})
// #endif
},
watch: {
current(current : number, oldCurrent : number) {
......@@ -155,18 +165,31 @@
}
},
getData() : ListItem[] {
let videoUrlList = [
let videoUrlList = state.netless
? [
'/static/test-video/10second-demo.mp4',
'/static/test-video/10second-demo.mp4',
'/static/test-video/10second-demo.mp4'
]
: [
'https://web-ext-storage.dcloud.net.cn/uni-app-x/video/uts-5-16.mp4',
'https://web-ext-storage.dcloud.net.cn/uni-app-x/video/uni-ai-5-16.mp4',
'https://web-ext-storage.dcloud.net.cn/uni-app-x/video/uni-verify-5-16.mp4'
] as string[]
let posterSrcList = [
let posterSrcList = state.netless
? [
'/static/shuijiao.jpg',
'/static/logo.jpg',
'/static/shuijiao.jpg'
]
: [
'https://web-ext-storage.dcloud.net.cn/uni-app-x/dark-uni-uts-01.png',
'https://web-ext-storage.dcloud.net.cn/uni-app-x/dark-uni-ai-01.png',
'https://web-ext-storage.dcloud.net.cn/uni-app-x/dark-uni-verify-01.jpg'
] as string[]
let list = [] as ListItem[];
for (let i = 0; i < 6; i++) {
let index = this.list.length + i;
......
......@@ -29,6 +29,8 @@ type State = {
allowCapture: boolean,
// 是否暗黑主题(适配web端)
isDarkMode: boolean
// 是否无网环境
netless: boolean
}
const getAgreePrivacy = () => {
......@@ -60,7 +62,8 @@ export const state = reactive({
},
agreeToPrivacy: getAgreePrivacy(),
allowCapture: true,
isDarkMode:false
isDarkMode:false,
netless: false
} as State)
export const setLifeCycleNum = (num : number) => {
......@@ -126,4 +129,7 @@ export const checkSystemTheme = () => {
// #endif
}
export const setNetless = (netless: boolean) => {
state.netless = netless
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册