mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-01 03:24:14 +08:00
fix: Fix issue where saving throws an error after entering a decimal in frequency access limit (#7997)
This commit is contained in:
parent
fb299179e8
commit
109c77a4b6
16
frontend/src/directives/index.ts
Normal file
16
frontend/src/directives/index.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { App, Directive } from 'vue';
|
||||
import integerInput from './modules/integer';
|
||||
|
||||
const directivesList: { [key: string]: Directive } = {
|
||||
'integer-input': integerInput,
|
||||
};
|
||||
|
||||
const directives = {
|
||||
install: function (app: App<Element>) {
|
||||
Object.keys(directivesList).forEach((key) => {
|
||||
app.directive(key, directivesList[key]);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default directives;
|
23
frontend/src/directives/modules/integer.ts
Normal file
23
frontend/src/directives/modules/integer.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import type { Directive, DirectiveBinding } from 'vue';
|
||||
|
||||
const integerInput: Directive = {
|
||||
mounted(el: HTMLElement, binding: DirectiveBinding) {
|
||||
const { value } = binding;
|
||||
el.addEventListener('input', (event: Event) => {
|
||||
const inputElement = event.target as HTMLInputElement;
|
||||
let inputValue = inputElement.value;
|
||||
inputValue = inputValue.replace(/\..*/, '');
|
||||
if (value?.min !== undefined && Number(inputValue) < value.min) {
|
||||
inputValue = value.min.toString();
|
||||
}
|
||||
if (value?.max !== undefined && Number(inputValue) > value.max) {
|
||||
inputValue = value.max.toString();
|
||||
}
|
||||
inputElement.value = inputValue;
|
||||
const inputEvent = new Event('input', { bubbles: true });
|
||||
inputElement.dispatchEvent(inputEvent);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default integerInput;
|
@ -28,6 +28,8 @@ import hljsVuePlugin from '@highlightjs/vue-plugin';
|
||||
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css';
|
||||
import VirtualScroller from 'vue-virtual-scroller';
|
||||
|
||||
import directives from '@/directives/index';
|
||||
|
||||
const app = createApp(App);
|
||||
app.use(hljsVuePlugin);
|
||||
app.component('SvgIcon', SvgIcon);
|
||||
@ -43,4 +45,6 @@ app.use(router);
|
||||
app.use(i18n);
|
||||
app.use(pinia);
|
||||
app.use(Components);
|
||||
app.use(directives);
|
||||
|
||||
app.mount('#app');
|
||||
|
@ -24,7 +24,7 @@
|
||||
</div>
|
||||
<div class="w-full">
|
||||
<el-progress
|
||||
v-if="value.total === 0"
|
||||
v-if="value.total === 0 && value.percent != 100"
|
||||
:percentage="100"
|
||||
:indeterminate="true"
|
||||
:duration="1"
|
||||
|
Loading…
x
Reference in New Issue
Block a user