sadais-piui 1.2.7-beta76 → 1.2.7-beta77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,88 +1,92 @@
1
- <template>
2
- <view class="pi-scroll-container">
3
- <!-- #ifndef MP -->
4
- <slot name="title">
5
- <pi-navbar :show-home="false">{{ title }}</pi-navbar>
6
- </slot>
7
- <!-- #endif -->
8
- <!-- #ifndef APP-PLUS -->
9
- <web-view v-if="webviewURL" :progress="true" :src="webviewURL" class="pi-scroll pi-safearea" />
10
- <!-- #endif -->
11
- </view>
12
- </template>
13
-
14
- <script>
15
- const TAG = 'PiWebview'
16
- export default {
17
- name: 'PiWebview',
18
- props: {
19
- title: {
20
- type: String
21
- },
22
- url: {
23
- type: String
24
- },
25
- autoAddTimestamp: {
26
- type: Boolean,
27
- default: () => true
28
- }
29
- },
30
- data() {
31
- return {
32
- webviewURL: ''
33
- }
34
- },
35
- watch: {
36
- url: {
37
- deep: true,
38
- immediate: true,
39
- handler(value) {
40
- value && this.init()
41
- }
42
- }
43
- },
44
- methods: {
45
- init() {
46
- // 设置标题
47
- if (this.title) {
48
- uni.setNavigationBarTitle({
49
- title: this.title
50
- })
51
- }
52
- if (!this.url) return
53
- // H5 url 需要加时间戳,否则会有缓存问题
54
- this.webviewURL = this.autoAddTimestamp
55
- ? this.urlAddParam(this.url || '', {
56
- sadaisTimestamp: new Date().getTime() + '-' + Math.round(Math.random(1) * 10000)
57
- })
58
- : this.url
59
- console.log('webview页面即将打开以下URL:', this.webviewURL)
60
- // #ifdef APP-PLUS
61
- const wv = plus.webview.create('', 'custom-webview', {
62
- 'plusrequire': 'none', // 禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
63
- 'uni-app': 'none', // 不加载uni-app渲染层框架,避免样式冲突
64
- 'top': uni.getSystemInfoSync().statusBarHeight + 44 // 放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值
65
- })
66
- wv.loadURL(this.webviewURL)
67
- const currentWebview = this.$mp.page.$getAppWebview() // 获取当前页面的webview对象
68
- currentWebview.append(wv) // 一定要append到当前的页面里,才能跟随当前页面一起做动画,一起关闭
69
- // #endif
70
- },
71
- urlAddParam(url, params) {
72
- params = this.$pi.navi.objToUrl(params)
73
- if (url.indexOf('?') !== -1 && params) {
74
- url = url + params.replace('?', '&')
75
- } else {
76
- url = url + params
77
- }
78
- return url
79
- }
80
- }
81
- }
82
- </script>
83
-
84
- <style lang="scss" scoped>
85
- .pi-scroll-container {
86
- background-color: #ffffff;
87
- }
88
- </style>
1
+ <template>
2
+ <view class="pi-scroll-container">
3
+ <!-- #ifndef MP -->
4
+ <slot name="title">
5
+ <pi-navbar :show-home="showHome">{{ title }}</pi-navbar>
6
+ </slot>
7
+ <!-- #endif -->
8
+ <!-- #ifndef APP-PLUS -->
9
+ <web-view v-if="webviewURL" :progress="true" :src="webviewURL" class="pi-scroll pi-safearea" />
10
+ <!-- #endif -->
11
+ </view>
12
+ </template>
13
+
14
+ <script>
15
+ const TAG = 'PiWebview'
16
+ export default {
17
+ name: 'PiWebview',
18
+ props: {
19
+ title: {
20
+ type: String
21
+ },
22
+ showHome: {
23
+ type: Boolean,
24
+ default: () => false
25
+ },
26
+ url: {
27
+ type: String
28
+ },
29
+ autoAddTimestamp: {
30
+ type: Boolean,
31
+ default: () => true
32
+ }
33
+ },
34
+ data() {
35
+ return {
36
+ webviewURL: ''
37
+ }
38
+ },
39
+ watch: {
40
+ url: {
41
+ deep: true,
42
+ immediate: true,
43
+ handler(value) {
44
+ value && this.init()
45
+ }
46
+ }
47
+ },
48
+ methods: {
49
+ init() {
50
+ // 设置标题
51
+ if (this.title) {
52
+ uni.setNavigationBarTitle({
53
+ title: this.title
54
+ })
55
+ }
56
+ if (!this.url) return
57
+ // H5 url 需要加时间戳,否则会有缓存问题
58
+ this.webviewURL = this.autoAddTimestamp
59
+ ? this.urlAddParam(this.url || '', {
60
+ sadaisTimestamp: new Date().getTime() + '-' + Math.round(Math.random(1) * 10000)
61
+ })
62
+ : this.url
63
+ console.log('webview页面即将打开以下URL:', this.webviewURL)
64
+ // #ifdef APP-PLUS
65
+ const wv = plus.webview.create('', 'custom-webview', {
66
+ 'plusrequire': 'none', // 禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
67
+ 'uni-app': 'none', // 不加载uni-app渲染层框架,避免样式冲突
68
+ 'top': uni.getSystemInfoSync().statusBarHeight + 44 // 放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值
69
+ })
70
+ wv.loadURL(this.webviewURL)
71
+ const currentWebview = this.$mp.page.$getAppWebview() // 获取当前页面的webview对象
72
+ currentWebview.append(wv) // 一定要append到当前的页面里,才能跟随当前页面一起做动画,一起关闭
73
+ // #endif
74
+ },
75
+ urlAddParam(url, params) {
76
+ params = this.$pi.navi.objToUrl(params)
77
+ if (url.indexOf('?') !== -1 && params) {
78
+ url = url + params.replace('?', '&')
79
+ } else {
80
+ url = url + params
81
+ }
82
+ return url
83
+ }
84
+ }
85
+ }
86
+ </script>
87
+
88
+ <style lang="scss" scoped>
89
+ .pi-scroll-container {
90
+ background-color: #ffffff;
91
+ }
92
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7-beta76",
3
+ "version": "1.2.7-beta77",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {