nova
5 years ago
7 changed files with 129 additions and 801 deletions
-
3chatto/.gitignore
-
15chatto/src/main/javascript/ts/src/main.ts
-
20chatto/src/main/javascript/ts/src/model/UserModel.ts
-
31chatto/src/main/javascript/ts/src/service/FuseSearchService.ts
-
3chatto/src/main/javascript/ts/src/service/SearchService.ts
-
76chatto/src/main/javascript/ts/src/view/UserView.ts
-
782chatto/src/main/resources/static/js/bundle.js
@ -0,0 +1,31 @@ |
|||||
|
import { SearchService } from "./SearchService"; |
||||
|
// import * as Fuse from 'fuse.js';
|
||||
|
import Fuse = require('fuse.js'); |
||||
|
|
||||
|
export class FuseSearchService<T> implements SearchService<T> { |
||||
|
// private readonly _fuse: Fuse<T, Object>;
|
||||
|
private readonly _params: Fuse.FuseOptions<T>; |
||||
|
|
||||
|
constructor(keys: string[], params: Fuse.FuseOptions<T> = { |
||||
|
shouldSort: true, |
||||
|
threshold: 0.01, |
||||
|
location: 0, |
||||
|
distance: 100, |
||||
|
maxPatternLength: 32, |
||||
|
minMatchCharLength: 1, |
||||
|
// keys: [
|
||||
|
// "userName",
|
||||
|
// ]
|
||||
|
}) { |
||||
|
this._params = params; |
||||
|
this._params.keys = keys; |
||||
|
// this._fuse = new Fuse(list, this._params);
|
||||
|
} |
||||
|
|
||||
|
search<T>(list: T[], searchTerm: string): T[] { |
||||
|
const fuse = new Fuse<T, Fuse.FuseOptions<any>>(list, this._params); |
||||
|
// fuse.search(searchTerm);
|
||||
|
return fuse.search(searchTerm) as T[]; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,3 @@ |
|||||
|
export interface SearchService<T> { |
||||
|
search<T>(list: T[], pattern: string): T[]; |
||||
|
} |
782
chatto/src/main/resources/static/js/bundle.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue