水印、消息管理

This commit is contained in:
陈红丽 2024-10-11 15:03:59 +08:00
parent 46128c8525
commit 879dfb8a74
8 changed files with 97 additions and 77 deletions

View File

@ -17,6 +17,7 @@
import { useLockscreenStore } from '@/store/modules/lockscreen'; import { useLockscreenStore } from '@/store/modules/lockscreen';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { PageEnum } from '@/enums/pageEnum'; import { PageEnum } from '@/enums/pageEnum';
import Watermark from '@/utils/wartermark';
const route = useRoute(); const route = useRoute();
const useLockscreen = useLockscreenStore(); const useLockscreen = useLockscreenStore();
@ -49,9 +50,9 @@
}; };
onMounted(() => { onMounted(() => {
// document.addEventListener('mousedown', timekeeping); const waterText = import.meta.env.VITE_GLOB_APP_TITLE;
Watermark.set(waterText)
}); });
onUnmounted(() => { onUnmounted(() => {
// document.removeEventListener('mousedown', timekeeping); // document.removeEventListener('mousedown', timekeeping);
}); });

View File

@ -384,7 +384,7 @@
await nextTick(); await nextTick();
const headEl = tableEl.querySelector('.el-table__header-wrapper'); const headEl = tableEl.querySelector('.el-table__header-wrapper');
const { bottomIncludeBody } = getViewportOffset(headEl); const { bottomIncludeBody } = getViewportOffset(headEl);
let headerH = 40; let headerH = 30;
let paginationH = 0; let paginationH = 0;
let marginH = 0; let marginH = 0;
if (!isBoolean(pagination.value)) { if (!isBoolean(pagination.value)) {

47
src/utils/wartermark.ts Normal file
View File

@ -0,0 +1,47 @@
// 页面添加水印效果
const setWatermark = (str: string) => {
const id = '1.23452384164.123412416';
if (document.getElementById(id) !== null) document.body.removeChild(<HTMLElement>document.getElementById(id));
const can = document.createElement('canvas');
can.width = 200;
can.height = 130;
const cans = <CanvasRenderingContext2D>can.getContext('2d');
cans.rotate((-20 * Math.PI) / 180);
cans.font = '12px Vedana';
cans.fillStyle = 'rgba(200, 200, 200, 0.30)';
cans.textBaseline = 'middle';
cans.fillText(str, can.width / 10, can.height / 2);
const div = document.createElement('div');
div.id = id;
div.style.pointerEvents = 'none';
div.style.top = '0px';
div.style.left = '0px';
div.style.position = 'fixed';
div.style.zIndex = '10000000';
div.style.width = `${document.documentElement.clientWidth}px`;
div.style.height = `${document.documentElement.clientHeight}px`;
div.style.background = `url(${can.toDataURL('image/png')}) left top repeat`;
document.body.appendChild(div);
return id;
};
/**
*
* @method set
* @method del
*/
const watermark = {
// 设置水印
set: (str: string) => {
let id = setWatermark(str);
if (document.getElementById(id) === null) id = setWatermark(str);
},
// 删除水印
del: () => {
let id = '1.23452384164.123412416';
if (document.getElementById(id) !== null) document.body.removeChild(<HTMLElement>document.getElementById(id));
},
};
// 导出方法
export default watermark;

View File

@ -1,23 +1,21 @@
<template> <template>
<PageWrapper> <PageWrapper>
<el-row :gutter="10" class="mt-3"> <el-card shadow="never" size="small" class="proCard tabsCard">
<el-col :xs="24" :sm="24" :md="3" :lg="3" :xl="3"> <el-tabs v-model="activeName" @tab-change="handleClick">
<el-card shadow="hover" class="mb-4 border-0 proCard" :style="{ height: docHeight + 'px' }"> <el-tab-pane
<div :name="item.value"
v-for="(item, index) in messageTypeList" v-for="(item, index) in messageTypeList"
:key="index" :key="index"
@click="handleClick(item, index)"
class="type-item"
:class="index == activeIndex ? 'active' : ''"
> >
<template #label>
<span class="custom-tabs-label">
<el-badge :value="item.number ? item.number : ''" :max="99" class="item"> <el-badge :value="item.number ? item.number : ''" :max="99" class="item">
<span class="t1">{{ item.name }}</span> <span class="t1">{{ item.name }}</span>
</el-badge> </el-badge>
</div> </span>
</el-card> </template>
</el-col> </el-tab-pane>
<el-col :xs="24" :sm="24" :md="21" :lg="21" :xl="21"> </el-tabs>
<el-card shadow="hover" class="mb-4 border-0 proCard">
<BasicTable <BasicTable
:columns="columns" :columns="columns"
:request="loadDataTable" :request="loadDataTable"
@ -39,8 +37,6 @@
</template> </template>
</BasicTable> </BasicTable>
</el-card> </el-card>
</el-col>
</el-row>
<editDialog <editDialog
v-if="editVisible" v-if="editVisible"
:messageId="messageId" :messageId="messageId"
@ -64,7 +60,7 @@
const editDialog = defineAsyncComponent(() => import('./edit.vue')); const editDialog = defineAsyncComponent(() => import('./edit.vue'));
const messageId = ref(0); const messageId = ref(0);
const docHeight = ref(500); const docHeight = ref(500);
const activeIndex = ref(0); const activeName = ref(1);
const messageTypeList = ref([ const messageTypeList = ref([
{ {
name: '系统通知', name: '系统通知',
@ -118,7 +114,7 @@
const loadDataTable = async (res: any) => { const loadDataTable = async (res: any) => {
const result = await getMessageProfile({ ...formParams, ...res }); const result = await getMessageProfile({ ...formParams, ...res });
let item = messageTypeList.value.find((item, index) => index == activeIndex.value); let item = messageTypeList.value.find((item, index) => item.value == activeName.value);
item.number = result.number; item.number = result.number;
return result; return result;
}; };
@ -126,9 +122,9 @@
function reloadTable(noRefresh = '') { function reloadTable(noRefresh = '') {
tableRef.value.reload(noRefresh ? {} : { pageNo: 1 }); tableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
} }
const handleClick = (item, index) => { const handleClick = (e) => {
activeIndex.value = index; activeName.value = e
formParams.type = item.value; formParams.type = activeName.value;
reloadTable(); reloadTable();
}; };
@ -166,32 +162,8 @@
}); });
</script> </script>
<style lang="scss"> <style lang="scss" scoped>
.type-item { :deep(.proCard.tabsCard .el-card__body) {
height: 40px; padding-bottom: 15px;
line-height: 40px;
padding: 0 6px;
cursor: pointer;
display: flex;
justify-content: space-between;
.t1 {
width: 100px;
display: block;
}
&.active {
background-color: #e8f1ff;
border-radius: 3px;
.t1 {
color: #1677ff;
.t2 {
background-color: #ff4d4f;
color: #ffffff;
}
}
}
.el-badge__content.is-fixed {
top: 20px;
right: calc(-10px + var(--el-badge-size) / 2);
}
} }
</style> </style>

View File

@ -104,7 +104,7 @@
size: 10, size: 10,
count: configDataList.value.length, count: configDataList.value.length,
}); });
const fwbHeight = document.body.clientHeight - 370; const fwbHeight = document.body.clientHeight - 360;
/** /**
* 执行添加 * 执行添加

View File

@ -122,7 +122,7 @@
size: 20, size: 20,
count: dictDataList.value.length, count: dictDataList.value.length,
}); });
const fwbHeight = document.body.clientHeight - 370; const fwbHeight = document.body.clientHeight - 360;
/** /**
* 执行添加 * 执行添加

View File

@ -126,7 +126,7 @@
}); });
const cacheName = ref(''); const cacheName = ref('');
const cacheKey = ref(''); const cacheKey = ref('');
const fwbHeight = document.body.clientHeight - 230; const fwbHeight = document.body.clientHeight - 220;
/** /**
* 选择缓存名 * 选择缓存名

View File

@ -73,7 +73,7 @@
size: 10, size: 10,
count: onlineTableData.value.length, count: onlineTableData.value.length,
}); });
const fwbHeight = document.body.clientHeight - 340; const fwbHeight = document.body.clientHeight - 330;
/** /**
* 加载数据列表 * 加载数据列表