11import { observable } from 'mobx' ;
22import { BiSearchModelClass } from 'mobx-lark' ;
3- import { BaseModel } from 'mobx-restful' ;
3+ import { BaseModel , DataObject , ListModel , toggle } from 'mobx-restful' ;
4+ import { Base , SearchableFilter } from 'mobx-strapi' ;
5+ import { Constructor } from 'web-utility' ;
6+
7+ import { ownClient } from './Base' ;
8+ import { OrganizationModel } from './Organization' ;
9+
10+ export type SearchModel < T extends DataObject = any > = ListModel < T , SearchableFilter < T > > ;
411
512export type SearchPageMeta = Pick <
613 InstanceType < BiSearchModelClass > ,
@@ -10,7 +17,9 @@ export type SearchPageMeta = Pick<
1017export type CityCoordinateMap = Record < string , [ number , number ] > ;
1118
1219export class SystemModel extends BaseModel {
13- searchMap : Record < string , BiSearchModelClass > = { } ;
20+ searchMap = {
21+ NGO : OrganizationModel ,
22+ } as Record < string , Constructor < SearchModel < Base > > > ;
1423
1524 @observable
1625 accessor screenNarrow = false ;
@@ -27,22 +36,14 @@ export class SystemModel extends BaseModel {
2736
2837 updateScreen = ( ) =>
2938 ( this . screenNarrow =
30- globalThis . innerWidth < globalThis . innerHeight ||
31- globalThis . innerWidth < 992 ) ;
39+ globalThis . innerWidth < globalThis . innerHeight || globalThis . innerWidth < 992 ) ;
3240
41+ @toggle ( 'downloading' )
3342 async getCityCoordinate ( ) {
34- // Placeholder for city coordinate data
35- // In production, this would load from an API or static data
36- this . cityCoordinate = {
37- '北京' : [ 116.4074 , 39.9042 ] ,
38- '上海' : [ 121.4737 , 31.2304 ] ,
39- '广州' : [ 113.2644 , 23.1291 ] ,
40- '深圳' : [ 114.0579 , 22.5431 ] ,
41- '杭州' : [ 120.1551 , 30.2741 ] ,
42- '成都' : [ 104.0668 , 30.5728 ] ,
43- '武汉' : [ 114.3054 , 30.5931 ] ,
44- '西安' : [ 108.9402 , 34.3416 ] ,
45- } ;
43+ const { body } = await ownClient . get < CityCoordinateMap > (
44+ 'https://idea2app.github.io/public-meta-data/china-city-coordinate.json' ,
45+ ) ;
46+ return ( this . cityCoordinate = body ! ) ;
4647 }
4748}
4849
0 commit comments