mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-10 00:31:10 +08:00
【新增】插件git同步模块,用于同步项目内容,加速项目开发
【调整】前端暗色问题
This commit is contained in:
33
frontend/apps/allin-ssl/src/lib/directive.tsx
Normal file
33
frontend/apps/allin-ssl/src/lib/directive.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { App, Directive, DirectiveBinding } from 'vue'
|
||||
|
||||
/**
|
||||
* 移除输入框中的空格
|
||||
* 用法:v-nospace
|
||||
*/
|
||||
export const vNospace: Directive = {
|
||||
mounted(el: HTMLElement, binding: DirectiveBinding) {
|
||||
el.addEventListener('input', (event: Event) => {
|
||||
const inputElement = event.target as HTMLInputElement
|
||||
const newValue = inputElement.value.replace(/\s+/g, '')
|
||||
|
||||
// 直接设置输入元素的值
|
||||
if (inputElement.value !== newValue) {
|
||||
inputElement.value = newValue
|
||||
// 触发自定义事件,通知父组件值已更改
|
||||
el.dispatchEvent(new Event('input', { bubbles: true }))
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
// 导出所有指令的集合,方便批量注册
|
||||
export const directives = {
|
||||
nospace: vNospace,
|
||||
}
|
||||
|
||||
// 注册所有指令
|
||||
export const useDirectives = (app: App, directives: Record<string, Directive>) => {
|
||||
Object.entries(directives).forEach(([key, value]) => {
|
||||
app.directive(key, value)
|
||||
})
|
||||
}
|
||||
0
frontend/apps/allin-ssl/src/lib/index.tsx
Normal file
0
frontend/apps/allin-ssl/src/lib/index.tsx
Normal file
Reference in New Issue
Block a user