diff --git a/config/dev.js b/config/dev.js index c641c82..9bec9a4 100644 --- a/config/dev.js +++ b/config/dev.js @@ -10,8 +10,8 @@ module.exports = { h5: { devServer: { //host: '0.0.0.0', - // host: '192.168.110.53', - host: '192.168.3.102', + host: '192.168.110.53', + // host: '192.168.3.102', port: 10086, // 设置代理来解决 H5 请求的跨域问题 proxy: { diff --git a/src/api/proto.js b/src/api/proto.js index 45e47d2..3003196 100644 --- a/src/api/proto.js +++ b/src/api/proto.js @@ -2135,6 +2135,209 @@ export const api = $root.api = (() => { return ResLobbyView; })(); + api.ResLobbyFresh = (function() { + + /** + * Properties of a ResLobbyFresh. + * @memberof api + * @interface IResLobbyFresh + * @property {number|null} [tableNo] ResLobbyFresh tableNo + */ + + /** + * Constructs a new ResLobbyFresh. + * @memberof api + * @classdesc Represents a ResLobbyFresh. + * @implements IResLobbyFresh + * @constructor + * @param {api.IResLobbyFresh=} [properties] Properties to set + */ + function ResLobbyFresh(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResLobbyFresh tableNo. + * @member {number} tableNo + * @memberof api.ResLobbyFresh + * @instance + */ + ResLobbyFresh.prototype.tableNo = 0; + + /** + * Creates a new ResLobbyFresh instance using the specified properties. + * @function create + * @memberof api.ResLobbyFresh + * @static + * @param {api.IResLobbyFresh=} [properties] Properties to set + * @returns {api.ResLobbyFresh} ResLobbyFresh instance + */ + ResLobbyFresh.create = function create(properties) { + return new ResLobbyFresh(properties); + }; + + /** + * Encodes the specified ResLobbyFresh message. Does not implicitly {@link api.ResLobbyFresh.verify|verify} messages. + * @function encode + * @memberof api.ResLobbyFresh + * @static + * @param {api.IResLobbyFresh} message ResLobbyFresh message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResLobbyFresh.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.tableNo != null && Object.hasOwnProperty.call(message, "tableNo")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.tableNo); + return writer; + }; + + /** + * Encodes the specified ResLobbyFresh message, length delimited. Does not implicitly {@link api.ResLobbyFresh.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResLobbyFresh + * @static + * @param {api.IResLobbyFresh} message ResLobbyFresh message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResLobbyFresh.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResLobbyFresh message from the specified reader or buffer. + * @function decode + * @memberof api.ResLobbyFresh + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResLobbyFresh} ResLobbyFresh + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResLobbyFresh.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ResLobbyFresh(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.tableNo = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResLobbyFresh message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResLobbyFresh + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResLobbyFresh} ResLobbyFresh + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResLobbyFresh.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResLobbyFresh message. + * @function verify + * @memberof api.ResLobbyFresh + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResLobbyFresh.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.tableNo != null && message.hasOwnProperty("tableNo")) + if (!$util.isInteger(message.tableNo)) + return "tableNo: integer expected"; + return null; + }; + + /** + * Creates a ResLobbyFresh message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResLobbyFresh + * @static + * @param {Object.} object Plain object + * @returns {api.ResLobbyFresh} ResLobbyFresh + */ + ResLobbyFresh.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResLobbyFresh) + return object; + let message = new $root.api.ResLobbyFresh(); + if (object.tableNo != null) + message.tableNo = object.tableNo | 0; + return message; + }; + + /** + * Creates a plain object from a ResLobbyFresh message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResLobbyFresh + * @static + * @param {api.ResLobbyFresh} message ResLobbyFresh + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResLobbyFresh.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) + object.tableNo = 0; + if (message.tableNo != null && message.hasOwnProperty("tableNo")) + object.tableNo = message.tableNo; + return object; + }; + + /** + * Converts this ResLobbyFresh to JSON. + * @function toJSON + * @memberof api.ResLobbyFresh + * @instance + * @returns {Object.} JSON object + */ + ResLobbyFresh.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResLobbyFresh + * @function getTypeUrl + * @memberof api.ResLobbyFresh + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResLobbyFresh.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResLobbyFresh"; + }; + + return ResLobbyFresh; + })(); + api.LobbyTable = (function() { /** diff --git a/src/pages/lobby/lobby.jsx b/src/pages/lobby/lobby.jsx index 7c9e913..ddae538 100644 --- a/src/pages/lobby/lobby.jsx +++ b/src/pages/lobby/lobby.jsx @@ -7,6 +7,7 @@ import { setBalance } from '@/store/user'; import './lobby.scss' import { navigateTo, redirectTo, showToast } from '@/utils/application' import { reqLobbyView, reqJoinTable, reqAccountBalance } from '@/api/wsapi' +import { addMsgListen, removeMsgListener } from '@/api/websocket' import Title from '@/components/title' import coin1 from '@/assets/coin-1.png' import robotIcon from '@/assets/icon/robot-1.svg' @@ -31,9 +32,18 @@ class Lobby extends Component { this.circleElePos = [{x:16,y:8},{x:70,y:-3},{x:110,y:28},{x:115,y:70},{x:80,y:105},{x:20,y:100},{x:-2,y:60}]; } + + componentWillUnmount() { + // 取消监听消息 + removeMsgListener('api.ResLobbyFresh'); + } + componentDidMount() { + // 有新桌面创建消息监听 + addMsgListen('api.ResLobbyFresh', this.handleReqLobbyView); + // setTimeout(() => { - this.handleReqLobbyView(); + this.handleReqLobbyView(); // }, 1500) // fetchLobbyView() // .then(res => { @@ -87,6 +97,7 @@ class Lobby extends Component { // console.log('join res...', res) }catch(err) { showToast({title: err}) + this.handleReqLobbyView(); } } @@ -135,7 +146,7 @@ class Lobby extends Component { - + ) diff --git a/src/pages/login/login.jsx b/src/pages/login/login.jsx index c1e93c3..30db896 100644 --- a/src/pages/login/login.jsx +++ b/src/pages/login/login.jsx @@ -67,7 +67,7 @@ function Login() { setState({...state, password: e.target.value})}/> - + setState({...state, captcha: e.target.value})}/> @@ -77,6 +77,12 @@ function Login() { + 新用户自动注册 diff --git a/src/pages/new_table/new_table.jsx b/src/pages/new_table/new_table.jsx index 723776f..9878620 100644 --- a/src/pages/new_table/new_table.jsx +++ b/src/pages/new_table/new_table.jsx @@ -63,8 +63,8 @@ function NewTable() { 限注德州扑克 - 底池限制德州扑克 - 无限制德州扑克 + 底池限注德州扑克 + 无限注德州扑克 @@ -111,7 +111,7 @@ function NewTable() { - {nickname} + {username}