diff --git a/package.json b/package.json index beb00c7..9ed9244 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "noob-mengyxu", - "version": "0.4.9", + "name": "noob-mengyxu1", + "version": "1.0.0", "main": "index.ts", "module": "index.ts", "keywords": [ diff --git a/packages/base/data/list-table.vue b/packages/base/data/list-table.vue index 3b7e64d..744923c 100644 --- a/packages/base/data/list-table.vue +++ b/packages/base/data/list-table.vue @@ -3,7 +3,7 @@ + :row-key="rowKey" :tree-porps="treeProps" :lazy="lazy" :load="load" :row-class-name="rowClassName" :empty-text="emptyText"> + :placeholder="placeholder || t('rule.pleaseEnter')" :disabled="disabled" :clearable="clearable" + @input="handleInput"> @@ -44,7 +45,15 @@ const prop = defineProps({ }, width: { type: Number - } + }, + trim: { + type: Boolean, + default: true, + }, + noSpace: { + type: Boolean, + default: false, + }, }); const emit = defineEmits(["update:modelValue"]); const myValue = ref(null); @@ -65,6 +74,10 @@ watch(() => prop.modelValue, (n, o) => { watch(() => state.size, (n, o) => { setWidth(); }) +const handleInput = value => { + prop.trim && (myValue.value = value.trim()) + prop.noSpace && (myValue.value = value.replace(/\s+/g, '')) +} onMounted(() => { prop.modelValue && (myValue.value = prop.modelValue); setWidth(); diff --git a/packages/manage/views/log.vue b/packages/manage/views/log.vue index 382157e..cdefd9b 100644 --- a/packages/manage/views/log.vue +++ b/packages/manage/views/log.vue @@ -2,7 +2,7 @@ - + diff --git a/packages/manage/views/role.vue b/packages/manage/views/role.vue index 653fecf..06fa944 100644 --- a/packages/manage/views/role.vue +++ b/packages/manage/views/role.vue @@ -57,12 +57,13 @@ const form = ref(); const permissionTree = ref(); const role = ref({}); const permissions = ref([]); +const halfWidth = window.innerHeight / 2 + 'px'; const props = [ { i18n: 'role.prop.0', code: 'roleCode', width: 120 }, { i18n: 'role.prop.1', code: 'roleName', width: 120 }, { i18n: 'role.prop.2', code: 'roleDesc', width: 180 }, - { i18n: 'role.prop.3', code: 'roleStatus', dict: 'role_status', width: 180 }, + // { i18n: 'role.prop.3', code: 'roleStatus', dict: 'role_status', width: 180 }, { i18n: 'role.prop.4', code: 'action', slot: true, width: 180, fixed: 'right' } ] @@ -152,6 +153,6 @@ onMounted(() => { \ No newline at end of file diff --git a/plugs/api/dictionary.ts b/plugs/api/dictionary.ts index 91141ce..1986830 100644 --- a/plugs/api/dictionary.ts +++ b/plugs/api/dictionary.ts @@ -1,6 +1,6 @@ import { delate } from '../http/axios'; import { queryPage, save, update } from './base'; -const root = 'dict'; +const root = 'dictionary'; export const list = (example) => { return queryPage(root, example); diff --git a/plugs/api/log.ts b/plugs/api/log.ts index dc83e38..510e62a 100644 --- a/plugs/api/log.ts +++ b/plugs/api/log.ts @@ -1,5 +1,5 @@ import { queryPage } from './base'; -const root = 'log/action'; +const root = 'log'; export const list = (example) => { return queryPage(root, example); }; diff --git a/plugs/element/rule.ts b/plugs/element/rule.ts index 373f14e..6380bd9 100644 --- a/plugs/element/rule.ts +++ b/plugs/element/rule.ts @@ -217,8 +217,8 @@ export class IdCard { export class SimplePassword { required: boolean = true; trigger = 'blur'; - min?: Number = 8; - max?: Number = 16; + min?: Number = 6; + max?: Number = 18; validator = (rule: any, value: any, callback: any) => { if (value == null || value === '') { callback(new Error(t('rule.pleaseEnter') + t('pwd.pwd').toLowerCase())); @@ -234,11 +234,11 @@ export class SimplePassword { export class Username { required: boolean = true; trigger = 'blur'; - min?: Number = 4; - max?: Number = 16; + min?: Number = 8; + max?: Number = 30; validator = (rule: any, value: any, callback: any) => { if (value != null && value.length != 0) { - if (!new RegExp('^[a-zA-Z0-9]{4,16}$').test(value)) { + if (!new RegExp('^[a-zA-Z0-9]{8,30}$').test(value)) { callback(new Error(t('rule.username.0'))); } if (/(^\_)|(\__)|(\_+$)/.test(value)) { @@ -256,7 +256,7 @@ export class Password { required: boolean = true; trigger = 'blur'; min?: Number = 8; - max?: Number = 16; + max?: Number = 20; validator = (rule: any, value: any, callback: any) => { if (value == null || value === '') { callback(new Error(t('rule.pleaseEnter') + t('pwd.pwd').toLowerCase())); diff --git a/plugs/i18n/zh.ts b/plugs/i18n/zh.ts index c685261..331f185 100644 --- a/plugs/i18n/zh.ts +++ b/plugs/i18n/zh.ts @@ -73,7 +73,7 @@ export default class Zh { birth: '你输入的身份证出生日期非法', error: '你输入的身份证号非法', }, - username: ['用户名由字母,数字组成,长度4-16之间', "用户名首尾不能出现下划线'_'", '用户名不能包含空格'], + username: ['用户名由字母,数字组成,长度8-30之间', "用户名首尾不能出现下划线'_'", '用户名不能包含空格'], name: '姓名由汉字或字母组成,且长度不超过10', }; diff --git a/plugs/index.ts b/plugs/index.ts index c5fcb54..6312f91 100644 --- a/plugs/index.ts +++ b/plugs/index.ts @@ -4,4 +4,5 @@ export * as Store from './store'; export * as Http from './http'; export * as Lang from './i18n'; export * as Api from './api'; +export * as WebSocket from './websocket'; export * from './constant'; diff --git a/plugs/websocket.ts b/plugs/websocket.ts new file mode 100644 index 0000000..328f519 --- /dev/null +++ b/plugs/websocket.ts @@ -0,0 +1,52 @@ +let websocket: WebSocket; +const msgHandlersMap = {}; +let lastUrl; +let closeFlag = false; + +export const closeWebSocket = () => { + closeFlag = false; + websocket?.close(); +}; + +export const sendSocketMsg = (msg) => { + websocket?.send(JSON.stringify(msg)); +}; + +export const openWebSocket = (url) => { + if (websocket && websocket.readyState === WebSocket.OPEN) { + if (lastUrl == url) { + return; + } + closeWebSocket(); + } + websocket = new WebSocket(url); + lastUrl = url; + websocket.onopen = () => { + console.log('websocket已连接'); + closeFlag = true; + }; + websocket.onmessage = (msg) => { + const event = JSON.parse(msg.data); + const handlers = msgHandlersMap[event.type]; + if (!handlers) { + return; + } + Object.values(handlers).forEach((handler: any) => { + handler(event.data); + }); + }; + websocket.onclose = () => { + console.log('websocket已断开'); + if (closeFlag) { + setTimeout(() => { + openWebSocket(url); + }, 2000); + } + }; +}; + +export const registerHandler = (type, key, handler) => { + const handlers = msgHandlersMap[type] || {}; + handlers[key] = handler; + msgHandlersMap[type] = handlers; +};