在线用户国际化

This commit is contained in:
PZ688 2025-02-28 18:00:18 +08:00
parent 1a39c1d3f0
commit 6ca4ef7405
2 changed files with 50 additions and 35 deletions

View File

@ -10,17 +10,22 @@
<el-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto">
<el-row :gutter="35">
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="收件人" prop="receiveUserName" :rules="[{ required: true, message: '收件人不能为空', trigger: 'blur' }]">
<el-input v-model="state.ruleForm.receiveUserName" placeholder="收件人" disabled />
<el-form-item :label="$t('message.list.recipient')" prop="receiveUserName" :rules="[{ required: true, message: $t('message.list.recipientRequired'), trigger: 'blur' }]">
<el-input v-model="state.ruleForm.receiveUserName" :placeholder="$t('message.list.recipient')" disabled />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="标题" prop="title" :rules="[{ required: true, message: '标题不能为空', trigger: 'blur' }]">
<el-input v-model="state.ruleForm.title" placeholder="标题" clearable />
<el-form-item :label="$t('message.list.title')" prop="title" :rules="[{ required: true, message: $t('message.list.titleRequired'), trigger: 'blur' }]">
<el-input v-model="state.ruleForm.title" :placeholder="$t('message.list.title')" clearable />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
<el-form-item label="内容" prop="message" :rules="[{ required: true, message: '内容不能为空', trigger: 'blur' }]">
<el-form-item :label="$t('message.list.content')" prop="message" :rules="[{ required: true, message: $t('message.list.contentRequired'), trigger: 'blur' }]">
<Editor v-model:get-html="state.ruleForm.message" />
</el-form-item>
</el-col>
@ -28,10 +33,11 @@
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button type="primary" icon="ele-Position" @click="submit"> </el-button>
<el-button type="primary" icon="ele-Position" @click="submit"> {{$t('message.list.send')}} </el-button>
</span>
</template>
</el-dialog>
</div>
</template>

View File

@ -4,21 +4,24 @@
<template #header>
<div style="color: #fff">
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-UserFilled /> </el-icon>
<span> 在线用户列表</span>
<span> {{$t('message.list.onlineUserList')}} </span>
</div>
</template>
<el-card shadow="hover" :body-style="{ padding: '5px 5px 0 5px', display: 'flex', width: '100%', height: '100%', alignItems: 'start' }">
<el-form :model="state.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true" label-width="auto" style="flex: 1 1 0%">
<el-row :gutter="10">
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="8" :xl="6">
<el-form-item label="账号" prop="userName">
<el-input v-model="state.queryParams.userName" placeholder="账号" clearable @keyup.enter.native="handleQuery(true)" />
<el-col class="mb5" :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item :label="$t('message.list.account')" prop="userName">
<el-input v-model="state.queryParams.userName" :placeholder="$t('message.list.account')" clearable @keyup.enter.native="handleQuery(true)" />
</el-form-item>
</el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="8" :xl="6">
<el-form-item label="姓名" prop="realName">
<el-input v-model="state.queryParams.realName" placeholder="姓名" clearable @keyup.enter.native="handleQuery(true)" />
<el-col class="mb5" :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item :label="$t('message.list.realName')" prop="realName">
<el-input v-model="state.queryParams.realName" :placeholder="$t('message.list.realName')" clearable @keyup.enter.native="handleQuery(true)" />
</el-form-item>
</el-col>
</el-row>
</el-form>
@ -28,8 +31,8 @@
<el-row>
<el-col>
<el-button-group>
<el-button type="primary" icon="ele-Search" @click="handleQuery(true)" :loading="options.loading"> 查询 </el-button>
<el-button icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> 重置 </el-button>
<el-button type="primary" icon="ele-Search" @click="handleQuery(true)" :loading="options.loading"> {{$t('message.list.query')}} </el-button>
<el-button icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> {{$t('message.list.reset')}} </el-button>
</el-button-group>
</el-col>
</el-row>
@ -43,10 +46,11 @@
<el-empty :image-size="200" />
</template>
<template #row_buttons="{ row }">
<el-tooltip content="发送消息" placement="top">
<el-tooltip :content="$t('message.list.sendMessage')" placement="top">
<el-button icon="ele-Position" text type="primary" @click="openSendMessage(row)"> </el-button>
</el-tooltip>
<el-tooltip content="强制下线" placement="top">
<el-tooltip :content="$t('message.list.forceOffline')" placement="top">
<el-button icon="ele-CircleCloseFilled" text type="danger" v-auth="'sysOnlineUser/forceOffline'" @click="forceOffline(row)"> </el-button>
</el-tooltip>
</template>
@ -54,10 +58,11 @@
</el-card>
</el-drawer>
<SendMessage ref="sendMessageRef" title="发送消息" />
<SendMessage ref="sendMessageRef" :title="$t('message.list.sendMessage')" />
</div>
</template>
<script lang="ts" setup>
import { onMounted, reactive, ref } from 'vue';
import { ElMessageBox, ElNotification } from 'element-plus';
@ -72,6 +77,9 @@ import SendMessage from '/@/views/system/onlineUser/component/sendMessage.vue';
import { getAPI, clearAccessTokens } from '/@/utils/axios-utils';
import { SysOnlineUserApi, SysAuthApi } from '/@/api-services/api';
import { SysOnlineUser, PageOnlineUserInput } from '/@/api-services/models';
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
const xGrid = ref<VxeGridInstance>();
const sendMessageRef = ref<InstanceType<typeof SendMessage>>();
@ -98,17 +106,18 @@ const localPageParamKey = 'localPageParam:sysOnlineUser';
const options = useVxeTable<SysOnlineUser>(
{
id: 'sysOnlineUser',
name: '在线用户',
name: t('message.list.onlineUserList'),
columns: [
// { type: 'checkbox', width: 40, fixed: 'left' },
{ type: 'seq', title: '序号', width: 50, fixed: 'left' },
{ field: 'userName', title: '账号', minWidth: 110, showOverflow: 'tooltip' },
{ field: 'realName', title: '姓名', minWidth: 110, showOverflow: 'tooltip' },
{ field: 'ip', title: 'IP地址', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'browser', title: '浏览器', minWidth: 160, showOverflow: 'tooltip' },
{ type: 'seq', title: t('message.list.seq'), width: 50, fixed: 'left' },
{ field: 'userName', title: t('message.list.account'), minWidth: 110, showOverflow: 'tooltip' },
{ field: 'realName', title: t('message.list.realName'), minWidth: 110, showOverflow: 'tooltip' },
{ field: 'ip', title: t('message.list.ipAddress'), minWidth: 100, showOverflow: 'tooltip' },
{ field: 'browser', title: t('message.list.browser'), minWidth: 160, showOverflow: 'tooltip' },
// { field: 'connectionId', title: 'Id', minWidth: 160, showOverflow: 'tooltip', sortable: true },
{ field: 'time', title: '登录时间', minWidth: 120, showOverflow: 'tooltip' },
{ title: '操作', fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } },
{ field: 'time', title: t('message.list.loginTime'), minWidth: 120, showOverflow: 'tooltip' },
{ title: t('message.list.operation'), fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } },
],
},
// vxeGrid()vxe-table
@ -151,12 +160,12 @@ onMounted(async () => {
//
const notificationThrottle = throttle(
function () {
ElNotification({
title: '提示',
message: `${state.lastUserState.online ? `${state.lastUserState.realName}】上线了` : `${state.lastUserState.realName}】离开了`}`,
type: `${state.lastUserState.online ? 'info' : 'error'}`,
position: 'bottom-right',
});
// ElNotification({
// title: '',
// message: `${state.lastUserState.online ? `${state.lastUserState.realName}线` : `${state.lastUserState.realName}`}`,
// type: `${state.lastUserState.online ? 'info' : 'error'}`,
// position: 'bottom-right',
// });
},
3000,
{
@ -212,9 +221,9 @@ const openSendMessage = (row: any) => {
// 线
const forceOffline = async (row: any) => {
ElMessageBox.confirm(`确定踢掉账号:【${row.realName}】?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
ElMessageBox.confirm(t('message.list.confirmKickAccount', { account: row.realName }), t('message.list.hint'), {
confirmButtonText: t('message.list.confirm'),
cancelButtonText: t('message.list.cancelButtonText'),
type: 'warning',
})
.then(async () => {