diff --git a/pages.json b/pages.json index 463378598aeb9ec82dd51ac7109f50660af35e98..a19b268f2eb585e52f4c7fe9b25eb92159ede518 100644 --- a/pages.json +++ b/pages.json @@ -84,24 +84,24 @@ "style": { "navigationBarTitleText": "image" } - }, - { - "path": "pages/component/image/image-format", - "style": { - "navigationBarTitleText": "image-format" - } - }, - { - "path": "pages/component/image/image-mode", - "style": { - "navigationBarTitleText": "image-mode" - } - }, - { - "path": "pages/component/image/image-path", - "style": { - "navigationBarTitleText": "image-path" - } + }, + { + "path": "pages/component/image/image-format", + "style": { + "navigationBarTitleText": "image-format" + } + }, + { + "path": "pages/component/image/image-mode", + "style": { + "navigationBarTitleText": "image-mode" + } + }, + { + "path": "pages/component/image/image-path", + "style": { + "navigationBarTitleText": "image-path" + } }, { "path": "pages/component/web-view/web-view", @@ -530,6 +530,15 @@ } } + ,{ + "path" : "pages/component/list/list", + "style" : + { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + + } ], "globalStyle": { "pageOrientation": "portrait", diff --git a/pages/API/download-file/download-file.uvue b/pages/API/download-file/download-file.uvue index 61a7af8292c765bdacb8eb304357a0870dd03000..6bb7cebbaa6bcd1dfc1466d86d6aa86c7e7dd1a1 100644 --- a/pages/API/download-file/download-file.uvue +++ b/pages/API/download-file/download-file.uvue @@ -1,8 +1,8 @@ + .img { + width: 500rpx; + height: 500rpx; + margin: 0 auto; + } + + .image-container { + display: flex; + justify-content: center; + align-items: center; + } + \ No newline at end of file diff --git a/pages/API/request/request.uvue b/pages/API/request/request.uvue index 292682584852c41840b666b659adc45f75ee6441..3d27b480798740112baba64ac4c31011022f8754 100644 --- a/pages/API/request/request.uvue +++ b/pages/API/request/request.uvue @@ -15,55 +15,70 @@ + \ No newline at end of file diff --git a/pages/API/upload-file/upload-file.uvue b/pages/API/upload-file/upload-file.uvue index a5f26a60a5ee9bb236d25728d0b1eb63c5b1c004..edcb14d31045a3a0256fc5f917f8de9091c590e5 100644 --- a/pages/API/upload-file/upload-file.uvue +++ b/pages/API/upload-file/upload-file.uvue @@ -10,15 +10,24 @@ - - + this.pageVisible = false; + const closeOptions = new CloseSocketOptions(); + uni.closeSocket(closeOptions); + uni.hideLoading() + }, + methods: { + connect() { + if (this.connected || this.connecting) { + uni.showModal({ + content: '正在连接或者已经连接,请勿重复连接', + showCancel: false + }) + return + } + this.connecting = true + uni.showLoading({ + title: '连接中...' + }) + uni.connectSocket({ + url: 'ws://192.168.12.106:8080/ws', + success(res) { + // 这里是接口调用成功的回调,不是连接成功的回调,请注意 + }, + fail(err) { + // 这里是接口调用失败的回调,不是连接失败的回调,请注意 + } + }) + uni.onSocketOpen((res) => { + if (this.pageVisible) { + this.connecting = false + this.connected = true + uni.hideLoading() + + uni.showToast({ + icon: 'none', + title: '连接成功' + }) + console.log('onOpen', res); + } + }) + uni.onSocketError((err) => { + if (this.pageVisible) { + this.connecting = false + this.connected = false + uni.hideLoading() + + uni.showModal({ + content: '连接失败,可能是websocket服务不可用,请稍后再试', + showCancel: false + }) + console.log('onError', err); + } + }) + uni.onSocketMessage((res) => { + if (this.pageVisible) { + this.msg = res.data as string + console.log('onMessage', res) + } + }) + uni.onSocketClose((res) => { + if (this.pageVisible) { + this.connected = false + this.msg = "" + console.log('onClose', res) + } + }) + }, + send() { + uni.sendSocketMessage({ + data: 'from ' + platform + ' : ' + parseInt((Math.random() * 10000).toString()).toString(), + success(res) { + console.log(res); + }, + fail(err) { + console.log(err); + } + }) + }, + close() { + const closeSocketOptions = new CloseSocketOptions(); + uni.closeSocket(closeSocketOptions) + } + } + } + + + \ No newline at end of file diff --git a/pages/API/websocket-socketTask/websocket-socketTask.uvue b/pages/API/websocket-socketTask/websocket-socketTask.uvue index de19b878b89c0cb38f66409189959d119a9921e1..06f474b058aa3c85ac73db54bb40d3658a131639 100644 --- a/pages/API/websocket-socketTask/websocket-socketTask.uvue +++ b/pages/API/websocket-socketTask/websocket-socketTask.uvue @@ -24,8 +24,9 @@ connected: false, connecting: false, socketTask: null as SocketTask | null, - msg: "", - platform :"", + msg: "", + platform: "", + pageVisible: false } }, computed: { @@ -40,14 +41,16 @@ return '尚未连接' } } - }, - onReady() { - this.platform = uni.getSystemInfoSync().platform; + }, + onLoad() { + this.platform = uni.getSystemInfoSync().platform; + this.pageVisible = true; }, onUnload() { + this.pageVisible = false; uni.hideLoading() - let task = this.socketTask; - if (task != null) { + let task = this.socketTask; + if (task != null) { const closeOptions = new CloseSocketOptions(); task.close(closeOptions) } @@ -64,7 +67,7 @@ this.connecting = true uni.showLoading({ title: '连接中...' - }) + }) this.socketTask = uni.connectSocket({ url: 'ws://192.168.12.106:8080/ws', success(res) { @@ -73,36 +76,44 @@ fail(err) { // 这里是接口调用失败的回调,不是连接失败的回调,请注意 } - }) + }) this.socketTask?.onOpen((res) => { - this.connecting = false - this.connected = true - uni.hideLoading() - uni.showToast({ - icon: 'none', - title: '连接成功' - }) - console.log('onOpen', res); + if (this.pageVisible) { + this.connecting = false + this.connected = true + uni.hideLoading() + uni.showToast({ + icon: 'none', + title: '连接成功' + }) + console.log('onOpen', res); + } }) this.socketTask?.onError((err) => { - this.connecting = false - this.connected = false - uni.hideLoading() - uni.showModal({ - content: '连接失败,可能是websocket服务不可用,请稍后再试', - showCancel: false - }) - console.log('onError', err); + if (this.pageVisible) { + this.connecting = false + this.connected = false + uni.hideLoading() + uni.showModal({ + content: '连接失败,可能是websocket服务不可用,请稍后再试', + showCancel: false + }) + console.log('onError', err); + } }) this.socketTask?.onMessage((res) => { - this.msg = res.data as string - console.log('onMessage', res) + if (this.pageVisible) { + this.msg = res.data as string + console.log('onMessage', res) + } }) this.socketTask?.onClose((res) => { - this.connected = false - this.socketTask = null - this.msg = "" - console.log('onClose', res) + if (this.pageVisible) { + this.connected = false + this.socketTask = null + this.msg = "" + console.log('onClose', res) + } }) }, send() { @@ -116,7 +127,7 @@ }, close() { let task = this.socketTask; - if (task != null) { + if (task != null) { let closeOptions = new CloseSocketOptions(); task.close(closeOptions) } diff --git a/pages/component/list/list.uvue b/pages/component/list/list.uvue new file mode 100644 index 0000000000000000000000000000000000000000..504d81b6cb2369f5d8a9b89b9ac778c0cd4985e3 --- /dev/null +++ b/pages/component/list/list.uvue @@ -0,0 +1,87 @@ + + + + \ No newline at end of file diff --git a/pages/component/scroll-view/scroll-view-refresher.uvue b/pages/component/scroll-view/scroll-view-refresher.uvue index 25ff64580fd10445be13a7efeb9b5c437591d1b3..b1ed10ad33c46bbd62dc8d58797abf0bd9a824c1 100644 --- a/pages/component/scroll-view/scroll-view-refresher.uvue +++ b/pages/component/scroll-view/scroll-view-refresher.uvue @@ -10,7 +10,8 @@ -