简体   繁体   English

没有客户端网址处理的动态网站

[英]Dynamic website without client side url handling

I have a challenge that I can't solve. 我有一个我无法解决的挑战。 I have made a website with node.js and have all of the code written for the routing including routing for sub-domains. 我已经使用node.js创建了一个网站,并为路由(包括子域的路由)编写了所有代码。 Some location only some users can access, some locations only logged in users can access. 只有某些用户可以访问的某些位置,只有登录用户可以访问的某些位置。 I wanted to include a chat for my users so I went along and created one with socket.io and some client side js. 我想为我的用户添加一个聊天记录,所以我继续使用socket.io和一些客户端js创建了一个聊天记录。

Now I need the site to keep the chat element open which in on a bar across the screen when the client goes to another portion of the website. 现在,我需要该站点保持聊天元素打开,当客户端转到该网站的另一部分时,该聊天元素将位于屏幕上的栏中。 I have looked into many solutions but almost all of them include some js library like angular.js with the ng-model or ui technique but all include writing code for the client side that handles the url and what to load. 我研究了许多解决方案,但是几乎所有解决方案都包括一些js库(例如带有ng-model或ui技术的angular.js),但都包括为客户端编写处理url和加载内容的代码。

I don't really want to do this method because: 我真的不想这样做,因为:

  1. I don't want to re-write all my routes and I am not even sure how to handle the authentication of the users. 我不想重写所有路由,甚至不知道如何处理用户身份验证。
  2. I find the client method to be a security issue 我发现客户端方法是一个安全问题
  3. My website isn't a single page app, I just want one portion of the website to stay loaded. 我的网站不是单页应用程序,我只希望网站的一部分保持加载状态。

Here is some images of what I am wanting: 以下是我想要的图像:

State 1: State1 国家1: 状态1

State 2: State2 状态2: State2

Notice that the chat stays but other content was loaded. 请注意,聊天保留,但其他内容已加载。 Also that it went to a different sub domain and a location that is only accessible by logged in users. 另外,它转到了另一个子域和一个只能由登录用户访问的位置。

Thanks! 谢谢!

I guess you want to maintain state across page refresh, much like eg Facebook does. 我想您想像刷新页面一样保持页面刷新的状态。 A true and trusted way of doing this is setting a cookie that stores the chat state: open/closed, or store the state on the server. 这样做的一种真正可靠的方式是设置一个cookie,该cookie存储聊天状态:打开/关闭,或将状态存储在服务器上。 Then on page load, initialize the chat based on this data. 然后在页面加载时,根据此数据初始化聊天。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM