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

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

上级 333d04b2
<script lang="uts"> <script lang="uts">
import { state, setLifeCycleNum,checkSystemTheme } from '@/store/index.uts' import { state, setLifeCycleNum, checkSystemTheme, setNetless } from '@/store/index.uts'
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
let firstBackTime = 0 let firstBackTime = 0
...@@ -68,10 +68,21 @@ ...@@ -68,10 +68,21 @@
}) })
} }
} }
}) })
// #ifdef APP-HARMONY
uni.getNetworkType({
success(res) {
setNetless(res.networkType === 'none')
}
})
uni.onNetworkStatusChange((res) => {
setNetless(res.isConnected === false)
})
// #endif
} }
// #endif // #endif
// 获取系统主题 // 获取系统主题
checkSystemTheme(); checkSystemTheme();
......
...@@ -81,8 +81,25 @@ ...@@ -81,8 +81,25 @@
}, },
isDarkMode() : boolean { isDarkMode() : boolean {
return state.isDarkMode 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: { methods: {
goPage(url : string) { goPage(url : string) {
if (url == '/set-tab-bar') { if (url == '/set-tab-bar') {
......
...@@ -69,8 +69,25 @@ ...@@ -69,8 +69,25 @@
}, },
isDarkMode() : boolean { isDarkMode() : boolean {
return state.isDarkMode 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: { methods: {
goPage(url : string) { goPage(url : string) {
if (this.hasLeftWin) { if (this.hasLeftWin) {
......
...@@ -251,8 +251,25 @@ ...@@ -251,8 +251,25 @@
}, },
isDarkMode() : boolean { isDarkMode() : boolean {
return state.isDarkMode 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: { methods: {
triggerCollapse(index : number, item : ListItem) { triggerCollapse(index : number, item : ListItem) {
if (item.pages.length == 0) { if (item.pages.length == 0) {
...@@ -319,4 +336,4 @@ ...@@ -319,4 +336,4 @@
.uni-panel-h { .uni-panel-h {
padding: 12px 18px; padding: 12px 18px;
} }
</style> </style>
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
type ListItem = { _id : string, content : string, src : string, poster_src : string } type ListItem = { _id : string, content : string, src : string, poster_src : string }
let page : number = 0, let page : number = 0,
currentPageIsShow : boolean = true; currentPageIsShow : boolean = true;
import { state, setNetless } from '@/store/index.uts'
export default { export default {
components: {}, components: {},
data() { data() {
...@@ -45,8 +46,17 @@ ...@@ -45,8 +46,17 @@
} }
}, },
created() { created() {
this.list = this.getData() // #ifdef APP-HARMONY
this.visibleList = this.list.slice(0, 3) 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: { watch: {
current(current : number, oldCurrent : number) { current(current : number, oldCurrent : number) {
...@@ -155,17 +165,30 @@ ...@@ -155,17 +165,30 @@
} }
}, },
getData() : ListItem[] { getData() : ListItem[] {
let videoUrlList = [ let videoUrlList = state.netless
'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', '/static/test-video/10second-demo.mp4',
'https://web-ext-storage.dcloud.net.cn/uni-app-x/video/uni-verify-5-16.mp4' '/static/test-video/10second-demo.mp4',
] as string[] '/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 = 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 posterSrcList = [
'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[]; let list = [] as ListItem[];
for (let i = 0; i < 6; i++) { for (let i = 0; i < 6; i++) {
......
...@@ -28,7 +28,9 @@ type State = { ...@@ -28,7 +28,9 @@ type State = {
// 是否同意截屏 // 是否同意截屏
allowCapture: boolean, allowCapture: boolean,
// 是否暗黑主题(适配web端) // 是否暗黑主题(适配web端)
isDarkMode: boolean isDarkMode: boolean
// 是否无网环境
netless: boolean
} }
const getAgreePrivacy = () => { const getAgreePrivacy = () => {
...@@ -60,7 +62,8 @@ export const state = reactive({ ...@@ -60,7 +62,8 @@ export const state = reactive({
}, },
agreeToPrivacy: getAgreePrivacy(), agreeToPrivacy: getAgreePrivacy(),
allowCapture: true, allowCapture: true,
isDarkMode:false isDarkMode:false,
netless: false
} as State) } as State)
export const setLifeCycleNum = (num : number) => { export const setLifeCycleNum = (num : number) => {
...@@ -125,5 +128,8 @@ export const checkSystemTheme = () => { ...@@ -125,5 +128,8 @@ export const checkSystemTheme = () => {
}) })
// #endif // #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.
先完成此消息的编辑!
想要评论请 注册