feat(plugin-watermark): 提供开关

This commit is contained in:
wanchun 2022-04-18 13:02:29 +08:00
parent 74d94fb001
commit 162a0b89d3
3 changed files with 18 additions and 2 deletions

View File

@ -8,7 +8,7 @@ export default (api) => {
config: { config: {
schema(joi) { schema(joi) {
return joi.object({ return joi.object({
roles: joi.object() disabled: joi.boolean()
}); });
}, },
default: {} default: {}
@ -17,6 +17,16 @@ export default (api) => {
const absoluteFilePath = join(namespace, 'core.js'); const absoluteFilePath = join(namespace, 'core.js');
// 当配置为disabled时不显示水印
api.modifyConfig((memo) => {
const defineConfig = memo.define;
defineConfig.WATERMARK_DISABLED = memo.watermark.disabled ?? false;
return {
...memo,
define: defineConfig
};
});
api.onGenerateFiles(() => { api.onGenerateFiles(() => {
api.copyTmpFiles({ api.copyTmpFiles({

View File

@ -44,6 +44,10 @@ export function createWatermark({
zIndex = 99999, zIndex = 99999,
timestamp = 'YYYY-MM-DD hh:mm' timestamp = 'YYYY-MM-DD hh:mm'
} = {}) { } = {}) {
// eslint-disable-next-line no-undef
if (WATERMARK_DISABLED) {
return;
}
const param = { const param = {
container, container,
width, width,

View File

@ -12,7 +12,9 @@ export default {
router: { router: {
mode: 'hash' mode: 'hash'
}, },
watermark: {}, watermark: {
disabled: false
},
access: { access: {
roles: { roles: {
admin: ['*'], admin: ['*'],