修复输入框bug,历史命令框置顶,增加判断字母数字方法

pull/22/head
Zoe 7 years ago
parent f936c0c5df
commit 8c510b30cb

@ -12,7 +12,15 @@ export function IsChar(keyCode: number)
{
return keyCode >= 65 && keyCode <= 90
}
export function isLetter(s: string)
{
let code = s.charCodeAt(0);
return (code >= 97 && code <= 122) || (code >= 65 && code <= 90)
}
export function isNum(s: string)
{
return !isNaN(parseFloat(s));
}
export function ArrayRemove(arr: Array<any>, el: any)
{
let index = arr.indexOf(el);
@ -35,4 +43,4 @@ export function FixIndex(index: number, arr: Array<any> | number)
return 0
else
return index
}
}

@ -1,10 +1,3 @@
/*
* @Author: Zoe
* @Date: 2017-12-01 10:25:21
* @Last Modified by: mikey.zhaopeng
* @Last Modified time: 2017-12-08 14:54:54
*
*/
html {
font-size: 10px;
@ -19,12 +12,6 @@ a {
#input-hint {
overflow: hidden;
flex-basis: 25px;
/* width: 100%;
position: fixed;
color: #000;
z-index: 99;
left: 0;
bottom: 16px; */
}

@ -7,7 +7,7 @@ import { end } from 'xaop';
import { app } from '../../../ApplicationServices/Application';
import { KeyWord } from '../../../Common/InputState';
import { KeyBoard } from '../../../Common/KeyEnum';
import { ArrayRemove, FixIndex, IsChar, IsNumble } from '../../../Common/Utils';
import { ArrayRemove, FixIndex, IsChar, IsNumble, isNum, isLetter } from '../../../Common/Utils';
interface InputHintProps
{
@ -103,16 +103,20 @@ export class InputHint extends React.Component<InputHintProps, InputHitState>
{
return;
}
if (inputCmd == "")
let isIntell = inputCmd.split("").every((str: string) =>
{
return isLetter(str) || isNum(str);
})
if (inputCmd == "" || !isIntell)
{
this.setState({ intelliSenseCommand: [] });
return;
}
inputCmd = inputCmd.toUpperCase();
// 动态生成正则表达式
let searchReg: RegExp;
// 拼接动态正则表达式
let m_comTmp: string = '^' + inputCmd.toUpperCase().split('').join('\\w*') + '\\w*$';
let m_comTmp: string = '^' + inputCmd.split('').join('\\w*') + '\\w*$';
searchReg = new RegExp(m_comTmp, 'i');
let intelliSenseCmdList: string[] = [];
@ -121,27 +125,13 @@ export class InputHint extends React.Component<InputHintProps, InputHitState>
if (cmdName.indexOf(inputCmd) !== -1)
{
intelliSenseCmdList.push(cmdName);
return;
}
if (searchReg.test(cmdName))
{
intelliSenseCmdList.push(cmdName);
}
}
// while (true)
// {
// console.log(m_comTmp);
// tmpStr = m_comTmp.splice(i, 0, "\\w*").toString()
// if (RegExp(tmpStr, "i").test(cmdName))
// {
// intelliSenseCmdList.push({
// level: i,
// cmd: cmdName
// });
// return;
// }
// i += 2;
// }
intelliSenseCmdList.sort((c1, c2) =>
{
return c1.length < c2.length ? -1 : 1;

@ -436,3 +436,7 @@ img {
.button-marign {
margin-right: 10px;
}
/*修改黄金布局框架源码样式*/
#app .lm_content{
overflow: unset;
}

Loading…
Cancel
Save