支持多字查询

master
yutent 2022-03-11 16:23:29 +08:00
parent 2033e9f155
commit d717fd0804
3 changed files with 36 additions and 15 deletions

View File

@ -1 +1 @@
body{line-height:1.5;font-size:14px;color:var(--color-dark-1)}a{color:inherit;text-decoration:none}wc-switch{cursor:pointer}.app{width:100%;height:100vh}.flex{display:flex}.flex.column{flex-direction:column}.flex.ac{justify-content:center}.flex.alc{align-items:center}.flex.acc{justify-content:center;align-items:center}.flex.asc{justify-content:space-between;align-items:center}.wrapper{width:1024px}.topbar{width:100%;height:64px;background:#fff;box-shadow:0 6px 12px rgba(0,0,0,.05)}.topbar .logo{font-size:24px;color:var(--color-red-1)}.topbar .logo span{font-size:14px}.topbar .navs{font-size:16px}.topbar .navs .nav{margin-left:32px;cursor:pointer;transition:color .2s linear}.topbar .navs .nav.active,.topbar .navs .nav:hover{text-decoration:underline;color:var(--color-red-1)}.main{flex:1}.main .table-info{width:100%;height:64px}.main .search{width:100%}.main .search .field{margin-top:16px}.main .search .field.result{line-height:2;word-wrap:break-word;white-space:pre-wrap}.main .search .field wc-input{flex:1}.footer{width:100%;height:64px;border-top:1px solid var(--color-plain-2)}@media screen and (max-width: 1024px){.topbar,.main{padding:0 16px}.footer .wrapper{flex-direction:column;align-items:center;justify-content:center}}
body{line-height:1.5;font-size:14px;color:var(--color-dark-1)}a{color:inherit;text-decoration:none}wc-switch{cursor:pointer}.app{width:100%;height:100vh}.flex{display:flex}.flex.column{flex-direction:column}.flex.ac{justify-content:center}.flex.alc{align-items:center}.flex.acc{justify-content:center;align-items:center}.flex.asc{justify-content:space-between;align-items:center}.wrapper{width:1024px}.topbar{width:100%;height:64px;background:#fff;box-shadow:0 6px 12px rgba(0,0,0,.05)}.topbar .logo{font-size:24px;color:var(--color-red-1)}.topbar .logo span{font-size:14px}.topbar .navs{font-size:16px}.topbar .navs .nav{margin-left:32px;cursor:pointer;transition:color .2s linear}.topbar .navs .nav.active,.topbar .navs .nav:hover{text-decoration:underline;color:var(--color-red-1)}.main{flex:1}.main .table-info{width:100%;height:64px}.main .search{width:100%}.main .search .field{margin-top:16px}.main .search .field.result{line-height:2;font-family:Menlo;word-wrap:break-word;white-space:pre-wrap}.main .search .field wc-input{flex:1}.footer{width:100%;height:64px;border-top:1px solid var(--color-plain-2)}@media screen and (max-width: 1024px){.topbar,.main{padding:0 16px}.footer .wrapper{flex-direction:column;align-items:center;justify-content:center}}

View File

@ -94,6 +94,7 @@ wc-switch {
&.result {
line-height: 2;
font-family: Menlo;
word-wrap: break-word;
white-space: pre-wrap;
}

View File

@ -66,21 +66,41 @@ Anot({
reverse = /^[a-z]{1,4}$/.test(params.txt)
res = WB_TABLE.get(params.txt)
if (!reverse) {
params.txt = params.txt.replace(/[\sa-z]/g, '')
}
if (params.txt.length > 1) {
res = params.txt.split('').map(t => WB_TABLE.get(t))
} else {
res = [WB_TABLE.get(params.txt)]
}
if (res) {
if (reverse) {
res = res.join('\t\t')
if (res[0]) {
res = `${params.txt} 】👉\t${res[0].join('\t\t')}`
} else {
res = res.map(t => `${WB_CODE_NAME.get(t.length)}: ${t}`).join('\t\t')
res = `${
params.txt
} 👉\t无结果, 请检查你的输入是否正确, 如果确认无误, 可以反馈缺失字库`
}
} else {
res = res
.map((it, i) => {
if (it) {
return `${params.txt[i]} 】👉\t${it
.map(t => `${WB_CODE_NAME.get(t.length)}: ${t.toUpperCase()}`)
.join('\t\t')}`
} else {
return `${
params.txt[i]
} 👉\t无结果, 请检查你的输入是否正确, 如果确认无误, 可以反馈缺失字库`
}
})
.join('\n')
}
this.result = `查询结果: 【 ${params.txt}\n${res.toUpperCase()}`
} else {
this.result = `查询结果: 【 ${
params.txt
} \n无结果, 请检查你的输入是否正确, 如果确认无误, 可以反馈缺失字库`
}
this.result = `查询结果: \n${res}`
}
}
})