Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 国际化相关问题调整 #4866

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions bkmonitor/webpack/src/monitor-pc/components/biz-select/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
import { Component, Emit, Prop, Mixins } from 'vue-property-decorator';
import { Component as tsc } from 'vue-tsx-support';

import store from '../../store/store';

import { SPACE_TYPE_MAP } from '../../common/constant';
import UserConfigMixin from '../../mixins/userStoreConfig';
import store from '../../store/store';

import type { ThemeType } from './biz-select';

Expand All @@ -39,6 +38,7 @@ interface IProps {
list: IListItem[];
checked?: number;
theme?: ThemeType;
canSetDefaultSpace?: boolean;
}
interface IEvents {
onSelected: number;
Expand Down Expand Up @@ -72,6 +72,8 @@ const DEFAULT_BIZ_ID = 'DEFAULT_BIZ_ID';
export default class List extends Mixins(UserConfigMixin, tsc<IProps, IEvents>) {
/** 选中的id */
@Prop({ type: Number }) checked: number;
/** 可设置默认空间 */
@Prop({ default: true, type: Boolean }) canSetDefaultSpace: boolean;
/** 列表数据 */
@Prop({ default: () => [], type: Array }) list: IListItem[];
/** 主题 */
Expand Down Expand Up @@ -171,7 +173,7 @@ export default class List extends Mixins(UserConfigMixin, tsc<IProps, IEvents>)
>
({child.space_type_id === ETagsType.BKCC ? `#${child.id}` : child.space_id || child.space_code})
</span>
{this.defaultBizId && Number(this.defaultBizId) === child.id && (
{this.canSetDefaultSpace && this.defaultBizId && Number(this.defaultBizId) === child.id && (
<span class='item-default-icon'>
<span class='item-default-text'>{this.$tc('默认')}</span>
</span>
Expand All @@ -190,23 +192,25 @@ export default class List extends Mixins(UserConfigMixin, tsc<IProps, IEvents>)
))}
</span>
)}
<div class='set-default-button'>
{this.defaultBizId && Number(this.defaultBizId) === child.id ? (
<div
class={`btn-style-${this.theme} remove`}
onClick={e => this.handleDefaultBizIdDialog(e, child, false)}
>
{this.$tc('取消默认')}
</div>
) : (
<div
class={`btn-style-${this.theme}`}
onClick={e => this.handleDefaultBizIdDialog(e, child, true)}
>
{this.$tc('设为默认')}
</div>
)}
</div>
{this.canSetDefaultSpace && (
<div class='set-default-button'>
{this.defaultBizId && Number(this.defaultBizId) === child.id ? (
<div
class={`btn-style-${this.theme} remove`}
onClick={e => this.handleDefaultBizIdDialog(e, child, false)}
>
{this.$tc('取消默认')}
</div>
) : (
<div
class={`btn-style-${this.theme}`}
onClick={e => this.handleDefaultBizIdDialog(e, child, true)}
>
{this.$tc('设为默认')}
</div>
)}
</div>
)}
</div>
))}
</div>
Expand Down
8 changes: 4 additions & 4 deletions bkmonitor/webpack/src/monitor-pc/lang/new-home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default {
// 规范: 动词-主体-结果 如 新建应用成功 New application successful
// 规范: 仅首字母大写
容器服务: 'Container service',
日志检索: 'Log retrieval',
日志检索: 'Logs',
关联的告警: 'Related Alarms',
关联的屏蔽策略: 'Associated blocking policy',
'有问题就问 AI 小鲸': 'If you have any questions, ask Xiaojing',
Expand All @@ -38,10 +38,10 @@ export default {
暂无快捷入口: 'No quick entry',
快捷入口管理: 'Quick entry management',
最近告警事件: 'Recent warning events',
'业务:{0}': 'Business: {0}',
'业务:{0}': 'Space: {0}',
'删除后,该tab下的视图也会一起删除': 'After deletion, the views under the tab will also be deleted.',
'确定删除该视图?': 'Are you sure you want to delete this view?',
'确定删除该业务视图?': 'Are you sure you want to delete this business view?',
'确定删除该业务视图?': 'Are you sure you want to delete this space view?',
新增图表: 'New charts',
修改图表: 'Modify chart',
图表名称: 'Chart name',
Expand All @@ -51,7 +51,7 @@ export default {
'请输入图表名称,默认为策略名称': 'Please enter a chart name, the default is the strategy name',
'当前还未配置业务,快点击添加业务按钮新增图表':
'There is no service configured yet. Click the Add Service button to add a new chart.',
删除该业务: 'Delete this business',
删除该业务: 'Delete this space',
添加业务: 'Add a service',
'请输入 IP / Trace ID / 容器集群 / 告警ID / 策略名 进行搜索':
'Please enter IP / Trace ID / container cluster / alarm ID / policy name to search',
Expand Down
1 change: 1 addition & 0 deletions bkmonitor/webpack/src/monitor-pc/lang/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default {
'route-告警事件': 'Alarms',
'route-指标检索': 'Metrics',
'route-日志检索': 'Logs',
'route-服务': 'Apm service',
'route-事件检索': 'Events',
'route-Tracing 检索': 'Traces',
'route-综合拨测': 'Synthetics',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ export default class AddAlarmChartDialog extends tsc<IAddAlarmChartDialogProps,
</div>
<div class='strategy-status'>
<span class='strategy-tag'>
{this.getStrategyStatus(item.is_deleted, item.shield_info?.is_shielded, item.is_enabled)}
{this.$tc(
this.getStrategyStatus(item.is_deleted, item.shield_info?.is_shielded, item.is_enabled)
)}
</span>
{this.isSelected(item.id) && <span class='icon-monitor icon-mc-check-small' />}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
background-color: white;

.content-header {
width: 120px;
height: 28px;
font-family: MicrosoftYaHei;
font-size: 20px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,14 @@ import './home-biz-list.scss';

/** 业务组件常用的业务缓存key */
const BIZ_SELECTOR_COMMON_IDS = 'BIZ_SELECTOR_COMMON_IDS';
/** 业务组件常用业务缓存最大个数 */
const BIZ_SELECTOR_COMMON_MAX = 5;
const BIZ_COLOR_LIST = [
'#7250A9',
'#3563BE',
'#3799BA',
'#4FB17F',
'#86AF4A',
'#E9AE1D',
'#EB9258',
'#D36C68',
'#BC4FB3',
];

interface IProps {
zIndex?: number;
bizList: ISpaceItem[];
isShrink?: boolean;
theme?: ThemeType;
minWidth?: number;
stickyList?: string[];
isShowCommon?: boolean;
canAddBusiness?: boolean;
}
export type ThemeType = 'dark' | 'light';
interface IEvents {
Expand All @@ -75,12 +60,10 @@ interface IEvents {
@Component
export default class HomeBizSelect extends tsc<IProps, IEvents> {
@Prop({ default: () => [], type: Array }) bizList: ISpaceItem[];
@Prop({ default: false, type: Boolean }) isShrink: boolean;
@Prop({ default: true, type: Boolean }) isShowCommon: boolean;
@Prop({ default: null, type: Number }) zIndex: number;
@Prop({ default: 200, type: Number }) minWidth: number;
@Prop({ default: () => [], type: Array }) stickyList: string[];
@Prop({ default: true, type: Boolean }) canAddBusiness: boolean;
@Prop({
default: 'light',
type: String,
Expand All @@ -91,7 +74,6 @@ export default class HomeBizSelect extends tsc<IProps, IEvents> {
@Ref() homePopoverRef: any;
@Ref('typeList') typeListRef: HTMLDivElement;

localValue: number = null;
showBizList = false;
keyword = '';

Expand All @@ -101,7 +83,6 @@ export default class HomeBizSelect extends tsc<IProps, IEvents> {
commonListIds: number[] = [];
spaceTypeIdList: { id: string; name: string; styles: any }[] = [];
searchTypeId = '';
bizBgColor = '';

bizListFilter = [];

Expand All @@ -112,11 +93,11 @@ export default class HomeBizSelect extends tsc<IProps, IEvents> {
limit: number;
data: IListItem[];
} = {
current: 1,
count: 0,
limit: 20,
data: [],
};
current: 1,
count: 0,
limit: 20,
data: [],
};

typeWrapInfo = {
showBtn: false,
Expand All @@ -127,7 +108,6 @@ export default class HomeBizSelect extends tsc<IProps, IEvents> {
firstCodeBgColor = '';

created() {
this.bizBgColor = this.$store.getters.bizBgColor || this.getRandomColor();
const spaceTypeMap: Record<string, any> = {};
for (const item of this.bizList) {
spaceTypeMap[item.space_type_id] = 1;
Expand Down Expand Up @@ -156,7 +136,6 @@ export default class HomeBizSelect extends tsc<IProps, IEvents> {
@Emit('change')
handleBizChange(id: number) {
this.homePopoverRef.instance.hide();
this.handleCacheBizId(id);
return id;
}

Expand Down Expand Up @@ -296,29 +275,6 @@ export default class HomeBizSelect extends tsc<IProps, IEvents> {
}
}

getRandomColor() {
const color = BIZ_COLOR_LIST[Math.floor(Math.random() * BIZ_COLOR_LIST.length)];
this.$store.commit('app/SET_BIZ_BGCOLOR', color);
return color;
}

handleCacheBizId(id: number) {
const leng = this.commonListIds.length;
const isExist = this.commonListIds.includes(id);
let newIds = [...this.commonListIds];
if (isExist) {
newIds = newIds.filter(item => item !== id);
newIds.unshift(id);
} else {
newIds.unshift(id);
if (leng >= BIZ_SELECTOR_COMMON_MAX) {
newIds.length = BIZ_SELECTOR_COMMON_MAX;
}
}
this.commonListIds = newIds;
this.storage.set(BIZ_SELECTOR_COMMON_IDS, this.commonListIds);
}

handleSetListWidth() {
this.bizListFilter = this.getBizListFilter();
const react = this.$el.getBoundingClientRect();
Expand All @@ -335,10 +291,6 @@ export default class HomeBizSelect extends tsc<IProps, IEvents> {
this.typeListWrapNextPreShowChange();
}

handleOpenSpaceManager() {
this.handleSearchBlur();
}

handleSearchBlur() {
setTimeout(() => {
const popover = this.homePopoverRef;
Expand Down Expand Up @@ -501,7 +453,7 @@ export default class HomeBizSelect extends tsc<IProps, IEvents> {
onScroll={this.handleScroll}
>
<List
// checked={this.localValue}
canSetDefaultSpace={false}
list={this.bizListFilter}
theme={this.theme}
onSelected={this.handleBizChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
color: #4D4F56;
cursor: pointer;
transition: color 0.3s;
display: flex;
align-items: center;

.icon-monitor {
margin-right: 5px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export default class RecentAlarmEvents extends tsc<object> {
let detail = this.$t('业务:{0}', {
0: this.businessTab.filter(item => item.bk_biz_id === this.currentDelId)[0]?.bk_biz_name,
});
let width = 680;
let tips = this.$t('删除后,该tab下的视图也会一起删除');
let info = this.$t('确定删除该业务视图?');
let handleDelFunction = this.delTaskByIndex;
Expand All @@ -350,11 +351,12 @@ export default class RecentAlarmEvents extends tsc<object> {
info = this.$t('确定删除该视图?');
this.alarmGraphBizId = this.activeTabId;
this.isAppendMode = true;
width = 580;
handleDelFunction = this.handleSaveAlarmGraphConfig;
}
return (
<bk-dialog
width={480}
width={width}
ext-cls='task-del-dialog'
v-model={this.showDelDialog}
header-position='left'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import 'monitor-pc/theme/mixin.scss';

.recent-content {
display: flex;
flex-wrap: wrap;
Expand Down Expand Up @@ -96,14 +98,14 @@
}

.detail {
overflow: hidden;
font-size: 12px;
line-height: 20px;
color: #313238;
text-overflow: ellipsis;
letter-spacing: 0;
white-space: nowrap;

overflow: hidden;
letter-spacing: 0;
width: 80%;
.favorite {
margin-right: 3px;
font-size: 14px;
Expand Down Expand Up @@ -138,6 +140,7 @@
color: #979BA5;
text-align: right;
letter-spacing: 0;
@include ellipsis;
}

&:last-child {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export default class RecentFavoritesList extends tsc<IRecentFavoritesListProps>
) : (
<i class={['bk-icon bk-icon', functionName]} />
)}
<span class='recent-subtitle'>{EFunctionNameType[functionName]}</span>
<span class='recent-subtitle'>{this.$tc(`route-${EFunctionNameType[functionName]}`)}</span>
{/* <span class='more'>更多</span> */}
</div>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@

/* 通过传递参数来动态控制每个 div 的宽度 */
.single-col .category {
min-width: 100%;
width: 100%;
}

.double-col .category {
min-width: 50%;
width: 50%;
}

.triple-col .category {
min-width: 32%;
width: 32%;
}

.has-line {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ import './recent-favorites-tab.scss';

// 模块名称映射
const modeNameMap = {
[window.i18n.tc('仪表盘')]: 'dashboard',
[window.i18n.tc('服务')]: 'apm_service',
[window.i18n.tc('日志检索')]: 'log_retrieve',
[window.i18n.tc('服务拨测')]: '-',
[window.i18n.tc('主机监控')]: '-',
[window.i18n.tc('容器服务')]: '-',
仪表盘: 'dashboard',
服务: 'apm_service',
日志检索: 'log_retrieve',
服务拨测: '-',
主机监控: '-',
容器服务: '-',
};

interface Category {
Expand Down Expand Up @@ -195,7 +195,7 @@ export default class RecentFavoritesTab extends Mixins(UserConfigMixin) {
}
value={modeNameMap[item.name]}
>
<span>{item.name}</span>
<span>{this.$tc(item.name)}</span>
</bk-checkbox>
<i class='icon-monitor icon-mc-tuozhuai' />
</li>
Expand Down