Skip to content

Commit

Permalink
Merge pull request #1452 from jumpserver/pr@dev@perf_water_mark
Browse files Browse the repository at this point in the history
perf: Adding a watermark
  • Loading branch information
ZhaoJiSen authored Sep 3, 2024
2 parents 96df172 + 621a9ae commit 5617a74
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
1 change: 1 addition & 0 deletions ui/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ declare module 'vue' {
Logo: typeof import('./src/components/Kubernetes/Sidebar/components/Logo/index.vue')['default']
MainContent: typeof import('./src/components/Kubernetes/MainContent/index.vue')['default']
NButton: typeof import('naive-ui')['NButton']
NButtonGroup: typeof import('naive-ui')['NButtonGroup']
NCollapse: typeof import('naive-ui')['NCollapse']
NCollapseItem: typeof import('naive-ui')['NCollapseItem']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
Expand Down
39 changes: 29 additions & 10 deletions ui/src/components/Kubernetes/MainContent/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,29 @@
class="bg-[#101014] pt-0"
>
<n-scrollbar trigger="hover">
<CustomTerminal
ref="terminalRef"
class="k8s-terminal"
:socket="socket"
:key="panel.name"
:index-key="panel.name as string"
:theme-name="themeName"
:terminal-type="terminalType"
@socketData="onSocketData"
/>
<n-watermark
cross
selectable
:rotate="-15"
:font-size="16"
:width="192"
:height="128"
:x-offset="12"
:y-offset="28"
:content="waterMarkContent"
:line-height="16"
>
<CustomTerminal
ref="terminalRef"
class="k8s-terminal"
:socket="socket"
:key="panel.name"
:index-key="panel.name as string"
:theme-name="themeName"
:terminal-type="terminalType"
@socketData="onSocketData"
/>
</n-watermark>
</n-scrollbar>
</n-tab-pane>
<template v-slot:suffix>
Expand Down Expand Up @@ -111,6 +124,7 @@ const el = ref();
const nameRef = ref('');
const sessionId = ref('');
const waterMarkContent = ref('');
const enableShare = ref(false);
const terminalType = ref('k8s');
const themeName = ref('Default');
Expand Down Expand Up @@ -297,6 +311,11 @@ const onSocketData = (msgType: string, msg: any, terminal: Terminal) => {
const sessionDetail = sessionInfo.session;
const share = sessionInfo.permission.actions.includes('share');
const username = `${sessionDetail.user}`;
if (setting.value.SECURITY_WATERMARK_ENABLED) {
waterMarkContent.value = `${username}\n${sessionDetail.asset.split('(')[0]}`;
}
if (sessionInfo.backspaceAsCtrlH) {
const value = sessionInfo.backspaceAsCtrlH ? '1' : '0';
Expand Down

0 comments on commit 5617a74

Please sign in to comment.