Skip to content

Commit

Permalink
修改:
Browse files Browse the repository at this point in the history
  * 将查询修改为本地查询。
  • Loading branch information
zenjava committed May 19, 2020
1 parent 29ec363 commit 1e15df0
Show file tree
Hide file tree
Showing 3 changed files with 2,365 additions and 2,146 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"history": "^4.7.2",
"isomorphic-fetch": "^2.2.1",
"marked": "^0.7.0",
"ramda": "^0.27.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-highlight": "^0.12.0",
Expand Down
43 changes: 23 additions & 20 deletions src/search/models/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,38 @@
*
* @flow
*/
import lugiax from '@lugia/lugiax';

const model = 'search';
import lugiax from "@lugia/lugiax";
import { groupBy } from "ramda";
import searchData from "../../router/search";
const model = "search";
const state = {
searchInfo: null,
searchInfo: null
};
export default lugiax.register({
model,
state,
mutations: {
sync: {
handleInputChange(state, inParam) {
return state.set('searchInfo', inParam);

},
return state.set("searchInfo", inParam);
}
},
async:{
async fetchRequest(state, inParam){
const resp = await fetch('http://219.141.235.67:9100/api/search',
{
method: 'Post',
body: JSON.stringify({ q: inParam }),
headers: new Headers({ 'Content-Type': 'application/json' }),
}).then(response => (response.json())).then(data => {
return data;
});
const res = await resp;
return state.set('result', res);
async: {
async fetchRequest(state, q) {
const res = groupBy(item => {
return item.type;
})(
searchData
.filter(item => {
const { content } = item;
return content.toUpperCase().indexOf(q.toUpperCase()) !== -1;
})
.sort((a, b) => a.power - b.power)
);

console.info(res);
return state.set("result", res);
}
}
},
}
});
Loading

0 comments on commit 1e15df0

Please sign in to comment.