update 重构 彻底删除proxy用法 改为vue3官方推荐写法

This commit is contained in:
疯狂的狮子Li
2026-04-10 13:07:37 +08:00
parent eb62402423
commit 9acf52e8a7
144 changed files with 1264 additions and 1082 deletions

View File

@@ -143,19 +143,19 @@
</template>
<script setup name="Cache" lang="ts">
import { getCache } from '@/api/monitor/cache';
import * as echarts from 'echarts';
import { getCache } from '@/api/monitor/cache';
import { CacheVO } from '@/api/monitor/cache/types';
import modal from '@/plugins/modal';
const cache = ref<Partial<CacheVO>>({});
const commandstats = ref();
const usedmemory = ref();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const getList = async () => {
proxy?.$modal.loading('正在加载缓存监控数据,请稍候!');
modal.loading('正在加载缓存监控数据,请稍候!');
const res = await getCache();
proxy?.$modal.closeLoading();
modal.closeLoading();
cache.value = res.data;
const commandstatsIntance = echarts.init(commandstats.value, 'macarons');
commandstatsIntance.setOption({

View File

@@ -137,7 +137,7 @@
width="180"
>
<template #default="scope">
<span>{{ proxy.parseTime(scope.row.loginTime) }}</span>
<span>{{ parseTime(scope.row.loginTime) }}</span>
</template>
</el-table-column>
</el-table>
@@ -156,10 +156,13 @@
<script setup name="LoginInfo" lang="ts">
import { list, delLoginInfo, cleanLoginInfo, unlockLoginInfo } from '@/api/monitor/logininfo';
import { LoginInfoQuery, LoginInfoVO } from '@/api/monitor/logininfo/types';
import modal from '@/plugins/modal';
import { useDict } from '@/utils/dict';
import { download as requestDownload } from '@/utils/request';
import { parseTime, addDateRange } from '@/utils/ruoyi';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_device_type } = toRefs<any>(proxy?.useDict('sys_device_type'));
const { sys_common_status } = toRefs<any>(proxy?.useDict('sys_common_status'));
const { sys_device_type } = toRefs<any>(useDict('sys_device_type'));
const { sys_common_status } = toRefs<any>(useDict('sys_common_status'));
const loginInfoList = ref<LoginInfoVO[]>([]);
const loading = ref(true);
@@ -169,7 +172,7 @@ const single = ref(true);
const multiple = ref(true);
const selectName = ref<Array<string>>([]);
const total = ref(0);
const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
const dateRange = ref<any>(['', '']);
const defaultSort = ref<any>({ prop: 'loginTime', order: 'descending' });
const queryFormRef = ref<ElFormInstance>();
@@ -188,7 +191,7 @@ const queryParams = ref<LoginInfoQuery>({
/** 查询登录日志列表 */
const getList = async () => {
loading.value = true;
const res = await list(proxy?.addDateRange(queryParams.value, dateRange.value));
const res = await list(addDateRange(queryParams.value, dateRange.value));
loginInfoList.value = res.data?.rows;
total.value = res.data?.total;
loading.value = false;
@@ -221,28 +224,28 @@ const handleSortChange = (column: any) => {
/** 删除按钮操作 */
const handleDelete = async (row?: LoginInfoVO) => {
const infoIds = row?.infoId || ids.value;
await proxy?.$modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?');
await modal.confirm('是否确认删除访问编号为"' + infoIds + '"的数据项?');
await delLoginInfo(infoIds);
await getList();
proxy?.$modal.msgSuccess('删除成功');
modal.msgSuccess('删除成功');
};
/** 清空按钮操作 */
const handleClean = async () => {
await proxy?.$modal.confirm('是否确认清空所有登录日志数据项?');
await modal.confirm('是否确认清空所有登录日志数据项?');
await cleanLoginInfo();
await getList();
proxy?.$modal.msgSuccess('清空成功');
modal.msgSuccess('清空成功');
};
/** 解锁按钮操作 */
const handleUnlock = async () => {
const username = selectName.value;
await proxy?.$modal.confirm('是否确认解锁用户"' + username + '"数据项?');
await modal.confirm('是否确认解锁用户"' + username + '"数据项?');
await unlockLoginInfo(username);
proxy?.$modal.msgSuccess('用户' + username + '解锁成功');
modal.msgSuccess('用户' + username + '解锁成功');
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
requestDownload(
'monitor/loginInfo/export',
{
...queryParams.value

View File

@@ -68,7 +68,7 @@
<el-table-column label="浏览器" align="center" prop="browser" :show-overflow-tooltip="true" />
<el-table-column label="登录时间" align="center" prop="loginTime" width="180">
<template #default="scope">
<span>{{ proxy.parseTime(scope.row.loginTime) }}</span>
<span>{{ parseTime(scope.row.loginTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@@ -97,13 +97,14 @@
</template>
<script setup name="Online" lang="ts">
import { to } from 'await-to-js';
import { forceLogout, list as initData } from '@/api/monitor/online';
import { OnlineQuery, OnlineVO } from '@/api/monitor/online/types';
import api from '@/api/system/user';
import { to } from 'await-to-js';
import modal from '@/plugins/modal';
import { useDict } from '@/utils/dict';
import { parseTime } from '@/utils/ruoyi';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_device_type } = toRefs<any>(proxy?.useDict('sys_device_type'));
const { sys_device_type } = toRefs<any>(useDict('sys_device_type'));
const onlineList = ref<OnlineVO[]>([]);
const loading = ref(true);
@@ -138,11 +139,11 @@ const resetQuery = () => {
};
/** 强退按钮操作 */
const handleForceLogout = async (row: OnlineVO) => {
const [err] = await to(proxy?.$modal.confirm('是否确认强退名称为"' + row.userName + '"的用户?') as any);
const [err] = await to(modal.confirm('是否确认强退名称为"' + row.userName + '"的用户?') as any);
if (!err) {
await forceLogout(row.tokenId);
await getList();
proxy?.$modal.msgSuccess('删除成功');
modal.msgSuccess('删除成功');
}
};

View File

@@ -161,7 +161,7 @@
:sort-orders="['descending', 'ascending']"
>
<template #default="scope">
<span>{{ proxy.parseTime(scope.row.operTime) }}</span>
<span>{{ parseTime(scope.row.operTime) }}</span>
</template>
</el-table-column>
<el-table-column
@@ -208,11 +208,14 @@
<script setup name="Operlog" lang="ts">
import { list, delOperlog, cleanOperlog } from '@/api/monitor/operlog';
import { OperLogForm, OperLogQuery, OperLogVO } from '@/api/monitor/operlog/types';
import OperInfoDialog from './oper-info-dialog.vue';
import modal from '@/plugins/modal';
import { useDict } from '@/utils/dict';
import { download as requestDownload } from '@/utils/request';
import { parseTime, addDateRange, selectDictLabel } from '@/utils/ruoyi';
import OperInfoDialog from './operInfoDialog.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_oper_type, sys_common_status, sys_device_type } = toRefs<any>(
proxy?.useDict('sys_oper_type', 'sys_common_status', 'sys_device_type')
useDict('sys_oper_type', 'sys_common_status', 'sys_device_type')
);
const operlogList = ref<OperLogVO[]>([]);
@@ -221,7 +224,7 @@ const showSearch = ref(true);
const ids = ref<Array<number | string>>([]);
const multiple = ref(true);
const total = ref(0);
const dateRange = ref<[DateModelType, DateModelType]>(['', '']);
const dateRange = ref<any>(['', '']);
const defaultSort = ref<any>({ prop: 'operTime', order: 'descending' });
const operLogTableRef = ref<ElTableInstance>();
@@ -280,14 +283,14 @@ const { queryParams, form } = toRefs(data);
/** 查询登录日志 */
const getList = async () => {
loading.value = true;
const res = await list(proxy?.addDateRange(queryParams.value, dateRange.value));
const res = await list(addDateRange(queryParams.value, dateRange.value));
operlogList.value = res.data?.rows;
total.value = res.data?.total;
loading.value = false;
};
/** 操作日志类型字典翻译 */
const typeFormat = (row: OperLogForm) => {
return proxy?.selectDictLabel(sys_oper_type.value, row.businessType);
return selectDictLabel(sys_oper_type.value, row.businessType);
};
/** 搜索按钮操作 */
const handleQuery = () => {
@@ -322,23 +325,23 @@ const handleView = (row: OperLogVO) => {
/** 删除按钮操作 */
const handleDelete = async (row?: OperLogVO) => {
const operIds = row?.operId || ids.value;
await proxy?.$modal.confirm('是否确认删除日志编号为"' + operIds + '"的数据项?');
await modal.confirm('是否确认删除日志编号为"' + operIds + '"的数据项?');
await delOperlog(operIds);
await getList();
proxy?.$modal.msgSuccess('删除成功');
modal.msgSuccess('删除成功');
};
/** 清空按钮操作 */
const handleClean = async () => {
await proxy?.$modal.confirm('是否确认清空所有操作日志数据项?');
await modal.confirm('是否确认清空所有操作日志数据项?');
await cleanOperlog();
await getList();
proxy?.$modal.msgSuccess('清空成功');
modal.msgSuccess('清空成功');
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
requestDownload(
'monitor/operlog/export',
{
...queryParams.value

View File

@@ -52,7 +52,7 @@
</template>
</el-descriptions-item>
<el-descriptions-item label="操作时间">
<template #default>{{ proxy.parseTime(info.operTime) }}</template>
<template #default>{{ parseTime(info.operTime) }}</template>
</el-descriptions-item>
<el-descriptions-item v-if="info.status === 1" label="异常信息">
<template #default>
@@ -64,9 +64,11 @@
</template>
<script setup lang="ts">
import type { OperLogForm } from '@/api/monitor/operlog/types';
import VueJsonPretty from 'vue-json-pretty';
import type { OperLogForm } from '@/api/monitor/operlog/types';
import 'vue-json-pretty/lib/styles.css';
import { useDict } from '@/utils/dict';
import { parseTime, selectDictLabel } from '@/utils/ruoyi';
const open = ref(false);
const info = ref<OperLogForm | null>(null);
@@ -99,13 +101,12 @@ function formatToJsonObject(data: string) {
/**
* 字典信息
*/
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_oper_type, sys_device_type } = toRefs<any>(proxy?.useDict('sys_oper_type', 'sys_device_type'));
const { sys_oper_type, sys_device_type } = toRefs<any>(useDict('sys_oper_type', 'sys_device_type'));
const typeFormat = (row: OperLogForm) => {
return proxy?.selectDictLabel(sys_oper_type.value, row.businessType);
return selectDictLabel(sys_oper_type.value, row.businessType);
};
const deviceTypeFormat = (deviceType: string) => {
return proxy?.selectDictLabel(sys_device_type.value, deviceType);
return selectDictLabel(sys_device_type.value, deviceType);
};
</script>