Browse Source

Merge branch 'dev/v4.8.91_cyl' of qmx/jy into feature/v4.8.91

cuiyalong 1 year ago
parent
commit
a960086f18
2 changed files with 32 additions and 9 deletions
  1. 26 0
      src/web/staticres/public-pc/js/sub-page.js
  2. 6 9
      src/web/templates/pc/supsearch.html

+ 26 - 0
src/web/staticres/public-pc/js/sub-page.js

@@ -85,6 +85,32 @@ function openWorkBenchLink (options) {
   }
 }
 
+/**
+ * 工作桌面内打开某个url
+ * inWorkspace: 当前是否在工作桌面内打开某个url
+ * conf.url: 将要打开的url
+ * conf.newTab: 是否新窗口打开
+ */
+function openLinkInWorkspace (inWorkspace, conf) {
+  var url = conf.url
+  var newTab = conf.newTab
+  var withoutDomain = url.indexOf('http://') === -1 && url.indexOf('https://') === -1
+  var targetLink = ''
+  if (withoutDomain) {
+    targetLink = location.origin + url
+  }
+  if (inWorkspace) {
+    targetLink = '/page_workDesktop/work-bench/page?link=' + encodeURIComponent(targetLink)
+  } else {
+    targetLink = url
+  }
+  if (newTab) {
+    window.open(targetLink)
+  } else {
+    location.href = targetLink
+  }
+}
+
 /**
  * 注入全局事件链接跳转
  */

+ 6 - 9
src/web/templates/pc/supsearch.html

@@ -2894,16 +2894,13 @@ function checkTagDisabled () {
     if(loginflag){
       checkVisited()
       // aHref += aHref.indexOf('?') > -1 ? '&aside=0' : '?aside=0'
-      var targetLink = '/article/content/' + thisId + aHref
+      var prefix = goTemplateData.inIframe ? '/article/content/' : '/nologin/content/'
+      var targetLink = prefix + thisId + aHref
       // 在iframe里,往工作桌面跳转。不在iframe里,正常跳转
-      // if(goTemplateData.inIframe){
-      //   var workspaceTargetLink = location.origin + targetLink
-      //   var wordspcePage = '/page_workDesktop/work-bench/page?link=' + encodeURIComponent(workspaceTargetLink)
-      //   window.open(wordspcePage)
-      // } else {
-      //   window.open(targetLink)
-      // }
-      window.open(targetLink)
+      openLinkInWorkspace(goTemplateData.inIframe, {
+        url: targetLink,
+        newTab: true,
+      })
     }else{//没有登录跳转新的详情
       checkVisited('nologin')
       // 渠道合作页,未登录跳转需要弹出登录,重置到已登录后的详情页