diff --git a/frontend/src/App.vue b/frontend/src/App.vue index ec51dac30..f552b85c8 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -88,7 +88,7 @@ import '@blueking/functional-dependency/vue2/vue2.css'; import '@blueking/notice-component-vue2/dist/style.css'; // import IamGuide from '@/components/iam-guide/index.vue'; - import { existValue, formatI18nKey } from '@/common/util'; + import { existValue, formatI18nKey, navDocCenterPath } from '@/common/util'; import { bus } from '@/common/bus'; import { mapGetters } from 'vuex'; import { afterEach } from '@/router'; @@ -150,7 +150,7 @@ }; }, computed: { - ...mapGetters(['mainContentLoading', 'user', 'externalSystemsLayout']), + ...mapGetters(['mainContentLoading', 'user', 'externalSystemsLayout', 'versionLogs']), isShowNoticeAlert () { return this.showNoticeAlert && this.isEnableNoticeAlert; }, @@ -382,14 +382,15 @@ window.open(`${window.BK_DOCS_URL_PREFIX}${payload}`); }, - getRouteInstanceSearch (payload = {}) { + async getRouteInstanceSearch (payload = {}) { const { show, routeName } = payload; + const curPath = await navDocCenterPath(this.versionLogs, `/UserGuide/Feature/PermissionsApply.md`, false); const routeMap = { applyCustomPerm: () => { this.noInstanceSearchData = Object.assign({}, { show: show || false, mode: 'dialog', - url: `/IAM//1.8/UserGuide/Feature/PermissionsApply.md`, + url: curPath, title: this.$t(`m.permApply['未启用用户组自动推荐功能']`), functionalDesc: this.t(`m.permApply['该功能可以根据用户当前的权限需求,自动匹配相关的用户组']`), guideTitle: this.$t(`m.permApply['如需启用该功能,请联系部署同学部署相关ES服务']`), diff --git a/frontend/src/common/util.js b/frontend/src/common/util.js index 7c979018c..c0d3b3759 100644 --- a/frontend/src/common/util.js +++ b/frontend/src/common/util.js @@ -829,3 +829,25 @@ export const getRoutePath = (subPath) => { const path = subPath.startsWith('/') ? subPath.slice(1) : subPath; return rootPath ? `${rootPath}${path}` : subPath; }; + +/** + * 跳转不同页面的文档中心 + * @param {versionLog} versionLog 传入的版本列表 + * @param {path} path 传入的文档路径 + * @param {autoOpen} autoOpen 是否自动跳转到文档中心 + */ +export const navDocCenterPath = (versionLog, path, autoOpen = true) => { + let curVersion = '1.16'; + const curLang = formatI18nKey().toLowerCase().indexOf('en') > -1 ? 'EN' : 'ZH'; + if (versionLog.length) { + const { version } = versionLog[0]; + const lastIndex = version.lastIndexOf('.'); + curVersion = version.substring(1, lastIndex !== -1 ? lastIndex : version.length); + } + const curPath = `/${curLang}/IAM/${curVersion}${path}`; + if (autoOpen) { + window.open(`${window.BK_DOCS_URL_PREFIX}${curPath}`); + } else { + return curPath; + } +}; diff --git a/frontend/src/components/header-nav/index.vue b/frontend/src/components/header-nav/index.vue index 8343001d2..1a3079f7a 100644 --- a/frontend/src/components/header-nav/index.vue +++ b/frontend/src/components/header-nav/index.vue @@ -126,7 +126,7 @@ import { il8n, language } from '@/language'; import { bus } from '@/common/bus'; import { buildURLParams } from '@/common/url'; - import { formatI18nKey, jsonpRequest, getManagerMenuPerm } from '@/common/util'; + import { formatI18nKey, jsonpRequest, getManagerMenuPerm, navDocCenterPath } from '@/common/util'; import { NEED_CONFIRM_DIALOG_ROUTER } from '@/common/constants'; import { getRouterDiff, getNavRouterDiff } from '@/common/router-handle'; import SystemLog from '../system-log'; @@ -173,40 +173,6 @@ }; }; - const NORMAL_DOCU_LINK = '/IAM/UserGuide/Introduce/README.md'; - // const GRADE_DOCU_LINK = '/权限中心/产品白皮书/场景案例/GradingManager.md'; - - const docuLinkMap = new Map([ - // 权限模板 - [['permTemplate', 'permTemplateDetail', 'permTemplateCreate'], NORMAL_DOCU_LINK], - // 首页 - [['', 'index'], NORMAL_DOCU_LINK], - // 用户组 - [ - ['userGroup', 'userGroupDetail', 'createUserGroup', 'userGroupPermDetail'], - NORMAL_DOCU_LINK - ], - // 系统接入 - [['systemAccess'], NORMAL_DOCU_LINK], - // 我的申请 - [['apply'], NORMAL_DOCU_LINK], - // 权限申请 'permApply' - [['applyCustomPerm', 'applyJoinUserGroup'], NORMAL_DOCU_LINK], - // 我的权限 - [['myPerm', 'templatePermDetail', 'groupPermDetail', 'permRenewal'], NORMAL_DOCU_LINK], - // 管理空间 - [ - ['ratingManager', 'gradingAdminDetail', 'gradingAdminCreate', 'gradingAdminEdit'], - NORMAL_DOCU_LINK - ], - // 管理员 - [['administrator'], NORMAL_DOCU_LINK], - // 审批流程 - [['approvalProcess'], NORMAL_DOCU_LINK], - // 用户 - [['user'], NORMAL_DOCU_LINK] - ]); - export default { inject: ['reloadCurPage'], components: { @@ -253,8 +219,6 @@ getTabData: getTabData, curRoleList: [], searchValue: '', - docuLinkMap: docuLinkMap, - curDocuLink: `${window.BK_DOCS_URL_PREFIX}${NORMAL_DOCU_LINK}`, showGuide: false, isShowHeader: false, placeholderValue: '', @@ -294,7 +258,8 @@ 'roleList', 'index', 'navCurRoleId', - 'externalSystemId' + 'externalSystemId', + 'versionLogs' ]), ...mapGetters('userGlobalConfig', ['globalConfig']), style () { @@ -334,12 +299,6 @@ } this.active = active; } - for (const [key, value] of this.docuLinkMap.entries()) { - if (key.includes(to.name)) { - this.curDocuLink = `${window.BK_DOCS_URL_PREFIX}${value}`; - break; - } - } }, user: { handler (value) { @@ -466,7 +425,7 @@ }, handleOpenDocu () { - window.open(this.curDocuLink); + navDocCenterPath(this.versionLogs, '/UserGuide/Introduce/README.md', true); }, handleOpenQuestion () { diff --git a/frontend/src/views/grading-admin/index.vue b/frontend/src/views/grading-admin/index.vue index bf331f50a..923df5b07 100644 --- a/frontend/src/views/grading-admin/index.vue +++ b/frontend/src/views/grading-admin/index.vue @@ -273,7 +273,7 @@ import _ from 'lodash'; import { mapGetters } from 'vuex'; import { buildURLParams } from '@/common/url'; - import { getWindowHeight, formatCodeData } from '@/common/util'; + import { getWindowHeight, formatCodeData, navDocCenterPath } from '@/common/util'; import ConfirmDialog from '@/components/iam-confirm-dialog/index'; import ApplyDialog from './components/apply-join-dialog'; import IamEditInput from '@/views/my-manage-space/components/iam-edit/input'; @@ -355,16 +355,16 @@ }; }, computed: { - ...mapGetters(['user']), - isStaff () { - return this.user.role.type === 'staff'; - }, - disabledPerm () { - return (payload) => { - const result = payload.members.map(item => item.username).includes(this.user.username); - return !result; - }; - } + ...mapGetters(['user', 'versionLogs']), + isStaff () { + return this.user.role.type === 'staff'; + }, + disabledPerm () { + return (payload) => { + const result = payload.members.map(item => item.username).includes(this.user.username); + return !result; + }; + } }, watch: { searchValue (newVal, oldVal) { @@ -864,10 +864,8 @@ }, handleOpenDocu () { - const GRADE_DOCU_LINK = '/IAM/UserGuide/Feature/ManagerCreate.md'; - window.open(`${window.BK_DOCS_URL_PREFIX}${GRADE_DOCU_LINK}`); + navDocCenterPath(this.versionLogs, `/UserGuide/Feature/ManagerCreate.md`, true); } - } }; diff --git a/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue b/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue index ba5aa3f96..c523dabdd 100644 --- a/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue +++ b/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue @@ -2,22 +2,23 @@