feat: 移除前端解锁前判断权限的逻辑,适配后台解锁接口 (#276)

This commit is contained in:
Gene 2024-01-25 16:42:59 +08:00 committed by GitHub
parent 6ca84ee6f2
commit a192280fc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 32 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>编组 7备份</title>
<g id="ICon" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="编组-7备份">
<rect id="矩形" fill="currentColor" fill-rule="nonzero" opacity="0" x="0" y="0" width="24" height="24"></rect>
<path d="M12.0003,2.00015 C14.6848308,2.00015 16.8613,4.17625357 16.8613,6.86115 L16.8613,6.86115 L16.861,9.24915 L17,9.24985 C18.5970631,9.24985 19.9036168,10.4993657 19.9949049,12.073641 L20,12.24985 L20,18.99985 C20,20.6567698 18.6565074,21.99985 17,21.99985 L17,21.99985 L7,21.99985 C5.34349256,21.99985 4,20.6567698 4,18.99985 L4,18.99985 L4,12.24985 C4,10.5936364 5.34378644,9.24985 7,9.24985 L7,9.24985 L7.138,9.24915 L7.1383,6.86115 C7.1383,4.24864046 9.19888513,2.11813926 11.7837168,2.00488536 L12.0003,2.00015 Z M7.87310737,10.7499992 L7,10.74985 C6.17221356,10.74985 5.5,11.4220636 5.5,12.24985 L5.5,12.24985 L5.5,18.99985 C5.5,19.8282396 6.17181662,20.49985 7,20.49985 L7,20.49985 L17,20.49985 C17.8281834,20.49985 18.5,19.8282396 18.5,18.99985 L18.5,18.99985 L18.5,12.24985 C18.5,11.4220636 17.8277864,10.74985 17,10.74985 L17,10.74985 L16.126,10.74915 L16.1113,10.75015 L7.8883,10.75015 C7.88322385,10.75015 7.87815949,10.7500996 7.87310737,10.7499992 Z M12.0003,3.50015 C10.1432663,3.50015 8.6383,5.00461073 8.6383,6.86115 L8.6383,6.86115 L8.638,9.24925 L15.361,9.24925 L15.3613,6.86115 C15.3613,5.06661755 13.9551107,3.60084673 12.1847022,3.5051226 L12.1847022,3.5051226 L12.0003,3.50015 Z" id="形状结合" fill="currentColor" fill-rule="nonzero"></path>
<g id="编组-4" transform="translate(9.000000, 12.200000)" fill="currentColor">
<circle id="椭圆形" cx="2.95" cy="1.77" r="1.77"></circle>
<path d="M5.9,6.1890106 C5.9,5.44324225 5.62326654,4.76210845 5.16688577,4.24269538 C4.62623603,3.62737464 3.83347166,3.2390106 2.95,3.2390106 C2.0722897,3.2390106 1.28410749,3.6223259 0.743723518,4.23068636 C0.281025729,4.75158825 0,5.43748089 0,6.1890106 C0,6.95798112 5.9,7.02717331 5.9,6.1890106 Z" id="椭圆形"></path>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -18,7 +18,7 @@
<script>
import { computed, reactive } from 'vue'
import { useCanvas, useLayout, useBlock, useNotify, useEditorInfo } from '@opentiny/tiny-engine-controller'
import { useCanvas, useLayout, useBlock, useNotify } from '@opentiny/tiny-engine-controller'
import { constants } from '@opentiny/tiny-engine-utils'
import { Popover } from '@opentiny/vue'
import { requestBlockPage } from './http'
@ -66,17 +66,32 @@ export default {
disabled: false
})
const iconName = computed(() => (state.status === PAGE_STATUS.Occupy ? 'locked' : 'unlocked'))
const iconName = computed(() => {
switch (state.status) {
case PAGE_STATUS.Occupy:
return 'locked'
case PAGE_STATUS.Lock:
return 'user-locked'
default:
return 'unlocked'
}
})
const lockPage = (id, type, newState) => {
requestBlockPage(`id=${id}&state=${newState}&type=${type}`)
.then((data) => {
if (data) {
if (data?.operate === 'success') {
useNotify({
type: 'success',
message: statusMessageMap[newState].message(type)
})
layoutState.pageStatus.state = newState
} else {
const pageInfo = layoutState.pageStatus?.data
useNotify({
type: 'warning',
message: `当前页面被 ${pageInfo?.username || ''} ${pageInfo?.resetPasswordToken || ''} 锁定,请联系解锁`
})
}
})
.catch((error) => {
@ -91,35 +106,8 @@ export default {
})
}
const hasPermission = () => {
if (state.disabled) {
return false
}
const isAdmin = useEditorInfo().isAdmin()
if (state.status === PAGE_STATUS.Lock) {
if (!isAdmin) {
const pageInfo = layoutState.pageStatus?.data
useNotify({
type: 'warning',
message: `当前页面被 ${pageInfo?.username || ''} ${pageInfo?.resetPasswordToken || ''} 锁定,请联系解锁`
})
}
return isAdmin
}
if (![PAGE_STATUS.Occupy, PAGE_STATUS.Release].includes(state.status)) {
return false
}
return true
}
const lockOrUnlock = () => {
if (!hasPermission()) {
if (state.disabled) {
return
}

View File

@ -64,9 +64,9 @@ export default {
height: 32px;
width: 32px;
border-radius: 6px;
font-size: 20px;
svg {
color: var(--ti-lowcode-toolbar-title-color);
font-size: 20px;
}
&.disabled {
cursor: not-allowed;