Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { timeParse } from '@/utils';
import { cloneDeep } from 'lodash';
import nodeApi from '~/vgpu/api/node';
import { ElMessage } from 'element-plus';
import i18n from '@/locales';

export const getResourceStatus = (statusConfig) => {
return {
Expand Down Expand Up @@ -280,7 +281,7 @@ export const handleChartClick = async (params, router) => {
const uuid = node.uid;
router.push(`/admin/vgpu/node/admin/${uuid}?nodeName=${name}`);
} else {
ElMessage.error('节点未找到');
ElMessage.error(i18n.global.t('node.nodeNotFound'));
}
};

Expand Down
10 changes: 5 additions & 5 deletions packages/web/projects/vgpu/views/monitor/overview/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const _cardGaugeConfig = useInstantVector([
percentQuery: `avg(sum (hami_container_vgpu_allocated) by (instance))/avg(sum (hami_vgpu_count) by (instance)) *100`,
total: 0,
used: 0,
unit: '个',
unit: t('common.unitCount'),
},
{
title: 'computeAllocRate',
Expand Down Expand Up @@ -224,19 +224,19 @@ const resourceOverview = computed(() => [
title: t('dashboard.node'),
count: resourceCounts.node,
icon: 'vgpu-node',
unit: '个',
unit: t('common.unitCount'),
},
{
title: t('dashboard.card'),
count: resourceCounts.card,
icon: 'vgpu-gpu-d',
unit: '张',
unit: t('common.unitSheet'),
},
{
title: t('dashboard.vgpu'),
count: resourceCounts.vgpu,
icon: 'vgpu-card',
unit: '个',
unit: t('common.unitCount'),
},
{
title: t('dashboard.compute'),
Expand Down Expand Up @@ -286,7 +286,7 @@ const cardDetail = useInstantVector([
title: 'vGPU',
count: 0,
query: 'avg(hami_vgpu_count)',
unit: '个',
unit: t('common.unitCount'),
icon: 'gpu2',
},
{
Expand Down
5 changes: 4 additions & 1 deletion packages/web/src/components/CodePre.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

<script setup>
import { ElMessage } from 'element-plus';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();

const props = defineProps({
value: String,
Expand All @@ -22,7 +25,7 @@ const handleCopy = () => {
document.execCommand('copy');
document.body.removeChild(textarea);

ElMessage.success('复制成功');
ElMessage.success(t('common.copySuccess'));
};
</script>

Expand Down
5 changes: 3 additions & 2 deletions packages/web/src/components/Confirm/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ConfirmComponent from './index.vue'
import { createVNode, render } from 'vue'
import i18n from '@/locales'

const Confirm = {
install(app) {
Expand All @@ -8,8 +9,8 @@ const Confirm = {
app.config.globalProperties.$Confirm = (confirmText, confirmObj, fn) => {
if(JSON.stringify(confirmObj) === '{}') {
confirmObj = {
confirmButtonText: '确定',
cancelButtonText: '取消',
confirmButtonText: i18n.global.t('common.confirm'),
cancelButtonText: i18n.global.t('common.cancel'),
type: '',
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/web/src/components/Confirm/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

<script>
import { Modal } from 'bootstrap';
import i18n from '@/locales';

export default {
// props: {
Expand Down Expand Up @@ -92,8 +93,8 @@ export default {
removeModal: null,
fn: null,
confirmObj: {
confirmButtonText: '确定',
cancelButtonText: '取消',
confirmButtonText: i18n.global.t('common.confirm'),
cancelButtonText: i18n.global.t('common.cancel'),
type: '',
},
confirmText: '',
Expand Down
7 changes: 5 additions & 2 deletions packages/web/src/components/FilterInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
>
<el-input
v-model="searchVal"
placeholder="请输入搜索关键词"
:placeholder="t('common.searchKeyword')"
@keyup.enter="handleSearch"
clearable
@focus="openSearchDropdown"
Expand All @@ -49,6 +49,9 @@
import { ref, computed } from 'vue';
import { ElMessage } from 'element-plus';
import { omit } from 'lodash';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();

const props = defineProps({
modelValue: Object, //数据源,双向绑定
Expand Down Expand Up @@ -111,7 +114,7 @@ const handleSearch = () => {
source.filters?.find((item) => item.text === textQ)?.value || textQ;
emit('update:modelValue', { ...props.modelValue, [type]: value });
} else {
ElMessage.error('输入不合法');
ElMessage.error(t('common.inputInvalid'));
}

searchVal.value = '';
Expand Down
6 changes: 4 additions & 2 deletions packages/web/src/components/FormPlus/FormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<el-input
v-model="value"
autocomplete="off"
placeholder="请输入"
:placeholder="t('common.pleaseInput')"
v-if="component === 'input'"
v-bind="componentProps"
class="form-item-input"
Expand Down Expand Up @@ -173,6 +173,7 @@ import {
inject,
watchEffect,
} from 'vue';
import { useI18n } from 'vue-i18n';
import FormList from './FormList.vue';
import TableSelect from './TableSelect';
import Cascader from './elements/Cascader.vue';
Expand Down Expand Up @@ -278,6 +279,7 @@ const value = computed({
});

const schema = inject('$schema', {});
const { t } = useI18n();

const computeRules = computed(() => {
const { rules, required } = props;
Expand All @@ -287,7 +289,7 @@ const computeRules = computed(() => {
if (required) {
ruleData.push({
required: true,
message: '该字段是必填字段',
message: t('common.fieldRequired'),
trigger: 'blur',
});
}
Expand Down
9 changes: 6 additions & 3 deletions packages/web/src/components/FormPlus/FormList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
{{ item.label }}
<el-tooltip
effect="dark"
content="以 art. 为前缀的属性不支持修改和删除"
:content="t('common.artPrefixTip')"
placement="top"
v-if="item.tip"
>
Expand All @@ -97,7 +97,7 @@
<template #append>
<div class="table-append">
<el-button v-if="allowAdd && !isMax" @click="add" :icon="Plus"
>增加</el-button
>{{ addTitle || t('common.add') }}</el-button
>
</div>
</template>
Expand Down Expand Up @@ -127,6 +127,9 @@ import {
import { Plus, Minus } from '@element-plus/icons-vue';
import { deepParse } from '@/utils/form';
import FormItem from './FormItem.vue';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();

const props = defineProps({
modelValue: Array,
Expand Down Expand Up @@ -169,7 +172,7 @@ const props = defineProps({
},
addTitle: {
type: String,
default: '增加',
default: '',
},
or: Boolean,
});
Expand Down
4 changes: 3 additions & 1 deletion packages/web/src/components/FormPlus/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import {
import { ElMessage } from 'element-plus';
import { timeParse, parseMemory } from '@/utils';
import { useStore } from 'vuex';
import { useI18n } from 'vue-i18n';
import { parseFormItems, handleLinkages } from './utils';
import FormRender from './FormRender.vue';

const formRef = ref(null);

const store = useStore();
const { t } = useI18n();

const props = defineProps({
// 表单数据源,双向绑定
Expand Down Expand Up @@ -88,7 +90,7 @@ const submit = async () => {
//转化成普通对象,便于阅读
return { ...form.value };
} catch (e) {
ElMessage.error('表单填写校验不通过!');
ElMessage.error(t('common.formValidationFailed'));
return Promise.reject(e);
}
};
Expand Down
7 changes: 5 additions & 2 deletions packages/web/src/components/FormPlusDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
<slot />
<template #footer>
<div class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="handleOk">确定</el-button>
<el-button @click="visible = false">{{ t('common.cancel') }}</el-button>
<el-button type="primary" @click="handleOk">{{ t('common.confirm') }}</el-button>
</div>
</template>
</el-drawer>
</template>

<script setup>
import { ref, computed } from 'vue';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();

const formPlusRef = ref(null);

Expand Down
4 changes: 3 additions & 1 deletion packages/web/src/components/Message/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import MessageComponent from './index.vue'
import { createVNode, render } from 'vue'
import i18n from '@/locales'

const Message = {
install(app) {
const Vnode = createVNode(MessageComponent)
render(Vnode, document.body)
app.config.globalProperties.$Message = (type, msg, duration) => {
if(!msg){
msg = type==='success'?'操作成功':type==='info'?'消息提示':type==='warning'?'操作警告':type==='danger'?'操作失败':''
msg = type==='success'?i18n.global.t('common.operationSuccess'):type==='info'?i18n.global.t('common.messageTip'):type==='warning'?i18n.global.t('common.operationWarning'):type==='danger'?i18n.global.t('common.operationFailed'):''
}
duration = duration || 2000
Vnode.component.ctx.showMessage(type, msg, duration)
Expand Down
7 changes: 5 additions & 2 deletions packages/web/src/components/RadioPlus.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<el-radio-group
v-model="selectVal"
:placeholder="placeholder"
:placeholder="placeholder || t('common.pleaseSelect')"
:disabled="disabled"
@change="selectChange"
:class="{ 'radio-plus': true, renderLabelIcon }"
Expand Down Expand Up @@ -65,6 +65,9 @@ import {
} from 'vue';
import { isString, isEqual, debounce } from 'lodash';
import request from '@/utils/request';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();

const props = defineProps({
modelValue: {},
Expand All @@ -74,7 +77,7 @@ const props = defineProps({
},
placeholder: {
type: String,
default: '请选择',
default: '',
},
disabled: {
type: Boolean,
Expand Down
7 changes: 5 additions & 2 deletions packages/web/src/components/TablePlus/SearchTag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import { computed, isVNode } from 'vue';
import { isArray } from 'lodash';
import { ElPopover, ElTag } from 'element-plus';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();

const props = defineProps({
label: String,
Expand All @@ -24,7 +27,7 @@ const parseValue = computed(() => {
return (
<ElPopover trigger="hover">
{{
reference: () => <span>{props.value.length}</span>,
reference: () => <span>{props.value.length}{t('common.unitCount')}</span>,
default: () => (
<div
style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}
Expand All @@ -40,6 +43,6 @@ const parseValue = computed(() => {
}
const index = ['true', 'false'].indexOf(props.value);
if (index == -1) return props.value;
return index == 0 ? '是' : '否';
return index == 0 ? t('common.yes') : t('common.no');
});
</script>
4 changes: 3 additions & 1 deletion packages/web/src/components/TextPlus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
<script setup>
import { ElMessage } from 'element-plus';
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';

const router = useRouter();
const { t } = useI18n();

const props = defineProps({
text: String,
Expand All @@ -27,7 +29,7 @@ const handleCopy = () => {
document.execCommand('copy');
document.body.removeChild(textarea);

ElMessage.success('复制成功');
ElMessage.success(t('common.copySuccess'));
};

const handleClick = () => {
Expand Down
17 changes: 17 additions & 0 deletions packages/web/src/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ export default {
advanced: 'Advanced',
operation: 'Operation',
details: 'Details',
formValidationFailed: 'Form validation failed!',
requestError: 'Request error',
tip: 'Tip',
copySuccess: 'Copy successful',
inputInvalid: 'Invalid input',
operationSuccess: 'Operation successful',
messageTip: 'Message',
operationWarning: 'Operation warning',
operationFailed: 'Operation failed',
fieldRequired: 'This field is required',
yes: 'Yes',
no: 'No',
unitCount: '',
unitSheet: '',
artPrefixTip: 'Properties prefixed with art. cannot be modified or deleted',
searchKeyword: 'Search keyword',
},
routes: {
gpuAdmin: 'GPU',
Expand Down Expand Up @@ -214,6 +230,7 @@ export default {
backHome: 'Back to home',
backPrevious: 'Back to previous page',
back: 'Back',
dialogTitle: 'Just Look',
}
},
timeRange: {
Expand Down
Loading
Loading