Skip to content

Commit

Permalink
feat: 🚀 添加跳转外部网页功能
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Sep 9, 2023
1 parent 0ab60df commit 8d062a9
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 2 deletions.
12 changes: 12 additions & 0 deletions pages.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ export default defineUniPages({
},
],
subPackages: [
{
root: 'pages/webview',
pages: [
{
path: 'index',
aliasPath: '/webview',
style: {
navigationBarTitleText: 'webview',
},
},
],
},
{
root: 'pages/middleware',
pages: [
Expand Down
12 changes: 12 additions & 0 deletions src/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@
}
}
]
},
{
"root": "pages/webview",
"pages": [
{
"path": "index",
"aliasPath": "/webview",
"style": {
"navigationBarTitleText": "webview"
}
}
]
}
],
"tabBar": {
Expand Down
20 changes: 19 additions & 1 deletion src/pages/login/phone/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@
<view
class="absolute inset-x-0 bottom-0 text-center mb-4 text-gray-400 text-sm"
>
<view>Supported by {{ enterpriseInfo.name }} v{{ version }}</view>
<view>
Supported by
<text
class="text-primary-500 underline active:text-primary-700"
@click="handleInfo"
>
{{ enterpriseInfo.name }}
</text>
v{{ version }}
</view>
</view>
</view>
</template>
Expand All @@ -52,6 +61,15 @@ export default {
this.getLoginCode()
},
methods: {
handleInfo() {
this.$Router.push({
path: '/webview',
query: {
title: 'viarotel',
src: 'https://viarotel.eu.org/',
},
})
},
getLoginCode() {
uni.login({
provider: 'weixin', // 使用微信登录
Expand Down
25 changes: 25 additions & 0 deletions src/pages/webview/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<web-view class="h-full" v-bind="viewProps" :src="viewProps.src"></web-view>
</template>

<script>
export default {
data() {
return {
viewProps: {
src: '',
},
}
},
onLoad(params) {
this.viewProps = params
if (params.title) {
uni.setNavigationBarTitle({
title: params.title,
})
}
},
}
</script>

<style></style>
2 changes: 1 addition & 1 deletion src/router/guards/permission/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import store from '@/store/index.js'
const homePath = '/pages/index/home/index'
const loginPath = '/pages/login/phone/index'

const whiteList = [loginPath, '/pages/statement/index']
const whiteList = [loginPath, '/pages/statement/index', '/pages/webview/index']

const permission = (router) => {
const userStore = store.useUserStore()
Expand Down

0 comments on commit 8d062a9

Please sign in to comment.