fetchSearchHistory.js 869 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { config } from '../../config/index';
  2. /** 获取搜索历史 */
  3. function mockSearchHistory() {
  4. const { delay } = require('../_utils/delay');
  5. const { getSearchHistory } = require('../../model/search');
  6. return delay().then(() => getSearchHistory());
  7. }
  8. /** 获取搜索历史 */
  9. export function getSearchHistory() {
  10. if (config.useMock) {
  11. return mockSearchHistory();
  12. }
  13. return new Promise((resolve) => {
  14. resolve('real api');
  15. });
  16. }
  17. /** 获取搜索历史 */
  18. function mockSearchPopular() {
  19. const { delay } = require('../_utils/delay');
  20. const { getSearchPopular } = require('../../model/search');
  21. return delay().then(() => getSearchPopular());
  22. }
  23. /** 获取搜索历史 */
  24. export function getSearchPopular() {
  25. if (config.useMock) {
  26. return mockSearchPopular();
  27. }
  28. return new Promise((resolve) => {
  29. resolve('real api');
  30. });
  31. }