( title: string, subtitle: string, arg: string = "", pronounce: string = "")
| 125 | } |
| 126 | |
| 127 | private addResult( title: string, subtitle: string, arg: string = "", pronounce: string = ""): Result[] { |
| 128 | const quicklookurl = "https://www.youdao.com/w/" + this.word; |
| 129 | |
| 130 | const maxLength = this.detectChinese(title) ? 27 : 60; |
| 131 | |
| 132 | if (title.length > maxLength) { |
| 133 | const copy = title; |
| 134 | title = copy.slice(0, maxLength); |
| 135 | subtitle = copy.slice(maxLength); |
| 136 | } |
| 137 | |
| 138 | this.results.push({ title, subtitle, arg, pronounce, quicklookurl }); |
| 139 | return this.results; |
| 140 | } |
| 141 | |
| 142 | private detectChinese(word: string): boolean { |
| 143 | return /^[\u4e00-\u9fa5]+$/.test(word); |
no test coverage detected