引导之旅- URL与不同的值每个用户

Bootstrap Tour - URL with different value per user

本文关键字:用户 之旅 URL      更新时间:2023-09-26

我已经看过其他问题/答案,但我就是找不到一个解决我的问题。我在这里看了原始文档,但解决方案对我来说没有意义。

以下代码中的路径因用户而异

onNext: function(){
        document.location.href = 'http://localhost:8080/web/client/biography';
      },

那么接下来用户将根据他们的用户名被定向到一个不同的路径。

我怎么能确保URL是正确的每个用户?

http://localhost:8080/web/client/biography
http://localhost:8080/web/client1/biography
http://localhost:8080/web/client2/biography
我代码:

 <script>
// Instance the tour
var tour = new Tour({
	name: "tour",
  steps: [],
  container: "body",
  keyboard: true,
  storage: window.localStorage,
  debug: false,
  backdrop: true,
  backdropContainer: 'body',
  backdropPadding: 0,
  steps: [
  {
    element: ".logo",
    title: "Setup Wizard",
    content: "Synergistically visualize maintainable metrics vis-a-vis.",
  },
  {
    //element: "#groups",
    //backdrop: false,
  //  title: "Setup Wizard",
   // content: "Synergistically visualize maintainable metrics vis-a-vis."
   
  },
  {
    element: ".group-content",
    //backdrop: false,
    onNext: function(){
        document.location.href = 'http://localhost:8080/web/client/biography';
      },
    title: "Setup Wizard",
    content: "To get started we'd like you to setup your group subscriptions, and later tell us a bit more about yourself. Please tick your interested groups and click on Save"
  },
  {
    element: ".user-profile-portlet",
    onEnd: function(){
        document.location.href = 'http://localhost:8080/user/client/home';
      },
    title: "Setup Wizard",
    content: "Go ahead and click on 'edit' and tell us a bit more about yourself."
    
  }
 
]});
// Initialize the tour
tour.init();
// Start the tour
tour.start();
    </script>
 

@Adriano Repetti的回答很好,实际上应该被视为最佳实践。然而,由于许多原因,我无法在服务器端更改许多东西,使用liferay门户就是其中之一!

如果有人也有兴趣知道答案,这是我的解决方案:

:

onNext: function(){
        var n=window.location.href;
        //alert(n);
        n=n.replace('/user/','/web/').replace('/groups','/biography');
        document.location.href = n;
      },

这告诉tour找到当前url并将其分配给n。然后将/user/替换为/web/,以此类推。然后将新值赋给n,并告诉onNext函数点击它!

我希望这对你有帮助。