Skip to content

Commit

Permalink
feat:添加跳转CMDB
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuikill committed Oct 27, 2023
1 parent acba7d6 commit 6d680c4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions bcs-services/bcs-bscp/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
var BK_BCS_BSCP_API = '{{ .BK_BCS_BSCP_API }}'
var SITE_URL = '{{ .SITE_URL }}'
var BK_IAM_HOST = '{{ .BK_IAM_HOST }}'
var BK_CC_HOST = '{{ .BK_CC_HOST }}'
window.BSCP_CONFIG = JSON.parse('{{ .BK_BSCP_CONFIG }}')
</script>
</head>
Expand Down
32 changes: 28 additions & 4 deletions bcs-services/bcs-bscp/ui/src/components/head.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
<AngleDown class="arrow-icon" />
</div>
</template>
<template #extension>
<div class="create-operation" @click="handleToCMDB">
<plus />
<div class="content">新建业务</div>
</div>
</template>
<bk-option v-for="item in optionList" :key="item.space_id" :value="item.space_id" :label="item.space_name">
<div
v-cursor="{ active: !item.permission }"
Expand Down Expand Up @@ -88,7 +94,7 @@
import { ref, computed, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { storeToRefs } from 'pinia';
import { AngleDown, HelpFill, DownShape } from 'bkui-vue/lib/icon';
import { AngleDown, HelpFill, DownShape, Plus } from 'bkui-vue/lib/icon';
import useGlobalStore from '../store/global';
import useUserStore from '../store/user';
import useTemplateStore from '../store/template';
Expand Down Expand Up @@ -121,7 +127,7 @@ const navList = [
const optionList = ref<ISpaceDetail[]>([]);
const crtSpaceText = computed(() => {
const space = spaceList.value.find((item) => item.space_id === spaceId.value);
const space = spaceList.value.find(item => item.space_id === spaceId.value);
if (space) {
return `${space.space_name}(${spaceId.value})`;
}
Expand All @@ -135,7 +141,7 @@ watch(
},
{
immediate: true,
}
},
);
const handleSpaceSearch = (searchStr: string) => {
Expand Down Expand Up @@ -174,7 +180,7 @@ const handleSelectSpace = (id: string) => {
state.currentTemplateSpace = 0;
state.currentPkg = '';
});
const nav = navList.find((item) => item.module === route.meta.navModule);
const nav = navList.find(item => item.module === route.meta.navModule);
if (nav) {
router.push({ name: nav.id, params: { spaceId: id } });
} else {
Expand Down Expand Up @@ -242,6 +248,10 @@ Object.keys(module).forEach((path) => {
const handleLoginOut = () => {
loginOut();
};
const handleToCMDB = () => {
// @ts-ignore
window.open(BK_CC_HOST); // eslint-disable-line no-undef
};
</script>

<style lang="scss" scoped>
Expand Down Expand Up @@ -386,6 +396,20 @@ const handleLoginOut = () => {
color: #3a84ff;
}
}
.create-operation {
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
height: 33px;
padding: 0 12px;
width: 100%;
color: #2B353E;
span {
font-size: 16px;
margin-right: 3px;
}
}
</style>
<style lang="scss">
.space-selector-popover .bk-select-option {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ const rules = {
{
validator: (value: string) => {
if (value.length > 0) {
return /^[\u4e00-\u9fa5a-zA-Z0-9][\u4e00-\u9fa5a-zA-Z0-9_-]*[\u4e00-\u9fa5a-zA-Z0-9]?$/.test(value);
return /^(?!^[0-9])\w+$/.test(value);
}
return true;
},
message: '仅允许使用中文、英文、数字、下划线、中划线,且必须以中文、英文、数字开头和结尾',
message: '仅允许使用中文、英文、数字、下划线,且不能以数字开头',
trigger: 'blur',
},
],
memo: [
Expand Down

0 comments on commit 6d680c4

Please sign in to comment.