在线用户国际化

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-form :model="state.ruleForm" ref="ruleFormRef" label-width="auto">
<el-row :gutter="35"> <el-row :gutter="35">
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> <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-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="收件人" disabled /> <el-input v-model="state.ruleForm.receiveUserName" :placeholder="$t('message.list.recipient')" disabled />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> <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-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="标题" clearable />
<el-input v-model="state.ruleForm.title" :placeholder="$t('message.list.title')" clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20"> <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" /> <Editor v-model:get-html="state.ruleForm.message" />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -28,10 +33,11 @@
</el-form> </el-form>
<template #footer> <template #footer>
<span class="dialog-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> </span>
</template> </template>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>

View File

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