diff --git a/.editorconfig b/.editorconfig index f5a84b5..82da0b1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,52 +1,15 @@ -[*] -charset=utf-8 -end_of_line=lf -trim_trailing_whitespace=true -insert_final_newline=false -indent_style=space -indent_size=4 - -[{*.ng,*.sht,*.html,*.shtm,*.shtml,*.htm}] -indent_style=space -indent_size=2 - -[{.babelrc,.stylelintrc,.eslintrc,jest.config,*.json,*.jsb3,*.jsb2,*.bowerrc}] -indent_style=space -indent_size=2 - -[*.css] -indent_style=space -indent_size=2 - -[{*.applejs,*.js}] -indent_style=space -indent_size=2 - -[{*.ats,*.ts}] -indent_style=space -indent_size=2 +# http://editorconfig.org -[*.tsx] -indent_style=space -indent_size=2 - -[*.js] -indent_style=space -indent_size=2 - -[*.js.map] -indent_style=space -indent_size=2 - -[*.less] -indent_style=space -indent_size=2 - -[{.analysis_options,*.yml,*.yaml}] -indent_style=space -indent_size=2 - -[tslint.json] -indent_style=space -indent_size=2 +root = true +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..ffd349a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,10 @@ +**/*.md +**/*.svg +**/test.ts +_nginx/ +_screenshot/ +node_modules/ +coverage/ +dist/ +package.json +src/templates/ diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..f70500a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,14 @@ +{ + "printWidth": 120, + "singleQuote": true, + "semi": true, + "trailingComma": "all", + "tabWidth": 2, + "useTabs": false, + "overrides": [{ + "files": ".prettierrc", + "options": { + "parser": "json" + } + }] +} diff --git a/components/pagination/pagination.spec.ts b/.stylelintignore similarity index 100% rename from components/pagination/pagination.spec.ts rename to .stylelintignore diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 0000000..ba1b4a0 --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,25 @@ +{ + "extends": [ + "stylelint-config-standard", + "stylelint-config-css-modules", + "stylelint-config-rational-order", + "stylelint-config-prettier" + ], + "plugins": ["stylelint-order", "stylelint-declaration-block-no-ignored-properties"], + "rules": { + "no-descending-specificity": null, + "plugin/declaration-block-no-ignored-properties": true, + "selector-type-no-unknown": null, + "selector-pseudo-element-no-unknown": [ + true, + { + "ignorePseudoElements": [ + "ng-deep" + ] + } + ] + }, + "ignoreFiles": [ + "src/assets/**/*" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 976f2a1..4d9cf11 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,13 +1,25 @@ // Place your settings in this file to overwrite default and user settings. { - "javascript.implicitProjectConfig.checkJs": true, "files.watcherExclude": { "**/.git/objects/**": true, "**/.git/subtree-cache/**": true, "**/node_modules/*/**": true, "**/dist/*/**": true, - "**/coverage/*/**": true, - "**/tools/*/**": true + "**/coverage/*/**": true }, - "tslint.autoFixOnSave": true -} \ No newline at end of file + "html.format.wrapAttributes": "force-aligned", + "html.format.wrapLineLength": 100, + "editor.tabSize": 2, + "editor.insertSpaces": true, + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll": true, + }, + "[markdown]": { + "editor.formatOnSave": false + }, + "[javascript]": { + "editor.formatOnSave": false + }, + "prettier.stylelintIntegration": true +} diff --git a/README.md b/README.md index ed8a2cb..25ea4ae 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,12 @@ ngx-weui -[![](https://cdn-images-1.medium.com/max/3840/1*DzVxlbQups8aAEhFRuZ6dQ.png)](https://cipchk.github.io/ngx-weui/) +[![](https://cdn-images-1.medium.com/max/1600/1*ceWDQUy3-MQgEchW6SuSRA.png)](https://cipchk.github.io/ngx-weui/) + +## Version + +- WeUI 1.x using `7.0.x` +- WeUI 2.x using `7.1.x` ## Table of Contents @@ -40,8 +45,6 @@ ngx-weui ```bash npm install -g @angular/cli -# Optional: Set default use of yarn to install dependencies -# ng config -g cli.packageManager yarn ``` 2. New a empty angular project diff --git a/components/accordion/accordion-panel.component.ts b/components/accordion/accordion-panel.component.ts index 3f105ac..6bc634c 100644 --- a/components/accordion/accordion-panel.component.ts +++ b/components/accordion/accordion-panel.component.ts @@ -1,29 +1,27 @@ -import { - Component, - Input, - Inject, - HostBinding, - OnDestroy, - OnInit, -} from '@angular/core'; +import { ChangeDetectionStrategy, Component, Inject, Input, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; +import { InputBoolean } from 'ngx-weui/core'; import { AccordionComponent } from './accordion.component'; @Component({ selector: 'weui-accordion-panel', + exportAs: 'weuiAccordionPanel', template: ` -
+
- `, + `, host: { '[class.weui-accordion-panel-disabled]': 'disabled', '[class.weui-accordion-active]': 'active', - } + }, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class AccordionPanelComponent implements OnInit, OnDestroy { /** * 是否禁止 */ - @Input() disabled: boolean = false; + @Input() @InputBoolean() disabled: boolean = false; private _active: boolean = false; @@ -31,6 +29,7 @@ export class AccordionPanelComponent implements OnInit, OnDestroy { * 是否展开 */ @Input() + @InputBoolean() get active(): boolean { return this._active; } @@ -40,9 +39,7 @@ export class AccordionPanelComponent implements OnInit, OnDestroy { if (value) this.accordion._closeOthers(this); } - constructor( - @Inject(AccordionComponent) protected accordion: AccordionComponent, - ) { } + constructor(@Inject(AccordionComponent) protected accordion: AccordionComponent) {} ngOnInit() { this.accordion._add(this); @@ -52,7 +49,7 @@ export class AccordionPanelComponent implements OnInit, OnDestroy { this.accordion._remove(this); } - _toggle(event: Event) { + _toggle() { if (!this.disabled) { this.active = !this.active; this.accordion.select.emit(this.accordion._index(this)); diff --git a/components/accordion/accordion.component.ts b/components/accordion/accordion.component.ts index 9c36456..c5b4ec2 100644 --- a/components/accordion/accordion.component.ts +++ b/components/accordion/accordion.component.ts @@ -1,24 +1,30 @@ -import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core'; +import { AnimateType, InputBoolean } from 'ngx-weui/core'; import { AccordionPanelComponent } from './accordion-panel.component'; import { AccordionConfig } from './accordion.config'; -import { AnimateType } from '../utils/types'; @Component({ selector: 'weui-accordion', - template: ``, + exportAs: 'weuiAccordion', + template: ` + + `, host: { '[attr.aria-multiselectable]': 'closeOthers', }, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class AccordionComponent { /** * 是否可折叠,`true` 表示同时所有都允许展开,`false` 表示同时只允许一个展开,默认:`false` */ - @Input() collapsible: boolean = false; + @Input() @InputBoolean() collapsible: boolean = false; /** * 自动展开第一次,默认:`true` */ - @Input() activeFirst: boolean = true; + @Input() @InputBoolean() activeFirst: boolean = true; /** * 动画类型,`none` 无动画,`slide` 滑动,默认:`slide` */ @@ -27,7 +33,7 @@ export class AccordionComponent { /** * 展开时回调,参数为面板下标。 */ - @Output() select = new EventEmitter(); + @Output() readonly select = new EventEmitter(); private panels: AccordionPanelComponent[] = []; diff --git a/components/accordion/accordion.config.ts b/components/accordion/accordion.config.ts index f4a7dcc..03aa970 100644 --- a/components/accordion/accordion.config.ts +++ b/components/accordion/accordion.config.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; -import { AnimateType } from '../utils/types'; +import { AnimateType } from 'ngx-weui/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class AccordionConfig { /** * 是否可折叠,`false` 表示保持只有一个可折叠,`true` 表示所有都允许,默认:`false` diff --git a/components/accordion/accordion.module.ts b/components/accordion/accordion.module.ts index c53b26d..7bd1fd3 100644 --- a/components/accordion/accordion.module.ts +++ b/components/accordion/accordion.module.ts @@ -1,16 +1,11 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { AccordionPanelComponent } from './accordion-panel.component'; import { AccordionComponent } from './accordion.component'; -import { AccordionConfig } from './accordion.config'; @NgModule({ imports: [CommonModule], declarations: [AccordionPanelComponent, AccordionComponent], exports: [AccordionPanelComponent, AccordionComponent], }) -export class AccordionModule { - public static forRoot(): ModuleWithProviders { - return { ngModule: AccordionModule, providers: [AccordionConfig] }; - } -} +export class AccordionModule {} diff --git a/components/accordion/accordion.spec.ts b/components/accordion/accordion.spec.ts index 36a5194..b119cab 100644 --- a/components/accordion/accordion.spec.ts +++ b/components/accordion/accordion.spec.ts @@ -1,9 +1,8 @@ -import { Component, DebugElement } from '@angular/core'; +import { Component } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; -import { AccordionModule } from './accordion.module'; import { AccordionConfig } from './accordion.config'; +import { AccordionModule } from './accordion.module'; const html = ` @@ -33,10 +32,7 @@ function getPanels(element: HTMLElement): Element[] { return Array.from(element.querySelectorAll('weui-accordion-panel')); } -function expectOpenPanels( - nativeEl: HTMLElement, - openPanelsDef: boolean[], -): void { +function expectOpenPanels(nativeEl: HTMLElement, openPanelsDef: boolean[]): void { const panels = getPanels(nativeEl); expect(panels.length).toBe(openPanelsDef.length); for (let i = 0; i < panels.length; i++) { @@ -49,20 +45,15 @@ function expectOpenPanels( } } -function hasTitle(element: HTMLElement, str: string): boolean { - return element.textContent === str; -} - describe('Component: Accordion', () => { let fixture: ComponentFixture; let context: TestAccordionComponent; let element: any; - let dl: DebugElement; beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestAccordionComponent], - imports: [AccordionModule.forRoot()], + imports: [AccordionModule], }); TestBed.overrideComponent(TestAccordionComponent, { set: { template: html }, @@ -70,7 +61,6 @@ describe('Component: Accordion', () => { fixture = TestBed.createComponent(TestAccordionComponent); context = fixture.componentInstance; element = fixture.nativeElement; - dl = fixture.debugElement; fixture.detectChanges(); }); @@ -86,9 +76,7 @@ describe('Component: Accordion', () => { it('should toggle panel via click header', () => { const panels = getPanels(element); - ((panels[1] as HTMLDivElement).querySelector( - '[role="tab"]', - ) as HTMLDivElement).click(); + ((panels[1] as HTMLDivElement).querySelector('[role="tab"]') as HTMLDivElement).click(); fixture.detectChanges(); expectOpenPanels(element, [false, true, false]); }); @@ -106,28 +94,24 @@ describe('Component: Accordion', () => { fixture.detectChanges(); expectOpenPanels(element, [false, false, false]); const panels = getPanels(element); - ((panels[1] as HTMLDivElement).querySelector( - '[role="tab"]', - ) as HTMLDivElement).click(); + ((panels[1] as HTMLDivElement).querySelector('[role="tab"]') as HTMLDivElement).click(); expectOpenPanels(element, [false, false, false]); }); }); describe('Component: Accordion: Auto', () => { let fixture: ComponentFixture; - let context: any; let element: any; beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestAccordionComponent], - imports: [AccordionModule.forRoot()], + imports: [AccordionModule], }); TestBed.overrideComponent(TestAccordionComponent, { set: { template: htmlAutoActiveFirst }, }); fixture = TestBed.createComponent(TestAccordionComponent); - context = fixture.componentInstance; element = fixture.nativeElement; fixture.detectChanges(); }); @@ -139,14 +123,14 @@ describe('Component: Accordion: Auto', () => { @Component({ template: '' }) class TestAccordionComponent { - public collapsible: boolean = true; - public panels: any[] = [ + collapsible: boolean = true; + panels: any[] = [ { title: 'title1', content: 'content1', active: false, disabled: false }, { title: 'title2', content: 'content2', active: false, disabled: false }, { title: 'title3', content: 'content3', active: false, disabled: false }, ]; - public constructor(config: AccordionConfig) { + constructor(config: AccordionConfig) { Object.assign(this, config); } } diff --git a/components/accordion/package.json b/components/accordion/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/accordion/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/actionsheet/actionsheet.component.html b/components/actionsheet/actionsheet.component.html new file mode 100644 index 0000000..51b7897 --- /dev/null +++ b/components/actionsheet/actionsheet.component.html @@ -0,0 +1,12 @@ +
+
+
+

{{ config.title }}

+
+
+
{{ item.text }}
+
+
+
{{ config.cancel }}
+
+
diff --git a/components/actionsheet/actionsheet.component.ts b/components/actionsheet/actionsheet.component.ts index 6d9d069..44a9dcd 100644 --- a/components/actionsheet/actionsheet.component.ts +++ b/components/actionsheet/actionsheet.component.ts @@ -1,39 +1,22 @@ +import { animate, state, style, transition, trigger } from '@angular/animations'; import { + ChangeDetectionStrategy, + ChangeDetectorRef, Component, - OnDestroy, + EventEmitter, Input, - OnChanges, - SimpleChanges, + OnDestroy, Output, - EventEmitter, + ViewEncapsulation, } from '@angular/core'; -import { - animate, - state, - style, - transition, - trigger, -} from '@angular/animations'; -import { isAndroid } from '../utils/browser'; +import { isAndroid } from 'ngx-weui/core'; +import { Observable, Observer, Subscription } from 'rxjs'; import { ActionSheetConfig } from './actionsheet.config'; -import { Observer, Observable, Subscription } from 'rxjs'; @Component({ selector: 'weui-actionsheet', - template: ` -
-
-
-

{{config.title}}

-
-
-
{{item.text}}
-
-
-
{{config.cancel}}
-
-
- `, + exportAs: 'weuiActionsheet', + templateUrl: './actionsheet.component.html', animations: [ trigger('visibility', [ state('show', style({ opacity: 1 })), @@ -44,9 +27,19 @@ import { Observer, Observable, Subscription } from 'rxjs'; host: { '[hidden]': '!_shown', '[class.weui-skin_android]': 'config.skin === "android"', - } + }, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class ActionSheetComponent implements OnDestroy { + private observer: Observer; + private destroied = false; + _shown = false; + /** + * 动画状态码 + */ + _shownAnt = false; /** * 配置项 */ @@ -55,45 +48,41 @@ export class ActionSheetComponent implements OnDestroy { /** * 菜单内容 */ - @Input() menus: { text?: string; [key: string]: any }[]; + @Input() menus: Array<{ text?: string; [key: string]: any }> = []; /** * 关闭回调 */ - @Output() close = new EventEmitter(); - - _shown: boolean = false; - /** - * 动画状态码 - */ - _shownAnt = false; - - private observer: Observer; + @Output() readonly close = new EventEmitter(); get _visibility(): string { return this._shownAnt ? 'show' : 'hide'; } - constructor(private DEF: ActionSheetConfig) { } + constructor(private DEF: ActionSheetConfig, private cdr: ChangeDetectorRef) {} + + private detectChanges() { + if (this.destroied) return; + this.cdr.detectChanges(); + } /** * 显示,组件载入页面后并不会显示,显示调用 `show()` 并订阅结果。 */ show(): Observable { - this.config = Object.assign( - { - backdrop: true, - skin: 'auto', - }, - this.DEF, - this.config, - ); + this.config = { + backdrop: true, + skin: 'auto', + ...this.DEF, + ...this.config, + }; if (this.config.skin === 'auto') { this.config.skin = isAndroid() ? 'android' : 'ios'; } this._shown = true; setTimeout(() => { this._shownAnt = true; + this.detectChanges(); }, 10); return Observable.create((observer: Observer) => { this.observer = observer; @@ -109,10 +98,14 @@ export class ActionSheetComponent implements OnDestroy { if (is_backdrop === true && this.config.backdrop === false) return false; this._shownAnt = false; - setTimeout(() => { - this._shown = false; - this.close.emit(); - }, this.config.skin === 'android' ? 200 : 300); + this.detectChanges(); + setTimeout( + () => { + this._shown = false; + this.close.emit(); + }, + this.config.skin === 'android' ? 200 : 300, + ); } /** @@ -125,8 +118,9 @@ export class ActionSheetComponent implements OnDestroy { } ngOnDestroy(): void { + this.destroied = true; if (this.observer && this.observer instanceof Subscription) { - (this.observer).unsubscribe(); + (this.observer as Subscription).unsubscribe(); } } } diff --git a/components/actionsheet/actionsheet.config.ts b/components/actionsheet/actionsheet.config.ts index 3272464..9371668 100644 --- a/components/actionsheet/actionsheet.config.ts +++ b/components/actionsheet/actionsheet.config.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; -import { SkinType } from '../utils/types'; +import { SkinType } from 'ngx-weui/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class ActionSheetConfig { /** * 样式,默认:`ios` diff --git a/components/actionsheet/actionsheet.module.ts b/components/actionsheet/actionsheet.module.ts index accf46d..65439c3 100644 --- a/components/actionsheet/actionsheet.module.ts +++ b/components/actionsheet/actionsheet.module.ts @@ -1,9 +1,8 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { ActionSheetComponent } from './actionsheet.component'; import { ActionSheetService } from './actionsheet.service'; -import { ActionSheetConfig } from './actionsheet.config'; @NgModule({ imports: [CommonModule], @@ -12,8 +11,4 @@ import { ActionSheetConfig } from './actionsheet.config'; providers: [ActionSheetService], entryComponents: [ActionSheetComponent], }) -export class ActionSheetModule { - static forRoot(): ModuleWithProviders { - return { ngModule: ActionSheetModule, providers: [ActionSheetConfig] }; - } -} +export class ActionSheetModule {} diff --git a/components/actionsheet/actionsheet.service.ts b/components/actionsheet/actionsheet.service.ts index a453eab..dfe48bf 100644 --- a/components/actionsheet/actionsheet.service.ts +++ b/components/actionsheet/actionsheet.service.ts @@ -1,9 +1,9 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; +import { BaseService } from 'ngx-weui/core'; import { ActionSheetComponent } from './actionsheet.component'; import { ActionSheetConfig } from './actionsheet.config'; -import { BaseService } from '../utils/base.service'; @Injectable() export class ActionSheetService extends BaseService { @@ -14,10 +14,7 @@ export class ActionSheetService extends BaseService { * @param config 配置性(可选) * @returns 可订阅来获取结果 */ - show( - menus: { text?: string; [key: string]: any }[], - config: ActionSheetConfig = {}, - ): Observable { + show(menus: Array<{ text?: string; [key: string]: any }>, config: ActionSheetConfig = {}): Observable { const componentRef = this.build(ActionSheetComponent); componentRef.instance.menus = menus; diff --git a/components/actionsheet/actionsheet.spec.ts b/components/actionsheet/actionsheet.spec.ts index 0f43a35..b1fe79a 100644 --- a/components/actionsheet/actionsheet.spec.ts +++ b/components/actionsheet/actionsheet.spec.ts @@ -1,60 +1,37 @@ -import { Component, ViewChild, DebugElement } from '@angular/core'; +import { Component, ViewChild } from '@angular/core'; +import { fakeAsync, inject, tick, ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - ComponentFixtureAutoDetect, - async, - inject, -} from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; - -import { Subscription } from 'rxjs'; - -import { - ActionSheetModule, - ActionSheetComponent, - ActionSheetConfig, - ActionSheetService, -} from '../actionsheet'; -import { isAndroid } from '../utils/browser'; -import * as browserModule from '../utils/browser'; - -const MENUS: any[] = [ - { text: 'menu1', value: 'value1', other: 1 }, - { text: 'menu2', value: 'value2' }, -]; - -const CONFIG: ActionSheetConfig = { + +import { isAndroid } from 'ngx-weui/core'; +// tslint:disable-next-line: no-duplicate-imports +import * as browserModule from 'ngx-weui/core'; +import { ActionSheetComponent, ActionSheetConfig, ActionSheetModule, ActionSheetService } from '../actionsheet'; + +const MENUS: any[] = [{ text: 'menu1', value: 'value1', other: 1 }, { text: 'menu2', value: 'value2' }]; + +const CONFIG: ActionSheetConfig = { title: 'test title', skin: 'ios', cancel: '取消', -}; +} as ActionSheetConfig; function getTitle(nativeEl: HTMLElement): Element { - return nativeEl.querySelector('.weui-actionsheet__title-text'); + return nativeEl.querySelector('.weui-actionsheet__title-text')!; } function getItems(nativeEl: HTMLElement): NodeListOf { - return nativeEl.querySelectorAll( - '.weui-actionsheet__menu .weui-actionsheet__cell', - ); + return nativeEl.querySelectorAll('.weui-actionsheet__menu .weui-actionsheet__cell'); } function getAction(nativeEl: HTMLElement): Element { - return nativeEl.querySelector( - '.weui-actionsheet__action .weui-actionsheet__cell', - ); + return nativeEl.querySelector('.weui-actionsheet__action .weui-actionsheet__cell')!; } describe('Component: ActionSheet', () => { describe('[default]', () => { let fixture: ComponentFixture; let context: TestActionSheetComponent; - let dl: DebugElement; let el: any; const html = ` @@ -64,53 +41,42 @@ describe('Component: ActionSheet', () => { (close)="_close()"> `; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestActionSheetComponent], - imports: [ - ActionSheetModule.forRoot(), - FormsModule, - NoopAnimationsModule, - ], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], - }); - TestBed.overrideComponent(TestActionSheetComponent, { - set: { template: html }, - }); - fixture = TestBed.createComponent(TestActionSheetComponent); - context = fixture.componentInstance; - dl = fixture.debugElement; - el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); - - it( - 'should init', - fakeAsync(() => { - expect(getTitle(el)).not.toBeNull(); - expect(getAction(el)).not.toBeNull(); - expect(getItems(el).length).toBe(2); - }), - ); - - it('should auto style', (done: () => void) => { - context.config = Object.assign(context.config, { skin: 'auto' }); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestActionSheetComponent], + imports: [ActionSheetModule, FormsModule, NoopAnimationsModule], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], + }); + TestBed.overrideComponent(TestActionSheetComponent, { + set: { template: html }, + }); + fixture = TestBed.createComponent(TestActionSheetComponent); + context = fixture.componentInstance; + el = fixture.nativeElement; fixture.detectChanges(); - context.actioinSheet.show().subscribe(res => { + tick(1000); + fixture.detectChanges(); + })); + + it('should init', fakeAsync(() => { + expect(getTitle(el)).not.toBeNull(); + expect(getAction(el)).not.toBeNull(); + expect(getItems(el).length).toBe(2); + })); + + it('should auto style', done => { + context.config = { ...context.config, skin: 'auto' }; + fixture.detectChanges(); + context.actioinSheet.show().subscribe(() => { fixture.detectChanges(); if (isAndroid()) { - expect( - (el as HTMLElement).querySelectorAll('.weui-skin_android').length, - ).toBe(1); + expect((el as HTMLElement).querySelectorAll('.weui-skin_android').length).toBe(1); } else { expect(true).toBeTruthy(); } done(); }); - (getItems(el)[0]).click(); + (getItems(el)[0] as any).click(); }); describe('[Android] style', () => { @@ -118,32 +84,30 @@ describe('Component: ActionSheet', () => { spyOn(browserModule, 'isAndroid').and.returnValue(true); }); - it('should be inited', (done: () => void) => { - context.config = Object.assign(context.config, { skin: 'auto' }); + it('should be inited', done => { + context.config = { ...context.config, skin: 'auto' }; fixture.detectChanges(); - context.actioinSheet.show().subscribe(res => { + context.actioinSheet.show().subscribe(() => { fixture.detectChanges(); - expect( - (el as HTMLElement).querySelectorAll('.weui-skin_android').length, - ).toBe(1); + expect((el as HTMLElement).querySelectorAll('.weui-skin_android').length).toBe(1); done(); }); - (getItems(el)[0]).click(); + (getItems(el)[0] as any).click(); }); }); - it('should be opened set actionsheet title', (done: () => void) => { - context.actioinSheet.show().subscribe(res => { + it('should be opened set actionsheet title', done => { + context.actioinSheet.show().subscribe(() => { fixture.detectChanges(); - const str: string = 'test title'; + const str = 'test title'; expect(getTitle(el).textContent).toBe(str); done(); }); - (getItems(el)[0]).click(); + (getItems(el)[0] as any).click(); }); - it('should be opened set actionsheet items', (done: () => void) => { - context.actioinSheet.show().subscribe(res => { + it('should be opened set actionsheet items', done => { + context.actioinSheet.show().subscribe(() => { fixture.detectChanges(); const items = getItems(el); expect(items.length).toBe(2); @@ -151,33 +115,33 @@ describe('Component: ActionSheet', () => { expect(items[1].textContent).toBe('menu2'); done(); }); - (getItems(el)[0]).click(); + (getItems(el)[0] as any).click(); }); - it('should be opened set actionsheet action', (done: () => void) => { - context.actioinSheet.show().subscribe(res => { + it('should be opened set actionsheet action', done => { + context.actioinSheet.show().subscribe(() => { fixture.detectChanges(); - const str: string = '取消'; + const str = '取消'; expect(getAction(el).textContent).toBe(str); done(); }); - (getItems(el)[0]).click(); + (getItems(el)[0] as any).click(); }); - it('should be opened if android not title & action', (done: () => void) => { + it('should be opened if android not title & action', done => { context.actioinSheet.config.skin = 'android'; fixture.detectChanges(); - context.actioinSheet.show().subscribe(res => { + context.actioinSheet.show().subscribe(() => { fixture.detectChanges(); expect(getTitle(el)).toBeNull(); expect(getAction(el)).toBeNull(); done(); }); - (getItems(el)[0]).click(); + (getItems(el)[0] as any).click(); }); - it('should choose item and get back a result', (done: () => void) => { + it('should choose item and get back a result', done => { fixture.detectChanges(); context.actioinSheet.show().subscribe(res => { @@ -187,10 +151,10 @@ describe('Component: ActionSheet', () => { expect(res.other).toBe(1); done(); }); - (getItems(el)[0]).click(); + (getItems(el)[0] as any).click(); }); - it('should click backdrop has closed', (done: () => void) => { + it('should click backdrop has closed', done => { context.actioinSheet.show(); fixture.detectChanges(); context.actioinSheet.close.subscribe(() => { @@ -201,7 +165,7 @@ describe('Component: ActionSheet', () => { }); it('should click backdrop not-allow closing', () => { - context.config = Object.assign(context.config, { backdrop: false }); + context.config = { ...context.config, backdrop: false }; context.actioinSheet.show(); fixture.detectChanges(); el.querySelector('.weui-mask').click(); @@ -212,38 +176,26 @@ describe('Component: ActionSheet', () => { describe('[service]', () => { let service: ActionSheetService; let fixture: any; - let context: TestActionSheetServiceComponent; - let dl: DebugElement; let el: any; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - imports: [ - ActionSheetModule.forRoot(), - FormsModule, - NoopAnimationsModule, - ], - declarations: [TestActionSheetServiceComponent], - providers: [ActionSheetService], - }).createComponent(TestActionSheetServiceComponent); - - fixture = TestBed.createComponent(TestActionSheetServiceComponent); - context = fixture.componentInstance; - dl = fixture.debugElement; - el = fixture.nativeElement; - fixture.detectChanges(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + imports: [ActionSheetModule, FormsModule, NoopAnimationsModule], + declarations: [TestActionSheetServiceComponent], + providers: [ActionSheetService], + }).createComponent(TestActionSheetServiceComponent); + + fixture = TestBed.createComponent(TestActionSheetServiceComponent); + el = fixture.nativeElement; + fixture.detectChanges(); + })); - beforeEach( - inject([ActionSheetService], (_s: ActionSheetService) => { - service = _s; - }), - ); + beforeEach(inject([ActionSheetService], (_s: ActionSheetService) => { + service = _s; + })); - it('should be show', (done: () => void) => { - service.show(Object.assign([], MENUS)).subscribe(res => { + it('should be show', done => { + service.show([...MENUS]).subscribe(res => { fixture.detectChanges(); expect(res.text).toBe('menu1'); expect(res.value).toBe('value1'); @@ -254,11 +206,11 @@ describe('Component: ActionSheet', () => { }); fixture.detectChanges(); - (getItems(el.nextSibling)[0]).click(); + (getItems(el.nextSibling)[0] as any).click(); }); it('should be show if specify [config] param', () => { - service.show(Object.assign([], MENUS), Object.assign({}, CONFIG)); + service.show([...MENUS], { ...CONFIG }); fixture.detectChanges(); expect(el.nextSibling.nodeName).toBe('WEUI-ACTIONSHEET'); }); @@ -266,7 +218,9 @@ describe('Component: ActionSheet', () => { }); @Component({ - template: `

Test Service

`, + template: ` +

Test Service

+ `, }) class TestActionSheetServiceComponent {} @@ -277,9 +231,9 @@ class TestActionSheetServiceComponent {} class TestActionSheetComponent { @ViewChild(ActionSheetComponent) actioinSheet: ActionSheetComponent; - menus: any[] = Object.assign([], MENUS); + menus: any[] = [...MENUS]; - config: ActionSheetConfig = Object.assign({}, CONFIG); + config: ActionSheetConfig = { ...CONFIG }; _close() { return true; diff --git a/components/actionsheet/package.json b/components/actionsheet/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/actionsheet/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/button/button-icon.component.ts b/components/button/button-icon.component.ts new file mode 100644 index 0000000..4a7aa16 --- /dev/null +++ b/components/button/button-icon.component.ts @@ -0,0 +1,14 @@ +import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core'; + +@Component({ + selector: 'weui-button-icon, [weui-button-icon]', + exportAs: 'weuiButtonIcon', + host: { + '[class.weui-btn_cell__icon]': 'true', + }, + template: '', + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, +}) +export class ButtonIconComponent {} diff --git a/components/button/button.component.ts b/components/button/button.component.ts index 3415e3b..b6dae66 100644 --- a/components/button/button.component.ts +++ b/components/button/button.component.ts @@ -1,35 +1,28 @@ import { + ChangeDetectionStrategy, Component, - Directive, - EventEmitter, + ElementRef, Input, + OnChanges, OnInit, - Output, - HostBinding, + ViewEncapsulation, } from '@angular/core'; +import { ButtonType, InputBoolean, UpdateHostClassService } from 'ngx-weui/core'; import { ButtonConfig } from './button.config'; -import { ButtonType } from '../utils/types'; -import { toBoolean } from '../utils/boolean-property'; @Component({ - selector: 'weui-button, button[weui-button], a[weui-button]', + selector: 'weui-button, [weui-button]', + exportAs: 'weuiButton', host: { - class: 'weui-btn', - '[class.weui-btn_primary]': '!plain && type==="primary"', - '[class.weui-btn_default]': '!plain && type==="default"', - '[class.weui-btn_warn]': '!plain && type==="warn"', - '[class.weui-btn_plain-primary]': 'plain && type==="primary"', - '[class.weui-btn_plain-default]': 'plain && type==="default"', - '[class.weui-btn_plain-warn]': 'plain && type==="warn"', - '[class.weui-btn_disabled]': '!plain && disabled', - '[class.weui-btn_plain-disabled]': 'plain && disabled', '[attr.disabled]': 'disabled ? "disabled" : null', }, - exportAs: 'weuiButton', - template: - '' + template: '', + providers: [UpdateHostClassService], + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) -export class ButtonComponent { +export class ButtonComponent implements OnInit, OnChanges { /** * 操作场景:primary、default、warn,默认:`primary` */ @@ -38,54 +31,59 @@ export class ButtonComponent { /** * 是否加载状态 */ - @HostBinding('class.weui-btn_loading') - @Input('weui-loading') - get loading(): boolean { - return this._loading; - } - set loading(value) { - this._loading = toBoolean(value); - } - private _loading: boolean = false; + @Input('weui-loading') @InputBoolean() loading: boolean = false; /** * 是否小号 */ - @HostBinding('class.weui-btn_mini') - @Input('weui-mini') - get mini(): boolean { - return this._mini; - } - set mini(value) { - this._mini = toBoolean(value); - } - private _mini: boolean = false; + @Input('weui-mini') @InputBoolean() mini: boolean = false; /** * 镂空按钮 */ - @Input('weui-plain') - get plain(): boolean { - return this._plain; - } - set plain(value) { - this._plain = toBoolean(value); - } - private _plain: boolean = false; + @Input('weui-plain') @InputBoolean() plain: boolean = false; + + /** + * 行按钮 + */ + @Input('weui-cell') @InputBoolean() cell: boolean = false; + + /** + * Block 按钮 + */ + @Input('weui-block') @InputBoolean() block: boolean = false; /** * 禁用状态 */ - @Input() - get disabled(): boolean { - return this._disabled; + @Input() @InputBoolean() disabled: boolean = false; + + constructor(_config: ButtonConfig, private el: ElementRef, private uhcs: UpdateHostClassService) { + Object.assign(this, _config); } - set disabled(value) { - this._disabled = toBoolean(value); + + private setClassMap(): void { + const prefixCls = 'weui-btn'; + const { uhcs, el, type, plain, cell, disabled, block, mini, loading } = this; + const median = plain ? 'plain' : cell ? 'cell' : ''; + uhcs.updateHostClass(el.nativeElement, { + [`${prefixCls}`]: !cell, + [`${prefixCls}_cell`]: cell, + [`${prefixCls}_disabled`]: !plain && disabled, + [`${prefixCls}_block`]: block, + [`${prefixCls}_mini`]: mini, + [`${prefixCls}_${median}-${type}`]: median, + [`${prefixCls}_${type}`]: !median, + [`${prefixCls}_loading`]: loading, + [`${prefixCls}_plain-disabled`]: plain && disabled, + }); } - private _disabled: boolean = false; - constructor(_config: ButtonConfig) { - Object.assign(this, _config); + ngOnInit(): void { + this.setClassMap(); + } + + ngOnChanges(): void { + this.setClassMap(); } } diff --git a/components/button/button.config.ts b/components/button/button.config.ts index b0ed1f2..41f78a0 100644 --- a/components/button/button.config.ts +++ b/components/button/button.config.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; -import { ButtonType } from '../utils/types'; +import { ButtonType } from 'ngx-weui/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class ButtonConfig { /** * 操作场景:primary、default、warn diff --git a/components/button/button.module.ts b/components/button/button.module.ts index a3261cc..67ef215 100644 --- a/components/button/button.module.ts +++ b/components/button/button.module.ts @@ -1,16 +1,12 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; -import { ButtonConfig } from './button.config'; +import { ButtonIconComponent } from './button-icon.component'; import { ButtonComponent } from './button.component'; @NgModule({ imports: [CommonModule], - declarations: [ButtonComponent], - exports: [ButtonComponent], + declarations: [ButtonComponent, ButtonIconComponent], + exports: [ButtonComponent, ButtonIconComponent], }) -export class ButtonModule { - static forRoot(): ModuleWithProviders { - return { ngModule: ButtonModule, providers: [ButtonConfig] }; - } -} +export class ButtonModule {} diff --git a/components/button/button.spec.ts b/components/button/button.spec.ts index c00d151..019fb8d 100644 --- a/components/button/button.spec.ts +++ b/components/button/button.spec.ts @@ -1,14 +1,9 @@ import { Component } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - ComponentFixtureAutoDetect, -} from '@angular/core/testing'; +import { UpdateHostClassService } from 'ngx-weui/core'; -import { ButtonModule, ButtonConfig, ButtonComponent } from '../button'; +import { ButtonComponent, ButtonModule } from '../button'; const html = ` { let context: any; let el: any; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestButtonComponent], - imports: [ButtonModule.forRoot(), FormsModule], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], - }); - TestBed.overrideComponent(TestButtonComponent, { - set: { template: html }, - }); - fixture = TestBed.createComponent(TestButtonComponent); - context = fixture.debugElement.componentInstance; - el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestButtonComponent], + imports: [ButtonModule, FormsModule], + providers: [UpdateHostClassService, { provide: ComponentFixtureAutoDetect, useValue: true }], + }); + TestBed.overrideComponent(TestButtonComponent, { + set: { template: html }, + }); + fixture = TestBed.createComponent(TestButtonComponent); + context = fixture.debugElement.componentInstance; + el = fixture.nativeElement; + fixture.detectChanges(); + tick(); + })); describe('default', () => { - it( - 'should work weui-style', - fakeAsync(() => { - expect(el.querySelector('#default').classList).toContain('weui-btn'); - expect(el.querySelector('#default').classList).toContain( - 'weui-btn_primary', - ); - context.type = 'default'; - fixture.detectChanges(); - tick(); - expect(el.querySelector('#default').classList).toContain( - 'weui-btn_default', - ); - context.type = 'warn'; - fixture.detectChanges(); - tick(); - expect(el.querySelector('#default').classList).toContain( - 'weui-btn_warn', - ); - }), - ); + it('should work weui-style', fakeAsync(() => { + expect(el.querySelector('#default').classList).toContain('weui-btn'); + expect(el.querySelector('#default').classList).toContain('weui-btn_primary'); + context.type = 'default'; + fixture.detectChanges(); + tick(); + expect(el.querySelector('#default').classList).toContain('weui-btn_default'); + context.type = 'warn'; + fixture.detectChanges(); + tick(); + expect(el.querySelector('#default').classList).toContain('weui-btn_warn'); + })); - it( - 'should have class loading by loading=true', - fakeAsync(() => { - context.loading = true; - fixture.detectChanges(); - tick(); - expect(el.querySelector('#default').classList).toContain( - 'weui-btn_loading', - ); - expect(el.querySelector('.weui-loading')).not.toBeNull(); - }), - ); + it('should have class loading by loading=true', fakeAsync(() => { + context.loading = true; + fixture.detectChanges(); + tick(); + expect(el.querySelector('#default').classList).toContain('weui-btn_loading'); + expect(el.querySelector('.weui-loading')).not.toBeNull(); + })); - it( - 'should have class plain by plain=true', - fakeAsync(() => { - context.plain = true; - fixture.detectChanges(); - tick(); - expect(el.querySelector('#default').classList).toContain( - 'weui-btn_plain-primary', - ); - }), - ); + it('should have class plain by plain=true', fakeAsync(() => { + context.plain = true; + fixture.detectChanges(); + tick(); + expect(el.querySelector('#default').classList).toContain('weui-btn_plain-primary'); + })); - it( - 'should have class mini by mini=true', - fakeAsync(() => { - context.mini = true; - fixture.detectChanges(); - tick(); - expect(el.querySelector('#default').classList).toContain( - 'weui-btn_mini', - ); - }), - ); + it('should have class mini by mini=true', fakeAsync(() => { + context.mini = true; + fixture.detectChanges(); + tick(); + expect(el.querySelector('#default').classList).toContain('weui-btn_mini'); + })); - it( - 'should have class disabled by disabled=true', - fakeAsync(() => { - context.disabled = true; - fixture.detectChanges(); - tick(); - expect(el.querySelector('#default').classList).toContain( - 'weui-btn_disabled', - ); - }), - ); + it('should have class disabled by disabled=true', fakeAsync(() => { + context.disabled = true; + fixture.detectChanges(); + tick(); + expect(el.querySelector('#default').classList).toContain('weui-btn_disabled'); + })); }); }); @@ -125,7 +89,4 @@ class TestButtonComponent extends ButtonComponent { mini = false; plain = false; disabled = false; - constructor(config: ButtonConfig) { - super(config); - } } diff --git a/components/button/index.md b/components/button/index.md index bd74568..23bd7d6 100644 --- a/components/button/index.md +++ b/components/button/index.md @@ -14,5 +14,7 @@ module: ButtonModule weui-type | 操作场景 | `primary、default、warn` | `primary` weui-loading | 是否加载状态 | `boolean` | `false` weui-mini | 是否小号 | `boolean` | `false` +weui-cell | 行按钮 | `boolean` | `false` weui-plain | 镂空按钮 | `boolean` | `false` +weui-block | Block 按钮 | `boolean` | `false` disabled | 禁用状态 | `boolean` | `false` diff --git a/components/button/package.json b/components/button/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/button/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/button/public-api.ts b/components/button/public-api.ts index cdd49f6..770a148 100644 --- a/components/button/public-api.ts +++ b/components/button/public-api.ts @@ -1,3 +1,4 @@ export { ButtonComponent } from './button.component'; +export { ButtonIconComponent } from './button-icon.component'; export { ButtonModule } from './button.module'; export { ButtonConfig } from './button.config'; diff --git a/components/cell/cell.module.ts b/components/cell/cell.module.ts index 5d6608d..6c66b43 100644 --- a/components/cell/cell.module.ts +++ b/components/cell/cell.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { SwipeDirective } from './swipe.directive'; @NgModule({ @@ -7,8 +7,4 @@ import { SwipeDirective } from './swipe.directive'; declarations: [SwipeDirective], exports: [SwipeDirective], }) -export class CellModule { - static forRoot(): ModuleWithProviders { - return { ngModule: CellModule, providers: [] }; - } -} +export class CellModule {} diff --git a/components/cell/package.json b/components/cell/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/cell/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/cell/swipe.directive.spec.ts b/components/cell/swipe.directive.spec.ts index d5e4aed..82491d5 100644 --- a/components/cell/swipe.directive.spec.ts +++ b/components/cell/swipe.directive.spec.ts @@ -1,15 +1,9 @@ import { Component, DebugElement } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - ComponentFixtureAutoDetect, -} from '@angular/core/testing'; -import { CellModule, SwipeDirective } from '../cell'; import { By } from '@angular/platform-browser'; +import { CellModule, SwipeDirective } from '../cell'; const WIDTH = 68; const html = ` @@ -39,18 +33,11 @@ function spyPageX(val: number) { return { touches: [{ pageX: val }] }; } -function open( - directive: SwipeDirective, - el: any, - width: number, - shouldOpen: boolean, -) { +function open(directive: SwipeDirective, el: any, width: number, shouldOpen: boolean) { directive.onTouchStart(spyPageX(0)); directive.onTouchMove(spyPageX(-width)); fixture.detectChanges(); - expect(el.querySelector('.weui-cell__bd').style.transform).toBe( - `translateX(-${width}px)`, - ); + expect(el.querySelector('.weui-cell__bd').style.transform).toBe(`translateX(-${width}px)`); directive.onTouchEnd(spyPageX(-width)); fixture.detectChanges(); expect(el.querySelector('.weui-cell__bd').style.transform).toBe( @@ -60,60 +47,43 @@ function open( let fixture: ComponentFixture; describe('Directive: Swipe', () => { - let context: any; let el: any; - let dl: DebugElement; let directives: SwipeDirective[]; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestSwipeComponent], - imports: [CellModule.forRoot(), FormsModule], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], - }); - TestBed.overrideComponent(TestSwipeComponent, { - set: { template: html }, - }); - fixture = TestBed.createComponent(TestSwipeComponent); - context = fixture.componentInstance; - el = fixture.nativeElement; - dl = fixture.debugElement; - - const list = fixture.debugElement.queryAll(By.directive(SwipeDirective)); - directives = list.map( - (de: DebugElement) => de.injector.get(SwipeDirective) as SwipeDirective, - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestSwipeComponent], + imports: [CellModule, FormsModule], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], + }); + TestBed.overrideComponent(TestSwipeComponent, { + set: { template: html }, + }); + fixture = TestBed.createComponent(TestSwipeComponent); + el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); + const list = fixture.debugElement.queryAll(By.directive(SwipeDirective)); + directives = list.map((de: DebugElement) => de.injector.get(SwipeDirective)); - it( - 'should init', - fakeAsync(() => { - expect(directives.length).toBe(1); - expect(el.querySelector('.weui-cell__bd').style.transform).toBe( - 'translateX(0px)', - ); - }), - ); + fixture.detectChanges(); + tick(); + })); + + it('should init', fakeAsync(() => { + expect(directives.length).toBe(1); + expect(el.querySelector('.weui-cell__bd').style.transform).toBe('translateX(0px)'); + })); for (const moveWidth of [10, WIDTH - 10]) { const hasOpened = moveWidth > 10; - it(`should be ${ - hasOpened ? 'open' : 'close' - } by 0px to ${moveWidth}px in closed`, () => { + it(`should be ${hasOpened ? 'open' : 'close'} by 0px to ${moveWidth}px in closed`, () => { open(directives[0], el, moveWidth, hasOpened); }); } for (const moveWidth of [WIDTH - 10, 10]) { const hasOpened = moveWidth !== 10; - it(`should be ${ - hasOpened ? 'open' : 'close' - } by ${WIDTH}px to ${moveWidth}px in opened`, () => { + it(`should be ${hasOpened ? 'open' : 'close'} by ${WIDTH}px to ${moveWidth}px in opened`, () => { // 先强制打开状态 open(directives[0], el, WIDTH - 10, true); @@ -121,9 +91,7 @@ describe('Directive: Swipe', () => { directives[0].onTouchMove(spyPageX(-moveWidth)); directives[0].onTouchEnd(spyPageX(-moveWidth)); fixture.detectChanges(); - expect(el.querySelector('.weui-cell__bd').style.transform).toBe( - `translateX(${hasOpened ? '-' + WIDTH : '0'}px)`, - ); + expect(el.querySelector('.weui-cell__bd').style.transform).toBe(`translateX(${hasOpened ? '-' + WIDTH : '0'}px)`); }); } @@ -132,43 +100,34 @@ describe('Directive: Swipe', () => { directives[0].onTouchMove(spyPageX(0)); directives[0].onTouchEnd(spyPageX(0)); fixture.detectChanges(); - expect(el.querySelector('.weui-cell__bd').style.transform).toBe( - `translateX(0px)`, - ); + expect(el.querySelector('.weui-cell__bd').style.transform).toBe(`translateX(0px)`); }); }); describe('Directive: Swipe(not body)', () => { let directive: SwipeDirective[]; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestSwipeComponent], - imports: [CellModule.forRoot(), FormsModule], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], - }); - TestBed.overrideComponent(TestSwipeComponent, { - set: { template: htmlNotBody }, - }); - fixture = TestBed.createComponent(TestSwipeComponent); - const list = fixture.debugElement.queryAll(By.directive(SwipeDirective)); - directive = list.map( - (de: DebugElement) => de.injector.get(SwipeDirective) as SwipeDirective, - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestSwipeComponent], + imports: [CellModule, FormsModule], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], + }); + TestBed.overrideComponent(TestSwipeComponent, { + set: { template: htmlNotBody }, + }); + fixture = TestBed.createComponent(TestSwipeComponent); + const list = fixture.debugElement.queryAll(By.directive(SwipeDirective)); + directive = list.map((de: DebugElement) => de.injector.get(SwipeDirective)); - fixture.detectChanges(); - tick(); - }), - ); + fixture.detectChanges(); + tick(); + })); - it( - 'should init', - fakeAsync(() => { - expect(directive.length).toBe(1); - expect(directive[0].width).toBe(0); - }), - ); + it('should init', fakeAsync(() => { + expect(directive.length).toBe(1); + expect(directive[0].width).toBe(0); + })); }); @Component({ diff --git a/components/cell/swipe.directive.ts b/components/cell/swipe.directive.ts index d3b7e93..5b31481 100644 --- a/components/cell/swipe.directive.ts +++ b/components/cell/swipe.directive.ts @@ -1,19 +1,12 @@ -import { - Directive, - HostListener, - ElementRef, - HostBinding, - Input, - OnChanges, - SimpleChanges, - OnInit, -} from '@angular/core'; +import { Directive, ElementRef, HostListener, Input, OnInit } from '@angular/core'; +import { InputNumber } from 'ngx-weui/core'; /** * 单元格滑块 */ @Directive({ selector: '[weui-swipe]', + exportAs: 'weuiSwipe', }) export class SwipeDirective implements OnInit { private curX: number = 0; @@ -23,7 +16,7 @@ export class SwipeDirective implements OnInit { /** * 右边滑动宽度(单位:px),默认:`68` */ - @Input('weui-width') width: number = 68; + @Input('weui-width') @InputNumber() width: number = 68; constructor(private el: ElementRef) {} diff --git a/components/chart-g2/chart-g2.directive.ts b/components/chart-g2/chart-g2.directive.ts index f2dcefd..172f6ed 100644 --- a/components/chart-g2/chart-g2.directive.ts +++ b/components/chart-g2/chart-g2.directive.ts @@ -1,17 +1,8 @@ -import { - Directive, - OnInit, - OnDestroy, - ElementRef, - Input, - OnChanges, - SimpleChanges, - NgZone, -} from '@angular/core'; +import { Directive, ElementRef, Input, NgZone, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; declare const GM: any; -@Directive({ selector: 'canvas[weui-chart-g2]', exportAs: 'chart-g2' }) +@Directive({ selector: 'canvas[weui-chart-g2]', exportAs: 'weuiChartG2' }) export class ChartG2Directive implements OnInit, OnDestroy, OnChanges { _chart: any; @@ -55,7 +46,7 @@ export class ChartG2Directive implements OnInit, OnDestroy, OnChanges { ngOnChanges(changes: SimpleChanges): void { if (this.initFlag) { - if ('margin' in changes && !changes['margin'].firstChange) { + if ('margin' in changes && !changes.margin.firstChange) { this.buildChart(); } } diff --git a/components/chart-g2/chart-g2.module.ts b/components/chart-g2/chart-g2.module.ts index 7469e33..d977080 100644 --- a/components/chart-g2/chart-g2.module.ts +++ b/components/chart-g2/chart-g2.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { ChartG2Directive } from './chart-g2.directive'; @@ -8,8 +8,4 @@ import { ChartG2Directive } from './chart-g2.directive'; declarations: [ChartG2Directive], exports: [ChartG2Directive], }) -export class ChartG2Module { - static forRoot(): ModuleWithProviders { - return { ngModule: ChartG2Module, providers: [] }; - } -} +export class ChartG2Module {} diff --git a/components/chart-g2/chart-g2.spec.ts b/components/chart-g2/chart-g2.spec.ts index 2afa3f4..6f5704f 100644 --- a/components/chart-g2/chart-g2.spec.ts +++ b/components/chart-g2/chart-g2.spec.ts @@ -1,32 +1,23 @@ import { Component, ViewChild } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, -} from '@angular/core/testing'; -import { ChartG2Module, ChartG2Directive } from '../chart-g2'; +import { ChartG2Directive, ChartG2Module } from '../chart-g2'; describe('Component: ChartG2', () => { let fixture: ComponentFixture; let context: TestChartG2Component; - let el: HTMLElement; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestChartG2Component], - imports: [ChartG2Module.forRoot(), NoopAnimationsModule], - }); - fixture = TestBed.createComponent(TestChartG2Component); - context = fixture.componentInstance; - el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestChartG2Component], + imports: [ChartG2Module, NoopAnimationsModule], + }); + fixture = TestBed.createComponent(TestChartG2Component); + context = fixture.componentInstance; + fixture.detectChanges(); + tick(); + })); it('should be inited', () => { expect(context.c1.chart).not.toBeNull(); @@ -42,7 +33,9 @@ describe('Component: ChartG2', () => { }); @Component({ - template: ``, + template: ` + + `, }) class TestChartG2Component { margin = 0; diff --git a/components/chart-g2/index.md b/components/chart-g2/index.md index cff2b4a..e2a64d9 100644 --- a/components/chart-g2/index.md +++ b/components/chart-g2/index.md @@ -31,7 +31,7 @@ npm install g2-mobile --save-dev **使用示例:** ```html - + ``` ```typescript diff --git a/components/chart-g2/package.json b/components/chart-g2/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/chart-g2/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/core/addon/addon.module.ts b/components/core/addon/addon.module.ts new file mode 100644 index 0000000..cdb17cb --- /dev/null +++ b/components/core/addon/addon.module.ts @@ -0,0 +1,10 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { StringTemplateOutletDirective } from './string_template_outlet'; + +@NgModule({ + imports: [CommonModule], + exports: [StringTemplateOutletDirective], + declarations: [StringTemplateOutletDirective], +}) +export class AddOnModule {} diff --git a/components/core/addon/index.ts b/components/core/addon/index.ts new file mode 100644 index 0000000..7e1a213 --- /dev/null +++ b/components/core/addon/index.ts @@ -0,0 +1 @@ +export * from './public-api'; diff --git a/components/core/addon/public-api.ts b/components/core/addon/public-api.ts new file mode 100644 index 0000000..9cfd8d2 --- /dev/null +++ b/components/core/addon/public-api.ts @@ -0,0 +1,2 @@ +export { AddOnModule } from './addon.module'; +export { StringTemplateOutletDirective } from './string_template_outlet'; diff --git a/components/core/addon/string_template_outlet.ts b/components/core/addon/string_template_outlet.ts new file mode 100644 index 0000000..3a7649f --- /dev/null +++ b/components/core/addon/string_template_outlet.ts @@ -0,0 +1,47 @@ +import { Directive, EmbeddedViewRef, Input, TemplateRef, ViewContainerRef } from '@angular/core'; + +@Directive({ + selector: '[stringTemplateOutlet]', + exportAs: 'stringTemplateOutlet', +}) +export class StringTemplateOutletDirective { + private isTemplate: boolean; + private inputTemplate: TemplateRef | null = null; + private inputViewRef: EmbeddedViewRef | null = null; + private defaultViewRef: EmbeddedViewRef | null = null; + + constructor(private viewContainer: ViewContainerRef, private defaultTemplate: TemplateRef) {} + + @Input() + set stringTemplateOutlet(value: string | TemplateRef) { + if (value instanceof TemplateRef) { + this.isTemplate = true; + this.inputTemplate = value; + } else { + this.isTemplate = false; + } + this.updateView(); + } + + updateView(): void { + if (!this.isTemplate) { + /** use default template when input is string **/ + if (!this.defaultViewRef) { + this.viewContainer.clear(); + this.inputViewRef = null; + if (this.defaultTemplate) { + this.defaultViewRef = this.viewContainer.createEmbeddedView(this.defaultTemplate); + } + } + } else { + /** use input template when input is templateRef **/ + if (!this.inputViewRef) { + this.viewContainer.clear(); + this.defaultViewRef = null; + if (this.inputTemplate) { + this.inputViewRef = this.viewContainer.createEmbeddedView(this.inputTemplate); + } + } + } + } +} diff --git a/components/core/index.ts b/components/core/index.ts new file mode 100644 index 0000000..7e1a213 --- /dev/null +++ b/components/core/index.ts @@ -0,0 +1 @@ +export * from './public-api'; diff --git a/components/core/package.json b/components/core/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/core/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/core/public-api.ts b/components/core/public-api.ts new file mode 100644 index 0000000..f30c29e --- /dev/null +++ b/components/core/public-api.ts @@ -0,0 +1,3 @@ +export * from './utils/public-api'; +export * from './addon/public-api'; +export * from './services/public-api'; diff --git a/components/core/services/index.ts b/components/core/services/index.ts new file mode 100644 index 0000000..7e1a213 --- /dev/null +++ b/components/core/services/index.ts @@ -0,0 +1 @@ +export * from './public-api'; diff --git a/components/core/services/public-api.ts b/components/core/services/public-api.ts new file mode 100644 index 0000000..cf66607 --- /dev/null +++ b/components/core/services/public-api.ts @@ -0,0 +1 @@ +export * from './update-host-class.service'; diff --git a/components/core/services/update-host-class.service.ts b/components/core/services/update-host-class.service.ts new file mode 100644 index 0000000..18018a6 --- /dev/null +++ b/components/core/services/update-host-class.service.ts @@ -0,0 +1,33 @@ +import { Injectable, Renderer2, RendererFactory2 } from '@angular/core'; + +@Injectable() +export class UpdateHostClassService { + private classMap = {}; + private renderer: Renderer2; + + updateHostClass(el: HTMLElement, classMap: object): void { + this.removeClass(el, this.classMap, this.renderer); + this.classMap = { ...classMap }; + this.addClass(el, this.classMap, this.renderer); + } + + private removeClass(el: HTMLElement, classMap: {}, renderer: Renderer2): void { + for (const i in classMap) { + if (classMap.hasOwnProperty(i)) { + renderer.removeClass(el, i); + } + } + } + + private addClass(el: HTMLElement, classMap: {}, renderer: Renderer2): void { + for (const i in classMap) { + if (classMap.hasOwnProperty(i) && classMap[i]) { + renderer.addClass(el, i); + } + } + } + + constructor(rendererFactory2: RendererFactory2) { + this.renderer = rendererFactory2.createRenderer(null, null); + } +} diff --git a/components/utils/base.service.ts b/components/core/utils/base.service.ts similarity index 80% rename from components/utils/base.service.ts rename to components/core/utils/base.service.ts index 9344f01..70eb0ef 100644 --- a/components/utils/base.service.ts +++ b/components/core/utils/base.service.ts @@ -1,12 +1,12 @@ +import { DOCUMENT } from '@angular/common'; import { - ComponentRef, - ComponentFactoryResolver, ApplicationRef, - Injector, + ComponentFactoryResolver, + ComponentRef, EmbeddedViewRef, Inject, + Injector, } from '@angular/core'; -import { DOCUMENT } from '@angular/common'; export abstract class BaseService { constructor( @@ -16,7 +16,7 @@ export abstract class BaseService { @Inject(DOCUMENT) private doc: any, ) {} - protected list: ComponentRef[] = []; + protected list: Array> = []; /** * 销毁 @@ -24,9 +24,9 @@ export abstract class BaseService { * @param component 下标(从0开始或组件引用对象),或不指定时,销毁最新一个 */ destroy(component?: number | ComponentRef) { - if (typeof component === 'number') component = this.list[component]; + if (typeof component === 'number') component = this.list[component as number]; if (!component) component = this.list.pop(); - if (component) (>component).destroy(); + if (component) (component as ComponentRef).destroy(); } /** @@ -37,12 +37,11 @@ export abstract class BaseService { } /** 动态构建组件 */ - protected build(component: { new (...args: any[]): T }): ComponentRef { + protected build(component: new (...args: any[]) => T): ComponentRef { const componentFactory = this.resolver.resolveComponentFactory(component); const componentRef = componentFactory.create(this.injector); this.list.push(componentRef); - const componentRootNode = (componentRef.hostView as EmbeddedViewRef) - .rootNodes[0] as HTMLElement; + const componentRootNode = (componentRef.hostView as EmbeddedViewRef).rootNodes[0] as HTMLElement; this.applicationRef.attachView(componentRef.hostView); componentRef.onDestroy(() => { this.applicationRef.detachView(componentRef.hostView); diff --git a/components/utils/browser.ts b/components/core/utils/browser.ts similarity index 90% rename from components/utils/browser.ts rename to components/core/utils/browser.ts index 17c4e9e..4ef3cd2 100644 --- a/components/utils/browser.ts +++ b/components/core/utils/browser.ts @@ -25,7 +25,7 @@ export function isIOS(): boolean { */ export function isImage(file: File) { if (!(file instanceof window.File)) return false; - const type = '|' + file.type.slice(file.type.lastIndexOf('/') + 1) + '|'; + const type = `|${file.type.slice(file.type.lastIndexOf('/') + 1)}|`; return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1; } diff --git a/components/core/utils/check.spec.ts b/components/core/utils/check.spec.ts new file mode 100644 index 0000000..566bb13 --- /dev/null +++ b/components/core/utils/check.spec.ts @@ -0,0 +1,157 @@ +import { isEmpty, toBoolean, toNumber, InputBoolean, InputNumber } from './check'; + +describe('#isEmpty', () => { + it('should empty when only spaces', () => { + const mockEl: any = { + childNodes: { + length: 1, + item: () => { + return { + nodeType: 3, + textContent: ' ', + }; + }, + }, + }; + expect(isEmpty(mockEl)).toBe(true); + }); + it('should not empty when has text', () => { + const mockEl: any = { + childNodes: { + length: 1, + item: () => { + return { + nodeType: 3, + textContent: '1 ', + }; + }, + }, + }; + expect(isEmpty(mockEl)).toBe(false); + }); +}); + +describe('#toBoolean', () => { + [ + { value: undefined, ret: undefined, au: true }, + { value: undefined, ret: false }, + { value: null, ret: false }, + { value: '', ret: true }, + { value: 0, ret: true }, + { value: 'false', ret: false }, + { value: false, ret: false }, + { value: true, ret: true }, + { value: 'true', ret: true }, + { value: 'pink', ret: true }, + { value: {}, ret: true }, + { value: [], ret: true }, + ].forEach(item => { + const au = typeof item.au !== 'undefined'; + it(`should coerce [${JSON.stringify(item.value)}] to [${JSON.stringify(item.ret)}]${ + au ? ', because allow undefined' : '' + }`, () => { + if (au) { + expect(toBoolean(item.value, item.au)).toBe(item.ret); + } else { + expect(toBoolean(item.value)).toBe(item.ret); + } + }); + }); +}); + +describe('#InputBoolean', () => { + it('should be warn when already exist', () => { + spyOn(console, 'warn'); + const target = {}; + InputBoolean()(target, 'a'); + InputBoolean()(target, 'a'); + expect(console.warn).toHaveBeenCalled(); + }); +}); + +describe('toNumber', () => { + it('should coerce undefined to 0 or default', () => { + expect(toNumber(undefined)).toBe(0); + expect(toNumber(undefined, 111)).toBe(111); + }); + + it('should coerce null to 0 or default', () => { + expect(toNumber(null)).toBe(0); + expect(toNumber(null, 111)).toBe(111); + }); + + it('should coerce true to 0 or default', () => { + expect(toNumber(true)).toBe(0); + expect(toNumber(true, 111)).toBe(111); + }); + + it('should coerce false to 0 or default', () => { + expect(toNumber(false)).toBe(0); + expect(toNumber(false, 111)).toBe(111); + }); + + it('should coerce the empty string to 0 or default', () => { + expect(toNumber('')).toBe(0); + expect(toNumber('', 111)).toBe(111); + }); + + it('should coerce the string "1" to 1', () => { + expect(toNumber('1')).toBe(1); + expect(toNumber('1', 111)).toBe(1); + }); + + it('should coerce the string "123.456" to 123.456', () => { + expect(toNumber('123.456')).toBe(123.456); + expect(toNumber('123.456', 111)).toBe(123.456); + }); + + it('should coerce the string "-123.456" to -123.456', () => { + expect(toNumber('-123.456')).toBe(-123.456); + expect(toNumber('-123.456', 111)).toBe(-123.456); + }); + + it('should coerce an arbitrary string to 0 or default', () => { + expect(toNumber('pink')).toBe(0); + expect(toNumber('pink', 111)).toBe(111); + }); + + it('should coerce an arbitrary string prefixed with a number to 0 or default', () => { + expect(toNumber('123pink')).toBe(0); + expect(toNumber('123pink', 111)).toBe(111); + }); + + it('should coerce the number 1 to 1', () => { + expect(toNumber(1)).toBe(1); + expect(toNumber(1, 111)).toBe(1); + }); + + it('should coerce the number 123.456 to 123.456', () => { + expect(toNumber(123.456)).toBe(123.456); + expect(toNumber(123.456, 111)).toBe(123.456); + }); + + it('should coerce the number -123.456 to -123.456', () => { + expect(toNumber(-123.456)).toBe(-123.456); + expect(toNumber(-123.456, 111)).toBe(-123.456); + }); + + it('should coerce an object to 0 or default', () => { + expect(toNumber({})).toBe(0); + expect(toNumber({}, 111)).toBe(111); + }); + + it('should coerce an array to 0 or default', () => { + expect(toNumber([])).toBe(0); + expect(toNumber([], 111)).toBe(111); + }); +}); + +describe('#InputNumber', () => { + it('should be warn when already exist', () => { + spyOn(console, 'warn'); + const target = {}; + InputNumber()(target, 'a'); + InputNumber()(target, 'a'); + expect(console.warn).toHaveBeenCalled(); + }); +}); diff --git a/components/core/utils/check.ts b/components/core/utils/check.ts new file mode 100644 index 0000000..116bada --- /dev/null +++ b/components/core/utils/check.ts @@ -0,0 +1,88 @@ +export function isEmpty(element: HTMLElement): boolean { + const nodes = element.childNodes; + for (let i = 0; i < nodes.length; i++) { + const node = nodes.item(i); + if (node.nodeType === 1 && (node as HTMLElement).outerHTML.toString().trim().length !== 0) { + return false; + } else if (node.nodeType === 3 && node.textContent!.toString().trim().length !== 0) { + return false; + } + } + return true; +} + +export function toBoolean(value: any, allowUndefined: boolean | null = false): boolean | undefined { + return allowUndefined && typeof value === 'undefined' ? undefined : value != null && `${value}` !== 'false'; +} + +/** + * Input decorator that handle a prop to do get/set automatically with toBoolean + * @example + * ```typescript + * @Input() @InputBoolean() visible: boolean = false; + * @Input() @InputBoolean(null) visible: boolean = false; + * ``` + */ +export function InputBoolean(allowUndefined: boolean | null = false): any { + return function InputBooleanPropDecorator(target: object, name: string): void { + // Add our own private prop + const privatePropName = `$$__${name}`; + + if (Object.prototype.hasOwnProperty.call(target, privatePropName)) { + console.warn(`The prop "${privatePropName}" is already exist, it will be overrided by InputBoolean decorator.`); + } + + Object.defineProperty(target, privatePropName, { + configurable: true, + writable: true, + }); + + Object.defineProperty(target, name, { + get(): boolean { + return this[privatePropName]; // tslint:disable-line:no-invalid-this + }, + set(value: any): void { + this[privatePropName] = toBoolean(value, allowUndefined); // tslint:disable-line:no-invalid-this + }, + }); + }; +} + +export function toNumber(value: any): number; +export function toNumber(value: any, fallback: D): number | D; +export function toNumber(value: any, fallbackValue: number = 0): number { + return !isNaN(parseFloat(value as any)) && !isNaN(Number(value)) ? Number(value) : fallbackValue; +} + +/** + * Input decorator that handle a prop to do get/set automatically with toNumber + * @example + * ```typescript + * @Input() @InputNumber() visible: number = 1; + * @Input() @InputNumber(null) visible: number = 2; + * ``` + */ +export function InputNumber(fallback: number | null = 0): any { + return function InputBooleanPropDecorator(target: object, name: string): void { + // Add our own private prop + const privatePropName = `$$__${name}`; + + if (Object.prototype.hasOwnProperty.call(target, privatePropName)) { + console.warn(`The prop "${privatePropName}" is already exist, it will be overrided by InputNumber decorator.`); + } + + Object.defineProperty(target, privatePropName, { + configurable: true, + writable: true, + }); + + Object.defineProperty(target, name, { + get(): boolean { + return this[privatePropName]; // tslint:disable-line:no-invalid-this + }, + set(value: any): void { + this[privatePropName] = toNumber(value, fallback); // tslint:disable-line:no-invalid-this + }, + }); + }; +} diff --git a/components/utils/dom.ts b/components/core/utils/dom.ts similarity index 97% rename from components/utils/dom.ts rename to components/core/utils/dom.ts index 46194df..652e9d3 100644 --- a/components/utils/dom.ts +++ b/components/core/utils/dom.ts @@ -37,6 +37,7 @@ export function add( * 移除 */ export function remove(el: any, selector: string) { + if (!el) return; const ret = el.querySelector(selector); if (ret) { el.removeChild(ret); diff --git a/components/core/utils/index.ts b/components/core/utils/index.ts new file mode 100644 index 0000000..7e1a213 --- /dev/null +++ b/components/core/utils/index.ts @@ -0,0 +1 @@ +export * from './public-api'; diff --git a/components/core/utils/loader.service.spec.ts b/components/core/utils/loader.service.spec.ts new file mode 100644 index 0000000..3239925 --- /dev/null +++ b/components/core/utils/loader.service.spec.ts @@ -0,0 +1,39 @@ +import { LoaderService } from './loader.service'; + +class MockDocument { + createElement = jasmine.createSpy('Document createElement').and.returnValue({}); + getElementsByTagName = jasmine.createSpy('Document getElementsByTagName'); +} + +describe('LoaderService', () => { + let service: LoaderService; + let doc: MockDocument; + + beforeEach(() => { + doc = new MockDocument(); + service = new LoaderService(doc); + }); + + it('should create script tag', () => { + const JSURL = 'http://test.com/1.js'; + service.load([JSURL]); + expect(doc.createElement).toHaveBeenCalled(); + expect(doc.getElementsByTagName).toHaveBeenCalled(); + }); + + it('should create link tag', () => { + const CSSURL = 'http://test.com/1.css'; + service.load(CSSURL); + expect(doc.createElement).toHaveBeenCalled(); + expect(doc.getElementsByTagName).toHaveBeenCalled(); + }); + + it('should at once if create exists', () => { + const JSURL = 'http://test.com/1.js'; + const CSSURL = 'http://test.com/1.css'; + service.load([JSURL, CSSURL]); + service.load([JSURL, CSSURL]); + expect(doc.createElement).toHaveBeenCalled(); + expect(doc.getElementsByTagName).toHaveBeenCalled(); + }); +}); diff --git a/components/utils/loader.service.ts b/components/core/utils/loader.service.ts similarity index 64% rename from components/utils/loader.service.ts rename to components/core/utils/loader.service.ts index 62b4774..c89f06b 100644 --- a/components/utils/loader.service.ts +++ b/components/core/utils/loader.service.ts @@ -1,20 +1,19 @@ -import { Injectable, Inject } from '@angular/core'; -import { DOCUMENT } from '@angular/platform-browser'; -import { Subject } from 'rxjs'; +import { DOCUMENT } from '@angular/common'; +import { Inject, Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class LoaderService { private list: any = {}; constructor(@Inject(DOCUMENT) private doc: any) {} load(paths: string | string[]): Promise { - return new Promise((resolve, reject) => { - const promises: Promise[] = []; + return new Promise(resolve => { + const promises: Array> = []; if (!Array.isArray(paths)) paths = [paths]; - (paths).forEach(path => { + (paths as string[]).forEach(path => { if (path.endsWith('.css')) { promises.push(this.loadCss(path)); } else { @@ -23,23 +22,19 @@ export class LoaderService { }); Promise.all(promises) - .then(res => { - resolve(true); - }) - .catch(err => { - resolve(false); - }); + .then(() => resolve(true)) + .catch(() => resolve(false)); }); } loadScript(path: string): Promise { - return new Promise((resolve, reject) => { + return new Promise(resolve => { if (this.list[path] === true) { - resolve({ - path: path, + resolve({ + path, loaded: true, status: 'Loaded', - }); + } as any); return; } @@ -51,30 +46,30 @@ export class LoaderService { node.charset = 'utf-8'; node.defer = true; node.onload = () => { - resolve({ - path: path, + resolve({ + path, loaded: true, status: 'Loaded', - }); + } as any); }; - node.onerror = (error: any) => - resolve({ - path: path, + node.onerror = () => + resolve({ + path, loaded: false, status: 'Loaded', - }); + } as any); this.doc.getElementsByTagName('head')[0].appendChild(node); }); } loadCss(path: string): Promise { - return new Promise((resolve, reject) => { + return new Promise(resolve => { if (this.list[path] === true) { - resolve({ - path: path, + resolve({ + path, loaded: true, status: 'Loaded', - }); + } as any); return; } @@ -85,11 +80,11 @@ export class LoaderService { node.type = 'text/css'; node.href = path; this.doc.getElementsByTagName('head')[0].appendChild(node); - resolve({ - path: path, + resolve({ + path, loaded: true, status: 'Loaded', - }); + } as any); }); } } diff --git a/components/core/utils/public-api.ts b/components/core/utils/public-api.ts new file mode 100644 index 0000000..1fe2a79 --- /dev/null +++ b/components/core/utils/public-api.ts @@ -0,0 +1,6 @@ +export * from './loader.service'; +export * from './types'; +export * from './base.service'; +export * from './dom'; +export * from './browser'; +export * from './check'; diff --git a/components/utils/types.ts b/components/core/utils/types.ts similarity index 100% rename from components/utils/types.ts rename to components/core/utils/types.ts diff --git a/components/dialog/dialog.component.html b/components/dialog/dialog.component.html index 6a36d95..1cb4655 100644 --- a/components/dialog/dialog.component.html +++ b/components/dialog/dialog.component.html @@ -1,32 +1,53 @@ -
-
+
+
- {{config.title}} + {{ config.title }}
-
+
- +
@@ -34,28 +55,51 @@
-
+
-
{{_promptData}}
+
{{ _promptData }}
-
+
- +
@@ -63,8 +107,14 @@
-
{{config.inputError}}
+
{{ config.inputError }}
diff --git a/components/dialog/dialog.component.ts b/components/dialog/dialog.component.ts index 1a47010..53de4e8 100644 --- a/components/dialog/dialog.component.ts +++ b/components/dialog/dialog.component.ts @@ -1,14 +1,17 @@ import { + ChangeDetectionStrategy, + ChangeDetectorRef, Component, - OnDestroy, + EventEmitter, Input, + OnDestroy, Output, - EventEmitter, ViewChild, + ViewEncapsulation, } from '@angular/core'; import { Observable, Observer, Subscription } from 'rxjs'; -import { isAndroid } from '../utils/browser'; +import { isAndroid } from 'ngx-weui/core'; import { DialogConfig } from './dialog.config'; /** @@ -20,22 +23,27 @@ import { DialogConfig } from './dialog.config'; */ @Component({ selector: 'weui-dialog', + exportAs: 'weuiDialog', templateUrl: './dialog.component.html', + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class DialogComponent implements OnDestroy { private _config: DialogConfig; + private observer: Observer; + _shown: boolean = false; + /** * 对话框配置项 */ @Input() set config(value: DialogConfig) { - const config = Object.assign( - { - backdrop: false, - }, - this.DEF, - value, - ); + const config = { + backdrop: false, + ...this.DEF, + ...value, + }; if (config.skin === 'auto') { config.skin = isAndroid() ? 'android' : 'ios'; @@ -46,14 +54,14 @@ export class DialogComponent implements OnDestroy { if (config.cancel) { config.btns.push({ text: config.cancel, - type: config.cancelType, + type: config.cancelType!, value: false, }); } if (config.confirm) { config.btns.push({ text: config.confirm, - type: config.confirmType, + type: config.confirmType!, value: true, }); } @@ -75,21 +83,18 @@ export class DialogComponent implements OnDestroy { } } - config.inputOptions = Object.assign([], config.inputOptions); - config.inputAttributes = Object.assign( - { - maxlength: null, - min: 0, - max: 100, - step: 1, - }, - config.inputAttributes, - ); + config.inputOptions = (config.inputOptions || [])!.slice(0); + config.inputAttributes = { + maxlength: null, + min: 0, + max: 100, + step: 1, + ...config.inputAttributes, + }; // 默认值 let defaultValue = config.inputValue; if (config.input === 'checkbox' && !Array.isArray(config.inputValue)) { - defaultValue = - typeof defaultValue !== 'undefined' ? [defaultValue] : []; + defaultValue = typeof defaultValue !== 'undefined' ? [defaultValue] : []; } config.inputValue = defaultValue || ''; @@ -113,18 +118,14 @@ export class DialogComponent implements OnDestroy { /** * 打开动画结束后回调(唯一参数:对话框实例对象) */ - @Output() open = new EventEmitter(); + @Output() readonly open = new EventEmitter(); /** * 关闭动画开始时回调(唯一参数:对话框实例对象) */ - @Output() close = new EventEmitter(); - - private observer: Observer; - - _shown: boolean = false; + @Output() readonly close = new EventEmitter(); - constructor(private DEF: DialogConfig) { } + constructor(private DEF: DialogConfig, private cdr: ChangeDetectorRef) {} @ViewChild('container') container: any; _prompError: boolean = false; @@ -142,10 +143,7 @@ export class DialogComponent implements OnDestroy { } } - if ( - this.config.inputRegex && - !this.config.inputRegex.test(this._promptData.toString()) - ) { + if (this.config.inputRegex && !this.config.inputRegex.test(this._promptData.toString())) { this._prompError = true; return false; } @@ -170,6 +168,7 @@ export class DialogComponent implements OnDestroy { } _keyup(event: KeyboardEvent) { + // tslint:disable-next-line: deprecation if (event.keyCode === 13) { this._onSelect(); } @@ -183,6 +182,7 @@ export class DialogComponent implements OnDestroy { show(): Observable { this._shown = true; this._prompError = false; + this.cdr.detectChanges(); // 模拟动画结束后回调 setTimeout(() => { this.open.emit(this); @@ -201,13 +201,14 @@ export class DialogComponent implements OnDestroy { if (is_backdrop === true && this.config.backdrop === false) return false; this._shown = false; + this.cdr.detectChanges(); this.close.emit(this); } _onSelect(menu?: any) { // 未指定时查找 `value===true` 的按钮 - if (!menu && this.config.btns.length > 0) { - menu = this.config.btns.find(w => w.value === true); + if (!menu && this.config.btns!.length > 0) { + menu = this.config.btns!.find(w => w.value === true); } const ret = menu; if (menu.value === true && this._config.type === 'prompt') { @@ -222,7 +223,7 @@ export class DialogComponent implements OnDestroy { ngOnDestroy(): void { if (this.observer && this.observer instanceof Subscription) { - (this.observer).unsubscribe(); + (this.observer as Subscription).unsubscribe(); } } } diff --git a/components/dialog/dialog.config.ts b/components/dialog/dialog.config.ts index 41ae362..6fe5bed 100644 --- a/components/dialog/dialog.config.ts +++ b/components/dialog/dialog.config.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; -import { SkinType, ButtonType, InputType, InputData } from '../utils/types'; +import { ButtonType, InputData, InputType, SkinType } from 'ngx-weui/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class DialogConfig { /** * 对话框类型,默认:`default` @@ -84,12 +84,12 @@ export class DialogConfig { /** * 自定义按钮组,当此属性存在时 `cancel` & `confirm` 参数将失效 */ - btns?: { + btns?: Array<{ text: string; type: ButtonType; value: boolean | any; [key: string]: any; - }[]; + }>; /** * 允许点击背景关闭,默认:`false` diff --git a/components/dialog/dialog.module.ts b/components/dialog/dialog.module.ts index 077e9bf..898073b 100644 --- a/components/dialog/dialog.module.ts +++ b/components/dialog/dialog.module.ts @@ -1,12 +1,12 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; -import { FormModule } from './../form/form.module'; -import { SliderModule } from './../slider/slider.module'; -import { MaskModule } from './../mask/mask.module'; +import { FormModule } from 'ngx-weui/form'; +import { MaskModule } from 'ngx-weui/mask'; +import { SliderModule } from 'ngx-weui/slider'; + import { DialogComponent } from './dialog.component'; import { DialogService } from './dialog.service'; -import { DialogConfig } from './dialog.config'; @NgModule({ imports: [CommonModule, FormsModule, MaskModule, FormModule, SliderModule], @@ -15,8 +15,4 @@ import { DialogConfig } from './dialog.config'; providers: [DialogService], entryComponents: [DialogComponent], }) -export class DialogModule { - static forRoot(): ModuleWithProviders { - return { ngModule: DialogModule, providers: [DialogConfig] }; - } -} +export class DialogModule {} diff --git a/components/dialog/dialog.service.ts b/components/dialog/dialog.service.ts index 73bb20d..1803f2e 100644 --- a/components/dialog/dialog.service.ts +++ b/components/dialog/dialog.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; +import { BaseService } from 'ngx-weui/core'; import { Observable } from 'rxjs'; -import { BaseService } from '../utils/base.service'; import { DialogComponent } from './dialog.component'; import { DialogConfig } from './dialog.config'; @@ -17,9 +17,7 @@ export class DialogService extends BaseService { componentRef.instance.config = data; componentRef.instance.close.subscribe(() => { - setTimeout(() => { - this.destroy(componentRef); - }, 300); + setTimeout(() => this.destroy(componentRef), 300); }); return componentRef.instance.show(); } diff --git a/components/dialog/dialog.spec.ts b/components/dialog/dialog.spec.ts index faafd32..21d9d2b 100644 --- a/components/dialog/dialog.spec.ts +++ b/components/dialog/dialog.spec.ts @@ -1,27 +1,13 @@ -import { Subscription } from 'rxjs'; -import { Component, ViewChild, DebugElement } from '@angular/core'; +import { Component, DebugElement, ViewChild } from '@angular/core'; +import { fakeAsync, inject, tick, ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - ComponentFixtureAutoDetect, - async, - inject, -} from '@angular/core/testing'; import { By } from '@angular/platform-browser'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - DialogModule, - DialogComponent, - DialogConfig, - DialogService, -} from '../dialog'; -import { isAndroid } from '../utils/browser'; +import { isAndroid } from 'ngx-weui/core'; +import { DialogComponent, DialogConfig, DialogModule, DialogService } from '../dialog'; -const CONFIG: DialogConfig = { +const CONFIG: DialogConfig = { title: 'title', content: 'content', skin: 'ios', @@ -30,7 +16,7 @@ const CONFIG: DialogConfig = { confirm: 'Confirm', confirmType: 'primary', backdrop: false, -}; +} as DialogConfig; const BTNS: any[] = [ { text: '否', type: 'default', value: 1 }, @@ -39,11 +25,11 @@ const BTNS: any[] = [ ]; function getTitle(nativeEl: HTMLElement): Element { - return nativeEl.querySelector('.weui-dialog__title'); + return nativeEl.querySelector('.weui-dialog__title')!; } function getContent(nativeEl: HTMLElement): Element { - return nativeEl.querySelector('.weui-dialog__bd'); + return nativeEl.querySelector('.weui-dialog__bd')!; } function getActions(nativeEl: HTMLElement): NodeListOf { @@ -51,7 +37,7 @@ function getActions(nativeEl: HTMLElement): NodeListOf { } function getCog(cog: any) { - return Object.assign({}, CONFIG, cog); + return { ...CONFIG, ...cog }; } describe('Component: Dialog', () => { @@ -65,41 +51,37 @@ describe('Component: Dialog', () => { `; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestDialogComponent], - imports: [DialogModule.forRoot(), FormsModule, NoopAnimationsModule], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], - }); - TestBed.overrideComponent(TestDialogComponent, { - set: { template: html }, - }); - fixture = TestBed.createComponent(TestDialogComponent); - context = fixture.componentInstance; - dl = fixture.debugElement; - el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestDialogComponent], + imports: [DialogModule, FormsModule, NoopAnimationsModule], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], + }); + TestBed.overrideComponent(TestDialogComponent, { + set: { template: html }, + }); + fixture = TestBed.createComponent(TestDialogComponent); + context = fixture.componentInstance; + dl = fixture.debugElement; + el = fixture.nativeElement; + fixture.detectChanges(); + tick(); + })); it('should init', () => { context.dialog.show(); fixture.detectChanges(); - expect(getTitle(el).textContent).toBe(CONFIG.title); - expect(getContent(el).textContent).toBe(CONFIG.content); + expect(getTitle(el).textContent).toBe(CONFIG.title!); + expect(getContent(el).textContent).toBe(CONFIG.content!); expect(getActions(el).length).toBe(2); }); it('should auto style', () => { - context.config = Object.assign({}, context.config, { skin: 'auto' }); + context.config = { ...context.config, skin: 'auto' }; context.dialog.show(); fixture.detectChanges(); if (isAndroid()) { - expect( - (el as HTMLElement).querySelectorAll('.weui-skin_android').length, - ).toBe(1); + expect((el as HTMLElement).querySelectorAll('.weui-skin_android').length).toBe(1); } else { expect(true).toBeTruthy(); } @@ -108,13 +90,13 @@ describe('Component: Dialog', () => { it('should be opened set dialog title', () => { context.dialog.show(); fixture.detectChanges(); - expect(getTitle(el).textContent).toBe(CONFIG.title); + expect(getTitle(el).textContent).toBe(CONFIG.title!); }); it('should be opened set dialog content', () => { context.dialog.show(); fixture.detectChanges(); - expect(getContent(el).textContent).toBe(CONFIG.content); + expect(getContent(el).textContent).toBe(CONFIG.content!); }); it('should be opened set dialog android style', () => { @@ -127,12 +109,8 @@ describe('Component: Dialog', () => { it('should be opened set dialog action items', () => { context.dialog.show(); fixture.detectChanges(); - expect( - dl.query(By.css('.weui-dialog__btn_' + CONFIG.cancelType)), - ).not.toBeNull(); - expect( - dl.query(By.css('.weui-dialog__btn_' + CONFIG.confirmType)), - ).not.toBeNull(); + expect(dl.query(By.css('.weui-dialog__btn_' + CONFIG.cancelType))).not.toBeNull(); + expect(dl.query(By.css('.weui-dialog__btn_' + CONFIG.confirmType))).not.toBeNull(); }); it('should be opened set dialog three action items', () => { @@ -144,25 +122,25 @@ describe('Component: Dialog', () => { expect(dl.query(By.css('.weui-dialog__btn_primary'))).not.toBeNull(); }); - it('should close a dialog and get back a value [false] result', (done: () => void) => { + it('should close a dialog and get back a value [false] result', done => { context.dialog.show().subscribe(res => { expect(res.value).toBeFalsy(); done(); }); fixture.detectChanges(); - (getActions(el)[0]).click(); + (getActions(el)[0] as any).click(); }); - it('should close a dialog and get back a value [true] result', (done: () => void) => { + it('should close a dialog and get back a value [true] result', done => { context.dialog.show().subscribe(res => { expect(res.value).toBeTruthy(); done(); }); fixture.detectChanges(); - (getActions(el)[1]).click(); + (getActions(el)[1] as any).click(); }); - it('should close a dialog by click mask', (done: () => void) => { + it('should close a dialog by click mask', done => { context.config = getCog({ backdrop: true }); context.dialog.show(); fixture.detectChanges(); @@ -174,7 +152,7 @@ describe('Component: Dialog', () => { }); it('should click backdrop not-allow closing', () => { - context.config = Object.assign(context.config, { backdrop: false }); + context.config = { ...context.config, backdrop: false }; context.dialog.show().subscribe(); fixture.detectChanges(); el.querySelector('.weui-mask').click(); @@ -192,24 +170,22 @@ describe('Component: Dialog', () => { `; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestDialogComponent], - imports: [DialogModule.forRoot(), FormsModule, NoopAnimationsModule], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], - }); - TestBed.overrideComponent(TestDialogComponent, { - set: { template: html }, - }); - fixture = TestBed.createComponent(TestDialogComponent); - context = fixture.componentInstance; - dl = fixture.debugElement; - el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestDialogComponent], + imports: [DialogModule, FormsModule, NoopAnimationsModule], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], + }); + TestBed.overrideComponent(TestDialogComponent, { + set: { template: html }, + }); + fixture = TestBed.createComponent(TestDialogComponent); + context = fixture.componentInstance; + dl = fixture.debugElement; + el = fixture.nativeElement; + fixture.detectChanges(); + tick(); + })); const TYPES: any[] = [ { @@ -232,8 +208,8 @@ describe('Component: Dialog', () => { { input: 'url', inputValue: 'https://cipchk.github.io/ngx-weui/' }, ]; for (const item of TYPES) { - it(`should be return ${item.input}`, (done: () => void) => { - context.config = Object.assign({}, CONFIG, item, { type: 'prompt' }); + it(`should be return ${item.input}`, done => { + context.config = { ...CONFIG, ...item, type: 'prompt' }; context.dialog.show().subscribe(res => { if (Array.isArray(res.result)) res.result = res.result[0]; expect(res.result).toBe(item.result || item.inputValue); @@ -246,118 +222,103 @@ describe('Component: Dialog', () => { fixture.detectChanges(); } expect(dl.queryAll(By.css('.weui-dialog__prompt')).length).toBe(1); - (getActions(el)[1]).click(); + (getActions(el)[1] as any).click(); }); } it('should be regex error in text', () => { const ERROR = '格式不正确'; - context.config = Object.assign({}, CONFIG, TYPES[0], { + context.config = { + ...CONFIG, + ...TYPES[0], type: 'prompt', inputRequired: true, inputValue: '123', inputRegex: /^[a-z]+$/, inputError: ERROR, - }); - console.log(context.config); + }; context.dialog.show().subscribe(); fixture.detectChanges(); expect(dl.queryAll(By.css('.weui-dialog__prompt')).length).toBe(1); - (getActions(el)[1]).click(); + (getActions(el)[1] as any).click(); fixture.detectChanges(); const errorEl = dl.queryAll(By.css('.weui-dialog__error')); expect(errorEl.length).toBe(1); - expect((errorEl[0].nativeElement as HTMLDivElement).textContent).toBe( - ERROR, - ); + expect((errorEl[0].nativeElement as HTMLDivElement).textContent).toBe(ERROR); }); it('should be required in checkbox', () => { const ERROR = '必填'; - context.config = Object.assign({}, CONFIG, TYPES[0], { + context.config = { + ...CONFIG, + ...TYPES[0], type: 'prompt', inputRequired: true, inputValue: undefined, inputError: ERROR, - }); - console.log(context.config); + }; context.dialog.show().subscribe(); fixture.detectChanges(); expect(dl.queryAll(By.css('.weui-dialog__prompt')).length).toBe(1); - (getActions(el)[1]).click(); + (getActions(el)[1] as any).click(); fixture.detectChanges(); const errorEl = dl.queryAll(By.css('.weui-dialog__error')); expect(errorEl.length).toBe(1); - expect((errorEl[0].nativeElement as HTMLDivElement).textContent).toBe( - ERROR, - ); + expect((errorEl[0].nativeElement as HTMLDivElement).textContent).toBe(ERROR); }); - it( - 'should be auto focus and enter return', - fakeAsync(() => { - const VALUE = 'cipchk@qq.com'; - context.config = Object.assign({}, CONFIG, { - type: 'prompt', - input: 'email', - inputValue: VALUE, - }); - context.dialog.show().subscribe(res => { - expect(res.result).toBe(VALUE); - }); - fixture.detectChanges(); - tick(300); - // spy - context.dialog._keyup({ keyCode: 13 }); - fixture.detectChanges(); - }), - ); + it('should be auto focus and enter return', fakeAsync(() => { + const VALUE = 'cipchk@qq.com'; + context.config = { ...CONFIG, type: 'prompt', input: 'email', inputValue: VALUE }; + context.dialog.show().subscribe(res => { + expect(res.result).toBe(VALUE); + }); + fixture.detectChanges(); + tick(300); + // spy + context.dialog._keyup({ keyCode: 13 } as any); + fixture.detectChanges(); + })); }); describe('[service]', () => { let service: DialogService; let fixture: any; - let context: TestDialogServiceComponent; - let dl: DebugElement; let el: any; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - imports: [DialogModule.forRoot(), FormsModule, NoopAnimationsModule], - declarations: [TestDialogServiceComponent], - providers: [DialogService], - }).createComponent(TestDialogServiceComponent); - - fixture = TestBed.createComponent(TestDialogServiceComponent); - context = fixture.componentInstance; - dl = fixture.debugElement; - el = fixture.nativeElement; - fixture.detectChanges(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + imports: [DialogModule, FormsModule, NoopAnimationsModule], + declarations: [TestDialogServiceComponent], + providers: [DialogService], + }).createComponent(TestDialogServiceComponent); + + fixture = TestBed.createComponent(TestDialogServiceComponent); + el = fixture.nativeElement; + fixture.detectChanges(); + })); - beforeEach( - inject([DialogService], (_s: DialogService) => { - service = _s; - }), - ); + beforeEach(inject([DialogService], (_s: DialogService) => { + service = _s; + })); - it('should close a dialog and get back a value [true] result', (done: () => void) => { - service.show(Object.assign({}, CONFIG)).subscribe(res => { + it('should close a dialog and get back a value [true] result', done => { + service.show({ ...CONFIG }).subscribe(res => { fixture.detectChanges(); expect(res.value).toBeTruthy(); done(); }); fixture.detectChanges(); - (getActions(el.parentElement)[1]).click(); + (getActions(el.parentElement)[1] as any).click(); }); }); }); @Component({ - template: `

Test Service

`, + template: ` +

Test Service

+ `, }) class TestDialogServiceComponent {} @@ -368,5 +329,5 @@ class TestDialogServiceComponent {} class TestDialogComponent { @ViewChild(DialogComponent) dialog: DialogComponent; - config: DialogConfig = Object.assign({}, CONFIG); + config: DialogConfig = { ...CONFIG }; } diff --git a/components/dialog/package.json b/components/dialog/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/dialog/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/dialog/style/index.less b/components/dialog/style/index.less index b8ba441..b001ce2 100644 --- a/components/dialog/style/index.less +++ b/components/dialog/style/index.less @@ -2,26 +2,23 @@ weui-dialog { .weui-mask, .weui-dialog { - opacity: 0; visibility: hidden; + opacity: 0; } .weui-mask__in, .weui-dialog__in { - opacity: 1; visibility: visible; + opacity: 1; } .weui-mask { transition-duration: 0.3s; } .weui-dialog { - transition-duration: 0.2s; transform-origin: 0 0; - } - .weui-dialog__in { - transform: scale(1) translate(-50%, -50%); + transition-duration: 0.2s; } .weui-dialog__error { - font-size: @dialog-error-font-size; color: @dialog-error-color; + font-size: @dialog-error-font-size; } } diff --git a/components/form/check.directive.spec.ts b/components/form/check.directive.spec.ts index 3c47f6c..e4d3829 100644 --- a/components/form/check.directive.spec.ts +++ b/components/form/check.directive.spec.ts @@ -1,17 +1,9 @@ -import { Component, ViewChild, DebugElement } from '@angular/core'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - ComponentFixtureAutoDetect, - async, - inject, -} from '@angular/core/testing'; +import { Component, DebugElement } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { FormModule } from './form.module'; import { ChecklistDirective } from './check.directive'; +import { FormModule } from './form.module'; const DATALIST = ['A', 'B']; @@ -20,29 +12,22 @@ describe('Directive: Checklist', () => { let context: TestInputComponent; let directives: ChecklistDirective[]; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestInputComponent], - imports: [FormModule.forRoot()], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], - }); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestInputComponent], + imports: [FormModule], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], + }); - fixture = TestBed.createComponent(TestInputComponent); - context = fixture.componentInstance; + fixture = TestBed.createComponent(TestInputComponent); + context = fixture.componentInstance; - const inputs = fixture.debugElement.queryAll( - By.directive(ChecklistDirective), - ); - directives = inputs.map( - (de: DebugElement) => - de.injector.get(ChecklistDirective) as ChecklistDirective, - ); + const inputs = fixture.debugElement.queryAll(By.directive(ChecklistDirective)); + directives = inputs.map((de: DebugElement) => de.injector.get(ChecklistDirective) as ChecklistDirective); - fixture.detectChanges(); - tick(); - }), - ); + fixture.detectChanges(); + tick(); + })); it('should be inited', () => { expect(directives).not.toBeNull(); @@ -68,22 +53,27 @@ describe('Directive: Checklist', () => { @Component({ template: `
- +
- `, + `, }) class TestInputComponent { show: boolean = true; - list: string[] = Object.assign([], DATALIST); + list: string[] = [...DATALIST]; res: string[] = []; } diff --git a/components/form/check.directive.ts b/components/form/check.directive.ts index 246faef..f9cacce 100644 --- a/components/form/check.directive.ts +++ b/components/form/check.directive.ts @@ -2,6 +2,7 @@ import { Directive, Input } from '@angular/core'; @Directive({ selector: '[weui-checklist]', + exportAs: 'weuiChecklist', host: { '(change)': '_change($event)', '[checked]': 'checked', diff --git a/components/form/form.module.ts b/components/form/form.module.ts index 4539c1f..94a1799 100644 --- a/components/form/form.module.ts +++ b/components/form/form.module.ts @@ -1,28 +1,16 @@ import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { ChecklistDirective } from './check.directive'; import { InputDirective } from './input.directive'; -import { VCodeDirective } from './vcode.directive'; import { TextareaDirective } from './textarea.directive'; -import { ChecklistDirective } from './check.directive'; +import { VCodeDirective } from './vcode.directive'; + +const COMPONENTS = [InputDirective, VCodeDirective, TextareaDirective, ChecklistDirective]; @NgModule({ imports: [CommonModule, FormsModule], - declarations: [ - InputDirective, - VCodeDirective, - TextareaDirective, - ChecklistDirective, - ], - exports: [ - InputDirective, - VCodeDirective, - TextareaDirective, - ChecklistDirective, - ], + declarations: COMPONENTS, + exports: COMPONENTS, }) -export class FormModule { - static forRoot(): ModuleWithProviders { - return { ngModule: FormModule, providers: [] }; - } -} +export class FormModule {} diff --git a/components/form/input.directive.spec.ts b/components/form/input.directive.spec.ts index 3a8fc10..5755d9d 100644 --- a/components/form/input.directive.spec.ts +++ b/components/form/input.directive.spec.ts @@ -1,39 +1,11 @@ -import { Component, ViewChild, DebugElement } from '@angular/core'; -import { - FormsModule, - FormBuilder, - FormGroup, - FormControl, - ReactiveFormsModule, -} from '@angular/forms'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - ComponentFixtureAutoDetect, - async, - inject, -} from '@angular/core/testing'; +import { Component, DebugElement } from '@angular/core'; +import { ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing'; +import { FormsModule, FormControl, ReactiveFormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; import { FormModule } from './form.module'; import { InputDirective } from './input.directive'; -const HTML = ` -
-
-
- -
-
-
-`; - const HTML_FORM = `
@@ -66,7 +38,7 @@ describe('Directive: Input', () => { function genModule(html: string) { TestBed.configureTestingModule({ declarations: [TestInputComponent], - imports: [FormModule.forRoot(), FormsModule, ReactiveFormsModule], + imports: [FormModule, FormsModule, ReactiveFormsModule], providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], }); @@ -75,13 +47,10 @@ describe('Directive: Input', () => { }); fixture = TestBed.createComponent(TestInputComponent); context = fixture.componentInstance; - inputEl = fixture.debugElement.query(By.css('input')) - .nativeElement as HTMLInputElement; + inputEl = fixture.debugElement.query(By.css('input')).nativeElement as HTMLInputElement; const inputs = fixture.debugElement.queryAll(By.directive(InputDirective)); - directive = inputs.map( - (de: DebugElement) => de.injector.get(InputDirective) as InputDirective, - )[0]; + directive = inputs.map((de: DebugElement) => de.injector.get(InputDirective))[0]; fixture.detectChanges(); } @@ -89,9 +58,7 @@ describe('Directive: Input', () => { function expectValidator(val: string, validStatus: boolean) { context.control.setValue(val); fixture.detectChanges(); - expect(inputEl.classList).toContain( - validStatus ? 'ng-valid' : 'ng-invalid', - ); + expect(inputEl.classList).toContain(validStatus ? 'ng-valid' : 'ng-invalid'); } describe('[default]', () => { @@ -170,7 +137,7 @@ describe('Directive: Input', () => { spyOn(console, 'error'); TestBed.configureTestingModule({ declarations: [TestInputComponent], - imports: [FormModule.forRoot(), FormsModule, ReactiveFormsModule], + imports: [FormModule, FormsModule, ReactiveFormsModule], providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], }); @@ -185,9 +152,9 @@ describe('Directive: Input', () => { @Component({ template: `` }) class TestInputComponent { val: string = ''; - type: string = 'mobile'; - required: 'info' | 'warn' | 'waiting' = 'warn'; - regex: RegExp | string = null; + type: string | undefined = 'mobile'; + required: 'info' | 'warn' | 'waiting' | undefined = 'warn'; + regex: RegExp | string | null = null; cleaner: boolean = false; control = new FormControl(); diff --git a/components/form/input.directive.ts b/components/form/input.directive.ts index e312de5..8512792 100644 --- a/components/form/input.directive.ts +++ b/components/form/input.directive.ts @@ -1,28 +1,13 @@ -import { - Directive, - Input, - Renderer, - ElementRef, - OnInit, - OnChanges, - SimpleChanges, - forwardRef, -} from '@angular/core'; -import { - Validator, - AbstractControl, - Validators, - NG_VALIDATORS, - ValidatorFn, - ValidationErrors, -} from '@angular/forms'; -import { findParent, add, remove } from '../utils/dom'; +import { forwardRef, Directive, ElementRef, Input, OnChanges, OnInit } from '@angular/core'; +import { AbstractControl, NG_VALIDATORS, ValidationErrors, Validator, ValidatorFn } from '@angular/forms'; +import { add, findParent, remove, InputBoolean } from 'ngx-weui/core'; /** * 文本框,指令是对文本框格式校验(邮箱、手机、身份证等)、视觉效果的增强而已 */ @Directive({ selector: '[weui-input]', + exportAs: 'weuiInput', providers: [ { provide: NG_VALIDATORS, @@ -34,7 +19,6 @@ import { findParent, add, remove } from '../utils/dom'; export class InputDirective implements OnInit, OnChanges, Validator { private parentEl: any; private ftEl: any; - private pattern: RegExp; private _validator: ValidatorFn; private _onChange: () => void; @@ -57,7 +41,7 @@ export class InputDirective implements OnInit, OnChanges, Validator { /** * 是否自动清除内容中的空格 */ - @Input('weui-cleaner') cleaner: boolean = false; + @Input('weui-cleaner') @InputBoolean() cleaner: boolean = false; constructor(private el: ElementRef) {} @@ -65,19 +49,19 @@ export class InputDirective implements OnInit, OnChanges, Validator { this.parentEl = findParent(this.el.nativeElement, '.weui-cell'); if (!this.parentEl) { console.error('父DOM结构至少必须包含一个.weui-cell'); - return ; + return; } // 检查是否有 weui-cell__ft this.ftEl = add(this.parentEl); } - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { this._createValidator(); if (this._onChange) this._onChange(); } private _createValidator(): void { - let regex: RegExp = null; + let regex: RegExp | null = null; if (this.inputRegex) { if (typeof this.inputRegex === 'string') { regex = new RegExp(`^${this.inputRegex}$`); @@ -117,8 +101,7 @@ export class InputDirective implements OnInit, OnChanges, Validator { this._validator = (control: AbstractControl): ValidationErrors | null => { let value: string = control.value; if (value == null || value.length === 0) { - if (this.required !== undefined) - return { icon: this.required, type: 'required', actualValue: value }; + if (this.required !== undefined) return { icon: this.required, type: 'required', actualValue: value }; return null; } @@ -126,9 +109,7 @@ export class InputDirective implements OnInit, OnChanges, Validator { value = value.replace(/ /g, ''); control.setValue(value, { emitEvent: false }); } - return regex === null || regex.test(value) - ? null - : { icon: 'warn', type: 'regex', actualValue: value }; + return regex === null || regex.test(value) ? null : { icon: 'warn', type: 'regex', actualValue: value }; }; } @@ -137,6 +118,7 @@ export class InputDirective implements OnInit, OnChanges, Validator { } validate(c: AbstractControl): ValidationErrors | null { + if (!this.parentEl) return null; const ret = this._validator(c); if (ret === null) { this.parentEl.classList.remove('weui-cell_warn'); diff --git a/components/form/package.json b/components/form/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/form/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/form/textarea.directive.spec.ts b/components/form/textarea.directive.spec.ts index d9de434..d45665e 100644 --- a/components/form/textarea.directive.spec.ts +++ b/components/form/textarea.directive.spec.ts @@ -1,24 +1,15 @@ -import { Component, ViewChild, DebugElement } from '@angular/core'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - async, - inject, -} from '@angular/core/testing'; +import { Component } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; import { FormModule } from './form.module'; -import { TextareaDirective } from './textarea.directive'; -const MAXLENGTH: number = 5; +const MAXLENGTH = 5; describe('Directive: Textarea', () => { let fixture: ComponentFixture; let context: TestInputComponent; - let directive: TextareaDirective; let inputEl: HTMLInputElement; let counterEl: HTMLElement; @@ -30,24 +21,14 @@ describe('Directive: Textarea', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestInputComponent], - imports: [FormModule.forRoot(), FormsModule], + imports: [FormModule, FormsModule], }); fixture = TestBed.createComponent(TestInputComponent); context = fixture.componentInstance; - inputEl = fixture.debugElement.query(By.css('textarea')) - .nativeElement as HTMLInputElement; + inputEl = fixture.debugElement.query(By.css('textarea')).nativeElement as HTMLInputElement; - const inputs = fixture.debugElement.queryAll( - By.directive(TextareaDirective), - ); - directive = inputs.map( - (de: DebugElement) => - de.injector.get(TextareaDirective) as TextareaDirective, - )[0]; - - counterEl = fixture.debugElement.query(By.css('.weui-textarea-counter')) - .nativeElement as HTMLElement; + counterEl = fixture.debugElement.query(By.css('.weui-textarea-counter')).nativeElement as HTMLElement; fixture.detectChanges(); }); @@ -73,26 +54,28 @@ describe('Directive: Textarea', () => { it('should be inited if nospecify [maxlength]', () => { context.maxlength = 0; fixture.detectChanges(); - expect( - fixture.debugElement.nativeElement.querySelectorAll( - '.weui-textarea-counter', - ).length, - ).toBe(0); + expect(fixture.debugElement.nativeElement.querySelectorAll('.weui-textarea-counter').length).toBe(0); }); }); @Component({ template: `
-
-
- -
-
+
+
+ +
+
- `, + `, }) class TestInputComponent { val: string = ''; diff --git a/components/form/textarea.directive.ts b/components/form/textarea.directive.ts index a2dba12..2af7d6a 100644 --- a/components/form/textarea.directive.ts +++ b/components/form/textarea.directive.ts @@ -1,18 +1,12 @@ -import { - Directive, - Input, - OnChanges, - SimpleChanges, - ElementRef, - OnInit, -} from '@angular/core'; -import { add, remove } from '../utils/dom'; +import { Directive, ElementRef, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; +import { add, remove, InputNumber } from 'ngx-weui/core'; /** * 文本域字数统计 */ @Directive({ selector: '[weui-textarea]', + exportAs: 'weuiTextarea', host: { '(input)': '_onChange($event.target?.value)', }, @@ -23,7 +17,7 @@ export class TextareaDirective implements OnInit, OnChanges { /** * 最大长度,0表示不受限 */ - @Input() maxlength: number = 0; + @Input() @InputNumber() maxlength: number = 0; /** * 中文部分应该算多少个字符,使用 `/[^\x00-\xff]/g` 正则表达式统计中文部分(默认:1个字符) @@ -31,20 +25,20 @@ export class TextareaDirective implements OnInit, OnChanges { @Input('weui-cn') set cn(value: number) { this._cn = value; - this.fillStr = new Array(value).fill('*').join(''); + this.fillStr = new Array(+value).fill('*').join(''); } private _value: string; private _count: any; - constructor(private el: ElementRef) { } + constructor(private el: ElementRef) {} ngOnInit() { this.init(); } ngOnChanges(changes: SimpleChanges): void { - if ('maxlength' in changes) { + if (changes.maxlength) { this.init()._onChange(this._value); } } @@ -62,7 +56,7 @@ export class TextareaDirective implements OnInit, OnChanges { return this; } - _onChange(value: any) { + _onChange(value: string) { if (!this._count) return; value = value || ''; diff --git a/components/form/vcode.directive.spec.ts b/components/form/vcode.directive.spec.ts index 0f492be..1266ed8 100644 --- a/components/form/vcode.directive.spec.ts +++ b/components/form/vcode.directive.spec.ts @@ -1,28 +1,16 @@ -import { Observable, Subscription, of } from 'rxjs'; -import { Component, ViewChild, DebugElement } from '@angular/core'; -import { - FormsModule, - FormBuilder, - FormGroup, - FormControl, -} from '@angular/forms'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - ComponentFixtureAutoDetect, - async, - inject, -} from '@angular/core/testing'; +import { Component, DebugElement } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing'; +import { FormsModule } from '@angular/forms'; import { By } from '@angular/platform-browser'; +import { of, Observable } from 'rxjs'; import { FormModule } from './form.module'; import { VCodeDirective } from './vcode.directive'; -const SECONDS: number = 10; -const TPL: string = '${num}s'; -const ERRORS: string = 'resend'; +const SECONDS = 10; +// tslint:disable-next-line: no-invalid-template-strings +const TPL = '${num}s'; +const ERRORS = 'resend'; const html = `
@@ -47,34 +35,28 @@ describe('Directive: vcode', () => { let buttonEl: HTMLButtonElement; describe('[default]', () => { - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestVCodeComponent], - imports: [FormModule.forRoot(), FormsModule], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], - }); - - TestBed.overrideComponent(TestVCodeComponent, { - set: { template: html }, - }); - fixture = TestBed.createComponent(TestVCodeComponent); - context = fixture.componentInstance; - - buttonEl = fixture.debugElement.query(By.css('button')) - .nativeElement as HTMLButtonElement; - - const ds = fixture.debugElement.queryAll(By.directive(VCodeDirective)); - directive = ds.map( - (de: DebugElement) => - de.injector.get(VCodeDirective) as VCodeDirective, - )[0]; - - fixture.detectChanges(); - - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestVCodeComponent], + imports: [FormModule, FormsModule], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], + }); + + TestBed.overrideComponent(TestVCodeComponent, { + set: { template: html }, + }); + fixture = TestBed.createComponent(TestVCodeComponent); + context = fixture.componentInstance; + + buttonEl = fixture.debugElement.query(By.css('button')).nativeElement as HTMLButtonElement; + + const ds = fixture.debugElement.queryAll(By.directive(VCodeDirective)); + directive = ds.map((de: DebugElement) => de.injector.get(VCodeDirective))[0]; + + fixture.detectChanges(); + + tick(); + })); it('should be defined on the test component', () => { expect(directive).not.toBeNull(); @@ -93,7 +75,7 @@ describe('Directive: vcode', () => { expect(buttonEl.disabled).toBeTruthy(); }); - it('should be resend in to late', (done: () => void) => { + it('should be resend in to late', done => { context.seconds = 2; fixture.detectChanges(); buttonEl.click(); @@ -110,7 +92,7 @@ describe('Directive: vcode', () => { spyOn(console, 'error'); TestBed.configureTestingModule({ declarations: [TestVCodeComponent], - imports: [FormModule.forRoot(), FormsModule], + imports: [FormModule, FormsModule], providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], }); @@ -122,36 +104,30 @@ describe('Directive: vcode', () => { }); describe('send error', () => { - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestVCodeComponent], - imports: [FormModule.forRoot(), FormsModule], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], - }); - - TestBed.overrideComponent(TestVCodeComponent, { - set: { template: html }, - }); - fixture = TestBed.createComponent(TestVCodeComponent); - context = fixture.componentInstance; - - spyOn(context, 'onSendCode').and.returnValue(of(false)); - - buttonEl = fixture.debugElement.query(By.css('button')) - .nativeElement as HTMLButtonElement; - - const ds = fixture.debugElement.queryAll(By.directive(VCodeDirective)); - directive = ds.map( - (de: DebugElement) => - de.injector.get(VCodeDirective) as VCodeDirective, - )[0]; - - fixture.detectChanges(); - - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestVCodeComponent], + imports: [FormModule, FormsModule], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], + }); + + TestBed.overrideComponent(TestVCodeComponent, { + set: { template: html }, + }); + fixture = TestBed.createComponent(TestVCodeComponent); + context = fixture.componentInstance; + + spyOn(context, 'onSendCode').and.returnValue(of(false)); + + buttonEl = fixture.debugElement.query(By.css('button')).nativeElement as HTMLButtonElement; + + const ds = fixture.debugElement.queryAll(By.directive(VCodeDirective)); + directive = ds.map((de: DebugElement) => de.injector.get(VCodeDirective))[0]; + + fixture.detectChanges(); + + tick(); + })); it('should be resend', () => { buttonEl.click(); diff --git a/components/form/vcode.directive.ts b/components/form/vcode.directive.ts index 2fb1b07..85f3196 100644 --- a/components/form/vcode.directive.ts +++ b/components/form/vcode.directive.ts @@ -1,13 +1,13 @@ -import { Directive, Input, ElementRef, OnDestroy, OnInit } from '@angular/core'; -import { Observable, Subscription } from 'rxjs'; - -import { findParent, add, remove } from '../utils/dom'; +import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core'; +import { InputNumber } from 'ngx-weui/core'; +import { Observable } from 'rxjs'; /** * 获取验证码 */ @Directive({ selector: '[weui-vcode]', + exportAs: 'weuiVcode', host: { '(click)': '_onClick()', '[disabled]': '_disabled', @@ -22,11 +22,12 @@ export class VCodeDirective implements OnInit, OnDestroy { /** * 时长(单位:秒),默认:`60` */ - @Input('weui-seconds') seconds: number = 60; + @Input('weui-seconds') @InputNumber() seconds: number = 60; /** * 倒计时模板,使用 `${num}` 表示当前秒数 */ + // tslint:disable-next-line: no-invalid-template-strings @Input('weui-tpl') tpl: string = '${num} 秒'; /** @@ -41,8 +42,7 @@ export class VCodeDirective implements OnInit, OnDestroy { constructor(private el: ElementRef) {} ngOnInit() { - if (typeof this.onSend !== 'function') - console.error('weui-vcode必须传递一个返回值为 `Observable` 函数'); + if (typeof this.onSend !== 'function') console.error('weui-vcode必须传递一个返回值为 `Observable` 函数'); this._cur = this.el.nativeElement.innerHTML; } @@ -71,10 +71,7 @@ export class VCodeDirective implements OnInit, OnDestroy { } private setText(num: number): void { - this.el.nativeElement.innerHTML = this.tpl.replace( - /\${num}/, - num.toString(), - ); + this.el.nativeElement.innerHTML = this.tpl.replace(/\${num}/, num.toString()); } private destroy() { diff --git a/components/gallery/gallery.component.html b/components/gallery/gallery.component.html new file mode 100644 index 0000000..94b1666 --- /dev/null +++ b/components/gallery/gallery.component.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/components/gallery/gallery.component.ts b/components/gallery/gallery.component.ts index 62b1a35..e8aa2d7 100644 --- a/components/gallery/gallery.component.ts +++ b/components/gallery/gallery.component.ts @@ -1,22 +1,15 @@ +import { animate, state, style, transition, trigger } from '@angular/animations'; import { + ChangeDetectionStrategy, Component, - HostListener, - ElementRef, - HostBinding, + EventEmitter, Input, OnChanges, - SimpleChanges, - EventEmitter, Output, + SimpleChanges, + ViewEncapsulation, } from '@angular/core'; -import { - animate, - state, - style, - transition, - trigger, -} from '@angular/animations'; -import { isImage, genImageUrl } from '../utils/browser'; +import { genImageUrl, InputBoolean } from 'ngx-weui/core'; /** * 数据对象 @@ -42,25 +35,8 @@ export interface GalleryItem { @Component({ selector: 'weui-gallery', - template: ` -
- - - -
- `, + exportAs: 'weuiGallery', + templateUrl: './gallery.component.html', animations: [ trigger('visibility', [ state('show', style({ opacity: 1 })), @@ -68,6 +44,9 @@ export interface GalleryItem { transition('hide <=> show', [animate(200)]), ]), ], + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class GalleryComponent implements OnChanges { _imgs: any[]; @@ -82,23 +61,24 @@ export class GalleryComponent implements OnChanges { /** * 是否允许删除,默认:`true` */ - @Input() canDelete: boolean = true; + @Input() @InputBoolean() canDelete: boolean = true; /** * 删除回调 */ - @Output() delete = new EventEmitter(); + @Output() readonly delete = new EventEmitter(); /** * 隐藏回调 */ - @Output() hide = new EventEmitter(); + @Output() readonly hide = new EventEmitter(); /** * 标记是否显示,支持双向绑定 */ - @Input() show: boolean = false; - @Output() showChange = new EventEmitter(); + @Input() @InputBoolean() show: boolean = false; + @Output() readonly showChange = new EventEmitter(); + _showd: boolean = false; get _visibility(): string { return this.show ? 'show' : 'hide'; @@ -127,37 +107,37 @@ export class GalleryComponent implements OnChanges { } ngOnChanges(changes: SimpleChanges): void { - if ('imgs' in changes) this.parseImgs(); + if (changes.imgs) this.parseImgs(); } private parseImgs() { - let imgs = this.imgs; + let imgs = this.imgs as any; if (Array.isArray(imgs)) { if (imgs.length > 0) { if (typeof imgs[0] === 'string') { - imgs = (imgs).map((url: string) => { - return { url: url }; + imgs = (imgs as string[]).map((url: string) => { + return { url }; }); } else { - imgs = (imgs).map((item: GalleryItem) => { + imgs = (imgs as GalleryItem[]).map((item: GalleryItem) => { if (item.file) item.url = genImageUrl(item.file); return item; }); } } } else { - if (typeof imgs === 'string') imgs = [{ url: imgs }]; - else { + if (typeof imgs === 'string') { + imgs = [{ url: imgs }]; + } else { const imgUrl = genImageUrl(imgs); - if (imgUrl) imgs = [{ url: imgUrl }]; + if (imgUrl) { + imgs = [{ url: imgUrl }]; + } } } // todo: 永远只返回一个 // 针对未来可能直接上下个 - this._imgs = Object.assign( - [], - imgs && (imgs).length > 0 ? imgs.slice(0, 1) : [], - ); + this._imgs = imgs && (imgs as any[]).length > 0 ? imgs.slice(0, 1) : []; } } diff --git a/components/gallery/gallery.module.ts b/components/gallery/gallery.module.ts index 2975f5f..07c2649 100644 --- a/components/gallery/gallery.module.ts +++ b/components/gallery/gallery.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { GalleryComponent } from './gallery.component'; @@ -9,8 +9,4 @@ import { GalleryComponent } from './gallery.component'; exports: [GalleryComponent], entryComponents: [GalleryComponent], }) -export class GalleryModule { - static forRoot(): ModuleWithProviders { - return { ngModule: GalleryModule, providers: [] }; - } -} +export class GalleryModule {} diff --git a/components/gallery/package.json b/components/gallery/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/gallery/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/gallery/public-api.ts b/components/gallery/public-api.ts index dfb4267..1d13944 100644 --- a/components/gallery/public-api.ts +++ b/components/gallery/public-api.ts @@ -1,2 +1,2 @@ -export { GalleryComponent, GalleryItem } from './gallery.component'; -export { GalleryModule } from './gallery.module'; +export * from './gallery.component'; +export * from './gallery.module'; diff --git a/components/index.less b/components/index.less index a0ee11a..2fe1252 100644 --- a/components/index.less +++ b/components/index.less @@ -1,15 +1,16 @@ -@import "./style/theme.less"; -@import "./style/fixed/index.less"; -@import "./accordion/style/index.less"; -@import "./dialog/style/index.less"; -@import "./infiniteloader/style/index.less"; -@import "./mask/style/index.less"; -@import "./pagination/style/index.less"; -@import "./popup/style/index.less"; -@import "./ptr/style/index.less"; -@import "./rating/style/index.less"; -@import "./sidebar/style/index.less"; -@import "./stepper/style/index.less"; -@import "./swiper/style/index.less"; -@import "./tab/style/index.less"; -@import "./toptips/style/index.less"; +@import './style/theme.less'; +@import './style/fixed/index.less'; +@import './accordion/style/index.less'; +@import './dialog/style/index.less'; +@import './infiniteloader/style/index.less'; +@import './mask/style/index.less'; +@import './pagination/style/index.less'; +@import './popup/style/index.less'; +@import './ptr/style/index.less'; +@import './rating/style/index.less'; +@import './sidebar/style/index.less'; +@import './stepper/style/index.less'; +@import './swiper/style/index.less'; +@import './tab/style/index.less'; +@import './toptips/style/index.less'; +@import './slider/style/index.less'; diff --git a/components/infiniteloader/infiniteloader.component.html b/components/infiniteloader/infiniteloader.component.html new file mode 100644 index 0000000..0355de1 --- /dev/null +++ b/components/infiniteloader/infiniteloader.component.html @@ -0,0 +1,7 @@ +
+ +
+
+
+
+
diff --git a/components/infiniteloader/infiniteloader.component.ts b/components/infiniteloader/infiniteloader.component.ts index b36ee3d..f5cd8b0 100644 --- a/components/infiniteloader/infiniteloader.component.ts +++ b/components/infiniteloader/infiniteloader.component.ts @@ -1,33 +1,31 @@ import { + ChangeDetectionStrategy, Component, + ElementRef, + EventEmitter, Input, OnChanges, - SimpleChanges, - EventEmitter, - Output, - ElementRef, OnDestroy, OnInit, + Output, + SimpleChanges, + ViewEncapsulation, } from '@angular/core'; -import { Subscription, fromEvent } from 'rxjs'; +import { fromEvent, Subscription } from 'rxjs'; import { InfiniteLoaderConfig } from './infiniteloader.config'; @Component({ selector: 'weui-infiniteloader', - template: ` -
- -
-
-
-
-
- `, + exportAs: 'weuiInfiniteloader', + templateUrl: './infiniteloader.component.html', host: { '[class.weui-infiniteloader]': 'true', '[style.height]': 'config.height', }, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class InfiniteLoaderComponent implements OnChanges, OnInit, OnDestroy { private didScroll = false; @@ -46,12 +44,9 @@ export class InfiniteLoaderComponent implements OnChanges, OnInit, OnDestroy { /** * 加载更多回调 */ - @Output() loadmore = new EventEmitter(); + @Output() readonly loadmore = new EventEmitter(); - constructor( - private el: ElementRef, - private DEF: InfiniteLoaderConfig, - ) { } + constructor(private el: ElementRef, private DEF: InfiniteLoaderConfig) {} /** 设置本次加载完成 */ resolveLoading() { @@ -73,11 +68,9 @@ export class InfiniteLoaderComponent implements OnChanges, OnInit, OnDestroy { _onScroll() { if (this._loading || this._finished) return; const target = this.scrollEvent.target; - const scrollPercent = Math.floor( - (target.scrollTop + target.clientHeight) / target.scrollHeight * 100, - ); + const scrollPercent = Math.floor(((target.scrollTop + target.clientHeight) / target.scrollHeight) * 100); - if (scrollPercent > this.config.percent) { + if (scrollPercent > this.config.percent!) { this._loading = true; this.loadmore.emit(this); } @@ -112,6 +105,6 @@ export class InfiniteLoaderComponent implements OnChanges, OnInit, OnDestroy { } private parseConfig() { - this.config = Object.assign({}, this.DEF, this.config); + this.config = { ...this.DEF, ...this.config }; } } diff --git a/components/infiniteloader/infiniteloader.config.ts b/components/infiniteloader/infiniteloader.config.ts index ab76eaa..e206b4f 100644 --- a/components/infiniteloader/infiniteloader.config.ts +++ b/components/infiniteloader/infiniteloader.config.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class InfiniteLoaderConfig { /** * 容器高度,默认:`100vh` @@ -15,12 +15,14 @@ export class InfiniteLoaderConfig { /** * 加载中文本(支持HTML),默认:weui-loadmore 组件 */ - loading?: string = '
加载中…
'; + loading?: string = + '
加载中…
'; /** * 完成所有数据加载文本(支持HTML),默认:weui-loadmore 组件 */ - finished?: string = '
已加载完毕
'; + finished?: string = + '
已加载完毕
'; /**滚动节流时长(单位:ms),默认:`100` */ throttle?: number = 100; diff --git a/components/infiniteloader/infiniteloader.module.ts b/components/infiniteloader/infiniteloader.module.ts index 988813e..2116e6d 100644 --- a/components/infiniteloader/infiniteloader.module.ts +++ b/components/infiniteloader/infiniteloader.module.ts @@ -1,19 +1,10 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { InfiniteLoaderComponent } from './infiniteloader.component'; -import { InfiniteLoaderConfig } from './infiniteloader.config'; @NgModule({ imports: [CommonModule], declarations: [InfiniteLoaderComponent], exports: [InfiniteLoaderComponent], - entryComponents: [InfiniteLoaderComponent], }) -export class InfiniteLoaderModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: InfiniteLoaderModule, - providers: [InfiniteLoaderConfig], - }; - } -} +export class InfiniteLoaderModule {} diff --git a/components/infiniteloader/package.json b/components/infiniteloader/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/infiniteloader/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/jweixin/jweixin.d.ts b/components/jweixin/jweixin.d.ts index f09fe05..fd80694 100644 --- a/components/jweixin/jweixin.d.ts +++ b/components/jweixin/jweixin.d.ts @@ -107,10 +107,7 @@ export interface ICheckJsApi extends CallbackBase { /** 需要检测的JS接口列表,所有JS接口列表见附录2 */ jsApiList: ApiMethod[]; /** 以键值对的形式返回,可用的api值true,不可用为false */ - success(res: { - checkResult: { [api: string]: boolean }; - errMsg: string; - }): void; + success(res: { checkResult: { [api: string]: boolean }; errMsg: string }): void; } /** 判断当前客户端版本是否支持指定JS接口 */ @@ -133,9 +130,7 @@ export interface onMenuShareTimelineParam extends onMenuShareBase { } /** 获取“分享到朋友圈”按钮点击状态及自定义分享内容接口 */ -export declare function onMenuShareTimeline( - params: onMenuShareTimelineParam, -): void; +export declare function onMenuShareTimeline(params: onMenuShareTimelineParam): void; export interface onMenuShareAppMessageParam extends onMenuShareTimelineParam { /** 分享描述 */ @@ -147,9 +142,7 @@ export interface onMenuShareAppMessageParam extends onMenuShareTimelineParam { } /** 获取“分享给朋友”按钮点击状态及自定义分享内容接口 */ -export declare function onMenuShareAppMessage( - params: onMenuShareAppMessageParam, -): void; +export declare function onMenuShareAppMessage(params: onMenuShareAppMessageParam): void; export interface onMenuShareQQParam extends onMenuShareTimelineParam { /** 分享描述 */ @@ -186,11 +179,7 @@ export interface chooseImageParam extends CallbackBase { /** 可以指定来源是相册还是相机,默认二者都有 */ sourceType?: ImageSourceType[]; /** 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片 */ - success(res: { - sourceType: string; - localIds: string[]; - errMsg: string; - }): void; + success(res: { sourceType: string; localIds: string[]; errMsg: string }): void; } /** 拍照或从手机相册中选图接口 */ @@ -398,9 +387,7 @@ export interface startSearchBeaconsParam extends CallbackBase { * 开启查找周边ibeacon设备接口 * 注:这里成功的回调是 `complete` */ -export declare function startSearchBeacons( - params: startSearchBeaconsParam, -): void; +export declare function startSearchBeacons(params: startSearchBeaconsParam): void; export interface stopSearchBeaconsParam extends CallbackBase { /** 关闭查找完成后的回调函数 */ @@ -472,9 +459,7 @@ export interface openProductSpecificViewParam extends CallbackBase { } /** 跳转微信商品页接口 */ -export declare function openProductSpecificView( - params: openProductSpecificViewParam, -): void; +export declare function openProductSpecificView(params: openProductSpecificViewParam): void; export interface chooseCardParam extends CallbackBase { /** 门店ID。shopID用于筛选出拉起带有指定location_list(shopID)的卡券列表,非必填。 */ diff --git a/components/jweixin/jweixin.module.ts b/components/jweixin/jweixin.module.ts index 7fc99cb..521f56c 100644 --- a/components/jweixin/jweixin.module.ts +++ b/components/jweixin/jweixin.module.ts @@ -1,12 +1,4 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; -import { JWeiXinService } from './jweixin.service'; -import { LoaderService } from '../utils/loader.service'; +import { NgModule } from '@angular/core'; -@NgModule({ - providers: [JWeiXinService, LoaderService], -}) -export class JWeiXinModule { - static forRoot(): ModuleWithProviders { - return { ngModule: JWeiXinModule, providers: [] }; - } -} +@NgModule({}) +export class JWeiXinModule {} diff --git a/components/jweixin/jweixin.service.spec.ts b/components/jweixin/jweixin.service.spec.ts index a1b3527..8809a02 100644 --- a/components/jweixin/jweixin.service.spec.ts +++ b/components/jweixin/jweixin.service.spec.ts @@ -1,19 +1,13 @@ -import { NgModule, Component } from '@angular/core'; -import { - inject, - TestBed, - ComponentFixtureAutoDetect, - ComponentFixture, -} from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; - -import { LoaderService } from '../utils/loader.service'; +import { Component } from '@angular/core'; +import { inject, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LoaderService } from 'ngx-weui/core'; import { JWeiXinModule } from './jweixin.module'; import { JWeiXinService } from './jweixin.service'; class MockLoaderService { loadScript() { - return new Promise((resolve, reject) => { + return new Promise(resolve => { resolve({ loaded: true }); }); } @@ -21,31 +15,24 @@ class MockLoaderService { describe('jweixin: JWeiXinService', () => { let fixture: ComponentFixture; - let el: HTMLElement; let service: JWeiXinService; beforeEach(() => { TestBed.configureTestingModule({ declarations: [EmptyTestComponent], - imports: [JWeiXinModule.forRoot()], - providers: [ - JWeiXinService, - { provide: LoaderService, useClass: MockLoaderService }, - ], + imports: [JWeiXinModule], + providers: [JWeiXinService, { provide: LoaderService, useClass: MockLoaderService }], }); fixture = TestBed.createComponent(EmptyTestComponent); - el = fixture.nativeElement; fixture.detectChanges(); }); - beforeEach( - inject([JWeiXinService], (loader: JWeiXinService) => { - service = loader; - }), - ); + beforeEach(inject([JWeiXinService], (loader: JWeiXinService) => { + service = loader; + })); - it('#get', (done: () => void) => { + it('#get', done => { service.get().then(status => { expect(status).toBe(true); done(); diff --git a/components/jweixin/jweixin.service.ts b/components/jweixin/jweixin.service.ts index 4fba32f..f75bdb1 100644 --- a/components/jweixin/jweixin.service.ts +++ b/components/jweixin/jweixin.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; -import { LoaderService } from '../utils/loader.service'; +import { LoaderService } from 'ngx-weui/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class JWeiXinService { constructor(private load: LoaderService) {} @@ -11,7 +11,7 @@ export class JWeiXinService { * @param jweixinUrl 默认://res.wx.qq.com/open/js/jweixin-1.2.0.js */ get(jweixinUrl?: string): Promise { - return new Promise((resolve, reject) => { + return new Promise(resolve => { this.load .loadScript(jweixinUrl || '//res.wx.qq.com/open/js/jweixin-1.2.0.js') .then(res => { diff --git a/components/jweixin/package.json b/components/jweixin/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/jweixin/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/loadmore/loadmore.component.html b/components/loadmore/loadmore.component.html new file mode 100644 index 0000000..a1d9c9d --- /dev/null +++ b/components/loadmore/loadmore.component.html @@ -0,0 +1,10 @@ +
+ + {{ type === 'dot' ? '' : type === 'line' ? lineText : loadingText }} +
diff --git a/components/loadmore/loadmore.component.ts b/components/loadmore/loadmore.component.ts index eb92561..a12b351 100644 --- a/components/loadmore/loadmore.component.ts +++ b/components/loadmore/loadmore.component.ts @@ -1,25 +1,13 @@ -import { - Component, - HostListener, - ElementRef, - HostBinding, - Input, - OnChanges, - SimpleChanges, -} from '@angular/core'; +import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@angular/core'; import { LoadmoreConfig } from './loadmore.config'; @Component({ selector: 'weui-loadmore', - template: ` -
- - {{type==='dot'?'':type==='line'?lineText:loadingText}} -
- `, + exportAs: 'weuiLoadmore', + templateUrl: './loadmore.component.html', + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class LoadmoreComponent { /** diff --git a/components/loadmore/loadmore.config.ts b/components/loadmore/loadmore.config.ts index a03143f..372c8bb 100644 --- a/components/loadmore/loadmore.config.ts +++ b/components/loadmore/loadmore.config.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class LoadmoreConfig { /** * 类型,默认:`loading` diff --git a/components/loadmore/loadmore.module.ts b/components/loadmore/loadmore.module.ts index eda8a4f..cbeb9b3 100644 --- a/components/loadmore/loadmore.module.ts +++ b/components/loadmore/loadmore.module.ts @@ -1,7 +1,6 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { LoadmoreComponent } from './loadmore.component'; -import { LoadmoreConfig } from './loadmore.config'; @NgModule({ imports: [CommonModule], @@ -9,8 +8,4 @@ import { LoadmoreConfig } from './loadmore.config'; exports: [LoadmoreComponent], entryComponents: [LoadmoreComponent], }) -export class LoadmoreModule { - static forRoot(): ModuleWithProviders { - return { ngModule: LoadmoreModule, providers: [LoadmoreConfig] }; - } -} +export class LoadmoreModule {} diff --git a/components/loadmore/package.json b/components/loadmore/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/loadmore/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/mask/mask.component.html b/components/mask/mask.component.html new file mode 100644 index 0000000..349a630 --- /dev/null +++ b/components/mask/mask.component.html @@ -0,0 +1,8 @@ +
+
+
+
+ +
+
+
diff --git a/components/mask/mask.component.ts b/components/mask/mask.component.ts index a65372a..bea27df 100644 --- a/components/mask/mask.component.ts +++ b/components/mask/mask.component.ts @@ -1,29 +1,32 @@ import { + ChangeDetectionStrategy, + ChangeDetectorRef, Component, - Input, EventEmitter, - Output, + Input, OnDestroy, + Output, + ViewEncapsulation, } from '@angular/core'; +import { InputBoolean } from 'ngx-weui/core'; import { Observable, Observer, Subscription } from 'rxjs'; @Component({ selector: 'weui-mask', - template: ` -
-
-
-
- -
-
-
`, + exportAs: 'weuiMask', + templateUrl: './mask.component.html', + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class MaskComponent implements OnDestroy { + private observer: Observer; + _shown: boolean = false; + /** * 点击是否允许关闭(默认:`false`) */ - @Input() backdrop: boolean = false; + @Input() @InputBoolean() backdrop: boolean = false; /** * 内容方向(默认:`vertical`) @@ -35,13 +38,7 @@ export class MaskComponent implements OnDestroy { * + `none`: 无 */ @Input() - placement: - | 'top' - | 'bottom' - | 'vertical' - | 'vertical-left' - | 'vertical-right' - | 'none' = 'vertical'; + placement: 'top' | 'bottom' | 'vertical' | 'vertical-left' | 'vertical-right' | 'none' = 'vertical'; /** * 内容背景色 @@ -51,15 +48,14 @@ export class MaskComponent implements OnDestroy { /** * 内容为Loading效果(默认:`false`) */ - @Input() loading = false; + @Input() @InputBoolean() loading = false; /** * 关闭回调 */ - @Output() close = new EventEmitter(); + @Output() readonly close = new EventEmitter(); - private observer: Observer; - _shown: boolean = false; + constructor(private cdr: ChangeDetectorRef) {} /** * 显示,并返回一个Observable @@ -67,6 +63,7 @@ export class MaskComponent implements OnDestroy { show(): Observable { setTimeout(() => { this._shown = true; + this.cdr.detectChanges(); }); return Observable.create((observer: Observer) => { this.observer = observer; @@ -82,12 +79,13 @@ export class MaskComponent implements OnDestroy { if (is_backdrop === true && this.backdrop === false) return false; this._shown = false; + this.cdr.detectChanges(); this.close.emit(); } ngOnDestroy(): void { if (this.observer && this.observer instanceof Subscription) { - (this.observer).unsubscribe(); + (this.observer as Subscription).unsubscribe(); } } } diff --git a/components/mask/mask.module.ts b/components/mask/mask.module.ts index 6f945cb..467bf4c 100644 --- a/components/mask/mask.module.ts +++ b/components/mask/mask.module.ts @@ -1,5 +1,5 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { MaskComponent } from './mask.component'; @NgModule({ @@ -8,8 +8,4 @@ import { MaskComponent } from './mask.component'; exports: [MaskComponent], entryComponents: [MaskComponent], }) -export class MaskModule { - static forRoot(): ModuleWithProviders { - return { ngModule: MaskModule, providers: [] }; - } -} +export class MaskModule {} diff --git a/components/mask/mask.spec.ts b/components/mask/mask.spec.ts index a7016db..7f2be44 100644 --- a/components/mask/mask.spec.ts +++ b/components/mask/mask.spec.ts @@ -1,76 +1,59 @@ -import { By } from '@angular/platform-browser'; import { Component, DebugElement, ViewChild } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - ComponentFixtureAutoDetect, -} from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; -import { MaskModule, MaskComponent } from '../mask'; +import { MaskComponent, MaskModule } from '../mask'; const html = ``; describe('Component: Button', () => { let fixture: ComponentFixture; let context: TestMaskComponent; - let el: HTMLElement; let dl: DebugElement; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestMaskComponent], - imports: [MaskModule.forRoot(), FormsModule], - providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], - }); - TestBed.overrideComponent(TestMaskComponent, { set: { template: html } }); - fixture = TestBed.createComponent(TestMaskComponent); - context = fixture.componentInstance; - spyOn(context, 'close'); - el = fixture.nativeElement; - dl = fixture.debugElement; - fixture.detectChanges(); - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestMaskComponent], + imports: [MaskModule, FormsModule], + providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }], + }); + TestBed.overrideComponent(TestMaskComponent, { set: { template: html } }); + fixture = TestBed.createComponent(TestMaskComponent); + context = fixture.componentInstance; + spyOn(context, 'close'); + dl = fixture.debugElement; + fixture.detectChanges(); + tick(); + })); it('should be inited', () => { expect(fixture).not.toBeUndefined(); }); - it( - 'should closed via backdrop', - fakeAsync(() => { - const maskEl = dl.queryAll(By.css('.weui-mask'))[0]; - context.mask.show().subscribe(); - fixture.detectChanges(); - tick(10); - expect(context.mask._shown).toBe(true); - (maskEl.nativeElement as HTMLDivElement).click(); - fixture.detectChanges(); - expect(context.close).toHaveBeenCalled(); - expect(context.mask._shown).toBe(false); - }), - ); + it('should closed via backdrop', fakeAsync(() => { + const maskEl = dl.queryAll(By.css('.weui-mask'))[0]; + context.mask.show().subscribe(); + fixture.detectChanges(); + tick(10); + expect(context.mask._shown).toBe(true); + (maskEl.nativeElement as HTMLDivElement).click(); + fixture.detectChanges(); + expect(context.close).toHaveBeenCalled(); + expect(context.mask._shown).toBe(false); + })); - it( - 'should not-allow closing via backdrop', - fakeAsync(() => { - context.backdrop = false; - fixture.detectChanges(); - tick(10); - const maskEl = dl.queryAll(By.css('.weui-mask'))[0]; - context.mask.show().subscribe(); - fixture.detectChanges(); - tick(10); - context.mask.hide(true); - expect(context.mask._shown).toBe(true); - expect(context.close).not.toHaveBeenCalled(); - }), - ); + it('should not-allow closing via backdrop', fakeAsync(() => { + context.backdrop = false; + fixture.detectChanges(); + tick(10); + context.mask.show().subscribe(); + fixture.detectChanges(); + tick(10); + context.mask.hide(true); + expect(context.mask._shown).toBe(true); + expect(context.close).not.toHaveBeenCalled(); + })); }); @Component({ template: `` }) diff --git a/components/mask/package.json b/components/mask/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/mask/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/ng-package.json b/components/ng-package.json index 5634ba5..509d468 100644 --- a/components/ng-package.json +++ b/components/ng-package.json @@ -3,11 +3,10 @@ "dest": "../publish", "deleteDestPath": true, "lib": { - "entryFile": "ngx-weui.module.ts" + "entryFile": "./ngx-weui.module.ts", + "umdModuleIds": { + "ngx-weui/version": "ngx-weui/version" + } }, - "whitelistedNonPeerDependencies": [ - "tslib", - "angular", - "weui" - ] -} \ No newline at end of file + "whitelistedNonPeerDependencies": ["tslib", "weui"] +} diff --git a/components/ngx-weui.module.ts b/components/ngx-weui.module.ts index 9741f66..a322959 100644 --- a/components/ngx-weui.module.ts +++ b/components/ngx-weui.module.ts @@ -1,130 +1,92 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; -import { CellModule } from './cell/cell.module'; -import { ButtonModule } from './button/button.module'; -import { FormModule } from './form/form.module'; -import { SliderModule } from './slider/slider.module'; -import { UploaderModule } from './uploader/uploader.module'; -import { ActionSheetModule } from './actionsheet/actionsheet.module'; -import { DialogModule } from './dialog/dialog.module'; -import { LoadmoreModule } from './loadmore/loadmore.module'; -import { ProgressModule } from './progress/progress.module'; -import { GalleryModule } from './gallery/gallery.module'; -import { PickerModule } from './picker/picker.module'; -import { SearchBarModule } from './searchbar/searchbar.module'; -import { TabModule } from './tab/tab.module'; -import { ToastModule } from './toast/toast.module'; -import { ToptipsModule } from './toptips/toptips.module'; -import { PopupModule } from './popup/popup.module'; -import { PTRModule } from './ptr/ptr.module'; -import { InfiniteLoaderModule } from './infiniteloader/infiniteloader.module'; -import { SidebarModule } from './sidebar/sidebar.module'; -import { SwiperModule } from './swiper/swiper.module'; -import { ChartG2Module } from './chart-g2/chart-g2.module'; -import { JWeiXinModule } from './jweixin/jweixin.module'; -import { AccordionModule } from './accordion/accordion.module'; -import { MaskModule } from './mask/mask.module'; -import { RatingModule } from './rating/rating.module'; -import { StepperModule } from './stepper/stepper.module'; -import { PaginationModule } from './pagination/pagination.module'; +import { AccordionModule } from 'ngx-weui/accordion'; +import { ActionSheetModule } from 'ngx-weui/actionsheet'; +import { ButtonModule } from 'ngx-weui/button'; +import { CellModule } from 'ngx-weui/cell'; +import { ChartG2Module } from 'ngx-weui/chart-g2'; +import { DialogModule } from 'ngx-weui/dialog'; +import { FormModule } from 'ngx-weui/form'; +import { GalleryModule } from 'ngx-weui/gallery'; +import { InfiniteLoaderModule } from 'ngx-weui/infiniteloader'; +import { JWeiXinModule } from 'ngx-weui/jweixin'; +import { LoadmoreModule } from 'ngx-weui/loadmore'; +import { MaskModule } from 'ngx-weui/mask'; +import { PaginationModule } from 'ngx-weui/pagination'; +import { PickerModule } from 'ngx-weui/picker'; +import { PopupModule } from 'ngx-weui/popup'; +import { ProgressModule } from 'ngx-weui/progress'; +import { PTRModule } from 'ngx-weui/ptr'; +import { RatingModule } from 'ngx-weui/rating'; +import { SearchBarModule } from 'ngx-weui/searchbar'; +import { SidebarModule } from 'ngx-weui/sidebar'; +import { SliderModule } from 'ngx-weui/slider'; +import { StepperModule } from 'ngx-weui/stepper'; +import { SwiperModule } from 'ngx-weui/swiper'; +import { TabModule } from 'ngx-weui/tab'; +import { ToastModule } from 'ngx-weui/toast'; +import { ToptipsModule } from 'ngx-weui/toptips'; +import { UploaderModule } from 'ngx-weui/uploader'; -export * from './utils/types'; -export * from './cell'; -export * from './button'; -export * from './form'; -export * from './slider'; -export * from './uploader'; -export * from './actionsheet'; -export * from './dialog'; -export * from './loadmore'; -export * from './progress'; -export * from './gallery'; -export * from './picker'; -export * from './searchbar'; -export * from './tab'; -export * from './toast'; -export * from './toptips'; -export * from './popup'; -export * from './ptr'; -export * from './infiniteloader'; -export * from './sidebar'; -export * from './swiper'; -export * from './chart-g2'; -export * from './jweixin'; -export * from './accordion'; -export * from './mask'; -export * from './rating'; -export * from './stepper'; -export * from './pagination'; -export * from './version'; - -const MODULES = [ - CellModule, - ButtonModule, - FormModule, - SliderModule, - UploaderModule, - ActionSheetModule, - DialogModule, - LoadmoreModule, - ProgressModule, - GalleryModule, - PickerModule, - SearchBarModule, - TabModule, - ToastModule, - ToptipsModule, - PopupModule, - PTRModule, - InfiniteLoaderModule, - SidebarModule, - SwiperModule, - ChartG2Module, - JWeiXinModule, - AccordionModule, - MaskModule, - RatingModule, - StepperModule, - PaginationModule, -]; +export * from 'ngx-weui/core'; +export * from 'ngx-weui/cell'; +export * from 'ngx-weui/button'; +export * from 'ngx-weui/form'; +export * from 'ngx-weui/slider'; +export * from 'ngx-weui/uploader'; +export * from 'ngx-weui/actionsheet'; +export * from 'ngx-weui/dialog'; +export * from 'ngx-weui/loadmore'; +export * from 'ngx-weui/progress'; +export * from 'ngx-weui/gallery'; +export * from 'ngx-weui/picker'; +export * from 'ngx-weui/searchbar'; +export * from 'ngx-weui/tab'; +export * from 'ngx-weui/toast'; +export * from 'ngx-weui/toptips'; +export * from 'ngx-weui/popup'; +export * from 'ngx-weui/ptr'; +export * from 'ngx-weui/infiniteloader'; +export * from 'ngx-weui/sidebar'; +export * from 'ngx-weui/swiper'; +export * from 'ngx-weui/chart-g2'; +export * from 'ngx-weui/jweixin'; +export * from 'ngx-weui/accordion'; +export * from 'ngx-weui/mask'; +export * from 'ngx-weui/rating'; +export * from 'ngx-weui/stepper'; +export * from 'ngx-weui/pagination'; +export * from 'ngx-weui/version'; @NgModule({ - imports: [ - CellModule.forRoot(), - ButtonModule.forRoot(), - FormModule.forRoot(), - SliderModule.forRoot(), - UploaderModule.forRoot(), - ActionSheetModule.forRoot(), - DialogModule.forRoot(), - LoadmoreModule.forRoot(), - ProgressModule.forRoot(), - GalleryModule.forRoot(), - PickerModule.forRoot(), - SearchBarModule.forRoot(), - TabModule.forRoot(), - ToastModule.forRoot(), - ToptipsModule.forRoot(), - PopupModule.forRoot(), - PTRModule.forRoot(), - InfiniteLoaderModule.forRoot(), - SidebarModule.forRoot(), - SwiperModule.forRoot(), - ChartG2Module.forRoot(), - JWeiXinModule.forRoot(), - AccordionModule.forRoot(), - MaskModule.forRoot(), - RatingModule.forRoot(), - StepperModule.forRoot(), - PaginationModule.forRoot(), + exports: [ + CellModule, + ButtonModule, + FormModule, + SliderModule, + UploaderModule, + ActionSheetModule, + DialogModule, + LoadmoreModule, + ProgressModule, + GalleryModule, + PickerModule, + SearchBarModule, + TabModule, + ToastModule, + ToptipsModule, + PopupModule, + PTRModule, + InfiniteLoaderModule, + SidebarModule, + SwiperModule, + ChartG2Module, + JWeiXinModule, + AccordionModule, + MaskModule, + RatingModule, + StepperModule, + PaginationModule, ], - exports: MODULES, }) -export class WeUiRootModule { } - -@NgModule({ exports: MODULES }) -export class WeUiModule { - static forRoot(): ModuleWithProviders { - return { ngModule: WeUiRootModule }; - } -} +export class WeUiModule {} diff --git a/components/package.json b/components/package.json index 98c2598..6d29065 100644 --- a/components/package.json +++ b/components/package.json @@ -27,14 +27,7 @@ }, "homepage": "https://github.com/cipchk/ngx-weui#readme", "dependencies": { - "weui": "^1.1.3" - }, - "peerDependencies": { - "@angular/animations": "^7.0.0", - "@angular/common": "^7.0.0", - "@angular/core": "^7.0.0", - "@angular/forms": "^7.0.0", - "typescript": "~3.1.1" + "weui": "^2.0.0" }, "schematics": "./schematics/collection.json", "ng-update": { diff --git a/components/pagination/package.json b/components/pagination/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/pagination/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/pagination/pagination.component.html b/components/pagination/pagination.component.html new file mode 100644 index 0000000..5da1fcb --- /dev/null +++ b/components/pagination/pagination.component.html @@ -0,0 +1,30 @@ + +
+ +
+
{{ current }}/{{ total }}
+
+ +
+
+
+
+ +
+
diff --git a/components/pagination/pagination.component.ts b/components/pagination/pagination.component.ts index be62723..0b36076 100644 --- a/components/pagination/pagination.component.ts +++ b/components/pagination/pagination.component.ts @@ -1,52 +1,48 @@ import { + ChangeDetectionStrategy, Component, - Input, - Output, EventEmitter, + Input, OnChanges, - SimpleChanges, + Output, + ViewEncapsulation, } from '@angular/core'; -import { PaginationMode } from './pagination.type'; +import { InputBoolean, InputNumber } from 'ngx-weui/core'; import { PaginationConfig } from './pagination.config'; +import { PaginationMode } from './pagination.type'; @Component({ selector: 'weui-pagination', - template: ` - -
- -
-
{{current}}/{{total}}
-
- -
-
-
-
-
- `, + exportAs: 'weuiPagination', + templateUrl: './pagination.component.html', host: { class: 'weui-pagination', + '[class.weui-pagination__non-mini]': '!mini', }, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class PaginationComponent implements OnChanges { _ptArr: number[] = []; + _prevDisabled = false; + _nextDisabled = false; /** * 形态,可选 `button`,`pointer`,默认:`button` */ @Input() mode: PaginationMode; /** 当前索引 */ - @Input() current: number = 0; + @Input() @InputNumber() current: number = 0; /** 数据总数 */ - @Input() total: number = 0; + @Input() @InputNumber() total: number = 0; /** * 是否隐藏数值,默认:`false` */ - @Input() simple: boolean; + @Input() @InputBoolean() simple: boolean; /** * 小号按钮,默认:`true` */ - @Input() mini: boolean = true; + @Input() @InputBoolean() mini: boolean = true; /** * 上一页文本(支持HTML),默认:`上一页` */ @@ -56,13 +52,13 @@ export class PaginationComponent implements OnChanges { */ @Input() nextText: string; /** 分页触发的回调函数 */ - @Output() change = new EventEmitter(); + @Output() readonly change = new EventEmitter(); constructor(cog: PaginationConfig) { Object.assign(this, cog); } - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { if (this.mode === 'pointer') this._ptArr = Array(this.total) .fill(1) @@ -70,8 +66,6 @@ export class PaginationComponent implements OnChanges { this._checkDisabled(); } - _prevDisabled = false; - _nextDisabled = false; _checkDisabled() { if (this.mode === 'pointer') return; this._prevDisabled = this.current <= 1; diff --git a/components/pagination/pagination.config.ts b/components/pagination/pagination.config.ts index 0a11570..bbb794a 100644 --- a/components/pagination/pagination.config.ts +++ b/components/pagination/pagination.config.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { PaginationMode } from './pagination.type'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class PaginationConfig { /** * 形态,可选 `button`,`pointer`,默认:`button` diff --git a/components/pagination/pagination.module.ts b/components/pagination/pagination.module.ts index b91457f..31cb352 100644 --- a/components/pagination/pagination.module.ts +++ b/components/pagination/pagination.module.ts @@ -1,17 +1,12 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; -import { FormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; -import { ButtonModule } from './../button/button.module'; +import { NgModule } from '@angular/core'; +import { ButtonModule } from 'ngx-weui/button'; + import { PaginationComponent } from './pagination.component'; -import { PaginationConfig } from './pagination.config'; @NgModule({ - imports: [CommonModule, ButtonModule.forRoot()], + imports: [CommonModule, ButtonModule], declarations: [PaginationComponent], exports: [PaginationComponent], }) -export class PaginationModule { - static forRoot(): ModuleWithProviders { - return { ngModule: PaginationModule, providers: [PaginationConfig] }; - } -} +export class PaginationModule {} diff --git a/components/pagination/style/index.less b/components/pagination/style/index.less index 3b6f74a..fc1ef11 100644 --- a/components/pagination/style/index.less +++ b/components/pagination/style/index.less @@ -1,11 +1,13 @@ -.weui-pagination { +@weui-pagination-prefix: ~'.weui-pagination'; + +@{weui-pagination-prefix} { display: flex; align-items: center; - text-align: left; overflow-y: hidden; + text-align: left; &__item { - box-sizing: border-box; flex: 1; + box-sizing: border-box; min-width: 10px; margin-left: 8px; &:first-child { @@ -34,8 +36,8 @@ width: @pagination-dot-wh; height: @pagination-dot-wh; margin-right: 5px; - border-radius: 50%; background: @pagination-dot-bg; + border-radius: 50%; } &-active { > span { @@ -43,4 +45,9 @@ } } } + &__non-mini { + .weui-btn { + width: auto; + } + } } diff --git a/components/picker/options.ts b/components/picker/options.ts index 22adb41..a7ada9e 100644 --- a/components/picker/options.ts +++ b/components/picker/options.ts @@ -1,6 +1,3 @@ -import { Observable } from 'rxjs'; -import { PickerData } from './data'; - export interface PickerOptions { /** * 类型 diff --git a/components/picker/package.json b/components/picker/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/picker/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/picker/picker-city.component.ts b/components/picker/picker-city.component.ts index 9b96973..e7d8532 100644 --- a/components/picker/picker-city.component.ts +++ b/components/picker/picker-city.component.ts @@ -1,13 +1,16 @@ import { - Component, - Input, - Output, forwardRef, + ChangeDetectionStrategy, + Component, EventEmitter, + Input, OnDestroy, + Output, ViewChild, + ViewEncapsulation, } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { InputBoolean } from 'ngx-weui/core'; import { PickerOptions } from './options'; import { PickerComponent } from './picker.component'; @@ -16,14 +19,20 @@ import { PickerComponent } from './picker.component'; */ @Component({ selector: 'weui-city-picker', + exportAs: 'weuiCityPicker', template: ` - + (cancel)="_onCityCancelChange()" + > `, providers: [ { @@ -32,12 +41,15 @@ import { PickerComponent } from './picker.component'; multi: true, }, ], + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class CityPickerComponent implements ControlValueAccessor, OnDestroy { @ViewChild(PickerComponent) _pickerInstance: PickerComponent; _value: string; - _groups: any[] = []; + _groups: any[] | null = []; _selected: number[] = []; private _tmpData: any; @@ -57,34 +69,28 @@ export class CityPickerComponent implements ControlValueAccessor, OnDestroy { @Input() options: PickerOptions; /** 当options.type=='form'时,占位符文本 */ @Input() placeholder: string; - @Input() disabled: boolean; + @Input() @InputBoolean() disabled: boolean; /** * 确认后回调当前选择数据(包括已选面板所有数据) * * `{ value: '10000', items: [ {}, {}, {} ] }` */ - @Output() change = new EventEmitter(); + @Output() readonly change = new EventEmitter(); /** 列变更时回调 */ - @Output() groupChange = new EventEmitter(); + @Output() readonly groupChange = new EventEmitter(); /** 取消后回调 */ - @Output() cancel = new EventEmitter(); + @Output() readonly cancel = new EventEmitter(); /** 显示时回调 */ - @Output() show = new EventEmitter(); + @Output() readonly show = new EventEmitter(); /** 隐藏后回调 */ - @Output() hide = new EventEmitter(); + @Output() readonly hide = new EventEmitter(); ngOnDestroy(): void { this._tmpData = null; this._groups = null; } - private parseData( - data: any, - subKey: any, - selected: any[] = [], - group: any[] = [], - newselected: any[] = [], - ): any { + private parseData(data: any, subKey: any, selected: any[] = [], group: any[] = [], newselected: any[] = []): any { let _selected = 0; if (Array.isArray(selected) && selected.length > 0) { @@ -121,12 +127,7 @@ export class CityPickerComponent implements ControlValueAccessor, OnDestroy { /** * 将值转换成位置 */ - private valueToSelect( - data: any, - subKey: any, - dept: number = 1, - newSelected: any[] = [], - ): any { + private valueToSelect(data: any, subKey: any, dept: number = 1, newSelected: any[] = []): any { const code = (this._value.substr(0, dept * 2) + '0000').substr(0, 6); let _selected = data.findIndex((w: any) => w[this.dataMap.value] === code); if (_selected <= -1) { @@ -155,8 +156,7 @@ export class CityPickerComponent implements ControlValueAccessor, OnDestroy { _onCityGroupChange(res: any) { this._selected[res.groupIndex] = res.index; - if (res.groupIndex !== 2) - this.parseData(this._tmpData, this.dataMap.items, this._selected); + if (res.groupIndex !== 2) this.parseData(this._tmpData, this.dataMap.items, this._selected); this.groupChange.emit(res); } @@ -193,10 +193,10 @@ export class CityPickerComponent implements ControlValueAccessor, OnDestroy { private onChange: any = Function.prototype; private onTouched: any = Function.prototype; - public registerOnChange(fn: (_: any) => {}): void { + registerOnChange(fn: (_: any) => {}): void { this.onChange = fn; } - public registerOnTouched(fn: () => {}): void { + registerOnTouched(fn: () => {}): void { this.onTouched = fn; } diff --git a/components/picker/picker-date.component.ts b/components/picker/picker-date.component.ts index 81c3ecd..184c7c7 100644 --- a/components/picker/picker-date.component.ts +++ b/components/picker/picker-date.component.ts @@ -1,19 +1,19 @@ +import { DatePipe } from '@angular/common'; import { - Component, - Input, - Output, forwardRef, + ChangeDetectionStrategy, + Component, EventEmitter, - OnDestroy, - ViewChild, - LOCALE_ID, + Input, OnChanges, - SimpleChanges, - ElementRef, + OnDestroy, OnInit, + Output, + ViewChild, + ViewEncapsulation, } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import { DatePipe } from '@angular/common'; +import { InputBoolean } from 'ngx-weui/core'; import { PickerOptions } from './options'; import { PickerComponent } from './picker.component'; @@ -31,27 +31,33 @@ export type DatePickerType = 'date-ym' | 'date' | 'datetime' | 'time'; export type FORMAT_TYPE = | string | { - format: string; - yu?: string; - Mu?: string; - du?: string; - hu?: string; - mu?: string; - }; + format: string; + yu?: string; + Mu?: string; + du?: string; + hu?: string; + mu?: string; + }; /** * 日期时间选择器 */ @Component({ selector: 'weui-date-picker', + exportAs: 'weuiDatePicker', template: ` - + (cancel)="_onCityCancelChange()" + > `, providers: [ DatePipe, @@ -61,9 +67,11 @@ export type FORMAT_TYPE = multi: true, }, ], + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) -export class DatePickerComponent - implements OnInit, ControlValueAccessor, OnDestroy, OnChanges { +export class DatePickerComponent implements OnInit, ControlValueAccessor, OnDestroy, OnChanges { @ViewChild(PickerComponent) _pickerInstance: PickerComponent; _value: Date; @@ -91,18 +99,16 @@ export class DatePickerComponent */ @Input() type: DatePickerType = 'date'; - private _format: any = Object.assign({}, FORMAT); + private _format: any = { ...FORMAT }; /** * 日期格式化代码,实际是采用 DatePipe,所有代码内容和它一样 */ @Input() set format(v: FORMAT_TYPE) { if (typeof v === 'string') { - this._format = Object.assign(FORMAT, { - format: v, - }); + this._format = { ...FORMAT, format: v }; } else { - this._format = Object.assign(FORMAT, v); + this._format = { ...FORMAT, ...v }; } } @@ -110,19 +116,19 @@ export class DatePickerComponent @Input() options: PickerOptions; /** 当options.type=='form'时,占位符文本 */ @Input() placeholder: string; - @Input() disabled: boolean; + @Input() @InputBoolean() disabled: boolean; /** 确认后回调 */ - @Output() change = new EventEmitter(); + @Output() readonly change = new EventEmitter(); /** 列变更时回调 */ - @Output() groupChange = new EventEmitter(); + @Output() readonly groupChange = new EventEmitter(); /** 取消后回调 */ - @Output() cancel = new EventEmitter(); + @Output() readonly cancel = new EventEmitter(); /** 显示时回调 */ - @Output() show = new EventEmitter(); + @Output() readonly show = new EventEmitter(); /** 隐藏后回调 */ - @Output() hide = new EventEmitter(); + @Output() readonly hide = new EventEmitter(); - constructor(private el: ElementRef, private datePipe: DatePipe) { } + constructor(private datePipe: DatePipe) {} // todo: 太粗暴,需要优化代码 private genGroups() { @@ -134,41 +140,41 @@ export class DatePickerComponent } private genDateGroups() { - const year = this._value.getFullYear(), - month = this._value.getMonth() + 1, - day = this._value.getDate(); + const year = this._value.getFullYear(); + const month = this._value.getMonth() + 1; + const day = this._value.getDate(); // year - let _selected = 0, - startYear = year - 10, - endYear = year + 10; + let _selected = 0; + let startYear = year - 10; + let endYear = year + 10; if (this.min) startYear = this.min.getFullYear(); if (this.max) endYear = this.max.getFullYear(); this._groups.push( Array(endYear - startYear + 1) .fill(0) - .map((v: number, idx: number) => { - const _v = startYear + idx; - if (_v === year) _selected = idx; - return { label: _v + this._format.yu, value: _v }; + .map((_v: number, idx: number) => { + const val = startYear + idx; + if (val === year) _selected = idx; + return { label: val + this._format.yu, value: val }; }), ); this._selected.push(_selected); // month const cy = this._groups[0][_selected].value; - let startMonth = 1, - endMonth = 12; + let startMonth = 1; + let endMonth = 12; if (cy === startYear) startMonth = this.min.getMonth() + 1; if (cy === endYear) endMonth = this.max.getMonth() + 1; _selected = 0; this._groups.push( Array(endMonth - startMonth + 1) .fill(0) - .map((v: number, idx: number) => { - const _v = startMonth + idx; - if (_v === month) _selected = idx; - return { label: _v + this._format.Mu, value: _v }; + .map((_v: number, idx: number) => { + const val = startMonth + idx; + if (val === month) _selected = idx; + return { label: val + this._format.Mu, value: val }; }), ); this._selected.push(_selected); @@ -176,18 +182,18 @@ export class DatePickerComponent // day if (this.type !== 'date-ym') { const cm = this._groups[1][_selected].value; - let startDay = 1, - endDay = new Date(year, month, 0).getDate(); + let startDay = 1; + let endDay = new Date(year, month, 0).getDate(); if (cy === startYear && cm === startMonth) startDay = this.min.getDate(); if (cy === endYear && cm === endMonth) endDay = this.max.getDate(); _selected = 0; this._groups.push( Array(endDay - startDay + 1) .fill(0) - .map((v: number, idx: number) => { - const _v = startDay + idx; - if (_v === day) _selected = idx; - return { label: _v + this._format.du, value: _v }; + .map((_v: number, idx: number) => { + const val = startDay + idx; + if (val === day) _selected = idx; + return { label: val + this._format.du, value: val }; }), ); this._selected.push(_selected); @@ -195,17 +201,17 @@ export class DatePickerComponent } private genDateTimeGroups() { - const hours = this._value.getHours(), - minutes = this._value.getMinutes(); + const hours = this._value.getHours(); + const minutes = this._value.getMinutes(); // hours let _selected = 0; this._groups.push( Array(24) .fill(0) - .map((v: number, idx: number) => { - const _v = idx; - if (_v === hours) _selected = idx; - return { label: _v + this._format.hu, value: _v }; + .map((_v: number, idx: number) => { + const val = idx; + if (val === hours) _selected = idx; + return { label: val + this._format.hu, value: val }; }), ); this._selected.push(_selected); @@ -215,10 +221,10 @@ export class DatePickerComponent this._groups.push( Array(60) .fill(0) - .map((v: number, idx: number) => { - const _v = idx; - if (_v === minutes) _selected = idx; - return { label: _v + this._format.mu, value: _v }; + .map((_v: number, idx: number) => { + const val = idx; + if (val === minutes) _selected = idx; + return { label: val + this._format.mu, value: val }; }), ); this._selected.push(_selected); @@ -255,11 +261,11 @@ export class DatePickerComponent } ngOnDestroy(): void { - this._groups = null; + this._groups.length = 0; } private getFormatDate(date: Date) { - let f: string = ''; + let f = ''; if (this._format && this._format.format) f = this._format.format; else { switch (this.type) { @@ -313,7 +319,7 @@ export class DatePickerComponent this.genGroups(); } - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { if (this.initFlag) this.genGroups(); } @@ -333,17 +339,16 @@ export class DatePickerComponent writeValue(value: Date): void { if (value) this.genGroups(); this._value = value; - this._pickerInstance._text = - value instanceof Date ? this.getFormatDate(value) : ''; + this._pickerInstance._text = value instanceof Date ? this.getFormatDate(value)! : ''; } private onChange: any = Function.prototype; private onTouched: any = Function.prototype; - public registerOnChange(fn: (_: any) => {}): void { + registerOnChange(fn: (_: any) => {}): void { this.onChange = fn; } - public registerOnTouched(fn: () => {}): void { + registerOnTouched(fn: () => {}): void { this.onTouched = fn; } diff --git a/components/picker/picker-group.component.html b/components/picker/picker-group.component.html new file mode 100644 index 0000000..06f4bbb --- /dev/null +++ b/components/picker/picker-group.component.html @@ -0,0 +1,14 @@ + +
+
+
+
+ {{ item.label || item.value }} +
+
diff --git a/components/picker/picker-group.component.ts b/components/picker/picker-group.component.ts index 30b7219..c71f383 100644 --- a/components/picker/picker-group.component.ts +++ b/components/picker/picker-group.component.ts @@ -1,13 +1,15 @@ import { + ChangeDetectionStrategy, Component, - Input, EventEmitter, - Output, - OnDestroy, HostListener, + Input, OnChanges, + Output, SimpleChanges, + ViewEncapsulation, } from '@angular/core'; +import { InputNumber } from 'ngx-weui/core'; import { PickerData } from './data'; declare const window: any; @@ -20,34 +22,27 @@ const getWindowHeight = (): number => { */ @Component({ selector: 'weui-picker-group', - template: ` - -
-
-
-
{{item.label || item.value}}
-
- `, + exportAs: 'weuiPickerGroup', + templateUrl: './picker-group.component.html', host: { '[class.weui-picker__group]': 'true', }, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) -export class PickerGroupComponent implements OnDestroy, OnChanges { +export class PickerGroupComponent implements OnChanges { /** 数据列表 */ @Input() items: PickerData[]; /** 当前默认位置 */ - @Input() defaultIndex: number = -1; + @Input() @InputNumber() defaultIndex: number = -1; /** 多列中的位置 */ - @Input() groupIndex: number; + @Input() @InputNumber() groupIndex: number; /** 变更回调 */ - @Output() change = new EventEmitter(); + @Output() readonly change = new EventEmitter(); private defaults: any = { offset: 3, // 列表初始化时的偏移量(列表初始化时,选项是聚焦在中间的,通过offset强制往上挪3项,以达到初始选项是为顶部的那项) @@ -66,13 +61,8 @@ export class PickerGroupComponent implements OnDestroy, OnChanges { ngOnChanges(changes: SimpleChanges): void { if ('defaultIndex' in changes) { - if ( - this.defaultIndex < 0 || - (this.items && this.defaultIndex >= this.items.length) - ) - this.defaultIndex = 0; - this._distance = - (this.defaults.offset - this.defaultIndex) * this.defaults.rowHeight; + if (this.defaultIndex < 0 || (this.items && this.defaultIndex >= this.items.length)) this.defaultIndex = 0; + this._distance = (this.defaults.offset - this.defaultIndex) * this.defaults.rowHeight; } } @@ -125,7 +115,7 @@ export class PickerGroupComponent implements OnDestroy, OnChanges { } else { this.stop(0); } - this.startY = null; + this.startY = 0; } private stop(diff: number): void { @@ -134,11 +124,7 @@ export class PickerGroupComponent implements OnDestroy, OnChanges { // 移动到最接近的那一行 dist = Math.round(dist / this.defaults.rowHeight) * this.defaults.rowHeight; const max = this._getMax(this.defaults.offset, this.defaults.rowHeight); - const min = this._getMin( - this.defaults.offset, - this.defaults.rowHeight, - this.items.length, - ); + const min = this._getMin(this.defaults.offset, this.defaults.rowHeight, this.items.length); // 不要超过最大值或者最小值 dist = Math.max(Math.min(dist, max), min); @@ -168,6 +154,4 @@ export class PickerGroupComponent implements OnDestroy, OnChanges { private _getMin(offset: number, rowHeight: number, length: number): number { return -(rowHeight * (length - offset - 1)); } - - ngOnDestroy(): void { } } diff --git a/components/picker/picker.component.html b/components/picker/picker.component.html new file mode 100644 index 0000000..e699c71 --- /dev/null +++ b/components/picker/picker.component.html @@ -0,0 +1,34 @@ + + diff --git a/components/picker/picker.component.ts b/components/picker/picker.component.ts index 01cc2f8..80e2110 100644 --- a/components/picker/picker.component.ts +++ b/components/picker/picker.component.ts @@ -1,46 +1,26 @@ import { - Component, forwardRef, - OnDestroy, - OnChanges, - SimpleChanges, - Input, + ChangeDetectionStrategy, + Component, EventEmitter, - Output, - ElementRef, + Input, + OnChanges, + OnDestroy, OnInit, + Output, + SimpleChanges, + ViewEncapsulation, } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import { Observable, Subscription } from 'rxjs'; +import { InputBoolean } from 'ngx-weui/core'; import { PickerData } from './data'; import { PickerOptions } from './options'; import { PickerConfig } from './picker.config'; @Component({ selector: 'weui-picker', - template: ` - -
-
- -
- `, + exportAs: 'weuiPicker', + templateUrl: './picker.component.html', providers: [ { provide: NG_VALUE_ACCESSOR, @@ -48,9 +28,11 @@ import { PickerConfig } from './picker.config'; multi: true, }, ], + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) -export class PickerComponent - implements ControlValueAccessor, OnInit, OnDestroy, OnChanges { +export class PickerComponent implements ControlValueAccessor, OnInit, OnDestroy, OnChanges { /** 配置项 */ @Input() options: PickerOptions; @@ -71,18 +53,18 @@ export class PickerComponent * 支持string[]单列数组,单纯只是为了方便 */ @Input() - set groups(d: PickerData[][] | String[]) { + set groups(d: PickerData[][] | string[]) { if (!d) throw new Error('无效数据源'); if (d.length > 0) { if (typeof d[0] === 'string') { d = [ - (d).map((v: string) => { + (d as string[]).map((v: string) => { return { label: v, value: v }; }), ]; } } - this._groups = d; + this._groups = d as PickerData[][]; this._selected = this._selected ? this._selected : Array(d.length).fill(0); } @@ -90,23 +72,23 @@ export class PickerComponent /** 当 `options.type==='form'` 时,占位符文本 */ @Input() placeholder: string; - @Input() disabled: boolean = false; + @Input() @InputBoolean() disabled: boolean = false; /** * 确认后回调当前选择数据(包括已选面板所有数据) * * `{ value: '10000', items: [ {}, {}, {} ] }` */ - @Output() change = new EventEmitter(); + @Output() readonly change = new EventEmitter(); /** 列变更时回调 */ - @Output() groupChange = new EventEmitter(); + @Output() readonly groupChange = new EventEmitter(); /** 取消后回调 */ - @Output() cancel = new EventEmitter(); + @Output() readonly cancel = new EventEmitter(); /** 显示时回调 */ - @Output() show = new EventEmitter(); + @Output() readonly show = new EventEmitter(); /** 隐藏后回调 */ - @Output() hide = new EventEmitter(); + @Output() readonly hide = new EventEmitter(); - constructor(private el: ElementRef, private DEF: PickerConfig) { } + constructor(private DEF: PickerConfig) {} ngOnInit() { if (!this.options) this.parseOptions(); @@ -133,18 +115,16 @@ export class PickerComponent } private parseOptions() { - this.options = Object.assign( - { - type: 'form', - cancel: '取消', - confirm: '确定', - backdrop: true, - gruopCount: null, - separator: ' ', - }, - this.DEF, - this.options, - ); + this.options = { + type: 'form', + cancel: '取消', + confirm: '确定', + backdrop: true, + gruopCount: null, + separator: ' ', + ...this.DEF, + ...this.options, + } as PickerOptions; } private getSelecteItem() { @@ -156,12 +136,9 @@ export class PickerComponent return res; } - _setText(res: any[] = null) { - if (res === null) res = this.getSelecteItem(); - if (res.length > 0) - this._text = res - .map((i: any) => i.label || i.value) - .join(this.options.separator); + _setText(res: any[] | null = null) { + if (res == null) res = this.getSelecteItem(); + if (res.length > 0) this._text = res.map((i: any) => i.label || i.value).join(this.options.separator); return this; } @@ -209,7 +186,7 @@ export class PickerComponent } } - ngOnDestroy(): void { } + ngOnDestroy(): void {} writeValue(value: any): void { if (!value) this._text = ''; @@ -223,10 +200,10 @@ export class PickerComponent private onChange: any = Function.prototype; private onTouched: any = Function.prototype; - public registerOnChange(fn: (_: any) => {}): void { + registerOnChange(fn: (_: any) => {}): void { this.onChange = fn; } - public registerOnTouched(fn: () => {}): void { + registerOnTouched(fn: () => {}): void { this.onTouched = fn; } @@ -234,7 +211,7 @@ export class PickerComponent this.disabled = isDisabled; } - _onFocus($event: FocusEvent) { + _onFocus() { arguments[0].target.blur(); } } diff --git a/components/picker/picker.config.ts b/components/picker/picker.config.ts index 3425e50..85ef68b 100644 --- a/components/picker/picker.config.ts +++ b/components/picker/picker.config.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class PickerConfig { /** * 取消按钮文本,默认:`取消` diff --git a/components/picker/picker.module.ts b/components/picker/picker.module.ts index eea1455..d669b4a 100644 --- a/components/picker/picker.module.ts +++ b/components/picker/picker.module.ts @@ -1,36 +1,18 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { PickerComponent } from './picker.component'; -import { PickerGroupComponent } from './picker-group.component'; -import { DatePickerComponent } from './picker-date.component'; +import { NgModule } from '@angular/core'; import { CityPickerComponent } from './picker-city.component'; +import { DatePickerComponent } from './picker-date.component'; +import { PickerGroupComponent } from './picker-group.component'; +import { PickerComponent } from './picker.component'; import { PickerService } from './picker.service'; -import { PickerConfig } from './picker.config'; + +const COMPONENTS = [PickerComponent, PickerGroupComponent, DatePickerComponent, CityPickerComponent]; @NgModule({ imports: [CommonModule], - declarations: [ - PickerComponent, - PickerGroupComponent, - DatePickerComponent, - CityPickerComponent, - ], - exports: [ - PickerComponent, - PickerGroupComponent, - DatePickerComponent, - CityPickerComponent, - ], + declarations: COMPONENTS, + exports: COMPONENTS, providers: [PickerService], - entryComponents: [ - PickerComponent, - PickerGroupComponent, - DatePickerComponent, - CityPickerComponent, - ], + entryComponents: COMPONENTS, }) -export class PickerModule { - static forRoot(): ModuleWithProviders { - return { ngModule: PickerModule, providers: [PickerConfig] }; - } -} +export class PickerModule {} diff --git a/components/picker/picker.service.ts b/components/picker/picker.service.ts index 4bf8c7b..4e3697a 100644 --- a/components/picker/picker.service.ts +++ b/components/picker/picker.service.ts @@ -1,24 +1,19 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { BaseService } from '../utils/base.service'; +import { BaseService } from 'ngx-weui/core'; -import { - FORMAT_TYPE, - DatePickerComponent, - DatePickerType, -} from './picker-date.component'; import { PickerData } from './data'; import { PickerOptions } from './options'; -import { PickerComponent } from './picker.component'; import { CityPickerComponent } from './picker-city.component'; +import { DatePickerComponent, DatePickerType, FORMAT_TYPE } from './picker-date.component'; +import { PickerComponent } from './picker.component'; /** * 多列选择器Service,可直接通过Class构造选择器 */ @Injectable() export class PickerService extends BaseService { - /** * 构建一个多列选择器并显示 * @@ -29,14 +24,14 @@ export class PickerService extends BaseService { * @returns 务必订阅结果才会显示。 */ show( - data: PickerData[][] | String[], + data: PickerData[][] | string[], value?: any, defaultSelect?: number[], options?: PickerOptions, ): Observable { const componentRef = this.build(PickerComponent); // 通过Service打开的强制设置为 `default` 以免出现 `input` - options = Object.assign({}, options, { type: 'default' }); + options = { ...options, type: 'default' }; componentRef.instance.options = options; if (defaultSelect) componentRef.instance.defaultSelect = defaultSelect; componentRef.instance.groups = data; @@ -63,16 +58,11 @@ export class PickerService extends BaseService { * @param options 配置项 * @returns 务必订阅结果才会显示。 */ - showCity( - data: any, - value?: string, - dataMap?: any, - options?: PickerOptions, - ): Observable { + showCity(data: any, value?: string, dataMap?: any, options?: PickerOptions): Observable { const componentRef = this.build(CityPickerComponent); if (dataMap) componentRef.instance.dataMap = dataMap; // 通过Service打开的强制设置为 `default` 以免出现 `input` - options = Object.assign({}, options, { type: 'default' }); + options = { ...options, type: 'default' }; componentRef.instance.options = options; componentRef.instance.data = data; if (value) { @@ -112,7 +102,7 @@ export class PickerService extends BaseService { ): Observable { const componentRef = this.build(DatePickerComponent); // 通过Service打开的强制设置为 `default` 以免出现 `input` - options = Object.assign({}, options, { type: 'default' }); + options = { ...options, type: 'default' }; componentRef.instance.options = options; if (type) componentRef.instance.type = type; if (format) componentRef.instance.format = format; @@ -129,7 +119,7 @@ export class PickerService extends BaseService { }, 100); }); setTimeout(() => { - componentRef.instance.ngOnChanges(null); + componentRef.instance.ngOnChanges(); componentRef.instance._triggerShow(); }, 200); return componentRef.instance.change; diff --git a/components/picker/public-api.ts b/components/picker/public-api.ts index 51340a5..f3d53ca 100644 --- a/components/picker/public-api.ts +++ b/components/picker/public-api.ts @@ -1,9 +1,9 @@ -export { PickerOptions } from './options'; -export { PickerData } from './data'; -export { PickerConfig } from './picker.config'; -export { PickerGroupComponent } from './picker-group.component'; -export { PickerComponent } from './picker.component'; -export { CityPickerComponent } from './picker-city.component'; -export { DatePickerComponent, DatePickerType } from './picker-date.component'; -export { PickerService } from './picker.service'; -export { PickerModule } from './picker.module'; +export * from './options'; +export * from './data'; +export * from './picker.config'; +export * from './picker-group.component'; +export * from './picker.component'; +export * from './picker-city.component'; +export * from './picker-date.component'; +export * from './picker.service'; +export * from './picker.module'; diff --git a/components/polyfills.ts b/components/polyfills.ts index 3560e4f..e58188f 100644 --- a/components/polyfills.ts +++ b/components/polyfills.ts @@ -1,3 +1,4 @@ +// tslint:disable:no-import-side-effect /** * This file includes polyfills needed by Angular and is loaded before the app. * You can add your own extra polyfills to this file. @@ -19,20 +20,20 @@ */ /** IE9, IE10 and IE11 requires all of the following polyfills. **/ -import 'core-js/es6/symbol'; -import 'core-js/es6/object'; +import 'core-js/es6/array'; +import 'core-js/es6/date'; import 'core-js/es6/function'; -import 'core-js/es6/parse-int'; -import 'core-js/es6/parse-float'; -import 'core-js/es6/number'; +import 'core-js/es6/map'; import 'core-js/es6/math'; -import 'core-js/es6/string'; -import 'core-js/es6/date'; -import 'core-js/es6/array'; +import 'core-js/es6/number'; +import 'core-js/es6/object'; +import 'core-js/es6/parse-float'; +import 'core-js/es6/parse-int'; import 'core-js/es6/regexp'; -import 'core-js/es6/map'; -import 'core-js/es6/weak-map'; import 'core-js/es6/set'; +import 'core-js/es6/string'; +import 'core-js/es6/symbol'; +import 'core-js/es6/weak-map'; /** IE10 and IE11 requires the following for NgClass support on SVG elements */ // import 'classlist.js'; // Run `npm install --save classlist.js`. @@ -40,12 +41,10 @@ import 'core-js/es6/set'; /** IE10 and IE11 requires the following for the Reflect API. */ import 'core-js/es6/reflect'; - /** Evergreen browsers require these. **/ // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. import 'core-js/es7/reflect'; - /** * Web Animations `@angular/platform-browser/animations` * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. @@ -63,17 +62,15 @@ import 'core-js/es7/reflect'; // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames /* -* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js -* with the following flag, it will bypass `zone.js` patch for IE/Edge -*/ + * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js + * with the following flag, it will bypass `zone.js` patch for IE/Edge + */ // (window as any).__Zone_enable_cross_context_check = true; /*************************************************************************************************** * Zone JS is required by default for Angular itself. */ -import 'zone.js/dist/zone'; // Included with Angular CLI. - - +import 'zone.js/dist/zone'; // Included with Angular CLI. /*************************************************************************************************** * APPLICATION IMPORTS diff --git a/components/popup/package.json b/components/popup/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/popup/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/popup/popup.component.html b/components/popup/popup.component.html new file mode 100644 index 0000000..0b10fa8 --- /dev/null +++ b/components/popup/popup.component.html @@ -0,0 +1,10 @@ +
+ diff --git a/components/popup/popup.component.ts b/components/popup/popup.component.ts index 3c7e607..3eaa898 100644 --- a/components/popup/popup.component.ts +++ b/components/popup/popup.component.ts @@ -1,37 +1,24 @@ +import { animate, state, style, transition, trigger } from '@angular/animations'; import { + ChangeDetectionStrategy, + ChangeDetectorRef, Component, - OnDestroy, - Output, - Input, EventEmitter, + Input, OnChanges, - SimpleChanges, + OnDestroy, OnInit, + Output, + SimpleChanges, + ViewEncapsulation, } from '@angular/core'; -import { - animate, - state, - style, - transition, - trigger, -} from '@angular/animations'; import { Observable, Observer, Subscription } from 'rxjs'; import { PopupConfig } from './popup.config'; @Component({ selector: 'weui-popup', - template: ` -
- - `, + exportAs: 'weuiPopup', + templateUrl: './popup.component.html', animations: [ trigger('visibility', [ state('show', style({ opacity: 1 })), @@ -42,30 +29,32 @@ import { PopupConfig } from './popup.config'; host: { '[hidden]': '!shown', }, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class PopupComponent implements OnInit, OnDestroy, OnChanges { + private observer: Observer; + shown: boolean = false; + _shownAnt = false; + /** * 配置项 */ @Input() config: PopupConfig; /** 取消回调 */ - @Output() cancel = new EventEmitter(); + @Output() readonly cancel = new EventEmitter(); /** 确认回调 */ - @Output() confirm = new EventEmitter(); - - private shown: boolean = false; - _shownAnt = false; - - private observer: Observer; + @Output() readonly confirm = new EventEmitter(); get _visibility(): string { return this._shownAnt ? 'show' : 'hide'; } - constructor(private DEF: PopupConfig) {} + constructor(private DEF: PopupConfig, private cdr: ChangeDetectorRef) {} private parseConfig() { - this.config = Object.assign({}, this.DEF, this.config); + this.config = { ...this.DEF, ...this.config }; } ngOnInit() { @@ -73,7 +62,7 @@ export class PopupComponent implements OnInit, OnDestroy, OnChanges { } ngOnChanges(changes: SimpleChanges): void { - if ('config' in changes) this.parseConfig(); + if (changes.config) this.parseConfig(); } /** @@ -83,6 +72,7 @@ export class PopupComponent implements OnInit, OnDestroy, OnChanges { this.shown = true; setTimeout(() => { this._shownAnt = true; + this.cdr.detectChanges(); }, 10); return Observable.create((observer: Observer) => { this.observer = observer; @@ -98,6 +88,7 @@ export class PopupComponent implements OnInit, OnDestroy, OnChanges { if (is_backdrop === true && this.config.backdrop === false) return false; this._shownAnt = false; + this.cdr.detectChanges(); setTimeout(() => { this.shown = false; }, 300); @@ -130,7 +121,7 @@ export class PopupComponent implements OnInit, OnDestroy, OnChanges { ngOnDestroy(): void { if (this.observer && this.observer instanceof Subscription) { - (this.observer).unsubscribe(); + (this.observer as Subscription).unsubscribe(); } } } diff --git a/components/popup/popup.config.ts b/components/popup/popup.config.ts index f143328..077b026 100644 --- a/components/popup/popup.config.ts +++ b/components/popup/popup.config.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class PopupConfig { /** * 是否全屏,默认:`false` diff --git a/components/popup/popup.module.ts b/components/popup/popup.module.ts index 1757277..eb3d5d3 100644 --- a/components/popup/popup.module.ts +++ b/components/popup/popup.module.ts @@ -1,7 +1,6 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { PopupComponent } from './popup.component'; -import { PopupConfig } from './popup.config'; @NgModule({ imports: [CommonModule], @@ -9,8 +8,4 @@ import { PopupConfig } from './popup.config'; exports: [PopupComponent], entryComponents: [PopupComponent], }) -export class PopupModule { - static forRoot(): ModuleWithProviders { - return { ngModule: PopupModule, providers: [PopupConfig] }; - } -} +export class PopupModule {} diff --git a/components/popup/public-api.ts b/components/popup/public-api.ts index b1930a8..5377daf 100644 --- a/components/popup/public-api.ts +++ b/components/popup/public-api.ts @@ -1,3 +1,3 @@ -export { PopupComponent } from './popup.component'; -export { PopupConfig } from './popup.config'; -export { PopupModule } from './popup.module'; +export * from './popup.component'; +export * from './popup.config'; +export * from './popup.module'; diff --git a/components/progress/package.json b/components/progress/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/progress/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/progress/progress.component.html b/components/progress/progress.component.html new file mode 100644 index 0000000..7544879 --- /dev/null +++ b/components/progress/progress.component.html @@ -0,0 +1,8 @@ +
+
+
+
+ + + +
diff --git a/components/progress/progress.component.ts b/components/progress/progress.component.ts index 08bd773..ffa33cd 100644 --- a/components/progress/progress.component.ts +++ b/components/progress/progress.component.ts @@ -1,17 +1,21 @@ -import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + EventEmitter, + Input, + Output, + ViewEncapsulation, +} from '@angular/core'; +import { InputBoolean, InputNumber } from 'ngx-weui/core'; @Component({ selector: 'weui-progress', - template: ` -
-
-
-
- - - -
- `, + exportAs: 'weuiProgress', + templateUrl: './progress.component.html', + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class ProgressComponent { _value: number = 0; @@ -19,19 +23,23 @@ export class ProgressComponent { * 默认进度值,取值范围:0-100(单位:%) */ @Input() + @InputNumber() set value(d: number) { this._value = Math.max(0, Math.min(100, d)); + this.cdr.detectChanges(); } /** * 是否允许取消,默认:`true` */ - @Input() canCancel: boolean = true; + @Input() @InputBoolean() canCancel: boolean = true; /** * 取消回调 */ - @Output() cancel = new EventEmitter(); + @Output() readonly cancel = new EventEmitter(); + + constructor(private cdr: ChangeDetectorRef) {} _onCancel() { if (this.canCancel) this.cancel.emit(); diff --git a/components/progress/progress.module.ts b/components/progress/progress.module.ts index eb276e5..019c968 100644 --- a/components/progress/progress.module.ts +++ b/components/progress/progress.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { ProgressComponent } from './progress.component'; @NgModule({ @@ -8,8 +8,4 @@ import { ProgressComponent } from './progress.component'; exports: [ProgressComponent], entryComponents: [ProgressComponent], }) -export class ProgressModule { - static forRoot(): ModuleWithProviders { - return { ngModule: ProgressModule, providers: [] }; - } -} +export class ProgressModule {} diff --git a/components/progress/progress.spec.ts b/components/progress/progress.spec.ts index e9fa739..049c9f9 100644 --- a/components/progress/progress.spec.ts +++ b/components/progress/progress.spec.ts @@ -1,18 +1,8 @@ -import { Subscription } from 'rxjs'; -import { Component, ViewChild, DebugElement } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - async, - inject, -} from '@angular/core/testing'; +import { Component } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { ProgressModule, ProgressComponent } from '../progress'; +import { ProgressComponent, ProgressModule } from '.'; describe('Component: Progress', () => { let fixture: ComponentFixture; @@ -20,23 +10,19 @@ describe('Component: Progress', () => { let comp: ProgressComponent; let barEl: HTMLElement; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestProgressComponent], - imports: [ProgressModule.forRoot(), FormsModule], - }); - fixture = TestBed.createComponent(TestProgressComponent); - context = fixture.componentInstance; - spyOn(context, 'cancel'); - fixture.detectChanges(); - comp = fixture.debugElement.query(By.css('weui-progress')) - .componentInstance as ProgressComponent; - barEl = fixture.debugElement.query(By.css('.weui-progress__inner-bar')) - .nativeElement as HTMLElement; - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestProgressComponent], + imports: [ProgressModule], + }); + fixture = TestBed.createComponent(TestProgressComponent); + context = fixture.componentInstance; + spyOn(context, 'cancel'); + fixture.detectChanges(); + comp = fixture.debugElement.query(By.css('weui-progress')).componentInstance as ProgressComponent; + barEl = fixture.debugElement.query(By.css('.weui-progress__inner-bar')).nativeElement as HTMLElement; + tick(); + })); it('should define default values', () => { expect(comp._value).toBe(0); @@ -62,14 +48,17 @@ describe('Component: Progress', () => { }); it('should be cancel', () => { - (fixture.debugElement.query(By.css('.weui-progress__opr')) - .nativeElement as HTMLLinkElement).click(); + (fixture.debugElement.query(By.css('.weui-progress__opr')).nativeElement as HTMLLinkElement).click(); fixture.detectChanges(); expect(context.cancel).toHaveBeenCalled(); }); }); -@Component({ template: `` }) +@Component({ + template: ` + + `, +}) class TestProgressComponent { cancel() {} } diff --git a/components/progress/public-api.ts b/components/progress/public-api.ts index c90d0b3..5df4040 100644 --- a/components/progress/public-api.ts +++ b/components/progress/public-api.ts @@ -1,2 +1,2 @@ -export { ProgressComponent } from './progress.component'; -export { ProgressModule } from './progress.module'; +export * from './progress.component'; +export * from './progress.module'; diff --git a/components/ptr/package.json b/components/ptr/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/ptr/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/ptr/ptr.component.html b/components/ptr/ptr.component.html new file mode 100644 index 0000000..6fe160e --- /dev/null +++ b/components/ptr/ptr.component.html @@ -0,0 +1,23 @@ +
+
+ +

{{ _lastLabel }}

+
+ +
+
diff --git a/components/ptr/ptr.component.ts b/components/ptr/ptr.component.ts index 4c22916..6c867e8 100644 --- a/components/ptr/ptr.component.ts +++ b/components/ptr/ptr.component.ts @@ -1,64 +1,51 @@ import { + ChangeDetectionStrategy, + ChangeDetectorRef, Component, - Input, - OnChanges, - SimpleChanges, + ElementRef, EventEmitter, - Output, HostListener, - ElementRef, + Input, + OnChanges, OnInit, + Output, + SimpleChanges, + ViewEncapsulation, } from '@angular/core'; +import { InputBoolean } from 'ngx-weui/core'; import { PTRConfig } from './ptr.config'; @Component({ selector: 'weui-ptr', - template: ` -
-
- -

{{_lastLabel}}

-
- -
-
- `, + exportAs: 'weuiPtr', + templateUrl: './ptr.component.html', host: { '[class.weui-ptr]': 'true', }, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class PTRComponent implements OnInit, OnChanges { private ogY: number = 0; private loading: boolean = false; private touching: boolean = false; private touchId: any; - _animating: boolean = false; private initScrollTop: number = 0; - _pullPercent: number = 0; - private loaderEl: HTMLElement; - private iconEl: HTMLElement; private contentEl: HTMLElement; - + _animating: boolean = false; + _pullPercent: number = 0; _lastLabel: string; /** 配置项 */ @Input() config: PTRConfig; /** 是否禁止 */ - @Input() disabled: boolean = false; + @Input() @InputBoolean() disabled: boolean = false; /** 下拉滚动时回调,返回一个0-100%的参数 */ - @Output() scroll = new EventEmitter(); + @Output() readonly scroll = new EventEmitter(); /** 刷新回调 */ - @Output() refresh = new EventEmitter(); + @Output() readonly refresh = new EventEmitter(); - constructor(private el: ElementRef, private DEF: PTRConfig) { } + constructor(private el: ElementRef, private DEF: PTRConfig, private cdr: ChangeDetectorRef) {} /** * 设置最后更新标签 @@ -67,6 +54,7 @@ export class PTRComponent implements OnInit, OnChanges { */ setLastUpdatedLabel(label: string) { this._lastLabel = label; + this.cdr.detectChanges(); } /** @@ -78,11 +66,13 @@ export class PTRComponent implements OnInit, OnChanges { this._pullPercent = 0; this.loading = false; this._animating = true; + this.cdr.detectChanges(); if (!this.touching) { setTimeout(() => { this._animating = false; if (lastUpdatedLabel) this.setLastUpdatedLabel(lastUpdatedLabel); + this.cdr.detectChanges(); }, 350); } } @@ -93,9 +83,7 @@ export class PTRComponent implements OnInit, OnChanges { this.touching = true; this.touchId = $event.targetTouches[0].identifier; this.ogY = - this._pullPercent === 0 - ? $event.targetTouches[0].pageY - : $event.targetTouches[0].pageY - this._pullPercent; + this._pullPercent === 0 ? $event.targetTouches[0].pageY : $event.targetTouches[0].pageY - this._pullPercent; this.initScrollTop = this.contentEl.scrollTop; this._animating = false; } @@ -115,19 +103,18 @@ export class PTRComponent implements OnInit, OnChanges { $event.preventDefault(); // let diffY = Math.abs(this.ogY - pageY); - this._pullPercent = - diffY - this.initScrollTop > 100 ? 100 : diffY - this.initScrollTop; + this._pullPercent = diffY - this.initScrollTop > 100 ? 100 : diffY - this.initScrollTop; this.scroll.emit(this._pullPercent); } - @HostListener('touchend', ['$event']) - @HostListener('touchcancel', ['$event']) - onTouchEnd($event: any) { + @HostListener('touchend') + @HostListener('touchcancel') + onTouchEnd() { if (this.disabled || !this.touching || this.loading) return; let _pullPercent = this._pullPercent; let loading = false; - if (_pullPercent >= this.config.treshold) { + if (_pullPercent >= this.config.treshold!) { loading = true; } else { _pullPercent = 0; @@ -141,6 +128,7 @@ export class PTRComponent implements OnInit, OnChanges { this._pullPercent = _pullPercent; this.loading = loading; if (loading) this.refresh.emit(this); + this.cdr.detectChanges(); } ngOnInit() { @@ -149,13 +137,10 @@ export class PTRComponent implements OnInit, OnChanges { } ngOnChanges(changes: SimpleChanges): void { - if ('config' in changes) this.parseConfig(); + if (changes.config) this.parseConfig(); } private parseConfig() { - this.config = Object.assign({}, this.DEF, this.config); - const el = this.el.nativeElement; - this.loaderEl = el.querySelector('.weui-ptr__loader'); - this.iconEl = el.querySelector('.weui-ptr__icon'); + this.config = { ...this.DEF, ...this.config }; } } diff --git a/components/ptr/ptr.config.ts b/components/ptr/ptr.config.ts index 2e2547e..28242c2 100644 --- a/components/ptr/ptr.config.ts +++ b/components/ptr/ptr.config.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class PTRConfig { /** * 是否使用默认icon样式,默认:`false` diff --git a/components/ptr/ptr.module.ts b/components/ptr/ptr.module.ts index 88b7504..37bb9b1 100644 --- a/components/ptr/ptr.module.ts +++ b/components/ptr/ptr.module.ts @@ -1,7 +1,6 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { PTRComponent } from './ptr.component'; -import { PTRConfig } from './ptr.config'; @NgModule({ imports: [CommonModule], @@ -9,8 +8,4 @@ import { PTRConfig } from './ptr.config'; exports: [PTRComponent], entryComponents: [PTRComponent], }) -export class PTRModule { - static forRoot(): ModuleWithProviders { - return { ngModule: PTRModule, providers: [PTRConfig] }; - } -} +export class PTRModule {} diff --git a/components/ptr/ptr.spec.ts b/components/ptr/ptr.spec.ts index 2a6c360..b5278d0 100644 --- a/components/ptr/ptr.spec.ts +++ b/components/ptr/ptr.spec.ts @@ -1,23 +1,14 @@ -import { Component, ViewChild, DebugElement } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - async, - inject, -} from '@angular/core/testing'; +import { Component } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { Observable, Subscriber } from 'rxjs'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { PTRModule, PTRComponent, PTRConfig } from '../ptr'; +import { PTRComponent, PTRConfig, PTRModule } from '../ptr'; function spyTouchArgument(val: number) { return { targetTouches: [{ pageY: val, identifier: 1 }], - preventDefault: function() {}, + preventDefault() {}, }; } @@ -27,51 +18,43 @@ describe('Component: PTR', () => { let el: HTMLDivElement; let comp: PTRComponent; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestPTRComponent], - imports: [PTRModule.forRoot(), NoopAnimationsModule], - }); - fixture = TestBed.createComponent(TestPTRComponent); - context = fixture.componentInstance; - spyOn(context, 'onScroll'); - spyOn(context, 'onRefresh'); - fixture.detectChanges(); - el = fixture.nativeElement; - comp = fixture.debugElement.query(By.css('weui-ptr')) - .componentInstance as PTRComponent; - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestPTRComponent], + imports: [PTRModule, NoopAnimationsModule], + }); + fixture = TestBed.createComponent(TestPTRComponent); + context = fixture.componentInstance; + spyOn(context, 'onScroll'); + spyOn(context, 'onRefresh'); + fixture.detectChanges(); + el = fixture.nativeElement; + comp = fixture.debugElement.query(By.css('weui-ptr')).componentInstance as PTRComponent; + tick(); + })); it('should correctly initialize and attach to DOM', () => { expect(el.querySelector('.weui-ptr__loader')).not.toBeNull(); expect(el.querySelector('.weui-ptr__content')).not.toBeNull(); - expect(el.querySelectorAll('.weui-cell_access').length).toBe( - context.items.length, - ); + expect(el.querySelectorAll('.weui-cell_access').length).toBe(context.items.length); }); it('should be set last updated labled', () => { const labelText = 'test'; comp.setLastUpdatedLabel(labelText); fixture.detectChanges(); - expect(el.querySelector('.weui-ptr__label').textContent).toBe(labelText); + expect(el.querySelector('.weui-ptr__label')!.textContent).toBe(labelText); }); - it( - 'should be set finished', - fakeAsync(() => { - const labelText = 'test'; - comp.setFinished(labelText); - fixture.detectChanges(); - tick(500); - expect(comp._animating).toBe(false); - fixture.detectChanges(); - expect(el.querySelector('.weui-ptr__label').textContent).toBe(labelText); - }), - ); + it('should be set finished', fakeAsync(() => { + const labelText = 'test'; + comp.setFinished(labelText); + fixture.detectChanges(); + tick(500); + expect(comp._animating).toBe(false); + fixture.detectChanges(); + expect(el.querySelector('.weui-ptr__label')!.textContent).toBe(labelText); + })); it('should be re-setting config', () => { expect(comp.config.height).toBe(100); @@ -84,7 +67,7 @@ describe('Component: PTR', () => { comp.onTouchStart(spyTouchArgument(0)); comp.onTouchMove(spyTouchArgument(80)); fixture.detectChanges(); - comp.onTouchEnd(spyTouchArgument(80)); + comp.onTouchEnd(); fixture.detectChanges(); expect(context.onScroll).toHaveBeenCalled(); expect(context.onRefresh).toHaveBeenCalled(); @@ -94,7 +77,7 @@ describe('Component: PTR', () => { comp.onTouchStart(spyTouchArgument(0)); comp.onTouchMove(spyTouchArgument(50)); fixture.detectChanges(); - comp.onTouchEnd(spyTouchArgument(50)); + comp.onTouchEnd(); fixture.detectChanges(); expect(context.onScroll).toHaveBeenCalled(); expect(context.onRefresh).not.toHaveBeenCalled(); @@ -103,16 +86,21 @@ describe('Component: PTR', () => { @Component({ template: ` - -
List with link
-
+ +
List with link
+ -
-`, +
+
+ `, }) class TestPTRComponent { config: PTRConfig = { @@ -121,7 +109,7 @@ class TestPTRComponent { items: any[] = Array(6) .fill({}) - .map((v: any, idx: number) => { + .map((_v: any, idx: number) => { return `${idx}:${Math.random()}`; }); onRefresh(ptr: PTRComponent) { diff --git a/components/rating/package.json b/components/rating/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/rating/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/rating/rating.component.html b/components/rating/rating.component.html new file mode 100644 index 0000000..76a927e --- /dev/null +++ b/components/rating/rating.component.html @@ -0,0 +1,13 @@ + + + ({{ index < _value ? '*' : ' ' }}) + + + diff --git a/components/rating/rating.component.ts b/components/rating/rating.component.ts index a094c20..9087014 100644 --- a/components/rating/rating.component.ts +++ b/components/rating/rating.component.ts @@ -1,26 +1,23 @@ import { + forwardRef, + ChangeDetectionStrategy, + ChangeDetectorRef, Component, EventEmitter, Input, + OnChanges, Output, - forwardRef, SimpleChanges, - OnChanges, + ViewEncapsulation, } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { InputBoolean } from 'ngx-weui/core'; import { RatingConfig } from './rating.config'; @Component({ selector: 'weui-rating', - template: ` - - - ({{ index < _value ? '*' : ' ' }}) - - - - `, + exportAs: 'weuiRating', + templateUrl: './rating.component.html', providers: [ { provide: NG_VALUE_ACCESSOR, @@ -28,50 +25,50 @@ import { RatingConfig } from './rating.config'; multi: true, }, ], + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class RatingComponent implements ControlValueAccessor, OnChanges { /** 配置项 */ @Input() config: RatingConfig; /** 是否只读模式,默认:`false` */ - @Input() readonly: boolean = false; + @Input() @InputBoolean() readonly: boolean = false; /** 选中后回调,参数:选中值 */ - @Output() selected = new EventEmitter(); + @Output() readonly selected = new EventEmitter(); _range: any[]; _value: number; _preValue: number; _class: string = ''; - constructor(private DEF: RatingConfig) { } + constructor(private DEF: RatingConfig, private cdr: ChangeDetectorRef) {} - _setConfig(cog: RatingConfig) { - const _c = Object.assign( - { - states: [], - }, - this.DEF, - cog, - ); + private setConfig(cog: RatingConfig) { + const _c = { + states: [], + ...this.DEF, + ...cog, + }; this._class = _c.cls || ''; const count = _c.states.length || _c.max; this._range = Array(count) .fill(0) - .map((v, i) => { - return Object.assign( - { - index: i, - on: _c.stateOn, - off: _c.stateOff, - title: _c.titles[i] || i + 1, - }, - _c.states[i] || {}, - ); + .map((_v, i) => { + return { + index: i, + on: _c.stateOn, + off: _c.stateOff, + title: _c.titles![i] || i + 1, + ...(_c.states[i] || {}), + }; }); + this.cdr.detectChanges(); } ngOnChanges(changes: SimpleChanges): void { if (changes.config) { - this._setConfig(changes.config.currentValue); + this.setConfig(changes.config.currentValue); } } @@ -80,27 +77,31 @@ export class RatingComponent implements ControlValueAccessor, OnChanges { this.writeValue(value); this.onChange(value); } + this.cdr.detectChanges(); } writeValue(_value: any): void { if (_value % 1 !== _value) { this._value = Math.round(_value); this._preValue = _value; + this.cdr.detectChanges(); return; } this._preValue = _value; this._value = _value; + this.cdr.detectChanges(); } private onChange: any = Function.prototype; - private onTouched: any = Function.prototype; + // private onTouched: any = Function.prototype; - public registerOnChange(fn: (_: any) => {}): void { + registerOnChange(fn: (_: any) => {}): void { this.onChange = fn; } - public registerOnTouched(fn: () => {}): void { - this.onTouched = fn; + + registerOnTouched(_fn: () => {}): void { + // this.onTouched = fn; } setDisabledState(isDisabled: boolean): void { diff --git a/components/rating/rating.config.ts b/components/rating/rating.config.ts index 323d5af..e3af09e 100644 --- a/components/rating/rating.config.ts +++ b/components/rating/rating.config.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class RatingConfig { /** * 图标数量(默认:5个) @@ -25,7 +25,7 @@ export class RatingConfig { /** * 自定义图标,当存在时 `max`、`stateOff`、`stateOn` 失效 */ - states?: { on: string; off: string }[] = []; + states?: Array<{ on: string; off: string }> = []; /** * 图标 `title` 属性值,默认以 `1` 开始的索引值 diff --git a/components/rating/rating.module.ts b/components/rating/rating.module.ts index d61eefb..bb7c81f 100644 --- a/components/rating/rating.module.ts +++ b/components/rating/rating.module.ts @@ -1,16 +1,10 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { RatingComponent } from './rating.component'; -import { RatingConfig } from './rating.config'; @NgModule({ imports: [CommonModule], declarations: [RatingComponent], exports: [RatingComponent], - entryComponents: [RatingComponent], }) -export class RatingModule { - static forRoot(): ModuleWithProviders { - return { ngModule: RatingModule, providers: [RatingConfig] }; - } -} +export class RatingModule {} diff --git a/components/rating/rating.spec.ts b/components/rating/rating.spec.ts index 6197bcd..d207a46 100644 --- a/components/rating/rating.spec.ts +++ b/components/rating/rating.spec.ts @@ -1,15 +1,10 @@ import { Component } from '@angular/core'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, -} from '@angular/core/testing'; +import { fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; import { RatingComponent } from './rating.component'; -import { RatingModule } from './rating.module'; import { RatingConfig } from './rating.config'; +import { RatingModule } from './rating.module'; describe('Component: Rating', () => { describe('Init', () => { @@ -19,10 +14,11 @@ describe('Component: Rating', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [RatingModule.forRoot()], + imports: [RatingModule], }); fixture = TestBed.createComponent(RatingComponent); - fixture.componentInstance._setConfig(null); + // tslint:disable-next-line: no-string-literal + fixture.componentInstance['setConfig'](null!); context = fixture.debugElement.componentInstance; el = fixture.nativeElement; @@ -45,7 +41,8 @@ describe('Component: Rating', () => { }); it('should working with changed value', () => { - context._setConfig({ + // tslint:disable-next-line: no-string-literal + context['setConfig']({ max: 3, titles: ['one', 'two'], stateOff: 'fa-circle', @@ -71,75 +68,67 @@ describe('Component: Rating', () => { let context: TestRatingComponent; let element: HTMLElement; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestRatingComponent], - imports: [RatingModule.forRoot(), FormsModule], - }); - TestBed.overrideComponent(TestRatingComponent, { - set: { template: tpl }, - }); - fixture = TestBed.createComponent(TestRatingComponent); - context = fixture.debugElement.componentInstance; - element = fixture.nativeElement; - fixture.detectChanges(); - }), - ); - - it( - 'check simple click', - fakeAsync(() => { - const items = element.querySelectorAll('.weui-rating__sr-only'); - const icons = element.querySelectorAll('i'); - - expect(items[0].innerHTML).toEqual('( )'); - expect(icons[0].classList).toContain('weui-icon-circle'); - expect(icons[0].classList).not.toContain('weui-icon-download'); - - icons[1].click(); - tick(200); - fixture.detectChanges(); - - expect(items[0].innerHTML).toEqual('(*)'); - expect(icons[0].classList).not.toContain('weui-icon-circle'); - expect(icons[0].classList).toContain('weui-icon-download'); - }), - ); - - it( - 'check disabling', - fakeAsync(() => { - const items = element.querySelectorAll('.weui-rating__sr-only'); - const icons = element.querySelectorAll('i'); - - expect(items[0].innerHTML).toEqual('( )'); - expect(icons[0].classList).toContain('weui-icon-circle'); - expect(icons[0].classList).not.toContain('weui-icon-download'); - - context.readonly = true; - fixture.detectChanges(); - - icons[1].click(); - tick(200); - fixture.detectChanges(); - - expect(items[0].innerHTML).toEqual('( )'); - expect(icons[0].classList).toContain('weui-icon-circle'); - expect(icons[0].classList).not.toContain('weui-icon-download'); - - context.readonly = false; - fixture.detectChanges(); - - icons[1].click(); - tick(200); - fixture.detectChanges(); - - expect(items[0].innerHTML).toEqual('(*)'); - expect(icons[0].classList).not.toContain('weui-icon-circle'); - expect(icons[0].classList).toContain('weui-icon-download'); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestRatingComponent], + imports: [RatingModule, FormsModule], + }); + TestBed.overrideComponent(TestRatingComponent, { + set: { template: tpl }, + }); + fixture = TestBed.createComponent(TestRatingComponent); + context = fixture.debugElement.componentInstance; + element = fixture.nativeElement; + fixture.detectChanges(); + })); + + it('check simple click', fakeAsync(() => { + const items = element.querySelectorAll('.weui-rating__sr-only'); + const icons = element.querySelectorAll('i'); + + expect(items[0].innerHTML).toEqual('( )'); + expect(icons[0].classList).toContain('weui-icon-circle'); + expect(icons[0].classList).not.toContain('weui-icon-download'); + + icons[1].click(); + tick(200); + fixture.detectChanges(); + + expect(items[0].innerHTML).toEqual('(*)'); + expect(icons[0].classList).not.toContain('weui-icon-circle'); + expect(icons[0].classList).toContain('weui-icon-download'); + })); + + it('check disabling', fakeAsync(() => { + const items = element.querySelectorAll('.weui-rating__sr-only'); + const icons = element.querySelectorAll('i'); + + expect(items[0].innerHTML).toEqual('( )'); + expect(icons[0].classList).toContain('weui-icon-circle'); + expect(icons[0].classList).not.toContain('weui-icon-download'); + + context.readonly = true; + fixture.detectChanges(); + + icons[1].click(); + tick(200); + fixture.detectChanges(); + + expect(items[0].innerHTML).toEqual('( )'); + expect(icons[0].classList).toContain('weui-icon-circle'); + expect(icons[0].classList).not.toContain('weui-icon-download'); + + context.readonly = false; + fixture.detectChanges(); + + icons[1].click(); + tick(200); + fixture.detectChanges(); + + expect(items[0].innerHTML).toEqual('(*)'); + expect(icons[0].classList).not.toContain('weui-icon-circle'); + expect(icons[0].classList).toContain('weui-icon-download'); + })); }); }); diff --git a/components/rating/style/index.less b/components/rating/style/index.less index 1e0ec05..68ab62a 100644 --- a/components/rating/style/index.less +++ b/components/rating/style/index.less @@ -5,4 +5,4 @@ &__sr-only { display: none; } -} \ No newline at end of file +} diff --git a/components/schematics/shell/index.ts b/components/schematics/shell/index.ts index 3b9f3e1..7186ef5 100644 --- a/components/schematics/shell/index.ts +++ b/components/schematics/shell/index.ts @@ -1,20 +1,11 @@ -import { - Rule, - chain, - noop, - Tree, - SchematicContext, -} from '@angular-devkit/schematics'; +import { chain, noop, Rule, SchematicContext, Tree } from '@angular-devkit/schematics'; import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks'; -import { Schema } from './schema'; -import { addPackageToPackageJson } from '../utils/package'; +import { addModuleImportToRootModule } from '../utils/ast'; +import { getProjectFromWorkspace, getWorkspace } from '../utils/devkit-utils/config'; import { weuiVersion } from '../utils/lib-versions'; -import { - getProjectFromWorkspace, - getWorkspace, -} from '../utils/devkit-utils/config'; +import { addPackageToPackageJson } from '../utils/package'; +import { Schema } from './schema'; import { addThemeToAppStyles } from './theming'; -import { addModuleImportToRootModule } from '../utils/ast'; export default function(options: Schema): Rule { return chain([ @@ -39,12 +30,7 @@ function addWeUIRootConfig(options: Schema) { const workspace = getWorkspace(host); const project = getProjectFromWorkspace(workspace, options.project); - addModuleImportToRootModule( - host, - 'WeUiModule.forRoot()', - 'ngx-weui', - project, - ); + addModuleImportToRootModule(host, 'WeUiModule.forRoot()', 'ngx-weui', project); return host; }; @@ -56,12 +42,7 @@ function addAnimationRootConfig(options: Schema) { const workspace = getWorkspace(host); const project = getProjectFromWorkspace(workspace, options.project); - addModuleImportToRootModule( - host, - 'BrowserAnimationsModule', - '@angular/platform-browser/animations', - project, - ); + addModuleImportToRootModule(host, 'BrowserAnimationsModule', '@angular/platform-browser/animations', project); return host; }; diff --git a/components/schematics/shell/theming.ts b/components/schematics/shell/theming.ts index 47828d1..e05b29a 100644 --- a/components/schematics/shell/theming.ts +++ b/components/schematics/shell/theming.ts @@ -1,14 +1,9 @@ -import { Tree, SchematicsException } from '@angular-devkit/schematics'; -import { Schema } from './schema'; +import { SchematicsException, Tree } from '@angular-devkit/schematics'; import { getStylesPath } from '../utils/ast'; import { InsertChange } from '../utils/devkit-utils/change'; -import { - getProjectFromWorkspace, - getWorkspace, - Project, - Workspace, -} from '../utils/devkit-utils/config'; +import { getProjectFromWorkspace, getWorkspace, Project, Workspace } from '../utils/devkit-utils/config'; import { createCustomTheme } from './custom-theme'; +import { Schema } from './schema'; export function addThemeToAppStyles(options: Schema): (host: Tree) => Tree { return function(host: Tree): Tree { @@ -25,11 +20,7 @@ export function addThemeToAppStyles(options: Schema): (host: Tree) => Tree { } const buffer = host.read(stylesPath); if (buffer) { - const insertion = new InsertChange( - stylesPath, - 0, - createCustomTheme(project), - ); + const insertion = new InsertChange(stylesPath, 0, createCustomTheme(project)); const recorder = host.beginUpdate(stylesPath); recorder.insertLeft(insertion.pos, insertion.toAdd); host.commitUpdate(recorder); @@ -58,9 +49,9 @@ function isProjectUsingDefaultConfig(project: Project) { return ( project.architect && - project.architect['build'] && - project.architect['build']['builder'] === defaultBuilder && - project.architect['test'] && - project.architect['build']['builder'] === defaultBuilder + project.architect.build && + project.architect.build.builder === defaultBuilder && + project.architect.test && + project.architect.build.builder === defaultBuilder ); } diff --git a/components/schematics/utils/ast.ts b/components/schematics/utils/ast.ts index 3eb9e8c..bb181f0 100644 --- a/components/schematics/utils/ast.ts +++ b/components/schematics/utils/ast.ts @@ -1,12 +1,11 @@ -import {normalize} from '@angular-devkit/core'; -import {SchematicsException, Tree} from '@angular-devkit/schematics'; +import { normalize } from '@angular-devkit/core'; +import { SchematicsException, Tree } from '@angular-devkit/schematics'; import * as ts from 'typescript'; -import {addImportToModule} from './devkit-utils/ast-utils'; -import {InsertChange} from './devkit-utils/change'; -import {Project, getWorkspace} from './devkit-utils/config'; -import {findBootstrapModulePath, getAppModulePath} from './devkit-utils/ng-ast-utils'; -import {ModuleOptions, findModuleFromOptions as internalFindModule} from './devkit-utils/find-module'; - +import { addImportToModule } from './devkit-utils/ast-utils'; +import { InsertChange } from './devkit-utils/change'; +import { getWorkspace, Project } from './devkit-utils/config'; +import { findModuleFromOptions as internalFindModule } from './devkit-utils/find-module'; +import { getAppModulePath } from './devkit-utils/ng-ast-utils'; /** Reads file given path and returns TypeScript source file. */ export function getSourceFile(host: Tree, path: string): ts.SourceFile { @@ -31,8 +30,7 @@ export function addModuleImportToRootModule(host: Tree, moduleName: string, src: * @param moduleName name of module to import * @param src src location to import */ -export function addModuleImportToModule( - host: Tree, modulePath: string, moduleName: string, src: string) { +export function addModuleImportToModule(host: Tree, modulePath: string, moduleName: string, src: string) { const moduleSource = getSourceFile(host, modulePath); if (!moduleSource) { @@ -42,7 +40,7 @@ export function addModuleImportToModule( const changes = addImportToModule(moduleSource, modulePath, moduleName, src); const recorder = host.beginUpdate(modulePath); - changes.forEach((change) => { + changes.forEach(change => { if (change instanceof InsertChange) { recorder.insertLeft(change.pos, change.toAdd); } @@ -64,10 +62,10 @@ export function getIndexHtmlPath(host: Tree, project: Project): string { /** Get the root stylesheet file. */ export function getStylesPath(host: Tree, project: Project): string { - const buildTarget = project.architect['build']; + const buildTarget = project.architect.build; if (buildTarget.options && buildTarget.options.styles && buildTarget.options.styles.length) { - const styles = buildTarget.options.styles.map(s => typeof s === 'string' ? s : s.input); + const styles = buildTarget.options.styles.map(s => (typeof s === 'string' ? s : s.input)); // First, see if any of the assets is called "styles.(le|sc|c)ss", which is the default // "main" style sheet. diff --git a/components/schematics/utils/devkit-utils/ast-utils.ts b/components/schematics/utils/devkit-utils/ast-utils.ts index 253c969..db9e50c 100644 --- a/components/schematics/utils/devkit-utils/ast-utils.ts +++ b/components/schematics/utils/devkit-utils/ast-utils.ts @@ -9,7 +9,6 @@ import * as ts from 'typescript'; import { Change, InsertChange } from './change'; import { insertImport } from './route-utils'; - /** * Find all nodes from the AST in the subtree of node of SyntaxKind kind. * @param node @@ -45,7 +44,6 @@ export function findNodes(node: ts.Node, kind: ts.SyntaxKind, max = Infinity): t return arr; } - /** * Get all the nodes from a source. * @param sourceFile The source file object. @@ -83,7 +81,6 @@ export function findNode(node: ts.Node, kind: ts.SyntaxKind, text: string): ts.N return foundNode; } - /** * Helper for sorting nodes. * @return function to sort nodes in increasing order of position in sourceFile @@ -92,7 +89,6 @@ function nodesByPosition(first: ts.Node, second: ts.Node): number { return first.getStart() - second.getStart(); } - /** * Insert `toInsert` after the last occurence of `ts.SyntaxKind[nodes[i].kind]` * or after the last of occurence of `syntaxKind` if the last occurence is a sub child @@ -106,17 +102,21 @@ function nodesByPosition(first: ts.Node, second: ts.Node): number { * @return Change instance * @throw Error if toInsert is first occurence but fall back is not set */ -export function insertAfterLastOccurrence(nodes: ts.Node[], - toInsert: string, - file: string, - fallbackPos: number, - syntaxKind?: ts.SyntaxKind): Change { +export function insertAfterLastOccurrence( + nodes: ts.Node[], + toInsert: string, + file: string, + fallbackPos: number, + syntaxKind?: ts.SyntaxKind, +): Change { let lastItem = nodes.sort(nodesByPosition).pop(); if (!lastItem) { throw new Error(); } if (syntaxKind) { - lastItem = findNodes(lastItem, syntaxKind).sort(nodesByPosition).pop(); + lastItem = findNodes(lastItem, syntaxKind) + .sort(nodesByPosition) + .pop(); } if (!lastItem && fallbackPos == undefined) { throw new Error(`tried to insert ${toInsert} as first occurence with no fallback position`); @@ -126,7 +126,6 @@ export function insertAfterLastOccurrence(nodes: ts.Node[], return new InsertChange(file, lastItemPosition, toInsert); } - export function getContentOfKeyLiteral(_source: ts.SourceFile, node: ts.Node): string | null { if (node.kind == ts.SyntaxKind.Identifier) { return (node as ts.Identifier).text; @@ -137,9 +136,7 @@ export function getContentOfKeyLiteral(_source: ts.SourceFile, node: ts.Node): s } } - -function _angularImportsFromNode(node: ts.ImportDeclaration, - _sourceFile: ts.SourceFile): {[name: string]: string} { +function _angularImportsFromNode(node: ts.ImportDeclaration, _sourceFile: ts.SourceFile): { [name: string]: string } { const ms = node.moduleSpecifier; let modulePath: string; switch (ms.kind) { @@ -170,8 +167,8 @@ function _angularImportsFromNode(node: ts.ImportDeclaration, const namedImports = nb as ts.NamedImports; return namedImports.elements - .map((is: ts.ImportSpecifier) => is.propertyName ? is.propertyName.text : is.name.text) - .reduce((acc: {[name: string]: string}, curr: string) => { + .map((is: ts.ImportSpecifier) => (is.propertyName ? is.propertyName.text : is.name.text)) + .reduce((acc: { [name: string]: string }, curr: string) => { acc[curr] = modulePath; return acc; @@ -186,13 +183,10 @@ function _angularImportsFromNode(node: ts.ImportDeclaration, } } - -export function getDecoratorMetadata(source: ts.SourceFile, identifier: string, - module: string): ts.Node[] { - const angularImports: {[name: string]: string} - = findNodes(source, ts.SyntaxKind.ImportDeclaration) +export function getDecoratorMetadata(source: ts.SourceFile, identifier: string, module: string): ts.Node[] { + const angularImports: { [name: string]: string } = findNodes(source, ts.SyntaxKind.ImportDeclaration) .map((node: ts.ImportDeclaration) => _angularImportsFromNode(node, source)) - .reduce((acc: {[name: string]: string}, current: {[name: string]: string}) => { + .reduce((acc: { [name: string]: string }, current: { [name: string]: string }) => { for (const key of Object.keys(current)) { acc[key] = current[key]; } @@ -202,16 +196,16 @@ export function getDecoratorMetadata(source: ts.SourceFile, identifier: string, return getSourceNodes(source) .filter(node => { - return node.kind == ts.SyntaxKind.Decorator - && (node as ts.Decorator).expression.kind == ts.SyntaxKind.CallExpression; + return ( + node.kind == ts.SyntaxKind.Decorator && (node as ts.Decorator).expression.kind == ts.SyntaxKind.CallExpression + ); }) .map(node => (node as ts.Decorator).expression as ts.CallExpression) .filter(expr => { if (expr.expression.kind == ts.SyntaxKind.Identifier) { const id = expr.expression as ts.Identifier; - return id.getFullText(source) == identifier - && angularImports[id.getFullText(source)] === module; + return id.getFullText(source) == identifier && angularImports[id.getFullText(source)] === module; } else if (expr.expression.kind == ts.SyntaxKind.PropertyAccessExpression) { // This covers foo.NgModule when importing * as foo. const paExpr = expr.expression as ts.PropertyAccessExpression; @@ -223,17 +217,16 @@ export function getDecoratorMetadata(source: ts.SourceFile, identifier: string, const id = paExpr.name.text; const moduleId = (paExpr.expression as ts.Identifier).getText(source); - return id === identifier && (angularImports[moduleId + '.'] === module); + return id === identifier && angularImports[moduleId + '.'] === module; } return false; }) - .filter(expr => expr.arguments[0] - && expr.arguments[0].kind == ts.SyntaxKind.ObjectLiteralExpression) + .filter(expr => expr.arguments[0] && expr.arguments[0].kind == ts.SyntaxKind.ObjectLiteralExpression) .map(expr => expr.arguments[0] as ts.ObjectLiteralExpression); } -function findClassDeclarationParent(node: ts.Node): ts.ClassDeclaration|undefined { +function findClassDeclarationParent(node: ts.Node): ts.ClassDeclaration | undefined { if (ts.isClassDeclaration(node)) { return node; } @@ -247,7 +240,7 @@ function findClassDeclarationParent(node: ts.Node): ts.ClassDeclaration|undefine * @param source source file containing one or more @NgModule * @returns the name of the first @NgModule, or `undefined` if none is found */ -export function getFirstNgModuleName(source: ts.SourceFile): string|undefined { +export function getFirstNgModuleName(source: ts.SourceFile): string | undefined { // First, find the @NgModule decorators. const ngModulesMetadata = getDecoratorMetadata(source, 'NgModule', '@angular/core'); if (ngModulesMetadata.length === 0) { @@ -273,7 +266,7 @@ export function addSymbolToNgModuleMetadata( importPath: string | null = null, ): Change[] { const nodes = getDecoratorMetadata(source, 'NgModule', '@angular/core'); - let node: any = nodes[0]; // tslint:disable-line:no-any + let node: any = nodes[0]; // tslint:disable-line:no-any // Find the decorator declaration. if (!node) { @@ -281,8 +274,7 @@ export function addSymbolToNgModuleMetadata( } // Get all the children property assignment of object literals. - const matchingProperties: ts.ObjectLiteralElement[] = - (node as ts.ObjectLiteralExpression).properties + const matchingProperties: ts.ObjectLiteralElement[] = (node as ts.ObjectLiteralExpression).properties .filter(prop => prop.kind == ts.SyntaxKind.PropertyAssignment) // Filter out every fields that's not "metadataField". Also handles string literals // (but not expressions). @@ -353,7 +345,7 @@ export function addSymbolToNgModuleMetadata( } if (Array.isArray(node)) { - const nodeArray = node as {} as Array; + const nodeArray = (node as {}) as ts.Node[]; const symbolsArray = nodeArray.map(node => node.getText()); if (symbolsArray.includes(symbolName)) { return []; @@ -409,69 +401,81 @@ export function addSymbolToNgModuleMetadata( * Custom function to insert a declaration (component, pipe, directive) * into NgModule declarations. It also imports the component. */ -export function addDeclarationToModule(source: ts.SourceFile, - modulePath: string, classifiedName: string, - importPath: string): Change[] { - return addSymbolToNgModuleMetadata( - source, modulePath, 'declarations', classifiedName, importPath); +export function addDeclarationToModule( + source: ts.SourceFile, + modulePath: string, + classifiedName: string, + importPath: string, +): Change[] { + return addSymbolToNgModuleMetadata(source, modulePath, 'declarations', classifiedName, importPath); } /** * Custom function to insert an NgModule into NgModule imports. It also imports the module. */ -export function addImportToModule(source: ts.SourceFile, - modulePath: string, classifiedName: string, - importPath: string): Change[] { - +export function addImportToModule( + source: ts.SourceFile, + modulePath: string, + classifiedName: string, + importPath: string, +): Change[] { return addSymbolToNgModuleMetadata(source, modulePath, 'imports', classifiedName, importPath); } /** * Custom function to insert a provider into NgModule. It also imports it. */ -export function addProviderToModule(source: ts.SourceFile, - modulePath: string, classifiedName: string, - importPath: string): Change[] { +export function addProviderToModule( + source: ts.SourceFile, + modulePath: string, + classifiedName: string, + importPath: string, +): Change[] { return addSymbolToNgModuleMetadata(source, modulePath, 'providers', classifiedName, importPath); } /** * Custom function to insert an export into NgModule. It also imports it. */ -export function addExportToModule(source: ts.SourceFile, - modulePath: string, classifiedName: string, - importPath: string): Change[] { +export function addExportToModule( + source: ts.SourceFile, + modulePath: string, + classifiedName: string, + importPath: string, +): Change[] { return addSymbolToNgModuleMetadata(source, modulePath, 'exports', classifiedName, importPath); } /** * Custom function to insert an export into NgModule. It also imports it. */ -export function addBootstrapToModule(source: ts.SourceFile, - modulePath: string, classifiedName: string, - importPath: string): Change[] { +export function addBootstrapToModule( + source: ts.SourceFile, + modulePath: string, + classifiedName: string, + importPath: string, +): Change[] { return addSymbolToNgModuleMetadata(source, modulePath, 'bootstrap', classifiedName, importPath); } /** * Determine if an import already exists. */ -export function isImported(source: ts.SourceFile, - classifiedName: string, - importPath: string): boolean { +export function isImported(source: ts.SourceFile, classifiedName: string, importPath: string): boolean { const allNodes = getSourceNodes(source); const matchingNodes = allNodes .filter(node => node.kind === ts.SyntaxKind.ImportDeclaration) .filter((imp: ts.ImportDeclaration) => imp.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral) .filter((imp: ts.ImportDeclaration) => { - return ( imp.moduleSpecifier).text === importPath; + return (imp.moduleSpecifier as ts.StringLiteral).text === importPath; }) .filter((imp: ts.ImportDeclaration) => { if (!imp.importClause) { return false; } - const nodes = findNodes(imp.importClause, ts.SyntaxKind.ImportSpecifier) - .filter(n => n.getText() === classifiedName); + const nodes = findNodes(imp.importClause, ts.SyntaxKind.ImportSpecifier).filter( + n => n.getText() === classifiedName, + ); return nodes.length > 0; }); diff --git a/components/schematics/utils/devkit-utils/change.ts b/components/schematics/utils/devkit-utils/change.ts index 1255635..0154d1d 100644 --- a/components/schematics/utils/devkit-utils/change.ts +++ b/components/schematics/utils/devkit-utils/change.ts @@ -10,7 +10,6 @@ export interface Host { read(path: string): Promise; } - export interface Change { apply(host: Host): Promise; @@ -26,7 +25,6 @@ export interface Change { readonly description: string; } - /** * An operation that does nothing. */ @@ -34,15 +32,15 @@ export class NoopChange implements Change { description = 'No operation.'; order = Infinity; path = null; - apply() { return Promise.resolve(); } + apply() { + return Promise.resolve(); + } } - /** * Will add text to the source code. */ export class InsertChange implements Change { - order: number; description: string; @@ -71,7 +69,6 @@ export class InsertChange implements Change { * Will remove text from the source code. */ export class RemoveChange implements Change { - order: number; description: string; @@ -101,8 +98,7 @@ export class ReplaceChange implements Change { order: number; description: string; - constructor(public path: string, private pos: number, private oldText: string, - private newText: string) { + constructor(public path: string, private pos: number, private oldText: string, private newText: string) { if (pos < 0) { throw new Error('Negative positions are invalid'); } diff --git a/components/schematics/utils/devkit-utils/component.ts b/components/schematics/utils/devkit-utils/component.ts index b50fa17..bb671db 100644 --- a/components/schematics/utils/devkit-utils/component.ts +++ b/components/schematics/utils/devkit-utils/component.ts @@ -1,4 +1,4 @@ -import {normalize, strings} from '@angular-devkit/core'; +import { normalize, strings } from '@angular-devkit/core'; import { apply, branchAndMerge, @@ -15,12 +15,12 @@ import { url, } from '@angular-devkit/schematics'; import * as ts from 'typescript'; -import {addDeclarationToModule, addExportToModule} from './ast-utils'; -import {InsertChange} from './change'; -import {buildRelativePath, findModuleFromOptions} from './find-module'; -import {getWorkspace} from './config'; -import {parseName} from './parse-name'; -import {validateName} from './validation'; +import { addDeclarationToModule, addExportToModule } from './ast-utils'; +import { InsertChange } from './change'; +import { buildRelativePath, findModuleFromOptions } from './find-module'; +import { getWorkspace } from './config'; +import { parseName } from './parse-name'; +import { validateName } from './validation'; function addDeclarationToNgModule(options: any): Rule { return (host: Tree) => { @@ -36,16 +36,14 @@ function addDeclarationToNgModule(options: any): Rule { const sourceText = text.toString('utf-8'); const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true); - const componentPath = `/${options.path}/` - + (options.flat ? '' : strings.dasherize(options.name) + '/') - + strings.dasherize(options.name) - + '.component'; + const componentPath = + `/${options.path}/` + + (options.flat ? '' : strings.dasherize(options.name) + '/') + + strings.dasherize(options.name) + + '.component'; const relativePath = buildRelativePath(modulePath, componentPath); const classifiedName = strings.classify(`${options.name}Component`); - const declarationChanges = addDeclarationToModule(source, - modulePath, - classifiedName, - relativePath); + const declarationChanges = addDeclarationToModule(source, modulePath, classifiedName, relativePath); const declarationRecorder = host.beginUpdate(modulePath); for (const change of declarationChanges) { @@ -65,9 +63,12 @@ function addDeclarationToNgModule(options: any): Rule { const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true); const exportRecorder = host.beginUpdate(modulePath); - const exportChanges = addExportToModule(source, modulePath, - strings.classify(`${options.name}Component`), - relativePath); + const exportChanges = addExportToModule( + source, + modulePath, + strings.classify(`${options.name}Component`), + relativePath, + ); for (const change of exportChanges) { if (change instanceof InsertChange) { @@ -77,12 +78,10 @@ function addDeclarationToNgModule(options: any): Rule { host.commitUpdate(exportRecorder); } - return host; }; } - function buildSelector(options: any) { let selector = strings.dasherize(options.name); if (options.prefix) { @@ -92,7 +91,6 @@ function buildSelector(options: any) { return selector; } - export function buildComponent(options: any): Rule { return (host: Tree, context: SchematicContext) => { const workspace = getWorkspace(host); @@ -120,17 +118,15 @@ export function buildComponent(options: any): Rule { options.inlineTemplate ? filter(path => !path.endsWith('.html')) : noop(), template({ ...strings, - 'if-flat': (s: string) => options.flat ? '' : s, + 'if-flat': (s: string) => (options.flat ? '' : s), ...options, }), move(null, parsedPath.path), ]); - return chain([ - branchAndMerge(chain([ - addDeclarationToNgModule(options), - mergeWith(templateSource), - ])), - ])(host, context); + return chain([branchAndMerge(chain([addDeclarationToNgModule(options), mergeWith(templateSource)]))])( + host, + context, + ); }; } diff --git a/components/schematics/utils/devkit-utils/config.ts b/components/schematics/utils/devkit-utils/config.ts index 838e44a..406725c 100644 --- a/components/schematics/utils/devkit-utils/config.ts +++ b/components/schematics/utils/devkit-utils/config.ts @@ -5,11 +5,10 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import {SchematicsException, Tree} from '@angular-devkit/schematics'; +import { SchematicsException, Tree } from '@angular-devkit/schematics'; export const ANGULAR_CLI_WORKSPACE_PATH = '/angular.json'; - /** An Angular CLI Workspacer config (angular.json) */ export interface Workspace { /** Link to schema. */ @@ -98,7 +97,7 @@ export function getProjectFromWorkspace(config: Workspace, projectName?: string) throw new SchematicsException(`No project named "${projectName}" exists.`); } - Object.defineProperty(project, 'name', {enumerable: false, value: projectName}); + Object.defineProperty(project, 'name', { enumerable: false, value: projectName }); return project; } @@ -109,7 +108,7 @@ export function getProjectFromWorkspace(config: Workspace, projectName?: string) const project = config.projects[allProjectNames[0]]; // Set a non-enumerable project name to the project. We need the name for schematics // later on, but don't want to write it back out to the config file. - Object.defineProperty(project, 'name', {enumerable: false, value: projectName}); + Object.defineProperty(project, 'name', { enumerable: false, value: projectName }); return project; } else { throw new SchematicsException('Multiple projects are defined; please specify a project name'); diff --git a/components/schematics/utils/devkit-utils/find-module.ts b/components/schematics/utils/devkit-utils/find-module.ts index cf55bbd..b47d7f7 100644 --- a/components/schematics/utils/devkit-utils/find-module.ts +++ b/components/schematics/utils/devkit-utils/find-module.ts @@ -8,7 +8,6 @@ import { Path, join, normalize, relative, strings } from '@angular-devkit/core'; import { DirEntry, Tree } from '@angular-devkit/schematics'; - export interface ModuleOptions { module?: string; name: string; @@ -17,7 +16,6 @@ export interface ModuleOptions { skipImport?: boolean; } - /** * Find the module referred by a set of options passed to the schematics. */ @@ -27,14 +25,14 @@ export function findModuleFromOptions(host: Tree, options: ModuleOptions): Path } if (!options.module) { - const pathToCheck = (options.path || '') - + (options.flat ? '' : '/' + strings.dasherize(options.name)); + const pathToCheck = (options.path || '') + (options.flat ? '' : '/' + strings.dasherize(options.name)); return normalize(findModule(host, pathToCheck)); } else { - const modulePath = normalize( - '/' + (options.path) + '/' + options.module); - const moduleBaseName = normalize(modulePath).split('/').pop(); + const modulePath = normalize('/' + options.path + '/' + options.module); + const moduleBaseName = normalize(modulePath) + .split('/') + .pop(); if (host.exists(modulePath)) { return normalize(modulePath); @@ -65,15 +63,16 @@ export function findModule(host: Tree, generateDir: string): Path { if (matches.length == 1) { return join(dir.path, matches[0]); } else if (matches.length > 1) { - throw new Error('More than one module matches. Use skip-import option to skip importing ' - + 'the component into the closest module.'); + throw new Error( + 'More than one module matches. Use skip-import option to skip importing ' + + 'the component into the closest module.', + ); } dir = dir.parent; } - throw new Error('Could not find an NgModule. Use the skip-import ' - + 'option to skip importing in NgModule.'); + throw new Error('Could not find an NgModule. Use the skip-import ' + 'option to skip importing in NgModule.'); } /** diff --git a/components/schematics/utils/devkit-utils/ng-ast-utils.ts b/components/schematics/utils/devkit-utils/ng-ast-utils.ts index 74fd4c6..87e2fb7 100644 --- a/components/schematics/utils/devkit-utils/ng-ast-utils.ts +++ b/components/schematics/utils/devkit-utils/ng-ast-utils.ts @@ -24,20 +24,23 @@ export function findBootstrapModuleCall(host: Tree, mainPath: string): ts.CallEx let bootstrapCall: ts.CallExpression | null = null; for (const node of allNodes) { - let bootstrapCallNode: ts.Node | null = null; bootstrapCallNode = findNode(node, ts.SyntaxKind.Identifier, 'bootstrapModule'); // Walk up the parent until CallExpression is found. - while (bootstrapCallNode && bootstrapCallNode.parent - && bootstrapCallNode.parent.kind !== ts.SyntaxKind.CallExpression) { - + while ( + bootstrapCallNode && + bootstrapCallNode.parent && + bootstrapCallNode.parent.kind !== ts.SyntaxKind.CallExpression + ) { bootstrapCallNode = bootstrapCallNode.parent; } - if (bootstrapCallNode !== null && + if ( + bootstrapCallNode !== null && bootstrapCallNode.parent !== undefined && - bootstrapCallNode.parent.kind === ts.SyntaxKind.CallExpression) { + bootstrapCallNode.parent.kind === ts.SyntaxKind.CallExpression + ) { bootstrapCall = bootstrapCallNode.parent as ts.CallExpression; break; } @@ -67,7 +70,7 @@ export function findBootstrapModulePath(host: Tree, mainPath: string): string { return findNode(imp, ts.SyntaxKind.Identifier, bootstrapModule.getText()); }) .map((imp: ts.ImportDeclaration) => { - const modulePathStringLiteral = imp.moduleSpecifier; + const modulePathStringLiteral = imp.moduleSpecifier; return modulePathStringLiteral.text; })[0]; diff --git a/components/schematics/utils/devkit-utils/parse-name.ts b/components/schematics/utils/devkit-utils/parse-name.ts index 12d2e89..a8673b2 100644 --- a/components/schematics/utils/devkit-utils/parse-name.ts +++ b/components/schematics/utils/devkit-utils/parse-name.ts @@ -1,4 +1,3 @@ - /** * @license * Copyright Google Inc. All Rights Reserved. diff --git a/components/schematics/utils/devkit-utils/route-utils.ts b/components/schematics/utils/devkit-utils/route-utils.ts index 67e7e49..b09c4f6 100644 --- a/components/schematics/utils/devkit-utils/route-utils.ts +++ b/components/schematics/utils/devkit-utils/route-utils.ts @@ -9,26 +9,31 @@ import * as ts from 'typescript'; import { findNodes, insertAfterLastOccurrence } from './ast-utils'; import { Change, NoopChange } from './change'; - /** -* Add Import `import { symbolName } from fileName` if the import doesn't exit -* already. Assumes fileToEdit can be resolved and accessed. -* @param fileToEdit (file we want to add import to) -* @param symbolName (item to import) -* @param fileName (path to the file) -* @param isDefault (if true, import follows style for importing default exports) -* @return Change -*/ + * Add Import `import { symbolName } from fileName` if the import doesn't exit + * already. Assumes fileToEdit can be resolved and accessed. + * @param fileToEdit (file we want to add import to) + * @param symbolName (item to import) + * @param fileName (path to the file) + * @param isDefault (if true, import follows style for importing default exports) + * @return Change + */ -export function insertImport(source: ts.SourceFile, fileToEdit: string, symbolName: string, - fileName: string, isDefault = false): Change { +export function insertImport( + source: ts.SourceFile, + fileToEdit: string, + symbolName: string, + fileName: string, + isDefault = false, +): Change { const rootNode = source; const allImports = findNodes(rootNode, ts.SyntaxKind.ImportDeclaration); // get nodes that map to import statements from the file fileName const relevantImports = allImports.filter(node => { // StringLiteral of the ImportDeclaration is the import file (fileName in this case). - const importFiles = node.getChildren() + const importFiles = node + .getChildren() .filter(child => child.kind === ts.SyntaxKind.StringLiteral) .map(n => (n as ts.StringLiteral).text); @@ -66,8 +71,9 @@ export function insertImport(source: ts.SourceFile, fileToEdit: string, symbolNa } // no such import declaration exists - const useStrict = findNodes(rootNode, ts.SyntaxKind.StringLiteral) - .filter((n: ts.StringLiteral) => n.text === 'use strict'); + const useStrict = findNodes(rootNode, ts.SyntaxKind.StringLiteral).filter( + (n: ts.StringLiteral) => n.text === 'use strict', + ); let fallbackPos = 0; if (useStrict.length > 0) { fallbackPos = useStrict[0].end; @@ -77,14 +83,8 @@ export function insertImport(source: ts.SourceFile, fileToEdit: string, symbolNa // if there are no imports or 'use strict' statement, insert import at beginning of file const insertAtBeginning = allImports.length === 0 && useStrict.length === 0; const separator = insertAtBeginning ? '' : ';\n'; - const toInsert = `${separator}import ${open}${symbolName}${close}` + - ` from '${fileName}'${insertAtBeginning ? ';\n' : ''}`; + const toInsert = + `${separator}import ${open}${symbolName}${close}` + ` from '${fileName}'${insertAtBeginning ? ';\n' : ''}`; - return insertAfterLastOccurrence( - allImports, - toInsert, - fileToEdit, - fallbackPos, - ts.SyntaxKind.StringLiteral, - ); + return insertAfterLastOccurrence(allImports, toInsert, fileToEdit, fallbackPos, ts.SyntaxKind.StringLiteral); } diff --git a/components/schematics/utils/package.ts b/components/schematics/utils/package.ts index 3c35ff7..5853a42 100644 --- a/components/schematics/utils/package.ts +++ b/components/schematics/utils/package.ts @@ -3,12 +3,7 @@ import { Tree } from '@angular-devkit/schematics'; /** * Adds a package to the package.json */ -export function addPackageToPackageJson( - host: Tree, - type: string, - pkg: string, - version: string, -): Tree { +export function addPackageToPackageJson(host: Tree, type: string, pkg: string, version: string): Tree { if (host.exists('package.json')) { const sourceText = host.read('package.json')!.toString('utf-8'); const json = JSON.parse(sourceText); diff --git a/components/searchbar/package.json b/components/searchbar/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/searchbar/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/searchbar/searchbar.component.html b/components/searchbar/searchbar.component.html new file mode 100644 index 0000000..e20b484 --- /dev/null +++ b/components/searchbar/searchbar.component.html @@ -0,0 +1,25 @@ + diff --git a/components/searchbar/searchbar.component.ts b/components/searchbar/searchbar.component.ts index 6e212ce..4bdf827 100644 --- a/components/searchbar/searchbar.component.ts +++ b/components/searchbar/searchbar.component.ts @@ -1,41 +1,27 @@ import { + ChangeDetectionStrategy, Component, - HostListener, ElementRef, - HostBinding, - Input, - OnChanges, - SimpleChanges, - Output, EventEmitter, - ViewChild, + Input, OnDestroy, OnInit, + Output, + ViewChild, + ViewEncapsulation, } from '@angular/core'; -import { SearchBarConfig } from './searchbar.config'; +import { InputNumber } from 'ngx-weui/core'; import { Subject, Subscription } from 'rxjs'; import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; +import { SearchBarConfig } from './searchbar.config'; @Component({ -selector: 'weui-searchbar', -template: ` - - `, + selector: 'weui-searchbar', + exportAs: 'weuiSearchbar', + templateUrl: './searchbar.component.html', + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class SearchBarComponent implements OnInit, OnDestroy { _q: string = ''; @@ -55,18 +41,18 @@ export class SearchBarComponent implements OnInit, OnDestroy { /** * 去抖时长(单位:ms),默认:`300` */ - @Input() debounceTime: number; + @Input() @InputNumber() debounceTime: number; /** 搜索回调 */ - @Output() search = new EventEmitter(); + @Output() readonly search = new EventEmitter(); /** 取消回调 */ - @Output() cancel = new EventEmitter(); + @Output() readonly cancel = new EventEmitter(); /** 清空回调 */ - @Output() clear = new EventEmitter(); + @Output() readonly clear = new EventEmitter(); /** 提交回调(指的是键盘回车后) */ - @Output() submit = new EventEmitter(); + @Output() readonly submit = new EventEmitter(); _focus: boolean = false; - @ViewChild('term') _term: ElementRef; + @ViewChild('term') private _term: ElementRef; private _sub: Subscription; private _subject = new Subject(); @@ -77,7 +63,10 @@ export class SearchBarComponent implements OnInit, OnDestroy { ngOnInit() { this._sub = this._subject - .pipe(debounceTime(this.debounceTime), distinctUntilChanged()) + .pipe( + debounceTime(this.debounceTime), + distinctUntilChanged(), + ) .subscribe((q: string) => { this.search.emit(q); }); diff --git a/components/searchbar/searchbar.config.ts b/components/searchbar/searchbar.config.ts index 23e5b3b..b395d31 100644 --- a/components/searchbar/searchbar.config.ts +++ b/components/searchbar/searchbar.config.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class SearchBarConfig { /** * 占位符,默认:`搜索` diff --git a/components/searchbar/searchbar.module.ts b/components/searchbar/searchbar.module.ts index 37c4cbd..1853fd7 100644 --- a/components/searchbar/searchbar.module.ts +++ b/components/searchbar/searchbar.module.ts @@ -1,17 +1,11 @@ -import { FormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; import { SearchBarComponent } from './searchbar.component'; -import { SearchBarConfig } from './searchbar.config'; @NgModule({ imports: [CommonModule, FormsModule], declarations: [SearchBarComponent], exports: [SearchBarComponent], - entryComponents: [SearchBarComponent], }) -export class SearchBarModule { - static forRoot(): ModuleWithProviders { - return { ngModule: SearchBarModule, providers: [SearchBarConfig] }; - } -} +export class SearchBarModule {} diff --git a/components/sidebar/close.directive.ts b/components/sidebar/close.directive.ts index 376a7ad..c2a3179 100644 --- a/components/sidebar/close.directive.ts +++ b/components/sidebar/close.directive.ts @@ -4,7 +4,7 @@ import { SidebarService } from './sidebar.service'; /** * 关闭侧边栏指令 */ -@Directive({ selector: '[closeSidebar]' }) +@Directive({ selector: '[closeSidebar]', exportAs: 'weuiCloseSidebar' }) export class CloseSidebarDirective { constructor(private _sidebarService: SidebarService) {} diff --git a/components/sidebar/package.json b/components/sidebar/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/sidebar/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/sidebar/sidebar-container.component.html b/components/sidebar/sidebar-container.component.html new file mode 100644 index 0000000..e863fb0 --- /dev/null +++ b/components/sidebar/sidebar-container.component.html @@ -0,0 +1,5 @@ + + +
+ +
diff --git a/components/sidebar/sidebar-container.component.ts b/components/sidebar/sidebar-container.component.ts index b7db5ec..30af6c0 100644 --- a/components/sidebar/sidebar-container.component.ts +++ b/components/sidebar/sidebar-container.component.ts @@ -1,19 +1,21 @@ import { - Component, AfterContentInit, - OnChanges, - OnDestroy, - SimpleChanges, ChangeDetectionStrategy, - QueryList, - ContentChildren, - Input, - Output, - EventEmitter, ChangeDetectorRef, + Component, + ContentChildren, ElementRef, + EventEmitter, + Input, + OnChanges, + OnDestroy, OnInit, + Output, + QueryList, + SimpleChanges, + ViewEncapsulation, } from '@angular/core'; +import { InputBoolean } from 'ngx-weui/core'; import { SidebarComponent } from './sidebar.component'; /** @@ -21,25 +23,25 @@ import { SidebarComponent } from './sidebar.component'; */ @Component({ selector: 'weui-sidebar-container', - template: ` - - -
- -
- `, + exportAs: 'weuiSidebarContainer', + templateUrl: './sidebar-container.component.html', + preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) -export class SidebarContainerComponent - implements AfterContentInit, OnChanges, OnInit, OnDestroy { +export class SidebarContainerComponent implements AfterContentInit, OnChanges, OnInit, OnDestroy { @ContentChildren(SidebarComponent) _sidebars: QueryList; - @Input() _showBackdrop: boolean = false; - @Output() _showBackdropChange = new EventEmitter(); + @Input() @InputBoolean() _showBackdrop: boolean = false; + @Output() readonly _showBackdropChange = new EventEmitter(); private orgOverflowX = ''; - constructor(private _ref: ChangeDetectorRef, private _el: ElementRef) { } + private get body(): HTMLBodyElement { + return document.querySelector('body')!; + } + + constructor(private _ref: ChangeDetectorRef, private _el: ElementRef) {} ngAfterContentInit(): void { this._onToggle(); @@ -52,20 +54,19 @@ export class SidebarContainerComponent } ngOnChanges(changes: SimpleChanges): void { - if ('_showBackdrop' in changes) { - this._showBackdropChange.emit(changes['_showBackdrop'].currentValue); + if (changes._showBackdrop) { + this._showBackdropChange.emit(changes._showBackdrop.currentValue); } } ngOnInit() { - const $body = document.querySelector('body'); - this.orgOverflowX = $body.style.overflowX; - $body.style.overflowX = 'hidden'; + this.orgOverflowX = this.body.style.overflowX!; + this.body.style.overflowX = 'hidden'; } ngOnDestroy(): void { this._unsubscribe(); - document.querySelector('body').style.overflowX = this.orgOverflowX; + this.body.style.overflowX = this.orgOverflowX; } _getStyles(): CSSStyleDeclaration { @@ -76,18 +77,14 @@ export class SidebarContainerComponent } if (sidebar.mode === 'slide') { - let transformStyle = null; + let transformStyle: string | null = null; if (sidebar.status) { - const isLeftOrTop: boolean = - sidebar.position === 'left' || sidebar.position === 'top'; - const isLeftOrRight: boolean = - sidebar.position === 'left' || sidebar.position === 'right'; + const isLeftOrTop = sidebar.position === 'left' || sidebar.position === 'top'; + const isLeftOrRight = sidebar.position === 'left' || sidebar.position === 'right'; - const transformDir: string = isLeftOrRight ? 'X' : 'Y'; - const transformAmt: string = `${isLeftOrTop ? '' : '-'}${ - isLeftOrRight ? sidebar._width : sidebar._height - }`; + const transformDir = isLeftOrRight ? 'X' : 'Y'; + const transformAmt = `${isLeftOrTop ? '' : '-'}${isLeftOrRight ? sidebar._width : sidebar._height}`; transformStyle = `translate${transformDir}(${transformAmt}px)`; } @@ -165,6 +162,7 @@ export class SidebarContainerComponent let hasOpen = false; const _sidebars = this._sidebars.toArray(); + // tslint:disable-next-line: prefer-for-of for (let i = 0; i < _sidebars.length; i++) { const sidebar: SidebarComponent = _sidebars[i]; diff --git a/components/sidebar/sidebar.component.html b/components/sidebar/sidebar.component.html new file mode 100644 index 0000000..8f27cfb --- /dev/null +++ b/components/sidebar/sidebar.component.html @@ -0,0 +1,14 @@ + diff --git a/components/sidebar/sidebar.component.ts b/components/sidebar/sidebar.component.ts index 0943018..d4029e0 100644 --- a/components/sidebar/sidebar.component.ts +++ b/components/sidebar/sidebar.component.ts @@ -1,47 +1,41 @@ +import { DOCUMENT } from '@angular/common'; import { + ChangeDetectionStrategy, Component, - Input, - EventEmitter, - Output, ElementRef, - ViewChild, - SimpleChanges, + EventEmitter, + Inject, + Input, OnChanges, OnDestroy, - ChangeDetectionStrategy, - Inject, + Output, + SimpleChange, + SimpleChanges, + ViewChild, + ViewEncapsulation, } from '@angular/core'; +import { isIOS, InputBoolean } from 'ngx-weui/core'; import { Subscription } from 'rxjs'; -import { isIOS } from '../utils/browser'; -import { SidebarConfig, PositionType, ModeType } from './sidebar.config'; +import { ModeType, PositionType, SidebarConfig } from './sidebar.config'; import { SidebarService } from './sidebar.service'; -import { DOCUMENT } from '@angular/common'; /** * 侧边栏 */ @Component({ selector: 'weui-sidebar', - template: ` - - `, + exportAs: 'weuiSidebar', + templateUrl: './sidebar.component.html', + preserveWhitespaces: false, changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class SidebarComponent implements OnChanges, OnDestroy { /** * 状态,true表示打开,false表示关闭 */ - @Input() status: boolean = false; - @Output() statusChange: EventEmitter = new EventEmitter(); + @Input() @InputBoolean() status: boolean = false; + @Output() readonly statusChange = new EventEmitter(); /** * 位置方向,默认:`left` */ @@ -57,7 +51,7 @@ export class SidebarComponent implements OnChanges, OnDestroy { /** * 允许点击背景关闭,默认:`true` */ - @Input() backdrop: boolean = true; + @Input() @InputBoolean() backdrop: boolean = true; /** * 自定义CLSS */ @@ -68,21 +62,21 @@ export class SidebarComponent implements OnChanges, OnDestroy { @Input() ariaLabel: string; /** 打开前回调 */ - @Output() openStart: EventEmitter = new EventEmitter(); + @Output() readonly openStart = new EventEmitter(); /** 打开后回调 */ - @Output() opened: EventEmitter = new EventEmitter(); + @Output() readonly opened = new EventEmitter(); /** 关闭前回调 */ - @Output() closeStart: EventEmitter = new EventEmitter(); + @Output() readonly closeStart = new EventEmitter(); /** 关闭后回调 */ - @Output() closed: EventEmitter = new EventEmitter(); + @Output() readonly closed = new EventEmitter(); /** 模式变更通知 */ - @Output() modeChange: EventEmitter = new EventEmitter(); + @Output() readonly modeChange = new EventEmitter(); /** 位置变更通知 */ - @Output() positionChange: EventEmitter = new EventEmitter(); + @Output() readonly positionChange = new EventEmitter(); - @Output() _rerender: EventEmitter = new EventEmitter(); + @Output() readonly _rerender = new EventEmitter(); - @ViewChild('sidebar') _elSidebar: ElementRef; + @ViewChild('sidebar') private _elSidebar: ElementRef; private _openSub: Subscription; private _closeSub: Subscription; @@ -106,22 +100,22 @@ export class SidebarComponent implements OnChanges, OnDestroy { this._closeSub = this._sidebarService.onClose(this.close); } - ngOnChanges(changes: SimpleChanges): void { - if ('status' in changes && !this._anting) { - if (changes['status'].currentValue) { + ngOnChanges(changes: { [P in keyof this]?: SimpleChange } & SimpleChanges): void { + if (changes.status && !this._anting) { + if (changes.status.currentValue) { this.open(); } else { this.close(); } - if (changes['status'].firstChange) this._anting = false; + if (changes.status.firstChange) this._anting = false; } - if ('mode' in changes) { - this.modeChange.emit(changes['mode'].currentValue); + if (changes.mode) { + this.modeChange.emit(changes.mode.currentValue); } - if ('position' in changes) { - this.positionChange.emit(changes['position'].currentValue); + if (changes.position) { + this.positionChange.emit(changes.position.currentValue); } - if ('backdrop' in changes) { + if (changes.backdrop) { this._initCloseListeners(); } } @@ -165,24 +159,18 @@ export class SidebarComponent implements OnChanges, OnDestroy { } _getStyle(): CSSStyleDeclaration { - let transformStyle: string = 'none'; + let transformStyle = 'none'; const marginStyle = {}; const isSlideMode: boolean = this.mode === 'slide'; if (!this.status || isSlideMode) { - transformStyle = `translate${ - this.position === 'left' || this.position === 'right' ? 'X' : 'Y' - }`; - const isLeftOrTop: boolean = - this.position === 'left' || this.position === 'top'; - const translateAmt: string = `${isLeftOrTop ? '-' : ''}100%`; + transformStyle = `translate${this.position === 'left' || this.position === 'right' ? 'X' : 'Y'}`; + const isLeftOrTop: boolean = this.position === 'left' || this.position === 'top'; + const translateAmt = `${isLeftOrTop ? '-' : ''}100%`; transformStyle += `(${translateAmt})`; } - return Object.assign(marginStyle, { - webkitTransform: transformStyle, - transform: transformStyle, - }) as CSSStyleDeclaration; + return { ...marginStyle, webkitTransform: transformStyle, transform: transformStyle } as CSSStyleDeclaration; } private closeAnt() { @@ -217,26 +205,18 @@ export class SidebarComponent implements OnChanges, OnDestroy { } private _onClickOutside(e: Event): void { - if ( - this._onClickOutsideAttached && - this._elSidebar && - !this._elSidebar.nativeElement.contains(e.target) - ) { + if (this._onClickOutsideAttached && this._elSidebar && !this._elSidebar.nativeElement.contains(e.target as any)) { this.close(); } } /** 获取侧边栏容器高度 */ get _height(): number { - return this._elSidebar.nativeElement - ? this._elSidebar.nativeElement.offsetHeight - : 0; + return this._elSidebar.nativeElement ? this._elSidebar.nativeElement.offsetHeight : 0; } /** 获取侧边栏容器宽度 */ get _width(): number { - return this._elSidebar.nativeElement - ? this._elSidebar.nativeElement.offsetWidth - : 0; + return this._elSidebar.nativeElement ? this._elSidebar.nativeElement.offsetWidth : 0; } } diff --git a/components/sidebar/sidebar.config.ts b/components/sidebar/sidebar.config.ts index e3a3209..790c105 100644 --- a/components/sidebar/sidebar.config.ts +++ b/components/sidebar/sidebar.config.ts @@ -4,7 +4,7 @@ export type PositionType = 'left' | 'right' | 'top' | 'bottom'; export type ModeType = 'over' | 'slide'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class SidebarConfig { /** * 位置方向,默认:`left` diff --git a/components/sidebar/sidebar.module.ts b/components/sidebar/sidebar.module.ts index 5675c5e..5e05d7e 100644 --- a/components/sidebar/sidebar.module.ts +++ b/components/sidebar/sidebar.module.ts @@ -1,23 +1,16 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; +import { CloseSidebarDirective } from './close.directive'; import { SidebarContainerComponent } from './sidebar-container.component'; import { SidebarComponent } from './sidebar.component'; -import { CloseSidebarDirective } from './close.directive'; import { SidebarService } from './sidebar.service'; -import { SidebarConfig } from './sidebar.config'; + +const COMPONENTS = [SidebarContainerComponent, SidebarComponent, CloseSidebarDirective]; @NgModule({ imports: [CommonModule], - declarations: [ - SidebarContainerComponent, - SidebarComponent, - CloseSidebarDirective, - ], - exports: [SidebarContainerComponent, SidebarComponent, CloseSidebarDirective], + declarations: COMPONENTS, + exports: COMPONENTS, providers: [SidebarService], }) -export class SidebarModule { - static forRoot(): ModuleWithProviders { - return { ngModule: SidebarModule, providers: [SidebarConfig] }; - } -} +export class SidebarModule {} diff --git a/components/sidebar/sidebar.spec.ts b/components/sidebar/sidebar.spec.ts index 572e1b8..7de80a3 100644 --- a/components/sidebar/sidebar.spec.ts +++ b/components/sidebar/sidebar.spec.ts @@ -1,24 +1,8 @@ -import { Subscriber } from 'rxjs'; -import { Component, ViewChild, DebugElement } from '@angular/core'; -import { FormsModule } from '@angular/forms'; +import { Component, ViewChild } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - async, - inject, - discardPeriodicTasks, -} from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; - -import { - SidebarModule, - SidebarContainerComponent, - SidebarComponent, - CloseSidebarDirective, -} from '../sidebar'; + +import { SidebarComponent, SidebarModule } from '../sidebar'; describe('Component: Sidebar', () => { let fixture: ComponentFixture; @@ -28,7 +12,7 @@ describe('Component: Sidebar', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestSidebarComponent], - imports: [SidebarModule.forRoot(), NoopAnimationsModule], + imports: [SidebarModule, NoopAnimationsModule], }); fixture = TestBed.createComponent(TestSidebarComponent); context = fixture.componentInstance; @@ -52,111 +36,85 @@ describe('Component: Sidebar', () => { it('should set mode="over"', () => { context.mode = 'over'; fixture.detectChanges(); - expect(el.querySelector('.weui-sidebar').classList).toContain( - 'weui-sidebar__over', - ); + expect(el.querySelector('.weui-sidebar')!.classList).toContain('weui-sidebar__over'); }); for (const pos of ['left', 'right', 'top', 'bottom']) { it(`should set position="${pos}"`, () => { context.position = pos; fixture.detectChanges(); - expect(el.querySelector('.weui-sidebar').classList).toContain( - `weui-sidebar__${pos}`, - ); + expect(el.querySelector('.weui-sidebar')!.classList).toContain(`weui-sidebar__${pos}`); }); } - it( - 'should set ariaLabel', - fakeAsync(() => { - const str: string = 'value'; - context.ariaLabel = str; - fixture.detectChanges(); - tick(1000); - expect( - el.querySelector('.weui-sidebar').attributes['aria-label'].value, - ).toBe(str); - }), - ); - - it( - 'should be opened and status=true', - fakeAsync(() => { - context.status = true; - fixture.detectChanges(); - tick(1000); - expect(context.status).toBe(true); - }), - ); - - it( - 'should be closed and status=false', - fakeAsync(() => { - context.status = true; - fixture.detectChanges(); - tick(1000); - context.sidebar.close(); - fixture.detectChanges(); - tick(1000); - expect(context.sidebar.status).toBe(false); - }), - ); - - it( - 'should emit opens event', - fakeAsync(() => { - context.status = true; - fixture.detectChanges(); - tick(1000); - expect(context._openStart).toHaveBeenCalled(); - }), - ); - - it( - 'should emit closes event', - fakeAsync(() => { - context.status = true; - fixture.detectChanges(); - context.sidebar.close(); - fixture.detectChanges(); - tick(1000); - expect(context._closeStart).toHaveBeenCalled(); - }), - ); - - it( - 'should close via directive', - fakeAsync(() => { - context.status = true; - fixture.detectChanges(); - (el.querySelector('[closesidebar]') as HTMLDivElement).click(); - fixture.detectChanges(); - tick(1000); - expect(context._closeStart).toHaveBeenCalled(); - expect(context.status).toBe(false); - }), - ); - - it( - 'should closed via click mask', - fakeAsync(() => { - context._showBackdrop = true; - context.status = true; - fixture.detectChanges(); - (el.querySelector('.weui-mask') as HTMLElement).click(); - fixture.detectChanges(); - tick(1000); - expect(context._closeStart).toHaveBeenCalled(); - expect(context.status).toBe(false); - }), - ); + it('should set ariaLabel', fakeAsync(() => { + const str = 'value'; + context.ariaLabel = str; + fixture.detectChanges(); + tick(1000); + expect(el.querySelector('.weui-sidebar')!.attributes.getNamedItem('aria-label')!.value).toBe(str); + })); + + it('should be opened and status=true', fakeAsync(() => { + context.status = true; + fixture.detectChanges(); + tick(1000); + expect(context.status).toBe(true); + })); + + it('should be closed and status=false', fakeAsync(() => { + context.status = true; + fixture.detectChanges(); + tick(1000); + context.sidebar.close(); + fixture.detectChanges(); + tick(1000); + expect(context.sidebar.status).toBe(false); + })); + + it('should emit opens event', fakeAsync(() => { + context.status = true; + fixture.detectChanges(); + tick(1000); + expect(context._openStart).toHaveBeenCalled(); + })); + + it('should emit closes event', fakeAsync(() => { + context.status = true; + fixture.detectChanges(); + context.sidebar.close(); + fixture.detectChanges(); + tick(1000); + expect(context._closeStart).toHaveBeenCalled(); + })); + + it('should close via directive', fakeAsync(() => { + context.status = true; + fixture.detectChanges(); + (el.querySelector('[closesidebar]') as HTMLDivElement).click(); + fixture.detectChanges(); + tick(1000); + expect(context._closeStart).toHaveBeenCalled(); + expect(context.status).toBe(false); + })); + + it('should closed via click mask', fakeAsync(() => { + context._showBackdrop = true; + context.status = true; + fixture.detectChanges(); + (el.querySelector('.weui-mask') as HTMLElement).click(); + fixture.detectChanges(); + tick(1000); + expect(context._closeStart).toHaveBeenCalled(); + expect(context.status).toBe(false); + })); }); @Component({ template: ` - - + { (openStart)="_openStart()" (opened)="_opened()" (closeStart)="_closeStart()" - (closed)="_closed()">sidebar -

这是侧边栏内容

-
使用指令[closeSidebar]关闭
-
- `, + (closed)="_closed()" + >sidebar +

这是侧边栏内容

+
使用指令[closeSidebar]关闭
+ + `, }) class TestSidebarComponent { @ViewChild('sidebar') sidebar: SidebarComponent; diff --git a/components/slider/index.md b/components/slider/index.md index c65f9a6..bce3bce 100644 --- a/components/slider/index.md +++ b/components/slider/index.md @@ -10,6 +10,7 @@ module: SliderModule 参数 | 说明 | 类型 | 默认值 ----|------|-----|------ +weui-show-value | 是否显示文本 | `boolean` | `true` weui-min | 允许的最小值 | `number` | `0` weui-max | 允许的最大值 | `number` | `100` weui-step | 步长 | `number` | `1` diff --git a/components/slider/package.json b/components/slider/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/slider/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/slider/public-api.ts b/components/slider/public-api.ts index 02f16c4..010bd54 100644 --- a/components/slider/public-api.ts +++ b/components/slider/public-api.ts @@ -1,2 +1,2 @@ -export { SliderDirective } from './slider'; +export { SliderComponent as SliderDirective } from './slider.component'; export { SliderModule } from './slider.module'; diff --git a/components/slider/slider.component.html b/components/slider/slider.component.html new file mode 100644 index 0000000..07f038e --- /dev/null +++ b/components/slider/slider.component.html @@ -0,0 +1,13 @@ +
+
+
+
+ +
+
+
+
+
+
+
{{ value }}
+
diff --git a/components/slider/slider.component.ts b/components/slider/slider.component.ts new file mode 100644 index 0000000..67813a5 --- /dev/null +++ b/components/slider/slider.component.ts @@ -0,0 +1,193 @@ +import { + forwardRef, + AfterViewInit, + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + ElementRef, + EventEmitter, + Input, + OnChanges, + OnDestroy, + Output, + ViewEncapsulation, +} from '@angular/core'; +import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { InputBoolean, InputNumber } from 'ngx-weui/core'; + +@Component({ + selector: 'weui-slider, [weui-slider]', + exportAs: 'weuiSlider', + templateUrl: './slider.component.html', + host: { + '[class.weui-slider-box]': 'showValue', + '[class.weui-slider]': '!showValue', + '[class.weui-slider__disabled]': '!enabled', + }, + providers: [ + { + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => SliderComponent), + multi: true, + }, + ], + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, +}) +export class SliderComponent implements ControlValueAccessor, AfterViewInit, OnDestroy, OnChanges { + private el: HTMLElement; + private state: any = null; + private isInit: boolean = false; + private trackEl: HTMLElement; + private handlerEl: HTMLElement; + private onChange: (val: number) => void; + private onTouched: () => void; + private onTouchStart: any; + private onTouchMove: any; + + value: number = 0; + + /** + * 允许的最小值,默认:`0` + */ + @Input('weui-min') @InputNumber() min: number = 0; + + /** + * 允许的最大值,默认:`100` + */ + @Input('weui-max') @InputNumber() max: number = 100; + + /** + * 步长,默认:`1` + */ + @Input('weui-step') @InputNumber() step: number = 1; + + /** + * 是否可用 + */ + @Input('weui-enabled') @InputBoolean() enabled: boolean = true; + + @Input('weui-show-value') @InputBoolean() showValue: boolean = true; + /** + * 值改变时触发 + */ + @Output('weui-change') readonly change = new EventEmitter(); + + constructor(el: ElementRef, private cdr: ChangeDetectorRef) { + this.el = el.nativeElement; + } + + ngAfterViewInit() { + this.isInit = true; + this.trackEl = this.el.querySelector('.weui-slider__track')! as HTMLElement; + this.handlerEl = this.el.querySelector('.weui-slider__handler')! as HTMLElement; + + this.onTouchStart = this.startHandle.bind(this); + this.onTouchMove = this.moveHandle.bind(this); + this.handlerEl.addEventListener('touchstart', this.onTouchStart, false); + this.handlerEl.addEventListener('touchmove', this.onTouchMove, false); + } + + ngOnDestroy(): void { + this.handlerEl.removeEventListener('touchstart', this.onTouchStart, false); + this.handlerEl.removeEventListener('touchmove', this.onTouchMove, false); + } + + private refresh() { + this.state = { + enabled: this.enabled, + left: this.el.getBoundingClientRect().left, + size: (this.el.querySelector('.weui-slider__inner')! as HTMLElement).offsetWidth!, + percentage: [0, 0, 0], + x: 0, + }; + this.max = +this.max; + this.min = +this.min; + this.step = +this.step; + + this.setValue(this.value); + this.layout(); + } + + private setValue(value: number) { + if (this.max > this.min) { + this.state.percentage = [ + // tslint:disable-next-line: binary-expression-operand-order + (100 * (value - this.min)) / (this.max - this.min), + 0, + (this.step * 100) / (this.max - this.min), + ]; + } else { + this.state.percentage = [0, 0, 100]; + } + } + + private layout() { + this.trackEl.style.width = this.state.percentage[0] + '%'; + this.handlerEl.style.left = this.state.percentage[0] + '%'; + } + + private startHandle($event: TouchEvent) { + if (this.state === null) this.refresh(); + + this.state.x = ($event.touches[0] || $event.changedTouches[0]).pageX; + } + + private moveHandle($event: TouchEvent) { + if (!this.state.enabled) return false; + + const pageX = ($event.touches[0] || $event.changedTouches[0]).pageX; + + const xDiff = pageX - this.state.x; + if (xDiff >= 15 || xDiff <= 15) { + this.state.percentage[0] = this.getPercentage(pageX); + this.layout(); + this.calculateValue(this.state.percentage[0]); + } + } + + private getPercentage(pageX: number): number { + const distanceToSlide = pageX - this.state.left; + let percentage = (distanceToSlide / this.state.size) * 100; + percentage = Math.round(percentage / this.state.percentage[2]) * this.state.percentage[2]; + return Math.max(0, Math.min(100, percentage)); + } + + private calculateValue(percentage: number) { + const rawValue = (percentage / 100) * (this.max - this.min); + // adjustment = this.min + let value = this.min + Math.round(rawValue / this.step) * this.step; + if (value < this.min) value = this.min; + else if (value > this.max) value = this.max; + + this.value = value; + this.onChange(this.value); + this.onTouched(); + this.change.emit(this.value); + } + + ngOnChanges(): void { + if (this.isInit) this.refresh(); + } + + writeValue(value: number): void { + if (value) { + this.value = +value; + this.refresh(); + this.calculateValue(this.state.percentage[0]); + } + this.cdr.detectChanges(); + } + + registerOnChange(fn: (_: number) => void): void { + this.onChange = fn; + } + registerOnTouched(fn: () => void): void { + this.onTouched = fn; + } + + setDisabledState(isDisabled: boolean): void { + this.enabled = !isDisabled; + } +} diff --git a/components/slider/slider.module.ts b/components/slider/slider.module.ts index 0065d03..0827f08 100644 --- a/components/slider/slider.module.ts +++ b/components/slider/slider.module.ts @@ -1,14 +1,10 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; -import { SliderDirective } from './slider'; +import { NgModule } from '@angular/core'; +import { SliderComponent } from './slider.component'; @NgModule({ imports: [CommonModule], - declarations: [SliderDirective], - exports: [SliderDirective], + declarations: [SliderComponent], + exports: [SliderComponent], }) -export class SliderModule { - static forRoot(): ModuleWithProviders { - return { ngModule: SliderModule, providers: [] }; - } -} +export class SliderModule {} diff --git a/components/slider/slider.spec.ts b/components/slider/slider.spec.ts index 46339f7..ea8dd49 100644 --- a/components/slider/slider.spec.ts +++ b/components/slider/slider.spec.ts @@ -1,32 +1,23 @@ -import { Subscriber } from 'rxjs'; -import { Component, ViewChild, DebugElement, OnInit } from '@angular/core'; +import { Component, DebugElement } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - async, - inject, -} from '@angular/core/testing'; import { By } from '@angular/platform-browser'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { SliderComponent } from './slider.component'; import { SliderModule } from './slider.module'; -import { SliderDirective } from './slider'; -const CONTAINER_WIDTH = 500, - MIN = 1, - MAX = 100, - STEP = 1, - VALUE = 0, - REALVALUE = 1; +const CONTAINER_WIDTH = 500; +const MIN = 1; +const MAX = 100; +const STEP = 1; +const VALUE = 0; function spyTouchArgument(val: number) { return { touches: [{ pageX: val, identifier: 1 }], targetTouches: [{ pageX: val, identifier: 1 }], - preventDefault: function() {}, + preventDefault() {}, }; } @@ -34,136 +25,89 @@ const html = `
-
-
-
-
-
-
-
{{val}}
+(weui-change)="_change()" +[weui-show-value]="showValue">
`; -const htmlInValid = `
`; describe('Component: Slider', () => { let fixture: ComponentFixture; let context: TestSliderComponent; let el: HTMLElement; - let directive: SliderDirective; - - describe('[default]', () => { - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestSliderComponent], - imports: [SliderModule.forRoot(), FormsModule, NoopAnimationsModule], - }); - TestBed.overrideComponent(TestSliderComponent, { - set: { template: html }, - }); - fixture = TestBed.createComponent(TestSliderComponent); - context = fixture.componentInstance; - spyOn(context, '_change'); - el = fixture.nativeElement; - - const directives = fixture.debugElement.queryAll( - By.directive(SliderDirective), - ); - directive = directives.map( - (de: DebugElement) => - de.injector.get(SliderDirective) as SliderDirective, - )[0]; - - fixture.detectChanges(); - - tick(); - }), - ); - - it('should be defined on the test component', () => { - expect(directive).not.toBeNull(); - }); + let directive: SliderComponent; - it('should default values', () => { - expect(directive.min).toBe(MIN); - expect(directive.max).toBe(MAX); - expect(directive.step).toBe(STEP); - fixture.detectChanges(); - expect(context.val).toBe(VALUE); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestSliderComponent], + imports: [SliderModule, FormsModule, NoopAnimationsModule], + }); + TestBed.overrideComponent(TestSliderComponent, { + set: { template: html }, }); + fixture = TestBed.createComponent(TestSliderComponent); + context = fixture.componentInstance; + spyOn(context, '_change'); + el = fixture.nativeElement; + + const directives = fixture.debugElement.queryAll(By.directive(SliderComponent)); + directive = directives.map((de: DebugElement) => de.injector.get(SliderComponent))[0]; + + fixture.detectChanges(); + + tick(); + })); + + it('should be defined on the test component', () => { + expect(directive).not.toBeNull(); + }); - it( - 'should set value: 10', - fakeAsync(() => { - const val = 10; - context.val = val; - fixture.detectChanges(); - tick(10); - - expect(el.querySelector('.weui-slider-box__value').textContent).toBe( - '' + val, - ); - expect(context._change).toHaveBeenCalled(); - }), - ); - - it( - 'should exceed minimum return min value', - fakeAsync(() => { - context.val = -10; - fixture.detectChanges(); - tick(10); - - expect(context.val).toBe(MIN); - expect(context._change).toHaveBeenCalled(); - }), - ); - - it( - 'should exceed maximum return max value', - fakeAsync(() => { - context.val = 110; - fixture.detectChanges(); - tick(10); - - expect(context.val).toBe(MAX); - expect(context._change).toHaveBeenCalled(); - }), - ); - - it( - 'should be new value via touch', - fakeAsync(() => { - const moveSize = 1; - const result = Math.ceil(moveSize / CONTAINER_WIDTH * 100); - directive.onTouchStart(spyTouchArgument(0)); - directive.onTouchMove(spyTouchArgument(moveSize)); - fixture.detectChanges(); - tick(10); - expect(context.val).toBe(result); - expect(context._change).toHaveBeenCalled(); - }), - ); + it('should default values', () => { + expect(directive.min).toBe(MIN); + expect(directive.max).toBe(MAX); + expect(directive.step).toBe(STEP); + fixture.detectChanges(); + expect(context.val).toBe(VALUE); }); - it( - 'should be throw error if invalid html', - fakeAsync(() => { - expect(() => { - TestBed.configureTestingModule({ - declarations: [TestSliderComponent], - imports: [SliderModule.forRoot(), FormsModule, NoopAnimationsModule], - }); - TestBed.overrideComponent(TestSliderComponent, { - set: { template: htmlInValid }, - }); - TestBed.createComponent(TestSliderComponent).detectChanges(); - }).toThrowError(); - }), - ); + it('should set value: 10', fakeAsync(() => { + const val = 10; + context.val = val; + fixture.detectChanges(); + tick(10); + + expect(el.querySelector('.weui-slider-box__value')!.textContent).toBe('' + val); + expect(context._change).toHaveBeenCalled(); + })); + + it('should exceed minimum return min value', fakeAsync(() => { + context.val = -10; + fixture.detectChanges(); + tick(10); + + expect(context.val).toBe(MIN); + expect(context._change).toHaveBeenCalled(); + })); + + it('should exceed maximum return max value', fakeAsync(() => { + context.val = 110; + fixture.detectChanges(); + tick(10); + + expect(context.val).toBe(MAX); + expect(context._change).toHaveBeenCalled(); + })); + + it('should be new value via touch', fakeAsync(() => { + const moveSize = 1; + const result = Math.ceil((moveSize / CONTAINER_WIDTH) * 100); + // tslint:disable-next-line: no-string-literal + directive['onTouchStart'](spyTouchArgument(0)); + // tslint:disable-next-line: no-string-literal + directive['onTouchMove'](spyTouchArgument(moveSize)); + fixture.detectChanges(); + tick(10); + expect(context.val).toBe(result); + expect(context._change).toHaveBeenCalled(); + })); }); @Component({ template: `` }) @@ -174,5 +118,6 @@ class TestSliderComponent { max: number = MAX; step: number = STEP; enabled: boolean = true; + showValue = true; _change() {} } diff --git a/components/slider/slider.ts b/components/slider/slider.ts deleted file mode 100644 index a9cc2da..0000000 --- a/components/slider/slider.ts +++ /dev/null @@ -1,188 +0,0 @@ -import { - Directive, - forwardRef, - ElementRef, - OnDestroy, - HostListener, - ContentChild, - Input, - EventEmitter, - Output, - OnChanges, - SimpleChanges, - OnInit, -} from '@angular/core'; -import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; - -/** - * 滑块指令,支持[(ngModel)] - */ -@Directive({ - selector: '[weui-slider]', - providers: [ - { - provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => SliderDirective), - multi: true, - }, - ], -}) -export class SliderDirective - implements ControlValueAccessor, OnInit, OnDestroy, OnChanges { - private _state: any = null; - - private _value: number = 0; - - private isInit: boolean = false; - private trackEl: any; - private handlerEl: any; - onTouchStart: any; - onTouchMove: any; - - /** - * 允许的最小值,默认:`0` - */ - @Input('weui-min') min: number = 0; - - /** - * 允许的最大值,默认:`100` - */ - @Input('weui-max') max: number = 100; - - /** - * 步长,默认:`1` - */ - @Input('weui-step') step: number = 1; - - /** - * 是否可用 - */ - @Input('weui-enabled') enabled: boolean = true; - /** - * 值改变时触发 - */ - @Output('weui-change') change = new EventEmitter(); - - constructor(private el: ElementRef) { } - - ngOnInit() { - this.isInit = true; - this.trackEl = this.el.nativeElement.querySelector('.weui-slider__track'); - this.handlerEl = this.el.nativeElement.querySelector( - '.weui-slider__handler', - ); - if (this.trackEl === null || this.handlerEl === null) - throw new Error('失效DOM结构'); - - this.onTouchStart = this.startHandle.bind(this); - this.onTouchMove = this.moveHandle.bind(this); - this.handlerEl.addEventListener('touchstart', this.onTouchStart, false); - this.handlerEl.addEventListener('touchmove', this.onTouchMove, false); - } - - ngOnDestroy(): void { - this.handlerEl.removeEventListener('touchstart', this.onTouchStart, false); - this.handlerEl.removeEventListener('touchmove', this.onTouchMove, false); - } - - private refresh() { - const el = this.el.nativeElement; - this._state = { - enabled: this.enabled, - left: el.getBoundingClientRect().left, - size: el.querySelector('.weui-slider__inner').offsetWidth, - percentage: [0, 0, 0], - x: 0, - }; - this.max = +this.max; - this.min = +this.min; - this.step = +this.step; - - this.setValue(this._value); - this.layout(); - } - - private setValue(value: number) { - if (this.max > this.min) { - this._state.percentage = [ - 100 * (value - this.min) / (this.max - this.min), - 0, - this.step * 100 / (this.max - this.min), - ]; - } else { - this._state.percentage = [0, 0, 100]; - } - } - - private layout() { - this.trackEl.style.width = this._state.percentage[0] + '%'; - this.handlerEl.style.left = this._state.percentage[0] + '%'; - } - - private startHandle($event: any) { - if (this._state === null) this.refresh(); - - this._state.x = ($event.touches[0] || $event.changedTouches[0]).pageX; - } - - private moveHandle($event: any) { - if (!this._state.enabled) return false; - - const pageX = ($event.touches[0] || $event.changedTouches[0]).pageX; - - const xDiff = pageX - this._state.x; - if (xDiff >= 15 || xDiff <= 15) { - this._state.percentage[0] = this.getPercentage(pageX, $event); - this.layout(); - this.calculateValue(this._state.percentage[0]); - } - } - - private getPercentage(pageX: number, $event: any): number { - const distanceToSlide = pageX - this._state.left; - let percentage = distanceToSlide / this._state.size * 100; - percentage = - Math.round(percentage / this._state.percentage[2]) * - this._state.percentage[2]; - return Math.max(0, Math.min(100, percentage)); - } - - private calculateValue(percentage: number) { - const rawValue = percentage / 100 * (this.max - this.min); - // adjustment = this.min - let value = this.min + Math.round(rawValue / this.step) * this.step; - if (value < this.min) value = this.min; - else if (value > this.max) value = this.max; - - this._value = value; - this.onChange(this._value); - this.onTouched(); - this.change.emit(this._value); - } - - ngOnChanges(changes: SimpleChanges): void { - if (this.isInit) this.refresh(); - } - - writeValue(value: any): void { - if (value) { - this._value = +value; - this.refresh(); - this.calculateValue(this._state.percentage[0]); - } - } - - private onChange: any = Function.prototype; - private onTouched: any = Function.prototype; - - public registerOnChange(fn: (_: any) => {}): void { - this.onChange = fn; - } - public registerOnTouched(fn: () => {}): void { - this.onTouched = fn; - } - - setDisabledState(isDisabled: boolean): void { - this.enabled = !isDisabled; - } -} diff --git a/components/slider/style/index.less b/components/slider/style/index.less new file mode 100644 index 0000000..9f0b82a --- /dev/null +++ b/components/slider/style/index.less @@ -0,0 +1,10 @@ +@{weui-prefix}-slider { + display: block; +} + +.@{weui-prefix}-slider { + &__disabled { + opacity: 0.5; + pointer-events: none; + } +} diff --git a/components/stepper/package.json b/components/stepper/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/stepper/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/stepper/stepper.component.html b/components/stepper/stepper.component.html new file mode 100644 index 0000000..b6ddcd8 --- /dev/null +++ b/components/stepper/stepper.component.html @@ -0,0 +1,15 @@ +- +
+ +
++ diff --git a/components/stepper/stepper.component.ts b/components/stepper/stepper.component.ts index ef8eaf4..b1425f4 100644 --- a/components/stepper/stepper.component.ts +++ b/components/stepper/stepper.component.ts @@ -1,32 +1,26 @@ import { - Component, - Input, forwardRef, - Output, + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + ElementRef, EventEmitter, HostBinding, + Input, + Output, ViewChild, - ElementRef, + ViewEncapsulation, } from '@angular/core'; -import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms'; +import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { InputBoolean, InputNumber } from 'ngx-weui/core'; /** * Stepper 步进器,支持 `[(ngModel)]` */ @Component({ selector: 'weui-stepper', - template: ` - - -
- -
- + - `, + exportAs: 'weuiStepper', + templateUrl: './stepper.component.html', providers: [ { provide: NG_VALUE_ACCESSOR, @@ -34,27 +28,36 @@ import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms'; multi: true, }, ], + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class StepperComponent implements ControlValueAccessor { + private _value: number; + private onChange: any = Function.prototype; + // private onTouched: any = Function.prototype; + _step: number = 1; + _precisionStep = 0; + _precisionFactor = 1; + _disabledMinus: boolean = false; + _disabledPlus: boolean = false; /** 最小值 */ - @Input() min: number = -Infinity; + @Input() @InputNumber() min: number = -Infinity; /** 最大值 */ - @Input() max: number = Infinity; + @Input() @InputNumber() max: number = Infinity; /** 禁用 */ @Input() + @InputBoolean() @HostBinding('class.disabled') disabled: boolean = false; /** 变更时回调 */ - @Output() change = new EventEmitter(); + @Output() readonly change = new EventEmitter(); - _step: number = 1; - _precisionStep = 0; - _precisionFactor = 1; - - @ViewChild('inputNumber') _inputNumber: ElementRef; + @ViewChild('inputNumber') private _inputNumber: ElementRef; /** 步长,可以为小数 */ @Input() + @InputNumber() get step() { return this._step; } @@ -63,10 +66,7 @@ export class StepperComponent implements ControlValueAccessor { const stepString = value.toString(); if (stepString.indexOf('e-') >= 0) { - this._precisionStep = parseInt( - stepString.slice(stepString.indexOf('e-')), - 10, - ); + this._precisionStep = parseInt(stepString.slice(stepString.indexOf('e-')), 10); } if (stepString.indexOf('.') >= 0) { this._precisionStep = stepString.length - stepString.indexOf('.') - 1; @@ -74,8 +74,6 @@ export class StepperComponent implements ControlValueAccessor { this._precisionFactor = Math.pow(10, this._precisionStep); } - private _value: number; - get value() { return this._value; } @@ -94,14 +92,14 @@ export class StepperComponent implements ControlValueAccessor { this._value = value; this._checkDisabled(); } + this.cdr.detectChanges(); } - _disabledMinus: boolean = false; - _disabledPlus: boolean = false; + constructor(private cdr: ChangeDetectorRef) {} + _checkDisabled(): this { this._disabledPlus = this.disabled || !(this.value + this.step <= this.max); - this._disabledMinus = - this.disabled || !(this.value - this.step >= this.min); + this._disabledMinus = this.disabled || !(this.value - this.step >= this.min); return this; } @@ -116,8 +114,7 @@ export class StepperComponent implements ControlValueAccessor { if (this._disabledPlus) return; this.value = this._toPrecisionAsStep( - (this._precisionFactor * this.value + this._precisionFactor * this.step) / - this._precisionFactor, + (this._precisionFactor * this.value + this._precisionFactor * this.step) / this._precisionFactor, ); this._checkDisabled()._notify(); } @@ -128,8 +125,7 @@ export class StepperComponent implements ControlValueAccessor { if (this._disabledMinus) return; this.value = this._toPrecisionAsStep( - (this._precisionFactor * this.value - this._precisionFactor * this.step) / - this._precisionFactor, + (this._precisionFactor * this.value - this._precisionFactor * this.step) / this._precisionFactor, ); this._checkDisabled()._notify(); } @@ -137,7 +133,7 @@ export class StepperComponent implements ControlValueAccessor { _blur() { const el = this._inputNumber.nativeElement; this.value = +el.value; - el.value = this.value; + el.value = this.value.toString(); this._checkDisabled()._notify(); } @@ -153,14 +149,12 @@ export class StepperComponent implements ControlValueAccessor { this._checkDisabled(); } - private onChange: any = Function.prototype; - private onTouched: any = Function.prototype; - - public registerOnChange(fn: (_: any) => {}): void { + registerOnChange(fn: (_: any) => {}): void { this.onChange = fn; } - public registerOnTouched(fn: () => {}): void { - this.onTouched = fn; + + registerOnTouched(_fn: () => {}): void { + // this.onTouched = fn; } setDisabledState(isDisabled: boolean): void { diff --git a/components/stepper/stepper.module.ts b/components/stepper/stepper.module.ts index 1b7fa86..a4eac16 100644 --- a/components/stepper/stepper.module.ts +++ b/components/stepper/stepper.module.ts @@ -1,6 +1,6 @@ -import { FormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; import { StepperComponent } from './stepper.component'; @NgModule({ @@ -8,8 +8,4 @@ import { StepperComponent } from './stepper.component'; declarations: [StepperComponent], exports: [StepperComponent], }) -export class StepperModule { - static forRoot(): ModuleWithProviders { - return { ngModule: StepperModule, providers: [] }; - } -} +export class StepperModule {} diff --git a/components/stepper/stepper.spec.ts b/components/stepper/stepper.spec.ts deleted file mode 100644 index e69de29..0000000 diff --git a/components/style/fixed/_preserve-white-spaces.less b/components/style/fixed/_preserve-white-spaces.less index 2581a2b..498a064 100644 --- a/components/style/fixed/_preserve-white-spaces.less +++ b/components/style/fixed/_preserve-white-spaces.less @@ -3,6 +3,11 @@ .weui-btn + .weui-btn { margin-left: @gutter; } + .weui-btn-area { + .weui-btn + .weui-btn { + margin-left: auto; + } + } } .preserve-white-spaces-mixin(@preserve-white-spaces-enabled); diff --git a/components/style/fixed/index.less b/components/style/fixed/index.less index 7625ca2..a00dc27 100644 --- a/components/style/fixed/index.less +++ b/components/style/fixed/index.less @@ -1 +1 @@ -@import "./_preserve-white-spaces"; +@import './_preserve-white-spaces'; diff --git a/components/style/theme.less b/components/style/theme.less index 86a41cc..a9c33c5 100644 --- a/components/style/theme.less +++ b/components/style/theme.less @@ -1,3 +1,8 @@ +@weui-prefix: ~'weui'; + +// base color +@weuiColorDefault: #b2b2b2; +@weuiColorInfo: #586c94; // dialog @dialog-error-font-size: 14px; @dialog-error-color: #f50; @@ -18,9 +23,10 @@ @stepper-color: rgb(134, 134, 134); @stepper-font-size: 20px; // toptips -@toptips-bg-default: #B2B2B2; -@toptips-bg-info: #586C94; -@toptips-bg-primary: #1AAD19; +@toptips-bg-default: @weuiColorDefault; +@toptips-bg-warn: @weuiColorWarn; +@toptips-bg-info: @weuiColorInfo; +@toptips-bg-primary: @weuiColorPrimary; // fixed @gutter: 8px; @preserve-white-spaces-enabled: true; diff --git a/components/swiper/package.json b/components/swiper/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/swiper/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/swiper/swiper.component.ts b/components/swiper/swiper.component.ts index 7dce2d0..b6160f2 100644 --- a/components/swiper/swiper.component.ts +++ b/components/swiper/swiper.component.ts @@ -1,15 +1,15 @@ import { + AfterViewInit, + ChangeDetectionStrategy, Component, + ElementRef, Input, + NgZone, OnChanges, - SimpleChanges, OnDestroy, - EventEmitter, - Output, - ElementRef, - NgZone, OnInit, - AfterViewInit, + SimpleChanges, + ViewEncapsulation, } from '@angular/core'; import { SwiperConfig } from './swiper.config'; @@ -17,20 +17,21 @@ declare const Swiper: any; @Component({ selector: 'weui-swiper', - template: ``, + exportAs: 'weuiSwiper', + template: ` + + `, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) -export class SwiperComponent - implements AfterViewInit, OnChanges, OnInit, OnDestroy { +export class SwiperComponent implements AfterViewInit, OnChanges, OnInit, OnDestroy { /** * 等同于swiper[参数项](http://idangero.us/swiper/api/) */ @Input() options: any; - constructor( - private el: ElementRef, - private zone: NgZone, - private DEF: SwiperConfig, - ) {} + constructor(private el: ElementRef, private zone: NgZone, private DEF: SwiperConfig) {} /** * Swiper 实例对象,可以通过 `@ViewChild` 访问到它 @@ -38,7 +39,7 @@ export class SwiperComponent swiper: any; private initOptions() { - this.options = Object.assign({}, this.DEF.options, this.options); + this.options = { ...this.DEF.options, ...this.options }; } private containerEl: HTMLElement; @@ -67,8 +68,7 @@ export class SwiperComponent ngOnInit() { if (!this.options) this.initOptions(); this.containerEl = this.el.nativeElement.querySelector('.swiper-container'); - if (!this.containerEl) - throw new Error('组件内容的HTML跟swiper所需要的DOM结构必须完全一样。'); + if (!this.containerEl) throw new Error('组件内容的HTML跟swiper所需要的DOM结构必须完全一样。'); } ngAfterViewInit() { @@ -78,7 +78,7 @@ export class SwiperComponent ngOnChanges(changes: SimpleChanges): void { if ('options' in changes) { this.initOptions(); - if (!changes['options'].firstChange) { + if (!changes.options.firstChange) { this.init(); } } diff --git a/components/swiper/swiper.config.ts b/components/swiper/swiper.config.ts index 0c7f037..47e3d05 100644 --- a/components/swiper/swiper.config.ts +++ b/components/swiper/swiper.config.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class SwiperConfig { /** * 等同于swiper[参数项](http://idangero.us/swiper/api/) diff --git a/components/swiper/swiper.module.ts b/components/swiper/swiper.module.ts index c0f60c9..4a09cbe 100644 --- a/components/swiper/swiper.module.ts +++ b/components/swiper/swiper.module.ts @@ -1,17 +1,10 @@ -import { FormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { SwiperComponent } from './swiper.component'; -import { SwiperConfig } from './swiper.config'; @NgModule({ - imports: [CommonModule, FormsModule], + imports: [CommonModule], declarations: [SwiperComponent], exports: [SwiperComponent], - providers: [SwiperConfig], }) -export class SwiperModule { - static forRoot(): ModuleWithProviders { - return { ngModule: SwiperModule, providers: [SwiperConfig] }; - } -} +export class SwiperModule {} diff --git a/components/swiper/swiper.spec.ts b/components/swiper/swiper.spec.ts index 0c6d875..b3c6830 100644 --- a/components/swiper/swiper.spec.ts +++ b/components/swiper/swiper.spec.ts @@ -1,20 +1,10 @@ -import { Subscriber } from 'rxjs'; -import { Component, ViewChild, DebugElement } from '@angular/core'; -import { FormsModule } from '@angular/forms'; +import { Component, ViewChild } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - async, - inject, -} from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; -import { SwiperModule, SwiperComponent } from '../swiper'; +import { SwiperComponent, SwiperModule } from '../swiper'; -const correct_html: string = ` +const correct_html = `
@@ -25,7 +15,7 @@ const correct_html: string = `
`; -const incorrect_html: string = ` +const incorrect_html = `
@@ -43,22 +33,20 @@ describe('Component: Swiper', () => { let el: HTMLElement; describe('[basic]', () => { - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestSwiperComponent], - imports: [SwiperModule.forRoot(), NoopAnimationsModule], - }); - TestBed.overrideComponent(TestSwiperComponent, { - set: { template: correct_html }, - }); - fixture = TestBed.createComponent(TestSwiperComponent); - context = fixture.componentInstance; - el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestSwiperComponent], + imports: [SwiperModule, NoopAnimationsModule], + }); + TestBed.overrideComponent(TestSwiperComponent, { + set: { template: correct_html }, + }); + fixture = TestBed.createComponent(TestSwiperComponent); + context = fixture.componentInstance; + el = fixture.nativeElement; + fixture.detectChanges(); + tick(); + })); it('should be inited if correct DOM structure', () => { expect(context.comp.swiper).not.toBeNull(); @@ -69,9 +57,7 @@ describe('Component: Swiper', () => { direction: 'vertical', }; fixture.detectChanges(); - expect(el.querySelector('.swiper-container').classList).toContain( - 'swiper-container-vertical', - ); + expect(el.querySelector('.swiper-container')!.classList).toContain('swiper-container-vertical'); }); }); @@ -80,7 +66,7 @@ describe('Component: Swiper', () => { try { TestBed.configureTestingModule({ declarations: [TestSwiperComponent], - imports: [SwiperModule.forRoot(), NoopAnimationsModule], + imports: [SwiperModule, NoopAnimationsModule], }); TestBed.overrideComponent(TestSwiperComponent, { set: { template: incorrect_html }, @@ -89,9 +75,7 @@ describe('Component: Swiper', () => { fixture.detectChanges(); expect(false).toBe(true); } catch (ex) { - expect(ex.toString()).toBe( - 'Error: 组件内容的HTML跟swiper所需要的DOM结构必须完全一样。', - ); + expect(ex.toString()).toBe('Error: 组件内容的HTML跟swiper所需要的DOM结构必须完全一样。'); } }); }); diff --git a/components/tab/bar.component.ts b/components/tab/bar.component.ts index 031108a..41faa77 100644 --- a/components/tab/bar.component.ts +++ b/components/tab/bar.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy } from '@angular/core'; +import { ChangeDetectorRef, Component, OnDestroy } from '@angular/core'; import { TabDirective } from './tab.directive'; @Component({ @@ -9,6 +9,8 @@ export class BarComponent implements OnDestroy { tabs: TabDirective[] = []; protected isDestroyed: boolean; + constructor(private cdr: ChangeDetectorRef) {} + add(tab: TabDirective) { this.tabs.push(tab); tab.active = this.tabs.length === 1 && tab.active !== false; @@ -34,6 +36,10 @@ export class BarComponent implements OnDestroy { tab.select.emit(tab); } + detectChanges() { + this.cdr.detectChanges(); + } + protected getClosestTabIndex(index: number): number { const tabsLength = this.tabs.length; if (!tabsLength) { diff --git a/components/tab/navbar.component.html b/components/tab/navbar.component.html new file mode 100644 index 0000000..0ed6010 --- /dev/null +++ b/components/tab/navbar.component.html @@ -0,0 +1,12 @@ +
+
+ {{ item.heading }} +
+
+
diff --git a/components/tab/navbar.component.ts b/components/tab/navbar.component.ts index c0724ef..7651ed1 100644 --- a/components/tab/navbar.component.ts +++ b/components/tab/navbar.component.ts @@ -1,4 +1,4 @@ -import { Component, forwardRef } from '@angular/core'; +import { forwardRef, ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core'; import { BarComponent } from './bar.component'; /** @@ -6,20 +6,14 @@ import { BarComponent } from './bar.component'; */ @Component({ selector: 'weui-navbar', - template: ` -
-
{{item.heading}}
-
-
- `, - providers: [ - { provide: BarComponent, useExisting: forwardRef(() => NavbarComponent) }, - ], + exportAs: 'weuiNavbar', + templateUrl: './navbar.component.html', + providers: [{ provide: BarComponent, useExisting: forwardRef(() => NavbarComponent) }], host: { '[class.weui-tab]': 'true', }, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) -export class NavbarComponent extends BarComponent { } +export class NavbarComponent extends BarComponent {} diff --git a/components/tab/package.json b/components/tab/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/tab/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/tab/tab.directive.ts b/components/tab/tab.directive.ts index f00a2b3..52fc701 100644 --- a/components/tab/tab.directive.ts +++ b/components/tab/tab.directive.ts @@ -1,20 +1,16 @@ -import { - Directive, - Input, - HostBinding, - Output, - EventEmitter, - OnDestroy, - OnChanges, -} from '@angular/core'; +import { Directive, EventEmitter, HostBinding, Input, OnChanges, OnDestroy, Output } from '@angular/core'; +import { InputBoolean } from 'ngx-weui/core'; import { BarComponent } from './bar.component'; -@Directive({ selector: 'weui-tab, [weui-tab]' }) +@Directive({ + selector: 'weui-tab, [weui-tab]', + exportAs: 'weuiTab', +}) export class TabDirective implements OnDestroy, OnChanges { /** 选项卡名称 */ @Input() heading: string; /** 是否禁用 */ - @Input() disabled: boolean; + @Input() @InputBoolean() disabled: boolean; /** icon图标,支持HTML */ @Input() icon: string; /** 激活时icon图标,支持HTML */ @@ -34,6 +30,7 @@ export class TabDirective implements OnDestroy, OnChanges { */ @HostBinding('class.active') @Input() + @InputBoolean() get active(): boolean { return this._active; } @@ -48,7 +45,7 @@ export class TabDirective implements OnDestroy, OnChanges { } this._active = active; - this._tabComp.tabs.filter(t => t !== this).forEach(tab => tab.active = false); + this._tabComp.tabs.filter(t => t !== this).forEach(tab => (tab.active = false)); } protected _active: boolean; @@ -63,6 +60,7 @@ export class TabDirective implements OnDestroy, OnChanges { if (!this.activeIcon) { this.activeIcon = this.icon; } + this._tabComp.detectChanges(); } ngOnDestroy(): void { diff --git a/components/tab/tab.module.ts b/components/tab/tab.module.ts index 9088913..6d52085 100644 --- a/components/tab/tab.module.ts +++ b/components/tab/tab.module.ts @@ -1,18 +1,17 @@ -import { FormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; -import { TabDirective } from './tab.directive'; +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; + +import { BarComponent } from './bar.component'; import { NavbarComponent } from './navbar.component'; +import { TabDirective } from './tab.directive'; import { TabbarComponent } from './tabbar.component'; -import { BarComponent } from './bar.component'; + +const COMPONENTS = [TabDirective, NavbarComponent, TabbarComponent, BarComponent]; @NgModule({ imports: [CommonModule, FormsModule], - declarations: [TabDirective, NavbarComponent, TabbarComponent, BarComponent], - exports: [TabDirective, NavbarComponent, TabbarComponent], + declarations: COMPONENTS, + exports: COMPONENTS, }) -export class TabModule { - static forRoot(): ModuleWithProviders { - return { ngModule: TabModule, providers: [] }; - } -} +export class TabModule {} diff --git a/components/tab/tab.spec.ts b/components/tab/tab.spec.ts index c06f200..781ffd3 100644 --- a/components/tab/tab.spec.ts +++ b/components/tab/tab.spec.ts @@ -1,23 +1,7 @@ -import { Subscriber } from 'rxjs'; -import { Component, ViewChild, DebugElement } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - async, - inject, -} from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; - -import { - TabModule, - NavbarComponent, - TabbarComponent, - TabDirective, -} from '../tab'; +import { Component } from '@angular/core'; +import { fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TabModule } from './tab.module'; const TABS: any[] = [ { @@ -38,7 +22,7 @@ const TABS: any[] = [ { heading: 'tab4', content: 'tab4 content', active: false, removable: true }, ]; const navbar_html = ` - + {{item.content}} - + `; const tabbar_html = ` @@ -77,8 +61,8 @@ function getContents(nativeEl: HTMLElement): NodeListOf { } function expectActiveTabs(nativeEl: HTMLElement, action: boolean[]) { - const items = getItems(nativeEl), - contents = getContents(nativeEl); + const items = getItems(nativeEl); + const contents = getContents(nativeEl); expect(items.length).toBe(action.length); expect(contents.length).toBe(action.length); @@ -99,25 +83,23 @@ describe('Component: Tabs', () => { let el: any; describe('[Navbar]', () => { - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestTabComponent], - imports: [TabModule.forRoot()], - }); - TestBed.overrideComponent(TestTabComponent, { - set: { template: navbar_html }, - }); - fixture = TestBed.createComponent(TestTabComponent); - context = fixture.componentInstance; - spyOn(context, '_select'); - spyOn(context, '_deselect'); - spyOn(context, '_removed'); - el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestTabComponent], + imports: [TabModule], + }); + TestBed.overrideComponent(TestTabComponent, { + set: { template: navbar_html }, + }); + fixture = TestBed.createComponent(TestTabComponent); + context = fixture.componentInstance; + spyOn(context, '_select'); + spyOn(context, '_deselect'); + spyOn(context, '_removed'); + el = fixture.nativeElement; + fixture.detectChanges(); + tick(); + })); it('should select first tab as active by default', () => { expectActiveTabs(el, [true, false, false, false]); @@ -130,10 +112,10 @@ describe('Component: Tabs', () => { }); it('should set tab heading', () => { - const newTitle: string = 'new title'; + const newTitle = 'new title'; context.tabs[0].heading = newTitle; fixture.detectChanges(); - expect(getItems(el)[0].innerHTML).toBe(newTitle); + expect(getItems(el)[0].innerHTML.trim()).toBe(newTitle); }); it('should set tab disabled', () => { @@ -160,53 +142,43 @@ describe('Component: Tabs', () => { }); describe('[Tabbar]', () => { - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestTabComponent], - imports: [TabModule.forRoot()], - }); - TestBed.overrideComponent(TestTabComponent, { - set: { template: tabbar_html }, - }); - fixture = TestBed.createComponent(TestTabComponent); - context = fixture.componentInstance; - spyOn(context, '_select'); - spyOn(context, '_deselect'); - spyOn(context, '_removed'); - el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestTabComponent], + imports: [TabModule], + }); + TestBed.overrideComponent(TestTabComponent, { + set: { template: tabbar_html }, + }); + fixture = TestBed.createComponent(TestTabComponent); + context = fixture.componentInstance; + spyOn(context, '_select'); + spyOn(context, '_deselect'); + spyOn(context, '_removed'); + el = fixture.nativeElement; + fixture.detectChanges(); + tick(); + })); it('should set tab has icon', () => { - expect( - (getItemsByTabbar(el)[0] as HTMLElement).querySelector( - '.weui-tabbar__icon', - ), - ).not.toBeNull(); + expect((getItemsByTabbar(el)[0] as HTMLElement).querySelector('.weui-tabbar__icon')).not.toBeNull(); }); it('should set tab badge number value', () => { - expect( - (getItemsByTabbar(el)[0] as HTMLElement).querySelector('.weui-badge') - .innerHTML, - ).toBe('8'); + expect((getItemsByTabbar(el)[0] as HTMLElement).querySelector('.weui-badge')!.innerHTML).toBe('8'); }); it('should set tab badge dot value', () => { - expect( - (getItemsByTabbar(el)[1] as HTMLElement).querySelector('.weui-badge') - .classList, - ).toContain('weui-badge_dot'); + expect((getItemsByTabbar(el)[1] as HTMLElement).querySelector('.weui-badge')!.classList).toContain( + 'weui-badge_dot', + ); }); }); }); @Component({ template: `` }) class TestTabComponent { - tabs: any[] = Object.assign([], TABS); + tabs: any[] = [...TABS]; _select(e: TabModule): TabModule { return e; diff --git a/components/tab/tabbar.component.html b/components/tab/tabbar.component.html new file mode 100644 index 0000000..af72879 --- /dev/null +++ b/components/tab/tabbar.component.html @@ -0,0 +1,25 @@ +
+
+
+
+
+ {{ item.badge }} + +
+

{{ item.heading }}

+
+
diff --git a/components/tab/tabbar.component.ts b/components/tab/tabbar.component.ts index 0d4846d..1927c6d 100644 --- a/components/tab/tabbar.component.ts +++ b/components/tab/tabbar.component.ts @@ -1,4 +1,4 @@ -import { Component, forwardRef } from '@angular/core'; +import { forwardRef, ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core'; import { BarComponent } from './bar.component'; /** @@ -6,25 +6,14 @@ import { BarComponent } from './bar.component'; */ @Component({ selector: 'weui-tabbar', - template: ` -
-
-
-
-
- {{item.badge}} - -
-

{{item.heading}}

-
-
- `, - providers: [ - { provide: BarComponent, useExisting: forwardRef(() => TabbarComponent) }, - ], + exportAs: 'weuiTabbar', + templateUrl: './tabbar.component.html', + providers: [{ provide: BarComponent, useExisting: forwardRef(() => TabbarComponent) }], host: { '[class.weui-tab]': 'true', }, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) -export class TabbarComponent extends BarComponent { } +export class TabbarComponent extends BarComponent {} diff --git a/components/test.ts b/components/test.ts index 1631789..3dd0c6c 100644 --- a/components/test.ts +++ b/components/test.ts @@ -1,10 +1,13 @@ +// tslint:disable:ordered-imports +// tslint:disable:no-import-side-effect + // This file is required by karma.conf.js and loads recursively all the .spec and framework files import 'zone.js/dist/zone-testing'; import { getTestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, - platformBrowserDynamicTesting + platformBrowserDynamicTesting, } from '@angular/platform-browser-dynamic/testing'; declare const require: any; @@ -12,7 +15,7 @@ declare const require: any; // First, initialize the Angular testing environment. getTestBed().initTestEnvironment( BrowserDynamicTestingModule, - platformBrowserDynamicTesting() + platformBrowserDynamicTesting(), ); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); diff --git a/components/toast/package.json b/components/toast/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/toast/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/toast/public-api.ts b/components/toast/public-api.ts index ab5f113..3c4d132 100644 --- a/components/toast/public-api.ts +++ b/components/toast/public-api.ts @@ -1,4 +1,4 @@ export { ToastService } from './toast.service'; export { ToastComponent } from './toast.component'; -export { ToastConfig } from './toast.config'; +export * from './toast.config'; export { ToastModule } from './toast.module'; diff --git a/components/toast/toast.component.html b/components/toast/toast.component.html new file mode 100644 index 0000000..eef492d --- /dev/null +++ b/components/toast/toast.component.html @@ -0,0 +1,5 @@ +
+
+ +

{{ text }}

+
diff --git a/components/toast/toast.component.ts b/components/toast/toast.component.ts index 1a2e196..93d4b79 100644 --- a/components/toast/toast.component.ts +++ b/components/toast/toast.component.ts @@ -1,25 +1,25 @@ import { + ChangeDetectionStrategy, Component, - HostBinding, - Input, - Output, EventEmitter, + Input, OnDestroy, + Output, + ViewEncapsulation, } from '@angular/core'; +import { InputNumber } from 'ngx-weui/core'; import { ToastConfig } from './toast.config'; @Component({ selector: 'weui-toast', - template: ` -
-
- -

{{text}}

-
- `, + exportAs: 'weuiToast', + templateUrl: './toast.component.html', host: { '[hidden]': '!_showd', }, + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class ToastComponent implements OnDestroy { /** @@ -40,11 +40,11 @@ export class ToastComponent implements OnDestroy { /** * 显示时长后自动关闭(单位:ms),0 表示永久,默认:`2000` */ - @Input() time: number = 2000; + @Input() @InputNumber() time: number = 2000; /** * 隐藏后回调 */ - @Output() hide = new EventEmitter(); + @Output() readonly hide = new EventEmitter(); constructor(private DEF: ToastConfig) { this.type = 'success'; diff --git a/components/toast/toast.config.ts b/components/toast/toast.config.ts index f1b7f91..ac745e5 100644 --- a/components/toast/toast.config.ts +++ b/components/toast/toast.config.ts @@ -1,9 +1,12 @@ import { Injectable } from '@angular/core'; -// tslint:disable-next-line:interface-over-type-literal -export type ToastConfigType = { text: string; icon: string; time: number }; +export interface ToastConfigType { + text: string; + icon: string; + time: number; +} -@Injectable() +@Injectable({ providedIn: 'root' }) export class ToastConfig { /** * 成功配置项 diff --git a/components/toast/toast.module.ts b/components/toast/toast.module.ts index bfec12f..96bd86b 100644 --- a/components/toast/toast.module.ts +++ b/components/toast/toast.module.ts @@ -1,18 +1,11 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { ToastComponent } from './toast.component'; -import { ToastService } from './toast.service'; -import { ToastConfig } from './toast.config'; @NgModule({ imports: [CommonModule], declarations: [ToastComponent], exports: [ToastComponent], - providers: [ToastService], entryComponents: [ToastComponent], }) -export class ToastModule { - static forRoot(): ModuleWithProviders { - return { ngModule: ToastModule, providers: [ToastConfig] }; - } -} +export class ToastModule {} diff --git a/components/toast/toast.service.ts b/components/toast/toast.service.ts index ba91f0d..cf5110c 100644 --- a/components/toast/toast.service.ts +++ b/components/toast/toast.service.ts @@ -1,8 +1,8 @@ import { Injectable } from '@angular/core'; -import { BaseService } from '../utils/base.service'; +import { BaseService } from 'ngx-weui/core'; import { ToastComponent } from './toast.component'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class ToastService extends BaseService { /** * 构建toast并显示 @@ -12,12 +12,7 @@ export class ToastService extends BaseService { * @param [icon] icon图标Class名(可选) * @param [type] 类型(可选) */ - show( - text?: string, - time?: number, - icon?: string, - type?: 'success' | 'loading', - ): ToastComponent { + show(text?: string, time?: number, icon?: string, type?: 'success' | 'loading'): ToastComponent { const componentRef = this.build(ToastComponent); if (type) componentRef.instance.type = type; diff --git a/components/toast/toast.spec.ts b/components/toast/toast.spec.ts index 47a7992..e442000 100644 --- a/components/toast/toast.spec.ts +++ b/components/toast/toast.spec.ts @@ -1,126 +1,87 @@ -import { Subscriber } from 'rxjs'; -import { Component, ViewChild, DebugElement } from '@angular/core'; +import { Component, ViewChild } from '@angular/core'; +import { fakeAsync, inject, tick, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - ComponentFixtureAutoDetect, - async, - inject, -} from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; -import { - ToastModule, - ToastComponent, - ToastConfig, - ToastService, -} from '../toast'; +import { ToastComponent, ToastModule, ToastService } from '../toast'; describe('Component: Toast', () => { describe('[default]', () => { let fixture: ComponentFixture; let context: TestToastComponent; - let dl: DebugElement; let el: HTMLElement; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestToastComponent], - imports: [ToastModule.forRoot(), NoopAnimationsModule], - }); - fixture = TestBed.createComponent(TestToastComponent); - context = fixture.componentInstance; - dl = fixture.debugElement; - el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestToastComponent], + imports: [ToastModule, NoopAnimationsModule], + }); + fixture = TestBed.createComponent(TestToastComponent); + context = fixture.componentInstance; + el = fixture.nativeElement; + fixture.detectChanges(); + tick(); + })); it('should default values', () => { - expect(el.querySelector('.weui-toast__content').textContent).toBe( - '已完成', - ); - expect(el.querySelector('.weui-icon_toast').classList).toContain( - 'weui-icon-success-no-circle', - ); + expect(el.querySelector('.weui-toast__content')!.textContent).toBe('已完成'); + expect(el.querySelector('.weui-icon_toast')!.classList).toContain('weui-icon-success-no-circle'); }); it('should be open by onShow()', () => { context.toast.onShow(); fixture.detectChanges(); - expect( - el.querySelector('weui-toast').attributes['hidden'], - ).toBeUndefined(); + expect(el.querySelector('weui-toast')!.attributes.getNamedItem('hidden')).toBeNull(); }); - it( - 'should hide', - fakeAsync(() => { - context.toast.onShow(); - fixture.detectChanges(); - // 等待动画结束 - tick(200); - fixture.detectChanges(); - expect( - el.querySelector('weui-toast').attributes['hidden'], - ).not.toBeUndefined(); - tick(); - }), - ); + it('should hide', fakeAsync(() => { + context.toast.onShow(); + fixture.detectChanges(); + // 等待动画结束 + tick(200); + fixture.detectChanges(); + expect(el.querySelector('weui-toast')!.attributes.getNamedItem('hidden')).not.toBeNull(); + tick(); + })); }); describe('[service]', () => { let service: ToastService; let fixture: any; - let context: TestToastServiceComponent; - let dl: DebugElement; let el: any; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - imports: [ToastModule.forRoot(), FormsModule, NoopAnimationsModule], - declarations: [TestToastServiceComponent], - providers: [ToastService], - }).createComponent(TestToastServiceComponent); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + imports: [ToastModule, FormsModule, NoopAnimationsModule], + declarations: [TestToastServiceComponent], + providers: [ToastService], + }).createComponent(TestToastServiceComponent); - fixture = TestBed.createComponent(TestToastServiceComponent); - context = fixture.componentInstance; - dl = fixture.debugElement; - el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); + fixture = TestBed.createComponent(TestToastServiceComponent); + el = fixture.nativeElement; + fixture.detectChanges(); + tick(); + })); - beforeEach( - inject([ToastService], (_s: ToastService) => { - service = _s; - }), - ); + beforeEach(inject([ToastService], (_s: ToastService) => { + service = _s; + })); - it( - 'should show success toast', - fakeAsync(() => { - service.show('success', 100); - fixture.detectChanges(); - // 等待动画结束 - tick(500); - fixture.detectChanges(); - expect(el.parentElement.querySelector('weui-toast')).toBeNull(); - }), - ); + it('should show success toast', fakeAsync(() => { + service.show('success', 100); + fixture.detectChanges(); + // 等待动画结束 + tick(500); + fixture.detectChanges(); + expect(el.parentElement.querySelector('weui-toast')).toBeNull(); + })); }); }); @Component({ - template: `

Test Service

`, + template: ` +

Test Service

+ `, }) class TestToastServiceComponent {} @@ -128,7 +89,7 @@ class TestToastServiceComponent {} selector: 'test-component', template: ` - `, + `, }) class TestToastComponent { @ViewChild(ToastComponent) toast: ToastComponent; diff --git a/components/toptips/index.md b/components/toptips/index.md index a5dea7b..fed9a54 100644 --- a/components/toptips/index.md +++ b/components/toptips/index.md @@ -12,7 +12,7 @@ module: ToptipsModule ----|------|-----|------ text | 文本 | `string` | - time | 显示时长后自动关闭(单位:ms),0 表示永久 | `number` | `2000` -type | 类型 | `default,warn,info,primary,success` | - +type | 类型 | `default,warn,info,primary,success` | `primary` hide | 隐藏后回调 | `EventEmitter` | - ### ToptipsService diff --git a/components/toptips/package.json b/components/toptips/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/toptips/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/toptips/public-api.ts b/components/toptips/public-api.ts index 0443bd7..d1bb69b 100644 --- a/components/toptips/public-api.ts +++ b/components/toptips/public-api.ts @@ -1,3 +1,3 @@ -export { ToptipsComponent } from './toptips.component'; -export { ToptipsService } from './toptips.service'; -export { ToptipsModule } from './toptips.module'; +export * from './toptips.component'; +export * from './toptips.service'; +export * from './toptips.module'; diff --git a/components/toptips/style/index.less b/components/toptips/style/index.less index 07b7749..d5e2ab3 100644 --- a/components/toptips/style/index.less +++ b/components/toptips/style/index.less @@ -1,11 +1,14 @@ .weui-toptips { - &_default { + &__default { background-color: @toptips-bg-default; } - &_info { + &__warn { + background-color: @toptips-bg-warn; + } + &__info { background-color: @toptips-bg-info; } - &_primary { + &__primary { background-color: @toptips-bg-primary; } } diff --git a/components/toptips/toptips.component.ts b/components/toptips/toptips.component.ts index c6b65ac..b257083 100644 --- a/components/toptips/toptips.component.ts +++ b/components/toptips/toptips.component.ts @@ -1,23 +1,38 @@ import { + ChangeDetectionStrategy, Component, - Input, + ElementRef, EventEmitter, - Output, - OnInit, + Input, + OnChanges, OnDestroy, + OnInit, + Output, + ViewEncapsulation, } from '@angular/core'; +import { InputNumber, UpdateHostClassService } from 'ngx-weui/core'; export type ToptipsType = 'default' | 'warn' | 'info' | 'primary' | 'success'; @Component({ selector: 'weui-toptips', + exportAs: 'weuiToptips', template: ` -
{{text}}
`, + {{ text }} + `, host: { '[hidden]': '!_showd', + '[style.display]': '_showd ? "block" : "none"', }, + providers: [UpdateHostClassService], + preserveWhitespaces: false, + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) -export class ToptipsComponent implements OnInit, OnDestroy { +export class ToptipsComponent implements OnInit, OnChanges, OnDestroy { + private timer: any; + _showd: boolean = false; + /** * 文本 */ @@ -25,43 +40,41 @@ export class ToptipsComponent implements OnInit, OnDestroy { /** * 显示时长后自动关闭(单位:ms),默认:`2000` */ - @Input() time: number = 2000; - /** - * 隐藏后回调 - */ - @Output() hide = new EventEmitter(); + @Input() @InputNumber() time: number = 2000; - _type: ToptipsType; /** * 类型 */ - @Input() - set type(_type: ToptipsType) { - this._type = _type; - this.setClassMap(); + @Input() type: ToptipsType = 'primary'; + /** + * 隐藏后回调 + */ + @Output() readonly hide = new EventEmitter(); + + constructor(private el: ElementRef, private uhcs: UpdateHostClassService) {} + + private setClassMap(): void { + const prefixCls = 'weui-toptips'; + const { uhcs, el, type } = this; + uhcs.updateHostClass(el.nativeElement, { + [`${prefixCls}`]: true, + [`${prefixCls}__${type}`]: true, + }); } ngOnInit() { this.setClassMap(); } - _classMap: any = {}; - private setClassMap(): void { - this._classMap = { - [`weui-toptips_${this._type}`]: true, - }; + ngOnChanges(): void { + this.setClassMap(); } - _showd: boolean = false; - private timer: any; - onShow() { this.destroy(); this._showd = true; - this.timer = setTimeout(() => { - this.onHide(); - }, this.time); + this.timer = setTimeout(() => this.onHide(), this.time); return this; } diff --git a/components/toptips/toptips.module.ts b/components/toptips/toptips.module.ts index ff1f01e..6178f54 100644 --- a/components/toptips/toptips.module.ts +++ b/components/toptips/toptips.module.ts @@ -1,17 +1,11 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { ToptipsComponent } from './toptips.component'; -import { ToptipsService } from './toptips.service'; @NgModule({ imports: [CommonModule], declarations: [ToptipsComponent], exports: [ToptipsComponent], - providers: [ToptipsService], entryComponents: [ToptipsComponent], }) -export class ToptipsModule { - static forRoot(): ModuleWithProviders { - return { ngModule: ToptipsModule, providers: [] }; - } -} +export class ToptipsModule {} diff --git a/components/toptips/toptips.service.ts b/components/toptips/toptips.service.ts index 5e5c181..4427128 100644 --- a/components/toptips/toptips.service.ts +++ b/components/toptips/toptips.service.ts @@ -1,10 +1,9 @@ import { Injectable } from '@angular/core'; -import { BaseService } from '../utils/base.service'; -import { ToptipsType, ToptipsComponent } from './toptips.component'; +import { BaseService } from 'ngx-weui/core'; +import { ToptipsComponent, ToptipsType } from './toptips.component'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class ToptipsService extends BaseService { - /** * 构建一个Toptips并显示 * diff --git a/components/toptips/toptips.spec.ts b/components/toptips/toptips.spec.ts index 040f543..b42bad5 100644 --- a/components/toptips/toptips.spec.ts +++ b/components/toptips/toptips.spec.ts @@ -1,19 +1,9 @@ -import { Subscriber } from 'rxjs'; -import { Component, ViewChild, DebugElement } from '@angular/core'; +import { Component, ViewChild } from '@angular/core'; +import { fakeAsync, inject, tick, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { - ComponentFixture, - TestBed, - fakeAsync, - tick, - ComponentFixtureAutoDetect, - async, - inject, -} from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; -import { ToptipsModule, ToptipsComponent, ToptipsService } from '../toptips'; +import { ToptipsComponent, ToptipsModule, ToptipsService } from '../toptips'; describe('Component: Toptips', () => { describe('[default]', () => { @@ -21,103 +11,85 @@ describe('Component: Toptips', () => { let context: TestToptipsComponent; let el: HTMLElement; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - declarations: [TestToptipsComponent], - imports: [ToptipsModule.forRoot(), NoopAnimationsModule], - }); - fixture = TestBed.createComponent(TestToptipsComponent); - context = fixture.componentInstance; - fixture.detectChanges(); - el = fixture.nativeElement; - tick(); - }), - ); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + declarations: [TestToptipsComponent], + imports: [ToptipsModule, NoopAnimationsModule], + }); + fixture = TestBed.createComponent(TestToptipsComponent); + context = fixture.componentInstance; + fixture.detectChanges(); + el = fixture.nativeElement; + tick(); + })); it('should default values', () => { - expect(el.querySelector('.weui-toptips').textContent).toBe('content'); - expect(el.querySelector('.weui-toptips').classList).toContain( - 'weui-toptips_success', - ); + expect(el.querySelector('.weui-toptips')!.textContent!.trim()).toBe('content'); + expect(el.querySelector('.weui-toptips')!.classList).toContain('weui-toptips__success'); }); it('should be open by onShow()', () => { context.toptips.onShow(); fixture.detectChanges(); - expect( - el.querySelector('weui-toptips').attributes['hidden'], - ).toBeUndefined(); + expect(el.querySelector('weui-toptips')!.attributes.getNamedItem('hidden')).toBeNull(); }); - it( - 'should hide', - fakeAsync(() => { - context.toptips.onShow(); - fixture.detectChanges(); - // 等待动画结束 - tick(200); - fixture.detectChanges(); - expect( - el.querySelector('weui-toptips').attributes['hidden'], - ).not.toBeUndefined(); - tick(); - }), - ); + it('should hide', fakeAsync(() => { + context.toptips.onShow(); + fixture.detectChanges(); + // 等待动画结束 + tick(200); + fixture.detectChanges(); + expect(el.querySelector('weui-toptips')!.attributes.getNamedItem('hidden')).not.toBeNull(); + tick(); + })); }); describe('[service]', () => { let service: ToptipsService; let fixture: any; - let context: TestToptipsServiceComponent; - let dl: DebugElement; let el: any; - beforeEach( - fakeAsync(() => { - TestBed.configureTestingModule({ - imports: [ToptipsModule.forRoot(), FormsModule, NoopAnimationsModule], - declarations: [TestToptipsServiceComponent], - providers: [ToptipsService], - }).createComponent(TestToptipsServiceComponent); + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + imports: [ToptipsModule, FormsModule, NoopAnimationsModule], + declarations: [TestToptipsServiceComponent], + providers: [ToptipsService], + }).createComponent(TestToptipsServiceComponent); - fixture = TestBed.createComponent(TestToptipsServiceComponent); - context = fixture.componentInstance; - dl = fixture.debugElement; - el = fixture.nativeElement; - fixture.detectChanges(); - tick(); - }), - ); + fixture = TestBed.createComponent(TestToptipsServiceComponent); + el = fixture.nativeElement; + fixture.detectChanges(); + tick(); + })); - beforeEach( - inject([ToptipsService], (_s: ToptipsService) => { - service = _s; - }), - ); + beforeEach(inject([ToptipsService], (_s: ToptipsService) => { + service = _s; + })); - it( - 'should show success toptips', - fakeAsync(() => { - service.success('success', 100); - fixture.detectChanges(); - // 等待动画结束 - tick(200); - fixture.detectChanges(); - expect(el.parentElement.querySelector('weui-toptips')).toBeNull(); - }), - ); + it('should show success toptips', fakeAsync(() => { + service.success('success', 100); + fixture.detectChanges(); + // 等待动画结束 + tick(200); + fixture.detectChanges(); + expect(el.parentElement.querySelector('weui-toptips')).toBeNull(); + })); }); }); @Component({ - template: `

Test Service

`, + template: ` +

Test Service

+ `, }) class TestToptipsServiceComponent {} @Component({ selector: 'test-component', - template: ``, + template: ` + + `, }) class TestToptipsComponent { @ViewChild(ToptipsComponent) toptips: ToptipsComponent; diff --git a/components/tsconfig.json b/components/tsconfig.json index 642e1df..36ad017 100644 --- a/components/tsconfig.json +++ b/components/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../tsconfig.json", "compilerOptions": { + "baseUrl": "./", + "rootDir": "./", "target": "es5", "module": "es2015", "sourceMap": false, @@ -9,12 +11,14 @@ "experimentalDecorators": true, "declaration": true, "outDir": "../release", - "lib": ["es2015", "dom"] + "lib": ["es2015", "dom"], + "paths": { + "ngx-weui": ["./ngx-weui.module"], + "ngx-weui/*": ["./*"] + } }, - "files": [ - "./ngx-weui.module.ts" - ], + "files": ["./ngx-weui.module.ts"], "angularCompilerOptions": { "skipTemplateCodegen": true } -} \ No newline at end of file +} diff --git a/components/tsconfig.lib.json b/components/tsconfig.lib.json index 423551b..a97a958 100644 --- a/components/tsconfig.lib.json +++ b/components/tsconfig.lib.json @@ -1,7 +1,8 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "baseUrl": "./", + "baseUrl": ".", + "rootDir": ".", "target": "es2015", "module": "es2015", "sourceMap": true, @@ -26,4 +27,4 @@ "flatModuleId": "AUTOGENERATED", "flatModuleOutFile": "AUTOGENERATED" } -} \ No newline at end of file +} diff --git a/components/tsconfig.spec.json b/components/tsconfig.spec.json index 9afc85e..3963df2 100644 --- a/components/tsconfig.spec.json +++ b/components/tsconfig.spec.json @@ -6,17 +6,8 @@ "module": "commonjs", "esModuleInterop": true, "target": "es5", - "types": [ - "jasmine", - "node" - ] + "types": ["jasmine"] }, - "files": [ - "test.ts", - "polyfills.ts" - ], - "include": [ - "**/*.spec.ts", - "**/*.d.ts" - ] -} \ No newline at end of file + "files": ["test.ts", "polyfills.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts"] +} diff --git a/components/uploader/file-item.class.ts b/components/uploader/file-item.class.ts index ec66c5d..04cc4d5 100644 --- a/components/uploader/file-item.class.ts +++ b/components/uploader/file-item.class.ts @@ -1,10 +1,8 @@ import { FileLikeObject } from './file-like-object.class'; -import { Uploader } from './uploader.class'; import { ParsedResponseHeaders } from './interface'; +import { Uploader } from './uploader.class'; import { UploaderOptions } from './uploader.options'; -declare const window: any; - /** * 文件对象 */ @@ -82,7 +80,7 @@ export class FileItem { } setOptions(options: UploaderOptions) { - this.options = Object.assign({}, this.uploader.options, options); + this.options = { ...this.uploader.options, ...options }; } /** @@ -130,8 +128,7 @@ export class FileItem { _onProgress(progress: number): any { this.progress = progress; - if (this.options.onUploadProgress) - this.options.onUploadProgress(this, progress, this.uploader.progress); + if (this.options.onUploadProgress) this.options.onUploadProgress(this, progress, this.uploader.progress); } _onSuccess(response: string, status: number, headers: ParsedResponseHeaders) { @@ -142,10 +139,9 @@ export class FileItem { this.isCancel = false; this.isError = false; this.progress = 100; - this.index = void 0; + this.index = 0; - if (this.options.onUploadSuccess) - this.options.onUploadSuccess(this, response, status, headers); + if (this.options.onUploadSuccess) this.options.onUploadSuccess(this, response, status, headers); } _onError(response: string, status: number, headers: ParsedResponseHeaders) { @@ -156,30 +152,20 @@ export class FileItem { this.isCancel = false; this.isError = true; this.progress = 0; - this.index = void 0; + this.index = 0; - if (this.options.onUploadError) - this.options.onUploadError(this, response, status, headers); + if (this.options.onUploadError) this.options.onUploadError(this, response, status, headers); } - _onComplete( - response: string, - status: number, - headers: ParsedResponseHeaders, - ): void { + _onComplete(response: string, status: number, headers: ParsedResponseHeaders): void { if (this.uploader.options.removeAfterUpload) { this.remove(); } - if (this.options.onUploadComplete) - this.options.onUploadComplete(this, response, status, headers); + if (this.options.onUploadComplete) this.options.onUploadComplete(this, response, status, headers); } - _onCancel( - response: string, - status: number, - headers: ParsedResponseHeaders, - ): any { + _onCancel(): any { this.isReady = false; this.isUploading = false; this.isUploaded = false; @@ -187,7 +173,7 @@ export class FileItem { this.isCancel = true; this.isError = false; this.progress = 0; - this.index = void 0; + this.index = 0; if (this.options.onUploadCancel) this.options.onUploadCancel(this); } diff --git a/components/uploader/file-like-object.class.ts b/components/uploader/file-like-object.class.ts index 20faf82..370c90d 100644 --- a/components/uploader/file-like-object.class.ts +++ b/components/uploader/file-like-object.class.ts @@ -12,8 +12,7 @@ export class FileLikeObject { constructor(fileOrInput: any) { const isInput = isElement(fileOrInput); const fakePathOrObject = isInput ? fileOrInput.value : fileOrInput; - const postfix = - typeof fakePathOrObject === 'string' ? 'FakePath' : 'Object'; + const postfix = typeof fakePathOrObject === 'string' ? 'FakePath' : 'Object'; const method = '_createFrom' + postfix; (this as any)[method](fakePathOrObject); } @@ -25,11 +24,7 @@ export class FileLikeObject { this.name = path.slice(path.lastIndexOf('/') + path.lastIndexOf('\\') + 2); } - _createFromObject(object: { - size: number; - type: string; - name: string; - }): void { + _createFromObject(object: { size: number; type: string; name: string }): void { // this.lastModifiedDate = copy(object.lastModifiedDate); this.size = object.size; this.type = object.type; diff --git a/components/uploader/file-thumb.directive.ts b/components/uploader/file-thumb.directive.ts index bfedd9b..ab31068 100644 --- a/components/uploader/file-thumb.directive.ts +++ b/components/uploader/file-thumb.directive.ts @@ -1,11 +1,5 @@ -import { - Directive, - Input, - ElementRef, - OnChanges, - SimpleChanges, -} from '@angular/core'; -import { isImage, genImageUrl } from '../utils/browser'; +import { Directive, ElementRef, Input, OnChanges } from '@angular/core'; +import { genImageUrl } from 'ngx-weui/core'; /** * 创建缩略图 @@ -26,7 +20,7 @@ export class FileThumbDirective implements OnChanges { this.el.nativeElement.style.backgroundImage = `url(${url})`; } - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { this.render(); } } diff --git a/components/uploader/file-thumb.spec.ts b/components/uploader/file-thumb.spec.ts index 6953fb4..cafa869 100644 --- a/components/uploader/file-thumb.spec.ts +++ b/components/uploader/file-thumb.spec.ts @@ -1,8 +1,8 @@ -import { TestBed, ComponentFixture } from '@angular/core/testing'; import { Component, DebugElement } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { UploaderModule, FileThumbDirective } from '../uploader'; import { By } from '@angular/platform-browser'; +import { FileThumbDirective, UploaderModule } from '../uploader'; const html = `
`; @@ -13,7 +13,7 @@ describe('Component: file-thumb', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestFileThumbComponent], - imports: [UploaderModule.forRoot()], + imports: [UploaderModule], }); TestBed.overrideComponent(TestFileThumbComponent, { set: { template: html }, @@ -23,32 +23,25 @@ describe('Component: file-thumb', () => { directives = fixture.debugElement .queryAll(By.directive(FileThumbDirective)) - .map( - (de: DebugElement) => - de.injector.get(FileThumbDirective) as FileThumbDirective, - ); + .map((de: DebugElement) => de.injector.get(FileThumbDirective)); }); it('should be init', () => { fixture.componentInstance.file = new File( - [ - 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkWK1WDwAC1gFS81OXVgAAAABJRU5ErkJggg==', - ], + ['iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkWK1WDwAC1gFS81OXVgAAAABJRU5ErkJggg=='], 'test.png', { type: 'image/png' }, ); fixture.detectChanges(); expect(directives.length).toBe(1); - const divEl = fixture.debugElement.query(By.css('[weui-thumb]')) - .nativeElement as HTMLDivElement; + const divEl = fixture.debugElement.query(By.css('[weui-thumb]')).nativeElement as HTMLDivElement; expect(divEl).not.toBeNull(); expect(divEl.style.backgroundImage).toContain('blob:'); }); it('should invalid image', () => { expect(directives.length).toBe(1); - const divEl = fixture.debugElement.query(By.css('[weui-thumb]')) - .nativeElement as HTMLDivElement; + const divEl = fixture.debugElement.query(By.css('[weui-thumb]')).nativeElement as HTMLDivElement; expect(divEl).not.toBeNull(); expect(divEl.style.backgroundImage).toBe(''); }); diff --git a/components/uploader/package.json b/components/uploader/package.json new file mode 100644 index 0000000..61f8a57 --- /dev/null +++ b/components/uploader/package.json @@ -0,0 +1,7 @@ +{ + "ngPackage": { + "lib": { + "entryFile": "public-api.ts" + } + } +} \ No newline at end of file diff --git a/components/uploader/uploader.class.spec.ts b/components/uploader/uploader.class.spec.ts index bdff567..f622519 100644 --- a/components/uploader/uploader.class.spec.ts +++ b/components/uploader/uploader.class.spec.ts @@ -1,26 +1,22 @@ -import { TestBed, fakeAsync, tick } from '@angular/core/testing'; -import { Uploader } from './uploader.class'; +import { fakeAsync, tick } from '@angular/core/testing'; import * as sinon from 'sinon'; +import { Uploader } from './uploader.class'; describe('Uploader: Class', () => { - let instance: Uploader = null; - let xhr: any, requests: any[]; + let instance: Uploader; + let xhr: any; + let requests: any[]; - function addFiles( - count: number = 1, - ext: string = 'png', - type: string = 'image/png', - ) { + function addFiles(count: number = 1, ext: string = 'png', type: string = 'image/png') { for (let i = 0; i < count; i++) { - const textFileAsBlob = new Blob(['a' + i], { type: type }); + const textFileAsBlob = new Blob(['a' + i], { type }); const f = new File([textFileAsBlob], `${i + 1}.${ext}`); instance.addToQueue([f]); } } beforeEach(() => { - instance = null; - instance = new Uploader(); + instance = new Uploader({}); xhr = sinon.useFakeXMLHttpRequest(); requests = []; xhr.onCreate = function(req) { @@ -66,10 +62,7 @@ describe('Uploader: Class', () => { for (const item of files) { instance.clearQueue(); addFiles(1, item.e, item.t); - expect(instance.queue.length).toBe( - 0, - `the ${item.e} file need invalid`, - ); + expect(instance.queue.length).toBe(0, `the ${item.e} file need invalid`); } }); }); @@ -95,14 +88,11 @@ describe('Uploader: Class', () => { expect(instance.isUploading).toBe(true); }); - it( - '#cancelItem should be', - fakeAsync(() => { - addFiles(1, 'png'); - instance.uploadItem(instance.queue[0]); - instance.cancelItem(instance.queue[0]); - tick(100); - expect(instance.queue[0].isCancel).toBe(true); - }), - ); + it('#cancelItem should be', fakeAsync(() => { + addFiles(1, 'png'); + instance.uploadItem(instance.queue[0]); + instance.cancelItem(instance.queue[0]); + tick(100); + expect(instance.queue[0].isCancel).toBe(true); + })); }); diff --git a/components/uploader/uploader.class.ts b/components/uploader/uploader.class.ts index 2cd32ae..c703662 100644 --- a/components/uploader/uploader.class.ts +++ b/components/uploader/uploader.class.ts @@ -1,17 +1,17 @@ -import { Optional, Inject } from '@angular/core'; -import { UploaderOptions, FilterFunction } from './uploader.options'; +import { Inject, Optional } from '@angular/core'; import { FileItem } from './file-item.class'; -import { UploaderConfig } from './uploader.config'; import { FileLikeObject } from './file-like-object.class'; import { FileType } from './file-type.class'; import { ParsedResponseHeaders } from './interface'; +import { UploaderConfig } from './uploader.config'; +import { FilterFunction, UploaderOptions } from './uploader.options'; /** * 内置HTML5上传组件 */ export class Uploader { private _options: UploaderOptions; - private _queue: Array = []; + private _queue: FileItem[] = []; private _progress: number = 0; private _isUploading: boolean = false; private _nextIndex: number = 0; @@ -67,7 +67,7 @@ export class Uploader { * Creates an instance of Uploader. */ constructor( - options?: UploaderOptions, + options: UploaderOptions, @Inject(UploaderConfig) @Optional() private globalConfig?: UploaderConfig, @@ -82,53 +82,52 @@ export class Uploader { * @param includeOldQueue 是否包括已存在队列中的文件 */ setOptions(options: UploaderOptions, includeOldQueue: boolean = true) { - this._options = Object.assign( - { - filters: [], - disableMultipart: false, - method: 'POST', - alias: 'file', - withCredentials: true, - auto: false, - limit: -1, - size: -1, - removeAfterUpload: false, - }, - this.globalConfig, - this._options, - options, - ); + this._options = { + filters: [], + disableMultipart: false, + method: 'POST', + alias: 'file', + withCredentials: true, + auto: false, + limit: -1, + size: -1, + removeAfterUpload: false, + ...this.globalConfig, + ...this._options, + ...options, + } as UploaderOptions; // 数量 if (this._options.limit !== -1) - this._options.filters.unshift({ + this._options.filters!.unshift({ name: 'queueLimit', fn: this._queueLimitFilter, }); // 大小 if (this._options.size !== -1) - this._options.filters.unshift({ + this._options.filters!.unshift({ name: 'fileSize', fn: this._fileSizeFilter, }); // 类型 if (this._options.types) - this._options.filters.unshift({ + this._options.filters!.unshift({ name: 'fileType', fn: this._fileTypeFilter, }); // mime类型 if (this._options.mimes) - this._options.filters.unshift({ + this._options.filters!.unshift({ name: 'mimeType', fn: this._mimeTypeFilter, }); // 对已经存在的队列重置所有配置信息 if (includeOldQueue) { + // tslint:disable-next-line: prefer-for-of for (let i = 0; i < this._queue.length; i++) { this._queue[i].setOptions(this._options); } @@ -136,34 +135,22 @@ export class Uploader { } private _queueLimitFilter(): boolean { - return ( - this._options.limit === undefined || - this._queue.length < this._options.limit - ); + return this._options.limit === undefined || this._queue.length < this._options.limit; } - private _fileSizeFilter(item: FileLikeObject): boolean { - return !(this._options.size && item.size > this._options.size); + private _fileSizeFilter(item?: FileLikeObject, _options?: UploaderOptions): boolean { + return !(this._options.size && item!.size > this._options.size); } - private _mimeTypeFilter(item: FileLikeObject): boolean { - return !( - this._options.mimes && this._options.mimes.indexOf(item.type) === -1 - ); + private _mimeTypeFilter(item?: FileLikeObject, _options?: UploaderOptions): boolean { + return !(this._options.mimes && this._options.mimes.indexOf(item!.type) === -1); } - private _fileTypeFilter(item: FileLikeObject): boolean { - return !( - this._options.types && - this._options.types.indexOf(FileType.getMimeClass(item)) === -1 - ); + private _fileTypeFilter(item?: FileLikeObject, _options?: UploaderOptions): boolean { + return !(this._options.types && this._options.types.indexOf(FileType.getMimeClass(item!)) === -1); } - private _isValidFile( - file: FileLikeObject, - filters: FilterFunction[], - options: UploaderOptions, - ): boolean { + private _isValidFile(file: FileLikeObject, filters: FilterFunction[], options: UploaderOptions): boolean { this._failFilterIndex = -1; return !filters.length ? true @@ -175,15 +162,13 @@ export class Uploader { /** 过滤器,如果未指定采用内置 */ private _getFilters(filters: FilterFunction[] | string): FilterFunction[] { - if (!filters) return this._options.filters; + if (!filters) return this._options.filters!; if (Array.isArray(filters)) return filters; if (typeof filters === 'string') { - const names = filters.match(/[^\s,]+/g); - return this._options.filters.filter( - (filter: any) => names.indexOf(filter.name) !== -1, - ); + const names = filters.match(/[^\s,]+/g)!; + return this._options.filters!.filter((filter: any) => names.indexOf(filter.name) !== -1); } - return this._options.filters; + return this._options.filters!; } private _getIndexOfItem(value: any): number { @@ -209,14 +194,10 @@ export class Uploader { * @param options 强制重新指定新 `options` 内容 * @param filters 强制重新指定新 `filters` 内容 */ - addToQueue( - files: File[], - options?: UploaderOptions, - filters?: FilterFunction[] | string, - ) { + addToQueue(files: File[], options?: UploaderOptions, filters?: FilterFunction[] | string) { const list: File[] = []; for (const file of files) list.push(file); - const arrayOfFilters = this._getFilters(filters); + const arrayOfFilters = this._getFilters(filters!); const count = this._queue.length; const addedFileItems: FileItem[] = []; if (!options) { @@ -224,14 +205,14 @@ export class Uploader { } list.map((some: File) => { const temp = new FileLikeObject(some); - if (this._isValidFile(temp, arrayOfFilters, options)) { - const fileItem = new FileItem(this, some, options); + if (this._isValidFile(temp, arrayOfFilters, options!)) { + const fileItem = new FileItem(this, some, options!); addedFileItems.push(fileItem); this._queue.push(fileItem); if (this._options.onFileQueued) this._options.onFileQueued(fileItem); } else { const filter = arrayOfFilters[this._failFilterIndex]; - if (this._options.onError) this._options.onError(temp, filter, options); + if (this._options.onError) this._options.onError(temp, filter, options!); } }); @@ -239,7 +220,7 @@ export class Uploader { this._progress = this._getTotalProgress(); } - if (this.options.auto) { + if (this.options!.auto) { this.uploadAll(); } } @@ -249,7 +230,7 @@ export class Uploader { * * @param value FileItem对象或下标 */ - removeFromQueue(value: FileItem | Number): void { + removeFromQueue(value: FileItem | number): void { const index = this._getIndexOfItem(value); const item = this._queue[index]; if (item.isUploading) { @@ -293,8 +274,8 @@ export class Uploader { const item = this._queue[index]; if (item && item.isUploading) { if (item.options.abortTransport) { - this._onCancelItem(item, null, null, null); - this._onCompleteItem(item, null, null, null); + this._onCancelItem(item); + this._onCompleteItem(item, null!, null!, null!); item.options.abortTransport(item); } else { if (item._xhr) item._xhr.abort(); @@ -306,9 +287,7 @@ export class Uploader { * 上传队列中所有未上传的文件 */ uploadAll(): void { - const items = this.getNotUploadedItems().filter( - (item: FileItem) => !item.isUploading, - ); + const items = this.getNotUploadedItems().filter((item: FileItem) => !item.isUploading); if (!items.length) { return; } @@ -337,12 +316,10 @@ export class Uploader { // 自实现 if (item.options.uploadTransport) { - item.options.uploadTransport - .apply(this, [item]) - .subscribe((response: any) => { - this._onSuccessItem(item, response, 0, null); - this._onCompleteItem(item, response, 0, null); - }); + item.options.uploadTransport.apply(this, [item]).subscribe((response: any) => { + this._onSuccessItem(item, response, 0, null!); + this._onCompleteItem(item, response, 0, null!); + }); return this; } @@ -355,7 +332,7 @@ export class Uploader { sendable = new FormData(); Object.keys(this._options.params || {}).forEach((key: string) => - sendable.append(key, this._options.params[key]), + sendable.append(key, this._options.params![key]), ); sendable.append(item.options.alias, item._file, item.file.name); @@ -364,16 +341,14 @@ export class Uploader { } xhr.upload.onprogress = (event: any) => { - const progress = Math.round( - event.lengthComputable ? event.loaded * 100 / event.total : 0, - ); + const progress = Math.round(event.lengthComputable ? (event.loaded * 100) / event.total : 0); this._onProgressItem(item, progress); }; xhr.onload = () => { const headers = this._parseHeaders(xhr.getAllResponseHeaders()); const response = this._transformResponse(xhr.response, headers); const gist = this._isSuccessCode(xhr.status) ? 'Success' : 'Error'; - const method = '_on' + gist + 'Item'; + const method = `_on${gist}Item`; (this as any)[method](item, response, xhr.status, headers); this._onCompleteItem(item, response, xhr.status, headers); }; @@ -386,11 +361,11 @@ export class Uploader { xhr.onabort = () => { const headers = this._parseHeaders(xhr.getAllResponseHeaders()); const response = this._transformResponse(xhr.response, headers); - this._onCancelItem(item, response, xhr.status, headers); + this._onCancelItem(item); this._onCompleteItem(item, response, xhr.status, headers); }; - xhr.open(item.options.method, item.options.url, true); - xhr.withCredentials = item.options.withCredentials; + xhr.open(item.options.method!, item.options.url!, true); + xhr.withCredentials = item.options.withCredentials!; if (item.options.headers && item.options.headers.length > 0) { for (const header of item.options.headers) { xhr.setRequestHeader(header.name, header.value); @@ -405,11 +380,9 @@ export class Uploader { return value; } const notUploaded = this.getNotUploadedItems().length; - const uploaded = notUploaded - ? this._queue.length - notUploaded - : this._queue.length; + const uploaded = notUploaded ? this._queue.length - notUploaded : this._queue.length; const ratio = 100 / this._queue.length; - const current = value * ratio / 100; + const current = (value * ratio) / 100; return Math.round(uploaded * ratio + current); } @@ -429,16 +402,13 @@ export class Uploader { .toLowerCase(); val = line.slice(i + 1).trim(); if (key) { - parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + parsed[key] = parsed[key] ? `${parsed[key]}, ${val}` : val; } }); return parsed; } - private _transformResponse( - response: string, - headers: ParsedResponseHeaders, - ): string { + private _transformResponse(response: string, _headers: ParsedResponseHeaders): string { return response; } @@ -452,39 +422,19 @@ export class Uploader { item._onProgress(progress); } - _onErrorItem( - item: FileItem, - response: string, - status: number, - headers: ParsedResponseHeaders, - ): void { + _onErrorItem(item: FileItem, response: string, status: number, headers: ParsedResponseHeaders): void { item._onError(response, status, headers); } - private _onSuccessItem( - item: FileItem, - response: string, - status: number, - headers: ParsedResponseHeaders, - ): void { + private _onSuccessItem(item: FileItem, response: string, status: number, headers: ParsedResponseHeaders): void { item._onSuccess(response, status, headers); } - private _onCancelItem( - item: FileItem, - response: string, - status: number, - headers: ParsedResponseHeaders, - ): void { - item._onCancel(response, status, headers); + private _onCancelItem(item: FileItem): void { + item._onCancel(); } - _onCompleteItem( - item: FileItem, - response: string, - status: number, - headers: ParsedResponseHeaders, - ): void { + _onCompleteItem(item: FileItem, response: string, status: number, headers: ParsedResponseHeaders): void { item._onComplete(response, status, headers); const nextItem = this.getReadyItems[0]; this._isUploading = false; diff --git a/components/uploader/uploader.config.ts b/components/uploader/uploader.config.ts index 79cb084..f813db8 100644 --- a/components/uploader/uploader.config.ts +++ b/components/uploader/uploader.config.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class UploaderConfig { /** * 服务端网址 diff --git a/components/uploader/uploader.directive.spec.ts b/components/uploader/uploader.directive.spec.ts index 40125c8..4ab191b 100644 --- a/components/uploader/uploader.directive.spec.ts +++ b/components/uploader/uploader.directive.spec.ts @@ -1,13 +1,8 @@ -import { - TestBed, - ComponentFixture, - fakeAsync, - tick, -} from '@angular/core/testing'; -import { Component, DebugElement, enableProdMode } from '@angular/core'; - -import { UploaderModule, Uploader, UploaderFileDirective } from '../uploader'; +import { Component, DebugElement } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; + import { By } from '@angular/platform-browser'; +import { Uploader, UploaderFileDirective, UploaderModule } from '../uploader'; const html = ``; const URL = 'http://test.com'; @@ -20,7 +15,7 @@ describe('Component: Uploader', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestUploaderDirectiveComponent], - imports: [UploaderModule.forRoot()], + imports: [UploaderModule], }); TestBed.overrideComponent(TestUploaderDirectiveComponent, { set: { template: html }, @@ -28,12 +23,8 @@ describe('Component: Uploader', () => { fixture = TestBed.createComponent(TestUploaderDirectiveComponent); fixture.detectChanges(); - directiveEl = fixture.debugElement.query( - By.directive(UploaderFileDirective), - ); - directive = directiveEl.injector.get( - UploaderFileDirective, - ) as UploaderFileDirective; + directiveEl = fixture.debugElement.query(By.directive(UploaderFileDirective)); + directive = directiveEl.injector.get(UploaderFileDirective); }); it('should be inited', () => { @@ -57,25 +48,18 @@ describe('Component: Uploader', () => { it('should handle event', () => { spyOn(directive.uploader, 'addToQueue'); directive._onChange(); - const args = [ - (directiveEl.nativeElement as HTMLInputElement).files, - directive._options, - ]; + const args = [(directiveEl.nativeElement as HTMLInputElement).files, directive._options]; expect(directive.uploader.addToQueue).toHaveBeenCalledWith(...args); }); describe('CLASS', () => { const file1 = new File( - [ - 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkWK1WDwAC1gFS81OXVgAAAABJRU5ErkJggg==', - ], + ['iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkWK1WDwAC1gFS81OXVgAAAABJRU5ErkJggg=='], 'file1.png', { type: 'image/png' }, ); const file2 = new File( - [ - 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkWK1WDwAC1gFS81OXVgAAAABJRU5ErkJggg==', - ], + ['iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkWK1WDwAC1gFS81OXVgAAAABJRU5ErkJggg=='], 'file2.png', { type: 'image/png' }, ); diff --git a/components/uploader/uploader.directive.ts b/components/uploader/uploader.directive.ts index 5a8089f..e60da49 100644 --- a/components/uploader/uploader.directive.ts +++ b/components/uploader/uploader.directive.ts @@ -1,9 +1,10 @@ -import { Directive, Input, ElementRef, HostListener } from '@angular/core'; -import { UploaderOptions } from './uploader.options'; +import { Directive, ElementRef, HostListener, Input } from '@angular/core'; import { Uploader } from './uploader.class'; +import { UploaderOptions } from './uploader.options'; @Directive({ selector: '[weui-uploader-file]', + exportAs: 'weuiUploaderFile', }) export class UploaderFileDirective { /** diff --git a/components/uploader/uploader.module.ts b/components/uploader/uploader.module.ts index f3d6c31..a576f64 100644 --- a/components/uploader/uploader.module.ts +++ b/components/uploader/uploader.module.ts @@ -1,16 +1,11 @@ import { CommonModule } from '@angular/common'; -import { NgModule, ModuleWithProviders } from '@angular/core'; -import { UploaderFileDirective } from './uploader.directive'; +import { NgModule } from '@angular/core'; import { FileThumbDirective } from './file-thumb.directive'; -import { UploaderConfig } from './uploader.config'; +import { UploaderFileDirective } from './uploader.directive'; @NgModule({ imports: [CommonModule], declarations: [UploaderFileDirective, FileThumbDirective], exports: [UploaderFileDirective, FileThumbDirective], }) -export class UploaderModule { - static forRoot(): ModuleWithProviders { - return { ngModule: UploaderModule, providers: [UploaderConfig] }; - } -} +export class UploaderModule {} diff --git a/components/uploader/uploader.options.ts b/components/uploader/uploader.options.ts index 6f06dd8..739d440 100644 --- a/components/uploader/uploader.options.ts +++ b/components/uploader/uploader.options.ts @@ -1,8 +1,8 @@ import { Observable } from 'rxjs'; -import { ParsedResponseHeaders } from './interface'; import { FileItem } from './file-item.class'; import { FileLikeObject } from './file-like-object.class'; +import { ParsedResponseHeaders } from './interface'; // tslint:disable-next-line:interface-over-type-literal export type FilterFunction = { @@ -131,11 +131,7 @@ export interface UploaderOptions { * @param percentage 当前文件上传进度 * @param totaoPercentage 总上传进度 */ - onUploadProgress?: ( - file: FileItem, - percentage: number, - totaoPercentage: number, - ) => void; + onUploadProgress?: (file: FileItem, percentage: number, totaoPercentage: number) => void; /** * 当文件上传成功时触发 @@ -144,12 +140,7 @@ export interface UploaderOptions { * @param status 状态码 * @param headers Headers */ - onUploadSuccess?: ( - file: FileItem, - response: string, - status: number, - headers: ParsedResponseHeaders, - ) => void; + onUploadSuccess?: (file: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => void; /** * 当文件上传出错时触发 @@ -158,12 +149,7 @@ export interface UploaderOptions { * @param status 状态码 * @param headers Headers */ - onUploadError?: ( - file: FileItem, - response: string, - status: number, - headers: ParsedResponseHeaders, - ) => void; + onUploadError?: (file: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => void; /** * 不管成功或者失败,文件上传完成时触发 * @param file File对象 @@ -171,12 +157,7 @@ export interface UploaderOptions { * @param status 状态码 * @param headers Headers */ - onUploadComplete?: ( - file: FileItem, - response: string, - status: number, - headers: ParsedResponseHeaders, - ) => void; + onUploadComplete?: (file: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => void; /** * 取消某文件时触发 @@ -191,11 +172,7 @@ export interface UploaderOptions { * @param filter 过滤器 * @param options 选项 */ - onError?: ( - file: FileLikeObject, - filter: FilterFunction, - options: UploaderOptions, - ) => void; + onError?: (file: FileLikeObject, filter: FilterFunction, options: UploaderOptions) => void; /** * 内置的上传组件是基于HTML5 diff --git a/components/utils/boolean-property.ts b/components/utils/boolean-property.ts deleted file mode 100644 index 8adac28..0000000 --- a/components/utils/boolean-property.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function toBoolean(value: any): boolean { - return value != null && `${value}` !== 'false'; -} diff --git a/components/utils/loader.service.spec.ts b/components/utils/loader.service.spec.ts deleted file mode 100644 index 4d4434c..0000000 --- a/components/utils/loader.service.spec.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { Injector, ReflectiveInjector } from '@angular/core'; -import { DOCUMENT } from '@angular/platform-browser'; - -import { LoaderService } from './loader.service'; - -class MockDocument { - createElement = jasmine - .createSpy('Document createElement') - .and.returnValue({}); - getElementsByTagName = jasmine.createSpy('Document getElementsByTagName'); -} - -describe('LoaderService', () => { - let service: LoaderService; - let document: MockDocument; - - beforeEach(() => { - const injector = ReflectiveInjector.resolveAndCreate([ - LoaderService, - { provide: DOCUMENT, useClass: MockDocument }, - ]); - service = injector.get(LoaderService); - document = injector.get(DOCUMENT); - }); - - it('should create script tag', () => { - const JSURL = 'http://test.com/1.js'; - service.load([JSURL]); - expect(document.createElement).toHaveBeenCalled(); - expect(document.getElementsByTagName).toHaveBeenCalled(); - }); - - it('should create link tag', () => { - const CSSURL = 'http://test.com/1.css'; - service.load(CSSURL); - expect(document.createElement).toHaveBeenCalled(); - expect(document.getElementsByTagName).toHaveBeenCalled(); - }); - - it('should at once if create exists', () => { - const JSURL = 'http://test.com/1.js'; - const CSSURL = 'http://test.com/1.css'; - service.load([JSURL, CSSURL]); - service.load([JSURL, CSSURL]); - expect(document.createElement).toHaveBeenCalled(); - expect(document.getElementsByTagName).toHaveBeenCalled(); - }); -}); diff --git a/package.json b/package.json index e0a5e03..0344cc5 100644 --- a/package.json +++ b/package.json @@ -34,42 +34,39 @@ "release": "npm run build && cd publish && npm publish --access public" }, "dependencies": { - "@angular/animations": "~7.1.0", - "@angular/common": "~7.1.0", - "@angular/compiler": "~7.1.0", - "@angular/core": "~7.1.0", - "@angular/forms": "~7.1.0", - "@angular/platform-browser": "~7.1.0", - "@angular/platform-browser-dynamic": "~7.1.0", - "@angular/router": "~7.1.0", + "@angular/animations": "~7.2.0", + "@angular/common": "~7.2.0", + "@angular/compiler": "~7.2.0", + "@angular/core": "~7.2.0", + "@angular/forms": "~7.2.0", + "@angular/platform-browser": "~7.2.0", + "@angular/platform-browser-dynamic": "~7.2.0", + "@angular/router": "~7.2.0", "core-js": "^2.5.4", "rxjs": "~6.3.3", "tslib": "^1.9.0", "zone.js": "~0.8.26", - "weui": "^1.1.3", + "weui": "^2.0.0", "angular-qq-maps": "^7.0.0", "font-awesome": "^4.7.0", - "ngx-countdown": "^3.1.0", + "ngx-countdown": "^3.2.0", "ngx-gesture-password": "^7.0.0", - "ngx-toastr": "^9.1.1", - "swiper": "^4.4.2", + "ngx-toastr": "^10.0.2", + "swiper": "^4.5.0", "g2-mobile": "^2.2.0-beta.3" }, "devDependencies": { - "@angular-devkit/build-angular": "~0.11.0", - "@angular-devkit/build-ng-packagr": "~0.11.1", - "@angular/cli": "~7.1.1", - "@angular/compiler-cli": "~7.1.0", - "@angular/language-service": "~7.1.0", + "@angular-devkit/build-angular": "~0.13.0", + "@angular/cli": "~7.3.9", + "@angular/compiler-cli": "~7.2.0", + "@angular/language-service": "~7.2.0", "@types/node": "~8.9.4", "@types/jasmine": "~2.8.8", "@types/jasminewd2": "~2.0.3", - "@types/sinon": "^2.3.1", - "codecov": "^3.1.0", "codelyzer": "~4.5.0", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", - "karma": "~3.1.1", + "karma": "~4.0.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~1.1.2", @@ -77,13 +74,28 @@ "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.11.0", - "typescript": "~3.1.6", - "ng-packagr": "^4.4.5", - "tsickle": "^0.34.0", + "typescript": "~3.2.2", + "@angular-devkit/build-ng-packagr": "~0.13.9", + "@types/sinon": "^7.0.11", + "codecov": "^3.4.0", + "ng-packagr": "^5.1.0", + "tsickle": "^0.35.0", "mark-twain": "^2.0.3", "mustache": "^3.0.1", "less-plugin-clean-css": "^1.5.1", "fs-extra": "^7.0.1", - "sinon": "^4.4.2" + "sinon": "^7.3.2", + "prettier": "^1.16.1", + "prettier-stylelint": "^0.4.2", + "stylelint": "^10.0.1", + "stylelint-config-css-modules": "^1.4.0", + "stylelint-config-prettier": "^5.1.0", + "stylelint-config-rational-order": "^0.1.2", + "stylelint-config-standard": "^18.3.0", + "stylelint-declaration-block-no-ignored-properties": "^2.1.0", + "stylelint-order": "^3.0.0", + "gh-pages": "^2.0.1", + "tslint-config-prettier": "^1.18.0", + "tslint-language-service": "^0.9.9" } } \ No newline at end of file diff --git a/scripts/site/converters/highlight.ts b/scripts/site/converters/highlight.ts index 3fb939c..157b729 100644 --- a/scripts/site/converters/highlight.ts +++ b/scripts/site/converters/highlight.ts @@ -2,11 +2,11 @@ const JsonML = require('jsonml.js/lib/utils'); import { getCode } from '../utils/utils'; export function highlight() { - return [ - (node: any) => JsonML.isElement(node) && JsonML.getTagName(node) === 'pre', - (node: any, index: number) => { - const attr = JsonML.getAttributes(node); - return `
${getCode(node)}
`; - } - ]; + return [ + (node: any) => JsonML.isElement(node) && JsonML.getTagName(node) === 'pre', + (node: any, index: number) => { + const attr = JsonML.getAttributes(node); + return `
${getCode(node)}
`; + }, + ]; } diff --git a/scripts/site/converters/site.ts b/scripts/site/converters/site.ts index ae82203..b71556a 100644 --- a/scripts/site/converters/site.ts +++ b/scripts/site/converters/site.ts @@ -1,39 +1,42 @@ -// tslint:disable const JsonML = require('jsonml.js/lib/utils'); -import { isHeading, generateSluggedId, genAttr } from '../utils/utils'; +import { generateSluggedId, isHeading } from '../utils/utils'; export function site() { - return [ - [ - (node: any) => JsonML.isElement(node) && isHeading(node), - (node: any, index: number) => { - const tagName = JsonML.getTagName(node); - const children = JsonML.getChildren(node); - const sluggedId = generateSluggedId(children).id; - // # - return `<${tagName} id="${sluggedId}">${children}`; + return [ + [ + (node: any) => JsonML.isElement(node) && isHeading(node), + (node: any) => { + const tagName = JsonML.getTagName(node); + const children = JsonML.getChildren(node); + const sluggedId = generateSluggedId(children).id; + // # + return `<${tagName} id="${sluggedId}">${children}`; + }, + ], + [ + (node: any) => JsonML.isElement(node) && JsonML.getTagName(node) === 'img', + (node: any, index: number) => { + const attrs = JsonML.getAttributes(node); + const ret: any[] = []; + if (attrs) { + // tslint:disable-next-line: forin + for (const key in attrs) { + let value = attrs[key]; + if (key === 'src' && ~value.indexOf(' | ')) { + const imgWH = value + .split(' | ')[1] + .trim() + .split('='); + for (let i = 0; i < imgWH.length; i += 2) { + ret.push(`${imgWH[i]}=${imgWH[i + 1]}`); + } + value = value.split(' | ')[0]; } - ], - [ - (node: any) => JsonML.isElement(node) && JsonML.getTagName(node) === 'img', - (node: any, index: number) => { - const attrs = JsonML.getAttributes(node); - const ret: any[] = []; - if (attrs) { - for (const key in attrs) { - let value = attrs[key]; - if (key === 'src' && ~value.indexOf(' | ')) { - const imgWH = value.split(' | ')[1].trim().split('='); - for (let i = 0; i < imgWH.length; i += 2) { - ret.push(`${imgWH[i]}=${imgWH[i + 1]}`); - } - value = value.split(' | ')[0]; - } - if (value) ret.push(`${key}="${value}"`); - } - } - return ``; - } - ] - ]; + if (value) ret.push(`${key}="${value}"`); + } + } + return ``; + }, + ], + ]; } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 3a40222..1b647c4 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; @Component({ - selector: 'app-root', - template: `` + selector: 'app-root', + template: ` + + `, }) -export class AppComponent { -} +export class AppComponent {} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index df2594a..4fb6414 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -3,7 +3,6 @@ import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { HttpClientModule, HttpClientJsonpModule } from '@angular/common/http'; -import { WeUiModule } from 'ngx-weui'; import { ToastrModule } from 'ngx-toastr'; import { AqmModule } from 'angular-qq-maps'; @@ -23,17 +22,12 @@ import { AppComponent } from './app.component'; SharedModule, RoutesModule, LayoutModule, - WeUiModule.forRoot(), ToastrModule.forRoot(), AqmModule.forRoot({ - apiKey: 'I3TBZ-QTN3J-MWPFI-FERMS-IBOCQ-LBBWY' - }) + apiKey: 'I3TBZ-QTN3J-MWPFI-FERMS-IBOCQ-LBBWY', + }), ], - declarations: [ - AppComponent - ], - bootstrap: [AppComponent] + declarations: [AppComponent], + bootstrap: [AppComponent], }) - -export class AppModule { -} +export class AppModule {} diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index 2776fe6..b0a6d34 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -4,12 +4,10 @@ import { throwIfAlreadyLoaded } from './module-import-guard'; import { MenuService } from './menu.service'; @NgModule({ - providers: [ - MenuService - ] + providers: [MenuService], }) export class CoreModule { - constructor( @Optional() @SkipSelf() parentModule: CoreModule) { - throwIfAlreadyLoaded(parentModule, 'CoreModule'); - } + constructor(@Optional() @SkipSelf() parentModule: CoreModule) { + throwIfAlreadyLoaded(parentModule, 'CoreModule'); + } } diff --git a/src/app/core/menu.service.ts b/src/app/core/menu.service.ts index 825b890..4e93918 100644 --- a/src/app/core/menu.service.ts +++ b/src/app/core/menu.service.ts @@ -26,13 +26,11 @@ export class MenuService { items: [ { name: 'ActionSheet', - icon: - '//cipchk.github.io/ngx-weui/assets/images/icon_nav_actionSheet.png', + icon: '//cipchk.github.io/ngx-weui/assets/images/icon_nav_actionSheet.png', }, { name: 'Accordion', - icon: - '//cipchk.github.io/ngx-weui/assets/images/icon_nav_actionSheet.png', + icon: '//cipchk.github.io/ngx-weui/assets/images/icon_nav_actionSheet.png', }, { name: 'Button', @@ -40,8 +38,7 @@ export class MenuService { }, { name: 'Article', - icon: - '//cipchk.github.io/ngx-weui/assets/images/icon_nav_article.png', + icon: '//cipchk.github.io/ngx-weui/assets/images/icon_nav_article.png', }, { name: 'Badge', @@ -157,8 +154,7 @@ export class MenuService { }, { name: 'Progress', - icon: - '//cipchk.github.io/ngx-weui/assets/images/icon_nav_progress.png', + icon: '//cipchk.github.io/ngx-weui/assets/images/icon_nav_progress.png', }, { name: 'PullToRefresh', @@ -168,8 +164,7 @@ export class MenuService { }, { name: 'SearchBar', - icon: - '//cipchk.github.io/ngx-weui/assets/images/icon_nav_search_bar.png', + icon: '//cipchk.github.io/ngx-weui/assets/images/icon_nav_search_bar.png', }, { name: 'Slider', @@ -264,7 +259,7 @@ export class MenuService { docMenu.items = META.sort((a: any, b: any) => a.meta.order - b.meta.order).map(i => { return { id: i.name, - name: i.meta.title + name: i.meta.title, }; }); } diff --git a/src/app/core/preloader.ts b/src/app/core/preloader.ts index 9e2a687..e48ed39 100644 --- a/src/app/core/preloader.ts +++ b/src/app/core/preloader.ts @@ -1,19 +1,19 @@ -let body = document.querySelector('body'); -let preloader = document.querySelector('.preloader'); +let body = document.querySelector('body')!; +let preloader = document.querySelector('.preloader')!; body.style.overflow = 'hidden'; function remove() { - preloader.addEventListener('transitionend', function () { - preloader.className = 'preloader-hidden'; - }); + preloader.addEventListener('transitionend', function() { + preloader.className = 'preloader-hidden'; + }); - preloader.className += ' preloader-hidden-add preloader-hidden-add-active'; + preloader.className += ' preloader-hidden-add preloader-hidden-add-active'; } -(window).appBootstrap = () => { - setTimeout(() => { - remove(); - body.style.overflow = ''; - }, 100); +(window as any).appBootstrap = () => { + setTimeout(() => { + remove(); + body.style.overflow = ''; + }, 100); }; diff --git a/src/app/example/accordion/accordion.component.html b/src/app/example/accordion/accordion.component.html index d70baba..58a9a77 100644 --- a/src/app/example/accordion/accordion.component.html +++ b/src/app/example/accordion/accordion.component.html @@ -1,27 +1,27 @@ +
+ + + + +

choose index: {{ index }}

+
-
- - - - -

choose index: {{index}}

-
- - - -
{{ item.title }}
- -
-
- + + +
{{ item.title }}
+ +
+
diff --git a/src/app/example/accordion/accordion.component.scss b/src/app/example/accordion/accordion.component.scss index 5acd71f..790ee36 100644 --- a/src/app/example/accordion/accordion.component.scss +++ b/src/app/example/accordion/accordion.component.scss @@ -1,22 +1,22 @@ .weui-accordion-panel { - margin: 10px 0; - background-color: #fff; - overflow: hidden; - border-radius: 2px; - .heading { - padding: 20px; - cursor: pointer; - } - .weui-cells { - margin-top: 0; - } - .weui-accordion-content { - transition: max-height .5s ease-in; - } + margin: 10px 0; + overflow: hidden; + background-color: #fff; + border-radius: 2px; + .heading { + padding: 20px; + cursor: pointer; + } + .weui-cells { + margin-top: 0; + } + .weui-accordion-content { + transition: max-height 0.5s ease-in; + } } .weui-accordion-active { - .weui-accordion-content { - max-height: 100px; - } + .weui-accordion-content { + max-height: 100px; + } } diff --git a/src/app/example/accordion/accordion.component.ts b/src/app/example/accordion/accordion.component.ts index 8dee0e0..d96720a 100644 --- a/src/app/example/accordion/accordion.component.ts +++ b/src/app/example/accordion/accordion.component.ts @@ -1,42 +1,42 @@ -import { Component, Input, Output, ViewEncapsulation, EventEmitter, OnDestroy, OnInit } from '@angular/core'; +import { Component, OnInit, ViewEncapsulation } from '@angular/core'; interface AccordionItem { - disabled: boolean; - active: boolean; - title: string; - list: number[]; + disabled: boolean; + active: boolean; + title: string; + list: number[]; } @Component({ - selector: 'example-accordion', - templateUrl: './accordion.component.html', - styleUrls: ['./accordion.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-accordion', + templateUrl: './accordion.component.html', + styleUrls: ['./accordion.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoAccordionComponent implements OnInit { - collapsible: boolean = false; + collapsible: boolean = false; - list: AccordionItem[] = []; + list: AccordionItem[] = []; - ngOnInit() { - new Array(3).fill(0).forEach(() => this.add()); - } + ngOnInit() { + new Array(3).fill(0).forEach(() => this.add()); + } - add() { - this.list.push({ - disabled: false, - active: false, - title: `标题${this.list.length + 1}`, - list: new Array(this.list.length + 1) - }); - } + add() { + this.list.push({ + disabled: false, + active: false, + title: `标题${this.list.length + 1}`, + list: new Array(this.list.length + 1), + }); + } - remove() { - if (this.list.length > 1) this.list.pop(); - } + remove() { + if (this.list.length > 1) this.list.pop(); + } - index: number = 0; - select(index: number) { - this.index = index; - } + index: number = 0; + select(index: number) { + this.index = index; + } } diff --git a/src/app/example/actionsheet/actionsheet.component.html b/src/app/example/actionsheet/actionsheet.component.html index c3dae82..f30549c 100644 --- a/src/app/example/actionsheet/actionsheet.component.html +++ b/src/app/example/actionsheet/actionsheet.component.html @@ -1,16 +1,13 @@ - - - - - -
使用组件形式
- - - -
使用Service形式
- - - - + + + +
使用组件形式
+ + + +
使用Service形式
+ + +
diff --git a/src/app/example/actionsheet/actionsheet.component.ts b/src/app/example/actionsheet/actionsheet.component.ts index 60a50f7..d84d24c 100644 --- a/src/app/example/actionsheet/actionsheet.component.ts +++ b/src/app/example/actionsheet/actionsheet.component.ts @@ -1,50 +1,45 @@ -import { Component, ViewEncapsulation, ViewChild, OnDestroy } from '@angular/core'; +import { Component, ViewChild, ViewEncapsulation } from '@angular/core'; import { SkinType } from 'ngx-weui'; -import { ActionSheetService, ActionSheetConfig, ActionSheetComponent } from "ngx-weui/actionsheet"; +import { ActionSheetComponent, ActionSheetConfig, ActionSheetService } from 'ngx-weui/actionsheet'; @Component({ - selector: 'example-actionsheet', - templateUrl: './actionsheet.component.html', - styleUrls: [ './actionsheet.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-actionsheet', + templateUrl: './actionsheet.component.html', + styleUrls: ['./actionsheet.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoActionSheetComponent { - - @ViewChild('ios') iosAS: ActionSheetComponent; - @ViewChild('android') androidAS: ActionSheetComponent; - @ViewChild('auto') autoAS: ActionSheetComponent; - - menus: any[] = [ - { text: '菜单一', value: 'test', other: 1 }, - { text: '菜单三', value: 'test' } - ]; - config: ActionSheetConfig = { - title: '这是一段标题' - }; - - constructor(private srv: ActionSheetService) { } - - onShow(type: SkinType) { - this.config.skin = type; - this.config = Object.assign({}, this.config); - setTimeout(() => { - (this[`${type}AS`]).show().subscribe((res: any) => { - console.log('type', res); - }); - }, 10); - } - - onShowBySrv(type: SkinType, backdrop: boolean = true) { - this.config.skin = type; - this.config.backdrop = backdrop; - this.srv.show(this.menus, this.config).subscribe((res: any) => { - console.log(res); - }); - } - - ngOnDestroy() { - this.srv.destroyAll(); - } - + @ViewChild('ios') iosAS: ActionSheetComponent; + @ViewChild('android') androidAS: ActionSheetComponent; + @ViewChild('auto') autoAS: ActionSheetComponent; + + menus: any[] = [{ text: '菜单一', value: 'test', other: 1 }, { text: '菜单三', value: 'test' }]; + config: ActionSheetConfig = { + title: '这是一段标题', + } as ActionSheetConfig; + + constructor(private srv: ActionSheetService) {} + + onShow(type: SkinType) { + this.config.skin = type; + this.config = { ...this.config }; + setTimeout(() => { + (this[`${type}AS`] as ActionSheetComponent).show().subscribe((res: any) => { + console.log('type', res); + }); + }, 10); + } + + onShowBySrv(type: SkinType, backdrop: boolean = true) { + this.config.skin = type; + this.config.backdrop = backdrop; + this.srv.show(this.menus, this.config).subscribe((res: any) => { + console.log(res); + }); + } + + ngOnDestroy() { + this.srv.destroyAll(); + } } diff --git a/src/app/example/article/article.component.html b/src/app/example/article/article.component.html index a774918..ce2f999 100644 --- a/src/app/example/article/article.component.html +++ b/src/app/example/article/article.component.html @@ -1,25 +1,28 @@ -
-

大标题

-
-

章标题

-
-

1.1 节标题

-

- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. -

-

- - -

-
-
-

1.2 节标题

-

- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa - qui officia deserunt mollit anim id est laborum. -

-
-
-
+
+

大标题

+
+

章标题

+
+

1.1 节标题

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore + magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo + consequat. +

+

+ + +

+
+
+

1.2 节标题

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore + magna aliqua. Ut enim ad minim veniam, cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat + cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +

+
+
+
diff --git a/src/app/example/article/article.component.ts b/src/app/example/article/article.component.ts index 75f28df..1fd8308 100644 --- a/src/app/example/article/article.component.ts +++ b/src/app/example/article/article.component.ts @@ -1,9 +1,9 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-article', - templateUrl: './article.component.html', - styleUrls: [ './article.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-article', + templateUrl: './article.component.html', + styleUrls: ['./article.component.scss'], + encapsulation: ViewEncapsulation.None, }) -export class ArticleComponent {} +export class ArticleComponent {} diff --git a/src/app/example/badge/badge.component.html b/src/app/example/badge/badge.component.html index 123309f..49d9647 100644 --- a/src/app/example/badge/badge.component.html +++ b/src/app/example/badge/badge.component.html @@ -1,47 +1,46 @@ - -
新消息提示跟摘要信息后,统一在列表右侧
-
-
-
单行列表
-
- 详细信息 - -
-
+
新消息提示跟摘要信息后,统一在列表右侧
+
+
+
单行列表
+
+ 详细信息 + +
-
未读数红点跟在主题信息后,统一在列表左侧
-
-
-
- - 8 -
-
-

联系人名称

-

摘要信息

-
-
-
-
- 单行列表 - 8 -
-
-
-
-
- 单行列表 - 8 -
-
详细信息
-
-
-
- 单行列表 - New -
-
-
+
+
未读数红点跟在主题信息后,统一在列表左侧
+
+
+
+ + 8 +
+
+

联系人名称

+

摘要信息

+
+
+
+ 单行列表 + 8 +
+
+
+
+
+ 单行列表 + 8 +
+
详细信息
+
+
+
+ 单行列表 + New +
+
+
+
diff --git a/src/app/example/badge/badge.component.ts b/src/app/example/badge/badge.component.ts index 4f423d7..334a86f 100644 --- a/src/app/example/badge/badge.component.ts +++ b/src/app/example/badge/badge.component.ts @@ -1,9 +1,9 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-badge', - templateUrl: './badge.component.html', - styleUrls: [ './badge.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-badge', + templateUrl: './badge.component.html', + styleUrls: ['./badge.component.scss'], + encapsulation: ViewEncapsulation.None, }) -export class BadgeComponent {} +export class BadgeComponent {} diff --git a/src/app/example/button/button.component.html b/src/app/example/button/button.component.html index 71807c3..bf279e5 100644 --- a/src/app/example/button/button.component.html +++ b/src/app/example/button/button.component.html @@ -1,29 +1,67 @@ - - - - - - - - - - - + +
+ + + + + + + + + +
-
- - - - - + - - - - + -
+
+ + + + + + + + +
diff --git a/src/app/example/button/button.component.scss b/src/app/example/button/button.component.scss index 417c871..3fcb4f3 100644 --- a/src/app/example/button/button.component.scss +++ b/src/app/example/button/button.component.scss @@ -1,5 +1,8 @@ .page.button .button-sp-area { - margin: 0 auto; + margin: 15px auto; + padding: 15px; + text-align: center; + &.cell { padding: 15px 0; - width: 60%; + } } diff --git a/src/app/example/button/button.component.ts b/src/app/example/button/button.component.ts index e3eed10..04b2d40 100644 --- a/src/app/example/button/button.component.ts +++ b/src/app/example/button/button.component.ts @@ -1,13 +1,13 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-button', - templateUrl: './button.component.html', - styleUrls: [ './button.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-button', + templateUrl: './button.component.html', + styleUrls: ['./button.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class ButtonComponent { - disabled: boolean = true; - loading: boolean = true; - mini: boolean = true; + disabled: boolean = true; + loading: boolean = true; + mini: boolean = true; } diff --git a/src/app/example/chart-g2/chart-g2.component.html b/src/app/example/chart-g2/chart-g2.component.html index 9bd7d53..7ca38fc 100644 --- a/src/app/example/chart-g2/chart-g2.component.html +++ b/src/app/example/chart-g2/chart-g2.component.html @@ -1,18 +1,10 @@ - + +

快速上手

+ -

快速上手

- - -

平滑折线图

- - -

仪表盘

- +

平滑折线图

+ +

仪表盘

+
diff --git a/src/app/example/chart-g2/chart-g2.component.ts b/src/app/example/chart-g2/chart-g2.component.ts index 82ed22c..b5fe919 100644 --- a/src/app/example/chart-g2/chart-g2.component.ts +++ b/src/app/example/chart-g2/chart-g2.component.ts @@ -1,189 +1,194 @@ -import { Component, ViewEncapsulation, ViewChild } from '@angular/core'; +import { Component, ViewChild, ViewEncapsulation } from '@angular/core'; -import { ChartG2Directive } from 'ngx-weui/chart-g2' +import { ChartG2Directive } from 'ngx-weui/chart-g2'; @Component({ - selector: 'example-chart-g2', - templateUrl: './chart-g2.component.html', - styleUrls: ['./chart-g2.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-chart-g2', + templateUrl: './chart-g2.component.html', + styleUrls: ['./chart-g2.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoChartG2Component { - @ViewChild('c1') c1: ChartG2Directive; - renderC1() { - const chart = this.c1.chart; - chart.source([ - { "tem": 10, "city": "tokyo" }, - { "tem": 4, "city": "newYork" }, - { "tem": 3, "city": "berlin" } - ]); - chart.interval().position('city*tem').color('city'); - chart.render(); - } + @ViewChild('c1') c1: ChartG2Directive; + renderC1() { + const chart = this.c1.chart; + chart.source([{ tem: 10, city: 'tokyo' }, { tem: 4, city: 'newYork' }, { tem: 3, city: 'berlin' }]); + chart + .interval() + .position('city*tem') + .color('city'); + chart.render(); + } - @ViewChild('c2') c2: ChartG2Directive; - renderC2() { - let data = [ - { "time": '周一', "tem": 10, "city": "beijing" }, - { "time": '周二', "tem": 22, "city": "beijing" }, - { "time": '周三', "tem": 20, "city": "beijing" }, - { "time": '周四', "tem": 26, "city": "beijing" }, - { "time": '周五', "tem": 20, "city": "beijing" }, - { "time": '周六', "tem": 26, "city": "beijing" }, - { "time": '周日', "tem": 28, "city": "beijing" }, - { "time": '周一', "tem": 5, "city": "newYork" }, - { "time": '周二', "tem": 12, "city": "newYork" }, - { "time": '周三', "tem": 26, "city": "newYork" }, - { "time": '周四', "tem": 20, "city": "newYork" }, - { "time": '周五', "tem": 28, "city": "newYork" }, - { "time": '周六', "tem": 26, "city": "newYork" }, - { "time": '周日', "tem": 20, "city": "newYork" } - ]; - let defs = { - time: { - tickCount: 7, - range: [0, 1] - }, - tem: { - tickCount: 5, - min: 0 - } - }; - //配置time刻度文字样式 - let label = { - fill: '#979797', - font: '14px san-serif', - offset: 6 - }; + @ViewChild('c2') c2: ChartG2Directive; + renderC2() { + const data = [ + { time: '周一', tem: 10, city: 'beijing' }, + { time: '周二', tem: 22, city: 'beijing' }, + { time: '周三', tem: 20, city: 'beijing' }, + { time: '周四', tem: 26, city: 'beijing' }, + { time: '周五', tem: 20, city: 'beijing' }, + { time: '周六', tem: 26, city: 'beijing' }, + { time: '周日', tem: 28, city: 'beijing' }, + { time: '周一', tem: 5, city: 'newYork' }, + { time: '周二', tem: 12, city: 'newYork' }, + { time: '周三', tem: 26, city: 'newYork' }, + { time: '周四', tem: 20, city: 'newYork' }, + { time: '周五', tem: 28, city: 'newYork' }, + { time: '周六', tem: 26, city: 'newYork' }, + { time: '周日', tem: 20, city: 'newYork' }, + ]; + const defs = { + time: { + tickCount: 7, + range: [0, 1], + }, + tem: { + tickCount: 5, + min: 0, + }, + }; + // 配置time刻度文字样式 + const label = { + fill: '#979797', + font: '14px san-serif', + offset: 6, + }; - let Util = this.c2.GM.Util; - this.c2.chart.axis('time', { - label: function (text, index, total) { - var cfg = Util.mix({}, label); - // 第一个点左对齐,最后一个点右对齐,其余居中,只有一个点时左对齐 - if (index === 0) { - cfg.textAlign = 'start'; - } - if (index > 0 && index === total - 1) { - cfg.textAlign = 'end'; - } - return cfg; - } - }); - this.c2.chart.axis('tem', { - label: { - fontSize: 14 - } - }); - this.c2.chart.source(data, defs); - this.c2.chart.line().position('time*tem').color('city').shape('smooth'); - this.c2.chart.render(); - } + const Util = this.c2.GM.Util; + this.c2.chart.axis('time', { + label(_text, index, total) { + const cfg = Util.mix({}, label); + // 第一个点左对齐,最后一个点右对齐,其余居中,只有一个点时左对齐 + if (index === 0) { + cfg.textAlign = 'start'; + } + if (index > 0 && index === total - 1) { + cfg.textAlign = 'end'; + } + return cfg; + }, + }); + this.c2.chart.axis('tem', { + label: { + fontSize: 14, + }, + }); + this.c2.chart.source(data, defs); + this.c2.chart + .line() + .position('time*tem') + .color('city') + .shape('smooth'); + this.c2.chart.render(); + } - @ViewChild('c3') c3: ChartG2Directive; - renderC3() { - this.c3.GM.Global.pixelRatio = 2;//双精度 - var Shape = this.c3.GM.Shape; - var G = this.c3.GM.G; - var data = [{ pointer: '当前收益', value: 5, length: 2, y: 1.05 }]; - //自定义绘制数据的的形状 - Shape.registShape('point', 'dashBoard', { - getShapePoints: function (cfg) { - var x = cfg.x; - var y = cfg.y; - return [ - { x: x, y: y }, - { x: x, y: 0.5 } - ] - }, - drawShape: function (cfg, canvas) { - var point1 = cfg.points[0]; - var point2 = cfg.points[1]; - point1 = this.parsePoint(point1); - point2 = this.parsePoint(point2); - G.drawLines([point1, point2], canvas, { - stroke: '#18b7d6', - lineWidth: 2 - }); - var text = cfg.origin._origin.value.toString(); - G.drawText(text + '%', cfg.center, canvas, { - fillStyle: '#f75b5b', - font: '30px Arial', - textAlign: 'center', - textBaseline: 'bottom' - }); - G.drawText(cfg.origin._origin.pointer, cfg.center, canvas, { - fillStyle: '#ccc', - textAlign: 'center', - textBaseline: 'top' - }); - } - }); - var chart = this.c3.chart; - chart.source(data, { - 'value': { type: 'linear', min: 0, max: 15, tickCount: 6 }, - 'length': { type: 'linear', min: 0, max: 10 }, - y: { type: 'linear', min: 0, max: 1 } - }); - chart.coord('polar', { - inner: 0, - startAngle: -1.25 * Math.PI, - endAngle: 0.25 * Math.PI - }); - //配置value轴刻度线 - chart.axis('value', { - tickLine: { - strokeStyle: '#b9e6ef', - lineWidth: 2, - value: -5 - }, - label: null, - grid: null, - line: null - }); - chart.axis('y', false); - //绘制仪表盘辅助元素 - chart.guide().arc([0, 1.05], [4.8, 1.05], { - strokeStyle: '#18b7d6', - lineWidth: 5, - lineCap: 'round' - }); - chart.guide().arc([5.2, 1.05], [9.8, 1.05], { - strokeStyle: '#ccc', - lineWidth: 5, - lineCap: 'round' - }); - chart.guide().arc([10.2, 1.05], [15, 1.05], { - strokeStyle: '#ccc', - lineWidth: 5, - lineCap: 'round' - }); - chart.guide().arc([0, 1.2], [15, 1.2], { - strokeStyle: '#ccc', - lineWidth: 1 - }); - chart.guide().text([-0.5, 1.3], '0.00%', { - fillStyle: '#ccc', - font: '18px Arial', - textAlign: 'center' + @ViewChild('c3') c3: ChartG2Directive; + renderC3() { + this.c3.GM.Global.pixelRatio = 2; // 双精度 + const Shape = this.c3.GM.Shape; + const G = this.c3.GM.G; + const data = [{ pointer: '当前收益', value: 5, length: 2, y: 1.05 }]; + // 自定义绘制数据的的形状 + Shape.registShape('point', 'dashBoard', { + getShapePoints(cfg) { + const x = cfg.x; + const y = cfg.y; + return [{ x, y }, { x, y: 0.5 }]; + }, + drawShape(cfg, canvas) { + let point1 = cfg.points[0]; + let point2 = cfg.points[1]; + point1 = this.parsePoint(point1); + point2 = this.parsePoint(point2); + G.drawLines([point1, point2], canvas, { + stroke: '#18b7d6', + lineWidth: 2, }); - chart.guide().text([7.5, 0.7], '7.50%', { - fillStyle: '#ccc', - font: '18px Arial', - textAlign: 'center' + const text = cfg.origin._origin.value.toString(); + G.drawText(text + '%', cfg.center, canvas, { + fillStyle: '#f75b5b', + font: '30px Arial', + textAlign: 'center', + textBaseline: 'bottom', }); - chart.guide().text([15.5, 1.3], '15.00%', { - fillStyle: '#ccc', - font: '18px Arial', - textAlign: 'center' + G.drawText(cfg.origin._origin.pointer, cfg.center, canvas, { + fillStyle: '#ccc', + textAlign: 'center', + textBaseline: 'top', }); - chart.point().position('value*y').size('length').color('#18b7d6').shape('dashBoard'); - chart.render(); - } + }, + }); + const chart = this.c3.chart; + chart.source(data, { + value: { type: 'linear', min: 0, max: 15, tickCount: 6 }, + length: { type: 'linear', min: 0, max: 10 }, + y: { type: 'linear', min: 0, max: 1 }, + }); + chart.coord('polar', { + inner: 0, + startAngle: -1.25 * Math.PI, + endAngle: 0.25 * Math.PI, + }); + // 配置value轴刻度线 + chart.axis('value', { + tickLine: { + strokeStyle: '#b9e6ef', + lineWidth: 2, + value: -5, + }, + label: null, + grid: null, + line: null, + }); + chart.axis('y', false); + // 绘制仪表盘辅助元素 + chart.guide().arc([0, 1.05], [4.8, 1.05], { + strokeStyle: '#18b7d6', + lineWidth: 5, + lineCap: 'round', + }); + chart.guide().arc([5.2, 1.05], [9.8, 1.05], { + strokeStyle: '#ccc', + lineWidth: 5, + lineCap: 'round', + }); + chart.guide().arc([10.2, 1.05], [15, 1.05], { + strokeStyle: '#ccc', + lineWidth: 5, + lineCap: 'round', + }); + chart.guide().arc([0, 1.2], [15, 1.2], { + strokeStyle: '#ccc', + lineWidth: 1, + }); + chart.guide().text([-0.5, 1.3], '0.00%', { + fillStyle: '#ccc', + font: '18px Arial', + textAlign: 'center', + }); + chart.guide().text([7.5, 0.7], '7.50%', { + fillStyle: '#ccc', + font: '18px Arial', + textAlign: 'center', + }); + chart.guide().text([15.5, 1.3], '15.00%', { + fillStyle: '#ccc', + font: '18px Arial', + textAlign: 'center', + }); + chart + .point() + .position('value*y') + .size('length') + .color('#18b7d6') + .shape('dashBoard'); + chart.render(); + } - ngAfterViewInit() { - this.renderC1(); - this.renderC2(); - this.renderC3(); - } + ngAfterViewInit() { + this.renderC1(); + this.renderC2(); + this.renderC3(); + } } diff --git a/src/app/example/container.component.ts b/src/app/example/container.component.ts index 8e700d6..3f5aef2 100644 --- a/src/app/example/container.component.ts +++ b/src/app/example/container.component.ts @@ -1,57 +1,55 @@ import { Component, Input } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; @Component({ - selector: 'component-container', - template: ` -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ` + selector: 'component-container', + template: ` +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ `, }) export class ContainerComponent { - - @Input() url: string = 'example'; - @Input() menu: any = {}; + @Input() url: string = 'example'; + @Input() menu: any = {}; } diff --git a/src/app/example/countdown/countdown.component.html b/src/app/example/countdown/countdown.component.html index 5e7c5ea..456f1d0 100644 --- a/src/app/example/countdown/countdown.component.html +++ b/src/app/example/countdown/countdown.component.html @@ -1,7 +1,3 @@ - - - - + + diff --git a/src/app/example/countdown/countdown.component.ts b/src/app/example/countdown/countdown.component.ts index 27f2087..91aded0 100644 --- a/src/app/example/countdown/countdown.component.ts +++ b/src/app/example/countdown/countdown.component.ts @@ -1,10 +1,9 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-countdown', - templateUrl: './countdown.component.html', - styleUrls: [ './countdown.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-countdown', + templateUrl: './countdown.component.html', + styleUrls: ['./countdown.component.scss'], + encapsulation: ViewEncapsulation.None, }) -export class CountdownComponent { -} +export class CountdownComponent {} diff --git a/src/app/example/dialog/dialog.component.html b/src/app/example/dialog/dialog.component.html index 495a605..7204aa4 100644 --- a/src/app/example/dialog/dialog.component.html +++ b/src/app/example/dialog/dialog.component.html @@ -1,28 +1,28 @@ +
使用组件形式
+ + + + + + + + + +
使用组件Prompt形式
+ +
使用Service形式
+ + + + +
使用Service Prompt形式
+ -
使用组件形式
- - - - - - - - - -
使用组件Prompt形式
- -
使用Service形式
- - - - -
使用Service Prompt形式
- - - - - - - + + + +
diff --git a/src/app/example/dialog/dialog.component.scss b/src/app/example/dialog/dialog.component.scss index 02e291d..12d986a 100644 --- a/src/app/example/dialog/dialog.component.scss +++ b/src/app/example/dialog/dialog.component.scss @@ -1,9 +1,10 @@ .weui-dialog__prompt { - .weui-dialog__bd { - font-size: 12px; - } - .weui-cells, .weui-dialog__error { - margin-top: 0; - margin-bottom: 1.17647059em; - } + .weui-dialog__bd { + font-size: 12px; + } + .weui-cells, + .weui-dialog__error { + margin-top: 0; + margin-bottom: 1.17647059em; + } } diff --git a/src/app/example/dialog/dialog.component.ts b/src/app/example/dialog/dialog.component.ts index a543d56..59fc961 100644 --- a/src/app/example/dialog/dialog.component.ts +++ b/src/app/example/dialog/dialog.component.ts @@ -1,146 +1,154 @@ -import { Component, ViewEncapsulation, ViewChild, OnDestroy } from '@angular/core'; +import { Component, OnDestroy, ViewChild, ViewEncapsulation } from '@angular/core'; -import { SkinType, InputType } from 'ngx-weui'; -import { DialogService, DialogConfig, DialogComponent } from 'ngx-weui/dialog'; +import { InputType, SkinType } from 'ngx-weui'; +import { DialogComponent, DialogConfig, DialogService } from 'ngx-weui/dialog'; import { ToastService } from 'ngx-weui/toast'; @Component({ - selector: 'example-dialog', - templateUrl: './dialog.component.html', - styleUrls: ['./dialog.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-dialog', + templateUrl: './dialog.component.html', + styleUrls: ['./dialog.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoDialogComponent implements OnDestroy { + @ViewChild('ios') iosAS: DialogComponent; + @ViewChild('android') androidAS: DialogComponent; + @ViewChild('auto') autoAS: DialogComponent; - @ViewChild('ios') iosAS: DialogComponent; - @ViewChild('android') androidAS: DialogComponent; - @ViewChild('auto') autoAS: DialogComponent; + private DEFCONFIG: DialogConfig = { + title: '弹窗标题', + content: '弹窗内容,告知当前状态、信息和解决方法,描述文字尽量控制在三行内', + cancel: '辅助操作', + confirm: '主操作', + inputPlaceholder: '必填项', + inputError: '请填写或选择项', + inputRequired: true, + inputAttributes: { + maxlength: 140, + cn: 2, + }, + inputOptions: [ + { text: '请选择' }, + { text: '杜蕾斯', value: 'durex', other: 1 }, + { text: '杰士邦', value: 'jissbon' }, + { text: '多乐士', value: 'donless' }, + { text: '处男', value: 'first' }, + ], + } as DialogConfig; + config: DialogConfig = {}; - private DEFCONFIG: DialogConfig = { - title: '弹窗标题', - content: '弹窗内容,告知当前状态、信息和解决方法,描述文字尽量控制在三行内', - cancel: '辅助操作', - confirm: '主操作', - inputPlaceholder: '必填项', - inputError: '请填写或选择项', - inputRequired: true, - inputAttributes: { - maxlength: 140, - cn: 2 - }, - inputOptions: [ - { text: '请选择' }, - { text: '杜蕾斯', value: 'durex', other: 1 }, - { text: '杰士邦', value: 'jissbon' }, - { text: '多乐士', value: 'donless' }, - { text: '处男', value: 'first' } - ] - }; - config: DialogConfig = {}; - - constructor(private srv: DialogService, private toastService: ToastService) { - } + constructor(private srv: DialogService, private toastService: ToastService) {} - onShow(type: SkinType, style: 1 | 2 | 3) { - this.config = Object.assign({}, this.DEFCONFIG, { - skin: type, - cancel: null, - confirm: null, - btns: null, - content: '弹窗内容,告知当前状态、信息和解决方法,描述文字尽量控制在三行内' - }); - switch (style) { - case 1: - this.config.cancel = '辅助操作'; - this.config.confirm = '主操作'; - break; - case 2: - this.config.confirm = '主操作'; - break; - case 3: - this.config.btns = [ - { text: '否', type: 'default', value: 1 }, - { text: '不确定', type: 'default', value: 2 }, - { text: '是', type: 'primary', value: 3 } - ]; - break; - } - setTimeout(() => { - (this[`${type}AS`]).show().subscribe((res: any) => { - console.log('type', res); - }); - }, 10); - return false; + onShow(type: SkinType, style: 1 | 2 | 3) { + this.config = { + ...this.DEFCONFIG, + ...{ + skin: type, + cancel: undefined, + confirm: undefined, + btns: undefined, + content: '弹窗内容,告知当前状态、信息和解决方法,描述文字尽量控制在三行内', + }, + } as DialogConfig; + switch (style) { + case 1: + this.config.cancel = '辅助操作'; + this.config.confirm = '主操作'; + break; + case 2: + this.config.confirm = '主操作'; + break; + case 3: + this.config.btns = [ + { text: '否', type: 'default', value: 1 }, + { text: '不确定', type: 'default', value: 2 }, + { text: '是', type: 'primary', value: 3 }, + ]; + break; } + setTimeout(() => { + (this[`${type}AS`] as DialogComponent).show().subscribe((res: any) => { + console.log('type', res); + }); + }, 10); + return false; + } - onShowBySrv(type: SkinType, backdrop: boolean = true) { - this.config = Object.assign({}, this.DEFCONFIG, { - skin: type, - backdrop: backdrop, - content: '弹窗内容,告知当前状态、信息和解决方法,描述文字尽量控制在三行内' - }); - this.srv.show(this.config).subscribe((res: any) => { - console.log(res); - }); - return false; - } + onShowBySrv(type: SkinType, backdrop: boolean = true) { + this.config = { + ...this.DEFCONFIG, + ...({ + skin: type, + backdrop, + content: '弹窗内容,告知当前状态、信息和解决方法,描述文字尽量控制在三行内', + } as DialogConfig), + }; + this.srv.show(this.config).subscribe((res: any) => { + console.log(res); + }); + return false; + } - onShowOfHtml() { - this.config = Object.assign({}, this.DEFCONFIG, { - content: ` + onShowOfHtml() { + this.config = { + ...this.DEFCONFIG, + ...({ + content: `

这是一段HTML加粗

这是一段HTML加粗

- ` - }); - this.srv.show(this.config).subscribe((res: any) => { - console.log(res); - }); - return false; - } + `, + } as DialogConfig), + }; + this.srv.show(this.config).subscribe((res: any) => { + console.log(res); + }); + return false; + } - promptValue: any; - promptTypes: string[] = ['text', 'email', 'url', 'range', 'textarea', 'select', 'radio', 'checkbox']; - onShowPrompt(inputType: InputType, useSrv: boolean = false) { - const cog = Object.assign({}, this.DEFCONFIG, { - skin: 'auto', - type: 'prompt', - confirm: '确认', - cancel: '取消', - input: inputType, - inputValue: undefined, - inputRegex: null + promptValue: any; + promptTypes: string[] = ['text', 'email', 'url', 'range', 'textarea', 'select', 'radio', 'checkbox']; + onShowPrompt(inputType: InputType, useSrv: boolean = false) { + const cog = { + ...this.DEFCONFIG, + ...({ + skin: 'auto', + type: 'prompt', + confirm: '确认', + cancel: '取消', + input: inputType, + inputValue: undefined, + inputRegex: undefined, + } as DialogConfig), + } as DialogConfig; + if (inputType === 'range') { + cog.inputValue = 10; + } + if (inputType === 'select') { + cog.inputValue = cog.inputOptions![0]; + } + if (inputType === 'checkbox') { + cog.inputValue = cog.inputOptions!.slice(1, 3); + } + if (useSrv) { + setTimeout(() => { + this.srv.show(cog).subscribe((res: any) => { + if (res.result) this.toastService.show(`结果:${JSON.stringify(res.result)}`); + console.log('prompt from service', res); }); - if (inputType === 'range') { - cog.inputValue = 10; - } - if (inputType === 'select') { - cog.inputValue = cog.inputOptions[0]; - } - if (inputType === 'checkbox') { - cog.inputValue = cog.inputOptions.slice(1, 3); + }); + } else { + this.config = cog; + this.autoAS.show().subscribe((res: any) => { + if (res.result) { + this.toastService.show(`结果:${JSON.stringify(res.result)}`); } - if (useSrv) { - setTimeout(() => { - this.srv.show(cog).subscribe((res: any) => { - if (res.result) - this.toastService.show(`结果:${JSON.stringify(res.result)}`); - console.log('prompt from service', res); - }); - }); - } else { - this.config = cog; - this.autoAS.show().subscribe((res: any) => { - if (res.result) { - this.toastService.show(`结果:${JSON.stringify(res.result)}`); - } - console.log('prompt from component', res); - }); - } - return false; - } - - ngOnDestroy() { - this.srv.destroyAll(); + console.log('prompt from component', res); + }); } + return false; + } + ngOnDestroy() { + this.srv.destroyAll(); + } } diff --git a/src/app/example/example.module.ts b/src/app/example/example.module.ts index c661781..7a2a5b1 100644 --- a/src/app/example/example.module.ts +++ b/src/app/example/example.module.ts @@ -1,74 +1,103 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; +import { NgModule } from '@angular/core'; import { SharedModule } from '../shared/shared.module'; -import { ContainerComponent } from './container.component'; -import { PageComponent } from './page/page.component'; import { DemoAccordionComponent } from './accordion/accordion.component'; -import { ButtonComponent } from './button/button.component'; -import { ListComponent } from './list/list.component'; -import { InputComponent } from './input/input.component'; -import { SliderComponent } from './slider/slider.component'; -import { DemoUploaderComponent } from './uploader/uploader.component'; import { DemoActionSheetComponent } from './actionsheet/actionsheet.component'; -import { DemoDialogComponent } from './dialog/dialog.component'; import { ArticleComponent } from './article/article.component'; -import { FlexComponent } from './flex/flex.component'; import { BadgeComponent } from './badge/badge.component'; +import { ButtonComponent } from './button/button.component'; +import { DemoChartG2Component } from './chart-g2/chart-g2.component'; +import { ContainerComponent } from './container.component'; +import { CountdownComponent } from './countdown/countdown.component'; +import { DemoDialogComponent } from './dialog/dialog.component'; +import { FlexComponent } from './flex/flex.component'; import { FooterComponent } from './footer/footer.component'; +import { DemoGalleryComponent } from './gallery/gallery.component'; +import { GesturePasswordComponent } from './gesture-password/gesture-password.component'; import { GridComponent } from './grid/grid.component'; import { IconsComponent } from './icons/icons.component'; -import { PanelComponent } from './panel/panel.component'; -import { PreviewComponent } from './preview/preview.component'; +import { DemoInfiniteLoaderComponent } from './infiniteloader/infiniteloader.component'; +import { InputComponent } from './input/input.component'; +import { JWeiXinComponent } from './jweixin/jweixin.component'; +import { ListComponent } from './list/list.component'; import { DemoLoadmoreComponent } from './loadmore/loadmore.component'; -import { DemoProgressComponent } from './progress/progress.component'; -import { DemoGalleryComponent } from './gallery/gallery.component'; -import { DemoPickerComponent } from './picker/picker.component'; -import { DemoSearchBarComponent } from './searchbar/searchbar.component'; -import { DemoNavbarComponent } from './navbar/navbar.component'; -import { DemoTabbarComponent } from './tabbar/tabbar.component'; -import { DemoToastComponent } from './toast/toast.component'; -import { DemoToptipsComponent } from './toptips/toptips.component'; -import { DemoMsgComponent } from './msg/msg.component'; +import { DemoMapQQComponent } from './map-qq/map-qq.component'; +import { DemoMaskComponent } from './mask/mask.component'; import { DemoMsgFailComponent } from './msg/fail.component'; +import { DemoMsgComponent } from './msg/msg.component'; import { DemoMsgSuccessComponent } from './msg/success.component'; +import { DemoNavbarComponent } from './navbar/navbar.component'; +import { PageComponent } from './page/page.component'; +import { DemoPaginationComponent } from './pagination/pagination.component'; +import { PanelComponent } from './panel/panel.component'; +import { DemoPickerComponent } from './picker/picker.component'; import { DemoPopupComponent } from './popup/popup.component'; +import { PreviewComponent } from './preview/preview.component'; +import { DemoProgressComponent } from './progress/progress.component'; import { DemoPTRComponent } from './ptr/ptr.component'; -import { DemoInfiniteLoaderComponent } from './infiniteloader/infiniteloader.component'; -import { DemoSidebarComponent } from './sidebar/sidebar.component'; -import { DemoSwiperComponent } from './swiper/swiper.component'; -import { CountdownComponent } from './countdown/countdown.component'; -import { GesturePasswordComponent } from './gesture-password/gesture-password.component'; -import { DemoChartG2Component } from './chart-g2/chart-g2.component'; -import { DemoMapQQComponent } from './map-qq/map-qq.component'; -import { JWeiXinComponent } from './jweixin/jweixin.component'; -import { DemoMaskComponent } from './mask/mask.component'; import { DemoRatingComponent } from './rating/rating.component'; +import { DemoSearchBarComponent } from './searchbar/searchbar.component'; +import { DemoSidebarComponent } from './sidebar/sidebar.component'; +import { SliderComponent } from './slider/slider.component'; import { DemoStepperComponent } from './stepper/stepper.component'; -import { DemoPaginationComponent } from './pagination/pagination.component'; +import { DemoSwiperComponent } from './swiper/swiper.component'; +import { DemoTabbarComponent } from './tabbar/tabbar.component'; +import { DemoToastComponent } from './toast/toast.component'; +import { DemoToptipsComponent } from './toptips/toptips.component'; +import { DemoUploaderComponent } from './uploader/uploader.component'; const COMPONENTS = [ - ContainerComponent, PageComponent, DemoAccordionComponent, - ButtonComponent, InputComponent, ListComponent, SliderComponent, - DemoUploaderComponent, DemoActionSheetComponent, DemoDialogComponent, ArticleComponent, FlexComponent, - BadgeComponent, FooterComponent, GridComponent, IconsComponent, PanelComponent, PreviewComponent, - DemoLoadmoreComponent, DemoProgressComponent, DemoGalleryComponent, DemoPickerComponent, - DemoSearchBarComponent, DemoNavbarComponent, DemoTabbarComponent, DemoToastComponent, - DemoToptipsComponent, DemoMsgComponent, DemoMsgFailComponent, DemoMsgSuccessComponent, - DemoPopupComponent, DemoPTRComponent, DemoInfiniteLoaderComponent, DemoSidebarComponent, - DemoSwiperComponent, CountdownComponent, GesturePasswordComponent, DemoChartG2Component, - DemoMapQQComponent, JWeiXinComponent, DemoMaskComponent, DemoRatingComponent, DemoStepperComponent, - DemoPaginationComponent + ContainerComponent, + PageComponent, + DemoAccordionComponent, + ButtonComponent, + InputComponent, + ListComponent, + SliderComponent, + DemoUploaderComponent, + DemoActionSheetComponent, + DemoDialogComponent, + ArticleComponent, + FlexComponent, + BadgeComponent, + FooterComponent, + GridComponent, + IconsComponent, + PanelComponent, + PreviewComponent, + DemoLoadmoreComponent, + DemoProgressComponent, + DemoGalleryComponent, + DemoPickerComponent, + DemoSearchBarComponent, + DemoNavbarComponent, + DemoTabbarComponent, + DemoToastComponent, + DemoToptipsComponent, + DemoMsgComponent, + DemoMsgFailComponent, + DemoMsgSuccessComponent, + DemoPopupComponent, + DemoPTRComponent, + DemoInfiniteLoaderComponent, + DemoSidebarComponent, + DemoSwiperComponent, + CountdownComponent, + GesturePasswordComponent, + DemoChartG2Component, + DemoMapQQComponent, + JWeiXinComponent, + DemoMaskComponent, + DemoRatingComponent, + DemoStepperComponent, + DemoPaginationComponent, ]; @NgModule({ - imports: [ - SharedModule - ], - declarations: COMPONENTS, - entryComponents: [ - PageComponent - ], - exports: COMPONENTS + imports: [SharedModule], + declarations: COMPONENTS, + entryComponents: [PageComponent], + exports: COMPONENTS, }) export class ExampleCoreModule {} diff --git a/src/app/example/flex/flex.component.html b/src/app/example/flex/flex.component.html index 0b9043a..fd3e6ec 100644 --- a/src/app/example/flex/flex.component.html +++ b/src/app/example/flex/flex.component.html @@ -1,53 +1,51 @@ - -
-
-
weui
-
-
-
-
-
weui
-
-
-
weui
-
-
-
-
-
weui
-
-
-
weui
-
-
-
weui
-
-
-
-
-
weui
-
-
-
weui
-
-
-
weui
-
-
-
weui
-
-
-
-
-
weui
-
-
-
weui
-
-
-
weui
-
-
- +
+
+
weui
+
+
+
+
+
weui
+
+
+
weui
+
+
+
+
+
weui
+
+
+
weui
+
+
+
weui
+
+
+
+
+
weui
+
+
+
weui
+
+
+
weui
+
+
+
weui
+
+
+
+
+
weui
+
+
+
weui
+
+
+
weui
+
+
diff --git a/src/app/example/flex/flex.component.scss b/src/app/example/flex/flex.component.scss index af7d3ab..f79d6f7 100644 --- a/src/app/example/flex/flex.component.scss +++ b/src/app/example/flex/flex.component.scss @@ -1,8 +1,8 @@ .page.flex .placeholder { - background-color: #ebebeb; - height: 2.3em; - line-height: 2.3em; - text-align: center; - margin: 5px; - color: #cfcfcf; + height: 2.3em; + margin: 5px; + color: #cfcfcf; + line-height: 2.3em; + text-align: center; + background-color: #ebebeb; } diff --git a/src/app/example/flex/flex.component.ts b/src/app/example/flex/flex.component.ts index b8f90dd..394ca79 100644 --- a/src/app/example/flex/flex.component.ts +++ b/src/app/example/flex/flex.component.ts @@ -1,9 +1,9 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-flex', - templateUrl: './flex.component.html', - styleUrls: [ './flex.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-flex', + templateUrl: './flex.component.html', + styleUrls: ['./flex.component.scss'], + encapsulation: ViewEncapsulation.None, }) -export class FlexComponent {} +export class FlexComponent {} diff --git a/src/app/example/footer/footer.component.html b/src/app/example/footer/footer.component.html index 731191a..8ec8382 100644 --- a/src/app/example/footer/footer.component.html +++ b/src/app/example/footer/footer.component.html @@ -1,27 +1,26 @@ + +
+
+ +
+
+ - -
-
- -
-
- - - +
diff --git a/src/app/example/footer/footer.component.ts b/src/app/example/footer/footer.component.ts index 3426d25..19b76db 100644 --- a/src/app/example/footer/footer.component.ts +++ b/src/app/example/footer/footer.component.ts @@ -1,11 +1,11 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-footer', - templateUrl: './footer.component.html', - styleUrls: [ './footer.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-footer', + templateUrl: './footer.component.html', + styleUrls: ['./footer.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class FooterComponent { - year: number = new Date().getFullYear(); -} + year: number = new Date().getFullYear(); +} diff --git a/src/app/example/gallery/gallery.component.html b/src/app/example/gallery/gallery.component.html index 8a1a728..37566e3 100644 --- a/src/app/example/gallery/gallery.component.html +++ b/src/app/example/gallery/gallery.component.html @@ -1,8 +1,4 @@ - - - - + + diff --git a/src/app/example/gallery/gallery.component.ts b/src/app/example/gallery/gallery.component.ts index 3370de9..461b14b 100644 --- a/src/app/example/gallery/gallery.component.ts +++ b/src/app/example/gallery/gallery.component.ts @@ -1,16 +1,14 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-gallery', - templateUrl: './gallery.component.html', - styleUrls: ['./gallery.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-gallery', + templateUrl: './gallery.component.html', + styleUrls: ['./gallery.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoGalleryComponent { - - show: boolean = true; - onDelete(item: any) { - console.log(item); - } - -} + show: boolean = true; + onDelete(item: any) { + console.log(item); + } +} diff --git a/src/app/example/gesture-password/gesture-password.component.html b/src/app/example/gesture-password/gesture-password.component.html index fa70706..451195f 100644 --- a/src/app/example/gesture-password/gesture-password.component.html +++ b/src/app/example/gesture-password/gesture-password.component.html @@ -1,19 +1,26 @@ - - -

current password: {{pwd}}

-check -recorder -change option -{{switchState?'hide':'show'}} - - + +

current password: {{ pwd }}

+ check + recorder + change option + {{ switchState ? 'hide' : 'show' }} +
diff --git a/src/app/example/gesture-password/gesture-password.component.ts b/src/app/example/gesture-password/gesture-password.component.ts index e8a8f22..0977c02 100644 --- a/src/app/example/gesture-password/gesture-password.component.ts +++ b/src/app/example/gesture-password/gesture-password.component.ts @@ -1,22 +1,21 @@ import { Component, ViewEncapsulation } from '@angular/core'; -import { ToastrService } from 'ngx-toastr'; import { ERR } from 'ngx-gesture-password'; +import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'example-gesture-password', templateUrl: './gesture-password.component.html', styleUrls: ['./gesture-password.component.scss'], - encapsulation: ViewEncapsulation.None + encapsulation: ViewEncapsulation.None, }) export class GesturePasswordComponent { - pwd: string = '1236'; type: string = 'check'; options: any; switchState: boolean = true; - constructor(private _ns: ToastrService) { } + constructor(private _ns: ToastrService) {} onChangeOptions() { if (this.options) { @@ -27,7 +26,9 @@ export class GesturePasswordComponent { focusColor: '#5aa5fe', fgColor: '#878aa1', num: 4, - passwords: Array(16).fill(0).map((i, index) => String.fromCharCode(index + 65)) + passwords: Array(16) + .fill(0) + .map((_i, index) => String.fromCharCode(index + 65)), }; } } diff --git a/src/app/example/grid/grid.component.html b/src/app/example/grid/grid.component.html index bddf97a..1be580a 100644 --- a/src/app/example/grid/grid.component.html +++ b/src/app/example/grid/grid.component.html @@ -1,59 +1,58 @@ - - + diff --git a/src/app/example/grid/grid.component.ts b/src/app/example/grid/grid.component.ts index 449432e..9167a26 100644 --- a/src/app/example/grid/grid.component.ts +++ b/src/app/example/grid/grid.component.ts @@ -1,10 +1,9 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-grid', - templateUrl: './grid.component.html', - styleUrls: [ './grid.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-grid', + templateUrl: './grid.component.html', + styleUrls: ['./grid.component.scss'], + encapsulation: ViewEncapsulation.None, }) -export class GridComponent { -} +export class GridComponent {} diff --git a/src/app/example/icons/icons.component.html b/src/app/example/icons/icons.component.html index 77bf651..6b5f4d9 100644 --- a/src/app/example/icons/icons.component.html +++ b/src/app/example/icons/icons.component.html @@ -1,49 +1,47 @@ - -
- -
-

成功

-

用于表示操作顺利达成

-
+
+ +
+

成功

+

用于表示操作顺利达成

-
- -
-

提示

-

用于表示信息提示;也常用于缺乏条件的操作拦截,提示用户所需信息

-
+
+
+ +
+

提示

+

用于表示信息提示;也常用于缺乏条件的操作拦截,提示用户所需信息

-
- -
-

普通警告

-

用于表示操作后将引起一定后果的情况

-
+
+
+ +
+

普通警告

+

用于表示操作后将引起一定后果的情况

-
- -
-

强烈警告

-

用于表示操作后将引起严重的不可挽回的后果的情况

-
+
+
+ +
+

强烈警告

+

用于表示操作后将引起严重的不可挽回的后果的情况

-
- -
-

等待

-

用于表示等待

-
+
+
+ +
+

等待

+

用于表示等待

-
- - - - - - - - -
- +
+
+ + + + + + + + +
diff --git a/src/app/example/icons/icons.component.ts b/src/app/example/icons/icons.component.ts index 59fdbb3..66d1d4a 100644 --- a/src/app/example/icons/icons.component.ts +++ b/src/app/example/icons/icons.component.ts @@ -1,10 +1,9 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-icons', - templateUrl: './icons.component.html', - styleUrls: [ './icons.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-icons', + templateUrl: './icons.component.html', + styleUrls: ['./icons.component.scss'], + encapsulation: ViewEncapsulation.None, }) -export class IconsComponent { -} +export class IconsComponent {} diff --git a/src/app/example/infiniteloader/infiniteloader.component.html b/src/app/example/infiniteloader/infiniteloader.component.html index 2ef80e3..79d7d2b 100644 --- a/src/app/example/infiniteloader/infiniteloader.component.html +++ b/src/app/example/infiniteloader/infiniteloader.component.html @@ -1,14 +1,19 @@ - + +
List with 50 Max
+ -
List with 50 Max
- - - 重新开始 -
+ 重新开始 +
diff --git a/src/app/example/infiniteloader/infiniteloader.component.scss b/src/app/example/infiniteloader/infiniteloader.component.scss index 72d0504..3440ead 100644 --- a/src/app/example/infiniteloader/infiniteloader.component.scss +++ b/src/app/example/infiniteloader/infiniteloader.component.scss @@ -1,3 +1,3 @@ .weui-infiniteloader .page { - position: static; + position: static; } diff --git a/src/app/example/infiniteloader/infiniteloader.component.ts b/src/app/example/infiniteloader/infiniteloader.component.ts index fbcb96b..a7d6fa6 100644 --- a/src/app/example/infiniteloader/infiniteloader.component.ts +++ b/src/app/example/infiniteloader/infiniteloader.component.ts @@ -1,5 +1,5 @@ -import { Component, ViewEncapsulation, ViewChild } from '@angular/core'; -import { Observable, timer } from 'rxjs'; +import { Component, ViewChild, ViewEncapsulation } from '@angular/core'; +import { timer } from 'rxjs'; import { InfiniteLoaderComponent } from 'ngx-weui/infiniteloader'; @@ -15,7 +15,7 @@ export class DemoInfiniteLoaderComponent { items: any[] = Array(20) .fill(0) - .map((v: any, i: number) => i); + .map((_v: any, i: number) => i); onLoadMore(comp: InfiniteLoaderComponent) { this.restartBtn = false; timer(1500).subscribe(() => { diff --git a/src/app/example/input/input.component.html b/src/app/example/input/input.component.html index 1bad790..b9c4854 100644 --- a/src/app/example/input/input.component.html +++ b/src/app/example/input/input.component.html @@ -1,187 +1,247 @@ - -
-
单选列表项
-
- - -
添加更多
-
-
-
复选列表项
-
- - -
添加更多
-
-
-
-
-
-
- -
-
-
-
- -
-
- -
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
- -
-
-
-
底部说明文字底部说明文字
-
表单报错
-
-
-
-
- -
-
-
-
开关
-
-
-
标题文字
-
- -
-
-
-
兼容IE Edge的版本
-
- -
-
-
-
文本框
-
-
-
- -
-
-
-
文本域
-
-
-
- -
-
-
-
选择
-
-
-
- -
-
- -
-
-
-
选择
-
-
-
- -
-
-
-
- -
-
- -
-
-
- -
- -
-
- {{res | json}} +
+
单选列表项
+
+ + +
添加更多
+
+
+
复选列表项
+
+ + +
添加更多
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
底部说明文字底部说明文字
+
表单报错
+
+
+
+
+ +
+
+
+
开关
+
+
+
标题文字
+
+ +
+
+
+
兼容IE Edge的版本
+
+ +
+
+
+
文本框
+
+
+
+ +
+
+
+
文本域
+
+
+
+ +
+
+
+
选择
+
+
+
+ +
+
+ +
+
+
+
选择
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+ +
+ +
+
+ {{ res | json }}
diff --git a/src/app/example/input/input.component.ts b/src/app/example/input/input.component.ts index 2a7ad58..5b40686 100644 --- a/src/app/example/input/input.component.ts +++ b/src/app/example/input/input.component.ts @@ -1,5 +1,5 @@ import { Component, ViewEncapsulation } from '@angular/core'; -import { Observable, timer } from 'rxjs'; +import { timer, Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @Component({ @@ -26,11 +26,12 @@ export class InputComponent { } onAddCheckbox() { + // tslint:disable-next-line: binary-expression-operand-order this.checkbox.push(String.fromCharCode(65 + this.checkbox.length)); } onSendCode(): Observable { - return timer(1000).pipe(map((v, i) => true)); + return timer(1000).pipe(map(() => true)); } onSave() { diff --git a/src/app/example/jweixin/jweixin.component.html b/src/app/example/jweixin/jweixin.component.html index 24f6e55..f6f624f 100644 --- a/src/app/example/jweixin/jweixin.component.html +++ b/src/app/example/jweixin/jweixin.component.html @@ -1,9 +1,4 @@ - - -

{{status}}

-

更多细节,请参与在线文档

- + +

{{ status }}

+

更多细节,请参与在线文档

diff --git a/src/app/example/jweixin/jweixin.component.ts b/src/app/example/jweixin/jweixin.component.ts index 84241c8..477aeaf 100644 --- a/src/app/example/jweixin/jweixin.component.ts +++ b/src/app/example/jweixin/jweixin.component.ts @@ -1,25 +1,28 @@ import { Component, ViewEncapsulation } from '@angular/core'; -import { WXService } from "../../wx.service"; +import { WXService } from '../../wx.service'; @Component({ - selector: 'example-jweixin', - templateUrl: './jweixin.component.html', - styleUrls: ['./jweixin.component.scss'], - encapsulation: ViewEncapsulation.None, - providers: [WXService] + selector: 'example-jweixin', + templateUrl: './jweixin.component.html', + styleUrls: ['./jweixin.component.scss'], + encapsulation: ViewEncapsulation.None, + providers: [WXService], }) export class JWeiXinComponent { - constructor(private wxService: WXService) { } + constructor(private wxService: WXService) {} - status: string; - ngOnInit() { - this.wxService.config({ - title: '新标题' - }).then(() => { - // 其它操作,可以确保注册成功以后才有效 - this.status = '注册成功'; - }).catch((err: string) => { - this.status = `注册失败,原因:${err}` - }); - } + status: string; + ngOnInit() { + this.wxService + .config({ + title: '新标题', + }) + .then(() => { + // 其它操作,可以确保注册成功以后才有效 + this.status = '注册成功'; + }) + .catch((err: string) => { + this.status = `注册失败,原因:${err}`; + }); + } } diff --git a/src/app/example/list/list.component.html b/src/app/example/list/list.component.html index db29edf..aff864b 100644 --- a/src/app/example/list/list.component.html +++ b/src/app/example/list/list.component.html @@ -1,108 +1,130 @@ -
带说明的列表项
-
-
-
-

标题文字

-
-
说明文字
-
-
-
-
-
-

标题文字

-
-
向左滑动试试
-
-
-
- 删除 -
-
-
-
-
-
-

标题文字

-
-
向左滑动试试多个按钮
-
-
- -
+
带说明的列表项
+
+
+
+

标题文字

+
+
说明文字
-
带图标、说明的列表项
-
+
+
-
-
-

标题文字

-
-
说明文字
+
+

标题文字

+
+
向左滑动试试
+
+
+ 删除 +
+
+
+
-
-
-

标题文字

-
-
说明文字
+
+

标题文字

+
+
向左滑动试试多个按钮
+
+
-
带跳转的列表项
- -
带说明、跳转的列表项
- +
带图标、说明的列表项
+
+
+
+ +
+ +
+

标题文字

+
+
说明文字
-
带图标、说明、跳转的列表项
- +
带跳转的列表项
+ +
带说明、跳转的列表项
+ +
带图标、说明、跳转的列表项
+ diff --git a/src/app/example/list/list.component.ts b/src/app/example/list/list.component.ts index d129367..0e1df9d 100644 --- a/src/app/example/list/list.component.ts +++ b/src/app/example/list/list.component.ts @@ -1,10 +1,9 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-list', - templateUrl: './list.component.html', - styleUrls: [ './list.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-list', + templateUrl: './list.component.html', + styleUrls: ['./list.component.scss'], + encapsulation: ViewEncapsulation.None, }) -export class ListComponent { -} +export class ListComponent {} diff --git a/src/app/example/loadmore/loadmore.component.html b/src/app/example/loadmore/loadmore.component.html index ebda96a..f8741e5 100644 --- a/src/app/example/loadmore/loadmore.component.html +++ b/src/app/example/loadmore/loadmore.component.html @@ -1,10 +1,9 @@ + + + - - - - -
- - +
+ +
diff --git a/src/app/example/loadmore/loadmore.component.ts b/src/app/example/loadmore/loadmore.component.ts index 944f699..772bd06 100644 --- a/src/app/example/loadmore/loadmore.component.ts +++ b/src/app/example/loadmore/loadmore.component.ts @@ -1,20 +1,20 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-loadmore', - templateUrl: './loadmore.component.html', - styleUrls: ['./loadmore.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-loadmore', + templateUrl: './loadmore.component.html', + styleUrls: ['./loadmore.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoLoadmoreComponent { - type: string = 'loading'; - first: boolean = true; + type: string = 'loading'; + first: boolean = true; - onChange() { - this.first = false; - this.type = 'loading'; - setTimeout(() => { - this.type = 'line'; - }, 1000) - } -} + onChange() { + this.first = false; + this.type = 'loading'; + setTimeout(() => { + this.type = 'line'; + }, 1000); + } +} diff --git a/src/app/example/map-qq/map-qq.component.ts b/src/app/example/map-qq/map-qq.component.ts index 8d94fdf..6faef0a 100644 --- a/src/app/example/map-qq/map-qq.component.ts +++ b/src/app/example/map-qq/map-qq.component.ts @@ -1,26 +1,20 @@ -/* tslint:disable */ -import { Component, OnInit, ViewEncapsulation, AfterViewInit, ViewChild, ElementRef } from '@angular/core'; +import { Component, ViewChild, ViewEncapsulation } from '@angular/core'; import { AqmPanoramaComponent } from 'angular-qq-maps'; -declare const qq: any; - @Component({ - selector: 'example-map-qq', - templateUrl: './map-qq.component.html', - styleUrls: ['./map-qq.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-map-qq', + templateUrl: './map-qq.component.html', + styleUrls: ['./map-qq.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoMapQQComponent { - - options: any = { - pano: '10011501120802180635300', - pov: { - heading: 1, - pitch: 0 - }, - zoom: 1 - } - @ViewChild('map') map: AqmPanoramaComponent; - - constructor(private el: ElementRef) { } + options: any = { + pano: '10011501120802180635300', + pov: { + heading: 1, + pitch: 0, + }, + zoom: 1, + }; + @ViewChild('map') map: AqmPanoramaComponent; } diff --git a/src/app/example/mask/mask.component.html b/src/app/example/mask/mask.component.html index b790652..98c74b6 100644 --- a/src/app/example/mask/mask.component.html +++ b/src/app/example/mask/mask.component.html @@ -1,23 +1,25 @@ + + + - - - + - +
自定义内容
-
自定义内容
- - - -

显示 + +

test content

-
- + " + > + test content +

+
diff --git a/src/app/example/mask/mask.component.ts b/src/app/example/mask/mask.component.ts index 3f54c9d..2ab90c2 100644 --- a/src/app/example/mask/mask.component.ts +++ b/src/app/example/mask/mask.component.ts @@ -2,43 +2,41 @@ import { Component, ViewChild } from '@angular/core'; import { MaskComponent } from 'ngx-weui/mask'; @Component({ - selector: 'example-mask', - templateUrl: './mask.component.html', - styleUrls: [ './mask.component.scss' ] + selector: 'example-mask', + templateUrl: './mask.component.html', + styleUrls: ['./mask.component.scss'], }) export class DemoMaskComponent { + loading = false; - loading = false; + @ViewChild('mask') mask: MaskComponent; - @ViewChild('mask') mask: MaskComponent; + @ViewChild('maskContent') maskContent: MaskComponent; - @ViewChild('maskContent') maskContent: MaskComponent; - - onShow(isNormal: boolean = false) { - this.mask.show().subscribe(() => { - console.log('已关闭'); - }); - this.mask.backdrop = isNormal; - if (!isNormal) { - setTimeout(() => { - this.mask.hide(); - }, 1000 * 2); - } - } - - onShowLoading() { - this.mask.show(); - this.loading = true; - setTimeout(() => { - this.mask.hide(); - }, 1000 * 2); + onShow(isNormal: boolean = false) { + this.mask.show().subscribe(() => { + console.log('已关闭'); + }); + this.mask.backdrop = isNormal; + if (!isNormal) { + setTimeout(() => { + this.mask.hide(); + }, 1000 * 2); } - - showContent() { - this.maskContent.show(); - setTimeout(() => { - this.maskContent.hide(); - }, 1000 * 2); - } - + } + + onShowLoading() { + this.mask.show(); + this.loading = true; + setTimeout(() => { + this.mask.hide(); + }, 1000 * 2); + } + + showContent() { + this.maskContent.show(); + setTimeout(() => { + this.maskContent.hide(); + }, 1000 * 2); + } } diff --git a/src/app/example/msg/fail.component.ts b/src/app/example/msg/fail.component.ts index f943688..e76fb5b 100644 --- a/src/app/example/msg/fail.component.ts +++ b/src/app/example/msg/fail.component.ts @@ -1,31 +1,31 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-msg-fail', - template: ` + selector: 'example-msg-fail', + template: `
-
-
-

操作失败

-

内容详情,可根据实际需要安排,如果换行则不超过规定长度,居中展现文字链接

-
- -
- +
+
+

操作失败

+

+ 内容详情,可根据实际需要安排,如果换行则不超过规定长度,居中展现文字链接 +

+
+ +
+ +
- `, - encapsulation: ViewEncapsulation.None + `, + encapsulation: ViewEncapsulation.None, }) -export class DemoMsgFailComponent { - -} +export class DemoMsgFailComponent {} diff --git a/src/app/example/msg/msg.component.html b/src/app/example/msg/msg.component.html index d4dd927..10164fd 100644 --- a/src/app/example/msg/msg.component.html +++ b/src/app/example/msg/msg.component.html @@ -1,8 +1,4 @@ - - - - - + + + diff --git a/src/app/example/msg/msg.component.ts b/src/app/example/msg/msg.component.ts index 26d5b9c..ab55149 100644 --- a/src/app/example/msg/msg.component.ts +++ b/src/app/example/msg/msg.component.ts @@ -1,10 +1,10 @@ import { Component, ViewEncapsulation, Input } from '@angular/core'; @Component({ - selector: 'example-msg', - templateUrl: './msg.component.html', - styleUrls: [ './msg.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-msg', + templateUrl: './msg.component.html', + styleUrls: ['./msg.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoMsgComponent { - @Input() url: string = 'example'; + @Input() url: string = 'example'; } diff --git a/src/app/example/msg/success.component.ts b/src/app/example/msg/success.component.ts index ada4ee2..c49a70e 100644 --- a/src/app/example/msg/success.component.ts +++ b/src/app/example/msg/success.component.ts @@ -1,31 +1,31 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-msg-success', - template: ` + selector: 'example-msg-success', + template: `
-
-
-

操作成功

-

内容详情,可根据实际需要安排,如果换行则不超过规定长度,居中展现文字链接

-
- -
- +
+
+

操作成功

+

+ 内容详情,可根据实际需要安排,如果换行则不超过规定长度,居中展现文字链接 +

+
+ +
+ +
- `, - encapsulation: ViewEncapsulation.None + `, + encapsulation: ViewEncapsulation.None, }) -export class DemoMsgSuccessComponent { - -} +export class DemoMsgSuccessComponent {} diff --git a/src/app/example/navbar/navbar.component.html b/src/app/example/navbar/navbar.component.html index 5d0fe1b..a78d7d3 100644 --- a/src/app/example/navbar/navbar.component.html +++ b/src/app/example/navbar/navbar.component.html @@ -1,18 +1,18 @@ - -
-

Panel 1 Title

-
-
- -
-

Panel 2 Title

-

Select Time: {{time}}

-
-
- -
-

Panel 3 Title

-
-
+ +
+

Panel 1 Title

+
+
+ +
+

Panel 2 Title

+

Select Time: {{ time }}

+
+
+ +
+

Panel 3 Title

+
+
diff --git a/src/app/example/navbar/navbar.component.scss b/src/app/example/navbar/navbar.component.scss index 84816d3..99830b6 100644 --- a/src/app/example/navbar/navbar.component.scss +++ b/src/app/example/navbar/navbar.component.scss @@ -1,4 +1,8 @@ -html, body, app-root, example-navbar, example-layout { - height: 100%; - display: block; +html, +body, +app-root, +example-navbar, +example-layout { + display: block; + height: 100%; } diff --git a/src/app/example/navbar/navbar.component.ts b/src/app/example/navbar/navbar.component.ts index aaab9e7..33fe329 100644 --- a/src/app/example/navbar/navbar.component.ts +++ b/src/app/example/navbar/navbar.component.ts @@ -1,14 +1,14 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-navbar', - templateUrl: './navbar.component.html', - styleUrls: ['./navbar.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-navbar', + templateUrl: './navbar.component.html', + styleUrls: ['./navbar.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoNavbarComponent { - time: number; - onSelect() { - this.time = new Date().getTime(); - } -} + time: number; + onSelect() { + this.time = new Date().getTime(); + } +} diff --git a/src/app/example/page/page.component.scss b/src/app/example/page/page.component.scss index 392a467..c4729e3 100644 --- a/src/app/example/page/page.component.scss +++ b/src/app/example/page/page.component.scss @@ -1,103 +1,104 @@ html, body { - height: 100%; - -webkit-tap-highlight-color: transparent; + height: 100%; + -webkit-tap-highlight-color: transparent; } body { - font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif; + font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif; } ul { - list-style: none; + list-style: none; } body, .page { - background-color: #F8F8F8; + background-color: #f8f8f8; } .link { - color: #1aad19; + color: #1aad19; } .container { - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - overflow: hidden; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + overflow: hidden; } .page { - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - overflow-y: auto; - -webkit-overflow-scrolling: touch; - z-index: 1; // fix 滑动几次后可滚动区域会卡住的问题 + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 1; // fix 滑动几次后可滚动区域会卡住的问题 + overflow-y: auto; + -webkit-overflow-scrolling: touch; } .page__hd { - padding: 40px; + padding: 40px; } -.page__bd {} +.page__bd { +} .page__bd_spacing { - padding: 0 15px; + padding: 0 15px; } .page__ft { - padding-top: 40px; - padding-bottom: 10px; - text-align: center; - img { - height: 19px; - } - &.j_bottom { - position: absolute; - bottom: 0; - left: 0; - right: 0; - } + padding-top: 40px; + padding-bottom: 10px; + text-align: center; + img { + height: 19px; + } + &.j_bottom { + position: absolute; + right: 0; + bottom: 0; + left: 0; + } } .page__title { - text-align: left; - font-size: 20px; - font-weight: 400; + font-weight: 400; + font-size: 20px; + text-align: left; } .page__desc { - margin-top: 5px; - color: #888888; - text-align: left; - font-size: 14px; + margin-top: 5px; + color: #888; + font-size: 14px; + text-align: left; } .page-enter { - z-index: 1024; - opacity: 0.01; - transform: translate3d(100%, 0, 0); - transition: all .2s ease; - &.page-enter-active { - opacity: 1; - transform: translate3d(0, 0, 0); - } + z-index: 1024; + transform: translate3d(100%, 0, 0); + opacity: 0.01; + transition: all 0.2s ease; + &.page-enter-active { + transform: translate3d(0, 0, 0); + opacity: 1; + } } .page-leave { - opacity: 1; - transform: translate3d(0, 0, 0); - transition: all .2s ease; - &.page-leave-active { - opacity: 0.01; - transform: translate3d(100%, 0, 0); - } + transform: translate3d(0, 0, 0); + opacity: 1; + transition: all 0.2s ease; + &.page-leave-active { + transform: translate3d(100%, 0, 0); + opacity: 0.01; + } } .page.article, @@ -109,56 +110,55 @@ body, .page.msg, .page.toast, .page.toptips, -.page.popup, -{ - background-color: #fff; +.page.popup { + background-color: #fff; } .page.infinite { - position: relative; + position: relative; } .page.flex { - .placeholder { - background-color: #EBEBEB; - height: 2.3em; - line-height: 2.3em; - text-align: center; - margin: 5px; - color: #CFCFCF; - } + .placeholder { + height: 2.3em; + margin: 5px; + color: #cfcfcf; + line-height: 2.3em; + text-align: center; + background-color: #ebebeb; + } } .page.icons { - text-align: center; - .page__bd { - padding: 0 40px; - text-align: left; - } - .icon-box { - margin-bottom: 25px; - display: flex; - align-items: center; - i { - margin-right: 18px; - } - } - .icon-box__ctn { - flex-shrink: 100; - } - .icon-box__title { - font-weight: normal; - } - .icon-box__desc { - margin-top: 6px; - font-size: 12px; - color: #888888; + text-align: center; + .page__bd { + padding: 0 40px; + text-align: left; + } + .icon-box { + display: flex; + align-items: center; + margin-bottom: 25px; + i { + margin-right: 18px; } - .icon_sp_area { - margin-top: 10px; - text-align: left; - i:before { - margin-bottom: 5px; - } + } + .icon-box__ctn { + flex-shrink: 100; + } + .icon-box__title { + font-weight: normal; + } + .icon-box__desc { + margin-top: 6px; + color: #888; + font-size: 12px; + } + .icon_sp_area { + margin-top: 10px; + text-align: left; + i::before { + margin-bottom: 5px; } + } } diff --git a/src/app/example/page/page.component.ts b/src/app/example/page/page.component.ts index e130d7b..738195d 100644 --- a/src/app/example/page/page.component.ts +++ b/src/app/example/page/page.component.ts @@ -1,28 +1,28 @@ import { Component, Input, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'Page', - template: ` + selector: 'Page', + template: `
-

-

+

+

-
-
- - +
+
+ +
- `, - host: { - 'class': 'page' - }, - styleUrls: [ './page.component.scss' ], - encapsulation: ViewEncapsulation.None + `, + host: { + class: 'page', + }, + styleUrls: ['./page.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class PageComponent { - @Input() title: string; - @Input() subTitle: string; - @Input() spacing: boolean = true; - @Input() ftBottom: boolean = false; - @Input() noBottom: boolean = false; + @Input() title: string; + @Input() subTitle: string; + @Input() spacing: boolean = true; + @Input() ftBottom: boolean = false; + @Input() noBottom: boolean = false; } diff --git a/src/app/example/pagination/pagination.component.html b/src/app/example/pagination/pagination.component.html index 2706c7c..6f980cf 100644 --- a/src/app/example/pagination/pagination.component.html +++ b/src/app/example/pagination/pagination.component.html @@ -1,16 +1,18 @@ - -
Button with text
- -
Button with text and icon
- -
Hide number
- -
Button Size
- -
Point Style
- - +
Button with text
+ +
Button with text and icon
+ +
Hide number
+ +
Button Size
+ +
Point Style
+
diff --git a/src/app/example/pagination/pagination.component.ts b/src/app/example/pagination/pagination.component.ts index f1b002d..9b47e3c 100644 --- a/src/app/example/pagination/pagination.component.ts +++ b/src/app/example/pagination/pagination.component.ts @@ -1,20 +1,19 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-pagination', - templateUrl: './pagination.component.html', - styleUrls: ['./pagination.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-pagination', + templateUrl: './pagination.component.html', + styleUrls: ['./pagination.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoPaginationComponent { + prev = ` Prev`; + next = `Next `; + cur = 1; + total = 10; - prev = ` Prev`; - next = `Next `; - cur = 1; - total = 10; - - change(value: number) { - this.cur = value; - console.log('pi=', value); - } + change(value: number) { + this.cur = value; + console.log('pi=', value); + } } diff --git a/src/app/example/panel/panel.component.html b/src/app/example/panel/panel.component.html index 69e2dc9..c546c06 100644 --- a/src/app/example/panel/panel.component.html +++ b/src/app/example/panel/panel.component.html @@ -1,93 +1,113 @@ - -
-
图文组合列表
-
- -
- -
-
-

标题一

-

由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。

-
-
- -
- -
-
-

标题二

-

由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。

-
-
+
+
图文组合列表
+
+ +
+
-
- -
查看更多
- -
+
+

标题一

+

+ 由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。 +

-
-
-
文字组合列表
-
-
-

标题一

-

由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。

-
-
-

标题二

-

由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。

-
+ + +
+
-
- -
查看更多
- -
+
+

标题二

+

+ 由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。 +

+
- +
+
文字组合列表
+
+
+

标题一

+

由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。

+
+
+

标题二

+

由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。

+
+
+ -
-
文字列表附来源
-
-
-

标题一

-

由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。

-
    -
  • 文字来源
  • -
  • 时间
  • -
  • 其它信息
  • -
+
+ +
+
文字列表附来源
+
+
+

标题一

+

由各种物质组成的巨型球状天体,叫做星球。星球有一定的形状,有自己的运行轨道。

+
    +
  • 文字来源
  • +
  • 时间
  • +
  • 其它信息
  • +
+
+
+
diff --git a/src/app/example/panel/panel.component.ts b/src/app/example/panel/panel.component.ts index 56d6eca..b51ad71 100644 --- a/src/app/example/panel/panel.component.ts +++ b/src/app/example/panel/panel.component.ts @@ -1,10 +1,9 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-panel', - templateUrl: './panel.component.html', - styleUrls: [ './panel.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-panel', + templateUrl: './panel.component.html', + styleUrls: ['./panel.component.scss'], + encapsulation: ViewEncapsulation.None, }) -export class PanelComponent { -} +export class PanelComponent {} diff --git a/src/app/example/picker/cn.ts b/src/app/example/picker/cn.ts index 905920a..f48da09 100644 --- a/src/app/example/picker/cn.ts +++ b/src/app/example/picker/cn.ts @@ -4,16485 +4,16481 @@ */ export const DATA = [ { - "name":"北京", - "code":"110000", - "sub": [ - { - "name": "北京市", - "code": "110000", - "sub":[ - { - "name":"东城区", - "code":"110101" - }, - { - "name":"西城区", - "code":"110102" - }, - { - "name":"朝阳区", - "code":"110105" - }, - { - "name":"丰台区", - "code":"110106" - }, - { - "name":"石景山区", - "code":"110107" - }, - { - "name":"海淀区", - "code":"110108" - }, - { - "name":"门头沟区", - "code":"110109" - }, - { - "name":"房山区", - "code":"110111" - }, - { - "name":"通州区", - "code":"110112" - }, - { - "name":"顺义区", - "code":"110113" - }, - { - "name":"昌平区", - "code":"110114" - }, - { - "name":"大兴区", - "code":"110115" - }, - { - "name":"怀柔区", - "code":"110116" - }, - { - "name":"平谷区", - "code":"110117" - }, - { - "name":"密云县", - "code":"110228" - }, - { - "name":"延庆县", - "code":"110229" - } - ] - } - ] + name: '北京', + code: '110000', + sub: [ + { + name: '北京市', + code: '110000', + sub: [ + { + name: '东城区', + code: '110101', + }, + { + name: '西城区', + code: '110102', + }, + { + name: '朝阳区', + code: '110105', + }, + { + name: '丰台区', + code: '110106', + }, + { + name: '石景山区', + code: '110107', + }, + { + name: '海淀区', + code: '110108', + }, + { + name: '门头沟区', + code: '110109', + }, + { + name: '房山区', + code: '110111', + }, + { + name: '通州区', + code: '110112', + }, + { + name: '顺义区', + code: '110113', + }, + { + name: '昌平区', + code: '110114', + }, + { + name: '大兴区', + code: '110115', + }, + { + name: '怀柔区', + code: '110116', + }, + { + name: '平谷区', + code: '110117', + }, + { + name: '密云县', + code: '110228', + }, + { + name: '延庆县', + code: '110229', + }, + ], + }, + ], }, { - "name":"天津", - "code":"120000", - "sub": [ - { - "name": "天津市", - "code": "120000", - "sub":[ - { - "name":"和平区", - "code":"120101" - }, - { - "name":"河东区", - "code":"120102" - }, - { - "name":"河西区", - "code":"120103" - }, - { - "name":"南开区", - "code":"120104" - }, - { - "name":"河北区", - "code":"120105" - }, - { - "name":"红桥区", - "code":"120106" - }, - { - "name":"东丽区", - "code":"120110" - }, - { - "name":"西青区", - "code":"120111" - }, - { - "name":"津南区", - "code":"120112" - }, - { - "name":"北辰区", - "code":"120113" - }, - { - "name":"武清区", - "code":"120114" - }, - { - "name":"宝坻区", - "code":"120115" - }, - { - "name":"滨海新区", - "code":"120116" - }, - { - "name":"宁河县", - "code":"120221" - }, - { - "name":"静海县", - "code":"120223" - }, - { - "name":"蓟县", - "code":"120225" - } - ] - } - ] + name: '天津', + code: '120000', + sub: [ + { + name: '天津市', + code: '120000', + sub: [ + { + name: '和平区', + code: '120101', + }, + { + name: '河东区', + code: '120102', + }, + { + name: '河西区', + code: '120103', + }, + { + name: '南开区', + code: '120104', + }, + { + name: '河北区', + code: '120105', + }, + { + name: '红桥区', + code: '120106', + }, + { + name: '东丽区', + code: '120110', + }, + { + name: '西青区', + code: '120111', + }, + { + name: '津南区', + code: '120112', + }, + { + name: '北辰区', + code: '120113', + }, + { + name: '武清区', + code: '120114', + }, + { + name: '宝坻区', + code: '120115', + }, + { + name: '滨海新区', + code: '120116', + }, + { + name: '宁河县', + code: '120221', + }, + { + name: '静海县', + code: '120223', + }, + { + name: '蓟县', + code: '120225', + }, + ], + }, + ], }, { - "name":"河北省", - "code":"130000", - "sub":[ + name: '河北省', + code: '130000', + sub: [ { - "name":"石家庄市", - "code":"130100", - "sub":[ + name: '石家庄市', + code: '130100', + sub: [ { - "name":"市辖区", - "code":"130101" + name: '市辖区', + code: '130101', }, { - "name":"长安区", - "code":"130102" + name: '长安区', + code: '130102', }, { - "name":"桥西区", - "code":"130104" + name: '桥西区', + code: '130104', }, { - "name":"新华区", - "code":"130105" + name: '新华区', + code: '130105', }, { - "name":"井陉矿区", - "code":"130107" + name: '井陉矿区', + code: '130107', }, { - "name":"裕华区", - "code":"130108" + name: '裕华区', + code: '130108', }, { - "name":"藁城区", - "code":"130109" + name: '藁城区', + code: '130109', }, { - "name":"鹿泉区", - "code":"130110" + name: '鹿泉区', + code: '130110', }, { - "name":"栾城区", - "code":"130111" + name: '栾城区', + code: '130111', }, { - "name":"井陉县", - "code":"130121" + name: '井陉县', + code: '130121', }, { - "name":"正定县", - "code":"130123" + name: '正定县', + code: '130123', }, { - "name":"行唐县", - "code":"130125" + name: '行唐县', + code: '130125', }, { - "name":"灵寿县", - "code":"130126" + name: '灵寿县', + code: '130126', }, { - "name":"高邑县", - "code":"130127" + name: '高邑县', + code: '130127', }, { - "name":"深泽县", - "code":"130128" + name: '深泽县', + code: '130128', }, { - "name":"赞皇县", - "code":"130129" + name: '赞皇县', + code: '130129', }, { - "name":"无极县", - "code":"130130" + name: '无极县', + code: '130130', }, { - "name":"平山县", - "code":"130131" + name: '平山县', + code: '130131', }, { - "name":"元氏县", - "code":"130132" + name: '元氏县', + code: '130132', }, { - "name":"赵县", - "code":"130133" + name: '赵县', + code: '130133', }, { - "name":"辛集市", - "code":"130181" + name: '辛集市', + code: '130181', }, { - "name":"晋州市", - "code":"130183" + name: '晋州市', + code: '130183', }, { - "name":"新乐市", - "code":"130184" - } - ] + name: '新乐市', + code: '130184', + }, + ], }, { - "name":"唐山市", - "code":"130200", - "sub":[ + name: '唐山市', + code: '130200', + sub: [ { - "name":"市辖区", - "code":"130201" + name: '市辖区', + code: '130201', }, { - "name":"路南区", - "code":"130202" + name: '路南区', + code: '130202', }, { - "name":"路北区", - "code":"130203" + name: '路北区', + code: '130203', }, { - "name":"古冶区", - "code":"130204" + name: '古冶区', + code: '130204', }, { - "name":"开平区", - "code":"130205" + name: '开平区', + code: '130205', }, { - "name":"丰南区", - "code":"130207" + name: '丰南区', + code: '130207', }, { - "name":"丰润区", - "code":"130208" + name: '丰润区', + code: '130208', }, { - "name":"曹妃甸区", - "code":"130209" + name: '曹妃甸区', + code: '130209', }, { - "name":"滦县", - "code":"130223" + name: '滦县', + code: '130223', }, { - "name":"滦南县", - "code":"130224" + name: '滦南县', + code: '130224', }, { - "name":"乐亭县", - "code":"130225" + name: '乐亭县', + code: '130225', }, { - "name":"迁西县", - "code":"130227" + name: '迁西县', + code: '130227', }, { - "name":"玉田县", - "code":"130229" + name: '玉田县', + code: '130229', }, { - "name":"遵化市", - "code":"130281" + name: '遵化市', + code: '130281', }, { - "name":"迁安市", - "code":"130283" - } - ] + name: '迁安市', + code: '130283', + }, + ], }, { - "name":"秦皇岛市", - "code":"130300", - "sub":[ + name: '秦皇岛市', + code: '130300', + sub: [ { - "name":"市辖区", - "code":"130301" + name: '市辖区', + code: '130301', }, { - "name":"海港区", - "code":"130302" + name: '海港区', + code: '130302', }, { - "name":"山海关区", - "code":"130303" + name: '山海关区', + code: '130303', }, { - "name":"北戴河区", - "code":"130304" + name: '北戴河区', + code: '130304', }, { - "name":"青龙满族自治县", - "code":"130321" + name: '青龙满族自治县', + code: '130321', }, { - "name":"昌黎县", - "code":"130322" + name: '昌黎县', + code: '130322', }, { - "name":"抚宁县", - "code":"130323" + name: '抚宁县', + code: '130323', }, { - "name":"卢龙县", - "code":"130324" - } - ] + name: '卢龙县', + code: '130324', + }, + ], }, { - "name":"邯郸市", - "code":"130400", - "sub":[ + name: '邯郸市', + code: '130400', + sub: [ { - "name":"市辖区", - "code":"130401" + name: '市辖区', + code: '130401', }, { - "name":"邯山区", - "code":"130402" + name: '邯山区', + code: '130402', }, { - "name":"丛台区", - "code":"130403" + name: '丛台区', + code: '130403', }, { - "name":"复兴区", - "code":"130404" + name: '复兴区', + code: '130404', }, { - "name":"峰峰矿区", - "code":"130406" + name: '峰峰矿区', + code: '130406', }, { - "name":"邯郸县", - "code":"130421" + name: '邯郸县', + code: '130421', }, { - "name":"临漳县", - "code":"130423" + name: '临漳县', + code: '130423', }, { - "name":"成安县", - "code":"130424" + name: '成安县', + code: '130424', }, { - "name":"大名县", - "code":"130425" + name: '大名县', + code: '130425', }, { - "name":"涉县", - "code":"130426" + name: '涉县', + code: '130426', }, { - "name":"磁县", - "code":"130427" + name: '磁县', + code: '130427', }, { - "name":"肥乡县", - "code":"130428" + name: '肥乡县', + code: '130428', }, { - "name":"永年县", - "code":"130429" + name: '永年县', + code: '130429', }, { - "name":"邱县", - "code":"130430" + name: '邱县', + code: '130430', }, { - "name":"鸡泽县", - "code":"130431" + name: '鸡泽县', + code: '130431', }, { - "name":"广平县", - "code":"130432" + name: '广平县', + code: '130432', }, { - "name":"馆陶县", - "code":"130433" + name: '馆陶县', + code: '130433', }, { - "name":"魏县", - "code":"130434" + name: '魏县', + code: '130434', }, { - "name":"曲周县", - "code":"130435" + name: '曲周县', + code: '130435', }, { - "name":"武安市", - "code":"130481" - } - ] + name: '武安市', + code: '130481', + }, + ], }, { - "name":"邢台市", - "code":"130500", - "sub":[ + name: '邢台市', + code: '130500', + sub: [ { - "name":"市辖区", - "code":"130501" + name: '市辖区', + code: '130501', }, { - "name":"桥东区", - "code":"130502" + name: '桥东区', + code: '130502', }, { - "name":"桥西区", - "code":"130503" + name: '桥西区', + code: '130503', }, { - "name":"邢台县", - "code":"130521" + name: '邢台县', + code: '130521', }, { - "name":"临城县", - "code":"130522" + name: '临城县', + code: '130522', }, { - "name":"内丘县", - "code":"130523" + name: '内丘县', + code: '130523', }, { - "name":"柏乡县", - "code":"130524" + name: '柏乡县', + code: '130524', }, { - "name":"隆尧县", - "code":"130525" + name: '隆尧县', + code: '130525', }, { - "name":"任县", - "code":"130526" + name: '任县', + code: '130526', }, { - "name":"南和县", - "code":"130527" + name: '南和县', + code: '130527', }, { - "name":"宁晋县", - "code":"130528" + name: '宁晋县', + code: '130528', }, { - "name":"巨鹿县", - "code":"130529" + name: '巨鹿县', + code: '130529', }, { - "name":"新河县", - "code":"130530" + name: '新河县', + code: '130530', }, { - "name":"广宗县", - "code":"130531" + name: '广宗县', + code: '130531', }, { - "name":"平乡县", - "code":"130532" + name: '平乡县', + code: '130532', }, { - "name":"威县", - "code":"130533" + name: '威县', + code: '130533', }, { - "name":"清河县", - "code":"130534" + name: '清河县', + code: '130534', }, { - "name":"临西县", - "code":"130535" + name: '临西县', + code: '130535', }, { - "name":"南宫市", - "code":"130581" + name: '南宫市', + code: '130581', }, { - "name":"沙河市", - "code":"130582" - } - ] + name: '沙河市', + code: '130582', + }, + ], }, { - "name":"保定市", - "code":"130600", - "sub":[ + name: '保定市', + code: '130600', + sub: [ { - "name":"市辖区", - "code":"130601" + name: '市辖区', + code: '130601', }, { - "name":"新市区", - "code":"130602" + name: '新市区', + code: '130602', }, { - "name":"北市区", - "code":"130603" + name: '北市区', + code: '130603', }, { - "name":"南市区", - "code":"130604" + name: '南市区', + code: '130604', }, { - "name":"满城县", - "code":"130621" + name: '满城县', + code: '130621', }, { - "name":"清苑县", - "code":"130622" + name: '清苑县', + code: '130622', }, { - "name":"涞水县", - "code":"130623" + name: '涞水县', + code: '130623', }, { - "name":"阜平县", - "code":"130624" + name: '阜平县', + code: '130624', }, { - "name":"徐水县", - "code":"130625" + name: '徐水县', + code: '130625', }, { - "name":"定兴县", - "code":"130626" + name: '定兴县', + code: '130626', }, { - "name":"唐县", - "code":"130627" + name: '唐县', + code: '130627', }, { - "name":"高阳县", - "code":"130628" + name: '高阳县', + code: '130628', }, { - "name":"容城县", - "code":"130629" + name: '容城县', + code: '130629', }, { - "name":"涞源县", - "code":"130630" + name: '涞源县', + code: '130630', }, { - "name":"望都县", - "code":"130631" + name: '望都县', + code: '130631', }, { - "name":"安新县", - "code":"130632" + name: '安新县', + code: '130632', }, { - "name":"易县", - "code":"130633" + name: '易县', + code: '130633', }, { - "name":"曲阳县", - "code":"130634" + name: '曲阳县', + code: '130634', }, { - "name":"蠡县", - "code":"130635" + name: '蠡县', + code: '130635', }, { - "name":"顺平县", - "code":"130636" + name: '顺平县', + code: '130636', }, { - "name":"博野县", - "code":"130637" + name: '博野县', + code: '130637', }, { - "name":"雄县", - "code":"130638" + name: '雄县', + code: '130638', }, { - "name":"涿州市", - "code":"130681" + name: '涿州市', + code: '130681', }, { - "name":"定州市", - "code":"130682" + name: '定州市', + code: '130682', }, { - "name":"安国市", - "code":"130683" + name: '安国市', + code: '130683', }, { - "name":"高碑店市", - "code":"130684" - } - ] + name: '高碑店市', + code: '130684', + }, + ], }, { - "name":"张家口市", - "code":"130700", - "sub":[ + name: '张家口市', + code: '130700', + sub: [ { - "name":"市辖区", - "code":"130701" + name: '市辖区', + code: '130701', }, { - "name":"桥东区", - "code":"130702" + name: '桥东区', + code: '130702', }, { - "name":"桥西区", - "code":"130703" + name: '桥西区', + code: '130703', }, { - "name":"宣化区", - "code":"130705" + name: '宣化区', + code: '130705', }, { - "name":"下花园区", - "code":"130706" + name: '下花园区', + code: '130706', }, { - "name":"宣化县", - "code":"130721" + name: '宣化县', + code: '130721', }, { - "name":"张北县", - "code":"130722" + name: '张北县', + code: '130722', }, { - "name":"康保县", - "code":"130723" + name: '康保县', + code: '130723', }, { - "name":"沽源县", - "code":"130724" + name: '沽源县', + code: '130724', }, { - "name":"尚义县", - "code":"130725" + name: '尚义县', + code: '130725', }, { - "name":"蔚县", - "code":"130726" + name: '蔚县', + code: '130726', }, { - "name":"阳原县", - "code":"130727" + name: '阳原县', + code: '130727', }, { - "name":"怀安县", - "code":"130728" + name: '怀安县', + code: '130728', }, { - "name":"万全县", - "code":"130729" + name: '万全县', + code: '130729', }, { - "name":"怀来县", - "code":"130730" + name: '怀来县', + code: '130730', }, { - "name":"涿鹿县", - "code":"130731" + name: '涿鹿县', + code: '130731', }, { - "name":"赤城县", - "code":"130732" + name: '赤城县', + code: '130732', }, { - "name":"崇礼县", - "code":"130733" - } - ] + name: '崇礼县', + code: '130733', + }, + ], }, { - "name":"承德市", - "code":"130800", - "sub":[ + name: '承德市', + code: '130800', + sub: [ { - "name":"市辖区", - "code":"130801" + name: '市辖区', + code: '130801', }, { - "name":"双桥区", - "code":"130802" + name: '双桥区', + code: '130802', }, { - "name":"双滦区", - "code":"130803" + name: '双滦区', + code: '130803', }, { - "name":"鹰手营子矿区", - "code":"130804" + name: '鹰手营子矿区', + code: '130804', }, { - "name":"承德县", - "code":"130821" + name: '承德县', + code: '130821', }, { - "name":"兴隆县", - "code":"130822" + name: '兴隆县', + code: '130822', }, { - "name":"平泉县", - "code":"130823" + name: '平泉县', + code: '130823', }, { - "name":"滦平县", - "code":"130824" + name: '滦平县', + code: '130824', }, { - "name":"隆化县", - "code":"130825" + name: '隆化县', + code: '130825', }, { - "name":"丰宁满族自治县", - "code":"130826" + name: '丰宁满族自治县', + code: '130826', }, { - "name":"宽城满族自治县", - "code":"130827" + name: '宽城满族自治县', + code: '130827', }, { - "name":"围场满族蒙古族自治县", - "code":"130828" - } - ] + name: '围场满族蒙古族自治县', + code: '130828', + }, + ], }, { - "name":"沧州市", - "code":"130900", - "sub":[ + name: '沧州市', + code: '130900', + sub: [ { - "name":"市辖区", - "code":"130901" + name: '市辖区', + code: '130901', }, { - "name":"新华区", - "code":"130902" + name: '新华区', + code: '130902', }, { - "name":"运河区", - "code":"130903" + name: '运河区', + code: '130903', }, { - "name":"沧县", - "code":"130921" + name: '沧县', + code: '130921', }, { - "name":"青县", - "code":"130922" + name: '青县', + code: '130922', }, { - "name":"东光县", - "code":"130923" + name: '东光县', + code: '130923', }, { - "name":"海兴县", - "code":"130924" + name: '海兴县', + code: '130924', }, { - "name":"盐山县", - "code":"130925" + name: '盐山县', + code: '130925', }, { - "name":"肃宁县", - "code":"130926" + name: '肃宁县', + code: '130926', }, { - "name":"南皮县", - "code":"130927" + name: '南皮县', + code: '130927', }, { - "name":"吴桥县", - "code":"130928" + name: '吴桥县', + code: '130928', }, { - "name":"献县", - "code":"130929" + name: '献县', + code: '130929', }, { - "name":"孟村回族自治县", - "code":"130930" + name: '孟村回族自治县', + code: '130930', }, { - "name":"泊头市", - "code":"130981" + name: '泊头市', + code: '130981', }, { - "name":"任丘市", - "code":"130982" + name: '任丘市', + code: '130982', }, { - "name":"黄骅市", - "code":"130983" + name: '黄骅市', + code: '130983', }, { - "name":"河间市", - "code":"130984" - } - ] + name: '河间市', + code: '130984', + }, + ], }, { - "name":"廊坊市", - "code":"131000", - "sub":[ + name: '廊坊市', + code: '131000', + sub: [ { - "name":"市辖区", - "code":"131001" + name: '市辖区', + code: '131001', }, { - "name":"安次区", - "code":"131002" + name: '安次区', + code: '131002', }, { - "name":"广阳区", - "code":"131003" + name: '广阳区', + code: '131003', }, { - "name":"固安县", - "code":"131022" + name: '固安县', + code: '131022', }, { - "name":"永清县", - "code":"131023" + name: '永清县', + code: '131023', }, { - "name":"香河县", - "code":"131024" + name: '香河县', + code: '131024', }, { - "name":"大城县", - "code":"131025" + name: '大城县', + code: '131025', }, { - "name":"文安县", - "code":"131026" + name: '文安县', + code: '131026', }, { - "name":"大厂回族自治县", - "code":"131028" + name: '大厂回族自治县', + code: '131028', }, { - "name":"霸州市", - "code":"131081" + name: '霸州市', + code: '131081', }, { - "name":"三河市", - "code":"131082" - } - ] + name: '三河市', + code: '131082', + }, + ], }, { - "name":"衡水市", - "code":"131100", - "sub":[ + name: '衡水市', + code: '131100', + sub: [ { - "name":"市辖区", - "code":"131101" + name: '市辖区', + code: '131101', }, { - "name":"桃城区", - "code":"131102" + name: '桃城区', + code: '131102', }, { - "name":"枣强县", - "code":"131121" + name: '枣强县', + code: '131121', }, { - "name":"武邑县", - "code":"131122" + name: '武邑县', + code: '131122', }, { - "name":"武强县", - "code":"131123" + name: '武强县', + code: '131123', }, { - "name":"饶阳县", - "code":"131124" + name: '饶阳县', + code: '131124', }, { - "name":"安平县", - "code":"131125" + name: '安平县', + code: '131125', }, { - "name":"故城县", - "code":"131126" + name: '故城县', + code: '131126', }, { - "name":"景县", - "code":"131127" + name: '景县', + code: '131127', }, { - "name":"阜城县", - "code":"131128" + name: '阜城县', + code: '131128', }, { - "name":"冀州市", - "code":"131181" + name: '冀州市', + code: '131181', }, { - "name":"深州市", - "code":"131182" - } - ] - } - ] + name: '深州市', + code: '131182', + }, + ], + }, + ], }, { - "name":"山西省", - "code":"140000", - "sub":[ + name: '山西省', + code: '140000', + sub: [ { - "name":"太原市", - "code":"140100", - "sub":[ + name: '太原市', + code: '140100', + sub: [ { - "name":"市辖区", - "code":"140101" + name: '市辖区', + code: '140101', }, { - "name":"小店区", - "code":"140105" + name: '小店区', + code: '140105', }, { - "name":"迎泽区", - "code":"140106" + name: '迎泽区', + code: '140106', }, { - "name":"杏花岭区", - "code":"140107" + name: '杏花岭区', + code: '140107', }, { - "name":"尖草坪区", - "code":"140108" + name: '尖草坪区', + code: '140108', }, { - "name":"万柏林区", - "code":"140109" + name: '万柏林区', + code: '140109', }, { - "name":"晋源区", - "code":"140110" + name: '晋源区', + code: '140110', }, { - "name":"清徐县", - "code":"140121" + name: '清徐县', + code: '140121', }, { - "name":"阳曲县", - "code":"140122" + name: '阳曲县', + code: '140122', }, { - "name":"娄烦县", - "code":"140123" + name: '娄烦县', + code: '140123', }, { - "name":"古交市", - "code":"140181" - } - ] + name: '古交市', + code: '140181', + }, + ], }, { - "name":"大同市", - "code":"140200", - "sub":[ + name: '大同市', + code: '140200', + sub: [ { - "name":"市辖区", - "code":"140201" + name: '市辖区', + code: '140201', }, { - "name":"城区", - "code":"140202" + name: '城区', + code: '140202', }, { - "name":"矿区", - "code":"140203" + name: '矿区', + code: '140203', }, { - "name":"南郊区", - "code":"140211" + name: '南郊区', + code: '140211', }, { - "name":"新荣区", - "code":"140212" + name: '新荣区', + code: '140212', }, { - "name":"阳高县", - "code":"140221" + name: '阳高县', + code: '140221', }, { - "name":"天镇县", - "code":"140222" + name: '天镇县', + code: '140222', }, { - "name":"广灵县", - "code":"140223" + name: '广灵县', + code: '140223', }, { - "name":"灵丘县", - "code":"140224" + name: '灵丘县', + code: '140224', }, { - "name":"浑源县", - "code":"140225" + name: '浑源县', + code: '140225', }, { - "name":"左云县", - "code":"140226" + name: '左云县', + code: '140226', }, { - "name":"大同县", - "code":"140227" - } - ] + name: '大同县', + code: '140227', + }, + ], }, { - "name":"阳泉市", - "code":"140300", - "sub":[ + name: '阳泉市', + code: '140300', + sub: [ { - "name":"市辖区", - "code":"140301" + name: '市辖区', + code: '140301', }, { - "name":"城区", - "code":"140302" + name: '城区', + code: '140302', }, { - "name":"矿区", - "code":"140303" + name: '矿区', + code: '140303', }, { - "name":"郊区", - "code":"140311" + name: '郊区', + code: '140311', }, { - "name":"平定县", - "code":"140321" + name: '平定县', + code: '140321', }, { - "name":"盂县", - "code":"140322" - } - ] + name: '盂县', + code: '140322', + }, + ], }, { - "name":"长治市", - "code":"140400", - "sub":[ + name: '长治市', + code: '140400', + sub: [ { - "name":"市辖区", - "code":"140401" + name: '市辖区', + code: '140401', }, { - "name":"城区", - "code":"140402" + name: '城区', + code: '140402', }, { - "name":"郊区", - "code":"140411" + name: '郊区', + code: '140411', }, { - "name":"长治县", - "code":"140421" + name: '长治县', + code: '140421', }, { - "name":"襄垣县", - "code":"140423" + name: '襄垣县', + code: '140423', }, { - "name":"屯留县", - "code":"140424" + name: '屯留县', + code: '140424', }, { - "name":"平顺县", - "code":"140425" + name: '平顺县', + code: '140425', }, { - "name":"黎城县", - "code":"140426" + name: '黎城县', + code: '140426', }, { - "name":"壶关县", - "code":"140427" + name: '壶关县', + code: '140427', }, { - "name":"长子县", - "code":"140428" + name: '长子县', + code: '140428', }, { - "name":"武乡县", - "code":"140429" + name: '武乡县', + code: '140429', }, { - "name":"沁县", - "code":"140430" + name: '沁县', + code: '140430', }, { - "name":"沁源县", - "code":"140431" + name: '沁源县', + code: '140431', }, { - "name":"潞城市", - "code":"140481" - } - ] + name: '潞城市', + code: '140481', + }, + ], }, { - "name":"晋城市", - "code":"140500", - "sub":[ + name: '晋城市', + code: '140500', + sub: [ { - "name":"市辖区", - "code":"140501" + name: '市辖区', + code: '140501', }, { - "name":"城区", - "code":"140502" + name: '城区', + code: '140502', }, { - "name":"沁水县", - "code":"140521" + name: '沁水县', + code: '140521', }, { - "name":"阳城县", - "code":"140522" + name: '阳城县', + code: '140522', }, { - "name":"陵川县", - "code":"140524" + name: '陵川县', + code: '140524', }, { - "name":"泽州县", - "code":"140525" + name: '泽州县', + code: '140525', }, { - "name":"高平市", - "code":"140581" - } - ] + name: '高平市', + code: '140581', + }, + ], }, { - "name":"朔州市", - "code":"140600", - "sub":[ + name: '朔州市', + code: '140600', + sub: [ { - "name":"市辖区", - "code":"140601" + name: '市辖区', + code: '140601', }, { - "name":"朔城区", - "code":"140602" + name: '朔城区', + code: '140602', }, { - "name":"平鲁区", - "code":"140603" + name: '平鲁区', + code: '140603', }, { - "name":"山阴县", - "code":"140621" + name: '山阴县', + code: '140621', }, { - "name":"应县", - "code":"140622" + name: '应县', + code: '140622', }, { - "name":"右玉县", - "code":"140623" + name: '右玉县', + code: '140623', }, { - "name":"怀仁县", - "code":"140624" - } - ] + name: '怀仁县', + code: '140624', + }, + ], }, { - "name":"晋中市", - "code":"140700", - "sub":[ + name: '晋中市', + code: '140700', + sub: [ { - "name":"市辖区", - "code":"140701" + name: '市辖区', + code: '140701', }, { - "name":"榆次区", - "code":"140702" + name: '榆次区', + code: '140702', }, { - "name":"榆社县", - "code":"140721" + name: '榆社县', + code: '140721', }, { - "name":"左权县", - "code":"140722" + name: '左权县', + code: '140722', }, { - "name":"和顺县", - "code":"140723" + name: '和顺县', + code: '140723', }, { - "name":"昔阳县", - "code":"140724" + name: '昔阳县', + code: '140724', }, { - "name":"寿阳县", - "code":"140725" + name: '寿阳县', + code: '140725', }, { - "name":"太谷县", - "code":"140726" + name: '太谷县', + code: '140726', }, { - "name":"祁县", - "code":"140727" + name: '祁县', + code: '140727', }, { - "name":"平遥县", - "code":"140728" + name: '平遥县', + code: '140728', }, { - "name":"灵石县", - "code":"140729" + name: '灵石县', + code: '140729', }, { - "name":"介休市", - "code":"140781" - } - ] + name: '介休市', + code: '140781', + }, + ], }, { - "name":"运城市", - "code":"140800", - "sub":[ + name: '运城市', + code: '140800', + sub: [ { - "name":"市辖区", - "code":"140801" + name: '市辖区', + code: '140801', }, { - "name":"盐湖区", - "code":"140802" + name: '盐湖区', + code: '140802', }, { - "name":"临猗县", - "code":"140821" + name: '临猗县', + code: '140821', }, { - "name":"万荣县", - "code":"140822" + name: '万荣县', + code: '140822', }, { - "name":"闻喜县", - "code":"140823" + name: '闻喜县', + code: '140823', }, { - "name":"稷山县", - "code":"140824" + name: '稷山县', + code: '140824', }, { - "name":"新绛县", - "code":"140825" + name: '新绛县', + code: '140825', }, { - "name":"绛县", - "code":"140826" + name: '绛县', + code: '140826', }, { - "name":"垣曲县", - "code":"140827" + name: '垣曲县', + code: '140827', }, { - "name":"夏县", - "code":"140828" + name: '夏县', + code: '140828', }, { - "name":"平陆县", - "code":"140829" + name: '平陆县', + code: '140829', }, { - "name":"芮城县", - "code":"140830" + name: '芮城县', + code: '140830', }, { - "name":"永济市", - "code":"140881" + name: '永济市', + code: '140881', }, { - "name":"河津市", - "code":"140882" - } - ] + name: '河津市', + code: '140882', + }, + ], }, { - "name":"忻州市", - "code":"140900", - "sub":[ + name: '忻州市', + code: '140900', + sub: [ { - "name":"市辖区", - "code":"140901" + name: '市辖区', + code: '140901', }, { - "name":"忻府区", - "code":"140902" + name: '忻府区', + code: '140902', }, { - "name":"定襄县", - "code":"140921" + name: '定襄县', + code: '140921', }, { - "name":"五台县", - "code":"140922" + name: '五台县', + code: '140922', }, { - "name":"代县", - "code":"140923" + name: '代县', + code: '140923', }, { - "name":"繁峙县", - "code":"140924" + name: '繁峙县', + code: '140924', }, { - "name":"宁武县", - "code":"140925" + name: '宁武县', + code: '140925', }, { - "name":"静乐县", - "code":"140926" + name: '静乐县', + code: '140926', }, { - "name":"神池县", - "code":"140927" + name: '神池县', + code: '140927', }, { - "name":"五寨县", - "code":"140928" + name: '五寨县', + code: '140928', }, { - "name":"岢岚县", - "code":"140929" + name: '岢岚县', + code: '140929', }, { - "name":"河曲县", - "code":"140930" + name: '河曲县', + code: '140930', }, { - "name":"保德县", - "code":"140931" + name: '保德县', + code: '140931', }, { - "name":"偏关县", - "code":"140932" + name: '偏关县', + code: '140932', }, { - "name":"原平市", - "code":"140981" - } - ] + name: '原平市', + code: '140981', + }, + ], }, { - "name":"临汾市", - "code":"141000", - "sub":[ + name: '临汾市', + code: '141000', + sub: [ { - "name":"市辖区", - "code":"141001" + name: '市辖区', + code: '141001', }, { - "name":"尧都区", - "code":"141002" + name: '尧都区', + code: '141002', }, { - "name":"曲沃县", - "code":"141021" + name: '曲沃县', + code: '141021', }, { - "name":"翼城县", - "code":"141022" + name: '翼城县', + code: '141022', }, { - "name":"襄汾县", - "code":"141023" + name: '襄汾县', + code: '141023', }, { - "name":"洪洞县", - "code":"141024" + name: '洪洞县', + code: '141024', }, { - "name":"古县", - "code":"141025" + name: '古县', + code: '141025', }, { - "name":"安泽县", - "code":"141026" + name: '安泽县', + code: '141026', }, { - "name":"浮山县", - "code":"141027" + name: '浮山县', + code: '141027', }, { - "name":"吉县", - "code":"141028" + name: '吉县', + code: '141028', }, { - "name":"乡宁县", - "code":"141029" + name: '乡宁县', + code: '141029', }, { - "name":"大宁县", - "code":"141030" + name: '大宁县', + code: '141030', }, { - "name":"隰县", - "code":"141031" + name: '隰县', + code: '141031', }, { - "name":"永和县", - "code":"141032" + name: '永和县', + code: '141032', }, { - "name":"蒲县", - "code":"141033" + name: '蒲县', + code: '141033', }, { - "name":"汾西县", - "code":"141034" + name: '汾西县', + code: '141034', }, { - "name":"侯马市", - "code":"141081" + name: '侯马市', + code: '141081', }, { - "name":"霍州市", - "code":"141082" - } - ] + name: '霍州市', + code: '141082', + }, + ], }, { - "name":"吕梁市", - "code":"141100", - "sub":[ + name: '吕梁市', + code: '141100', + sub: [ { - "name":"市辖区", - "code":"141101" + name: '市辖区', + code: '141101', }, { - "name":"离石区", - "code":"141102" + name: '离石区', + code: '141102', }, { - "name":"文水县", - "code":"141121" + name: '文水县', + code: '141121', }, { - "name":"交城县", - "code":"141122" + name: '交城县', + code: '141122', }, { - "name":"兴县", - "code":"141123" + name: '兴县', + code: '141123', }, { - "name":"临县", - "code":"141124" + name: '临县', + code: '141124', }, { - "name":"柳林县", - "code":"141125" + name: '柳林县', + code: '141125', }, { - "name":"石楼县", - "code":"141126" + name: '石楼县', + code: '141126', }, { - "name":"岚县", - "code":"141127" + name: '岚县', + code: '141127', }, { - "name":"方山县", - "code":"141128" + name: '方山县', + code: '141128', }, { - "name":"中阳县", - "code":"141129" + name: '中阳县', + code: '141129', }, { - "name":"交口县", - "code":"141130" + name: '交口县', + code: '141130', }, { - "name":"孝义市", - "code":"141181" + name: '孝义市', + code: '141181', }, { - "name":"汾阳市", - "code":"141182" - } - ] - } - ] + name: '汾阳市', + code: '141182', + }, + ], + }, + ], }, { - "name":"内蒙古自治区", - "code":"150000", - "sub":[ + name: '内蒙古自治区', + code: '150000', + sub: [ { - "name":"呼和浩特市", - "code":"150100", - "sub":[ + name: '呼和浩特市', + code: '150100', + sub: [ { - "name":"市辖区", - "code":"150101" + name: '市辖区', + code: '150101', }, { - "name":"新城区", - "code":"150102" + name: '新城区', + code: '150102', }, { - "name":"回民区", - "code":"150103" + name: '回民区', + code: '150103', }, { - "name":"玉泉区", - "code":"150104" + name: '玉泉区', + code: '150104', }, { - "name":"赛罕区", - "code":"150105" + name: '赛罕区', + code: '150105', }, { - "name":"土默特左旗", - "code":"150121" + name: '土默特左旗', + code: '150121', }, { - "name":"托克托县", - "code":"150122" + name: '托克托县', + code: '150122', }, { - "name":"和林格尔县", - "code":"150123" + name: '和林格尔县', + code: '150123', }, { - "name":"清水河县", - "code":"150124" + name: '清水河县', + code: '150124', }, { - "name":"武川县", - "code":"150125" - } - ] + name: '武川县', + code: '150125', + }, + ], }, { - "name":"包头市", - "code":"150200", - "sub":[ + name: '包头市', + code: '150200', + sub: [ { - "name":"市辖区", - "code":"150201" + name: '市辖区', + code: '150201', }, { - "name":"东河区", - "code":"150202" + name: '东河区', + code: '150202', }, { - "name":"昆都仑区", - "code":"150203" + name: '昆都仑区', + code: '150203', }, { - "name":"青山区", - "code":"150204" + name: '青山区', + code: '150204', }, { - "name":"石拐区", - "code":"150205" + name: '石拐区', + code: '150205', }, { - "name":"白云鄂博矿区", - "code":"150206" + name: '白云鄂博矿区', + code: '150206', }, { - "name":"九原区", - "code":"150207" + name: '九原区', + code: '150207', }, { - "name":"土默特右旗", - "code":"150221" + name: '土默特右旗', + code: '150221', }, { - "name":"固阳县", - "code":"150222" + name: '固阳县', + code: '150222', }, { - "name":"达尔罕茂明安联合旗", - "code":"150223" - } - ] + name: '达尔罕茂明安联合旗', + code: '150223', + }, + ], }, { - "name":"乌海市", - "code":"150300", - "sub":[ + name: '乌海市', + code: '150300', + sub: [ { - "name":"市辖区", - "code":"150301" + name: '市辖区', + code: '150301', }, { - "name":"海勃湾区", - "code":"150302" + name: '海勃湾区', + code: '150302', }, { - "name":"海南区", - "code":"150303" + name: '海南区', + code: '150303', }, { - "name":"乌达区", - "code":"150304" - } - ] + name: '乌达区', + code: '150304', + }, + ], }, { - "name":"赤峰市", - "code":"150400", - "sub":[ + name: '赤峰市', + code: '150400', + sub: [ { - "name":"市辖区", - "code":"150401" + name: '市辖区', + code: '150401', }, { - "name":"红山区", - "code":"150402" + name: '红山区', + code: '150402', }, { - "name":"元宝山区", - "code":"150403" + name: '元宝山区', + code: '150403', }, { - "name":"松山区", - "code":"150404" + name: '松山区', + code: '150404', }, { - "name":"阿鲁科尔沁旗", - "code":"150421" + name: '阿鲁科尔沁旗', + code: '150421', }, { - "name":"巴林左旗", - "code":"150422" + name: '巴林左旗', + code: '150422', }, { - "name":"巴林右旗", - "code":"150423" + name: '巴林右旗', + code: '150423', }, { - "name":"林西县", - "code":"150424" + name: '林西县', + code: '150424', }, { - "name":"克什克腾旗", - "code":"150425" + name: '克什克腾旗', + code: '150425', }, { - "name":"翁牛特旗", - "code":"150426" + name: '翁牛特旗', + code: '150426', }, { - "name":"喀喇沁旗", - "code":"150428" + name: '喀喇沁旗', + code: '150428', }, { - "name":"宁城县", - "code":"150429" + name: '宁城县', + code: '150429', }, { - "name":"敖汉旗", - "code":"150430" - } - ] + name: '敖汉旗', + code: '150430', + }, + ], }, { - "name":"通辽市", - "code":"150500", - "sub":[ + name: '通辽市', + code: '150500', + sub: [ { - "name":"市辖区", - "code":"150501" + name: '市辖区', + code: '150501', }, { - "name":"科尔沁区", - "code":"150502" + name: '科尔沁区', + code: '150502', }, { - "name":"科尔沁左翼中旗", - "code":"150521" + name: '科尔沁左翼中旗', + code: '150521', }, { - "name":"科尔沁左翼后旗", - "code":"150522" + name: '科尔沁左翼后旗', + code: '150522', }, { - "name":"开鲁县", - "code":"150523" + name: '开鲁县', + code: '150523', }, { - "name":"库伦旗", - "code":"150524" + name: '库伦旗', + code: '150524', }, { - "name":"奈曼旗", - "code":"150525" + name: '奈曼旗', + code: '150525', }, { - "name":"扎鲁特旗", - "code":"150526" + name: '扎鲁特旗', + code: '150526', }, { - "name":"霍林郭勒市", - "code":"150581" - } - ] + name: '霍林郭勒市', + code: '150581', + }, + ], }, { - "name":"鄂尔多斯市", - "code":"150600", - "sub":[ + name: '鄂尔多斯市', + code: '150600', + sub: [ { - "name":"市辖区", - "code":"150601" + name: '市辖区', + code: '150601', }, { - "name":"东胜区", - "code":"150602" + name: '东胜区', + code: '150602', }, { - "name":"达拉特旗", - "code":"150621" + name: '达拉特旗', + code: '150621', }, { - "name":"准格尔旗", - "code":"150622" + name: '准格尔旗', + code: '150622', }, { - "name":"鄂托克前旗", - "code":"150623" + name: '鄂托克前旗', + code: '150623', }, { - "name":"鄂托克旗", - "code":"150624" + name: '鄂托克旗', + code: '150624', }, { - "name":"杭锦旗", - "code":"150625" + name: '杭锦旗', + code: '150625', }, { - "name":"乌审旗", - "code":"150626" + name: '乌审旗', + code: '150626', }, { - "name":"伊金霍洛旗", - "code":"150627" - } - ] + name: '伊金霍洛旗', + code: '150627', + }, + ], }, { - "name":"呼伦贝尔市", - "code":"150700", - "sub":[ + name: '呼伦贝尔市', + code: '150700', + sub: [ { - "name":"市辖区", - "code":"150701" + name: '市辖区', + code: '150701', }, { - "name":"海拉尔区", - "code":"150702" + name: '海拉尔区', + code: '150702', }, { - "name":"扎赉诺尔区", - "code":"150703" + name: '扎赉诺尔区', + code: '150703', }, { - "name":"阿荣旗", - "code":"150721" + name: '阿荣旗', + code: '150721', }, { - "name":"莫力达瓦达斡尔族自治旗", - "code":"150722" + name: '莫力达瓦达斡尔族自治旗', + code: '150722', }, { - "name":"鄂伦春自治旗", - "code":"150723" + name: '鄂伦春自治旗', + code: '150723', }, { - "name":"鄂温克族自治旗", - "code":"150724" + name: '鄂温克族自治旗', + code: '150724', }, { - "name":"陈巴尔虎旗", - "code":"150725" + name: '陈巴尔虎旗', + code: '150725', }, { - "name":"新巴尔虎左旗", - "code":"150726" + name: '新巴尔虎左旗', + code: '150726', }, { - "name":"新巴尔虎右旗", - "code":"150727" + name: '新巴尔虎右旗', + code: '150727', }, { - "name":"满洲里市", - "code":"150781" + name: '满洲里市', + code: '150781', }, { - "name":"牙克石市", - "code":"150782" + name: '牙克石市', + code: '150782', }, { - "name":"扎兰屯市", - "code":"150783" + name: '扎兰屯市', + code: '150783', }, { - "name":"额尔古纳市", - "code":"150784" + name: '额尔古纳市', + code: '150784', }, { - "name":"根河市", - "code":"150785" - } - ] + name: '根河市', + code: '150785', + }, + ], }, { - "name":"巴彦淖尔市", - "code":"150800", - "sub":[ + name: '巴彦淖尔市', + code: '150800', + sub: [ { - "name":"市辖区", - "code":"150801" + name: '市辖区', + code: '150801', }, { - "name":"临河区", - "code":"150802" + name: '临河区', + code: '150802', }, { - "name":"五原县", - "code":"150821" + name: '五原县', + code: '150821', }, { - "name":"磴口县", - "code":"150822" + name: '磴口县', + code: '150822', }, { - "name":"乌拉特前旗", - "code":"150823" + name: '乌拉特前旗', + code: '150823', }, { - "name":"乌拉特中旗", - "code":"150824" + name: '乌拉特中旗', + code: '150824', }, { - "name":"乌拉特后旗", - "code":"150825" + name: '乌拉特后旗', + code: '150825', }, { - "name":"杭锦后旗", - "code":"150826" - } - ] + name: '杭锦后旗', + code: '150826', + }, + ], }, { - "name":"乌兰察布市", - "code":"150900", - "sub":[ + name: '乌兰察布市', + code: '150900', + sub: [ { - "name":"市辖区", - "code":"150901" + name: '市辖区', + code: '150901', }, { - "name":"集宁区", - "code":"150902" + name: '集宁区', + code: '150902', }, { - "name":"卓资县", - "code":"150921" + name: '卓资县', + code: '150921', }, { - "name":"化德县", - "code":"150922" + name: '化德县', + code: '150922', }, { - "name":"商都县", - "code":"150923" + name: '商都县', + code: '150923', }, { - "name":"兴和县", - "code":"150924" + name: '兴和县', + code: '150924', }, { - "name":"凉城县", - "code":"150925" + name: '凉城县', + code: '150925', }, { - "name":"察哈尔右翼前旗", - "code":"150926" + name: '察哈尔右翼前旗', + code: '150926', }, { - "name":"察哈尔右翼中旗", - "code":"150927" + name: '察哈尔右翼中旗', + code: '150927', }, { - "name":"察哈尔右翼后旗", - "code":"150928" + name: '察哈尔右翼后旗', + code: '150928', }, { - "name":"四子王旗", - "code":"150929" + name: '四子王旗', + code: '150929', }, { - "name":"丰镇市", - "code":"150981" - } - ] + name: '丰镇市', + code: '150981', + }, + ], }, { - "name":"兴安盟", - "code":"152200", - "sub":[ + name: '兴安盟', + code: '152200', + sub: [ { - "name":"乌兰浩特市", - "code":"152201" + name: '乌兰浩特市', + code: '152201', }, { - "name":"阿尔山市", - "code":"152202" + name: '阿尔山市', + code: '152202', }, { - "name":"科尔沁右翼前旗", - "code":"152221" + name: '科尔沁右翼前旗', + code: '152221', }, { - "name":"科尔沁右翼中旗", - "code":"152222" + name: '科尔沁右翼中旗', + code: '152222', }, { - "name":"扎赉特旗", - "code":"152223" + name: '扎赉特旗', + code: '152223', }, { - "name":"突泉县", - "code":"152224" - } - ] + name: '突泉县', + code: '152224', + }, + ], }, { - "name":"锡林郭勒盟", - "code":"152500", - "sub":[ + name: '锡林郭勒盟', + code: '152500', + sub: [ { - "name":"二连浩特市", - "code":"152501" + name: '二连浩特市', + code: '152501', }, { - "name":"锡林浩特市", - "code":"152502" + name: '锡林浩特市', + code: '152502', }, { - "name":"阿巴嘎旗", - "code":"152522" + name: '阿巴嘎旗', + code: '152522', }, { - "name":"苏尼特左旗", - "code":"152523" + name: '苏尼特左旗', + code: '152523', }, { - "name":"苏尼特右旗", - "code":"152524" + name: '苏尼特右旗', + code: '152524', }, { - "name":"东乌珠穆沁旗", - "code":"152525" + name: '东乌珠穆沁旗', + code: '152525', }, { - "name":"西乌珠穆沁旗", - "code":"152526" + name: '西乌珠穆沁旗', + code: '152526', }, { - "name":"太仆寺旗", - "code":"152527" + name: '太仆寺旗', + code: '152527', }, { - "name":"镶黄旗", - "code":"152528" + name: '镶黄旗', + code: '152528', }, { - "name":"正镶白旗", - "code":"152529" + name: '正镶白旗', + code: '152529', }, { - "name":"正蓝旗", - "code":"152530" + name: '正蓝旗', + code: '152530', }, { - "name":"多伦县", - "code":"152531" - } - ] + name: '多伦县', + code: '152531', + }, + ], }, { - "name":"阿拉善盟", - "code":"152900", - "sub":[ + name: '阿拉善盟', + code: '152900', + sub: [ { - "name":"阿拉善左旗", - "code":"152921" + name: '阿拉善左旗', + code: '152921', }, { - "name":"阿拉善右旗", - "code":"152922" + name: '阿拉善右旗', + code: '152922', }, { - "name":"额济纳旗", - "code":"152923" - } - ] - } - ] + name: '额济纳旗', + code: '152923', + }, + ], + }, + ], }, { - "name":"辽宁省", - "code":"210000", - "sub":[ + name: '辽宁省', + code: '210000', + sub: [ { - "name":"沈阳市", - "code":"210100", - "sub":[ + name: '沈阳市', + code: '210100', + sub: [ { - "name":"市辖区", - "code":"210101" + name: '市辖区', + code: '210101', }, { - "name":"和平区", - "code":"210102" + name: '和平区', + code: '210102', }, { - "name":"沈河区", - "code":"210103" + name: '沈河区', + code: '210103', }, { - "name":"大东区", - "code":"210104" + name: '大东区', + code: '210104', }, { - "name":"皇姑区", - "code":"210105" + name: '皇姑区', + code: '210105', }, { - "name":"铁西区", - "code":"210106" + name: '铁西区', + code: '210106', }, { - "name":"苏家屯区", - "code":"210111" + name: '苏家屯区', + code: '210111', }, { - "name":"浑南区", - "code":"210112" + name: '浑南区', + code: '210112', }, { - "name":"沈北新区", - "code":"210113" + name: '沈北新区', + code: '210113', }, { - "name":"于洪区", - "code":"210114" + name: '于洪区', + code: '210114', }, { - "name":"辽中县", - "code":"210122" + name: '辽中县', + code: '210122', }, { - "name":"康平县", - "code":"210123" + name: '康平县', + code: '210123', }, { - "name":"法库县", - "code":"210124" + name: '法库县', + code: '210124', }, { - "name":"新民市", - "code":"210181" - } - ] + name: '新民市', + code: '210181', + }, + ], }, { - "name":"大连市", - "code":"210200", - "sub":[ + name: '大连市', + code: '210200', + sub: [ { - "name":"市辖区", - "code":"210201" + name: '市辖区', + code: '210201', }, { - "name":"中山区", - "code":"210202" + name: '中山区', + code: '210202', }, { - "name":"西岗区", - "code":"210203" + name: '西岗区', + code: '210203', }, { - "name":"沙河口区", - "code":"210204" + name: '沙河口区', + code: '210204', }, { - "name":"甘井子区", - "code":"210211" + name: '甘井子区', + code: '210211', }, { - "name":"旅顺口区", - "code":"210212" + name: '旅顺口区', + code: '210212', }, { - "name":"金州区", - "code":"210213" + name: '金州区', + code: '210213', }, { - "name":"长海县", - "code":"210224" + name: '长海县', + code: '210224', }, { - "name":"瓦房店市", - "code":"210281" + name: '瓦房店市', + code: '210281', }, { - "name":"普兰店市", - "code":"210282" + name: '普兰店市', + code: '210282', }, { - "name":"庄河市", - "code":"210283" - } - ] + name: '庄河市', + code: '210283', + }, + ], }, { - "name":"鞍山市", - "code":"210300", - "sub":[ + name: '鞍山市', + code: '210300', + sub: [ { - "name":"市辖区", - "code":"210301" + name: '市辖区', + code: '210301', }, { - "name":"铁东区", - "code":"210302" + name: '铁东区', + code: '210302', }, { - "name":"铁西区", - "code":"210303" + name: '铁西区', + code: '210303', }, { - "name":"立山区", - "code":"210304" + name: '立山区', + code: '210304', }, { - "name":"千山区", - "code":"210311" + name: '千山区', + code: '210311', }, { - "name":"台安县", - "code":"210321" + name: '台安县', + code: '210321', }, { - "name":"岫岩满族自治县", - "code":"210323" + name: '岫岩满族自治县', + code: '210323', }, { - "name":"海城市", - "code":"210381" - } - ] + name: '海城市', + code: '210381', + }, + ], }, { - "name":"抚顺市", - "code":"210400", - "sub":[ + name: '抚顺市', + code: '210400', + sub: [ { - "name":"市辖区", - "code":"210401" + name: '市辖区', + code: '210401', }, { - "name":"新抚区", - "code":"210402" + name: '新抚区', + code: '210402', }, { - "name":"东洲区", - "code":"210403" + name: '东洲区', + code: '210403', }, { - "name":"望花区", - "code":"210404" + name: '望花区', + code: '210404', }, { - "name":"顺城区", - "code":"210411" + name: '顺城区', + code: '210411', }, { - "name":"抚顺县", - "code":"210421" + name: '抚顺县', + code: '210421', }, { - "name":"新宾满族自治县", - "code":"210422" + name: '新宾满族自治县', + code: '210422', }, { - "name":"清原满族自治县", - "code":"210423" - } - ] + name: '清原满族自治县', + code: '210423', + }, + ], }, { - "name":"本溪市", - "code":"210500", - "sub":[ + name: '本溪市', + code: '210500', + sub: [ { - "name":"市辖区", - "code":"210501" + name: '市辖区', + code: '210501', }, { - "name":"平山区", - "code":"210502" + name: '平山区', + code: '210502', }, { - "name":"溪湖区", - "code":"210503" + name: '溪湖区', + code: '210503', }, { - "name":"明山区", - "code":"210504" + name: '明山区', + code: '210504', }, { - "name":"南芬区", - "code":"210505" + name: '南芬区', + code: '210505', }, { - "name":"本溪满族自治县", - "code":"210521" + name: '本溪满族自治县', + code: '210521', }, { - "name":"桓仁满族自治县", - "code":"210522" - } - ] + name: '桓仁满族自治县', + code: '210522', + }, + ], }, { - "name":"丹东市", - "code":"210600", - "sub":[ + name: '丹东市', + code: '210600', + sub: [ { - "name":"市辖区", - "code":"210601" + name: '市辖区', + code: '210601', }, { - "name":"元宝区", - "code":"210602" + name: '元宝区', + code: '210602', }, { - "name":"振兴区", - "code":"210603" + name: '振兴区', + code: '210603', }, { - "name":"振安区", - "code":"210604" + name: '振安区', + code: '210604', }, { - "name":"宽甸满族自治县", - "code":"210624" + name: '宽甸满族自治县', + code: '210624', }, { - "name":"东港市", - "code":"210681" + name: '东港市', + code: '210681', }, { - "name":"凤城市", - "code":"210682" - } - ] + name: '凤城市', + code: '210682', + }, + ], }, { - "name":"锦州市", - "code":"210700", - "sub":[ + name: '锦州市', + code: '210700', + sub: [ { - "name":"市辖区", - "code":"210701" + name: '市辖区', + code: '210701', }, { - "name":"古塔区", - "code":"210702" + name: '古塔区', + code: '210702', }, { - "name":"凌河区", - "code":"210703" + name: '凌河区', + code: '210703', }, { - "name":"太和区", - "code":"210711" + name: '太和区', + code: '210711', }, { - "name":"黑山县", - "code":"210726" + name: '黑山县', + code: '210726', }, { - "name":"义县", - "code":"210727" + name: '义县', + code: '210727', }, { - "name":"凌海市", - "code":"210781" + name: '凌海市', + code: '210781', }, { - "name":"北镇市", - "code":"210782" - } - ] + name: '北镇市', + code: '210782', + }, + ], }, { - "name":"营口市", - "code":"210800", - "sub":[ + name: '营口市', + code: '210800', + sub: [ { - "name":"市辖区", - "code":"210801" + name: '市辖区', + code: '210801', }, { - "name":"站前区", - "code":"210802" + name: '站前区', + code: '210802', }, { - "name":"西市区", - "code":"210803" + name: '西市区', + code: '210803', }, { - "name":"鲅鱼圈区", - "code":"210804" + name: '鲅鱼圈区', + code: '210804', }, { - "name":"老边区", - "code":"210811" + name: '老边区', + code: '210811', }, { - "name":"盖州市", - "code":"210881" + name: '盖州市', + code: '210881', }, { - "name":"大石桥市", - "code":"210882" - } - ] + name: '大石桥市', + code: '210882', + }, + ], }, { - "name":"阜新市", - "code":"210900", - "sub":[ + name: '阜新市', + code: '210900', + sub: [ { - "name":"市辖区", - "code":"210901" + name: '市辖区', + code: '210901', }, { - "name":"海州区", - "code":"210902" + name: '海州区', + code: '210902', }, { - "name":"新邱区", - "code":"210903" + name: '新邱区', + code: '210903', }, { - "name":"太平区", - "code":"210904" + name: '太平区', + code: '210904', }, { - "name":"清河门区", - "code":"210905" + name: '清河门区', + code: '210905', }, { - "name":"细河区", - "code":"210911" + name: '细河区', + code: '210911', }, { - "name":"阜新蒙古族自治县", - "code":"210921" + name: '阜新蒙古族自治县', + code: '210921', }, { - "name":"彰武县", - "code":"210922" - } - ] + name: '彰武县', + code: '210922', + }, + ], }, { - "name":"辽阳市", - "code":"211000", - "sub":[ + name: '辽阳市', + code: '211000', + sub: [ { - "name":"市辖区", - "code":"211001" + name: '市辖区', + code: '211001', }, { - "name":"白塔区", - "code":"211002" + name: '白塔区', + code: '211002', }, { - "name":"文圣区", - "code":"211003" + name: '文圣区', + code: '211003', }, { - "name":"宏伟区", - "code":"211004" + name: '宏伟区', + code: '211004', }, { - "name":"弓长岭区", - "code":"211005" + name: '弓长岭区', + code: '211005', }, { - "name":"太子河区", - "code":"211011" + name: '太子河区', + code: '211011', }, { - "name":"辽阳县", - "code":"211021" + name: '辽阳县', + code: '211021', }, { - "name":"灯塔市", - "code":"211081" - } - ] + name: '灯塔市', + code: '211081', + }, + ], }, { - "name":"盘锦市", - "code":"211100", - "sub":[ + name: '盘锦市', + code: '211100', + sub: [ { - "name":"市辖区", - "code":"211101" + name: '市辖区', + code: '211101', }, { - "name":"双台子区", - "code":"211102" + name: '双台子区', + code: '211102', }, { - "name":"兴隆台区", - "code":"211103" + name: '兴隆台区', + code: '211103', }, { - "name":"大洼县", - "code":"211121" + name: '大洼县', + code: '211121', }, { - "name":"盘山县", - "code":"211122" - } - ] + name: '盘山县', + code: '211122', + }, + ], }, { - "name":"铁岭市", - "code":"211200", - "sub":[ + name: '铁岭市', + code: '211200', + sub: [ { - "name":"市辖区", - "code":"211201" + name: '市辖区', + code: '211201', }, { - "name":"银州区", - "code":"211202" + name: '银州区', + code: '211202', }, { - "name":"清河区", - "code":"211204" + name: '清河区', + code: '211204', }, { - "name":"铁岭县", - "code":"211221" + name: '铁岭县', + code: '211221', }, { - "name":"西丰县", - "code":"211223" + name: '西丰县', + code: '211223', }, { - "name":"昌图县", - "code":"211224" + name: '昌图县', + code: '211224', }, { - "name":"调兵山市", - "code":"211281" + name: '调兵山市', + code: '211281', }, { - "name":"开原市", - "code":"211282" - } - ] + name: '开原市', + code: '211282', + }, + ], }, { - "name":"朝阳市", - "code":"211300", - "sub":[ + name: '朝阳市', + code: '211300', + sub: [ { - "name":"市辖区", - "code":"211301" + name: '市辖区', + code: '211301', }, { - "name":"双塔区", - "code":"211302" + name: '双塔区', + code: '211302', }, { - "name":"龙城区", - "code":"211303" + name: '龙城区', + code: '211303', }, { - "name":"朝阳县", - "code":"211321" + name: '朝阳县', + code: '211321', }, { - "name":"建平县", - "code":"211322" + name: '建平县', + code: '211322', }, { - "name":"喀喇沁左翼蒙古族自治县", - "code":"211324" + name: '喀喇沁左翼蒙古族自治县', + code: '211324', }, { - "name":"北票市", - "code":"211381" + name: '北票市', + code: '211381', }, { - "name":"凌源市", - "code":"211382" - } - ] + name: '凌源市', + code: '211382', + }, + ], }, { - "name":"葫芦岛市", - "code":"211400", - "sub":[ + name: '葫芦岛市', + code: '211400', + sub: [ { - "name":"市辖区", - "code":"211401" + name: '市辖区', + code: '211401', }, { - "name":"连山区", - "code":"211402" + name: '连山区', + code: '211402', }, { - "name":"龙港区", - "code":"211403" + name: '龙港区', + code: '211403', }, { - "name":"南票区", - "code":"211404" + name: '南票区', + code: '211404', }, { - "name":"绥中县", - "code":"211421" + name: '绥中县', + code: '211421', }, { - "name":"建昌县", - "code":"211422" + name: '建昌县', + code: '211422', }, { - "name":"兴城市", - "code":"211481" - } - ] - } - ] + name: '兴城市', + code: '211481', + }, + ], + }, + ], }, { - "name":"吉林省", - "code":"220000", - "sub":[ + name: '吉林省', + code: '220000', + sub: [ { - "name":"长春市", - "code":"220100", - "sub":[ + name: '长春市', + code: '220100', + sub: [ { - "name":"市辖区", - "code":"220101" + name: '市辖区', + code: '220101', }, { - "name":"南关区", - "code":"220102" + name: '南关区', + code: '220102', }, { - "name":"宽城区", - "code":"220103" + name: '宽城区', + code: '220103', }, { - "name":"朝阳区", - "code":"220104" + name: '朝阳区', + code: '220104', }, { - "name":"二道区", - "code":"220105" + name: '二道区', + code: '220105', }, { - "name":"绿园区", - "code":"220106" + name: '绿园区', + code: '220106', }, { - "name":"双阳区", - "code":"220112" + name: '双阳区', + code: '220112', }, { - "name":"九台区", - "code":"220113" + name: '九台区', + code: '220113', }, { - "name":"农安县", - "code":"220122" + name: '农安县', + code: '220122', }, { - "name":"榆树市", - "code":"220182" + name: '榆树市', + code: '220182', }, { - "name":"德惠市", - "code":"220183" - } - ] + name: '德惠市', + code: '220183', + }, + ], }, { - "name":"吉林市", - "code":"220200", - "sub":[ + name: '吉林市', + code: '220200', + sub: [ { - "name":"市辖区", - "code":"220201" + name: '市辖区', + code: '220201', }, { - "name":"昌邑区", - "code":"220202" + name: '昌邑区', + code: '220202', }, { - "name":"龙潭区", - "code":"220203" + name: '龙潭区', + code: '220203', }, { - "name":"船营区", - "code":"220204" + name: '船营区', + code: '220204', }, { - "name":"丰满区", - "code":"220211" + name: '丰满区', + code: '220211', }, { - "name":"永吉县", - "code":"220221" + name: '永吉县', + code: '220221', }, { - "name":"蛟河市", - "code":"220281" + name: '蛟河市', + code: '220281', }, { - "name":"桦甸市", - "code":"220282" + name: '桦甸市', + code: '220282', }, { - "name":"舒兰市", - "code":"220283" + name: '舒兰市', + code: '220283', }, { - "name":"磐石市", - "code":"220284" - } - ] + name: '磐石市', + code: '220284', + }, + ], }, { - "name":"四平市", - "code":"220300", - "sub":[ + name: '四平市', + code: '220300', + sub: [ { - "name":"市辖区", - "code":"220301" + name: '市辖区', + code: '220301', }, { - "name":"铁西区", - "code":"220302" + name: '铁西区', + code: '220302', }, { - "name":"铁东区", - "code":"220303" + name: '铁东区', + code: '220303', }, { - "name":"梨树县", - "code":"220322" + name: '梨树县', + code: '220322', }, { - "name":"伊通满族自治县", - "code":"220323" + name: '伊通满族自治县', + code: '220323', }, { - "name":"公主岭市", - "code":"220381" + name: '公主岭市', + code: '220381', }, { - "name":"双辽市", - "code":"220382" - } - ] + name: '双辽市', + code: '220382', + }, + ], }, { - "name":"辽源市", - "code":"220400", - "sub":[ + name: '辽源市', + code: '220400', + sub: [ { - "name":"市辖区", - "code":"220401" + name: '市辖区', + code: '220401', }, { - "name":"龙山区", - "code":"220402" + name: '龙山区', + code: '220402', }, { - "name":"西安区", - "code":"220403" + name: '西安区', + code: '220403', }, { - "name":"东丰县", - "code":"220421" + name: '东丰县', + code: '220421', }, { - "name":"东辽县", - "code":"220422" - } - ] + name: '东辽县', + code: '220422', + }, + ], }, { - "name":"通化市", - "code":"220500", - "sub":[ + name: '通化市', + code: '220500', + sub: [ { - "name":"市辖区", - "code":"220501" + name: '市辖区', + code: '220501', }, { - "name":"东昌区", - "code":"220502" + name: '东昌区', + code: '220502', }, { - "name":"二道江区", - "code":"220503" + name: '二道江区', + code: '220503', }, { - "name":"通化县", - "code":"220521" + name: '通化县', + code: '220521', }, { - "name":"辉南县", - "code":"220523" + name: '辉南县', + code: '220523', }, { - "name":"柳河县", - "code":"220524" + name: '柳河县', + code: '220524', }, { - "name":"梅河口市", - "code":"220581" + name: '梅河口市', + code: '220581', }, { - "name":"集安市", - "code":"220582" - } - ] + name: '集安市', + code: '220582', + }, + ], }, { - "name":"白山市", - "code":"220600", - "sub":[ + name: '白山市', + code: '220600', + sub: [ { - "name":"市辖区", - "code":"220601" + name: '市辖区', + code: '220601', }, { - "name":"浑江区", - "code":"220602" + name: '浑江区', + code: '220602', }, { - "name":"江源区", - "code":"220605" + name: '江源区', + code: '220605', }, { - "name":"抚松县", - "code":"220621" + name: '抚松县', + code: '220621', }, { - "name":"靖宇县", - "code":"220622" + name: '靖宇县', + code: '220622', }, { - "name":"长白朝鲜族自治县", - "code":"220623" + name: '长白朝鲜族自治县', + code: '220623', }, { - "name":"临江市", - "code":"220681" - } - ] + name: '临江市', + code: '220681', + }, + ], }, { - "name":"松原市", - "code":"220700", - "sub":[ + name: '松原市', + code: '220700', + sub: [ { - "name":"市辖区", - "code":"220701" + name: '市辖区', + code: '220701', }, { - "name":"宁江区", - "code":"220702" + name: '宁江区', + code: '220702', }, { - "name":"前郭尔罗斯蒙古族自治县", - "code":"220721" + name: '前郭尔罗斯蒙古族自治县', + code: '220721', }, { - "name":"长岭县", - "code":"220722" + name: '长岭县', + code: '220722', }, { - "name":"乾安县", - "code":"220723" + name: '乾安县', + code: '220723', }, { - "name":"扶余市", - "code":"220781" - } - ] + name: '扶余市', + code: '220781', + }, + ], }, { - "name":"白城市", - "code":"220800", - "sub":[ + name: '白城市', + code: '220800', + sub: [ { - "name":"市辖区", - "code":"220801" + name: '市辖区', + code: '220801', }, { - "name":"洮北区", - "code":"220802" + name: '洮北区', + code: '220802', }, { - "name":"镇赉县", - "code":"220821" + name: '镇赉县', + code: '220821', }, { - "name":"通榆县", - "code":"220822" + name: '通榆县', + code: '220822', }, { - "name":"洮南市", - "code":"220881" + name: '洮南市', + code: '220881', }, { - "name":"大安市", - "code":"220882" - } - ] + name: '大安市', + code: '220882', + }, + ], }, { - "name":"延边朝鲜族自治州", - "code":"222400", - "sub":[ + name: '延边朝鲜族自治州', + code: '222400', + sub: [ { - "name":"延吉市", - "code":"222401" + name: '延吉市', + code: '222401', }, { - "name":"图们市", - "code":"222402" + name: '图们市', + code: '222402', }, { - "name":"敦化市", - "code":"222403" + name: '敦化市', + code: '222403', }, { - "name":"珲春市", - "code":"222404" + name: '珲春市', + code: '222404', }, { - "name":"龙井市", - "code":"222405" + name: '龙井市', + code: '222405', }, { - "name":"和龙市", - "code":"222406" + name: '和龙市', + code: '222406', }, { - "name":"汪清县", - "code":"222424" + name: '汪清县', + code: '222424', }, { - "name":"安图县", - "code":"222426" - } - ] - } - ] + name: '安图县', + code: '222426', + }, + ], + }, + ], }, { - "name":"黑龙江省", - "code":"230000", - "sub":[ + name: '黑龙江省', + code: '230000', + sub: [ { - "name":"哈尔滨市", - "code":"230100", - "sub":[ + name: '哈尔滨市', + code: '230100', + sub: [ { - "name":"市辖区", - "code":"230101" + name: '市辖区', + code: '230101', }, { - "name":"道里区", - "code":"230102" + name: '道里区', + code: '230102', }, { - "name":"南岗区", - "code":"230103" + name: '南岗区', + code: '230103', }, { - "name":"道外区", - "code":"230104" + name: '道外区', + code: '230104', }, { - "name":"平房区", - "code":"230108" + name: '平房区', + code: '230108', }, { - "name":"松北区", - "code":"230109" + name: '松北区', + code: '230109', }, { - "name":"香坊区", - "code":"230110" + name: '香坊区', + code: '230110', }, { - "name":"呼兰区", - "code":"230111" + name: '呼兰区', + code: '230111', }, { - "name":"阿城区", - "code":"230112" + name: '阿城区', + code: '230112', }, { - "name":"双城区", - "code":"230113" + name: '双城区', + code: '230113', }, { - "name":"依兰县", - "code":"230123" + name: '依兰县', + code: '230123', }, { - "name":"方正县", - "code":"230124" + name: '方正县', + code: '230124', }, { - "name":"宾县", - "code":"230125" + name: '宾县', + code: '230125', }, { - "name":"巴彦县", - "code":"230126" + name: '巴彦县', + code: '230126', }, { - "name":"木兰县", - "code":"230127" + name: '木兰县', + code: '230127', }, { - "name":"通河县", - "code":"230128" + name: '通河县', + code: '230128', }, { - "name":"延寿县", - "code":"230129" + name: '延寿县', + code: '230129', }, { - "name":"尚志市", - "code":"230183" + name: '尚志市', + code: '230183', }, { - "name":"五常市", - "code":"230184" - } - ] + name: '五常市', + code: '230184', + }, + ], }, { - "name":"齐齐哈尔市", - "code":"230200", - "sub":[ + name: '齐齐哈尔市', + code: '230200', + sub: [ { - "name":"市辖区", - "code":"230201" + name: '市辖区', + code: '230201', }, { - "name":"龙沙区", - "code":"230202" + name: '龙沙区', + code: '230202', }, { - "name":"建华区", - "code":"230203" + name: '建华区', + code: '230203', }, { - "name":"铁锋区", - "code":"230204" + name: '铁锋区', + code: '230204', }, { - "name":"昂昂溪区", - "code":"230205" + name: '昂昂溪区', + code: '230205', }, { - "name":"富拉尔基区", - "code":"230206" + name: '富拉尔基区', + code: '230206', }, { - "name":"碾子山区", - "code":"230207" + name: '碾子山区', + code: '230207', }, { - "name":"梅里斯达斡尔族区", - "code":"230208" + name: '梅里斯达斡尔族区', + code: '230208', }, { - "name":"龙江县", - "code":"230221" + name: '龙江县', + code: '230221', }, { - "name":"依安县", - "code":"230223" + name: '依安县', + code: '230223', }, { - "name":"泰来县", - "code":"230224" + name: '泰来县', + code: '230224', }, { - "name":"甘南县", - "code":"230225" + name: '甘南县', + code: '230225', }, { - "name":"富裕县", - "code":"230227" + name: '富裕县', + code: '230227', }, { - "name":"克山县", - "code":"230229" + name: '克山县', + code: '230229', }, { - "name":"克东县", - "code":"230230" + name: '克东县', + code: '230230', }, { - "name":"拜泉县", - "code":"230231" + name: '拜泉县', + code: '230231', }, { - "name":"讷河市", - "code":"230281" - } - ] + name: '讷河市', + code: '230281', + }, + ], }, { - "name":"鸡西市", - "code":"230300", - "sub":[ + name: '鸡西市', + code: '230300', + sub: [ { - "name":"市辖区", - "code":"230301" + name: '市辖区', + code: '230301', }, { - "name":"鸡冠区", - "code":"230302" + name: '鸡冠区', + code: '230302', }, { - "name":"恒山区", - "code":"230303" + name: '恒山区', + code: '230303', }, { - "name":"滴道区", - "code":"230304" + name: '滴道区', + code: '230304', }, { - "name":"梨树区", - "code":"230305" + name: '梨树区', + code: '230305', }, { - "name":"城子河区", - "code":"230306" + name: '城子河区', + code: '230306', }, { - "name":"麻山区", - "code":"230307" + name: '麻山区', + code: '230307', }, { - "name":"鸡东县", - "code":"230321" + name: '鸡东县', + code: '230321', }, { - "name":"虎林市", - "code":"230381" + name: '虎林市', + code: '230381', }, { - "name":"密山市", - "code":"230382" - } - ] + name: '密山市', + code: '230382', + }, + ], }, { - "name":"鹤岗市", - "code":"230400", - "sub":[ + name: '鹤岗市', + code: '230400', + sub: [ { - "name":"市辖区", - "code":"230401" + name: '市辖区', + code: '230401', }, { - "name":"向阳区", - "code":"230402" + name: '向阳区', + code: '230402', }, { - "name":"工农区", - "code":"230403" + name: '工农区', + code: '230403', }, { - "name":"南山区", - "code":"230404" + name: '南山区', + code: '230404', }, { - "name":"兴安区", - "code":"230405" + name: '兴安区', + code: '230405', }, { - "name":"东山区", - "code":"230406" + name: '东山区', + code: '230406', }, { - "name":"兴山区", - "code":"230407" + name: '兴山区', + code: '230407', }, { - "name":"萝北县", - "code":"230421" + name: '萝北县', + code: '230421', }, { - "name":"绥滨县", - "code":"230422" - } - ] + name: '绥滨县', + code: '230422', + }, + ], }, { - "name":"双鸭山市", - "code":"230500", - "sub":[ + name: '双鸭山市', + code: '230500', + sub: [ { - "name":"市辖区", - "code":"230501" + name: '市辖区', + code: '230501', }, { - "name":"尖山区", - "code":"230502" + name: '尖山区', + code: '230502', }, { - "name":"岭东区", - "code":"230503" + name: '岭东区', + code: '230503', }, { - "name":"四方台区", - "code":"230505" + name: '四方台区', + code: '230505', }, { - "name":"宝山区", - "code":"230506" + name: '宝山区', + code: '230506', }, { - "name":"集贤县", - "code":"230521" + name: '集贤县', + code: '230521', }, { - "name":"友谊县", - "code":"230522" + name: '友谊县', + code: '230522', }, { - "name":"宝清县", - "code":"230523" + name: '宝清县', + code: '230523', }, { - "name":"饶河县", - "code":"230524" - } - ] + name: '饶河县', + code: '230524', + }, + ], }, { - "name":"大庆市", - "code":"230600", - "sub":[ + name: '大庆市', + code: '230600', + sub: [ { - "name":"市辖区", - "code":"230601" + name: '市辖区', + code: '230601', }, { - "name":"萨尔图区", - "code":"230602" + name: '萨尔图区', + code: '230602', }, { - "name":"龙凤区", - "code":"230603" + name: '龙凤区', + code: '230603', }, { - "name":"让胡路区", - "code":"230604" + name: '让胡路区', + code: '230604', }, { - "name":"红岗区", - "code":"230605" + name: '红岗区', + code: '230605', }, { - "name":"大同区", - "code":"230606" + name: '大同区', + code: '230606', }, { - "name":"肇州县", - "code":"230621" + name: '肇州县', + code: '230621', }, { - "name":"肇源县", - "code":"230622" + name: '肇源县', + code: '230622', }, { - "name":"林甸县", - "code":"230623" + name: '林甸县', + code: '230623', }, { - "name":"杜尔伯特蒙古族自治县", - "code":"230624" - } - ] + name: '杜尔伯特蒙古族自治县', + code: '230624', + }, + ], }, { - "name":"伊春市", - "code":"230700", - "sub":[ + name: '伊春市', + code: '230700', + sub: [ { - "name":"市辖区", - "code":"230701" + name: '市辖区', + code: '230701', }, { - "name":"伊春区", - "code":"230702" + name: '伊春区', + code: '230702', }, { - "name":"南岔区", - "code":"230703" + name: '南岔区', + code: '230703', }, { - "name":"友好区", - "code":"230704" + name: '友好区', + code: '230704', }, { - "name":"西林区", - "code":"230705" + name: '西林区', + code: '230705', }, { - "name":"翠峦区", - "code":"230706" + name: '翠峦区', + code: '230706', }, { - "name":"新青区", - "code":"230707" + name: '新青区', + code: '230707', }, { - "name":"美溪区", - "code":"230708" + name: '美溪区', + code: '230708', }, { - "name":"金山屯区", - "code":"230709" + name: '金山屯区', + code: '230709', }, { - "name":"五营区", - "code":"230710" + name: '五营区', + code: '230710', }, { - "name":"乌马河区", - "code":"230711" + name: '乌马河区', + code: '230711', }, { - "name":"汤旺河区", - "code":"230712" + name: '汤旺河区', + code: '230712', }, { - "name":"带岭区", - "code":"230713" + name: '带岭区', + code: '230713', }, { - "name":"乌伊岭区", - "code":"230714" + name: '乌伊岭区', + code: '230714', }, { - "name":"红星区", - "code":"230715" + name: '红星区', + code: '230715', }, { - "name":"上甘岭区", - "code":"230716" + name: '上甘岭区', + code: '230716', }, { - "name":"嘉荫县", - "code":"230722" + name: '嘉荫县', + code: '230722', }, { - "name":"铁力市", - "code":"230781" - } - ] + name: '铁力市', + code: '230781', + }, + ], }, { - "name":"佳木斯市", - "code":"230800", - "sub":[ + name: '佳木斯市', + code: '230800', + sub: [ { - "name":"市辖区", - "code":"230801" + name: '市辖区', + code: '230801', }, { - "name":"向阳区", - "code":"230803" + name: '向阳区', + code: '230803', }, { - "name":"前进区", - "code":"230804" + name: '前进区', + code: '230804', }, { - "name":"东风区", - "code":"230805" + name: '东风区', + code: '230805', }, { - "name":"郊区", - "code":"230811" + name: '郊区', + code: '230811', }, { - "name":"桦南县", - "code":"230822" + name: '桦南县', + code: '230822', }, { - "name":"桦川县", - "code":"230826" + name: '桦川县', + code: '230826', }, { - "name":"汤原县", - "code":"230828" + name: '汤原县', + code: '230828', }, { - "name":"抚远县", - "code":"230833" + name: '抚远县', + code: '230833', }, { - "name":"同江市", - "code":"230881" + name: '同江市', + code: '230881', }, { - "name":"富锦市", - "code":"230882" - } - ] + name: '富锦市', + code: '230882', + }, + ], }, { - "name":"七台河市", - "code":"230900", - "sub":[ + name: '七台河市', + code: '230900', + sub: [ { - "name":"市辖区", - "code":"230901" + name: '市辖区', + code: '230901', }, { - "name":"新兴区", - "code":"230902" + name: '新兴区', + code: '230902', }, { - "name":"桃山区", - "code":"230903" + name: '桃山区', + code: '230903', }, { - "name":"茄子河区", - "code":"230904" + name: '茄子河区', + code: '230904', }, { - "name":"勃利县", - "code":"230921" - } - ] + name: '勃利县', + code: '230921', + }, + ], }, { - "name":"牡丹江市", - "code":"231000", - "sub":[ + name: '牡丹江市', + code: '231000', + sub: [ { - "name":"市辖区", - "code":"231001" + name: '市辖区', + code: '231001', }, { - "name":"东安区", - "code":"231002" + name: '东安区', + code: '231002', }, { - "name":"阳明区", - "code":"231003" + name: '阳明区', + code: '231003', }, { - "name":"爱民区", - "code":"231004" + name: '爱民区', + code: '231004', }, { - "name":"西安区", - "code":"231005" + name: '西安区', + code: '231005', }, { - "name":"东宁县", - "code":"231024" + name: '东宁县', + code: '231024', }, { - "name":"林口县", - "code":"231025" + name: '林口县', + code: '231025', }, { - "name":"绥芬河市", - "code":"231081" + name: '绥芬河市', + code: '231081', }, { - "name":"海林市", - "code":"231083" + name: '海林市', + code: '231083', }, { - "name":"宁安市", - "code":"231084" + name: '宁安市', + code: '231084', }, { - "name":"穆棱市", - "code":"231085" - } - ] + name: '穆棱市', + code: '231085', + }, + ], }, { - "name":"黑河市", - "code":"231100", - "sub":[ + name: '黑河市', + code: '231100', + sub: [ { - "name":"市辖区", - "code":"231101" + name: '市辖区', + code: '231101', }, { - "name":"爱辉区", - "code":"231102" + name: '爱辉区', + code: '231102', }, { - "name":"嫩江县", - "code":"231121" + name: '嫩江县', + code: '231121', }, { - "name":"逊克县", - "code":"231123" + name: '逊克县', + code: '231123', }, { - "name":"孙吴县", - "code":"231124" + name: '孙吴县', + code: '231124', }, { - "name":"北安市", - "code":"231181" + name: '北安市', + code: '231181', }, { - "name":"五大连池市", - "code":"231182" - } - ] + name: '五大连池市', + code: '231182', + }, + ], }, { - "name":"绥化市", - "code":"231200", - "sub":[ + name: '绥化市', + code: '231200', + sub: [ { - "name":"市辖区", - "code":"231201" + name: '市辖区', + code: '231201', }, { - "name":"北林区", - "code":"231202" + name: '北林区', + code: '231202', }, { - "name":"望奎县", - "code":"231221" + name: '望奎县', + code: '231221', }, { - "name":"兰西县", - "code":"231222" + name: '兰西县', + code: '231222', }, { - "name":"青冈县", - "code":"231223" + name: '青冈县', + code: '231223', }, { - "name":"庆安县", - "code":"231224" + name: '庆安县', + code: '231224', }, { - "name":"明水县", - "code":"231225" + name: '明水县', + code: '231225', }, { - "name":"绥棱县", - "code":"231226" + name: '绥棱县', + code: '231226', }, { - "name":"安达市", - "code":"231281" + name: '安达市', + code: '231281', }, { - "name":"肇东市", - "code":"231282" + name: '肇东市', + code: '231282', }, { - "name":"海伦市", - "code":"231283" - } - ] + name: '海伦市', + code: '231283', + }, + ], }, { - "name":"大兴安岭地区", - "code":"232700", - "sub":[ + name: '大兴安岭地区', + code: '232700', + sub: [ { - "name":"呼玛县", - "code":"232721" + name: '呼玛县', + code: '232721', }, { - "name":"塔河县", - "code":"232722" + name: '塔河县', + code: '232722', }, { - "name":"漠河县", - "code":"232723" - } - ] - } - ] + name: '漠河县', + code: '232723', + }, + ], + }, + ], }, { - "name":"上海", - "code":"310000", - "sub": [ - { - "name":"上海市", - "code": "310000", - "sub":[ - { - "name":"黄浦区", - "code":"310101" - }, - { - "name":"徐汇区", - "code":"310104" - }, - { - "name":"长宁区", - "code":"310105" - }, - { - "name":"静安区", - "code":"310106" - }, - { - "name":"普陀区", - "code":"310107" - }, - { - "name":"闸北区", - "code":"310108" - }, - { - "name":"虹口区", - "code":"310109" - }, - { - "name":"杨浦区", - "code":"310110" - }, - { - "name":"闵行区", - "code":"310112" - }, - { - "name":"宝山区", - "code":"310113" - }, - { - "name":"嘉定区", - "code":"310114" - }, - { - "name":"浦东新区", - "code":"310115" - }, - { - "name":"金山区", - "code":"310116" - }, - { - "name":"松江区", - "code":"310117" - }, - { - "name":"青浦区", - "code":"310118" - }, - { - "name":"奉贤区", - "code":"310120" - }, - { - "name":"崇明县", - "code":"310230" - } - ] - } - ] + name: '上海', + code: '310000', + sub: [ + { + name: '上海市', + code: '310000', + sub: [ + { + name: '黄浦区', + code: '310101', + }, + { + name: '徐汇区', + code: '310104', + }, + { + name: '长宁区', + code: '310105', + }, + { + name: '静安区', + code: '310106', + }, + { + name: '普陀区', + code: '310107', + }, + { + name: '闸北区', + code: '310108', + }, + { + name: '虹口区', + code: '310109', + }, + { + name: '杨浦区', + code: '310110', + }, + { + name: '闵行区', + code: '310112', + }, + { + name: '宝山区', + code: '310113', + }, + { + name: '嘉定区', + code: '310114', + }, + { + name: '浦东新区', + code: '310115', + }, + { + name: '金山区', + code: '310116', + }, + { + name: '松江区', + code: '310117', + }, + { + name: '青浦区', + code: '310118', + }, + { + name: '奉贤区', + code: '310120', + }, + { + name: '崇明县', + code: '310230', + }, + ], + }, + ], }, { - "name":"江苏省", - "code":"320000", - "sub":[ + name: '江苏省', + code: '320000', + sub: [ { - "name":"南京市", - "code":"320100", - "sub":[ + name: '南京市', + code: '320100', + sub: [ { - "name":"市辖区", - "code":"320101" + name: '市辖区', + code: '320101', }, { - "name":"玄武区", - "code":"320102" + name: '玄武区', + code: '320102', }, { - "name":"秦淮区", - "code":"320104" + name: '秦淮区', + code: '320104', }, { - "name":"建邺区", - "code":"320105" + name: '建邺区', + code: '320105', }, { - "name":"鼓楼区", - "code":"320106" + name: '鼓楼区', + code: '320106', }, { - "name":"浦口区", - "code":"320111" + name: '浦口区', + code: '320111', }, { - "name":"栖霞区", - "code":"320113" + name: '栖霞区', + code: '320113', }, { - "name":"雨花台区", - "code":"320114" + name: '雨花台区', + code: '320114', }, { - "name":"江宁区", - "code":"320115" + name: '江宁区', + code: '320115', }, { - "name":"六合区", - "code":"320116" + name: '六合区', + code: '320116', }, { - "name":"溧水区", - "code":"320117" + name: '溧水区', + code: '320117', }, { - "name":"高淳区", - "code":"320118" - } - ] + name: '高淳区', + code: '320118', + }, + ], }, { - "name":"无锡市", - "code":"320200", - "sub":[ + name: '无锡市', + code: '320200', + sub: [ { - "name":"市辖区", - "code":"320201" + name: '市辖区', + code: '320201', }, { - "name":"崇安区", - "code":"320202" + name: '崇安区', + code: '320202', }, { - "name":"南长区", - "code":"320203" + name: '南长区', + code: '320203', }, { - "name":"北塘区", - "code":"320204" + name: '北塘区', + code: '320204', }, { - "name":"锡山区", - "code":"320205" + name: '锡山区', + code: '320205', }, { - "name":"惠山区", - "code":"320206" + name: '惠山区', + code: '320206', }, { - "name":"滨湖区", - "code":"320211" + name: '滨湖区', + code: '320211', }, { - "name":"江阴市", - "code":"320281" + name: '江阴市', + code: '320281', }, { - "name":"宜兴市", - "code":"320282" - } - ] + name: '宜兴市', + code: '320282', + }, + ], }, { - "name":"徐州市", - "code":"320300", - "sub":[ + name: '徐州市', + code: '320300', + sub: [ { - "name":"市辖区", - "code":"320301" + name: '市辖区', + code: '320301', }, { - "name":"鼓楼区", - "code":"320302" + name: '鼓楼区', + code: '320302', }, { - "name":"云龙区", - "code":"320303" + name: '云龙区', + code: '320303', }, { - "name":"贾汪区", - "code":"320305" + name: '贾汪区', + code: '320305', }, { - "name":"泉山区", - "code":"320311" + name: '泉山区', + code: '320311', }, { - "name":"铜山区", - "code":"320312" + name: '铜山区', + code: '320312', }, { - "name":"丰县", - "code":"320321" + name: '丰县', + code: '320321', }, { - "name":"沛县", - "code":"320322" + name: '沛县', + code: '320322', }, { - "name":"睢宁县", - "code":"320324" + name: '睢宁县', + code: '320324', }, { - "name":"新沂市", - "code":"320381" + name: '新沂市', + code: '320381', }, { - "name":"邳州市", - "code":"320382" - } - ] + name: '邳州市', + code: '320382', + }, + ], }, { - "name":"常州市", - "code":"320400", - "sub":[ + name: '常州市', + code: '320400', + sub: [ { - "name":"市辖区", - "code":"320401" + name: '市辖区', + code: '320401', }, { - "name":"天宁区", - "code":"320402" + name: '天宁区', + code: '320402', }, { - "name":"钟楼区", - "code":"320404" + name: '钟楼区', + code: '320404', }, { - "name":"戚墅堰区", - "code":"320405" + name: '戚墅堰区', + code: '320405', }, { - "name":"新北区", - "code":"320411" + name: '新北区', + code: '320411', }, { - "name":"武进区", - "code":"320412" + name: '武进区', + code: '320412', }, { - "name":"溧阳市", - "code":"320481" + name: '溧阳市', + code: '320481', }, { - "name":"金坛市", - "code":"320482" - } - ] + name: '金坛市', + code: '320482', + }, + ], }, { - "name":"苏州市", - "code":"320500", - "sub":[ + name: '苏州市', + code: '320500', + sub: [ { - "name":"市辖区", - "code":"320501" + name: '市辖区', + code: '320501', }, { - "name":"虎丘区", - "code":"320505" + name: '虎丘区', + code: '320505', }, { - "name":"吴中区", - "code":"320506" + name: '吴中区', + code: '320506', }, { - "name":"相城区", - "code":"320507" + name: '相城区', + code: '320507', }, { - "name":"姑苏区", - "code":"320508" + name: '姑苏区', + code: '320508', }, { - "name":"吴江区", - "code":"320509" + name: '吴江区', + code: '320509', }, { - "name":"常熟市", - "code":"320581" + name: '常熟市', + code: '320581', }, { - "name":"张家港市", - "code":"320582" + name: '张家港市', + code: '320582', }, { - "name":"昆山市", - "code":"320583" + name: '昆山市', + code: '320583', }, { - "name":"太仓市", - "code":"320585" - } - ] + name: '太仓市', + code: '320585', + }, + ], }, { - "name":"南通市", - "code":"320600", - "sub":[ + name: '南通市', + code: '320600', + sub: [ { - "name":"市辖区", - "code":"320601" + name: '市辖区', + code: '320601', }, { - "name":"崇川区", - "code":"320602" + name: '崇川区', + code: '320602', }, { - "name":"港闸区", - "code":"320611" + name: '港闸区', + code: '320611', }, { - "name":"通州区", - "code":"320612" + name: '通州区', + code: '320612', }, { - "name":"海安县", - "code":"320621" + name: '海安县', + code: '320621', }, { - "name":"如东县", - "code":"320623" + name: '如东县', + code: '320623', }, { - "name":"启东市", - "code":"320681" + name: '启东市', + code: '320681', }, { - "name":"如皋市", - "code":"320682" + name: '如皋市', + code: '320682', }, { - "name":"海门市", - "code":"320684" - } - ] + name: '海门市', + code: '320684', + }, + ], }, { - "name":"连云港市", - "code":"320700", - "sub":[ + name: '连云港市', + code: '320700', + sub: [ { - "name":"市辖区", - "code":"320701" + name: '市辖区', + code: '320701', }, { - "name":"连云区", - "code":"320703" + name: '连云区', + code: '320703', }, { - "name":"海州区", - "code":"320706" + name: '海州区', + code: '320706', }, { - "name":"赣榆区", - "code":"320707" + name: '赣榆区', + code: '320707', }, { - "name":"东海县", - "code":"320722" + name: '东海县', + code: '320722', }, { - "name":"灌云县", - "code":"320723" + name: '灌云县', + code: '320723', }, { - "name":"灌南县", - "code":"320724" - } - ] + name: '灌南县', + code: '320724', + }, + ], }, { - "name":"淮安市", - "code":"320800", - "sub":[ + name: '淮安市', + code: '320800', + sub: [ { - "name":"市辖区", - "code":"320801" + name: '市辖区', + code: '320801', }, { - "name":"清河区", - "code":"320802" + name: '清河区', + code: '320802', }, { - "name":"淮安区", - "code":"320803" + name: '淮安区', + code: '320803', }, { - "name":"淮阴区", - "code":"320804" + name: '淮阴区', + code: '320804', }, { - "name":"清浦区", - "code":"320811" + name: '清浦区', + code: '320811', }, { - "name":"涟水县", - "code":"320826" + name: '涟水县', + code: '320826', }, { - "name":"洪泽县", - "code":"320829" + name: '洪泽县', + code: '320829', }, { - "name":"盱眙县", - "code":"320830" + name: '盱眙县', + code: '320830', }, { - "name":"金湖县", - "code":"320831" - } - ] + name: '金湖县', + code: '320831', + }, + ], }, { - "name":"盐城市", - "code":"320900", - "sub":[ + name: '盐城市', + code: '320900', + sub: [ { - "name":"市辖区", - "code":"320901" + name: '市辖区', + code: '320901', }, { - "name":"亭湖区", - "code":"320902" + name: '亭湖区', + code: '320902', }, { - "name":"盐都区", - "code":"320903" + name: '盐都区', + code: '320903', }, { - "name":"响水县", - "code":"320921" + name: '响水县', + code: '320921', }, { - "name":"滨海县", - "code":"320922" + name: '滨海县', + code: '320922', }, { - "name":"阜宁县", - "code":"320923" + name: '阜宁县', + code: '320923', }, { - "name":"射阳县", - "code":"320924" + name: '射阳县', + code: '320924', }, { - "name":"建湖县", - "code":"320925" + name: '建湖县', + code: '320925', }, { - "name":"东台市", - "code":"320981" + name: '东台市', + code: '320981', }, { - "name":"大丰市", - "code":"320982" - } - ] + name: '大丰市', + code: '320982', + }, + ], }, { - "name":"扬州市", - "code":"321000", - "sub":[ + name: '扬州市', + code: '321000', + sub: [ { - "name":"市辖区", - "code":"321001" + name: '市辖区', + code: '321001', }, { - "name":"广陵区", - "code":"321002" + name: '广陵区', + code: '321002', }, { - "name":"邗江区", - "code":"321003" + name: '邗江区', + code: '321003', }, { - "name":"江都区", - "code":"321012" + name: '江都区', + code: '321012', }, { - "name":"宝应县", - "code":"321023" + name: '宝应县', + code: '321023', }, { - "name":"仪征市", - "code":"321081" + name: '仪征市', + code: '321081', }, { - "name":"高邮市", - "code":"321084" - } - ] + name: '高邮市', + code: '321084', + }, + ], }, { - "name":"镇江市", - "code":"321100", - "sub":[ + name: '镇江市', + code: '321100', + sub: [ { - "name":"市辖区", - "code":"321101" + name: '市辖区', + code: '321101', }, { - "name":"京口区", - "code":"321102" + name: '京口区', + code: '321102', }, { - "name":"润州区", - "code":"321111" + name: '润州区', + code: '321111', }, { - "name":"丹徒区", - "code":"321112" + name: '丹徒区', + code: '321112', }, { - "name":"丹阳市", - "code":"321181" + name: '丹阳市', + code: '321181', }, { - "name":"扬中市", - "code":"321182" + name: '扬中市', + code: '321182', }, { - "name":"句容市", - "code":"321183" - } - ] + name: '句容市', + code: '321183', + }, + ], }, { - "name":"泰州市", - "code":"321200", - "sub":[ + name: '泰州市', + code: '321200', + sub: [ { - "name":"市辖区", - "code":"321201" + name: '市辖区', + code: '321201', }, { - "name":"海陵区", - "code":"321202" + name: '海陵区', + code: '321202', }, { - "name":"高港区", - "code":"321203" + name: '高港区', + code: '321203', }, { - "name":"姜堰区", - "code":"321204" + name: '姜堰区', + code: '321204', }, { - "name":"兴化市", - "code":"321281" + name: '兴化市', + code: '321281', }, { - "name":"靖江市", - "code":"321282" + name: '靖江市', + code: '321282', }, { - "name":"泰兴市", - "code":"321283" - } - ] + name: '泰兴市', + code: '321283', + }, + ], }, { - "name":"宿迁市", - "code":"321300", - "sub":[ + name: '宿迁市', + code: '321300', + sub: [ { - "name":"市辖区", - "code":"321301" + name: '市辖区', + code: '321301', }, { - "name":"宿城区", - "code":"321302" + name: '宿城区', + code: '321302', }, { - "name":"宿豫区", - "code":"321311" + name: '宿豫区', + code: '321311', }, { - "name":"沭阳县", - "code":"321322" + name: '沭阳县', + code: '321322', }, { - "name":"泗阳县", - "code":"321323" + name: '泗阳县', + code: '321323', }, { - "name":"泗洪县", - "code":"321324" - } - ] - } - ] + name: '泗洪县', + code: '321324', + }, + ], + }, + ], }, { - "name":"浙江省", - "code":"330000", - "sub":[ + name: '浙江省', + code: '330000', + sub: [ { - "name":"杭州市", - "code":"330100", - "sub":[ + name: '杭州市', + code: '330100', + sub: [ { - "name":"市辖区", - "code":"330101" + name: '市辖区', + code: '330101', }, { - "name":"上城区", - "code":"330102" + name: '上城区', + code: '330102', }, { - "name":"下城区", - "code":"330103" + name: '下城区', + code: '330103', }, { - "name":"江干区", - "code":"330104" + name: '江干区', + code: '330104', }, { - "name":"拱墅区", - "code":"330105" + name: '拱墅区', + code: '330105', }, { - "name":"西湖区", - "code":"330106" + name: '西湖区', + code: '330106', }, { - "name":"滨江区", - "code":"330108" + name: '滨江区', + code: '330108', }, { - "name":"萧山区", - "code":"330109" + name: '萧山区', + code: '330109', }, { - "name":"余杭区", - "code":"330110" + name: '余杭区', + code: '330110', }, { - "name":"富阳区", - "code":"330111" + name: '富阳区', + code: '330111', }, { - "name":"桐庐县", - "code":"330122" + name: '桐庐县', + code: '330122', }, { - "name":"淳安县", - "code":"330127" + name: '淳安县', + code: '330127', }, { - "name":"建德市", - "code":"330182" + name: '建德市', + code: '330182', }, { - "name":"临安市", - "code":"330185" - } - ] + name: '临安市', + code: '330185', + }, + ], }, { - "name":"宁波市", - "code":"330200", - "sub":[ + name: '宁波市', + code: '330200', + sub: [ { - "name":"市辖区", - "code":"330201" + name: '市辖区', + code: '330201', }, { - "name":"海曙区", - "code":"330203" + name: '海曙区', + code: '330203', }, { - "name":"江东区", - "code":"330204" + name: '江东区', + code: '330204', }, { - "name":"江北区", - "code":"330205" + name: '江北区', + code: '330205', }, { - "name":"北仑区", - "code":"330206" + name: '北仑区', + code: '330206', }, { - "name":"镇海区", - "code":"330211" + name: '镇海区', + code: '330211', }, { - "name":"鄞州区", - "code":"330212" + name: '鄞州区', + code: '330212', }, { - "name":"象山县", - "code":"330225" + name: '象山县', + code: '330225', }, { - "name":"宁海县", - "code":"330226" + name: '宁海县', + code: '330226', }, { - "name":"余姚市", - "code":"330281" + name: '余姚市', + code: '330281', }, { - "name":"慈溪市", - "code":"330282" + name: '慈溪市', + code: '330282', }, { - "name":"奉化市", - "code":"330283" - } - ] + name: '奉化市', + code: '330283', + }, + ], }, { - "name":"温州市", - "code":"330300", - "sub":[ + name: '温州市', + code: '330300', + sub: [ { - "name":"市辖区", - "code":"330301" + name: '市辖区', + code: '330301', }, { - "name":"鹿城区", - "code":"330302" + name: '鹿城区', + code: '330302', }, { - "name":"龙湾区", - "code":"330303" + name: '龙湾区', + code: '330303', }, { - "name":"瓯海区", - "code":"330304" + name: '瓯海区', + code: '330304', }, { - "name":"洞头县", - "code":"330322" + name: '洞头县', + code: '330322', }, { - "name":"永嘉县", - "code":"330324" + name: '永嘉县', + code: '330324', }, { - "name":"平阳县", - "code":"330326" + name: '平阳县', + code: '330326', }, { - "name":"苍南县", - "code":"330327" + name: '苍南县', + code: '330327', }, { - "name":"文成县", - "code":"330328" + name: '文成县', + code: '330328', }, { - "name":"泰顺县", - "code":"330329" + name: '泰顺县', + code: '330329', }, { - "name":"瑞安市", - "code":"330381" + name: '瑞安市', + code: '330381', }, { - "name":"乐清市", - "code":"330382" - } - ] + name: '乐清市', + code: '330382', + }, + ], }, { - "name":"嘉兴市", - "code":"330400", - "sub":[ + name: '嘉兴市', + code: '330400', + sub: [ { - "name":"市辖区", - "code":"330401" + name: '市辖区', + code: '330401', }, { - "name":"南湖区", - "code":"330402" + name: '南湖区', + code: '330402', }, { - "name":"秀洲区", - "code":"330411" + name: '秀洲区', + code: '330411', }, { - "name":"嘉善县", - "code":"330421" + name: '嘉善县', + code: '330421', }, { - "name":"海盐县", - "code":"330424" + name: '海盐县', + code: '330424', }, { - "name":"海宁市", - "code":"330481" + name: '海宁市', + code: '330481', }, { - "name":"平湖市", - "code":"330482" + name: '平湖市', + code: '330482', }, { - "name":"桐乡市", - "code":"330483" - } - ] + name: '桐乡市', + code: '330483', + }, + ], }, { - "name":"湖州市", - "code":"330500", - "sub":[ + name: '湖州市', + code: '330500', + sub: [ { - "name":"市辖区", - "code":"330501" + name: '市辖区', + code: '330501', }, { - "name":"吴兴区", - "code":"330502" + name: '吴兴区', + code: '330502', }, { - "name":"南浔区", - "code":"330503" + name: '南浔区', + code: '330503', }, { - "name":"德清县", - "code":"330521" + name: '德清县', + code: '330521', }, { - "name":"长兴县", - "code":"330522" + name: '长兴县', + code: '330522', }, { - "name":"安吉县", - "code":"330523" - } - ] + name: '安吉县', + code: '330523', + }, + ], }, { - "name":"绍兴市", - "code":"330600", - "sub":[ + name: '绍兴市', + code: '330600', + sub: [ { - "name":"市辖区", - "code":"330601" + name: '市辖区', + code: '330601', }, { - "name":"越城区", - "code":"330602" + name: '越城区', + code: '330602', }, { - "name":"柯桥区", - "code":"330603" + name: '柯桥区', + code: '330603', }, { - "name":"上虞区", - "code":"330604" + name: '上虞区', + code: '330604', }, { - "name":"新昌县", - "code":"330624" + name: '新昌县', + code: '330624', }, { - "name":"诸暨市", - "code":"330681" + name: '诸暨市', + code: '330681', }, { - "name":"嵊州市", - "code":"330683" - } - ] + name: '嵊州市', + code: '330683', + }, + ], }, { - "name":"金华市", - "code":"330700", - "sub":[ + name: '金华市', + code: '330700', + sub: [ { - "name":"市辖区", - "code":"330701" + name: '市辖区', + code: '330701', }, { - "name":"婺城区", - "code":"330702" + name: '婺城区', + code: '330702', }, { - "name":"金东区", - "code":"330703" + name: '金东区', + code: '330703', }, { - "name":"武义县", - "code":"330723" + name: '武义县', + code: '330723', }, { - "name":"浦江县", - "code":"330726" + name: '浦江县', + code: '330726', }, { - "name":"磐安县", - "code":"330727" + name: '磐安县', + code: '330727', }, { - "name":"兰溪市", - "code":"330781" + name: '兰溪市', + code: '330781', }, { - "name":"义乌市", - "code":"330782" + name: '义乌市', + code: '330782', }, { - "name":"东阳市", - "code":"330783" + name: '东阳市', + code: '330783', }, { - "name":"永康市", - "code":"330784" - } - ] + name: '永康市', + code: '330784', + }, + ], }, { - "name":"衢州市", - "code":"330800", - "sub":[ + name: '衢州市', + code: '330800', + sub: [ { - "name":"市辖区", - "code":"330801" + name: '市辖区', + code: '330801', }, { - "name":"柯城区", - "code":"330802" + name: '柯城区', + code: '330802', }, { - "name":"衢江区", - "code":"330803" + name: '衢江区', + code: '330803', }, { - "name":"常山县", - "code":"330822" + name: '常山县', + code: '330822', }, { - "name":"开化县", - "code":"330824" + name: '开化县', + code: '330824', }, { - "name":"龙游县", - "code":"330825" + name: '龙游县', + code: '330825', }, { - "name":"江山市", - "code":"330881" - } - ] + name: '江山市', + code: '330881', + }, + ], }, { - "name":"舟山市", - "code":"330900", - "sub":[ + name: '舟山市', + code: '330900', + sub: [ { - "name":"市辖区", - "code":"330901" + name: '市辖区', + code: '330901', }, { - "name":"定海区", - "code":"330902" + name: '定海区', + code: '330902', }, { - "name":"普陀区", - "code":"330903" + name: '普陀区', + code: '330903', }, { - "name":"岱山县", - "code":"330921" + name: '岱山县', + code: '330921', }, { - "name":"嵊泗县", - "code":"330922" - } - ] + name: '嵊泗县', + code: '330922', + }, + ], }, { - "name":"台州市", - "code":"331000", - "sub":[ + name: '台州市', + code: '331000', + sub: [ { - "name":"市辖区", - "code":"331001" + name: '市辖区', + code: '331001', }, { - "name":"椒江区", - "code":"331002" + name: '椒江区', + code: '331002', }, { - "name":"黄岩区", - "code":"331003" + name: '黄岩区', + code: '331003', }, { - "name":"路桥区", - "code":"331004" + name: '路桥区', + code: '331004', }, { - "name":"玉环县", - "code":"331021" + name: '玉环县', + code: '331021', }, { - "name":"三门县", - "code":"331022" + name: '三门县', + code: '331022', }, { - "name":"天台县", - "code":"331023" + name: '天台县', + code: '331023', }, { - "name":"仙居县", - "code":"331024" + name: '仙居县', + code: '331024', }, { - "name":"温岭市", - "code":"331081" + name: '温岭市', + code: '331081', }, { - "name":"临海市", - "code":"331082" - } - ] + name: '临海市', + code: '331082', + }, + ], }, { - "name":"丽水市", - "code":"331100", - "sub":[ + name: '丽水市', + code: '331100', + sub: [ { - "name":"市辖区", - "code":"331101" + name: '市辖区', + code: '331101', }, { - "name":"莲都区", - "code":"331102" + name: '莲都区', + code: '331102', }, { - "name":"青田县", - "code":"331121" + name: '青田县', + code: '331121', }, { - "name":"缙云县", - "code":"331122" + name: '缙云县', + code: '331122', }, { - "name":"遂昌县", - "code":"331123" + name: '遂昌县', + code: '331123', }, { - "name":"松阳县", - "code":"331124" + name: '松阳县', + code: '331124', }, { - "name":"云和县", - "code":"331125" + name: '云和县', + code: '331125', }, { - "name":"庆元县", - "code":"331126" + name: '庆元县', + code: '331126', }, { - "name":"景宁畲族自治县", - "code":"331127" + name: '景宁畲族自治县', + code: '331127', }, { - "name":"龙泉市", - "code":"331181" - } - ] - } - ] + name: '龙泉市', + code: '331181', + }, + ], + }, + ], }, { - "name":"安徽省", - "code":"340000", - "sub":[ + name: '安徽省', + code: '340000', + sub: [ { - "name":"合肥市", - "code":"340100", - "sub":[ + name: '合肥市', + code: '340100', + sub: [ { - "name":"市辖区", - "code":"340101" + name: '市辖区', + code: '340101', }, { - "name":"瑶海区", - "code":"340102" + name: '瑶海区', + code: '340102', }, { - "name":"庐阳区", - "code":"340103" + name: '庐阳区', + code: '340103', }, { - "name":"蜀山区", - "code":"340104" + name: '蜀山区', + code: '340104', }, { - "name":"包河区", - "code":"340111" + name: '包河区', + code: '340111', }, { - "name":"长丰县", - "code":"340121" + name: '长丰县', + code: '340121', }, { - "name":"肥东县", - "code":"340122" + name: '肥东县', + code: '340122', }, { - "name":"肥西县", - "code":"340123" + name: '肥西县', + code: '340123', }, { - "name":"庐江县", - "code":"340124" + name: '庐江县', + code: '340124', }, { - "name":"巢湖市", - "code":"340181" - } - ] + name: '巢湖市', + code: '340181', + }, + ], }, { - "name":"芜湖市", - "code":"340200", - "sub":[ + name: '芜湖市', + code: '340200', + sub: [ { - "name":"市辖区", - "code":"340201" + name: '市辖区', + code: '340201', }, { - "name":"镜湖区", - "code":"340202" + name: '镜湖区', + code: '340202', }, { - "name":"弋江区", - "code":"340203" + name: '弋江区', + code: '340203', }, { - "name":"鸠江区", - "code":"340207" + name: '鸠江区', + code: '340207', }, { - "name":"三山区", - "code":"340208" + name: '三山区', + code: '340208', }, { - "name":"芜湖县", - "code":"340221" + name: '芜湖县', + code: '340221', }, { - "name":"繁昌县", - "code":"340222" + name: '繁昌县', + code: '340222', }, { - "name":"南陵县", - "code":"340223" + name: '南陵县', + code: '340223', }, { - "name":"无为县", - "code":"340225" - } - ] + name: '无为县', + code: '340225', + }, + ], }, { - "name":"蚌埠市", - "code":"340300", - "sub":[ + name: '蚌埠市', + code: '340300', + sub: [ { - "name":"市辖区", - "code":"340301" + name: '市辖区', + code: '340301', }, { - "name":"龙子湖区", - "code":"340302" + name: '龙子湖区', + code: '340302', }, { - "name":"蚌山区", - "code":"340303" + name: '蚌山区', + code: '340303', }, { - "name":"禹会区", - "code":"340304" + name: '禹会区', + code: '340304', }, { - "name":"淮上区", - "code":"340311" + name: '淮上区', + code: '340311', }, { - "name":"怀远县", - "code":"340321" + name: '怀远县', + code: '340321', }, { - "name":"五河县", - "code":"340322" + name: '五河县', + code: '340322', }, { - "name":"固镇县", - "code":"340323" - } - ] + name: '固镇县', + code: '340323', + }, + ], }, { - "name":"淮南市", - "code":"340400", - "sub":[ + name: '淮南市', + code: '340400', + sub: [ { - "name":"市辖区", - "code":"340401" + name: '市辖区', + code: '340401', }, { - "name":"大通区", - "code":"340402" + name: '大通区', + code: '340402', }, { - "name":"田家庵区", - "code":"340403" + name: '田家庵区', + code: '340403', }, { - "name":"谢家集区", - "code":"340404" + name: '谢家集区', + code: '340404', }, { - "name":"八公山区", - "code":"340405" + name: '八公山区', + code: '340405', }, { - "name":"潘集区", - "code":"340406" + name: '潘集区', + code: '340406', }, { - "name":"凤台县", - "code":"340421" - } - ] + name: '凤台县', + code: '340421', + }, + ], }, { - "name":"马鞍山市", - "code":"340500", - "sub":[ + name: '马鞍山市', + code: '340500', + sub: [ { - "name":"市辖区", - "code":"340501" + name: '市辖区', + code: '340501', }, { - "name":"花山区", - "code":"340503" + name: '花山区', + code: '340503', }, { - "name":"雨山区", - "code":"340504" + name: '雨山区', + code: '340504', }, { - "name":"博望区", - "code":"340506" + name: '博望区', + code: '340506', }, { - "name":"当涂县", - "code":"340521" + name: '当涂县', + code: '340521', }, { - "name":"含山县", - "code":"340522" + name: '含山县', + code: '340522', }, { - "name":"和县", - "code":"340523" - } - ] + name: '和县', + code: '340523', + }, + ], }, { - "name":"淮北市", - "code":"340600", - "sub":[ + name: '淮北市', + code: '340600', + sub: [ { - "name":"市辖区", - "code":"340601" + name: '市辖区', + code: '340601', }, { - "name":"杜集区", - "code":"340602" + name: '杜集区', + code: '340602', }, { - "name":"相山区", - "code":"340603" + name: '相山区', + code: '340603', }, { - "name":"烈山区", - "code":"340604" + name: '烈山区', + code: '340604', }, { - "name":"濉溪县", - "code":"340621" - } - ] + name: '濉溪县', + code: '340621', + }, + ], }, { - "name":"铜陵市", - "code":"340700", - "sub":[ + name: '铜陵市', + code: '340700', + sub: [ { - "name":"市辖区", - "code":"340701" + name: '市辖区', + code: '340701', }, { - "name":"铜官山区", - "code":"340702" + name: '铜官山区', + code: '340702', }, { - "name":"狮子山区", - "code":"340703" + name: '狮子山区', + code: '340703', }, { - "name":"郊区", - "code":"340711" + name: '郊区', + code: '340711', }, { - "name":"铜陵县", - "code":"340721" - } - ] + name: '铜陵县', + code: '340721', + }, + ], }, { - "name":"安庆市", - "code":"340800", - "sub":[ + name: '安庆市', + code: '340800', + sub: [ { - "name":"市辖区", - "code":"340801" + name: '市辖区', + code: '340801', }, { - "name":"迎江区", - "code":"340802" + name: '迎江区', + code: '340802', }, { - "name":"大观区", - "code":"340803" + name: '大观区', + code: '340803', }, { - "name":"宜秀区", - "code":"340811" + name: '宜秀区', + code: '340811', }, { - "name":"怀宁县", - "code":"340822" + name: '怀宁县', + code: '340822', }, { - "name":"枞阳县", - "code":"340823" + name: '枞阳县', + code: '340823', }, { - "name":"潜山县", - "code":"340824" + name: '潜山县', + code: '340824', }, { - "name":"太湖县", - "code":"340825" + name: '太湖县', + code: '340825', }, { - "name":"宿松县", - "code":"340826" + name: '宿松县', + code: '340826', }, { - "name":"望江县", - "code":"340827" + name: '望江县', + code: '340827', }, { - "name":"岳西县", - "code":"340828" + name: '岳西县', + code: '340828', }, { - "name":"桐城市", - "code":"340881" - } - ] + name: '桐城市', + code: '340881', + }, + ], }, { - "name":"黄山市", - "code":"341000", - "sub":[ + name: '黄山市', + code: '341000', + sub: [ { - "name":"市辖区", - "code":"341001" + name: '市辖区', + code: '341001', }, { - "name":"屯溪区", - "code":"341002" + name: '屯溪区', + code: '341002', }, { - "name":"黄山区", - "code":"341003" + name: '黄山区', + code: '341003', }, { - "name":"徽州区", - "code":"341004" + name: '徽州区', + code: '341004', }, { - "name":"歙县", - "code":"341021" + name: '歙县', + code: '341021', }, { - "name":"休宁县", - "code":"341022" + name: '休宁县', + code: '341022', }, { - "name":"黟县", - "code":"341023" + name: '黟县', + code: '341023', }, { - "name":"祁门县", - "code":"341024" - } - ] + name: '祁门县', + code: '341024', + }, + ], }, { - "name":"滁州市", - "code":"341100", - "sub":[ + name: '滁州市', + code: '341100', + sub: [ { - "name":"市辖区", - "code":"341101" + name: '市辖区', + code: '341101', }, { - "name":"琅琊区", - "code":"341102" + name: '琅琊区', + code: '341102', }, { - "name":"南谯区", - "code":"341103" + name: '南谯区', + code: '341103', }, { - "name":"来安县", - "code":"341122" + name: '来安县', + code: '341122', }, { - "name":"全椒县", - "code":"341124" + name: '全椒县', + code: '341124', }, { - "name":"定远县", - "code":"341125" + name: '定远县', + code: '341125', }, { - "name":"凤阳县", - "code":"341126" + name: '凤阳县', + code: '341126', }, { - "name":"天长市", - "code":"341181" + name: '天长市', + code: '341181', }, { - "name":"明光市", - "code":"341182" - } - ] + name: '明光市', + code: '341182', + }, + ], }, { - "name":"阜阳市", - "code":"341200", - "sub":[ + name: '阜阳市', + code: '341200', + sub: [ { - "name":"市辖区", - "code":"341201" + name: '市辖区', + code: '341201', }, { - "name":"颍州区", - "code":"341202" + name: '颍州区', + code: '341202', }, { - "name":"颍东区", - "code":"341203" + name: '颍东区', + code: '341203', }, { - "name":"颍泉区", - "code":"341204" + name: '颍泉区', + code: '341204', }, { - "name":"临泉县", - "code":"341221" + name: '临泉县', + code: '341221', }, { - "name":"太和县", - "code":"341222" + name: '太和县', + code: '341222', }, { - "name":"阜南县", - "code":"341225" + name: '阜南县', + code: '341225', }, { - "name":"颍上县", - "code":"341226" + name: '颍上县', + code: '341226', }, { - "name":"界首市", - "code":"341282" - } - ] + name: '界首市', + code: '341282', + }, + ], }, { - "name":"宿州市", - "code":"341300", - "sub":[ + name: '宿州市', + code: '341300', + sub: [ { - "name":"市辖区", - "code":"341301" + name: '市辖区', + code: '341301', }, { - "name":"埇桥区", - "code":"341302" + name: '埇桥区', + code: '341302', }, { - "name":"砀山县", - "code":"341321" + name: '砀山县', + code: '341321', }, { - "name":"萧县", - "code":"341322" + name: '萧县', + code: '341322', }, { - "name":"灵璧县", - "code":"341323" + name: '灵璧县', + code: '341323', }, { - "name":"泗县", - "code":"341324" - } - ] + name: '泗县', + code: '341324', + }, + ], }, { - "name":"六安市", - "code":"341500", - "sub":[ + name: '六安市', + code: '341500', + sub: [ { - "name":"市辖区", - "code":"341501" + name: '市辖区', + code: '341501', }, { - "name":"金安区", - "code":"341502" + name: '金安区', + code: '341502', }, { - "name":"裕安区", - "code":"341503" + name: '裕安区', + code: '341503', }, { - "name":"寿县", - "code":"341521" + name: '寿县', + code: '341521', }, { - "name":"霍邱县", - "code":"341522" + name: '霍邱县', + code: '341522', }, { - "name":"舒城县", - "code":"341523" + name: '舒城县', + code: '341523', }, { - "name":"金寨县", - "code":"341524" + name: '金寨县', + code: '341524', }, { - "name":"霍山县", - "code":"341525" - } - ] + name: '霍山县', + code: '341525', + }, + ], }, { - "name":"亳州市", - "code":"341600", - "sub":[ + name: '亳州市', + code: '341600', + sub: [ { - "name":"市辖区", - "code":"341601" + name: '市辖区', + code: '341601', }, { - "name":"谯城区", - "code":"341602" + name: '谯城区', + code: '341602', }, { - "name":"涡阳县", - "code":"341621" + name: '涡阳县', + code: '341621', }, { - "name":"蒙城县", - "code":"341622" + name: '蒙城县', + code: '341622', }, { - "name":"利辛县", - "code":"341623" - } - ] + name: '利辛县', + code: '341623', + }, + ], }, { - "name":"池州市", - "code":"341700", - "sub":[ + name: '池州市', + code: '341700', + sub: [ { - "name":"市辖区", - "code":"341701" + name: '市辖区', + code: '341701', }, { - "name":"贵池区", - "code":"341702" + name: '贵池区', + code: '341702', }, { - "name":"东至县", - "code":"341721" + name: '东至县', + code: '341721', }, { - "name":"石台县", - "code":"341722" + name: '石台县', + code: '341722', }, { - "name":"青阳县", - "code":"341723" - } - ] + name: '青阳县', + code: '341723', + }, + ], }, { - "name":"宣城市", - "code":"341800", - "sub":[ + name: '宣城市', + code: '341800', + sub: [ { - "name":"市辖区", - "code":"341801" + name: '市辖区', + code: '341801', }, { - "name":"宣州区", - "code":"341802" + name: '宣州区', + code: '341802', }, { - "name":"郎溪县", - "code":"341821" + name: '郎溪县', + code: '341821', }, { - "name":"广德县", - "code":"341822" + name: '广德县', + code: '341822', }, { - "name":"泾县", - "code":"341823" + name: '泾县', + code: '341823', }, { - "name":"绩溪县", - "code":"341824" + name: '绩溪县', + code: '341824', }, { - "name":"旌德县", - "code":"341825" + name: '旌德县', + code: '341825', }, { - "name":"宁国市", - "code":"341881" - } - ] - } - ] + name: '宁国市', + code: '341881', + }, + ], + }, + ], }, { - "name":"福建省", - "code":"350000", - "sub":[ + name: '福建省', + code: '350000', + sub: [ { - "name":"福州市", - "code":"350100", - "sub":[ + name: '福州市', + code: '350100', + sub: [ { - "name":"市辖区", - "code":"350101" + name: '市辖区', + code: '350101', }, { - "name":"鼓楼区", - "code":"350102" + name: '鼓楼区', + code: '350102', }, { - "name":"台江区", - "code":"350103" + name: '台江区', + code: '350103', }, { - "name":"仓山区", - "code":"350104" + name: '仓山区', + code: '350104', }, { - "name":"马尾区", - "code":"350105" + name: '马尾区', + code: '350105', }, { - "name":"晋安区", - "code":"350111" + name: '晋安区', + code: '350111', }, { - "name":"闽侯县", - "code":"350121" + name: '闽侯县', + code: '350121', }, { - "name":"连江县", - "code":"350122" + name: '连江县', + code: '350122', }, { - "name":"罗源县", - "code":"350123" + name: '罗源县', + code: '350123', }, { - "name":"闽清县", - "code":"350124" + name: '闽清县', + code: '350124', }, { - "name":"永泰县", - "code":"350125" + name: '永泰县', + code: '350125', }, { - "name":"平潭县", - "code":"350128" + name: '平潭县', + code: '350128', }, { - "name":"福清市", - "code":"350181" + name: '福清市', + code: '350181', }, { - "name":"长乐市", - "code":"350182" - } - ] + name: '长乐市', + code: '350182', + }, + ], }, { - "name":"厦门市", - "code":"350200", - "sub":[ + name: '厦门市', + code: '350200', + sub: [ { - "name":"市辖区", - "code":"350201" + name: '市辖区', + code: '350201', }, { - "name":"思明区", - "code":"350203" + name: '思明区', + code: '350203', }, { - "name":"海沧区", - "code":"350205" + name: '海沧区', + code: '350205', }, { - "name":"湖里区", - "code":"350206" + name: '湖里区', + code: '350206', }, { - "name":"集美区", - "code":"350211" + name: '集美区', + code: '350211', }, { - "name":"同安区", - "code":"350212" + name: '同安区', + code: '350212', }, { - "name":"翔安区", - "code":"350213" - } - ] + name: '翔安区', + code: '350213', + }, + ], }, { - "name":"莆田市", - "code":"350300", - "sub":[ + name: '莆田市', + code: '350300', + sub: [ { - "name":"市辖区", - "code":"350301" + name: '市辖区', + code: '350301', }, { - "name":"城厢区", - "code":"350302" + name: '城厢区', + code: '350302', }, { - "name":"涵江区", - "code":"350303" + name: '涵江区', + code: '350303', }, { - "name":"荔城区", - "code":"350304" + name: '荔城区', + code: '350304', }, { - "name":"秀屿区", - "code":"350305" + name: '秀屿区', + code: '350305', }, { - "name":"仙游县", - "code":"350322" - } - ] + name: '仙游县', + code: '350322', + }, + ], }, { - "name":"三明市", - "code":"350400", - "sub":[ + name: '三明市', + code: '350400', + sub: [ { - "name":"市辖区", - "code":"350401" + name: '市辖区', + code: '350401', }, { - "name":"梅列区", - "code":"350402" + name: '梅列区', + code: '350402', }, { - "name":"三元区", - "code":"350403" + name: '三元区', + code: '350403', }, { - "name":"明溪县", - "code":"350421" + name: '明溪县', + code: '350421', }, { - "name":"清流县", - "code":"350423" + name: '清流县', + code: '350423', }, { - "name":"宁化县", - "code":"350424" + name: '宁化县', + code: '350424', }, { - "name":"大田县", - "code":"350425" + name: '大田县', + code: '350425', }, { - "name":"尤溪县", - "code":"350426" + name: '尤溪县', + code: '350426', }, { - "name":"沙县", - "code":"350427" + name: '沙县', + code: '350427', }, { - "name":"将乐县", - "code":"350428" + name: '将乐县', + code: '350428', }, { - "name":"泰宁县", - "code":"350429" + name: '泰宁县', + code: '350429', }, { - "name":"建宁县", - "code":"350430" + name: '建宁县', + code: '350430', }, { - "name":"永安市", - "code":"350481" - } - ] + name: '永安市', + code: '350481', + }, + ], }, { - "name":"泉州市", - "code":"350500", - "sub":[ + name: '泉州市', + code: '350500', + sub: [ { - "name":"市辖区", - "code":"350501" + name: '市辖区', + code: '350501', }, { - "name":"鲤城区", - "code":"350502" + name: '鲤城区', + code: '350502', }, { - "name":"丰泽区", - "code":"350503" + name: '丰泽区', + code: '350503', }, { - "name":"洛江区", - "code":"350504" + name: '洛江区', + code: '350504', }, { - "name":"泉港区", - "code":"350505" + name: '泉港区', + code: '350505', }, { - "name":"惠安县", - "code":"350521" + name: '惠安县', + code: '350521', }, { - "name":"安溪县", - "code":"350524" + name: '安溪县', + code: '350524', }, { - "name":"永春县", - "code":"350525" + name: '永春县', + code: '350525', }, { - "name":"德化县", - "code":"350526" + name: '德化县', + code: '350526', }, { - "name":"金门县", - "code":"350527" + name: '金门县', + code: '350527', }, { - "name":"石狮市", - "code":"350581" + name: '石狮市', + code: '350581', }, { - "name":"晋江市", - "code":"350582" + name: '晋江市', + code: '350582', }, { - "name":"南安市", - "code":"350583" - } - ] + name: '南安市', + code: '350583', + }, + ], }, { - "name":"漳州市", - "code":"350600", - "sub":[ + name: '漳州市', + code: '350600', + sub: [ { - "name":"市辖区", - "code":"350601" + name: '市辖区', + code: '350601', }, { - "name":"芗城区", - "code":"350602" + name: '芗城区', + code: '350602', }, { - "name":"龙文区", - "code":"350603" + name: '龙文区', + code: '350603', }, { - "name":"云霄县", - "code":"350622" + name: '云霄县', + code: '350622', }, { - "name":"漳浦县", - "code":"350623" + name: '漳浦县', + code: '350623', }, { - "name":"诏安县", - "code":"350624" + name: '诏安县', + code: '350624', }, { - "name":"长泰县", - "code":"350625" + name: '长泰县', + code: '350625', }, { - "name":"东山县", - "code":"350626" + name: '东山县', + code: '350626', }, { - "name":"南靖县", - "code":"350627" + name: '南靖县', + code: '350627', }, { - "name":"平和县", - "code":"350628" + name: '平和县', + code: '350628', }, { - "name":"华安县", - "code":"350629" + name: '华安县', + code: '350629', }, { - "name":"龙海市", - "code":"350681" - } - ] + name: '龙海市', + code: '350681', + }, + ], }, { - "name":"南平市", - "code":"350700", - "sub":[ + name: '南平市', + code: '350700', + sub: [ { - "name":"市辖区", - "code":"350701" + name: '市辖区', + code: '350701', }, { - "name":"延平区", - "code":"350702" + name: '延平区', + code: '350702', }, { - "name":"建阳区", - "code":"350703" + name: '建阳区', + code: '350703', }, { - "name":"顺昌县", - "code":"350721" + name: '顺昌县', + code: '350721', }, { - "name":"浦城县", - "code":"350722" + name: '浦城县', + code: '350722', }, { - "name":"光泽县", - "code":"350723" + name: '光泽县', + code: '350723', }, { - "name":"松溪县", - "code":"350724" + name: '松溪县', + code: '350724', }, { - "name":"政和县", - "code":"350725" + name: '政和县', + code: '350725', }, { - "name":"邵武市", - "code":"350781" + name: '邵武市', + code: '350781', }, { - "name":"武夷山市", - "code":"350782" + name: '武夷山市', + code: '350782', }, { - "name":"建瓯市", - "code":"350783" - } - ] + name: '建瓯市', + code: '350783', + }, + ], }, { - "name":"龙岩市", - "code":"350800", - "sub":[ + name: '龙岩市', + code: '350800', + sub: [ { - "name":"市辖区", - "code":"350801" + name: '市辖区', + code: '350801', }, { - "name":"新罗区", - "code":"350802" + name: '新罗区', + code: '350802', }, { - "name":"永定区", - "code":"350803" + name: '永定区', + code: '350803', }, { - "name":"长汀县", - "code":"350821" + name: '长汀县', + code: '350821', }, { - "name":"上杭县", - "code":"350823" + name: '上杭县', + code: '350823', }, { - "name":"武平县", - "code":"350824" + name: '武平县', + code: '350824', }, { - "name":"连城县", - "code":"350825" + name: '连城县', + code: '350825', }, { - "name":"漳平市", - "code":"350881" - } - ] + name: '漳平市', + code: '350881', + }, + ], }, { - "name":"宁德市", - "code":"350900", - "sub":[ + name: '宁德市', + code: '350900', + sub: [ { - "name":"市辖区", - "code":"350901" + name: '市辖区', + code: '350901', }, { - "name":"蕉城区", - "code":"350902" + name: '蕉城区', + code: '350902', }, { - "name":"霞浦县", - "code":"350921" + name: '霞浦县', + code: '350921', }, { - "name":"古田县", - "code":"350922" + name: '古田县', + code: '350922', }, { - "name":"屏南县", - "code":"350923" + name: '屏南县', + code: '350923', }, { - "name":"寿宁县", - "code":"350924" + name: '寿宁县', + code: '350924', }, { - "name":"周宁县", - "code":"350925" + name: '周宁县', + code: '350925', }, { - "name":"柘荣县", - "code":"350926" + name: '柘荣县', + code: '350926', }, { - "name":"福安市", - "code":"350981" + name: '福安市', + code: '350981', }, { - "name":"福鼎市", - "code":"350982" - } - ] - } - ] + name: '福鼎市', + code: '350982', + }, + ], + }, + ], }, { - "name":"江西省", - "code":"360000", - "sub":[ + name: '江西省', + code: '360000', + sub: [ { - "name":"南昌市", - "code":"360100", - "sub":[ + name: '南昌市', + code: '360100', + sub: [ { - "name":"市辖区", - "code":"360101" + name: '市辖区', + code: '360101', }, { - "name":"东湖区", - "code":"360102" + name: '东湖区', + code: '360102', }, { - "name":"西湖区", - "code":"360103" + name: '西湖区', + code: '360103', }, { - "name":"青云谱区", - "code":"360104" + name: '青云谱区', + code: '360104', }, { - "name":"湾里区", - "code":"360105" + name: '湾里区', + code: '360105', }, { - "name":"青山湖区", - "code":"360111" + name: '青山湖区', + code: '360111', }, { - "name":"南昌县", - "code":"360121" + name: '南昌县', + code: '360121', }, { - "name":"新建县", - "code":"360122" + name: '新建县', + code: '360122', }, { - "name":"安义县", - "code":"360123" + name: '安义县', + code: '360123', }, { - "name":"进贤县", - "code":"360124" - } - ] + name: '进贤县', + code: '360124', + }, + ], }, { - "name":"景德镇市", - "code":"360200", - "sub":[ + name: '景德镇市', + code: '360200', + sub: [ { - "name":"市辖区", - "code":"360201" + name: '市辖区', + code: '360201', }, { - "name":"昌江区", - "code":"360202" + name: '昌江区', + code: '360202', }, { - "name":"珠山区", - "code":"360203" + name: '珠山区', + code: '360203', }, { - "name":"浮梁县", - "code":"360222" + name: '浮梁县', + code: '360222', }, { - "name":"乐平市", - "code":"360281" - } - ] + name: '乐平市', + code: '360281', + }, + ], }, { - "name":"萍乡市", - "code":"360300", - "sub":[ + name: '萍乡市', + code: '360300', + sub: [ { - "name":"市辖区", - "code":"360301" + name: '市辖区', + code: '360301', }, { - "name":"安源区", - "code":"360302" + name: '安源区', + code: '360302', }, { - "name":"湘东区", - "code":"360313" + name: '湘东区', + code: '360313', }, { - "name":"莲花县", - "code":"360321" + name: '莲花县', + code: '360321', }, { - "name":"上栗县", - "code":"360322" + name: '上栗县', + code: '360322', }, { - "name":"芦溪县", - "code":"360323" - } - ] + name: '芦溪县', + code: '360323', + }, + ], }, { - "name":"九江市", - "code":"360400", - "sub":[ + name: '九江市', + code: '360400', + sub: [ { - "name":"市辖区", - "code":"360401" + name: '市辖区', + code: '360401', }, { - "name":"庐山区", - "code":"360402" + name: '庐山区', + code: '360402', }, { - "name":"浔阳区", - "code":"360403" + name: '浔阳区', + code: '360403', }, { - "name":"九江县", - "code":"360421" + name: '九江县', + code: '360421', }, { - "name":"武宁县", - "code":"360423" + name: '武宁县', + code: '360423', }, { - "name":"修水县", - "code":"360424" + name: '修水县', + code: '360424', }, { - "name":"永修县", - "code":"360425" + name: '永修县', + code: '360425', }, { - "name":"德安县", - "code":"360426" + name: '德安县', + code: '360426', }, { - "name":"星子县", - "code":"360427" + name: '星子县', + code: '360427', }, { - "name":"都昌县", - "code":"360428" + name: '都昌县', + code: '360428', }, { - "name":"湖口县", - "code":"360429" + name: '湖口县', + code: '360429', }, { - "name":"彭泽县", - "code":"360430" + name: '彭泽县', + code: '360430', }, { - "name":"瑞昌市", - "code":"360481" + name: '瑞昌市', + code: '360481', }, { - "name":"共青城市", - "code":"360482" - } - ] + name: '共青城市', + code: '360482', + }, + ], }, { - "name":"新余市", - "code":"360500", - "sub":[ + name: '新余市', + code: '360500', + sub: [ { - "name":"市辖区", - "code":"360501" + name: '市辖区', + code: '360501', }, { - "name":"渝水区", - "code":"360502" + name: '渝水区', + code: '360502', }, { - "name":"分宜县", - "code":"360521" - } - ] + name: '分宜县', + code: '360521', + }, + ], }, { - "name":"鹰潭市", - "code":"360600", - "sub":[ + name: '鹰潭市', + code: '360600', + sub: [ { - "name":"市辖区", - "code":"360601" + name: '市辖区', + code: '360601', }, { - "name":"月湖区", - "code":"360602" + name: '月湖区', + code: '360602', }, { - "name":"余江县", - "code":"360622" + name: '余江县', + code: '360622', }, { - "name":"贵溪市", - "code":"360681" - } - ] + name: '贵溪市', + code: '360681', + }, + ], }, { - "name":"赣州市", - "code":"360700", - "sub":[ + name: '赣州市', + code: '360700', + sub: [ { - "name":"市辖区", - "code":"360701" + name: '市辖区', + code: '360701', }, { - "name":"章贡区", - "code":"360702" + name: '章贡区', + code: '360702', }, { - "name":"南康区", - "code":"360703" + name: '南康区', + code: '360703', }, { - "name":"赣县", - "code":"360721" + name: '赣县', + code: '360721', }, { - "name":"信丰县", - "code":"360722" + name: '信丰县', + code: '360722', }, { - "name":"大余县", - "code":"360723" + name: '大余县', + code: '360723', }, { - "name":"上犹县", - "code":"360724" + name: '上犹县', + code: '360724', }, { - "name":"崇义县", - "code":"360725" + name: '崇义县', + code: '360725', }, { - "name":"安远县", - "code":"360726" + name: '安远县', + code: '360726', }, { - "name":"龙南县", - "code":"360727" + name: '龙南县', + code: '360727', }, { - "name":"定南县", - "code":"360728" + name: '定南县', + code: '360728', }, { - "name":"全南县", - "code":"360729" + name: '全南县', + code: '360729', }, { - "name":"宁都县", - "code":"360730" + name: '宁都县', + code: '360730', }, { - "name":"于都县", - "code":"360731" + name: '于都县', + code: '360731', }, { - "name":"兴国县", - "code":"360732" + name: '兴国县', + code: '360732', }, { - "name":"会昌县", - "code":"360733" + name: '会昌县', + code: '360733', }, { - "name":"寻乌县", - "code":"360734" + name: '寻乌县', + code: '360734', }, { - "name":"石城县", - "code":"360735" + name: '石城县', + code: '360735', }, { - "name":"瑞金市", - "code":"360781" - } - ] + name: '瑞金市', + code: '360781', + }, + ], }, { - "name":"吉安市", - "code":"360800", - "sub":[ + name: '吉安市', + code: '360800', + sub: [ { - "name":"市辖区", - "code":"360801" + name: '市辖区', + code: '360801', }, { - "name":"吉州区", - "code":"360802" + name: '吉州区', + code: '360802', }, { - "name":"青原区", - "code":"360803" + name: '青原区', + code: '360803', }, { - "name":"吉安县", - "code":"360821" + name: '吉安县', + code: '360821', }, { - "name":"吉水县", - "code":"360822" + name: '吉水县', + code: '360822', }, { - "name":"峡江县", - "code":"360823" + name: '峡江县', + code: '360823', }, { - "name":"新干县", - "code":"360824" + name: '新干县', + code: '360824', }, { - "name":"永丰县", - "code":"360825" + name: '永丰县', + code: '360825', }, { - "name":"泰和县", - "code":"360826" + name: '泰和县', + code: '360826', }, { - "name":"遂川县", - "code":"360827" + name: '遂川县', + code: '360827', }, { - "name":"万安县", - "code":"360828" + name: '万安县', + code: '360828', }, { - "name":"安福县", - "code":"360829" + name: '安福县', + code: '360829', }, { - "name":"永新县", - "code":"360830" + name: '永新县', + code: '360830', }, { - "name":"井冈山市", - "code":"360881" - } - ] + name: '井冈山市', + code: '360881', + }, + ], }, { - "name":"宜春市", - "code":"360900", - "sub":[ + name: '宜春市', + code: '360900', + sub: [ { - "name":"市辖区", - "code":"360901" + name: '市辖区', + code: '360901', }, { - "name":"袁州区", - "code":"360902" + name: '袁州区', + code: '360902', }, { - "name":"奉新县", - "code":"360921" + name: '奉新县', + code: '360921', }, { - "name":"万载县", - "code":"360922" + name: '万载县', + code: '360922', }, { - "name":"上高县", - "code":"360923" + name: '上高县', + code: '360923', }, { - "name":"宜丰县", - "code":"360924" + name: '宜丰县', + code: '360924', }, { - "name":"靖安县", - "code":"360925" + name: '靖安县', + code: '360925', }, { - "name":"铜鼓县", - "code":"360926" + name: '铜鼓县', + code: '360926', }, { - "name":"丰城市", - "code":"360981" + name: '丰城市', + code: '360981', }, { - "name":"樟树市", - "code":"360982" + name: '樟树市', + code: '360982', }, { - "name":"高安市", - "code":"360983" - } - ] + name: '高安市', + code: '360983', + }, + ], }, { - "name":"抚州市", - "code":"361000", - "sub":[ + name: '抚州市', + code: '361000', + sub: [ { - "name":"市辖区", - "code":"361001" + name: '市辖区', + code: '361001', }, { - "name":"临川区", - "code":"361002" + name: '临川区', + code: '361002', }, { - "name":"南城县", - "code":"361021" + name: '南城县', + code: '361021', }, { - "name":"黎川县", - "code":"361022" + name: '黎川县', + code: '361022', }, { - "name":"南丰县", - "code":"361023" + name: '南丰县', + code: '361023', }, { - "name":"崇仁县", - "code":"361024" + name: '崇仁县', + code: '361024', }, { - "name":"乐安县", - "code":"361025" + name: '乐安县', + code: '361025', }, { - "name":"宜黄县", - "code":"361026" + name: '宜黄县', + code: '361026', }, { - "name":"金溪县", - "code":"361027" + name: '金溪县', + code: '361027', }, { - "name":"资溪县", - "code":"361028" + name: '资溪县', + code: '361028', }, { - "name":"东乡县", - "code":"361029" + name: '东乡县', + code: '361029', }, { - "name":"广昌县", - "code":"361030" - } - ] + name: '广昌县', + code: '361030', + }, + ], }, { - "name":"上饶市", - "code":"361100", - "sub":[ + name: '上饶市', + code: '361100', + sub: [ { - "name":"市辖区", - "code":"361101" + name: '市辖区', + code: '361101', }, { - "name":"信州区", - "code":"361102" + name: '信州区', + code: '361102', }, { - "name":"上饶县", - "code":"361121" + name: '上饶县', + code: '361121', }, { - "name":"广丰县", - "code":"361122" + name: '广丰县', + code: '361122', }, { - "name":"玉山县", - "code":"361123" + name: '玉山县', + code: '361123', }, { - "name":"铅山县", - "code":"361124" + name: '铅山县', + code: '361124', }, { - "name":"横峰县", - "code":"361125" + name: '横峰县', + code: '361125', }, { - "name":"弋阳县", - "code":"361126" + name: '弋阳县', + code: '361126', }, { - "name":"余干县", - "code":"361127" + name: '余干县', + code: '361127', }, { - "name":"鄱阳县", - "code":"361128" + name: '鄱阳县', + code: '361128', }, { - "name":"万年县", - "code":"361129" + name: '万年县', + code: '361129', }, { - "name":"婺源县", - "code":"361130" + name: '婺源县', + code: '361130', }, { - "name":"德兴市", - "code":"361181" - } - ] - } - ] + name: '德兴市', + code: '361181', + }, + ], + }, + ], }, { - "name":"山东省", - "code":"370000", - "sub":[ + name: '山东省', + code: '370000', + sub: [ { - "name":"济南市", - "code":"370100", - "sub":[ + name: '济南市', + code: '370100', + sub: [ { - "name":"市辖区", - "code":"370101" + name: '市辖区', + code: '370101', }, { - "name":"历下区", - "code":"370102" + name: '历下区', + code: '370102', }, { - "name":"市中区", - "code":"370103" + name: '市中区', + code: '370103', }, { - "name":"槐荫区", - "code":"370104" + name: '槐荫区', + code: '370104', }, { - "name":"天桥区", - "code":"370105" + name: '天桥区', + code: '370105', }, { - "name":"历城区", - "code":"370112" + name: '历城区', + code: '370112', }, { - "name":"长清区", - "code":"370113" + name: '长清区', + code: '370113', }, { - "name":"平阴县", - "code":"370124" + name: '平阴县', + code: '370124', }, { - "name":"济阳县", - "code":"370125" + name: '济阳县', + code: '370125', }, { - "name":"商河县", - "code":"370126" + name: '商河县', + code: '370126', }, { - "name":"章丘市", - "code":"370181" - } - ] + name: '章丘市', + code: '370181', + }, + ], }, { - "name":"青岛市", - "code":"370200", - "sub":[ + name: '青岛市', + code: '370200', + sub: [ { - "name":"市辖区", - "code":"370201" + name: '市辖区', + code: '370201', }, { - "name":"市南区", - "code":"370202" + name: '市南区', + code: '370202', }, { - "name":"市北区", - "code":"370203" + name: '市北区', + code: '370203', }, { - "name":"黄岛区", - "code":"370211" + name: '黄岛区', + code: '370211', }, { - "name":"崂山区", - "code":"370212" + name: '崂山区', + code: '370212', }, { - "name":"李沧区", - "code":"370213" + name: '李沧区', + code: '370213', }, { - "name":"城阳区", - "code":"370214" + name: '城阳区', + code: '370214', }, { - "name":"胶州市", - "code":"370281" + name: '胶州市', + code: '370281', }, { - "name":"即墨市", - "code":"370282" + name: '即墨市', + code: '370282', }, { - "name":"平度市", - "code":"370283" + name: '平度市', + code: '370283', }, { - "name":"莱西市", - "code":"370285" - } - ] + name: '莱西市', + code: '370285', + }, + ], }, { - "name":"淄博市", - "code":"370300", - "sub":[ + name: '淄博市', + code: '370300', + sub: [ { - "name":"市辖区", - "code":"370301" + name: '市辖区', + code: '370301', }, { - "name":"淄川区", - "code":"370302" + name: '淄川区', + code: '370302', }, { - "name":"张店区", - "code":"370303" + name: '张店区', + code: '370303', }, { - "name":"博山区", - "code":"370304" + name: '博山区', + code: '370304', }, { - "name":"临淄区", - "code":"370305" + name: '临淄区', + code: '370305', }, { - "name":"周村区", - "code":"370306" + name: '周村区', + code: '370306', }, { - "name":"桓台县", - "code":"370321" + name: '桓台县', + code: '370321', }, { - "name":"高青县", - "code":"370322" + name: '高青县', + code: '370322', }, { - "name":"沂源县", - "code":"370323" - } - ] + name: '沂源县', + code: '370323', + }, + ], }, { - "name":"枣庄市", - "code":"370400", - "sub":[ + name: '枣庄市', + code: '370400', + sub: [ { - "name":"市辖区", - "code":"370401" + name: '市辖区', + code: '370401', }, { - "name":"市中区", - "code":"370402" + name: '市中区', + code: '370402', }, { - "name":"薛城区", - "code":"370403" + name: '薛城区', + code: '370403', }, { - "name":"峄城区", - "code":"370404" + name: '峄城区', + code: '370404', }, { - "name":"台儿庄区", - "code":"370405" + name: '台儿庄区', + code: '370405', }, { - "name":"山亭区", - "code":"370406" + name: '山亭区', + code: '370406', }, { - "name":"滕州市", - "code":"370481" - } - ] + name: '滕州市', + code: '370481', + }, + ], }, { - "name":"东营市", - "code":"370500", - "sub":[ + name: '东营市', + code: '370500', + sub: [ { - "name":"市辖区", - "code":"370501" + name: '市辖区', + code: '370501', }, { - "name":"东营区", - "code":"370502" + name: '东营区', + code: '370502', }, { - "name":"河口区", - "code":"370503" + name: '河口区', + code: '370503', }, { - "name":"垦利县", - "code":"370521" + name: '垦利县', + code: '370521', }, { - "name":"利津县", - "code":"370522" + name: '利津县', + code: '370522', }, { - "name":"广饶县", - "code":"370523" - } - ] + name: '广饶县', + code: '370523', + }, + ], }, { - "name":"烟台市", - "code":"370600", - "sub":[ + name: '烟台市', + code: '370600', + sub: [ { - "name":"市辖区", - "code":"370601" + name: '市辖区', + code: '370601', }, { - "name":"芝罘区", - "code":"370602" + name: '芝罘区', + code: '370602', }, { - "name":"福山区", - "code":"370611" + name: '福山区', + code: '370611', }, { - "name":"牟平区", - "code":"370612" + name: '牟平区', + code: '370612', }, { - "name":"莱山区", - "code":"370613" + name: '莱山区', + code: '370613', }, { - "name":"长岛县", - "code":"370634" + name: '长岛县', + code: '370634', }, { - "name":"龙口市", - "code":"370681" + name: '龙口市', + code: '370681', }, { - "name":"莱阳市", - "code":"370682" + name: '莱阳市', + code: '370682', }, { - "name":"莱州市", - "code":"370683" + name: '莱州市', + code: '370683', }, { - "name":"蓬莱市", - "code":"370684" + name: '蓬莱市', + code: '370684', }, { - "name":"招远市", - "code":"370685" + name: '招远市', + code: '370685', }, { - "name":"栖霞市", - "code":"370686" + name: '栖霞市', + code: '370686', }, { - "name":"海阳市", - "code":"370687" - } - ] + name: '海阳市', + code: '370687', + }, + ], }, { - "name":"潍坊市", - "code":"370700", - "sub":[ + name: '潍坊市', + code: '370700', + sub: [ { - "name":"市辖区", - "code":"370701" + name: '市辖区', + code: '370701', }, { - "name":"潍城区", - "code":"370702" + name: '潍城区', + code: '370702', }, { - "name":"寒亭区", - "code":"370703" + name: '寒亭区', + code: '370703', }, { - "name":"坊子区", - "code":"370704" + name: '坊子区', + code: '370704', }, { - "name":"奎文区", - "code":"370705" + name: '奎文区', + code: '370705', }, { - "name":"临朐县", - "code":"370724" + name: '临朐县', + code: '370724', }, { - "name":"昌乐县", - "code":"370725" + name: '昌乐县', + code: '370725', }, { - "name":"青州市", - "code":"370781" + name: '青州市', + code: '370781', }, { - "name":"诸城市", - "code":"370782" + name: '诸城市', + code: '370782', }, { - "name":"寿光市", - "code":"370783" + name: '寿光市', + code: '370783', }, { - "name":"安丘市", - "code":"370784" + name: '安丘市', + code: '370784', }, { - "name":"高密市", - "code":"370785" + name: '高密市', + code: '370785', }, { - "name":"昌邑市", - "code":"370786" - } - ] + name: '昌邑市', + code: '370786', + }, + ], }, { - "name":"济宁市", - "code":"370800", - "sub":[ + name: '济宁市', + code: '370800', + sub: [ { - "name":"市辖区", - "code":"370801" + name: '市辖区', + code: '370801', }, { - "name":"任城区", - "code":"370811" + name: '任城区', + code: '370811', }, { - "name":"兖州区", - "code":"370812" + name: '兖州区', + code: '370812', }, { - "name":"微山县", - "code":"370826" + name: '微山县', + code: '370826', }, { - "name":"鱼台县", - "code":"370827" + name: '鱼台县', + code: '370827', }, { - "name":"金乡县", - "code":"370828" + name: '金乡县', + code: '370828', }, { - "name":"嘉祥县", - "code":"370829" + name: '嘉祥县', + code: '370829', }, { - "name":"汶上县", - "code":"370830" + name: '汶上县', + code: '370830', }, { - "name":"泗水县", - "code":"370831" + name: '泗水县', + code: '370831', }, { - "name":"梁山县", - "code":"370832" + name: '梁山县', + code: '370832', }, { - "name":"曲阜市", - "code":"370881" + name: '曲阜市', + code: '370881', }, { - "name":"邹城市", - "code":"370883" - } - ] + name: '邹城市', + code: '370883', + }, + ], }, { - "name":"泰安市", - "code":"370900", - "sub":[ + name: '泰安市', + code: '370900', + sub: [ { - "name":"市辖区", - "code":"370901" + name: '市辖区', + code: '370901', }, { - "name":"泰山区", - "code":"370902" + name: '泰山区', + code: '370902', }, { - "name":"岱岳区", - "code":"370911" + name: '岱岳区', + code: '370911', }, { - "name":"宁阳县", - "code":"370921" + name: '宁阳县', + code: '370921', }, { - "name":"东平县", - "code":"370923" + name: '东平县', + code: '370923', }, { - "name":"新泰市", - "code":"370982" + name: '新泰市', + code: '370982', }, { - "name":"肥城市", - "code":"370983" - } - ] + name: '肥城市', + code: '370983', + }, + ], }, { - "name":"威海市", - "code":"371000", - "sub":[ + name: '威海市', + code: '371000', + sub: [ { - "name":"市辖区", - "code":"371001" + name: '市辖区', + code: '371001', }, { - "name":"环翠区", - "code":"371002" + name: '环翠区', + code: '371002', }, { - "name":"文登市", - "code":"371081" + name: '文登市', + code: '371081', }, { - "name":"荣成市", - "code":"371082" + name: '荣成市', + code: '371082', }, { - "name":"乳山市", - "code":"371083" - } - ] + name: '乳山市', + code: '371083', + }, + ], }, { - "name":"日照市", - "code":"371100", - "sub":[ + name: '日照市', + code: '371100', + sub: [ { - "name":"市辖区", - "code":"371101" + name: '市辖区', + code: '371101', }, { - "name":"东港区", - "code":"371102" + name: '东港区', + code: '371102', }, { - "name":"岚山区", - "code":"371103" + name: '岚山区', + code: '371103', }, { - "name":"五莲县", - "code":"371121" + name: '五莲县', + code: '371121', }, { - "name":"莒县", - "code":"371122" - } - ] + name: '莒县', + code: '371122', + }, + ], }, { - "name":"莱芜市", - "code":"371200", - "sub":[ + name: '莱芜市', + code: '371200', + sub: [ { - "name":"市辖区", - "code":"371201" + name: '市辖区', + code: '371201', }, { - "name":"莱城区", - "code":"371202" + name: '莱城区', + code: '371202', }, { - "name":"钢城区", - "code":"371203" - } - ] + name: '钢城区', + code: '371203', + }, + ], }, { - "name":"临沂市", - "code":"371300", - "sub":[ + name: '临沂市', + code: '371300', + sub: [ { - "name":"市辖区", - "code":"371301" + name: '市辖区', + code: '371301', }, { - "name":"兰山区", - "code":"371302" + name: '兰山区', + code: '371302', }, { - "name":"罗庄区", - "code":"371311" + name: '罗庄区', + code: '371311', }, { - "name":"河东区", - "code":"371312" + name: '河东区', + code: '371312', }, { - "name":"沂南县", - "code":"371321" + name: '沂南县', + code: '371321', }, { - "name":"郯城县", - "code":"371322" + name: '郯城县', + code: '371322', }, { - "name":"沂水县", - "code":"371323" + name: '沂水县', + code: '371323', }, { - "name":"兰陵县", - "code":"371324" + name: '兰陵县', + code: '371324', }, { - "name":"费县", - "code":"371325" + name: '费县', + code: '371325', }, { - "name":"平邑县", - "code":"371326" + name: '平邑县', + code: '371326', }, { - "name":"莒南县", - "code":"371327" + name: '莒南县', + code: '371327', }, { - "name":"蒙阴县", - "code":"371328" + name: '蒙阴县', + code: '371328', }, { - "name":"临沭县", - "code":"371329" - } - ] + name: '临沭县', + code: '371329', + }, + ], }, { - "name":"德州市", - "code":"371400", - "sub":[ + name: '德州市', + code: '371400', + sub: [ { - "name":"市辖区", - "code":"371401" + name: '市辖区', + code: '371401', }, { - "name":"德城区", - "code":"371402" + name: '德城区', + code: '371402', }, { - "name":"陵城区", - "code":"371403" + name: '陵城区', + code: '371403', }, { - "name":"宁津县", - "code":"371422" + name: '宁津县', + code: '371422', }, { - "name":"庆云县", - "code":"371423" + name: '庆云县', + code: '371423', }, { - "name":"临邑县", - "code":"371424" + name: '临邑县', + code: '371424', }, { - "name":"齐河县", - "code":"371425" + name: '齐河县', + code: '371425', }, { - "name":"平原县", - "code":"371426" + name: '平原县', + code: '371426', }, { - "name":"夏津县", - "code":"371427" + name: '夏津县', + code: '371427', }, { - "name":"武城县", - "code":"371428" + name: '武城县', + code: '371428', }, { - "name":"乐陵市", - "code":"371481" + name: '乐陵市', + code: '371481', }, { - "name":"禹城市", - "code":"371482" - } - ] + name: '禹城市', + code: '371482', + }, + ], }, { - "name":"聊城市", - "code":"371500", - "sub":[ + name: '聊城市', + code: '371500', + sub: [ { - "name":"市辖区", - "code":"371501" + name: '市辖区', + code: '371501', }, { - "name":"东昌府区", - "code":"371502" + name: '东昌府区', + code: '371502', }, { - "name":"阳谷县", - "code":"371521" + name: '阳谷县', + code: '371521', }, { - "name":"莘县", - "code":"371522" + name: '莘县', + code: '371522', }, { - "name":"茌平县", - "code":"371523" + name: '茌平县', + code: '371523', }, { - "name":"东阿县", - "code":"371524" + name: '东阿县', + code: '371524', }, { - "name":"冠县", - "code":"371525" + name: '冠县', + code: '371525', }, { - "name":"高唐县", - "code":"371526" + name: '高唐县', + code: '371526', }, { - "name":"临清市", - "code":"371581" - } - ] + name: '临清市', + code: '371581', + }, + ], }, { - "name":"滨州市", - "code":"371600", - "sub":[ + name: '滨州市', + code: '371600', + sub: [ { - "name":"市辖区", - "code":"371601" + name: '市辖区', + code: '371601', }, { - "name":"滨城区", - "code":"371602" + name: '滨城区', + code: '371602', }, { - "name":"沾化区", - "code":"371603" + name: '沾化区', + code: '371603', }, { - "name":"惠民县", - "code":"371621" + name: '惠民县', + code: '371621', }, { - "name":"阳信县", - "code":"371622" + name: '阳信县', + code: '371622', }, { - "name":"无棣县", - "code":"371623" + name: '无棣县', + code: '371623', }, { - "name":"博兴县", - "code":"371625" + name: '博兴县', + code: '371625', }, { - "name":"邹平县", - "code":"371626" - } - ] + name: '邹平县', + code: '371626', + }, + ], }, { - "name":"菏泽市", - "code":"371700", - "sub":[ + name: '菏泽市', + code: '371700', + sub: [ { - "name":"市辖区", - "code":"371701" + name: '市辖区', + code: '371701', }, { - "name":"牡丹区", - "code":"371702" + name: '牡丹区', + code: '371702', }, { - "name":"曹县", - "code":"371721" + name: '曹县', + code: '371721', }, { - "name":"单县", - "code":"371722" + name: '单县', + code: '371722', }, { - "name":"成武县", - "code":"371723" + name: '成武县', + code: '371723', }, { - "name":"巨野县", - "code":"371724" + name: '巨野县', + code: '371724', }, { - "name":"郓城县", - "code":"371725" + name: '郓城县', + code: '371725', }, { - "name":"鄄城县", - "code":"371726" + name: '鄄城县', + code: '371726', }, { - "name":"定陶县", - "code":"371727" + name: '定陶县', + code: '371727', }, { - "name":"东明县", - "code":"371728" - } - ] - } - ] + name: '东明县', + code: '371728', + }, + ], + }, + ], }, { - "name":"河南省", - "code":"410000", - "sub":[ + name: '河南省', + code: '410000', + sub: [ { - "name":"郑州市", - "code":"410100", - "sub":[ + name: '郑州市', + code: '410100', + sub: [ { - "name":"市辖区", - "code":"410101" + name: '市辖区', + code: '410101', }, { - "name":"中原区", - "code":"410102" + name: '中原区', + code: '410102', }, { - "name":"二七区", - "code":"410103" + name: '二七区', + code: '410103', }, { - "name":"管城回族区", - "code":"410104" + name: '管城回族区', + code: '410104', }, { - "name":"金水区", - "code":"410105" + name: '金水区', + code: '410105', }, { - "name":"上街区", - "code":"410106" + name: '上街区', + code: '410106', }, { - "name":"惠济区", - "code":"410108" + name: '惠济区', + code: '410108', }, { - "name":"中牟县", - "code":"410122" + name: '中牟县', + code: '410122', }, { - "name":"巩义市", - "code":"410181" + name: '巩义市', + code: '410181', }, { - "name":"荥阳市", - "code":"410182" + name: '荥阳市', + code: '410182', }, { - "name":"新密市", - "code":"410183" + name: '新密市', + code: '410183', }, { - "name":"新郑市", - "code":"410184" + name: '新郑市', + code: '410184', }, { - "name":"登封市", - "code":"410185" - } - ] + name: '登封市', + code: '410185', + }, + ], }, { - "name":"开封市", - "code":"410200", - "sub":[ + name: '开封市', + code: '410200', + sub: [ { - "name":"市辖区", - "code":"410201" + name: '市辖区', + code: '410201', }, { - "name":"龙亭区", - "code":"410202" + name: '龙亭区', + code: '410202', }, { - "name":"顺河回族区", - "code":"410203" + name: '顺河回族区', + code: '410203', }, { - "name":"鼓楼区", - "code":"410204" + name: '鼓楼区', + code: '410204', }, { - "name":"禹王台区", - "code":"410205" + name: '禹王台区', + code: '410205', }, { - "name":"祥符区", - "code":"410212" + name: '祥符区', + code: '410212', }, { - "name":"杞县", - "code":"410221" + name: '杞县', + code: '410221', }, { - "name":"通许县", - "code":"410222" + name: '通许县', + code: '410222', }, { - "name":"尉氏县", - "code":"410223" + name: '尉氏县', + code: '410223', }, { - "name":"兰考县", - "code":"410225" - } - ] + name: '兰考县', + code: '410225', + }, + ], }, { - "name":"洛阳市", - "code":"410300", - "sub":[ + name: '洛阳市', + code: '410300', + sub: [ { - "name":"市辖区", - "code":"410301" + name: '市辖区', + code: '410301', }, { - "name":"老城区", - "code":"410302" + name: '老城区', + code: '410302', }, { - "name":"西工区", - "code":"410303" + name: '西工区', + code: '410303', }, { - "name":"瀍河回族区", - "code":"410304" + name: '瀍河回族区', + code: '410304', }, { - "name":"涧西区", - "code":"410305" + name: '涧西区', + code: '410305', }, { - "name":"吉利区", - "code":"410306" + name: '吉利区', + code: '410306', }, { - "name":"洛龙区", - "code":"410311" + name: '洛龙区', + code: '410311', }, { - "name":"孟津县", - "code":"410322" + name: '孟津县', + code: '410322', }, { - "name":"新安县", - "code":"410323" + name: '新安县', + code: '410323', }, { - "name":"栾川县", - "code":"410324" + name: '栾川县', + code: '410324', }, { - "name":"嵩县", - "code":"410325" + name: '嵩县', + code: '410325', }, { - "name":"汝阳县", - "code":"410326" + name: '汝阳县', + code: '410326', }, { - "name":"宜阳县", - "code":"410327" + name: '宜阳县', + code: '410327', }, { - "name":"洛宁县", - "code":"410328" + name: '洛宁县', + code: '410328', }, { - "name":"伊川县", - "code":"410329" + name: '伊川县', + code: '410329', }, { - "name":"偃师市", - "code":"410381" - } - ] + name: '偃师市', + code: '410381', + }, + ], }, { - "name":"平顶山市", - "code":"410400", - "sub":[ + name: '平顶山市', + code: '410400', + sub: [ { - "name":"市辖区", - "code":"410401" + name: '市辖区', + code: '410401', }, { - "name":"新华区", - "code":"410402" + name: '新华区', + code: '410402', }, { - "name":"卫东区", - "code":"410403" + name: '卫东区', + code: '410403', }, { - "name":"石龙区", - "code":"410404" + name: '石龙区', + code: '410404', }, { - "name":"湛河区", - "code":"410411" + name: '湛河区', + code: '410411', }, { - "name":"宝丰县", - "code":"410421" + name: '宝丰县', + code: '410421', }, { - "name":"叶县", - "code":"410422" + name: '叶县', + code: '410422', }, { - "name":"鲁山县", - "code":"410423" + name: '鲁山县', + code: '410423', }, { - "name":"郏县", - "code":"410425" + name: '郏县', + code: '410425', }, { - "name":"舞钢市", - "code":"410481" + name: '舞钢市', + code: '410481', }, { - "name":"汝州市", - "code":"410482" - } - ] + name: '汝州市', + code: '410482', + }, + ], }, { - "name":"安阳市", - "code":"410500", - "sub":[ + name: '安阳市', + code: '410500', + sub: [ { - "name":"市辖区", - "code":"410501" + name: '市辖区', + code: '410501', }, { - "name":"文峰区", - "code":"410502" + name: '文峰区', + code: '410502', }, { - "name":"北关区", - "code":"410503" + name: '北关区', + code: '410503', }, { - "name":"殷都区", - "code":"410505" + name: '殷都区', + code: '410505', }, { - "name":"龙安区", - "code":"410506" + name: '龙安区', + code: '410506', }, { - "name":"安阳县", - "code":"410522" + name: '安阳县', + code: '410522', }, { - "name":"汤阴县", - "code":"410523" + name: '汤阴县', + code: '410523', }, { - "name":"滑县", - "code":"410526" + name: '滑县', + code: '410526', }, { - "name":"内黄县", - "code":"410527" + name: '内黄县', + code: '410527', }, { - "name":"林州市", - "code":"410581" - } - ] + name: '林州市', + code: '410581', + }, + ], }, { - "name":"鹤壁市", - "code":"410600", - "sub":[ + name: '鹤壁市', + code: '410600', + sub: [ { - "name":"市辖区", - "code":"410601" + name: '市辖区', + code: '410601', }, { - "name":"鹤山区", - "code":"410602" + name: '鹤山区', + code: '410602', }, { - "name":"山城区", - "code":"410603" + name: '山城区', + code: '410603', }, { - "name":"淇滨区", - "code":"410611" + name: '淇滨区', + code: '410611', }, { - "name":"浚县", - "code":"410621" + name: '浚县', + code: '410621', }, { - "name":"淇县", - "code":"410622" - } - ] + name: '淇县', + code: '410622', + }, + ], }, { - "name":"新乡市", - "code":"410700", - "sub":[ + name: '新乡市', + code: '410700', + sub: [ { - "name":"市辖区", - "code":"410701" + name: '市辖区', + code: '410701', }, { - "name":"红旗区", - "code":"410702" + name: '红旗区', + code: '410702', }, { - "name":"卫滨区", - "code":"410703" + name: '卫滨区', + code: '410703', }, { - "name":"凤泉区", - "code":"410704" + name: '凤泉区', + code: '410704', }, { - "name":"牧野区", - "code":"410711" + name: '牧野区', + code: '410711', }, { - "name":"新乡县", - "code":"410721" + name: '新乡县', + code: '410721', }, { - "name":"获嘉县", - "code":"410724" + name: '获嘉县', + code: '410724', }, { - "name":"原阳县", - "code":"410725" + name: '原阳县', + code: '410725', }, { - "name":"延津县", - "code":"410726" + name: '延津县', + code: '410726', }, { - "name":"封丘县", - "code":"410727" + name: '封丘县', + code: '410727', }, { - "name":"长垣县", - "code":"410728" + name: '长垣县', + code: '410728', }, { - "name":"卫辉市", - "code":"410781" + name: '卫辉市', + code: '410781', }, { - "name":"辉县市", - "code":"410782" - } - ] + name: '辉县市', + code: '410782', + }, + ], }, { - "name":"焦作市", - "code":"410800", - "sub":[ + name: '焦作市', + code: '410800', + sub: [ { - "name":"市辖区", - "code":"410801" + name: '市辖区', + code: '410801', }, { - "name":"解放区", - "code":"410802" + name: '解放区', + code: '410802', }, { - "name":"中站区", - "code":"410803" + name: '中站区', + code: '410803', }, { - "name":"马村区", - "code":"410804" + name: '马村区', + code: '410804', }, { - "name":"山阳区", - "code":"410811" + name: '山阳区', + code: '410811', }, { - "name":"修武县", - "code":"410821" + name: '修武县', + code: '410821', }, { - "name":"博爱县", - "code":"410822" + name: '博爱县', + code: '410822', }, { - "name":"武陟县", - "code":"410823" + name: '武陟县', + code: '410823', }, { - "name":"温县", - "code":"410825" + name: '温县', + code: '410825', }, { - "name":"沁阳市", - "code":"410882" + name: '沁阳市', + code: '410882', }, { - "name":"孟州市", - "code":"410883" - } - ] + name: '孟州市', + code: '410883', + }, + ], }, { - "name":"濮阳市", - "code":"410900", - "sub":[ + name: '濮阳市', + code: '410900', + sub: [ { - "name":"市辖区", - "code":"410901" + name: '市辖区', + code: '410901', }, { - "name":"华龙区", - "code":"410902" + name: '华龙区', + code: '410902', }, { - "name":"清丰县", - "code":"410922" + name: '清丰县', + code: '410922', }, { - "name":"南乐县", - "code":"410923" + name: '南乐县', + code: '410923', }, { - "name":"范县", - "code":"410926" + name: '范县', + code: '410926', }, { - "name":"台前县", - "code":"410927" + name: '台前县', + code: '410927', }, { - "name":"濮阳县", - "code":"410928" - } - ] + name: '濮阳县', + code: '410928', + }, + ], }, { - "name":"许昌市", - "code":"411000", - "sub":[ + name: '许昌市', + code: '411000', + sub: [ { - "name":"市辖区", - "code":"411001" + name: '市辖区', + code: '411001', }, { - "name":"魏都区", - "code":"411002" + name: '魏都区', + code: '411002', }, { - "name":"许昌县", - "code":"411023" + name: '许昌县', + code: '411023', }, { - "name":"鄢陵县", - "code":"411024" + name: '鄢陵县', + code: '411024', }, { - "name":"襄城县", - "code":"411025" + name: '襄城县', + code: '411025', }, { - "name":"禹州市", - "code":"411081" + name: '禹州市', + code: '411081', }, { - "name":"长葛市", - "code":"411082" - } - ] + name: '长葛市', + code: '411082', + }, + ], }, { - "name":"漯河市", - "code":"411100", - "sub":[ + name: '漯河市', + code: '411100', + sub: [ { - "name":"市辖区", - "code":"411101" + name: '市辖区', + code: '411101', }, { - "name":"源汇区", - "code":"411102" + name: '源汇区', + code: '411102', }, { - "name":"郾城区", - "code":"411103" + name: '郾城区', + code: '411103', }, { - "name":"召陵区", - "code":"411104" + name: '召陵区', + code: '411104', }, { - "name":"舞阳县", - "code":"411121" + name: '舞阳县', + code: '411121', }, { - "name":"临颍县", - "code":"411122" - } - ] + name: '临颍县', + code: '411122', + }, + ], }, { - "name":"三门峡市", - "code":"411200", - "sub":[ + name: '三门峡市', + code: '411200', + sub: [ { - "name":"市辖区", - "code":"411201" + name: '市辖区', + code: '411201', }, { - "name":"湖滨区", - "code":"411202" + name: '湖滨区', + code: '411202', }, { - "name":"渑池县", - "code":"411221" + name: '渑池县', + code: '411221', }, { - "name":"陕县", - "code":"411222" + name: '陕县', + code: '411222', }, { - "name":"卢氏县", - "code":"411224" + name: '卢氏县', + code: '411224', }, { - "name":"义马市", - "code":"411281" + name: '义马市', + code: '411281', }, { - "name":"灵宝市", - "code":"411282" - } - ] + name: '灵宝市', + code: '411282', + }, + ], }, { - "name":"南阳市", - "code":"411300", - "sub":[ + name: '南阳市', + code: '411300', + sub: [ { - "name":"市辖区", - "code":"411301" + name: '市辖区', + code: '411301', }, { - "name":"宛城区", - "code":"411302" + name: '宛城区', + code: '411302', }, { - "name":"卧龙区", - "code":"411303" + name: '卧龙区', + code: '411303', }, { - "name":"南召县", - "code":"411321" + name: '南召县', + code: '411321', }, { - "name":"方城县", - "code":"411322" + name: '方城县', + code: '411322', }, { - "name":"西峡县", - "code":"411323" + name: '西峡县', + code: '411323', }, { - "name":"镇平县", - "code":"411324" + name: '镇平县', + code: '411324', }, { - "name":"内乡县", - "code":"411325" + name: '内乡县', + code: '411325', }, { - "name":"淅川县", - "code":"411326" + name: '淅川县', + code: '411326', }, { - "name":"社旗县", - "code":"411327" + name: '社旗县', + code: '411327', }, { - "name":"唐河县", - "code":"411328" + name: '唐河县', + code: '411328', }, { - "name":"新野县", - "code":"411329" + name: '新野县', + code: '411329', }, { - "name":"桐柏县", - "code":"411330" + name: '桐柏县', + code: '411330', }, { - "name":"邓州市", - "code":"411381" - } - ] + name: '邓州市', + code: '411381', + }, + ], }, { - "name":"商丘市", - "code":"411400", - "sub":[ + name: '商丘市', + code: '411400', + sub: [ { - "name":"市辖区", - "code":"411401" + name: '市辖区', + code: '411401', }, { - "name":"梁园区", - "code":"411402" + name: '梁园区', + code: '411402', }, { - "name":"睢阳区", - "code":"411403" + name: '睢阳区', + code: '411403', }, { - "name":"民权县", - "code":"411421" + name: '民权县', + code: '411421', }, { - "name":"睢县", - "code":"411422" + name: '睢县', + code: '411422', }, { - "name":"宁陵县", - "code":"411423" + name: '宁陵县', + code: '411423', }, { - "name":"柘城县", - "code":"411424" + name: '柘城县', + code: '411424', }, { - "name":"虞城县", - "code":"411425" + name: '虞城县', + code: '411425', }, { - "name":"夏邑县", - "code":"411426" + name: '夏邑县', + code: '411426', }, { - "name":"永城市", - "code":"411481" - } - ] + name: '永城市', + code: '411481', + }, + ], }, { - "name":"信阳市", - "code":"411500", - "sub":[ + name: '信阳市', + code: '411500', + sub: [ { - "name":"市辖区", - "code":"411501" + name: '市辖区', + code: '411501', }, { - "name":"浉河区", - "code":"411502" + name: '浉河区', + code: '411502', }, { - "name":"平桥区", - "code":"411503" + name: '平桥区', + code: '411503', }, { - "name":"罗山县", - "code":"411521" + name: '罗山县', + code: '411521', }, { - "name":"光山县", - "code":"411522" + name: '光山县', + code: '411522', }, { - "name":"新县", - "code":"411523" + name: '新县', + code: '411523', }, { - "name":"商城县", - "code":"411524" + name: '商城县', + code: '411524', }, { - "name":"固始县", - "code":"411525" + name: '固始县', + code: '411525', }, { - "name":"潢川县", - "code":"411526" + name: '潢川县', + code: '411526', }, { - "name":"淮滨县", - "code":"411527" + name: '淮滨县', + code: '411527', }, { - "name":"息县", - "code":"411528" - } - ] + name: '息县', + code: '411528', + }, + ], }, { - "name":"周口市", - "code":"411600", - "sub":[ + name: '周口市', + code: '411600', + sub: [ { - "name":"市辖区", - "code":"411601" + name: '市辖区', + code: '411601', }, { - "name":"川汇区", - "code":"411602" + name: '川汇区', + code: '411602', }, { - "name":"扶沟县", - "code":"411621" + name: '扶沟县', + code: '411621', }, { - "name":"西华县", - "code":"411622" + name: '西华县', + code: '411622', }, { - "name":"商水县", - "code":"411623" + name: '商水县', + code: '411623', }, { - "name":"沈丘县", - "code":"411624" + name: '沈丘县', + code: '411624', }, { - "name":"郸城县", - "code":"411625" + name: '郸城县', + code: '411625', }, { - "name":"淮阳县", - "code":"411626" + name: '淮阳县', + code: '411626', }, { - "name":"太康县", - "code":"411627" + name: '太康县', + code: '411627', }, { - "name":"鹿邑县", - "code":"411628" + name: '鹿邑县', + code: '411628', }, { - "name":"项城市", - "code":"411681" - } - ] + name: '项城市', + code: '411681', + }, + ], }, { - "name":"驻马店市", - "code":"411700", - "sub":[ + name: '驻马店市', + code: '411700', + sub: [ { - "name":"市辖区", - "code":"411701" + name: '市辖区', + code: '411701', }, { - "name":"驿城区", - "code":"411702" + name: '驿城区', + code: '411702', }, { - "name":"西平县", - "code":"411721" + name: '西平县', + code: '411721', }, { - "name":"上蔡县", - "code":"411722" + name: '上蔡县', + code: '411722', }, { - "name":"平舆县", - "code":"411723" + name: '平舆县', + code: '411723', }, { - "name":"正阳县", - "code":"411724" + name: '正阳县', + code: '411724', }, { - "name":"确山县", - "code":"411725" + name: '确山县', + code: '411725', }, { - "name":"泌阳县", - "code":"411726" + name: '泌阳县', + code: '411726', }, { - "name":"汝南县", - "code":"411727" + name: '汝南县', + code: '411727', }, { - "name":"遂平县", - "code":"411728" + name: '遂平县', + code: '411728', }, { - "name":"新蔡县", - "code":"411729" - } - ] + name: '新蔡县', + code: '411729', + }, + ], }, { - "name":"济源市", - "code":"419001" - } - ] + name: '济源市', + code: '419001', + }, + ], }, { - "name":"湖北省", - "code":"420000", - "sub":[ + name: '湖北省', + code: '420000', + sub: [ { - "name":"武汉市", - "code":"420100", - "sub":[ + name: '武汉市', + code: '420100', + sub: [ { - "name":"市辖区", - "code":"420101" + name: '市辖区', + code: '420101', }, { - "name":"江岸区", - "code":"420102" + name: '江岸区', + code: '420102', }, { - "name":"江汉区", - "code":"420103" + name: '江汉区', + code: '420103', }, { - "name":"硚口区", - "code":"420104" + name: '硚口区', + code: '420104', }, { - "name":"汉阳区", - "code":"420105" + name: '汉阳区', + code: '420105', }, { - "name":"武昌区", - "code":"420106" + name: '武昌区', + code: '420106', }, { - "name":"青山区", - "code":"420107" + name: '青山区', + code: '420107', }, { - "name":"洪山区", - "code":"420111" + name: '洪山区', + code: '420111', }, { - "name":"东西湖区", - "code":"420112" + name: '东西湖区', + code: '420112', }, { - "name":"汉南区", - "code":"420113" + name: '汉南区', + code: '420113', }, { - "name":"蔡甸区", - "code":"420114" + name: '蔡甸区', + code: '420114', }, { - "name":"江夏区", - "code":"420115" + name: '江夏区', + code: '420115', }, { - "name":"黄陂区", - "code":"420116" + name: '黄陂区', + code: '420116', }, { - "name":"新洲区", - "code":"420117" - } - ] + name: '新洲区', + code: '420117', + }, + ], }, { - "name":"黄石市", - "code":"420200", - "sub":[ + name: '黄石市', + code: '420200', + sub: [ { - "name":"市辖区", - "code":"420201" + name: '市辖区', + code: '420201', }, { - "name":"黄石港区", - "code":"420202" + name: '黄石港区', + code: '420202', }, { - "name":"西塞山区", - "code":"420203" + name: '西塞山区', + code: '420203', }, { - "name":"下陆区", - "code":"420204" + name: '下陆区', + code: '420204', }, { - "name":"铁山区", - "code":"420205" + name: '铁山区', + code: '420205', }, { - "name":"阳新县", - "code":"420222" + name: '阳新县', + code: '420222', }, { - "name":"大冶市", - "code":"420281" - } - ] + name: '大冶市', + code: '420281', + }, + ], }, { - "name":"十堰市", - "code":"420300", - "sub":[ + name: '十堰市', + code: '420300', + sub: [ { - "name":"市辖区", - "code":"420301" + name: '市辖区', + code: '420301', }, { - "name":"茅箭区", - "code":"420302" + name: '茅箭区', + code: '420302', }, { - "name":"张湾区", - "code":"420303" + name: '张湾区', + code: '420303', }, { - "name":"郧阳区", - "code":"420304" + name: '郧阳区', + code: '420304', }, { - "name":"郧西县", - "code":"420322" + name: '郧西县', + code: '420322', }, { - "name":"竹山县", - "code":"420323" + name: '竹山县', + code: '420323', }, { - "name":"竹溪县", - "code":"420324" + name: '竹溪县', + code: '420324', }, { - "name":"房县", - "code":"420325" + name: '房县', + code: '420325', }, { - "name":"丹江口市", - "code":"420381" - } - ] + name: '丹江口市', + code: '420381', + }, + ], }, { - "name":"宜昌市", - "code":"420500", - "sub":[ + name: '宜昌市', + code: '420500', + sub: [ { - "name":"市辖区", - "code":"420501" + name: '市辖区', + code: '420501', }, { - "name":"西陵区", - "code":"420502" + name: '西陵区', + code: '420502', }, { - "name":"伍家岗区", - "code":"420503" + name: '伍家岗区', + code: '420503', }, { - "name":"点军区", - "code":"420504" + name: '点军区', + code: '420504', }, { - "name":"猇亭区", - "code":"420505" + name: '猇亭区', + code: '420505', }, { - "name":"夷陵区", - "code":"420506" + name: '夷陵区', + code: '420506', }, { - "name":"远安县", - "code":"420525" + name: '远安县', + code: '420525', }, { - "name":"兴山县", - "code":"420526" + name: '兴山县', + code: '420526', }, { - "name":"秭归县", - "code":"420527" + name: '秭归县', + code: '420527', }, { - "name":"长阳土家族自治县", - "code":"420528" + name: '长阳土家族自治县', + code: '420528', }, { - "name":"五峰土家族自治县", - "code":"420529" + name: '五峰土家族自治县', + code: '420529', }, { - "name":"宜都市", - "code":"420581" + name: '宜都市', + code: '420581', }, { - "name":"当阳市", - "code":"420582" + name: '当阳市', + code: '420582', }, { - "name":"枝江市", - "code":"420583" - } - ] + name: '枝江市', + code: '420583', + }, + ], }, { - "name":"襄阳市", - "code":"420600", - "sub":[ + name: '襄阳市', + code: '420600', + sub: [ { - "name":"市辖区", - "code":"420601" + name: '市辖区', + code: '420601', }, { - "name":"襄城区", - "code":"420602" + name: '襄城区', + code: '420602', }, { - "name":"樊城区", - "code":"420606" + name: '樊城区', + code: '420606', }, { - "name":"襄州区", - "code":"420607" + name: '襄州区', + code: '420607', }, { - "name":"南漳县", - "code":"420624" + name: '南漳县', + code: '420624', }, { - "name":"谷城县", - "code":"420625" + name: '谷城县', + code: '420625', }, { - "name":"保康县", - "code":"420626" + name: '保康县', + code: '420626', }, { - "name":"老河口市", - "code":"420682" + name: '老河口市', + code: '420682', }, { - "name":"枣阳市", - "code":"420683" + name: '枣阳市', + code: '420683', }, { - "name":"宜城市", - "code":"420684" - } - ] + name: '宜城市', + code: '420684', + }, + ], }, { - "name":"鄂州市", - "code":"420700", - "sub":[ + name: '鄂州市', + code: '420700', + sub: [ { - "name":"市辖区", - "code":"420701" + name: '市辖区', + code: '420701', }, { - "name":"梁子湖区", - "code":"420702" + name: '梁子湖区', + code: '420702', }, { - "name":"华容区", - "code":"420703" + name: '华容区', + code: '420703', }, { - "name":"鄂城区", - "code":"420704" - } - ] + name: '鄂城区', + code: '420704', + }, + ], }, { - "name":"荆门市", - "code":"420800", - "sub":[ + name: '荆门市', + code: '420800', + sub: [ { - "name":"市辖区", - "code":"420801" + name: '市辖区', + code: '420801', }, { - "name":"东宝区", - "code":"420802" + name: '东宝区', + code: '420802', }, { - "name":"掇刀区", - "code":"420804" + name: '掇刀区', + code: '420804', }, { - "name":"京山县", - "code":"420821" + name: '京山县', + code: '420821', }, { - "name":"沙洋县", - "code":"420822" + name: '沙洋县', + code: '420822', }, { - "name":"钟祥市", - "code":"420881" - } - ] + name: '钟祥市', + code: '420881', + }, + ], }, { - "name":"孝感市", - "code":"420900", - "sub":[ + name: '孝感市', + code: '420900', + sub: [ { - "name":"市辖区", - "code":"420901" + name: '市辖区', + code: '420901', }, { - "name":"孝南区", - "code":"420902" + name: '孝南区', + code: '420902', }, { - "name":"孝昌县", - "code":"420921" + name: '孝昌县', + code: '420921', }, { - "name":"大悟县", - "code":"420922" + name: '大悟县', + code: '420922', }, { - "name":"云梦县", - "code":"420923" + name: '云梦县', + code: '420923', }, { - "name":"应城市", - "code":"420981" + name: '应城市', + code: '420981', }, { - "name":"安陆市", - "code":"420982" + name: '安陆市', + code: '420982', }, { - "name":"汉川市", - "code":"420984" - } - ] + name: '汉川市', + code: '420984', + }, + ], }, { - "name":"荆州市", - "code":"421000", - "sub":[ + name: '荆州市', + code: '421000', + sub: [ { - "name":"市辖区", - "code":"421001" + name: '市辖区', + code: '421001', }, { - "name":"沙市区", - "code":"421002" + name: '沙市区', + code: '421002', }, { - "name":"荆州区", - "code":"421003" + name: '荆州区', + code: '421003', }, { - "name":"公安县", - "code":"421022" + name: '公安县', + code: '421022', }, { - "name":"监利县", - "code":"421023" + name: '监利县', + code: '421023', }, { - "name":"江陵县", - "code":"421024" + name: '江陵县', + code: '421024', }, { - "name":"石首市", - "code":"421081" + name: '石首市', + code: '421081', }, { - "name":"洪湖市", - "code":"421083" + name: '洪湖市', + code: '421083', }, { - "name":"松滋市", - "code":"421087" - } - ] + name: '松滋市', + code: '421087', + }, + ], }, { - "name":"黄冈市", - "code":"421100", - "sub":[ + name: '黄冈市', + code: '421100', + sub: [ { - "name":"市辖区", - "code":"421101" + name: '市辖区', + code: '421101', }, { - "name":"黄州区", - "code":"421102" + name: '黄州区', + code: '421102', }, { - "name":"团风县", - "code":"421121" + name: '团风县', + code: '421121', }, { - "name":"红安县", - "code":"421122" + name: '红安县', + code: '421122', }, { - "name":"罗田县", - "code":"421123" + name: '罗田县', + code: '421123', }, { - "name":"英山县", - "code":"421124" + name: '英山县', + code: '421124', }, { - "name":"浠水县", - "code":"421125" + name: '浠水县', + code: '421125', }, { - "name":"蕲春县", - "code":"421126" + name: '蕲春县', + code: '421126', }, { - "name":"黄梅县", - "code":"421127" + name: '黄梅县', + code: '421127', }, { - "name":"麻城市", - "code":"421181" + name: '麻城市', + code: '421181', }, { - "name":"武穴市", - "code":"421182" - } - ] + name: '武穴市', + code: '421182', + }, + ], }, { - "name":"咸宁市", - "code":"421200", - "sub":[ + name: '咸宁市', + code: '421200', + sub: [ { - "name":"市辖区", - "code":"421201" + name: '市辖区', + code: '421201', }, { - "name":"咸安区", - "code":"421202" + name: '咸安区', + code: '421202', }, { - "name":"嘉鱼县", - "code":"421221" + name: '嘉鱼县', + code: '421221', }, { - "name":"通城县", - "code":"421222" + name: '通城县', + code: '421222', }, { - "name":"崇阳县", - "code":"421223" + name: '崇阳县', + code: '421223', }, { - "name":"通山县", - "code":"421224" + name: '通山县', + code: '421224', }, { - "name":"赤壁市", - "code":"421281" - } - ] + name: '赤壁市', + code: '421281', + }, + ], }, { - "name":"随州市", - "code":"421300", - "sub":[ + name: '随州市', + code: '421300', + sub: [ { - "name":"市辖区", - "code":"421301" + name: '市辖区', + code: '421301', }, { - "name":"曾都区", - "code":"421303" + name: '曾都区', + code: '421303', }, { - "name":"随县", - "code":"421321" + name: '随县', + code: '421321', }, { - "name":"广水市", - "code":"421381" - } - ] + name: '广水市', + code: '421381', + }, + ], }, { - "name":"恩施土家族苗族自治州", - "code":"422800", - "sub":[ + name: '恩施土家族苗族自治州', + code: '422800', + sub: [ { - "name":"恩施市", - "code":"422801" + name: '恩施市', + code: '422801', }, { - "name":"利川市", - "code":"422802" + name: '利川市', + code: '422802', }, { - "name":"建始县", - "code":"422822" + name: '建始县', + code: '422822', }, { - "name":"巴东县", - "code":"422823" + name: '巴东县', + code: '422823', }, { - "name":"宣恩县", - "code":"422825" + name: '宣恩县', + code: '422825', }, { - "name":"咸丰县", - "code":"422826" + name: '咸丰县', + code: '422826', }, { - "name":"来凤县", - "code":"422827" + name: '来凤县', + code: '422827', }, { - "name":"鹤峰县", - "code":"422828" - } - ] + name: '鹤峰县', + code: '422828', + }, + ], }, { - "name":"仙桃市", - "code":"429004" + name: '仙桃市', + code: '429004', }, { - "name":"潜江市", - "code":"429005" + name: '潜江市', + code: '429005', }, { - "name":"天门市", - "code":"429006" + name: '天门市', + code: '429006', }, { - "name":"神农架林区", - "code":"429021" - } - ] + name: '神农架林区', + code: '429021', + }, + ], }, { - "name":"湖南省", - "code":"430000", - "sub":[ + name: '湖南省', + code: '430000', + sub: [ { - "name":"长沙市", - "code":"430100", - "sub":[ + name: '长沙市', + code: '430100', + sub: [ { - "name":"市辖区", - "code":"430101" + name: '市辖区', + code: '430101', }, { - "name":"芙蓉区", - "code":"430102" + name: '芙蓉区', + code: '430102', }, { - "name":"天心区", - "code":"430103" + name: '天心区', + code: '430103', }, { - "name":"岳麓区", - "code":"430104" + name: '岳麓区', + code: '430104', }, { - "name":"开福区", - "code":"430105" + name: '开福区', + code: '430105', }, { - "name":"雨花区", - "code":"430111" + name: '雨花区', + code: '430111', }, { - "name":"望城区", - "code":"430112" + name: '望城区', + code: '430112', }, { - "name":"长沙县", - "code":"430121" + name: '长沙县', + code: '430121', }, { - "name":"宁乡县", - "code":"430124" + name: '宁乡县', + code: '430124', }, { - "name":"浏阳市", - "code":"430181" - } - ] + name: '浏阳市', + code: '430181', + }, + ], }, { - "name":"株洲市", - "code":"430200", - "sub":[ + name: '株洲市', + code: '430200', + sub: [ { - "name":"市辖区", - "code":"430201" + name: '市辖区', + code: '430201', }, { - "name":"荷塘区", - "code":"430202" + name: '荷塘区', + code: '430202', }, { - "name":"芦淞区", - "code":"430203" + name: '芦淞区', + code: '430203', }, { - "name":"石峰区", - "code":"430204" + name: '石峰区', + code: '430204', }, { - "name":"天元区", - "code":"430211" + name: '天元区', + code: '430211', }, { - "name":"株洲县", - "code":"430221" + name: '株洲县', + code: '430221', }, { - "name":"攸县", - "code":"430223" + name: '攸县', + code: '430223', }, { - "name":"茶陵县", - "code":"430224" + name: '茶陵县', + code: '430224', }, { - "name":"炎陵县", - "code":"430225" + name: '炎陵县', + code: '430225', }, { - "name":"醴陵市", - "code":"430281" - } - ] + name: '醴陵市', + code: '430281', + }, + ], }, { - "name":"湘潭市", - "code":"430300", - "sub":[ + name: '湘潭市', + code: '430300', + sub: [ { - "name":"市辖区", - "code":"430301" + name: '市辖区', + code: '430301', }, { - "name":"雨湖区", - "code":"430302" + name: '雨湖区', + code: '430302', }, { - "name":"岳塘区", - "code":"430304" + name: '岳塘区', + code: '430304', }, { - "name":"湘潭县", - "code":"430321" + name: '湘潭县', + code: '430321', }, { - "name":"湘乡市", - "code":"430381" + name: '湘乡市', + code: '430381', }, { - "name":"韶山市", - "code":"430382" - } - ] + name: '韶山市', + code: '430382', + }, + ], }, { - "name":"衡阳市", - "code":"430400", - "sub":[ + name: '衡阳市', + code: '430400', + sub: [ { - "name":"市辖区", - "code":"430401" + name: '市辖区', + code: '430401', }, { - "name":"珠晖区", - "code":"430405" + name: '珠晖区', + code: '430405', }, { - "name":"雁峰区", - "code":"430406" + name: '雁峰区', + code: '430406', }, { - "name":"石鼓区", - "code":"430407" + name: '石鼓区', + code: '430407', }, { - "name":"蒸湘区", - "code":"430408" + name: '蒸湘区', + code: '430408', }, { - "name":"南岳区", - "code":"430412" + name: '南岳区', + code: '430412', }, { - "name":"衡阳县", - "code":"430421" + name: '衡阳县', + code: '430421', }, { - "name":"衡南县", - "code":"430422" + name: '衡南县', + code: '430422', }, { - "name":"衡山县", - "code":"430423" + name: '衡山县', + code: '430423', }, { - "name":"衡东县", - "code":"430424" + name: '衡东县', + code: '430424', }, { - "name":"祁东县", - "code":"430426" + name: '祁东县', + code: '430426', }, { - "name":"耒阳市", - "code":"430481" + name: '耒阳市', + code: '430481', }, { - "name":"常宁市", - "code":"430482" - } - ] + name: '常宁市', + code: '430482', + }, + ], }, { - "name":"邵阳市", - "code":"430500", - "sub":[ + name: '邵阳市', + code: '430500', + sub: [ { - "name":"市辖区", - "code":"430501" + name: '市辖区', + code: '430501', }, { - "name":"双清区", - "code":"430502" + name: '双清区', + code: '430502', }, { - "name":"大祥区", - "code":"430503" + name: '大祥区', + code: '430503', }, { - "name":"北塔区", - "code":"430511" + name: '北塔区', + code: '430511', }, { - "name":"邵东县", - "code":"430521" + name: '邵东县', + code: '430521', }, { - "name":"新邵县", - "code":"430522" + name: '新邵县', + code: '430522', }, { - "name":"邵阳县", - "code":"430523" + name: '邵阳县', + code: '430523', }, { - "name":"隆回县", - "code":"430524" + name: '隆回县', + code: '430524', }, { - "name":"洞口县", - "code":"430525" + name: '洞口县', + code: '430525', }, { - "name":"绥宁县", - "code":"430527" + name: '绥宁县', + code: '430527', }, { - "name":"新宁县", - "code":"430528" + name: '新宁县', + code: '430528', }, { - "name":"城步苗族自治县", - "code":"430529" + name: '城步苗族自治县', + code: '430529', }, { - "name":"武冈市", - "code":"430581" - } - ] + name: '武冈市', + code: '430581', + }, + ], }, { - "name":"岳阳市", - "code":"430600", - "sub":[ + name: '岳阳市', + code: '430600', + sub: [ { - "name":"市辖区", - "code":"430601" + name: '市辖区', + code: '430601', }, { - "name":"岳阳楼区", - "code":"430602" + name: '岳阳楼区', + code: '430602', }, { - "name":"云溪区", - "code":"430603" + name: '云溪区', + code: '430603', }, { - "name":"君山区", - "code":"430611" + name: '君山区', + code: '430611', }, { - "name":"岳阳县", - "code":"430621" + name: '岳阳县', + code: '430621', }, { - "name":"华容县", - "code":"430623" + name: '华容县', + code: '430623', }, { - "name":"湘阴县", - "code":"430624" + name: '湘阴县', + code: '430624', }, { - "name":"平江县", - "code":"430626" + name: '平江县', + code: '430626', }, { - "name":"汨罗市", - "code":"430681" + name: '汨罗市', + code: '430681', }, { - "name":"临湘市", - "code":"430682" - } - ] + name: '临湘市', + code: '430682', + }, + ], }, { - "name":"常德市", - "code":"430700", - "sub":[ + name: '常德市', + code: '430700', + sub: [ { - "name":"市辖区", - "code":"430701" + name: '市辖区', + code: '430701', }, { - "name":"武陵区", - "code":"430702" + name: '武陵区', + code: '430702', }, { - "name":"鼎城区", - "code":"430703" + name: '鼎城区', + code: '430703', }, { - "name":"安乡县", - "code":"430721" + name: '安乡县', + code: '430721', }, { - "name":"汉寿县", - "code":"430722" + name: '汉寿县', + code: '430722', }, { - "name":"澧县", - "code":"430723" + name: '澧县', + code: '430723', }, { - "name":"临澧县", - "code":"430724" + name: '临澧县', + code: '430724', }, { - "name":"桃源县", - "code":"430725" + name: '桃源县', + code: '430725', }, { - "name":"石门县", - "code":"430726" + name: '石门县', + code: '430726', }, { - "name":"津市市", - "code":"430781" - } - ] + name: '津市市', + code: '430781', + }, + ], }, { - "name":"张家界市", - "code":"430800", - "sub":[ + name: '张家界市', + code: '430800', + sub: [ { - "name":"市辖区", - "code":"430801" + name: '市辖区', + code: '430801', }, { - "name":"永定区", - "code":"430802" + name: '永定区', + code: '430802', }, { - "name":"武陵源区", - "code":"430811" + name: '武陵源区', + code: '430811', }, { - "name":"慈利县", - "code":"430821" + name: '慈利县', + code: '430821', }, { - "name":"桑植县", - "code":"430822" - } - ] + name: '桑植县', + code: '430822', + }, + ], }, { - "name":"益阳市", - "code":"430900", - "sub":[ + name: '益阳市', + code: '430900', + sub: [ { - "name":"市辖区", - "code":"430901" + name: '市辖区', + code: '430901', }, { - "name":"资阳区", - "code":"430902" + name: '资阳区', + code: '430902', }, { - "name":"赫山区", - "code":"430903" + name: '赫山区', + code: '430903', }, { - "name":"南县", - "code":"430921" + name: '南县', + code: '430921', }, { - "name":"桃江县", - "code":"430922" + name: '桃江县', + code: '430922', }, { - "name":"安化县", - "code":"430923" + name: '安化县', + code: '430923', }, { - "name":"沅江市", - "code":"430981" - } - ] + name: '沅江市', + code: '430981', + }, + ], }, { - "name":"郴州市", - "code":"431000", - "sub":[ + name: '郴州市', + code: '431000', + sub: [ { - "name":"市辖区", - "code":"431001" + name: '市辖区', + code: '431001', }, { - "name":"北湖区", - "code":"431002" + name: '北湖区', + code: '431002', }, { - "name":"苏仙区", - "code":"431003" + name: '苏仙区', + code: '431003', }, { - "name":"桂阳县", - "code":"431021" + name: '桂阳县', + code: '431021', }, { - "name":"宜章县", - "code":"431022" + name: '宜章县', + code: '431022', }, { - "name":"永兴县", - "code":"431023" + name: '永兴县', + code: '431023', }, { - "name":"嘉禾县", - "code":"431024" + name: '嘉禾县', + code: '431024', }, { - "name":"临武县", - "code":"431025" + name: '临武县', + code: '431025', }, { - "name":"汝城县", - "code":"431026" + name: '汝城县', + code: '431026', }, { - "name":"桂东县", - "code":"431027" + name: '桂东县', + code: '431027', }, { - "name":"安仁县", - "code":"431028" + name: '安仁县', + code: '431028', }, { - "name":"资兴市", - "code":"431081" - } - ] + name: '资兴市', + code: '431081', + }, + ], }, { - "name":"永州市", - "code":"431100", - "sub":[ + name: '永州市', + code: '431100', + sub: [ { - "name":"市辖区", - "code":"431101" + name: '市辖区', + code: '431101', }, { - "name":"零陵区", - "code":"431102" + name: '零陵区', + code: '431102', }, { - "name":"冷水滩区", - "code":"431103" + name: '冷水滩区', + code: '431103', }, { - "name":"祁阳县", - "code":"431121" + name: '祁阳县', + code: '431121', }, { - "name":"东安县", - "code":"431122" + name: '东安县', + code: '431122', }, { - "name":"双牌县", - "code":"431123" + name: '双牌县', + code: '431123', }, { - "name":"道县", - "code":"431124" + name: '道县', + code: '431124', }, { - "name":"江永县", - "code":"431125" + name: '江永县', + code: '431125', }, { - "name":"宁远县", - "code":"431126" + name: '宁远县', + code: '431126', }, { - "name":"蓝山县", - "code":"431127" + name: '蓝山县', + code: '431127', }, { - "name":"新田县", - "code":"431128" + name: '新田县', + code: '431128', }, { - "name":"江华瑶族自治县", - "code":"431129" - } - ] + name: '江华瑶族自治县', + code: '431129', + }, + ], }, { - "name":"怀化市", - "code":"431200", - "sub":[ + name: '怀化市', + code: '431200', + sub: [ { - "name":"市辖区", - "code":"431201" + name: '市辖区', + code: '431201', }, { - "name":"鹤城区", - "code":"431202" + name: '鹤城区', + code: '431202', }, { - "name":"中方县", - "code":"431221" + name: '中方县', + code: '431221', }, { - "name":"沅陵县", - "code":"431222" + name: '沅陵县', + code: '431222', }, { - "name":"辰溪县", - "code":"431223" + name: '辰溪县', + code: '431223', }, { - "name":"溆浦县", - "code":"431224" + name: '溆浦县', + code: '431224', }, { - "name":"会同县", - "code":"431225" + name: '会同县', + code: '431225', }, { - "name":"麻阳苗族自治县", - "code":"431226" + name: '麻阳苗族自治县', + code: '431226', }, { - "name":"新晃侗族自治县", - "code":"431227" + name: '新晃侗族自治县', + code: '431227', }, { - "name":"芷江侗族自治县", - "code":"431228" + name: '芷江侗族自治县', + code: '431228', }, { - "name":"靖州苗族侗族自治县", - "code":"431229" + name: '靖州苗族侗族自治县', + code: '431229', }, { - "name":"通道侗族自治县", - "code":"431230" + name: '通道侗族自治县', + code: '431230', }, { - "name":"洪江市", - "code":"431281" - } - ] + name: '洪江市', + code: '431281', + }, + ], }, { - "name":"娄底市", - "code":"431300", - "sub":[ + name: '娄底市', + code: '431300', + sub: [ { - "name":"市辖区", - "code":"431301" + name: '市辖区', + code: '431301', }, { - "name":"娄星区", - "code":"431302" + name: '娄星区', + code: '431302', }, { - "name":"双峰县", - "code":"431321" + name: '双峰县', + code: '431321', }, { - "name":"新化县", - "code":"431322" + name: '新化县', + code: '431322', }, { - "name":"冷水江市", - "code":"431381" + name: '冷水江市', + code: '431381', }, { - "name":"涟源市", - "code":"431382" - } - ] + name: '涟源市', + code: '431382', + }, + ], }, { - "name":"湘西土家族苗族自治州", - "code":"433100", - "sub":[ + name: '湘西土家族苗族自治州', + code: '433100', + sub: [ { - "name":"吉首市", - "code":"433101" + name: '吉首市', + code: '433101', }, { - "name":"泸溪县", - "code":"433122" + name: '泸溪县', + code: '433122', }, { - "name":"凤凰县", - "code":"433123" + name: '凤凰县', + code: '433123', }, { - "name":"花垣县", - "code":"433124" + name: '花垣县', + code: '433124', }, { - "name":"保靖县", - "code":"433125" + name: '保靖县', + code: '433125', }, { - "name":"古丈县", - "code":"433126" + name: '古丈县', + code: '433126', }, { - "name":"永顺县", - "code":"433127" + name: '永顺县', + code: '433127', }, { - "name":"龙山县", - "code":"433130" - } - ] - } - ] + name: '龙山县', + code: '433130', + }, + ], + }, + ], }, { - "name":"广东省", - "code":"440000", - "sub":[ + name: '广东省', + code: '440000', + sub: [ { - "name":"广州市", - "code":"440100", - "sub":[ + name: '广州市', + code: '440100', + sub: [ { - "name":"市辖区", - "code":"440101" + name: '市辖区', + code: '440101', }, { - "name":"荔湾区", - "code":"440103" + name: '荔湾区', + code: '440103', }, { - "name":"越秀区", - "code":"440104" + name: '越秀区', + code: '440104', }, { - "name":"海珠区", - "code":"440105" + name: '海珠区', + code: '440105', }, { - "name":"天河区", - "code":"440106" + name: '天河区', + code: '440106', }, { - "name":"白云区", - "code":"440111" + name: '白云区', + code: '440111', }, { - "name":"黄埔区", - "code":"440112" + name: '黄埔区', + code: '440112', }, { - "name":"番禺区", - "code":"440113" + name: '番禺区', + code: '440113', }, { - "name":"花都区", - "code":"440114" + name: '花都区', + code: '440114', }, { - "name":"南沙区", - "code":"440115" + name: '南沙区', + code: '440115', }, { - "name":"从化区", - "code":"440117" + name: '从化区', + code: '440117', }, { - "name":"增城区", - "code":"440118" - } - ] + name: '增城区', + code: '440118', + }, + ], }, { - "name":"韶关市", - "code":"440200", - "sub":[ + name: '韶关市', + code: '440200', + sub: [ { - "name":"市辖区", - "code":"440201" + name: '市辖区', + code: '440201', }, { - "name":"武江区", - "code":"440203" + name: '武江区', + code: '440203', }, { - "name":"浈江区", - "code":"440204" + name: '浈江区', + code: '440204', }, { - "name":"曲江区", - "code":"440205" + name: '曲江区', + code: '440205', }, { - "name":"始兴县", - "code":"440222" + name: '始兴县', + code: '440222', }, { - "name":"仁化县", - "code":"440224" + name: '仁化县', + code: '440224', }, { - "name":"翁源县", - "code":"440229" + name: '翁源县', + code: '440229', }, { - "name":"乳源瑶族自治县", - "code":"440232" + name: '乳源瑶族自治县', + code: '440232', }, { - "name":"新丰县", - "code":"440233" + name: '新丰县', + code: '440233', }, { - "name":"乐昌市", - "code":"440281" + name: '乐昌市', + code: '440281', }, { - "name":"南雄市", - "code":"440282" - } - ] + name: '南雄市', + code: '440282', + }, + ], }, { - "name":"深圳市", - "code":"440300", - "sub":[ + name: '深圳市', + code: '440300', + sub: [ { - "name":"市辖区", - "code":"440301" + name: '市辖区', + code: '440301', }, { - "name":"罗湖区", - "code":"440303" + name: '罗湖区', + code: '440303', }, { - "name":"福田区", - "code":"440304" + name: '福田区', + code: '440304', }, { - "name":"南山区", - "code":"440305" + name: '南山区', + code: '440305', }, { - "name":"宝安区", - "code":"440306" + name: '宝安区', + code: '440306', }, { - "name":"龙岗区", - "code":"440307" + name: '龙岗区', + code: '440307', }, { - "name":"盐田区", - "code":"440308" - } - ] + name: '盐田区', + code: '440308', + }, + ], }, { - "name":"珠海市", - "code":"440400", - "sub":[ + name: '珠海市', + code: '440400', + sub: [ { - "name":"市辖区", - "code":"440401" + name: '市辖区', + code: '440401', }, { - "name":"香洲区", - "code":"440402" + name: '香洲区', + code: '440402', }, { - "name":"斗门区", - "code":"440403" + name: '斗门区', + code: '440403', }, { - "name":"金湾区", - "code":"440404" - } - ] + name: '金湾区', + code: '440404', + }, + ], }, { - "name":"汕头市", - "code":"440500", - "sub":[ + name: '汕头市', + code: '440500', + sub: [ { - "name":"市辖区", - "code":"440501" + name: '市辖区', + code: '440501', }, { - "name":"龙湖区", - "code":"440507" + name: '龙湖区', + code: '440507', }, { - "name":"金平区", - "code":"440511" + name: '金平区', + code: '440511', }, { - "name":"濠江区", - "code":"440512" + name: '濠江区', + code: '440512', }, { - "name":"潮阳区", - "code":"440513" + name: '潮阳区', + code: '440513', }, { - "name":"潮南区", - "code":"440514" + name: '潮南区', + code: '440514', }, { - "name":"澄海区", - "code":"440515" + name: '澄海区', + code: '440515', }, { - "name":"南澳县", - "code":"440523" - } - ] + name: '南澳县', + code: '440523', + }, + ], }, { - "name":"佛山市", - "code":"440600", - "sub":[ + name: '佛山市', + code: '440600', + sub: [ { - "name":"市辖区", - "code":"440601" + name: '市辖区', + code: '440601', }, { - "name":"禅城区", - "code":"440604" + name: '禅城区', + code: '440604', }, { - "name":"南海区", - "code":"440605" + name: '南海区', + code: '440605', }, { - "name":"顺德区", - "code":"440606" + name: '顺德区', + code: '440606', }, { - "name":"三水区", - "code":"440607" + name: '三水区', + code: '440607', }, { - "name":"高明区", - "code":"440608" - } - ] + name: '高明区', + code: '440608', + }, + ], }, { - "name":"江门市", - "code":"440700", - "sub":[ + name: '江门市', + code: '440700', + sub: [ { - "name":"市辖区", - "code":"440701" + name: '市辖区', + code: '440701', }, { - "name":"蓬江区", - "code":"440703" + name: '蓬江区', + code: '440703', }, { - "name":"江海区", - "code":"440704" + name: '江海区', + code: '440704', }, { - "name":"新会区", - "code":"440705" + name: '新会区', + code: '440705', }, { - "name":"台山市", - "code":"440781" + name: '台山市', + code: '440781', }, { - "name":"开平市", - "code":"440783" + name: '开平市', + code: '440783', }, { - "name":"鹤山市", - "code":"440784" + name: '鹤山市', + code: '440784', }, { - "name":"恩平市", - "code":"440785" - } - ] + name: '恩平市', + code: '440785', + }, + ], }, { - "name":"湛江市", - "code":"440800", - "sub":[ + name: '湛江市', + code: '440800', + sub: [ { - "name":"市辖区", - "code":"440801" + name: '市辖区', + code: '440801', }, { - "name":"赤坎区", - "code":"440802" + name: '赤坎区', + code: '440802', }, { - "name":"霞山区", - "code":"440803" + name: '霞山区', + code: '440803', }, { - "name":"坡头区", - "code":"440804" + name: '坡头区', + code: '440804', }, { - "name":"麻章区", - "code":"440811" + name: '麻章区', + code: '440811', }, { - "name":"遂溪县", - "code":"440823" + name: '遂溪县', + code: '440823', }, { - "name":"徐闻县", - "code":"440825" + name: '徐闻县', + code: '440825', }, { - "name":"廉江市", - "code":"440881" + name: '廉江市', + code: '440881', }, { - "name":"雷州市", - "code":"440882" + name: '雷州市', + code: '440882', }, { - "name":"吴川市", - "code":"440883" - } - ] + name: '吴川市', + code: '440883', + }, + ], }, { - "name":"茂名市", - "code":"440900", - "sub":[ + name: '茂名市', + code: '440900', + sub: [ { - "name":"市辖区", - "code":"440901" + name: '市辖区', + code: '440901', }, { - "name":"茂南区", - "code":"440902" + name: '茂南区', + code: '440902', }, { - "name":"电白区", - "code":"440904" + name: '电白区', + code: '440904', }, { - "name":"高州市", - "code":"440981" + name: '高州市', + code: '440981', }, { - "name":"化州市", - "code":"440982" + name: '化州市', + code: '440982', }, { - "name":"信宜市", - "code":"440983" - } - ] + name: '信宜市', + code: '440983', + }, + ], }, { - "name":"肇庆市", - "code":"441200", - "sub":[ + name: '肇庆市', + code: '441200', + sub: [ { - "name":"市辖区", - "code":"441201" + name: '市辖区', + code: '441201', }, { - "name":"端州区", - "code":"441202" + name: '端州区', + code: '441202', }, { - "name":"鼎湖区", - "code":"441203" + name: '鼎湖区', + code: '441203', }, { - "name":"广宁县", - "code":"441223" + name: '广宁县', + code: '441223', }, { - "name":"怀集县", - "code":"441224" + name: '怀集县', + code: '441224', }, { - "name":"封开县", - "code":"441225" + name: '封开县', + code: '441225', }, { - "name":"德庆县", - "code":"441226" + name: '德庆县', + code: '441226', }, { - "name":"高要市", - "code":"441283" + name: '高要市', + code: '441283', }, { - "name":"四会市", - "code":"441284" - } - ] + name: '四会市', + code: '441284', + }, + ], }, { - "name":"惠州市", - "code":"441300", - "sub":[ + name: '惠州市', + code: '441300', + sub: [ { - "name":"市辖区", - "code":"441301" + name: '市辖区', + code: '441301', }, { - "name":"惠城区", - "code":"441302" + name: '惠城区', + code: '441302', }, { - "name":"惠阳区", - "code":"441303" + name: '惠阳区', + code: '441303', }, { - "name":"博罗县", - "code":"441322" + name: '博罗县', + code: '441322', }, { - "name":"惠东县", - "code":"441323" + name: '惠东县', + code: '441323', }, { - "name":"龙门县", - "code":"441324" - } - ] + name: '龙门县', + code: '441324', + }, + ], }, { - "name":"梅州市", - "code":"441400", - "sub":[ + name: '梅州市', + code: '441400', + sub: [ { - "name":"市辖区", - "code":"441401" + name: '市辖区', + code: '441401', }, { - "name":"梅江区", - "code":"441402" + name: '梅江区', + code: '441402', }, { - "name":"梅县区", - "code":"441403" + name: '梅县区', + code: '441403', }, { - "name":"大埔县", - "code":"441422" + name: '大埔县', + code: '441422', }, { - "name":"丰顺县", - "code":"441423" + name: '丰顺县', + code: '441423', }, { - "name":"五华县", - "code":"441424" + name: '五华县', + code: '441424', }, { - "name":"平远县", - "code":"441426" + name: '平远县', + code: '441426', }, { - "name":"蕉岭县", - "code":"441427" + name: '蕉岭县', + code: '441427', }, { - "name":"兴宁市", - "code":"441481" - } - ] + name: '兴宁市', + code: '441481', + }, + ], }, { - "name":"汕尾市", - "code":"441500", - "sub":[ + name: '汕尾市', + code: '441500', + sub: [ { - "name":"市辖区", - "code":"441501" + name: '市辖区', + code: '441501', }, { - "name":"城区", - "code":"441502" + name: '城区', + code: '441502', }, { - "name":"海丰县", - "code":"441521" + name: '海丰县', + code: '441521', }, { - "name":"陆河县", - "code":"441523" + name: '陆河县', + code: '441523', }, { - "name":"陆丰市", - "code":"441581" - } - ] + name: '陆丰市', + code: '441581', + }, + ], }, { - "name":"河源市", - "code":"441600", - "sub":[ + name: '河源市', + code: '441600', + sub: [ { - "name":"市辖区", - "code":"441601" + name: '市辖区', + code: '441601', }, { - "name":"源城区", - "code":"441602" + name: '源城区', + code: '441602', }, { - "name":"紫金县", - "code":"441621" + name: '紫金县', + code: '441621', }, { - "name":"龙川县", - "code":"441622" + name: '龙川县', + code: '441622', }, { - "name":"连平县", - "code":"441623" + name: '连平县', + code: '441623', }, { - "name":"和平县", - "code":"441624" + name: '和平县', + code: '441624', }, { - "name":"东源县", - "code":"441625" - } - ] + name: '东源县', + code: '441625', + }, + ], }, { - "name":"阳江市", - "code":"441700", - "sub":[ + name: '阳江市', + code: '441700', + sub: [ { - "name":"市辖区", - "code":"441701" + name: '市辖区', + code: '441701', }, { - "name":"江城区", - "code":"441702" + name: '江城区', + code: '441702', }, { - "name":"阳东区", - "code":"441704" + name: '阳东区', + code: '441704', }, { - "name":"阳西县", - "code":"441721" + name: '阳西县', + code: '441721', }, { - "name":"阳春市", - "code":"441781" - } - ] + name: '阳春市', + code: '441781', + }, + ], }, { - "name":"清远市", - "code":"441800", - "sub":[ + name: '清远市', + code: '441800', + sub: [ { - "name":"市辖区", - "code":"441801" + name: '市辖区', + code: '441801', }, { - "name":"清城区", - "code":"441802" + name: '清城区', + code: '441802', }, { - "name":"清新区", - "code":"441803" + name: '清新区', + code: '441803', }, { - "name":"佛冈县", - "code":"441821" + name: '佛冈县', + code: '441821', }, { - "name":"阳山县", - "code":"441823" + name: '阳山县', + code: '441823', }, { - "name":"连山壮族瑶族自治县", - "code":"441825" + name: '连山壮族瑶族自治县', + code: '441825', }, { - "name":"连南瑶族自治县", - "code":"441826" + name: '连南瑶族自治县', + code: '441826', }, { - "name":"英德市", - "code":"441881" + name: '英德市', + code: '441881', }, { - "name":"连州市", - "code":"441882" - } - ] + name: '连州市', + code: '441882', + }, + ], }, { - "name":"东莞市", - "code":"441900", - "sub":[ - - ] + name: '东莞市', + code: '441900', + sub: [], }, { - "name":"中山市", - "code":"442000", - "sub":[ - - ] + name: '中山市', + code: '442000', + sub: [], }, { - "name":"潮州市", - "code":"445100", - "sub":[ + name: '潮州市', + code: '445100', + sub: [ { - "name":"市辖区", - "code":"445101" + name: '市辖区', + code: '445101', }, { - "name":"湘桥区", - "code":"445102" + name: '湘桥区', + code: '445102', }, { - "name":"潮安区", - "code":"445103" + name: '潮安区', + code: '445103', }, { - "name":"饶平县", - "code":"445122" - } - ] + name: '饶平县', + code: '445122', + }, + ], }, { - "name":"揭阳市", - "code":"445200", - "sub":[ + name: '揭阳市', + code: '445200', + sub: [ { - "name":"市辖区", - "code":"445201" + name: '市辖区', + code: '445201', }, { - "name":"榕城区", - "code":"445202" + name: '榕城区', + code: '445202', }, { - "name":"揭东区", - "code":"445203" + name: '揭东区', + code: '445203', }, { - "name":"揭西县", - "code":"445222" + name: '揭西县', + code: '445222', }, { - "name":"惠来县", - "code":"445224" + name: '惠来县', + code: '445224', }, { - "name":"普宁市", - "code":"445281" - } - ] + name: '普宁市', + code: '445281', + }, + ], }, { - "name":"云浮市", - "code":"445300", - "sub":[ + name: '云浮市', + code: '445300', + sub: [ { - "name":"市辖区", - "code":"445301" + name: '市辖区', + code: '445301', }, { - "name":"云城区", - "code":"445302" + name: '云城区', + code: '445302', }, { - "name":"云安区", - "code":"445303" + name: '云安区', + code: '445303', }, { - "name":"新兴县", - "code":"445321" + name: '新兴县', + code: '445321', }, { - "name":"郁南县", - "code":"445322" + name: '郁南县', + code: '445322', }, { - "name":"罗定市", - "code":"445381" - } - ] - } - ] + name: '罗定市', + code: '445381', + }, + ], + }, + ], }, { - "name":"广西壮族自治区", - "code":"450000", - "sub":[ + name: '广西壮族自治区', + code: '450000', + sub: [ { - "name":"南宁市", - "code":"450100", - "sub":[ + name: '南宁市', + code: '450100', + sub: [ { - "name":"市辖区", - "code":"450101" + name: '市辖区', + code: '450101', }, { - "name":"兴宁区", - "code":"450102" + name: '兴宁区', + code: '450102', }, { - "name":"青秀区", - "code":"450103" + name: '青秀区', + code: '450103', }, { - "name":"江南区", - "code":"450105" + name: '江南区', + code: '450105', }, { - "name":"西乡塘区", - "code":"450107" + name: '西乡塘区', + code: '450107', }, { - "name":"良庆区", - "code":"450108" + name: '良庆区', + code: '450108', }, { - "name":"邕宁区", - "code":"450109" + name: '邕宁区', + code: '450109', }, { - "name":"武鸣县", - "code":"450122" + name: '武鸣县', + code: '450122', }, { - "name":"隆安县", - "code":"450123" + name: '隆安县', + code: '450123', }, { - "name":"马山县", - "code":"450124" + name: '马山县', + code: '450124', }, { - "name":"上林县", - "code":"450125" + name: '上林县', + code: '450125', }, { - "name":"宾阳县", - "code":"450126" + name: '宾阳县', + code: '450126', }, { - "name":"横县", - "code":"450127" - } - ] + name: '横县', + code: '450127', + }, + ], }, { - "name":"柳州市", - "code":"450200", - "sub":[ + name: '柳州市', + code: '450200', + sub: [ { - "name":"市辖区", - "code":"450201" + name: '市辖区', + code: '450201', }, { - "name":"城中区", - "code":"450202" + name: '城中区', + code: '450202', }, { - "name":"鱼峰区", - "code":"450203" + name: '鱼峰区', + code: '450203', }, { - "name":"柳南区", - "code":"450204" + name: '柳南区', + code: '450204', }, { - "name":"柳北区", - "code":"450205" + name: '柳北区', + code: '450205', }, { - "name":"柳江县", - "code":"450221" + name: '柳江县', + code: '450221', }, { - "name":"柳城县", - "code":"450222" + name: '柳城县', + code: '450222', }, { - "name":"鹿寨县", - "code":"450223" + name: '鹿寨县', + code: '450223', }, { - "name":"融安县", - "code":"450224" + name: '融安县', + code: '450224', }, { - "name":"融水苗族自治县", - "code":"450225" + name: '融水苗族自治县', + code: '450225', }, { - "name":"三江侗族自治县", - "code":"450226" - } - ] + name: '三江侗族自治县', + code: '450226', + }, + ], }, { - "name":"桂林市", - "code":"450300", - "sub":[ + name: '桂林市', + code: '450300', + sub: [ { - "name":"市辖区", - "code":"450301" + name: '市辖区', + code: '450301', }, { - "name":"秀峰区", - "code":"450302" + name: '秀峰区', + code: '450302', }, { - "name":"叠彩区", - "code":"450303" + name: '叠彩区', + code: '450303', }, { - "name":"象山区", - "code":"450304" + name: '象山区', + code: '450304', }, { - "name":"七星区", - "code":"450305" + name: '七星区', + code: '450305', }, { - "name":"雁山区", - "code":"450311" + name: '雁山区', + code: '450311', }, { - "name":"临桂区", - "code":"450312" + name: '临桂区', + code: '450312', }, { - "name":"阳朔县", - "code":"450321" + name: '阳朔县', + code: '450321', }, { - "name":"灵川县", - "code":"450323" + name: '灵川县', + code: '450323', }, { - "name":"全州县", - "code":"450324" + name: '全州县', + code: '450324', }, { - "name":"兴安县", - "code":"450325" + name: '兴安县', + code: '450325', }, { - "name":"永福县", - "code":"450326" + name: '永福县', + code: '450326', }, { - "name":"灌阳县", - "code":"450327" + name: '灌阳县', + code: '450327', }, { - "name":"龙胜各族自治县", - "code":"450328" + name: '龙胜各族自治县', + code: '450328', }, { - "name":"资源县", - "code":"450329" + name: '资源县', + code: '450329', }, { - "name":"平乐县", - "code":"450330" + name: '平乐县', + code: '450330', }, { - "name":"荔浦县", - "code":"450331" + name: '荔浦县', + code: '450331', }, { - "name":"恭城瑶族自治县", - "code":"450332" - } - ] + name: '恭城瑶族自治县', + code: '450332', + }, + ], }, { - "name":"梧州市", - "code":"450400", - "sub":[ + name: '梧州市', + code: '450400', + sub: [ { - "name":"市辖区", - "code":"450401" + name: '市辖区', + code: '450401', }, { - "name":"万秀区", - "code":"450403" + name: '万秀区', + code: '450403', }, { - "name":"长洲区", - "code":"450405" + name: '长洲区', + code: '450405', }, { - "name":"龙圩区", - "code":"450406" + name: '龙圩区', + code: '450406', }, { - "name":"苍梧县", - "code":"450421" + name: '苍梧县', + code: '450421', }, { - "name":"藤县", - "code":"450422" + name: '藤县', + code: '450422', }, { - "name":"蒙山县", - "code":"450423" + name: '蒙山县', + code: '450423', }, { - "name":"岑溪市", - "code":"450481" - } - ] + name: '岑溪市', + code: '450481', + }, + ], }, { - "name":"北海市", - "code":"450500", - "sub":[ + name: '北海市', + code: '450500', + sub: [ { - "name":"市辖区", - "code":"450501" + name: '市辖区', + code: '450501', }, { - "name":"海城区", - "code":"450502" + name: '海城区', + code: '450502', }, { - "name":"银海区", - "code":"450503" + name: '银海区', + code: '450503', }, { - "name":"铁山港区", - "code":"450512" + name: '铁山港区', + code: '450512', }, { - "name":"合浦县", - "code":"450521" - } - ] + name: '合浦县', + code: '450521', + }, + ], }, { - "name":"防城港市", - "code":"450600", - "sub":[ + name: '防城港市', + code: '450600', + sub: [ { - "name":"市辖区", - "code":"450601" + name: '市辖区', + code: '450601', }, { - "name":"港口区", - "code":"450602" + name: '港口区', + code: '450602', }, { - "name":"防城区", - "code":"450603" + name: '防城区', + code: '450603', }, { - "name":"上思县", - "code":"450621" + name: '上思县', + code: '450621', }, { - "name":"东兴市", - "code":"450681" - } - ] + name: '东兴市', + code: '450681', + }, + ], }, { - "name":"钦州市", - "code":"450700", - "sub":[ + name: '钦州市', + code: '450700', + sub: [ { - "name":"市辖区", - "code":"450701" + name: '市辖区', + code: '450701', }, { - "name":"钦南区", - "code":"450702" + name: '钦南区', + code: '450702', }, { - "name":"钦北区", - "code":"450703" + name: '钦北区', + code: '450703', }, { - "name":"灵山县", - "code":"450721" + name: '灵山县', + code: '450721', }, { - "name":"浦北县", - "code":"450722" - } - ] + name: '浦北县', + code: '450722', + }, + ], }, { - "name":"贵港市", - "code":"450800", - "sub":[ + name: '贵港市', + code: '450800', + sub: [ { - "name":"市辖区", - "code":"450801" + name: '市辖区', + code: '450801', }, { - "name":"港北区", - "code":"450802" + name: '港北区', + code: '450802', }, { - "name":"港南区", - "code":"450803" + name: '港南区', + code: '450803', }, { - "name":"覃塘区", - "code":"450804" + name: '覃塘区', + code: '450804', }, { - "name":"平南县", - "code":"450821" + name: '平南县', + code: '450821', }, { - "name":"桂平市", - "code":"450881" - } - ] + name: '桂平市', + code: '450881', + }, + ], }, { - "name":"玉林市", - "code":"450900", - "sub":[ + name: '玉林市', + code: '450900', + sub: [ { - "name":"市辖区", - "code":"450901" + name: '市辖区', + code: '450901', }, { - "name":"玉州区", - "code":"450902" + name: '玉州区', + code: '450902', }, { - "name":"福绵区", - "code":"450903" + name: '福绵区', + code: '450903', }, { - "name":"容县", - "code":"450921" + name: '容县', + code: '450921', }, { - "name":"陆川县", - "code":"450922" + name: '陆川县', + code: '450922', }, { - "name":"博白县", - "code":"450923" + name: '博白县', + code: '450923', }, { - "name":"兴业县", - "code":"450924" + name: '兴业县', + code: '450924', }, { - "name":"北流市", - "code":"450981" - } - ] + name: '北流市', + code: '450981', + }, + ], }, { - "name":"百色市", - "code":"451000", - "sub":[ + name: '百色市', + code: '451000', + sub: [ { - "name":"市辖区", - "code":"451001" + name: '市辖区', + code: '451001', }, { - "name":"右江区", - "code":"451002" + name: '右江区', + code: '451002', }, { - "name":"田阳县", - "code":"451021" + name: '田阳县', + code: '451021', }, { - "name":"田东县", - "code":"451022" + name: '田东县', + code: '451022', }, { - "name":"平果县", - "code":"451023" + name: '平果县', + code: '451023', }, { - "name":"德保县", - "code":"451024" + name: '德保县', + code: '451024', }, { - "name":"靖西县", - "code":"451025" + name: '靖西县', + code: '451025', }, { - "name":"那坡县", - "code":"451026" + name: '那坡县', + code: '451026', }, { - "name":"凌云县", - "code":"451027" + name: '凌云县', + code: '451027', }, { - "name":"乐业县", - "code":"451028" + name: '乐业县', + code: '451028', }, { - "name":"田林县", - "code":"451029" + name: '田林县', + code: '451029', }, { - "name":"西林县", - "code":"451030" + name: '西林县', + code: '451030', }, { - "name":"隆林各族自治县", - "code":"451031" - } - ] + name: '隆林各族自治县', + code: '451031', + }, + ], }, { - "name":"贺州市", - "code":"451100", - "sub":[ + name: '贺州市', + code: '451100', + sub: [ { - "name":"市辖区", - "code":"451101" + name: '市辖区', + code: '451101', }, { - "name":"八步区", - "code":"451102" + name: '八步区', + code: '451102', }, { - "name":"平桂管理区", - "code":"451119" + name: '平桂管理区', + code: '451119', }, { - "name":"昭平县", - "code":"451121" + name: '昭平县', + code: '451121', }, { - "name":"钟山县", - "code":"451122" + name: '钟山县', + code: '451122', }, { - "name":"富川瑶族自治县", - "code":"451123" - } - ] + name: '富川瑶族自治县', + code: '451123', + }, + ], }, { - "name":"河池市", - "code":"451200", - "sub":[ + name: '河池市', + code: '451200', + sub: [ { - "name":"市辖区", - "code":"451201" + name: '市辖区', + code: '451201', }, { - "name":"金城江区", - "code":"451202" + name: '金城江区', + code: '451202', }, { - "name":"南丹县", - "code":"451221" + name: '南丹县', + code: '451221', }, { - "name":"天峨县", - "code":"451222" + name: '天峨县', + code: '451222', }, { - "name":"凤山县", - "code":"451223" + name: '凤山县', + code: '451223', }, { - "name":"东兰县", - "code":"451224" + name: '东兰县', + code: '451224', }, { - "name":"罗城仫佬族自治县", - "code":"451225" + name: '罗城仫佬族自治县', + code: '451225', }, { - "name":"环江毛南族自治县", - "code":"451226" + name: '环江毛南族自治县', + code: '451226', }, { - "name":"巴马瑶族自治县", - "code":"451227" + name: '巴马瑶族自治县', + code: '451227', }, { - "name":"都安瑶族自治县", - "code":"451228" + name: '都安瑶族自治县', + code: '451228', }, { - "name":"大化瑶族自治县", - "code":"451229" + name: '大化瑶族自治县', + code: '451229', }, { - "name":"宜州市", - "code":"451281" - } - ] + name: '宜州市', + code: '451281', + }, + ], }, { - "name":"来宾市", - "code":"451300", - "sub":[ + name: '来宾市', + code: '451300', + sub: [ { - "name":"市辖区", - "code":"451301" + name: '市辖区', + code: '451301', }, { - "name":"兴宾区", - "code":"451302" + name: '兴宾区', + code: '451302', }, { - "name":"忻城县", - "code":"451321" + name: '忻城县', + code: '451321', }, { - "name":"象州县", - "code":"451322" + name: '象州县', + code: '451322', }, { - "name":"武宣县", - "code":"451323" + name: '武宣县', + code: '451323', }, { - "name":"金秀瑶族自治县", - "code":"451324" + name: '金秀瑶族自治县', + code: '451324', }, { - "name":"合山市", - "code":"451381" - } - ] + name: '合山市', + code: '451381', + }, + ], }, { - "name":"崇左市", - "code":"451400", - "sub":[ + name: '崇左市', + code: '451400', + sub: [ { - "name":"市辖区", - "code":"451401" + name: '市辖区', + code: '451401', }, { - "name":"江州区", - "code":"451402" + name: '江州区', + code: '451402', }, { - "name":"扶绥县", - "code":"451421" + name: '扶绥县', + code: '451421', }, { - "name":"宁明县", - "code":"451422" + name: '宁明县', + code: '451422', }, { - "name":"龙州县", - "code":"451423" + name: '龙州县', + code: '451423', }, { - "name":"大新县", - "code":"451424" + name: '大新县', + code: '451424', }, { - "name":"天等县", - "code":"451425" + name: '天等县', + code: '451425', }, { - "name":"凭祥市", - "code":"451481" - } - ] - } - ] + name: '凭祥市', + code: '451481', + }, + ], + }, + ], }, { - "name":"海南省", - "code":"460000", - "sub":[ + name: '海南省', + code: '460000', + sub: [ { - "name":"海口市", - "code":"460100", - "sub":[ + name: '海口市', + code: '460100', + sub: [ { - "name":"市辖区", - "code":"460101" + name: '市辖区', + code: '460101', }, { - "name":"秀英区", - "code":"460105" + name: '秀英区', + code: '460105', }, { - "name":"龙华区", - "code":"460106" + name: '龙华区', + code: '460106', }, { - "name":"琼山区", - "code":"460107" + name: '琼山区', + code: '460107', }, { - "name":"美兰区", - "code":"460108" - } - ] + name: '美兰区', + code: '460108', + }, + ], }, { - "name":"三亚市", - "code":"460200", - "sub":[ + name: '三亚市', + code: '460200', + sub: [ { - "name":"市辖区", - "code":"460201" + name: '市辖区', + code: '460201', }, { - "name":"海棠区", - "code":"460202" + name: '海棠区', + code: '460202', }, { - "name":"吉阳区", - "code":"460203" + name: '吉阳区', + code: '460203', }, { - "name":"天涯区", - "code":"460204" + name: '天涯区', + code: '460204', }, { - "name":"崖州区", - "code":"460205" - } - ] + name: '崖州区', + code: '460205', + }, + ], }, { - "name":"三沙市", - "code":"460300", - "sub":[ + name: '三沙市', + code: '460300', + sub: [ { - "name":"西沙群岛", - "code":"460321" + name: '西沙群岛', + code: '460321', }, { - "name":"南沙群岛", - "code":"460322" + name: '南沙群岛', + code: '460322', }, { - "name":"中沙群岛的岛礁及其海域", - "code":"460323" - } - ] + name: '中沙群岛的岛礁及其海域', + code: '460323', + }, + ], }, { - "name":"五指山市", - "code":"469001" + name: '五指山市', + code: '469001', }, { - "name":"琼海市", - "code":"469002" + name: '琼海市', + code: '469002', }, { - "name":"儋州市", - "code":"469003" + name: '儋州市', + code: '469003', }, { - "name":"文昌市", - "code":"469005" + name: '文昌市', + code: '469005', }, { - "name":"万宁市", - "code":"469006" + name: '万宁市', + code: '469006', }, { - "name":"东方市", - "code":"469007" + name: '东方市', + code: '469007', }, { - "name":"定安县", - "code":"469021" + name: '定安县', + code: '469021', }, { - "name":"屯昌县", - "code":"469022" + name: '屯昌县', + code: '469022', }, { - "name":"澄迈县", - "code":"469023" + name: '澄迈县', + code: '469023', }, { - "name":"临高县", - "code":"469024" + name: '临高县', + code: '469024', }, { - "name":"白沙黎族自治县", - "code":"469025" + name: '白沙黎族自治县', + code: '469025', }, { - "name":"昌江黎族自治县", - "code":"469026" + name: '昌江黎族自治县', + code: '469026', }, { - "name":"乐东黎族自治县", - "code":"469027" + name: '乐东黎族自治县', + code: '469027', }, { - "name":"陵水黎族自治县", - "code":"469028" + name: '陵水黎族自治县', + code: '469028', }, { - "name":"保亭黎族苗族自治县", - "code":"469029" + name: '保亭黎族苗族自治县', + code: '469029', }, { - "name":"琼中黎族苗族自治县", - "code":"469030" - } - ] + name: '琼中黎族苗族自治县', + code: '469030', + }, + ], }, { - "name":"重庆", - "code":"500000", - "sub": [ - { - "name": "重庆市", - "code": "500000", - "sub":[ - { - "name":"万州区", - "code":"500101" - }, - { - "name":"涪陵区", - "code":"500102" - }, - { - "name":"渝中区", - "code":"500103" - }, - { - "name":"大渡口区", - "code":"500104" - }, - { - "name":"江北区", - "code":"500105" - }, - { - "name":"沙坪坝区", - "code":"500106" - }, - { - "name":"九龙坡区", - "code":"500107" - }, - { - "name":"南岸区", - "code":"500108" - }, - { - "name":"北碚区", - "code":"500109" - }, - { - "name":"綦江区", - "code":"500110" - }, - { - "name":"大足区", - "code":"500111" - }, - { - "name":"渝北区", - "code":"500112" - }, - { - "name":"巴南区", - "code":"500113" - }, - { - "name":"黔江区", - "code":"500114" - }, - { - "name":"长寿区", - "code":"500115" - }, - { - "name":"江津区", - "code":"500116" - }, - { - "name":"合川区", - "code":"500117" - }, - { - "name":"永川区", - "code":"500118" - }, - { - "name":"南川区", - "code":"500119" - }, - { - "name":"璧山区", - "code":"500120" - }, - { - "name":"铜梁区", - "code":"500151" - }, - { - "name":"潼南县", - "code":"500223" - }, - { - "name":"荣昌县", - "code":"500226" - }, - { - "name":"梁平县", - "code":"500228" - }, - { - "name":"城口县", - "code":"500229" - }, - { - "name":"丰都县", - "code":"500230" - }, - { - "name":"垫江县", - "code":"500231" - }, - { - "name":"武隆县", - "code":"500232" - }, - { - "name":"忠县", - "code":"500233" - }, - { - "name":"开县", - "code":"500234" - }, - { - "name":"云阳县", - "code":"500235" - }, - { - "name":"奉节县", - "code":"500236" - }, - { - "name":"巫山县", - "code":"500237" - }, - { - "name":"巫溪县", - "code":"500238" - }, - { - "name":"石柱土家族自治县", - "code":"500240" - }, - { - "name":"秀山土家族苗族自治县", - "code":"500241" - }, - { - "name":"酉阳土家族苗族自治县", - "code":"500242" - }, - { - "name":"彭水苗族土家族自治县", - "code":"500243" - } - ] - } - ] + name: '重庆', + code: '500000', + sub: [ + { + name: '重庆市', + code: '500000', + sub: [ + { + name: '万州区', + code: '500101', + }, + { + name: '涪陵区', + code: '500102', + }, + { + name: '渝中区', + code: '500103', + }, + { + name: '大渡口区', + code: '500104', + }, + { + name: '江北区', + code: '500105', + }, + { + name: '沙坪坝区', + code: '500106', + }, + { + name: '九龙坡区', + code: '500107', + }, + { + name: '南岸区', + code: '500108', + }, + { + name: '北碚区', + code: '500109', + }, + { + name: '綦江区', + code: '500110', + }, + { + name: '大足区', + code: '500111', + }, + { + name: '渝北区', + code: '500112', + }, + { + name: '巴南区', + code: '500113', + }, + { + name: '黔江区', + code: '500114', + }, + { + name: '长寿区', + code: '500115', + }, + { + name: '江津区', + code: '500116', + }, + { + name: '合川区', + code: '500117', + }, + { + name: '永川区', + code: '500118', + }, + { + name: '南川区', + code: '500119', + }, + { + name: '璧山区', + code: '500120', + }, + { + name: '铜梁区', + code: '500151', + }, + { + name: '潼南县', + code: '500223', + }, + { + name: '荣昌县', + code: '500226', + }, + { + name: '梁平县', + code: '500228', + }, + { + name: '城口县', + code: '500229', + }, + { + name: '丰都县', + code: '500230', + }, + { + name: '垫江县', + code: '500231', + }, + { + name: '武隆县', + code: '500232', + }, + { + name: '忠县', + code: '500233', + }, + { + name: '开县', + code: '500234', + }, + { + name: '云阳县', + code: '500235', + }, + { + name: '奉节县', + code: '500236', + }, + { + name: '巫山县', + code: '500237', + }, + { + name: '巫溪县', + code: '500238', + }, + { + name: '石柱土家族自治县', + code: '500240', + }, + { + name: '秀山土家族苗族自治县', + code: '500241', + }, + { + name: '酉阳土家族苗族自治县', + code: '500242', + }, + { + name: '彭水苗族土家族自治县', + code: '500243', + }, + ], + }, + ], }, { - "name":"四川省", - "code":"510000", - "sub":[ + name: '四川省', + code: '510000', + sub: [ { - "name":"成都市", - "code":"510100", - "sub":[ + name: '成都市', + code: '510100', + sub: [ { - "name":"市辖区", - "code":"510101" + name: '市辖区', + code: '510101', }, { - "name":"锦江区", - "code":"510104" + name: '锦江区', + code: '510104', }, { - "name":"青羊区", - "code":"510105" + name: '青羊区', + code: '510105', }, { - "name":"金牛区", - "code":"510106" + name: '金牛区', + code: '510106', }, { - "name":"武侯区", - "code":"510107" + name: '武侯区', + code: '510107', }, { - "name":"成华区", - "code":"510108" + name: '成华区', + code: '510108', }, { - "name":"龙泉驿区", - "code":"510112" + name: '龙泉驿区', + code: '510112', }, { - "name":"青白江区", - "code":"510113" + name: '青白江区', + code: '510113', }, { - "name":"新都区", - "code":"510114" + name: '新都区', + code: '510114', }, { - "name":"温江区", - "code":"510115" + name: '温江区', + code: '510115', }, { - "name":"金堂县", - "code":"510121" + name: '金堂县', + code: '510121', }, { - "name":"双流县", - "code":"510122" + name: '双流县', + code: '510122', }, { - "name":"郫县", - "code":"510124" + name: '郫县', + code: '510124', }, { - "name":"大邑县", - "code":"510129" + name: '大邑县', + code: '510129', }, { - "name":"蒲江县", - "code":"510131" + name: '蒲江县', + code: '510131', }, { - "name":"新津县", - "code":"510132" + name: '新津县', + code: '510132', }, { - "name":"都江堰市", - "code":"510181" + name: '都江堰市', + code: '510181', }, { - "name":"彭州市", - "code":"510182" + name: '彭州市', + code: '510182', }, { - "name":"邛崃市", - "code":"510183" + name: '邛崃市', + code: '510183', }, { - "name":"崇州市", - "code":"510184" - } - ] + name: '崇州市', + code: '510184', + }, + ], }, { - "name":"自贡市", - "code":"510300", - "sub":[ + name: '自贡市', + code: '510300', + sub: [ { - "name":"市辖区", - "code":"510301" + name: '市辖区', + code: '510301', }, { - "name":"自流井区", - "code":"510302" + name: '自流井区', + code: '510302', }, { - "name":"贡井区", - "code":"510303" + name: '贡井区', + code: '510303', }, { - "name":"大安区", - "code":"510304" + name: '大安区', + code: '510304', }, { - "name":"沿滩区", - "code":"510311" + name: '沿滩区', + code: '510311', }, { - "name":"荣县", - "code":"510321" + name: '荣县', + code: '510321', }, { - "name":"富顺县", - "code":"510322" - } - ] + name: '富顺县', + code: '510322', + }, + ], }, { - "name":"攀枝花市", - "code":"510400", - "sub":[ + name: '攀枝花市', + code: '510400', + sub: [ { - "name":"市辖区", - "code":"510401" + name: '市辖区', + code: '510401', }, { - "name":"东区", - "code":"510402" + name: '东区', + code: '510402', }, { - "name":"西区", - "code":"510403" + name: '西区', + code: '510403', }, { - "name":"仁和区", - "code":"510411" + name: '仁和区', + code: '510411', }, { - "name":"米易县", - "code":"510421" + name: '米易县', + code: '510421', }, { - "name":"盐边县", - "code":"510422" - } - ] + name: '盐边县', + code: '510422', + }, + ], }, { - "name":"泸州市", - "code":"510500", - "sub":[ + name: '泸州市', + code: '510500', + sub: [ { - "name":"市辖区", - "code":"510501" + name: '市辖区', + code: '510501', }, { - "name":"江阳区", - "code":"510502" + name: '江阳区', + code: '510502', }, { - "name":"纳溪区", - "code":"510503" + name: '纳溪区', + code: '510503', }, { - "name":"龙马潭区", - "code":"510504" + name: '龙马潭区', + code: '510504', }, { - "name":"泸县", - "code":"510521" + name: '泸县', + code: '510521', }, { - "name":"合江县", - "code":"510522" + name: '合江县', + code: '510522', }, { - "name":"叙永县", - "code":"510524" + name: '叙永县', + code: '510524', }, { - "name":"古蔺县", - "code":"510525" - } - ] + name: '古蔺县', + code: '510525', + }, + ], }, { - "name":"德阳市", - "code":"510600", - "sub":[ + name: '德阳市', + code: '510600', + sub: [ { - "name":"市辖区", - "code":"510601" + name: '市辖区', + code: '510601', }, { - "name":"旌阳区", - "code":"510603" + name: '旌阳区', + code: '510603', }, { - "name":"中江县", - "code":"510623" + name: '中江县', + code: '510623', }, { - "name":"罗江县", - "code":"510626" + name: '罗江县', + code: '510626', }, { - "name":"广汉市", - "code":"510681" + name: '广汉市', + code: '510681', }, { - "name":"什邡市", - "code":"510682" + name: '什邡市', + code: '510682', }, { - "name":"绵竹市", - "code":"510683" - } - ] + name: '绵竹市', + code: '510683', + }, + ], }, { - "name":"绵阳市", - "code":"510700", - "sub":[ + name: '绵阳市', + code: '510700', + sub: [ { - "name":"市辖区", - "code":"510701" + name: '市辖区', + code: '510701', }, { - "name":"涪城区", - "code":"510703" + name: '涪城区', + code: '510703', }, { - "name":"游仙区", - "code":"510704" + name: '游仙区', + code: '510704', }, { - "name":"三台县", - "code":"510722" + name: '三台县', + code: '510722', }, { - "name":"盐亭县", - "code":"510723" + name: '盐亭县', + code: '510723', }, { - "name":"安县", - "code":"510724" + name: '安县', + code: '510724', }, { - "name":"梓潼县", - "code":"510725" + name: '梓潼县', + code: '510725', }, { - "name":"北川羌族自治县", - "code":"510726" + name: '北川羌族自治县', + code: '510726', }, { - "name":"平武县", - "code":"510727" + name: '平武县', + code: '510727', }, { - "name":"江油市", - "code":"510781" - } - ] + name: '江油市', + code: '510781', + }, + ], }, { - "name":"广元市", - "code":"510800", - "sub":[ + name: '广元市', + code: '510800', + sub: [ { - "name":"市辖区", - "code":"510801" + name: '市辖区', + code: '510801', }, { - "name":"利州区", - "code":"510802" + name: '利州区', + code: '510802', }, { - "name":"昭化区", - "code":"510811" + name: '昭化区', + code: '510811', }, { - "name":"朝天区", - "code":"510812" + name: '朝天区', + code: '510812', }, { - "name":"旺苍县", - "code":"510821" + name: '旺苍县', + code: '510821', }, { - "name":"青川县", - "code":"510822" + name: '青川县', + code: '510822', }, { - "name":"剑阁县", - "code":"510823" + name: '剑阁县', + code: '510823', }, { - "name":"苍溪县", - "code":"510824" - } - ] + name: '苍溪县', + code: '510824', + }, + ], }, { - "name":"遂宁市", - "code":"510900", - "sub":[ + name: '遂宁市', + code: '510900', + sub: [ { - "name":"市辖区", - "code":"510901" + name: '市辖区', + code: '510901', }, { - "name":"船山区", - "code":"510903" + name: '船山区', + code: '510903', }, { - "name":"安居区", - "code":"510904" + name: '安居区', + code: '510904', }, { - "name":"蓬溪县", - "code":"510921" + name: '蓬溪县', + code: '510921', }, { - "name":"射洪县", - "code":"510922" + name: '射洪县', + code: '510922', }, { - "name":"大英县", - "code":"510923" - } - ] + name: '大英县', + code: '510923', + }, + ], }, { - "name":"内江市", - "code":"511000", - "sub":[ + name: '内江市', + code: '511000', + sub: [ { - "name":"市辖区", - "code":"511001" + name: '市辖区', + code: '511001', }, { - "name":"市中区", - "code":"511002" + name: '市中区', + code: '511002', }, { - "name":"东兴区", - "code":"511011" + name: '东兴区', + code: '511011', }, { - "name":"威远县", - "code":"511024" + name: '威远县', + code: '511024', }, { - "name":"资中县", - "code":"511025" + name: '资中县', + code: '511025', }, { - "name":"隆昌县", - "code":"511028" - } - ] + name: '隆昌县', + code: '511028', + }, + ], }, { - "name":"乐山市", - "code":"511100", - "sub":[ + name: '乐山市', + code: '511100', + sub: [ { - "name":"市辖区", - "code":"511101" + name: '市辖区', + code: '511101', }, { - "name":"市中区", - "code":"511102" + name: '市中区', + code: '511102', }, { - "name":"沙湾区", - "code":"511111" + name: '沙湾区', + code: '511111', }, { - "name":"五通桥区", - "code":"511112" + name: '五通桥区', + code: '511112', }, { - "name":"金口河区", - "code":"511113" + name: '金口河区', + code: '511113', }, { - "name":"犍为县", - "code":"511123" + name: '犍为县', + code: '511123', }, { - "name":"井研县", - "code":"511124" + name: '井研县', + code: '511124', }, { - "name":"夹江县", - "code":"511126" + name: '夹江县', + code: '511126', }, { - "name":"沐川县", - "code":"511129" + name: '沐川县', + code: '511129', }, { - "name":"峨边彝族自治县", - "code":"511132" + name: '峨边彝族自治县', + code: '511132', }, { - "name":"马边彝族自治县", - "code":"511133" + name: '马边彝族自治县', + code: '511133', }, { - "name":"峨眉山市", - "code":"511181" - } - ] + name: '峨眉山市', + code: '511181', + }, + ], }, { - "name":"南充市", - "code":"511300", - "sub":[ + name: '南充市', + code: '511300', + sub: [ { - "name":"市辖区", - "code":"511301" + name: '市辖区', + code: '511301', }, { - "name":"顺庆区", - "code":"511302" + name: '顺庆区', + code: '511302', }, { - "name":"高坪区", - "code":"511303" + name: '高坪区', + code: '511303', }, { - "name":"嘉陵区", - "code":"511304" + name: '嘉陵区', + code: '511304', }, { - "name":"南部县", - "code":"511321" + name: '南部县', + code: '511321', }, { - "name":"营山县", - "code":"511322" + name: '营山县', + code: '511322', }, { - "name":"蓬安县", - "code":"511323" + name: '蓬安县', + code: '511323', }, { - "name":"仪陇县", - "code":"511324" + name: '仪陇县', + code: '511324', }, { - "name":"西充县", - "code":"511325" + name: '西充县', + code: '511325', }, { - "name":"阆中市", - "code":"511381" - } - ] + name: '阆中市', + code: '511381', + }, + ], }, { - "name":"眉山市", - "code":"511400", - "sub":[ + name: '眉山市', + code: '511400', + sub: [ { - "name":"市辖区", - "code":"511401" + name: '市辖区', + code: '511401', }, { - "name":"东坡区", - "code":"511402" + name: '东坡区', + code: '511402', }, { - "name":"彭山区", - "code":"511403" + name: '彭山区', + code: '511403', }, { - "name":"仁寿县", - "code":"511421" + name: '仁寿县', + code: '511421', }, { - "name":"洪雅县", - "code":"511423" + name: '洪雅县', + code: '511423', }, { - "name":"丹棱县", - "code":"511424" + name: '丹棱县', + code: '511424', }, { - "name":"青神县", - "code":"511425" - } - ] + name: '青神县', + code: '511425', + }, + ], }, { - "name":"宜宾市", - "code":"511500", - "sub":[ + name: '宜宾市', + code: '511500', + sub: [ { - "name":"市辖区", - "code":"511501" + name: '市辖区', + code: '511501', }, { - "name":"翠屏区", - "code":"511502" + name: '翠屏区', + code: '511502', }, { - "name":"南溪区", - "code":"511503" + name: '南溪区', + code: '511503', }, { - "name":"宜宾县", - "code":"511521" + name: '宜宾县', + code: '511521', }, { - "name":"江安县", - "code":"511523" + name: '江安县', + code: '511523', }, { - "name":"长宁县", - "code":"511524" + name: '长宁县', + code: '511524', }, { - "name":"高县", - "code":"511525" + name: '高县', + code: '511525', }, { - "name":"珙县", - "code":"511526" + name: '珙县', + code: '511526', }, { - "name":"筠连县", - "code":"511527" + name: '筠连县', + code: '511527', }, { - "name":"兴文县", - "code":"511528" + name: '兴文县', + code: '511528', }, { - "name":"屏山县", - "code":"511529" - } - ] + name: '屏山县', + code: '511529', + }, + ], }, { - "name":"广安市", - "code":"511600", - "sub":[ + name: '广安市', + code: '511600', + sub: [ { - "name":"市辖区", - "code":"511601" + name: '市辖区', + code: '511601', }, { - "name":"广安区", - "code":"511602" + name: '广安区', + code: '511602', }, { - "name":"前锋区", - "code":"511603" + name: '前锋区', + code: '511603', }, { - "name":"岳池县", - "code":"511621" + name: '岳池县', + code: '511621', }, { - "name":"武胜县", - "code":"511622" + name: '武胜县', + code: '511622', }, { - "name":"邻水县", - "code":"511623" + name: '邻水县', + code: '511623', }, { - "name":"华蓥市", - "code":"511681" - } - ] + name: '华蓥市', + code: '511681', + }, + ], }, { - "name":"达州市", - "code":"511700", - "sub":[ + name: '达州市', + code: '511700', + sub: [ { - "name":"市辖区", - "code":"511701" + name: '市辖区', + code: '511701', }, { - "name":"通川区", - "code":"511702" + name: '通川区', + code: '511702', }, { - "name":"达川区", - "code":"511703" + name: '达川区', + code: '511703', }, { - "name":"宣汉县", - "code":"511722" + name: '宣汉县', + code: '511722', }, { - "name":"开江县", - "code":"511723" + name: '开江县', + code: '511723', }, { - "name":"大竹县", - "code":"511724" + name: '大竹县', + code: '511724', }, { - "name":"渠县", - "code":"511725" + name: '渠县', + code: '511725', }, { - "name":"万源市", - "code":"511781" - } - ] + name: '万源市', + code: '511781', + }, + ], }, { - "name":"雅安市", - "code":"511800", - "sub":[ + name: '雅安市', + code: '511800', + sub: [ { - "name":"市辖区", - "code":"511801" + name: '市辖区', + code: '511801', }, { - "name":"雨城区", - "code":"511802" + name: '雨城区', + code: '511802', }, { - "name":"名山区", - "code":"511803" + name: '名山区', + code: '511803', }, { - "name":"荥经县", - "code":"511822" + name: '荥经县', + code: '511822', }, { - "name":"汉源县", - "code":"511823" + name: '汉源县', + code: '511823', }, { - "name":"石棉县", - "code":"511824" + name: '石棉县', + code: '511824', }, { - "name":"天全县", - "code":"511825" + name: '天全县', + code: '511825', }, { - "name":"芦山县", - "code":"511826" + name: '芦山县', + code: '511826', }, { - "name":"宝兴县", - "code":"511827" - } - ] + name: '宝兴县', + code: '511827', + }, + ], }, { - "name":"巴中市", - "code":"511900", - "sub":[ + name: '巴中市', + code: '511900', + sub: [ { - "name":"市辖区", - "code":"511901" + name: '市辖区', + code: '511901', }, { - "name":"巴州区", - "code":"511902" + name: '巴州区', + code: '511902', }, { - "name":"恩阳区", - "code":"511903" + name: '恩阳区', + code: '511903', }, { - "name":"通江县", - "code":"511921" + name: '通江县', + code: '511921', }, { - "name":"南江县", - "code":"511922" + name: '南江县', + code: '511922', }, { - "name":"平昌县", - "code":"511923" - } - ] + name: '平昌县', + code: '511923', + }, + ], }, { - "name":"资阳市", - "code":"512000", - "sub":[ + name: '资阳市', + code: '512000', + sub: [ { - "name":"市辖区", - "code":"512001" + name: '市辖区', + code: '512001', }, { - "name":"雁江区", - "code":"512002" + name: '雁江区', + code: '512002', }, { - "name":"安岳县", - "code":"512021" + name: '安岳县', + code: '512021', }, { - "name":"乐至县", - "code":"512022" + name: '乐至县', + code: '512022', }, { - "name":"简阳市", - "code":"512081" - } - ] + name: '简阳市', + code: '512081', + }, + ], }, { - "name":"阿坝藏族羌族自治州", - "code":"513200", - "sub":[ + name: '阿坝藏族羌族自治州', + code: '513200', + sub: [ { - "name":"汶川县", - "code":"513221" + name: '汶川县', + code: '513221', }, { - "name":"理县", - "code":"513222" + name: '理县', + code: '513222', }, { - "name":"茂县", - "code":"513223" + name: '茂县', + code: '513223', }, { - "name":"松潘县", - "code":"513224" + name: '松潘县', + code: '513224', }, { - "name":"九寨沟县", - "code":"513225" + name: '九寨沟县', + code: '513225', }, { - "name":"金川县", - "code":"513226" + name: '金川县', + code: '513226', }, { - "name":"小金县", - "code":"513227" + name: '小金县', + code: '513227', }, { - "name":"黑水县", - "code":"513228" + name: '黑水县', + code: '513228', }, { - "name":"马尔康县", - "code":"513229" + name: '马尔康县', + code: '513229', }, { - "name":"壤塘县", - "code":"513230" + name: '壤塘县', + code: '513230', }, { - "name":"阿坝县", - "code":"513231" + name: '阿坝县', + code: '513231', }, { - "name":"若尔盖县", - "code":"513232" + name: '若尔盖县', + code: '513232', }, { - "name":"红原县", - "code":"513233" - } - ] + name: '红原县', + code: '513233', + }, + ], }, { - "name":"甘孜藏族自治州", - "code":"513300", - "sub":[ + name: '甘孜藏族自治州', + code: '513300', + sub: [ { - "name":"康定县", - "code":"513321" + name: '康定县', + code: '513321', }, { - "name":"泸定县", - "code":"513322" + name: '泸定县', + code: '513322', }, { - "name":"丹巴县", - "code":"513323" + name: '丹巴县', + code: '513323', }, { - "name":"九龙县", - "code":"513324" + name: '九龙县', + code: '513324', }, { - "name":"雅江县", - "code":"513325" + name: '雅江县', + code: '513325', }, { - "name":"道孚县", - "code":"513326" + name: '道孚县', + code: '513326', }, { - "name":"炉霍县", - "code":"513327" + name: '炉霍县', + code: '513327', }, { - "name":"甘孜县", - "code":"513328" + name: '甘孜县', + code: '513328', }, { - "name":"新龙县", - "code":"513329" + name: '新龙县', + code: '513329', }, { - "name":"德格县", - "code":"513330" + name: '德格县', + code: '513330', }, { - "name":"白玉县", - "code":"513331" + name: '白玉县', + code: '513331', }, { - "name":"石渠县", - "code":"513332" + name: '石渠县', + code: '513332', }, { - "name":"色达县", - "code":"513333" + name: '色达县', + code: '513333', }, { - "name":"理塘县", - "code":"513334" + name: '理塘县', + code: '513334', }, { - "name":"巴塘县", - "code":"513335" + name: '巴塘县', + code: '513335', }, { - "name":"乡城县", - "code":"513336" + name: '乡城县', + code: '513336', }, { - "name":"稻城县", - "code":"513337" + name: '稻城县', + code: '513337', }, { - "name":"得荣县", - "code":"513338" - } - ] + name: '得荣县', + code: '513338', + }, + ], }, { - "name":"凉山彝族自治州", - "code":"513400", - "sub":[ + name: '凉山彝族自治州', + code: '513400', + sub: [ { - "name":"西昌市", - "code":"513401" + name: '西昌市', + code: '513401', }, { - "name":"木里藏族自治县", - "code":"513422" + name: '木里藏族自治县', + code: '513422', }, { - "name":"盐源县", - "code":"513423" + name: '盐源县', + code: '513423', }, { - "name":"德昌县", - "code":"513424" + name: '德昌县', + code: '513424', }, { - "name":"会理县", - "code":"513425" + name: '会理县', + code: '513425', }, { - "name":"会东县", - "code":"513426" + name: '会东县', + code: '513426', }, { - "name":"宁南县", - "code":"513427" + name: '宁南县', + code: '513427', }, { - "name":"普格县", - "code":"513428" + name: '普格县', + code: '513428', }, { - "name":"布拖县", - "code":"513429" + name: '布拖县', + code: '513429', }, { - "name":"金阳县", - "code":"513430" + name: '金阳县', + code: '513430', }, { - "name":"昭觉县", - "code":"513431" + name: '昭觉县', + code: '513431', }, { - "name":"喜德县", - "code":"513432" + name: '喜德县', + code: '513432', }, { - "name":"冕宁县", - "code":"513433" + name: '冕宁县', + code: '513433', }, { - "name":"越西县", - "code":"513434" + name: '越西县', + code: '513434', }, { - "name":"甘洛县", - "code":"513435" + name: '甘洛县', + code: '513435', }, { - "name":"美姑县", - "code":"513436" + name: '美姑县', + code: '513436', }, { - "name":"雷波县", - "code":"513437" - } - ] - } - ] + name: '雷波县', + code: '513437', + }, + ], + }, + ], }, { - "name":"贵州省", - "code":"520000", - "sub":[ + name: '贵州省', + code: '520000', + sub: [ { - "name":"贵阳市", - "code":"520100", - "sub":[ + name: '贵阳市', + code: '520100', + sub: [ { - "name":"市辖区", - "code":"520101" + name: '市辖区', + code: '520101', }, { - "name":"南明区", - "code":"520102" + name: '南明区', + code: '520102', }, { - "name":"云岩区", - "code":"520103" + name: '云岩区', + code: '520103', }, { - "name":"花溪区", - "code":"520111" + name: '花溪区', + code: '520111', }, { - "name":"乌当区", - "code":"520112" + name: '乌当区', + code: '520112', }, { - "name":"白云区", - "code":"520113" + name: '白云区', + code: '520113', }, { - "name":"观山湖区", - "code":"520115" + name: '观山湖区', + code: '520115', }, { - "name":"开阳县", - "code":"520121" + name: '开阳县', + code: '520121', }, { - "name":"息烽县", - "code":"520122" + name: '息烽县', + code: '520122', }, { - "name":"修文县", - "code":"520123" + name: '修文县', + code: '520123', }, { - "name":"清镇市", - "code":"520181" - } - ] + name: '清镇市', + code: '520181', + }, + ], }, { - "name":"六盘水市", - "code":"520200", - "sub":[ + name: '六盘水市', + code: '520200', + sub: [ { - "name":"钟山区", - "code":"520201" + name: '钟山区', + code: '520201', }, { - "name":"六枝特区", - "code":"520203" + name: '六枝特区', + code: '520203', }, { - "name":"水城县", - "code":"520221" + name: '水城县', + code: '520221', }, { - "name":"盘县", - "code":"520222" - } - ] + name: '盘县', + code: '520222', + }, + ], }, { - "name":"遵义市", - "code":"520300", - "sub":[ + name: '遵义市', + code: '520300', + sub: [ { - "name":"市辖区", - "code":"520301" + name: '市辖区', + code: '520301', }, { - "name":"红花岗区", - "code":"520302" + name: '红花岗区', + code: '520302', }, { - "name":"汇川区", - "code":"520303" + name: '汇川区', + code: '520303', }, { - "name":"遵义县", - "code":"520321" + name: '遵义县', + code: '520321', }, { - "name":"桐梓县", - "code":"520322" + name: '桐梓县', + code: '520322', }, { - "name":"绥阳县", - "code":"520323" + name: '绥阳县', + code: '520323', }, { - "name":"正安县", - "code":"520324" + name: '正安县', + code: '520324', }, { - "name":"道真仡佬族苗族自治县", - "code":"520325" + name: '道真仡佬族苗族自治县', + code: '520325', }, { - "name":"务川仡佬族苗族自治县", - "code":"520326" + name: '务川仡佬族苗族自治县', + code: '520326', }, { - "name":"凤冈县", - "code":"520327" + name: '凤冈县', + code: '520327', }, { - "name":"湄潭县", - "code":"520328" + name: '湄潭县', + code: '520328', }, { - "name":"余庆县", - "code":"520329" + name: '余庆县', + code: '520329', }, { - "name":"习水县", - "code":"520330" + name: '习水县', + code: '520330', }, { - "name":"赤水市", - "code":"520381" + name: '赤水市', + code: '520381', }, { - "name":"仁怀市", - "code":"520382" - } - ] + name: '仁怀市', + code: '520382', + }, + ], }, { - "name":"安顺市", - "code":"520400", - "sub":[ + name: '安顺市', + code: '520400', + sub: [ { - "name":"市辖区", - "code":"520401" + name: '市辖区', + code: '520401', }, { - "name":"西秀区", - "code":"520402" + name: '西秀区', + code: '520402', }, { - "name":"平坝区", - "code":"520403" + name: '平坝区', + code: '520403', }, { - "name":"普定县", - "code":"520422" + name: '普定县', + code: '520422', }, { - "name":"镇宁布依族苗族自治县", - "code":"520423" + name: '镇宁布依族苗族自治县', + code: '520423', }, { - "name":"关岭布依族苗族自治县", - "code":"520424" + name: '关岭布依族苗族自治县', + code: '520424', }, { - "name":"紫云苗族布依族自治县", - "code":"520425" - } - ] + name: '紫云苗族布依族自治县', + code: '520425', + }, + ], }, { - "name":"毕节市", - "code":"520500", - "sub":[ + name: '毕节市', + code: '520500', + sub: [ { - "name":"市辖区", - "code":"520501" + name: '市辖区', + code: '520501', }, { - "name":"七星关区", - "code":"520502" + name: '七星关区', + code: '520502', }, { - "name":"大方县", - "code":"520521" + name: '大方县', + code: '520521', }, { - "name":"黔西县", - "code":"520522" + name: '黔西县', + code: '520522', }, { - "name":"金沙县", - "code":"520523" + name: '金沙县', + code: '520523', }, { - "name":"织金县", - "code":"520524" + name: '织金县', + code: '520524', }, { - "name":"纳雍县", - "code":"520525" + name: '纳雍县', + code: '520525', }, { - "name":"威宁彝族回族苗族自治县", - "code":"520526" + name: '威宁彝族回族苗族自治县', + code: '520526', }, { - "name":"赫章县", - "code":"520527" - } - ] + name: '赫章县', + code: '520527', + }, + ], }, { - "name":"铜仁市", - "code":"520600", - "sub":[ + name: '铜仁市', + code: '520600', + sub: [ { - "name":"市辖区", - "code":"520601" + name: '市辖区', + code: '520601', }, { - "name":"碧江区", - "code":"520602" + name: '碧江区', + code: '520602', }, { - "name":"万山区", - "code":"520603" + name: '万山区', + code: '520603', }, { - "name":"江口县", - "code":"520621" + name: '江口县', + code: '520621', }, { - "name":"玉屏侗族自治县", - "code":"520622" + name: '玉屏侗族自治县', + code: '520622', }, { - "name":"石阡县", - "code":"520623" + name: '石阡县', + code: '520623', }, { - "name":"思南县", - "code":"520624" + name: '思南县', + code: '520624', }, { - "name":"印江土家族苗族自治县", - "code":"520625" + name: '印江土家族苗族自治县', + code: '520625', }, { - "name":"德江县", - "code":"520626" + name: '德江县', + code: '520626', }, { - "name":"沿河土家族自治县", - "code":"520627" + name: '沿河土家族自治县', + code: '520627', }, { - "name":"松桃苗族自治县", - "code":"520628" - } - ] + name: '松桃苗族自治县', + code: '520628', + }, + ], }, { - "name":"黔西南布依族苗族自治州", - "code":"522300", - "sub":[ + name: '黔西南布依族苗族自治州', + code: '522300', + sub: [ { - "name":"兴义市", - "code":"522301" + name: '兴义市', + code: '522301', }, { - "name":"兴仁县", - "code":"522322" + name: '兴仁县', + code: '522322', }, { - "name":"普安县", - "code":"522323" + name: '普安县', + code: '522323', }, { - "name":"晴隆县", - "code":"522324" + name: '晴隆县', + code: '522324', }, { - "name":"贞丰县", - "code":"522325" + name: '贞丰县', + code: '522325', }, { - "name":"望谟县", - "code":"522326" + name: '望谟县', + code: '522326', }, { - "name":"册亨县", - "code":"522327" + name: '册亨县', + code: '522327', }, { - "name":"安龙县", - "code":"522328" - } - ] + name: '安龙县', + code: '522328', + }, + ], }, { - "name":"黔东南苗族侗族自治州", - "code":"522600", - "sub":[ + name: '黔东南苗族侗族自治州', + code: '522600', + sub: [ { - "name":"凯里市", - "code":"522601" + name: '凯里市', + code: '522601', }, { - "name":"黄平县", - "code":"522622" + name: '黄平县', + code: '522622', }, { - "name":"施秉县", - "code":"522623" + name: '施秉县', + code: '522623', }, { - "name":"三穗县", - "code":"522624" + name: '三穗县', + code: '522624', }, { - "name":"镇远县", - "code":"522625" + name: '镇远县', + code: '522625', }, { - "name":"岑巩县", - "code":"522626" + name: '岑巩县', + code: '522626', }, { - "name":"天柱县", - "code":"522627" + name: '天柱县', + code: '522627', }, { - "name":"锦屏县", - "code":"522628" + name: '锦屏县', + code: '522628', }, { - "name":"剑河县", - "code":"522629" + name: '剑河县', + code: '522629', }, { - "name":"台江县", - "code":"522630" + name: '台江县', + code: '522630', }, { - "name":"黎平县", - "code":"522631" + name: '黎平县', + code: '522631', }, { - "name":"榕江县", - "code":"522632" + name: '榕江县', + code: '522632', }, { - "name":"从江县", - "code":"522633" + name: '从江县', + code: '522633', }, { - "name":"雷山县", - "code":"522634" + name: '雷山县', + code: '522634', }, { - "name":"麻江县", - "code":"522635" + name: '麻江县', + code: '522635', }, { - "name":"丹寨县", - "code":"522636" - } - ] + name: '丹寨县', + code: '522636', + }, + ], }, { - "name":"黔南布依族苗族自治州", - "code":"522700", - "sub":[ + name: '黔南布依族苗族自治州', + code: '522700', + sub: [ { - "name":"都匀市", - "code":"522701" + name: '都匀市', + code: '522701', }, { - "name":"福泉市", - "code":"522702" + name: '福泉市', + code: '522702', }, { - "name":"荔波县", - "code":"522722" + name: '荔波县', + code: '522722', }, { - "name":"贵定县", - "code":"522723" + name: '贵定县', + code: '522723', }, { - "name":"瓮安县", - "code":"522725" + name: '瓮安县', + code: '522725', }, { - "name":"独山县", - "code":"522726" + name: '独山县', + code: '522726', }, { - "name":"平塘县", - "code":"522727" + name: '平塘县', + code: '522727', }, { - "name":"罗甸县", - "code":"522728" + name: '罗甸县', + code: '522728', }, { - "name":"长顺县", - "code":"522729" + name: '长顺县', + code: '522729', }, { - "name":"龙里县", - "code":"522730" + name: '龙里县', + code: '522730', }, { - "name":"惠水县", - "code":"522731" + name: '惠水县', + code: '522731', }, { - "name":"三都水族自治县", - "code":"522732" - } - ] - } - ] + name: '三都水族自治县', + code: '522732', + }, + ], + }, + ], }, { - "name":"云南省", - "code":"530000", - "sub":[ + name: '云南省', + code: '530000', + sub: [ { - "name":"昆明市", - "code":"530100", - "sub":[ + name: '昆明市', + code: '530100', + sub: [ { - "name":"市辖区", - "code":"530101" + name: '市辖区', + code: '530101', }, { - "name":"五华区", - "code":"530102" + name: '五华区', + code: '530102', }, { - "name":"盘龙区", - "code":"530103" + name: '盘龙区', + code: '530103', }, { - "name":"官渡区", - "code":"530111" + name: '官渡区', + code: '530111', }, { - "name":"西山区", - "code":"530112" + name: '西山区', + code: '530112', }, { - "name":"东川区", - "code":"530113" + name: '东川区', + code: '530113', }, { - "name":"呈贡区", - "code":"530114" + name: '呈贡区', + code: '530114', }, { - "name":"晋宁县", - "code":"530122" + name: '晋宁县', + code: '530122', }, { - "name":"富民县", - "code":"530124" + name: '富民县', + code: '530124', }, { - "name":"宜良县", - "code":"530125" + name: '宜良县', + code: '530125', }, { - "name":"石林彝族自治县", - "code":"530126" + name: '石林彝族自治县', + code: '530126', }, { - "name":"嵩明县", - "code":"530127" + name: '嵩明县', + code: '530127', }, { - "name":"禄劝彝族苗族自治县", - "code":"530128" + name: '禄劝彝族苗族自治县', + code: '530128', }, { - "name":"寻甸回族彝族自治县", - "code":"530129" + name: '寻甸回族彝族自治县', + code: '530129', }, { - "name":"安宁市", - "code":"530181" - } - ] + name: '安宁市', + code: '530181', + }, + ], }, { - "name":"曲靖市", - "code":"530300", - "sub":[ + name: '曲靖市', + code: '530300', + sub: [ { - "name":"市辖区", - "code":"530301" + name: '市辖区', + code: '530301', }, { - "name":"麒麟区", - "code":"530302" + name: '麒麟区', + code: '530302', }, { - "name":"马龙县", - "code":"530321" + name: '马龙县', + code: '530321', }, { - "name":"陆良县", - "code":"530322" + name: '陆良县', + code: '530322', }, { - "name":"师宗县", - "code":"530323" + name: '师宗县', + code: '530323', }, { - "name":"罗平县", - "code":"530324" + name: '罗平县', + code: '530324', }, { - "name":"富源县", - "code":"530325" + name: '富源县', + code: '530325', }, { - "name":"会泽县", - "code":"530326" + name: '会泽县', + code: '530326', }, { - "name":"沾益县", - "code":"530328" + name: '沾益县', + code: '530328', }, { - "name":"宣威市", - "code":"530381" - } - ] + name: '宣威市', + code: '530381', + }, + ], }, { - "name":"玉溪市", - "code":"530400", - "sub":[ + name: '玉溪市', + code: '530400', + sub: [ { - "name":"市辖区", - "code":"530401" + name: '市辖区', + code: '530401', }, { - "name":"红塔区", - "code":"530402" + name: '红塔区', + code: '530402', }, { - "name":"江川县", - "code":"530421" + name: '江川县', + code: '530421', }, { - "name":"澄江县", - "code":"530422" + name: '澄江县', + code: '530422', }, { - "name":"通海县", - "code":"530423" + name: '通海县', + code: '530423', }, { - "name":"华宁县", - "code":"530424" + name: '华宁县', + code: '530424', }, { - "name":"易门县", - "code":"530425" + name: '易门县', + code: '530425', }, { - "name":"峨山彝族自治县", - "code":"530426" + name: '峨山彝族自治县', + code: '530426', }, { - "name":"新平彝族傣族自治县", - "code":"530427" + name: '新平彝族傣族自治县', + code: '530427', }, { - "name":"元江哈尼族彝族傣族自治县", - "code":"530428" - } - ] + name: '元江哈尼族彝族傣族自治县', + code: '530428', + }, + ], }, { - "name":"保山市", - "code":"530500", - "sub":[ + name: '保山市', + code: '530500', + sub: [ { - "name":"市辖区", - "code":"530501" + name: '市辖区', + code: '530501', }, { - "name":"隆阳区", - "code":"530502" + name: '隆阳区', + code: '530502', }, { - "name":"施甸县", - "code":"530521" + name: '施甸县', + code: '530521', }, { - "name":"腾冲县", - "code":"530522" + name: '腾冲县', + code: '530522', }, { - "name":"龙陵县", - "code":"530523" + name: '龙陵县', + code: '530523', }, { - "name":"昌宁县", - "code":"530524" - } - ] + name: '昌宁县', + code: '530524', + }, + ], }, { - "name":"昭通市", - "code":"530600", - "sub":[ + name: '昭通市', + code: '530600', + sub: [ { - "name":"市辖区", - "code":"530601" + name: '市辖区', + code: '530601', }, { - "name":"昭阳区", - "code":"530602" + name: '昭阳区', + code: '530602', }, { - "name":"鲁甸县", - "code":"530621" + name: '鲁甸县', + code: '530621', }, { - "name":"巧家县", - "code":"530622" + name: '巧家县', + code: '530622', }, { - "name":"盐津县", - "code":"530623" + name: '盐津县', + code: '530623', }, { - "name":"大关县", - "code":"530624" + name: '大关县', + code: '530624', }, { - "name":"永善县", - "code":"530625" + name: '永善县', + code: '530625', }, { - "name":"绥江县", - "code":"530626" + name: '绥江县', + code: '530626', }, { - "name":"镇雄县", - "code":"530627" + name: '镇雄县', + code: '530627', }, { - "name":"彝良县", - "code":"530628" + name: '彝良县', + code: '530628', }, { - "name":"威信县", - "code":"530629" + name: '威信县', + code: '530629', }, { - "name":"水富县", - "code":"530630" - } - ] + name: '水富县', + code: '530630', + }, + ], }, { - "name":"丽江市", - "code":"530700", - "sub":[ + name: '丽江市', + code: '530700', + sub: [ { - "name":"市辖区", - "code":"530701" + name: '市辖区', + code: '530701', }, { - "name":"古城区", - "code":"530702" + name: '古城区', + code: '530702', }, { - "name":"玉龙纳西族自治县", - "code":"530721" + name: '玉龙纳西族自治县', + code: '530721', }, { - "name":"永胜县", - "code":"530722" + name: '永胜县', + code: '530722', }, { - "name":"华坪县", - "code":"530723" + name: '华坪县', + code: '530723', }, { - "name":"宁蒗彝族自治县", - "code":"530724" - } - ] + name: '宁蒗彝族自治县', + code: '530724', + }, + ], }, { - "name":"普洱市", - "code":"530800", - "sub":[ + name: '普洱市', + code: '530800', + sub: [ { - "name":"市辖区", - "code":"530801" + name: '市辖区', + code: '530801', }, { - "name":"思茅区", - "code":"530802" + name: '思茅区', + code: '530802', }, { - "name":"宁洱哈尼族彝族自治县", - "code":"530821" + name: '宁洱哈尼族彝族自治县', + code: '530821', }, { - "name":"墨江哈尼族自治县", - "code":"530822" + name: '墨江哈尼族自治县', + code: '530822', }, { - "name":"景东彝族自治县", - "code":"530823" + name: '景东彝族自治县', + code: '530823', }, { - "name":"景谷傣族彝族自治县", - "code":"530824" + name: '景谷傣族彝族自治县', + code: '530824', }, { - "name":"镇沅彝族哈尼族拉祜族自治县", - "code":"530825" + name: '镇沅彝族哈尼族拉祜族自治县', + code: '530825', }, { - "name":"江城哈尼族彝族自治县", - "code":"530826" + name: '江城哈尼族彝族自治县', + code: '530826', }, { - "name":"孟连傣族拉祜族佤族自治县", - "code":"530827" + name: '孟连傣族拉祜族佤族自治县', + code: '530827', }, { - "name":"澜沧拉祜族自治县", - "code":"530828" + name: '澜沧拉祜族自治县', + code: '530828', }, { - "name":"西盟佤族自治县", - "code":"530829" - } - ] + name: '西盟佤族自治县', + code: '530829', + }, + ], }, { - "name":"临沧市", - "code":"530900", - "sub":[ + name: '临沧市', + code: '530900', + sub: [ { - "name":"市辖区", - "code":"530901" + name: '市辖区', + code: '530901', }, { - "name":"临翔区", - "code":"530902" + name: '临翔区', + code: '530902', }, { - "name":"凤庆县", - "code":"530921" + name: '凤庆县', + code: '530921', }, { - "name":"云县", - "code":"530922" + name: '云县', + code: '530922', }, { - "name":"永德县", - "code":"530923" + name: '永德县', + code: '530923', }, { - "name":"镇康县", - "code":"530924" + name: '镇康县', + code: '530924', }, { - "name":"双江拉祜族佤族布朗族傣族自治县", - "code":"530925" + name: '双江拉祜族佤族布朗族傣族自治县', + code: '530925', }, { - "name":"耿马傣族佤族自治县", - "code":"530926" + name: '耿马傣族佤族自治县', + code: '530926', }, { - "name":"沧源佤族自治县", - "code":"530927" - } - ] + name: '沧源佤族自治县', + code: '530927', + }, + ], }, { - "name":"楚雄彝族自治州", - "code":"532300", - "sub":[ + name: '楚雄彝族自治州', + code: '532300', + sub: [ { - "name":"楚雄市", - "code":"532301" + name: '楚雄市', + code: '532301', }, { - "name":"双柏县", - "code":"532322" + name: '双柏县', + code: '532322', }, { - "name":"牟定县", - "code":"532323" + name: '牟定县', + code: '532323', }, { - "name":"南华县", - "code":"532324" + name: '南华县', + code: '532324', }, { - "name":"姚安县", - "code":"532325" + name: '姚安县', + code: '532325', }, { - "name":"大姚县", - "code":"532326" + name: '大姚县', + code: '532326', }, { - "name":"永仁县", - "code":"532327" + name: '永仁县', + code: '532327', }, { - "name":"元谋县", - "code":"532328" + name: '元谋县', + code: '532328', }, { - "name":"武定县", - "code":"532329" + name: '武定县', + code: '532329', }, { - "name":"禄丰县", - "code":"532331" - } - ] + name: '禄丰县', + code: '532331', + }, + ], }, { - "name":"红河哈尼族彝族自治州", - "code":"532500", - "sub":[ + name: '红河哈尼族彝族自治州', + code: '532500', + sub: [ { - "name":"个旧市", - "code":"532501" + name: '个旧市', + code: '532501', }, { - "name":"开远市", - "code":"532502" + name: '开远市', + code: '532502', }, { - "name":"蒙自市", - "code":"532503" + name: '蒙自市', + code: '532503', }, { - "name":"弥勒市", - "code":"532504" + name: '弥勒市', + code: '532504', }, { - "name":"屏边苗族自治县", - "code":"532523" + name: '屏边苗族自治县', + code: '532523', }, { - "name":"建水县", - "code":"532524" + name: '建水县', + code: '532524', }, { - "name":"石屏县", - "code":"532525" + name: '石屏县', + code: '532525', }, { - "name":"泸西县", - "code":"532527" + name: '泸西县', + code: '532527', }, { - "name":"元阳县", - "code":"532528" + name: '元阳县', + code: '532528', }, { - "name":"红河县", - "code":"532529" + name: '红河县', + code: '532529', }, { - "name":"金平苗族瑶族傣族自治县", - "code":"532530" + name: '金平苗族瑶族傣族自治县', + code: '532530', }, { - "name":"绿春县", - "code":"532531" + name: '绿春县', + code: '532531', }, { - "name":"河口瑶族自治县", - "code":"532532" - } - ] + name: '河口瑶族自治县', + code: '532532', + }, + ], }, { - "name":"文山壮族苗族自治州", - "code":"532600", - "sub":[ + name: '文山壮族苗族自治州', + code: '532600', + sub: [ { - "name":"文山市", - "code":"532601" + name: '文山市', + code: '532601', }, { - "name":"砚山县", - "code":"532622" + name: '砚山县', + code: '532622', }, { - "name":"西畴县", - "code":"532623" + name: '西畴县', + code: '532623', }, { - "name":"麻栗坡县", - "code":"532624" + name: '麻栗坡县', + code: '532624', }, { - "name":"马关县", - "code":"532625" + name: '马关县', + code: '532625', }, { - "name":"丘北县", - "code":"532626" + name: '丘北县', + code: '532626', }, { - "name":"广南县", - "code":"532627" + name: '广南县', + code: '532627', }, { - "name":"富宁县", - "code":"532628" - } - ] + name: '富宁县', + code: '532628', + }, + ], }, { - "name":"西双版纳傣族自治州", - "code":"532800", - "sub":[ + name: '西双版纳傣族自治州', + code: '532800', + sub: [ { - "name":"景洪市", - "code":"532801" + name: '景洪市', + code: '532801', }, { - "name":"勐海县", - "code":"532822" + name: '勐海县', + code: '532822', }, { - "name":"勐腊县", - "code":"532823" - } - ] + name: '勐腊县', + code: '532823', + }, + ], }, { - "name":"大理白族自治州", - "code":"532900", - "sub":[ + name: '大理白族自治州', + code: '532900', + sub: [ { - "name":"大理市", - "code":"532901" + name: '大理市', + code: '532901', }, { - "name":"漾濞彝族自治县", - "code":"532922" + name: '漾濞彝族自治县', + code: '532922', }, { - "name":"祥云县", - "code":"532923" + name: '祥云县', + code: '532923', }, { - "name":"宾川县", - "code":"532924" + name: '宾川县', + code: '532924', }, { - "name":"弥渡县", - "code":"532925" + name: '弥渡县', + code: '532925', }, { - "name":"南涧彝族自治县", - "code":"532926" + name: '南涧彝族自治县', + code: '532926', }, { - "name":"巍山彝族回族自治县", - "code":"532927" + name: '巍山彝族回族自治县', + code: '532927', }, { - "name":"永平县", - "code":"532928" + name: '永平县', + code: '532928', }, { - "name":"云龙县", - "code":"532929" + name: '云龙县', + code: '532929', }, { - "name":"洱源县", - "code":"532930" + name: '洱源县', + code: '532930', }, { - "name":"剑川县", - "code":"532931" + name: '剑川县', + code: '532931', }, { - "name":"鹤庆县", - "code":"532932" - } - ] + name: '鹤庆县', + code: '532932', + }, + ], }, { - "name":"德宏傣族景颇族自治州", - "code":"533100", - "sub":[ + name: '德宏傣族景颇族自治州', + code: '533100', + sub: [ { - "name":"瑞丽市", - "code":"533102" + name: '瑞丽市', + code: '533102', }, { - "name":"芒市", - "code":"533103" + name: '芒市', + code: '533103', }, { - "name":"梁河县", - "code":"533122" + name: '梁河县', + code: '533122', }, { - "name":"盈江县", - "code":"533123" + name: '盈江县', + code: '533123', }, { - "name":"陇川县", - "code":"533124" - } - ] + name: '陇川县', + code: '533124', + }, + ], }, { - "name":"怒江傈僳族自治州", - "code":"533300", - "sub":[ + name: '怒江傈僳族自治州', + code: '533300', + sub: [ { - "name":"泸水县", - "code":"533321" + name: '泸水县', + code: '533321', }, { - "name":"福贡县", - "code":"533323" + name: '福贡县', + code: '533323', }, { - "name":"贡山独龙族怒族自治县", - "code":"533324" + name: '贡山独龙族怒族自治县', + code: '533324', }, { - "name":"兰坪白族普米族自治县", - "code":"533325" - } - ] + name: '兰坪白族普米族自治县', + code: '533325', + }, + ], }, { - "name":"迪庆藏族自治州", - "code":"533400", - "sub":[ + name: '迪庆藏族自治州', + code: '533400', + sub: [ { - "name":"香格里拉市", - "code":"533401" + name: '香格里拉市', + code: '533401', }, { - "name":"德钦县", - "code":"533422" + name: '德钦县', + code: '533422', }, { - "name":"维西傈僳族自治县", - "code":"533423" - } - ] - } - ] + name: '维西傈僳族自治县', + code: '533423', + }, + ], + }, + ], }, { - "name":"西藏自治区", - "code":"540000", - "sub":[ + name: '西藏自治区', + code: '540000', + sub: [ { - "name":"拉萨市", - "code":"540100", - "sub":[ + name: '拉萨市', + code: '540100', + sub: [ { - "name":"市辖区", - "code":"540101" + name: '市辖区', + code: '540101', }, { - "name":"城关区", - "code":"540102" + name: '城关区', + code: '540102', }, { - "name":"林周县", - "code":"540121" + name: '林周县', + code: '540121', }, { - "name":"当雄县", - "code":"540122" + name: '当雄县', + code: '540122', }, { - "name":"尼木县", - "code":"540123" + name: '尼木县', + code: '540123', }, { - "name":"曲水县", - "code":"540124" + name: '曲水县', + code: '540124', }, { - "name":"堆龙德庆县", - "code":"540125" + name: '堆龙德庆县', + code: '540125', }, { - "name":"达孜县", - "code":"540126" + name: '达孜县', + code: '540126', }, { - "name":"墨竹工卡县", - "code":"540127" - } - ] + name: '墨竹工卡县', + code: '540127', + }, + ], }, { - "name":"日喀则市", - "code":"540200", - "sub":[ + name: '日喀则市', + code: '540200', + sub: [ { - "name":"市辖区", - "code":"540201" + name: '市辖区', + code: '540201', }, { - "name":"桑珠孜区", - "code":"540202" + name: '桑珠孜区', + code: '540202', }, { - "name":"南木林县", - "code":"540221" + name: '南木林县', + code: '540221', }, { - "name":"江孜县", - "code":"540222" + name: '江孜县', + code: '540222', }, { - "name":"定日县", - "code":"540223" + name: '定日县', + code: '540223', }, { - "name":"萨迦县", - "code":"540224" + name: '萨迦县', + code: '540224', }, { - "name":"拉孜县", - "code":"540225" + name: '拉孜县', + code: '540225', }, { - "name":"昂仁县", - "code":"540226" + name: '昂仁县', + code: '540226', }, { - "name":"谢通门县", - "code":"540227" + name: '谢通门县', + code: '540227', }, { - "name":"白朗县", - "code":"540228" + name: '白朗县', + code: '540228', }, { - "name":"仁布县", - "code":"540229" + name: '仁布县', + code: '540229', }, { - "name":"康马县", - "code":"540230" + name: '康马县', + code: '540230', }, { - "name":"定结县", - "code":"540231" + name: '定结县', + code: '540231', }, { - "name":"仲巴县", - "code":"540232" + name: '仲巴县', + code: '540232', }, { - "name":"亚东县", - "code":"540233" + name: '亚东县', + code: '540233', }, { - "name":"吉隆县", - "code":"540234" + name: '吉隆县', + code: '540234', }, { - "name":"聂拉木县", - "code":"540235" + name: '聂拉木县', + code: '540235', }, { - "name":"萨嘎县", - "code":"540236" + name: '萨嘎县', + code: '540236', }, { - "name":"岗巴县", - "code":"540237" - } - ] + name: '岗巴县', + code: '540237', + }, + ], }, { - "name":"昌都市", - "code":"540300", - "sub":[ + name: '昌都市', + code: '540300', + sub: [ { - "name":"市辖区", - "code":"540301" + name: '市辖区', + code: '540301', }, { - "name":"卡若区", - "code":"540302" + name: '卡若区', + code: '540302', }, { - "name":"江达县", - "code":"540321" + name: '江达县', + code: '540321', }, { - "name":"贡觉县", - "code":"540322" + name: '贡觉县', + code: '540322', }, { - "name":"类乌齐县", - "code":"540323" + name: '类乌齐县', + code: '540323', }, { - "name":"丁青县", - "code":"540324" + name: '丁青县', + code: '540324', }, { - "name":"察雅县", - "code":"540325" + name: '察雅县', + code: '540325', }, { - "name":"八宿县", - "code":"540326" + name: '八宿县', + code: '540326', }, { - "name":"左贡县", - "code":"540327" + name: '左贡县', + code: '540327', }, { - "name":"芒康县", - "code":"540328" + name: '芒康县', + code: '540328', }, { - "name":"洛隆县", - "code":"540329" + name: '洛隆县', + code: '540329', }, { - "name":"边坝县", - "code":"540330" - } - ] + name: '边坝县', + code: '540330', + }, + ], }, { - "name":"山南地区", - "code":"542200", - "sub":[ + name: '山南地区', + code: '542200', + sub: [ { - "name":"乃东县", - "code":"542221" + name: '乃东县', + code: '542221', }, { - "name":"扎囊县", - "code":"542222" + name: '扎囊县', + code: '542222', }, { - "name":"贡嘎县", - "code":"542223" + name: '贡嘎县', + code: '542223', }, { - "name":"桑日县", - "code":"542224" + name: '桑日县', + code: '542224', }, { - "name":"琼结县", - "code":"542225" + name: '琼结县', + code: '542225', }, { - "name":"曲松县", - "code":"542226" + name: '曲松县', + code: '542226', }, { - "name":"措美县", - "code":"542227" + name: '措美县', + code: '542227', }, { - "name":"洛扎县", - "code":"542228" + name: '洛扎县', + code: '542228', }, { - "name":"加查县", - "code":"542229" + name: '加查县', + code: '542229', }, { - "name":"隆子县", - "code":"542231" + name: '隆子县', + code: '542231', }, { - "name":"错那县", - "code":"542232" + name: '错那县', + code: '542232', }, { - "name":"浪卡子县", - "code":"542233" - } - ] + name: '浪卡子县', + code: '542233', + }, + ], }, { - "name":"那曲地区", - "code":"542400", - "sub":[ + name: '那曲地区', + code: '542400', + sub: [ { - "name":"那曲县", - "code":"542421" + name: '那曲县', + code: '542421', }, { - "name":"嘉黎县", - "code":"542422" + name: '嘉黎县', + code: '542422', }, { - "name":"比如县", - "code":"542423" + name: '比如县', + code: '542423', }, { - "name":"聂荣县", - "code":"542424" + name: '聂荣县', + code: '542424', }, { - "name":"安多县", - "code":"542425" + name: '安多县', + code: '542425', }, { - "name":"申扎县", - "code":"542426" + name: '申扎县', + code: '542426', }, { - "name":"索县", - "code":"542427" + name: '索县', + code: '542427', }, { - "name":"班戈县", - "code":"542428" + name: '班戈县', + code: '542428', }, { - "name":"巴青县", - "code":"542429" + name: '巴青县', + code: '542429', }, { - "name":"尼玛县", - "code":"542430" + name: '尼玛县', + code: '542430', }, { - "name":"双湖县", - "code":"542431" - } - ] + name: '双湖县', + code: '542431', + }, + ], }, { - "name":"阿里地区", - "code":"542500", - "sub":[ + name: '阿里地区', + code: '542500', + sub: [ { - "name":"普兰县", - "code":"542521" + name: '普兰县', + code: '542521', }, { - "name":"札达县", - "code":"542522" + name: '札达县', + code: '542522', }, { - "name":"噶尔县", - "code":"542523" + name: '噶尔县', + code: '542523', }, { - "name":"日土县", - "code":"542524" + name: '日土县', + code: '542524', }, { - "name":"革吉县", - "code":"542525" + name: '革吉县', + code: '542525', }, { - "name":"改则县", - "code":"542526" + name: '改则县', + code: '542526', }, { - "name":"措勤县", - "code":"542527" - } - ] + name: '措勤县', + code: '542527', + }, + ], }, { - "name":"林芝地区", - "code":"542600", - "sub":[ + name: '林芝地区', + code: '542600', + sub: [ { - "name":"林芝县", - "code":"542621" + name: '林芝县', + code: '542621', }, { - "name":"工布江达县", - "code":"542622" + name: '工布江达县', + code: '542622', }, { - "name":"米林县", - "code":"542623" + name: '米林县', + code: '542623', }, { - "name":"墨脱县", - "code":"542624" + name: '墨脱县', + code: '542624', }, { - "name":"波密县", - "code":"542625" + name: '波密县', + code: '542625', }, { - "name":"察隅县", - "code":"542626" + name: '察隅县', + code: '542626', }, { - "name":"朗县", - "code":"542627" - } - ] - } - ] + name: '朗县', + code: '542627', + }, + ], + }, + ], }, { - "name":"陕西省", - "code":"610000", - "sub":[ + name: '陕西省', + code: '610000', + sub: [ { - "name":"西安市", - "code":"610100", - "sub":[ + name: '西安市', + code: '610100', + sub: [ { - "name":"市辖区", - "code":"610101" + name: '市辖区', + code: '610101', }, { - "name":"新城区", - "code":"610102" + name: '新城区', + code: '610102', }, { - "name":"碑林区", - "code":"610103" + name: '碑林区', + code: '610103', }, { - "name":"莲湖区", - "code":"610104" + name: '莲湖区', + code: '610104', }, { - "name":"灞桥区", - "code":"610111" + name: '灞桥区', + code: '610111', }, { - "name":"未央区", - "code":"610112" + name: '未央区', + code: '610112', }, { - "name":"雁塔区", - "code":"610113" + name: '雁塔区', + code: '610113', }, { - "name":"阎良区", - "code":"610114" + name: '阎良区', + code: '610114', }, { - "name":"临潼区", - "code":"610115" + name: '临潼区', + code: '610115', }, { - "name":"长安区", - "code":"610116" + name: '长安区', + code: '610116', }, { - "name":"高陵区", - "code":"610117" + name: '高陵区', + code: '610117', }, { - "name":"蓝田县", - "code":"610122" + name: '蓝田县', + code: '610122', }, { - "name":"周至县", - "code":"610124" + name: '周至县', + code: '610124', }, { - "name":"户县", - "code":"610125" - } - ] + name: '户县', + code: '610125', + }, + ], }, { - "name":"铜川市", - "code":"610200", - "sub":[ + name: '铜川市', + code: '610200', + sub: [ { - "name":"市辖区", - "code":"610201" + name: '市辖区', + code: '610201', }, { - "name":"王益区", - "code":"610202" + name: '王益区', + code: '610202', }, { - "name":"印台区", - "code":"610203" + name: '印台区', + code: '610203', }, { - "name":"耀州区", - "code":"610204" + name: '耀州区', + code: '610204', }, { - "name":"宜君县", - "code":"610222" - } - ] + name: '宜君县', + code: '610222', + }, + ], }, { - "name":"宝鸡市", - "code":"610300", - "sub":[ + name: '宝鸡市', + code: '610300', + sub: [ { - "name":"市辖区", - "code":"610301" + name: '市辖区', + code: '610301', }, { - "name":"渭滨区", - "code":"610302" + name: '渭滨区', + code: '610302', }, { - "name":"金台区", - "code":"610303" + name: '金台区', + code: '610303', }, { - "name":"陈仓区", - "code":"610304" + name: '陈仓区', + code: '610304', }, { - "name":"凤翔县", - "code":"610322" + name: '凤翔县', + code: '610322', }, { - "name":"岐山县", - "code":"610323" + name: '岐山县', + code: '610323', }, { - "name":"扶风县", - "code":"610324" + name: '扶风县', + code: '610324', }, { - "name":"眉县", - "code":"610326" + name: '眉县', + code: '610326', }, { - "name":"陇县", - "code":"610327" + name: '陇县', + code: '610327', }, { - "name":"千阳县", - "code":"610328" + name: '千阳县', + code: '610328', }, { - "name":"麟游县", - "code":"610329" + name: '麟游县', + code: '610329', }, { - "name":"凤县", - "code":"610330" + name: '凤县', + code: '610330', }, { - "name":"太白县", - "code":"610331" - } - ] + name: '太白县', + code: '610331', + }, + ], }, { - "name":"咸阳市", - "code":"610400", - "sub":[ + name: '咸阳市', + code: '610400', + sub: [ { - "name":"市辖区", - "code":"610401" + name: '市辖区', + code: '610401', }, { - "name":"秦都区", - "code":"610402" + name: '秦都区', + code: '610402', }, { - "name":"杨陵区", - "code":"610403" + name: '杨陵区', + code: '610403', }, { - "name":"渭城区", - "code":"610404" + name: '渭城区', + code: '610404', }, { - "name":"三原县", - "code":"610422" + name: '三原县', + code: '610422', }, { - "name":"泾阳县", - "code":"610423" + name: '泾阳县', + code: '610423', }, { - "name":"乾县", - "code":"610424" + name: '乾县', + code: '610424', }, { - "name":"礼泉县", - "code":"610425" + name: '礼泉县', + code: '610425', }, { - "name":"永寿县", - "code":"610426" + name: '永寿县', + code: '610426', }, { - "name":"彬县", - "code":"610427" + name: '彬县', + code: '610427', }, { - "name":"长武县", - "code":"610428" + name: '长武县', + code: '610428', }, { - "name":"旬邑县", - "code":"610429" + name: '旬邑县', + code: '610429', }, { - "name":"淳化县", - "code":"610430" + name: '淳化县', + code: '610430', }, { - "name":"武功县", - "code":"610431" + name: '武功县', + code: '610431', }, { - "name":"兴平市", - "code":"610481" - } - ] + name: '兴平市', + code: '610481', + }, + ], }, { - "name":"渭南市", - "code":"610500", - "sub":[ + name: '渭南市', + code: '610500', + sub: [ { - "name":"市辖区", - "code":"610501" + name: '市辖区', + code: '610501', }, { - "name":"临渭区", - "code":"610502" + name: '临渭区', + code: '610502', }, { - "name":"华县", - "code":"610521" + name: '华县', + code: '610521', }, { - "name":"潼关县", - "code":"610522" + name: '潼关县', + code: '610522', }, { - "name":"大荔县", - "code":"610523" + name: '大荔县', + code: '610523', }, { - "name":"合阳县", - "code":"610524" + name: '合阳县', + code: '610524', }, { - "name":"澄城县", - "code":"610525" + name: '澄城县', + code: '610525', }, { - "name":"蒲城县", - "code":"610526" + name: '蒲城县', + code: '610526', }, { - "name":"白水县", - "code":"610527" + name: '白水县', + code: '610527', }, { - "name":"富平县", - "code":"610528" + name: '富平县', + code: '610528', }, { - "name":"韩城市", - "code":"610581" + name: '韩城市', + code: '610581', }, { - "name":"华阴市", - "code":"610582" - } - ] + name: '华阴市', + code: '610582', + }, + ], }, { - "name":"延安市", - "code":"610600", - "sub":[ + name: '延安市', + code: '610600', + sub: [ { - "name":"市辖区", - "code":"610601" + name: '市辖区', + code: '610601', }, { - "name":"宝塔区", - "code":"610602" + name: '宝塔区', + code: '610602', }, { - "name":"延长县", - "code":"610621" + name: '延长县', + code: '610621', }, { - "name":"延川县", - "code":"610622" + name: '延川县', + code: '610622', }, { - "name":"子长县", - "code":"610623" + name: '子长县', + code: '610623', }, { - "name":"安塞县", - "code":"610624" + name: '安塞县', + code: '610624', }, { - "name":"志丹县", - "code":"610625" + name: '志丹县', + code: '610625', }, { - "name":"吴起县", - "code":"610626" + name: '吴起县', + code: '610626', }, { - "name":"甘泉县", - "code":"610627" + name: '甘泉县', + code: '610627', }, { - "name":"富县", - "code":"610628" + name: '富县', + code: '610628', }, { - "name":"洛川县", - "code":"610629" + name: '洛川县', + code: '610629', }, { - "name":"宜川县", - "code":"610630" + name: '宜川县', + code: '610630', }, { - "name":"黄龙县", - "code":"610631" + name: '黄龙县', + code: '610631', }, { - "name":"黄陵县", - "code":"610632" - } - ] + name: '黄陵县', + code: '610632', + }, + ], }, { - "name":"汉中市", - "code":"610700", - "sub":[ + name: '汉中市', + code: '610700', + sub: [ { - "name":"市辖区", - "code":"610701" + name: '市辖区', + code: '610701', }, { - "name":"汉台区", - "code":"610702" + name: '汉台区', + code: '610702', }, { - "name":"南郑县", - "code":"610721" + name: '南郑县', + code: '610721', }, { - "name":"城固县", - "code":"610722" + name: '城固县', + code: '610722', }, { - "name":"洋县", - "code":"610723" + name: '洋县', + code: '610723', }, { - "name":"西乡县", - "code":"610724" + name: '西乡县', + code: '610724', }, { - "name":"勉县", - "code":"610725" + name: '勉县', + code: '610725', }, { - "name":"宁强县", - "code":"610726" + name: '宁强县', + code: '610726', }, { - "name":"略阳县", - "code":"610727" + name: '略阳县', + code: '610727', }, { - "name":"镇巴县", - "code":"610728" + name: '镇巴县', + code: '610728', }, { - "name":"留坝县", - "code":"610729" + name: '留坝县', + code: '610729', }, { - "name":"佛坪县", - "code":"610730" - } - ] + name: '佛坪县', + code: '610730', + }, + ], }, { - "name":"榆林市", - "code":"610800", - "sub":[ + name: '榆林市', + code: '610800', + sub: [ { - "name":"市辖区", - "code":"610801" + name: '市辖区', + code: '610801', }, { - "name":"榆阳区", - "code":"610802" + name: '榆阳区', + code: '610802', }, { - "name":"神木县", - "code":"610821" + name: '神木县', + code: '610821', }, { - "name":"府谷县", - "code":"610822" + name: '府谷县', + code: '610822', }, { - "name":"横山县", - "code":"610823" + name: '横山县', + code: '610823', }, { - "name":"靖边县", - "code":"610824" + name: '靖边县', + code: '610824', }, { - "name":"定边县", - "code":"610825" + name: '定边县', + code: '610825', }, { - "name":"绥德县", - "code":"610826" + name: '绥德县', + code: '610826', }, { - "name":"米脂县", - "code":"610827" + name: '米脂县', + code: '610827', }, { - "name":"佳县", - "code":"610828" + name: '佳县', + code: '610828', }, { - "name":"吴堡县", - "code":"610829" + name: '吴堡县', + code: '610829', }, { - "name":"清涧县", - "code":"610830" + name: '清涧县', + code: '610830', }, { - "name":"子洲县", - "code":"610831" - } - ] + name: '子洲县', + code: '610831', + }, + ], }, { - "name":"安康市", - "code":"610900", - "sub":[ + name: '安康市', + code: '610900', + sub: [ { - "name":"市辖区", - "code":"610901" + name: '市辖区', + code: '610901', }, { - "name":"汉阴县", - "code":"610921" + name: '汉阴县', + code: '610921', }, { - "name":"石泉县", - "code":"610922" + name: '石泉县', + code: '610922', }, { - "name":"宁陕县", - "code":"610923" + name: '宁陕县', + code: '610923', }, { - "name":"紫阳县", - "code":"610924" + name: '紫阳县', + code: '610924', }, { - "name":"岚皋县", - "code":"610925" + name: '岚皋县', + code: '610925', }, { - "name":"平利县", - "code":"610926" + name: '平利县', + code: '610926', }, { - "name":"镇坪县", - "code":"610927" + name: '镇坪县', + code: '610927', }, { - "name":"旬阳县", - "code":"610928" + name: '旬阳县', + code: '610928', }, { - "name":"白河县", - "code":"610929" - } - ] + name: '白河县', + code: '610929', + }, + ], }, { - "name":"商洛市", - "code":"611000", - "sub":[ + name: '商洛市', + code: '611000', + sub: [ { - "name":"市辖区", - "code":"611001" + name: '市辖区', + code: '611001', }, { - "name":"商州区", - "code":"611002" + name: '商州区', + code: '611002', }, { - "name":"洛南县", - "code":"611021" + name: '洛南县', + code: '611021', }, { - "name":"丹凤县", - "code":"611022" + name: '丹凤县', + code: '611022', }, { - "name":"商南县", - "code":"611023" + name: '商南县', + code: '611023', }, { - "name":"山阳县", - "code":"611024" + name: '山阳县', + code: '611024', }, { - "name":"镇安县", - "code":"611025" + name: '镇安县', + code: '611025', }, { - "name":"柞水县", - "code":"611026" - } - ] - } - ] + name: '柞水县', + code: '611026', + }, + ], + }, + ], }, { - "name":"甘肃省", - "code":"620000", - "sub":[ + name: '甘肃省', + code: '620000', + sub: [ { - "name":"兰州市", - "code":"620100", - "sub":[ + name: '兰州市', + code: '620100', + sub: [ { - "name":"市辖区", - "code":"620101" + name: '市辖区', + code: '620101', }, { - "name":"城关区", - "code":"620102" + name: '城关区', + code: '620102', }, { - "name":"七里河区", - "code":"620103" + name: '七里河区', + code: '620103', }, { - "name":"西固区", - "code":"620104" + name: '西固区', + code: '620104', }, { - "name":"安宁区", - "code":"620105" + name: '安宁区', + code: '620105', }, { - "name":"红古区", - "code":"620111" + name: '红古区', + code: '620111', }, { - "name":"永登县", - "code":"620121" + name: '永登县', + code: '620121', }, { - "name":"皋兰县", - "code":"620122" + name: '皋兰县', + code: '620122', }, { - "name":"榆中县", - "code":"620123" - } - ] + name: '榆中县', + code: '620123', + }, + ], }, { - "name":"嘉峪关市", - "code":"620200", - "sub":[ + name: '嘉峪关市', + code: '620200', + sub: [ { - "name":"市辖区", - "code":"620201" - } - ] + name: '市辖区', + code: '620201', + }, + ], }, { - "name":"金昌市", - "code":"620300", - "sub":[ + name: '金昌市', + code: '620300', + sub: [ { - "name":"市辖区", - "code":"620301" + name: '市辖区', + code: '620301', }, { - "name":"金川区", - "code":"620302" + name: '金川区', + code: '620302', }, { - "name":"永昌县", - "code":"620321" - } - ] + name: '永昌县', + code: '620321', + }, + ], }, { - "name":"白银市", - "code":"620400", - "sub":[ + name: '白银市', + code: '620400', + sub: [ { - "name":"市辖区", - "code":"620401" + name: '市辖区', + code: '620401', }, { - "name":"白银区", - "code":"620402" + name: '白银区', + code: '620402', }, { - "name":"平川区", - "code":"620403" + name: '平川区', + code: '620403', }, { - "name":"靖远县", - "code":"620421" + name: '靖远县', + code: '620421', }, { - "name":"会宁县", - "code":"620422" + name: '会宁县', + code: '620422', }, { - "name":"景泰县", - "code":"620423" - } - ] + name: '景泰县', + code: '620423', + }, + ], }, { - "name":"天水市", - "code":"620500", - "sub":[ + name: '天水市', + code: '620500', + sub: [ { - "name":"市辖区", - "code":"620501" + name: '市辖区', + code: '620501', }, { - "name":"秦州区", - "code":"620502" + name: '秦州区', + code: '620502', }, { - "name":"麦积区", - "code":"620503" + name: '麦积区', + code: '620503', }, { - "name":"清水县", - "code":"620521" + name: '清水县', + code: '620521', }, { - "name":"秦安县", - "code":"620522" + name: '秦安县', + code: '620522', }, { - "name":"甘谷县", - "code":"620523" + name: '甘谷县', + code: '620523', }, { - "name":"武山县", - "code":"620524" + name: '武山县', + code: '620524', }, { - "name":"张家川回族自治县", - "code":"620525" - } - ] + name: '张家川回族自治县', + code: '620525', + }, + ], }, { - "name":"武威市", - "code":"620600", - "sub":[ + name: '武威市', + code: '620600', + sub: [ { - "name":"市辖区", - "code":"620601" + name: '市辖区', + code: '620601', }, { - "name":"凉州区", - "code":"620602" + name: '凉州区', + code: '620602', }, { - "name":"民勤县", - "code":"620621" + name: '民勤县', + code: '620621', }, { - "name":"古浪县", - "code":"620622" + name: '古浪县', + code: '620622', }, { - "name":"天祝藏族自治县", - "code":"620623" - } - ] + name: '天祝藏族自治县', + code: '620623', + }, + ], }, { - "name":"张掖市", - "code":"620700", - "sub":[ + name: '张掖市', + code: '620700', + sub: [ { - "name":"市辖区", - "code":"620701" + name: '市辖区', + code: '620701', }, { - "name":"甘州区", - "code":"620702" + name: '甘州区', + code: '620702', }, { - "name":"肃南裕固族自治县", - "code":"620721" + name: '肃南裕固族自治县', + code: '620721', }, { - "name":"民乐县", - "code":"620722" + name: '民乐县', + code: '620722', }, { - "name":"临泽县", - "code":"620723" + name: '临泽县', + code: '620723', }, { - "name":"高台县", - "code":"620724" + name: '高台县', + code: '620724', }, { - "name":"山丹县", - "code":"620725" - } - ] + name: '山丹县', + code: '620725', + }, + ], }, { - "name":"平凉市", - "code":"620800", - "sub":[ + name: '平凉市', + code: '620800', + sub: [ { - "name":"市辖区", - "code":"620801" + name: '市辖区', + code: '620801', }, { - "name":"崆峒区", - "code":"620802" + name: '崆峒区', + code: '620802', }, { - "name":"泾川县", - "code":"620821" + name: '泾川县', + code: '620821', }, { - "name":"灵台县", - "code":"620822" + name: '灵台县', + code: '620822', }, { - "name":"崇信县", - "code":"620823" + name: '崇信县', + code: '620823', }, { - "name":"华亭县", - "code":"620824" + name: '华亭县', + code: '620824', }, { - "name":"庄浪县", - "code":"620825" + name: '庄浪县', + code: '620825', }, { - "name":"静宁县", - "code":"620826" - } - ] + name: '静宁县', + code: '620826', + }, + ], }, { - "name":"酒泉市", - "code":"620900", - "sub":[ + name: '酒泉市', + code: '620900', + sub: [ { - "name":"市辖区", - "code":"620901" + name: '市辖区', + code: '620901', }, { - "name":"肃州区", - "code":"620902" + name: '肃州区', + code: '620902', }, { - "name":"金塔县", - "code":"620921" + name: '金塔县', + code: '620921', }, { - "name":"瓜州县", - "code":"620922" + name: '瓜州县', + code: '620922', }, { - "name":"肃北蒙古族自治县", - "code":"620923" + name: '肃北蒙古族自治县', + code: '620923', }, { - "name":"阿克塞哈萨克族自治县", - "code":"620924" + name: '阿克塞哈萨克族自治县', + code: '620924', }, { - "name":"玉门市", - "code":"620981" + name: '玉门市', + code: '620981', }, { - "name":"敦煌市", - "code":"620982" - } - ] + name: '敦煌市', + code: '620982', + }, + ], }, { - "name":"庆阳市", - "code":"621000", - "sub":[ + name: '庆阳市', + code: '621000', + sub: [ { - "name":"市辖区", - "code":"621001" + name: '市辖区', + code: '621001', }, { - "name":"西峰区", - "code":"621002" + name: '西峰区', + code: '621002', }, { - "name":"庆城县", - "code":"621021" + name: '庆城县', + code: '621021', }, { - "name":"环县", - "code":"621022" + name: '环县', + code: '621022', }, { - "name":"华池县", - "code":"621023" + name: '华池县', + code: '621023', }, { - "name":"合水县", - "code":"621024" + name: '合水县', + code: '621024', }, { - "name":"正宁县", - "code":"621025" + name: '正宁县', + code: '621025', }, { - "name":"宁县", - "code":"621026" + name: '宁县', + code: '621026', }, { - "name":"镇原县", - "code":"621027" - } - ] + name: '镇原县', + code: '621027', + }, + ], }, { - "name":"定西市", - "code":"621100", - "sub":[ + name: '定西市', + code: '621100', + sub: [ { - "name":"市辖区", - "code":"621101" + name: '市辖区', + code: '621101', }, { - "name":"安定区", - "code":"621102" + name: '安定区', + code: '621102', }, { - "name":"通渭县", - "code":"621121" + name: '通渭县', + code: '621121', }, { - "name":"陇西县", - "code":"621122" + name: '陇西县', + code: '621122', }, { - "name":"渭源县", - "code":"621123" + name: '渭源县', + code: '621123', }, { - "name":"临洮县", - "code":"621124" + name: '临洮县', + code: '621124', }, { - "name":"漳县", - "code":"621125" + name: '漳县', + code: '621125', }, { - "name":"岷县", - "code":"621126" - } - ] + name: '岷县', + code: '621126', + }, + ], }, { - "name":"陇南市", - "code":"621200", - "sub":[ + name: '陇南市', + code: '621200', + sub: [ { - "name":"市辖区", - "code":"621201" + name: '市辖区', + code: '621201', }, { - "name":"武都区", - "code":"621202" + name: '武都区', + code: '621202', }, { - "name":"成县", - "code":"621221" + name: '成县', + code: '621221', }, { - "name":"文县", - "code":"621222" + name: '文县', + code: '621222', }, { - "name":"宕昌县", - "code":"621223" + name: '宕昌县', + code: '621223', }, { - "name":"康县", - "code":"621224" + name: '康县', + code: '621224', }, { - "name":"西和县", - "code":"621225" + name: '西和县', + code: '621225', }, { - "name":"礼县", - "code":"621226" + name: '礼县', + code: '621226', }, { - "name":"徽县", - "code":"621227" + name: '徽县', + code: '621227', }, { - "name":"两当县", - "code":"621228" - } - ] + name: '两当县', + code: '621228', + }, + ], }, { - "name":"临夏回族自治州", - "code":"622900", - "sub":[ + name: '临夏回族自治州', + code: '622900', + sub: [ { - "name":"临夏市", - "code":"622901" + name: '临夏市', + code: '622901', }, { - "name":"临夏县", - "code":"622921" + name: '临夏县', + code: '622921', }, { - "name":"康乐县", - "code":"622922" + name: '康乐县', + code: '622922', }, { - "name":"永靖县", - "code":"622923" + name: '永靖县', + code: '622923', }, { - "name":"广河县", - "code":"622924" + name: '广河县', + code: '622924', }, { - "name":"和政县", - "code":"622925" + name: '和政县', + code: '622925', }, { - "name":"东乡族自治县", - "code":"622926" + name: '东乡族自治县', + code: '622926', }, { - "name":"积石山保安族东乡族撒拉族自治县", - "code":"622927" - } - ] + name: '积石山保安族东乡族撒拉族自治县', + code: '622927', + }, + ], }, { - "name":"甘南藏族自治州", - "code":"623000", - "sub":[ + name: '甘南藏族自治州', + code: '623000', + sub: [ { - "name":"合作市", - "code":"623001" + name: '合作市', + code: '623001', }, { - "name":"临潭县", - "code":"623021" + name: '临潭县', + code: '623021', }, { - "name":"卓尼县", - "code":"623022" + name: '卓尼县', + code: '623022', }, { - "name":"舟曲县", - "code":"623023" + name: '舟曲县', + code: '623023', }, { - "name":"迭部县", - "code":"623024" + name: '迭部县', + code: '623024', }, { - "name":"玛曲县", - "code":"623025" + name: '玛曲县', + code: '623025', }, { - "name":"碌曲县", - "code":"623026" + name: '碌曲县', + code: '623026', }, { - "name":"夏河县", - "code":"623027" - } - ] - } - ] + name: '夏河县', + code: '623027', + }, + ], + }, + ], }, { - "name":"青海省", - "code":"630000", - "sub":[ + name: '青海省', + code: '630000', + sub: [ { - "name":"西宁市", - "code":"630100", - "sub":[ + name: '西宁市', + code: '630100', + sub: [ { - "name":"市辖区", - "code":"630101" + name: '市辖区', + code: '630101', }, { - "name":"城东区", - "code":"630102" + name: '城东区', + code: '630102', }, { - "name":"城中区", - "code":"630103" + name: '城中区', + code: '630103', }, { - "name":"城西区", - "code":"630104" + name: '城西区', + code: '630104', }, { - "name":"城北区", - "code":"630105" + name: '城北区', + code: '630105', }, { - "name":"大通回族土族自治县", - "code":"630121" + name: '大通回族土族自治县', + code: '630121', }, { - "name":"湟中县", - "code":"630122" + name: '湟中县', + code: '630122', }, { - "name":"湟源县", - "code":"630123" - } - ] + name: '湟源县', + code: '630123', + }, + ], }, { - "name":"海东市", - "code":"630200", - "sub":[ + name: '海东市', + code: '630200', + sub: [ { - "name":"市辖区", - "code":"630201" + name: '市辖区', + code: '630201', }, { - "name":"乐都区", - "code":"630202" + name: '乐都区', + code: '630202', }, { - "name":"平安县", - "code":"630221" + name: '平安县', + code: '630221', }, { - "name":"民和回族土族自治县", - "code":"630222" + name: '民和回族土族自治县', + code: '630222', }, { - "name":"互助土族自治县", - "code":"630223" + name: '互助土族自治县', + code: '630223', }, { - "name":"化隆回族自治县", - "code":"630224" + name: '化隆回族自治县', + code: '630224', }, { - "name":"循化撒拉族自治县", - "code":"630225" - } - ] + name: '循化撒拉族自治县', + code: '630225', + }, + ], }, { - "name":"海北藏族自治州", - "code":"632200", - "sub":[ + name: '海北藏族自治州', + code: '632200', + sub: [ { - "name":"门源回族自治县", - "code":"632221" + name: '门源回族自治县', + code: '632221', }, { - "name":"祁连县", - "code":"632222" + name: '祁连县', + code: '632222', }, { - "name":"海晏县", - "code":"632223" + name: '海晏县', + code: '632223', }, { - "name":"刚察县", - "code":"632224" - } - ] + name: '刚察县', + code: '632224', + }, + ], }, { - "name":"黄南藏族自治州", - "code":"632300", - "sub":[ + name: '黄南藏族自治州', + code: '632300', + sub: [ { - "name":"同仁县", - "code":"632321" + name: '同仁县', + code: '632321', }, { - "name":"尖扎县", - "code":"632322" + name: '尖扎县', + code: '632322', }, { - "name":"泽库县", - "code":"632323" + name: '泽库县', + code: '632323', }, { - "name":"河南蒙古族自治县", - "code":"632324" - } - ] + name: '河南蒙古族自治县', + code: '632324', + }, + ], }, { - "name":"海南藏族自治州", - "code":"632500", - "sub":[ + name: '海南藏族自治州', + code: '632500', + sub: [ { - "name":"共和县", - "code":"632521" + name: '共和县', + code: '632521', }, { - "name":"同德县", - "code":"632522" + name: '同德县', + code: '632522', }, { - "name":"贵德县", - "code":"632523" + name: '贵德县', + code: '632523', }, { - "name":"兴海县", - "code":"632524" + name: '兴海县', + code: '632524', }, { - "name":"贵南县", - "code":"632525" - } - ] + name: '贵南县', + code: '632525', + }, + ], }, { - "name":"果洛藏族自治州", - "code":"632600", - "sub":[ + name: '果洛藏族自治州', + code: '632600', + sub: [ { - "name":"玛沁县", - "code":"632621" + name: '玛沁县', + code: '632621', }, { - "name":"班玛县", - "code":"632622" + name: '班玛县', + code: '632622', }, { - "name":"甘德县", - "code":"632623" + name: '甘德县', + code: '632623', }, { - "name":"达日县", - "code":"632624" + name: '达日县', + code: '632624', }, { - "name":"久治县", - "code":"632625" + name: '久治县', + code: '632625', }, { - "name":"玛多县", - "code":"632626" - } - ] + name: '玛多县', + code: '632626', + }, + ], }, { - "name":"玉树藏族自治州", - "code":"632700", - "sub":[ + name: '玉树藏族自治州', + code: '632700', + sub: [ { - "name":"玉树市", - "code":"632701" + name: '玉树市', + code: '632701', }, { - "name":"杂多县", - "code":"632722" + name: '杂多县', + code: '632722', }, { - "name":"称多县", - "code":"632723" + name: '称多县', + code: '632723', }, { - "name":"治多县", - "code":"632724" + name: '治多县', + code: '632724', }, { - "name":"囊谦县", - "code":"632725" + name: '囊谦县', + code: '632725', }, { - "name":"曲麻莱县", - "code":"632726" - } - ] + name: '曲麻莱县', + code: '632726', + }, + ], }, { - "name":"海西蒙古族藏族自治州", - "code":"632800", - "sub":[ + name: '海西蒙古族藏族自治州', + code: '632800', + sub: [ { - "name":"格尔木市", - "code":"632801" + name: '格尔木市', + code: '632801', }, { - "name":"德令哈市", - "code":"632802" + name: '德令哈市', + code: '632802', }, { - "name":"乌兰县", - "code":"632821" + name: '乌兰县', + code: '632821', }, { - "name":"都兰县", - "code":"632822" + name: '都兰县', + code: '632822', }, { - "name":"天峻县", - "code":"632823" - } - ] - } - ] + name: '天峻县', + code: '632823', + }, + ], + }, + ], }, { - "name":"宁夏回族自治区", - "code":"640000", - "sub":[ + name: '宁夏回族自治区', + code: '640000', + sub: [ { - "name":"银川市", - "code":"640100", - "sub":[ + name: '银川市', + code: '640100', + sub: [ { - "name":"市辖区", - "code":"640101" + name: '市辖区', + code: '640101', }, { - "name":"兴庆区", - "code":"640104" + name: '兴庆区', + code: '640104', }, { - "name":"西夏区", - "code":"640105" + name: '西夏区', + code: '640105', }, { - "name":"金凤区", - "code":"640106" + name: '金凤区', + code: '640106', }, { - "name":"永宁县", - "code":"640121" + name: '永宁县', + code: '640121', }, { - "name":"贺兰县", - "code":"640122" + name: '贺兰县', + code: '640122', }, { - "name":"灵武市", - "code":"640181" - } - ] + name: '灵武市', + code: '640181', + }, + ], }, { - "name":"石嘴山市", - "code":"640200", - "sub":[ + name: '石嘴山市', + code: '640200', + sub: [ { - "name":"市辖区", - "code":"640201" + name: '市辖区', + code: '640201', }, { - "name":"大武口区", - "code":"640202" + name: '大武口区', + code: '640202', }, { - "name":"惠农区", - "code":"640205" + name: '惠农区', + code: '640205', }, { - "name":"平罗县", - "code":"640221" - } - ] + name: '平罗县', + code: '640221', + }, + ], }, { - "name":"吴忠市", - "code":"640300", - "sub":[ + name: '吴忠市', + code: '640300', + sub: [ { - "name":"市辖区", - "code":"640301" + name: '市辖区', + code: '640301', }, { - "name":"利通区", - "code":"640302" + name: '利通区', + code: '640302', }, { - "name":"红寺堡区", - "code":"640303" + name: '红寺堡区', + code: '640303', }, { - "name":"盐池县", - "code":"640323" + name: '盐池县', + code: '640323', }, { - "name":"同心县", - "code":"640324" + name: '同心县', + code: '640324', }, { - "name":"青铜峡市", - "code":"640381" - } - ] + name: '青铜峡市', + code: '640381', + }, + ], }, { - "name":"固原市", - "code":"640400", - "sub":[ + name: '固原市', + code: '640400', + sub: [ { - "name":"市辖区", - "code":"640401" + name: '市辖区', + code: '640401', }, { - "name":"原州区", - "code":"640402" + name: '原州区', + code: '640402', }, { - "name":"西吉县", - "code":"640422" + name: '西吉县', + code: '640422', }, { - "name":"隆德县", - "code":"640423" + name: '隆德县', + code: '640423', }, { - "name":"泾源县", - "code":"640424" + name: '泾源县', + code: '640424', }, { - "name":"彭阳县", - "code":"640425" - } - ] + name: '彭阳县', + code: '640425', + }, + ], }, { - "name":"中卫市", - "code":"640500", - "sub":[ + name: '中卫市', + code: '640500', + sub: [ { - "name":"市辖区", - "code":"640501" + name: '市辖区', + code: '640501', }, { - "name":"沙坡头区", - "code":"640502" + name: '沙坡头区', + code: '640502', }, { - "name":"中宁县", - "code":"640521" + name: '中宁县', + code: '640521', }, { - "name":"海原县", - "code":"640522" - } - ] - } - ] + name: '海原县', + code: '640522', + }, + ], + }, + ], }, { - "name":"新疆维吾尔自治区", - "code":"650000", - "sub":[ + name: '新疆维吾尔自治区', + code: '650000', + sub: [ { - "name":"乌鲁木齐市", - "code":"650100", - "sub":[ + name: '乌鲁木齐市', + code: '650100', + sub: [ { - "name":"市辖区", - "code":"650101" + name: '市辖区', + code: '650101', }, { - "name":"天山区", - "code":"650102" + name: '天山区', + code: '650102', }, { - "name":"沙依巴克区", - "code":"650103" + name: '沙依巴克区', + code: '650103', }, { - "name":"新市区", - "code":"650104" + name: '新市区', + code: '650104', }, { - "name":"水磨沟区", - "code":"650105" + name: '水磨沟区', + code: '650105', }, { - "name":"头屯河区", - "code":"650106" + name: '头屯河区', + code: '650106', }, { - "name":"达坂城区", - "code":"650107" + name: '达坂城区', + code: '650107', }, { - "name":"米东区", - "code":"650109" + name: '米东区', + code: '650109', }, { - "name":"乌鲁木齐县", - "code":"650121" - } - ] + name: '乌鲁木齐县', + code: '650121', + }, + ], }, { - "name":"克拉玛依市", - "code":"650200", - "sub":[ + name: '克拉玛依市', + code: '650200', + sub: [ { - "name":"市辖区", - "code":"650201" + name: '市辖区', + code: '650201', }, { - "name":"独山子区", - "code":"650202" + name: '独山子区', + code: '650202', }, { - "name":"克拉玛依区", - "code":"650203" + name: '克拉玛依区', + code: '650203', }, { - "name":"白碱滩区", - "code":"650204" + name: '白碱滩区', + code: '650204', }, { - "name":"乌尔禾区", - "code":"650205" - } - ] + name: '乌尔禾区', + code: '650205', + }, + ], }, { - "name":"吐鲁番地区", - "code":"652100", - "sub":[ + name: '吐鲁番地区', + code: '652100', + sub: [ { - "name":"吐鲁番市", - "code":"652101" + name: '吐鲁番市', + code: '652101', }, { - "name":"鄯善县", - "code":"652122" + name: '鄯善县', + code: '652122', }, { - "name":"托克逊县", - "code":"652123" - } - ] + name: '托克逊县', + code: '652123', + }, + ], }, { - "name":"哈密地区", - "code":"652200", - "sub":[ + name: '哈密地区', + code: '652200', + sub: [ { - "name":"哈密市", - "code":"652201" + name: '哈密市', + code: '652201', }, { - "name":"巴里坤哈萨克自治县", - "code":"652222" + name: '巴里坤哈萨克自治县', + code: '652222', }, { - "name":"伊吾县", - "code":"652223" - } - ] + name: '伊吾县', + code: '652223', + }, + ], }, { - "name":"昌吉回族自治州", - "code":"652300", - "sub":[ + name: '昌吉回族自治州', + code: '652300', + sub: [ { - "name":"昌吉市", - "code":"652301" + name: '昌吉市', + code: '652301', }, { - "name":"阜康市", - "code":"652302" + name: '阜康市', + code: '652302', }, { - "name":"呼图壁县", - "code":"652323" + name: '呼图壁县', + code: '652323', }, { - "name":"玛纳斯县", - "code":"652324" + name: '玛纳斯县', + code: '652324', }, { - "name":"奇台县", - "code":"652325" + name: '奇台县', + code: '652325', }, { - "name":"吉木萨尔县", - "code":"652327" + name: '吉木萨尔县', + code: '652327', }, { - "name":"木垒哈萨克自治县", - "code":"652328" - } - ] + name: '木垒哈萨克自治县', + code: '652328', + }, + ], }, { - "name":"博尔塔拉蒙古自治州", - "code":"652700", - "sub":[ + name: '博尔塔拉蒙古自治州', + code: '652700', + sub: [ { - "name":"博乐市", - "code":"652701" + name: '博乐市', + code: '652701', }, { - "name":"阿拉山口市", - "code":"652702" + name: '阿拉山口市', + code: '652702', }, { - "name":"精河县", - "code":"652722" + name: '精河县', + code: '652722', }, { - "name":"温泉县", - "code":"652723" - } - ] + name: '温泉县', + code: '652723', + }, + ], }, { - "name":"巴音郭楞蒙古自治州", - "code":"652800", - "sub":[ + name: '巴音郭楞蒙古自治州', + code: '652800', + sub: [ { - "name":"库尔勒市", - "code":"652801" + name: '库尔勒市', + code: '652801', }, { - "name":"轮台县", - "code":"652822" + name: '轮台县', + code: '652822', }, { - "name":"尉犁县", - "code":"652823" + name: '尉犁县', + code: '652823', }, { - "name":"若羌县", - "code":"652824" + name: '若羌县', + code: '652824', }, { - "name":"且末县", - "code":"652825" + name: '且末县', + code: '652825', }, { - "name":"焉耆回族自治县", - "code":"652826" + name: '焉耆回族自治县', + code: '652826', }, { - "name":"和静县", - "code":"652827" + name: '和静县', + code: '652827', }, { - "name":"和硕县", - "code":"652828" + name: '和硕县', + code: '652828', }, { - "name":"博湖县", - "code":"652829" - } - ] + name: '博湖县', + code: '652829', + }, + ], }, { - "name":"阿克苏地区", - "code":"652900", - "sub":[ + name: '阿克苏地区', + code: '652900', + sub: [ { - "name":"阿克苏市", - "code":"652901" + name: '阿克苏市', + code: '652901', }, { - "name":"温宿县", - "code":"652922" + name: '温宿县', + code: '652922', }, { - "name":"库车县", - "code":"652923" + name: '库车县', + code: '652923', }, { - "name":"沙雅县", - "code":"652924" + name: '沙雅县', + code: '652924', }, { - "name":"新和县", - "code":"652925" + name: '新和县', + code: '652925', }, { - "name":"拜城县", - "code":"652926" + name: '拜城县', + code: '652926', }, { - "name":"乌什县", - "code":"652927" + name: '乌什县', + code: '652927', }, { - "name":"阿瓦提县", - "code":"652928" + name: '阿瓦提县', + code: '652928', }, { - "name":"柯坪县", - "code":"652929" - } - ] + name: '柯坪县', + code: '652929', + }, + ], }, { - "name":"克孜勒苏柯尔克孜自治州", - "code":"653000", - "sub":[ + name: '克孜勒苏柯尔克孜自治州', + code: '653000', + sub: [ { - "name":"阿图什市", - "code":"653001" + name: '阿图什市', + code: '653001', }, { - "name":"阿克陶县", - "code":"653022" + name: '阿克陶县', + code: '653022', }, { - "name":"阿合奇县", - "code":"653023" + name: '阿合奇县', + code: '653023', }, { - "name":"乌恰县", - "code":"653024" - } - ] + name: '乌恰县', + code: '653024', + }, + ], }, { - "name":"喀什地区", - "code":"653100", - "sub":[ + name: '喀什地区', + code: '653100', + sub: [ { - "name":"喀什市", - "code":"653101" + name: '喀什市', + code: '653101', }, { - "name":"疏附县", - "code":"653121" + name: '疏附县', + code: '653121', }, { - "name":"疏勒县", - "code":"653122" + name: '疏勒县', + code: '653122', }, { - "name":"英吉沙县", - "code":"653123" + name: '英吉沙县', + code: '653123', }, { - "name":"泽普县", - "code":"653124" + name: '泽普县', + code: '653124', }, { - "name":"莎车县", - "code":"653125" + name: '莎车县', + code: '653125', }, { - "name":"叶城县", - "code":"653126" + name: '叶城县', + code: '653126', }, { - "name":"麦盖提县", - "code":"653127" + name: '麦盖提县', + code: '653127', }, { - "name":"岳普湖县", - "code":"653128" + name: '岳普湖县', + code: '653128', }, { - "name":"伽师县", - "code":"653129" + name: '伽师县', + code: '653129', }, { - "name":"巴楚县", - "code":"653130" + name: '巴楚县', + code: '653130', }, { - "name":"塔什库尔干塔吉克自治县", - "code":"653131" - } - ] + name: '塔什库尔干塔吉克自治县', + code: '653131', + }, + ], }, { - "name":"和田地区", - "code":"653200", - "sub":[ + name: '和田地区', + code: '653200', + sub: [ { - "name":"和田市", - "code":"653201" + name: '和田市', + code: '653201', }, { - "name":"和田县", - "code":"653221" + name: '和田县', + code: '653221', }, { - "name":"墨玉县", - "code":"653222" + name: '墨玉县', + code: '653222', }, { - "name":"皮山县", - "code":"653223" + name: '皮山县', + code: '653223', }, { - "name":"洛浦县", - "code":"653224" + name: '洛浦县', + code: '653224', }, { - "name":"策勒县", - "code":"653225" + name: '策勒县', + code: '653225', }, { - "name":"于田县", - "code":"653226" + name: '于田县', + code: '653226', }, { - "name":"民丰县", - "code":"653227" - } - ] + name: '民丰县', + code: '653227', + }, + ], }, { - "name":"伊犁哈萨克自治州", - "code":"654000", - "sub":[ + name: '伊犁哈萨克自治州', + code: '654000', + sub: [ { - "name":"伊宁市", - "code":"654002" + name: '伊宁市', + code: '654002', }, { - "name":"奎屯市", - "code":"654003" + name: '奎屯市', + code: '654003', }, { - "name":"霍尔果斯市", - "code":"654004" + name: '霍尔果斯市', + code: '654004', }, { - "name":"伊宁县", - "code":"654021" + name: '伊宁县', + code: '654021', }, { - "name":"察布查尔锡伯自治县", - "code":"654022" + name: '察布查尔锡伯自治县', + code: '654022', }, { - "name":"霍城县", - "code":"654023" + name: '霍城县', + code: '654023', }, { - "name":"巩留县", - "code":"654024" + name: '巩留县', + code: '654024', }, { - "name":"新源县", - "code":"654025" + name: '新源县', + code: '654025', }, { - "name":"昭苏县", - "code":"654026" + name: '昭苏县', + code: '654026', }, { - "name":"特克斯县", - "code":"654027" + name: '特克斯县', + code: '654027', }, { - "name":"尼勒克县", - "code":"654028" + name: '尼勒克县', + code: '654028', }, { - "name":"塔城地区", - "code":"654200" + name: '塔城地区', + code: '654200', }, { - "name":"塔城市", - "code":"654201" + name: '塔城市', + code: '654201', }, { - "name":"乌苏市", - "code":"654202" + name: '乌苏市', + code: '654202', }, { - "name":"额敏县", - "code":"654221" + name: '额敏县', + code: '654221', }, { - "name":"沙湾县", - "code":"654223" + name: '沙湾县', + code: '654223', }, { - "name":"托里县", - "code":"654224" + name: '托里县', + code: '654224', }, { - "name":"裕民县", - "code":"654225" + name: '裕民县', + code: '654225', }, { - "name":"和布克赛尔蒙古自治县", - "code":"654226" + name: '和布克赛尔蒙古自治县', + code: '654226', }, { - "name":"阿勒泰地区", - "code":"654300" + name: '阿勒泰地区', + code: '654300', }, { - "name":"阿勒泰市", - "code":"654301" + name: '阿勒泰市', + code: '654301', }, { - "name":"布尔津县", - "code":"654321" + name: '布尔津县', + code: '654321', }, { - "name":"富蕴县", - "code":"654322" + name: '富蕴县', + code: '654322', }, { - "name":"福海县", - "code":"654323" + name: '福海县', + code: '654323', }, { - "name":"哈巴河县", - "code":"654324" + name: '哈巴河县', + code: '654324', }, { - "name":"青河县", - "code":"654325" + name: '青河县', + code: '654325', }, { - "name":"吉木乃县", - "code":"654326" - } - ] + name: '吉木乃县', + code: '654326', + }, + ], }, { - "name":"自治区直辖县级行政区划", - "code":"659000", - "sub":[ + name: '自治区直辖县级行政区划', + code: '659000', + sub: [ { - "name":"石河子市", - "code":"659001" + name: '石河子市', + code: '659001', }, { - "name":"阿拉尔市", - "code":"659002" + name: '阿拉尔市', + code: '659002', }, { - "name":"图木舒克市", - "code":"659003" + name: '图木舒克市', + code: '659003', }, { - "name":"五家渠市", - "code":"659004" + name: '五家渠市', + code: '659004', }, { - "name":"北屯市", - "code":"659005" + name: '北屯市', + code: '659005', }, { - "name":"铁门关市", - "code":"659006" + name: '铁门关市', + code: '659006', }, { - "name":"双河市", - "code":"659007" - } - ] - } - ] + name: '双河市', + code: '659007', + }, + ], + }, + ], }, { - "name":"台湾省", - "code":"710000", - "sub":[ + name: '台湾省', + code: '710000', + sub: [ { - "name":"台北市", - "code":"710100", - "sub":[ + name: '台北市', + code: '710100', + sub: [ { - "name":"松山区", - "code":"710101" + name: '松山区', + code: '710101', }, { - "name":"信义区", - "code":"710102" + name: '信义区', + code: '710102', }, { - "name":"大安区", - "code":"710103" + name: '大安区', + code: '710103', }, { - "name":"中山区", - "code":"710104" + name: '中山区', + code: '710104', }, { - "name":"中正区", - "code":"710105" + name: '中正区', + code: '710105', }, { - "name":"大同区", - "code":"710106" + name: '大同区', + code: '710106', }, { - "name":"万华区", - "code":"710107" + name: '万华区', + code: '710107', }, { - "name":"文山区", - "code":"710108" + name: '文山区', + code: '710108', }, { - "name":"南港区", - "code":"710109" + name: '南港区', + code: '710109', }, { - "name":"内湖区", - "code":"710110" + name: '内湖区', + code: '710110', }, { - "name":"士林区", - "code":"710111" + name: '士林区', + code: '710111', }, { - "name":"北投区", - "code":"710112" - } - ] + name: '北投区', + code: '710112', + }, + ], }, { - "name":"高雄市", - "code":"710200", - "sub":[ + name: '高雄市', + code: '710200', + sub: [ { - "name":"盐埕区", - "code":"710201" + name: '盐埕区', + code: '710201', }, { - "name":"鼓山区", - "code":"710202" + name: '鼓山区', + code: '710202', }, { - "name":"左营区", - "code":"710203" + name: '左营区', + code: '710203', }, { - "name":"楠梓区", - "code":"710204" + name: '楠梓区', + code: '710204', }, { - "name":"三民区", - "code":"710205" + name: '三民区', + code: '710205', }, { - "name":"新兴区", - "code":"710206" + name: '新兴区', + code: '710206', }, { - "name":"前金区", - "code":"710207" + name: '前金区', + code: '710207', }, { - "name":"苓雅区", - "code":"710208" + name: '苓雅区', + code: '710208', }, { - "name":"前镇区", - "code":"710209" + name: '前镇区', + code: '710209', }, { - "name":"旗津区", - "code":"710210" + name: '旗津区', + code: '710210', }, { - "name":"小港区", - "code":"710211" + name: '小港区', + code: '710211', }, { - "name":"凤山区", - "code":"710212" + name: '凤山区', + code: '710212', }, { - "name":"林园区", - "code":"710213" + name: '林园区', + code: '710213', }, { - "name":"大寮区", - "code":"710214" + name: '大寮区', + code: '710214', }, { - "name":"大树区", - "code":"710215" + name: '大树区', + code: '710215', }, { - "name":"大社区", - "code":"710216" + name: '大社区', + code: '710216', }, { - "name":"仁武区", - "code":"710217" + name: '仁武区', + code: '710217', }, { - "name":"鸟松区", - "code":"710218" + name: '鸟松区', + code: '710218', }, { - "name":"冈山区", - "code":"710219" + name: '冈山区', + code: '710219', }, { - "name":"桥头区", - "code":"710220" + name: '桥头区', + code: '710220', }, { - "name":"燕巢区", - "code":"710221" + name: '燕巢区', + code: '710221', }, { - "name":"田寮区", - "code":"710222" + name: '田寮区', + code: '710222', }, { - "name":"阿莲区", - "code":"710223" + name: '阿莲区', + code: '710223', }, { - "name":"路竹区", - "code":"710224" + name: '路竹区', + code: '710224', }, { - "name":"湖内区", - "code":"710225" + name: '湖内区', + code: '710225', }, { - "name":"茄萣区", - "code":"710226" + name: '茄萣区', + code: '710226', }, { - "name":"永安区", - "code":"710227" + name: '永安区', + code: '710227', }, { - "name":"弥陀区", - "code":"710228" + name: '弥陀区', + code: '710228', }, { - "name":"梓官区", - "code":"710229" + name: '梓官区', + code: '710229', }, { - "name":"旗山区", - "code":"710230" + name: '旗山区', + code: '710230', }, { - "name":"美浓区", - "code":"710231" + name: '美浓区', + code: '710231', }, { - "name":"六龟区", - "code":"710232" + name: '六龟区', + code: '710232', }, { - "name":"甲仙区", - "code":"710233" + name: '甲仙区', + code: '710233', }, { - "name":"杉林区", - "code":"710234" + name: '杉林区', + code: '710234', }, { - "name":"内门区", - "code":"710235" + name: '内门区', + code: '710235', }, { - "name":"茂林区", - "code":"710236" + name: '茂林区', + code: '710236', }, { - "name":"桃源区", - "code":"710237" + name: '桃源区', + code: '710237', }, { - "name":"那玛夏区", - "code":"710238" - } - ] + name: '那玛夏区', + code: '710238', + }, + ], }, { - "name":"基隆市", - "code":"710300", - "sub":[ + name: '基隆市', + code: '710300', + sub: [ { - "name":"中正区", - "code":"710301" + name: '中正区', + code: '710301', }, { - "name":"七堵区", - "code":"710302" + name: '七堵区', + code: '710302', }, { - "name":"暖暖区", - "code":"710303" + name: '暖暖区', + code: '710303', }, { - "name":"仁爱区", - "code":"710304" + name: '仁爱区', + code: '710304', }, { - "name":"中山区", - "code":"710305" + name: '中山区', + code: '710305', }, { - "name":"安乐区", - "code":"710306" + name: '安乐区', + code: '710306', }, { - "name":"信义区", - "code":"710307" - } - ] + name: '信义区', + code: '710307', + }, + ], }, { - "name":"台中市", - "code":"710400", - "sub":[ + name: '台中市', + code: '710400', + sub: [ { - "name":"中区", - "code":"710401" + name: '中区', + code: '710401', }, { - "name":"东区", - "code":"710402" + name: '东区', + code: '710402', }, { - "name":"南区", - "code":"710403" + name: '南区', + code: '710403', }, { - "name":"西区", - "code":"710404" + name: '西区', + code: '710404', }, { - "name":"北区", - "code":"710405" + name: '北区', + code: '710405', }, { - "name":"西屯区", - "code":"710406" + name: '西屯区', + code: '710406', }, { - "name":"南屯区", - "code":"710407" + name: '南屯区', + code: '710407', }, { - "name":"北屯区", - "code":"710408" + name: '北屯区', + code: '710408', }, { - "name":"丰原区", - "code":"710409" + name: '丰原区', + code: '710409', }, { - "name":"东势区", - "code":"710410" + name: '东势区', + code: '710410', }, { - "name":"大甲区", - "code":"710411" + name: '大甲区', + code: '710411', }, { - "name":"清水区", - "code":"710412" + name: '清水区', + code: '710412', }, { - "name":"沙鹿区", - "code":"710413" + name: '沙鹿区', + code: '710413', }, { - "name":"梧栖区", - "code":"710414" + name: '梧栖区', + code: '710414', }, { - "name":"后里区", - "code":"710415" + name: '后里区', + code: '710415', }, { - "name":"神冈区", - "code":"710416" + name: '神冈区', + code: '710416', }, { - "name":"潭子区", - "code":"710417" + name: '潭子区', + code: '710417', }, { - "name":"大雅区", - "code":"710418" + name: '大雅区', + code: '710418', }, { - "name":"新社区", - "code":"710419" + name: '新社区', + code: '710419', }, { - "name":"石冈区", - "code":"710420" + name: '石冈区', + code: '710420', }, { - "name":"外埔区", - "code":"710421" + name: '外埔区', + code: '710421', }, { - "name":"大安区", - "code":"710422" + name: '大安区', + code: '710422', }, { - "name":"乌日区", - "code":"710423" + name: '乌日区', + code: '710423', }, { - "name":"大肚区", - "code":"710424" + name: '大肚区', + code: '710424', }, { - "name":"龙井区", - "code":"710425" + name: '龙井区', + code: '710425', }, { - "name":"雾峰区", - "code":"710426" + name: '雾峰区', + code: '710426', }, { - "name":"太平区", - "code":"710427" + name: '太平区', + code: '710427', }, { - "name":"大里区", - "code":"710428" + name: '大里区', + code: '710428', }, { - "name":"和平区", - "code":"710429" - } - ] + name: '和平区', + code: '710429', + }, + ], }, { - "name":"台南市", - "code":"710500", - "sub":[ + name: '台南市', + code: '710500', + sub: [ { - "name":"东区", - "code":"710501" + name: '东区', + code: '710501', }, { - "name":"南区", - "code":"710502" + name: '南区', + code: '710502', }, { - "name":"北区", - "code":"710504" + name: '北区', + code: '710504', }, { - "name":"安南区", - "code":"710506" + name: '安南区', + code: '710506', }, { - "name":"安平区", - "code":"710507" + name: '安平区', + code: '710507', }, { - "name":"中西区", - "code":"710508" + name: '中西区', + code: '710508', }, { - "name":"新营区", - "code":"710509" + name: '新营区', + code: '710509', }, { - "name":"盐水区", - "code":"710510" + name: '盐水区', + code: '710510', }, { - "name":"白河区", - "code":"710511" + name: '白河区', + code: '710511', }, { - "name":"柳营区", - "code":"710512" + name: '柳营区', + code: '710512', }, { - "name":"后壁区", - "code":"710513" + name: '后壁区', + code: '710513', }, { - "name":"东山区", - "code":"710514" + name: '东山区', + code: '710514', }, { - "name":"麻豆区", - "code":"710515" + name: '麻豆区', + code: '710515', }, { - "name":"下营区", - "code":"710516" + name: '下营区', + code: '710516', }, { - "name":"六甲区", - "code":"710517" + name: '六甲区', + code: '710517', }, { - "name":"官田区", - "code":"710518" + name: '官田区', + code: '710518', }, { - "name":"大内区", - "code":"710519" + name: '大内区', + code: '710519', }, { - "name":"佳里区", - "code":"710520" + name: '佳里区', + code: '710520', }, { - "name":"学甲区", - "code":"710521" + name: '学甲区', + code: '710521', }, { - "name":"西港区", - "code":"710522" + name: '西港区', + code: '710522', }, { - "name":"七股区", - "code":"710523" + name: '七股区', + code: '710523', }, { - "name":"将军区", - "code":"710524" + name: '将军区', + code: '710524', }, { - "name":"北门区", - "code":"710525" + name: '北门区', + code: '710525', }, { - "name":"新化区", - "code":"710526" + name: '新化区', + code: '710526', }, { - "name":"善化区", - "code":"710527" + name: '善化区', + code: '710527', }, { - "name":"新市区", - "code":"710528" + name: '新市区', + code: '710528', }, { - "name":"安定区", - "code":"710529" + name: '安定区', + code: '710529', }, { - "name":"山上区", - "code":"710530" + name: '山上区', + code: '710530', }, { - "name":"玉井区", - "code":"710531" + name: '玉井区', + code: '710531', }, { - "name":"楠西区", - "code":"710532" + name: '楠西区', + code: '710532', }, { - "name":"南化区", - "code":"710533" + name: '南化区', + code: '710533', }, { - "name":"左镇区", - "code":"710534" + name: '左镇区', + code: '710534', }, { - "name":"仁德区", - "code":"710535" + name: '仁德区', + code: '710535', }, { - "name":"归仁区", - "code":"710536" + name: '归仁区', + code: '710536', }, { - "name":"关庙区", - "code":"710537" + name: '关庙区', + code: '710537', }, { - "name":"龙崎区", - "code":"710538" + name: '龙崎区', + code: '710538', }, { - "name":"永康区", - "code":"710539" - } - ] + name: '永康区', + code: '710539', + }, + ], }, { - "name":"新竹市", - "code":"710600", - "sub":[ + name: '新竹市', + code: '710600', + sub: [ { - "name":"东区", - "code":"710601" + name: '东区', + code: '710601', }, { - "name":"北区", - "code":"710602" + name: '北区', + code: '710602', }, { - "name":"香山区", - "code":"710603" - } - ] + name: '香山区', + code: '710603', + }, + ], }, { - "name":"嘉义市", - "code":"710700", - "sub":[ + name: '嘉义市', + code: '710700', + sub: [ { - "name":"东区", - "code":"710701" + name: '东区', + code: '710701', }, { - "name":"西区", - "code":"710702" - } - ] + name: '西区', + code: '710702', + }, + ], }, { - "name":"新北市", - "code":"710800", - "sub":[ + name: '新北市', + code: '710800', + sub: [ { - "name":"板桥区", - "code":"710801" + name: '板桥区', + code: '710801', }, { - "name":"三重区", - "code":"710802" + name: '三重区', + code: '710802', }, { - "name":"中和区", - "code":"710803" + name: '中和区', + code: '710803', }, { - "name":"永和区", - "code":"710804" + name: '永和区', + code: '710804', }, { - "name":"新庄区", - "code":"710805" + name: '新庄区', + code: '710805', }, { - "name":"新店区", - "code":"710806" + name: '新店区', + code: '710806', }, { - "name":"树林区", - "code":"710807" + name: '树林区', + code: '710807', }, { - "name":"莺歌区", - "code":"710808" + name: '莺歌区', + code: '710808', }, { - "name":"三峡区", - "code":"710809" + name: '三峡区', + code: '710809', }, { - "name":"淡水区", - "code":"710810" + name: '淡水区', + code: '710810', }, { - "name":"汐止区", - "code":"710811" + name: '汐止区', + code: '710811', }, { - "name":"瑞芳区", - "code":"710812" + name: '瑞芳区', + code: '710812', }, { - "name":"土城区", - "code":"710813" + name: '土城区', + code: '710813', }, { - "name":"芦洲区", - "code":"710814" + name: '芦洲区', + code: '710814', }, { - "name":"五股区", - "code":"710815" + name: '五股区', + code: '710815', }, { - "name":"泰山区", - "code":"710816" + name: '泰山区', + code: '710816', }, { - "name":"林口区", - "code":"710817" + name: '林口区', + code: '710817', }, { - "name":"深坑区", - "code":"710818" + name: '深坑区', + code: '710818', }, { - "name":"石碇区", - "code":"710819" + name: '石碇区', + code: '710819', }, { - "name":"坪林区", - "code":"710820" + name: '坪林区', + code: '710820', }, { - "name":"三芝区", - "code":"710821" + name: '三芝区', + code: '710821', }, { - "name":"石门区", - "code":"710822" + name: '石门区', + code: '710822', }, { - "name":"八里区", - "code":"710823" + name: '八里区', + code: '710823', }, { - "name":"平溪区", - "code":"710824" + name: '平溪区', + code: '710824', }, { - "name":"双溪区", - "code":"710825" + name: '双溪区', + code: '710825', }, { - "name":"贡寮区", - "code":"710826" + name: '贡寮区', + code: '710826', }, { - "name":"金山区", - "code":"710827" + name: '金山区', + code: '710827', }, { - "name":"万里区", - "code":"710828" + name: '万里区', + code: '710828', }, { - "name":"乌来区", - "code":"710829" - } - ] + name: '乌来区', + code: '710829', + }, + ], }, { - "name":"宜兰县", - "code":"712200", - "sub":[ + name: '宜兰县', + code: '712200', + sub: [ { - "name":"宜兰市", - "code":"712201" + name: '宜兰市', + code: '712201', }, { - "name":"罗东镇", - "code":"712221" + name: '罗东镇', + code: '712221', }, { - "name":"苏澳镇", - "code":"712222" + name: '苏澳镇', + code: '712222', }, { - "name":"头城镇", - "code":"712223" + name: '头城镇', + code: '712223', }, { - "name":"礁溪乡", - "code":"712224" + name: '礁溪乡', + code: '712224', }, { - "name":"壮围乡", - "code":"712225" + name: '壮围乡', + code: '712225', }, { - "name":"员山乡", - "code":"712226" + name: '员山乡', + code: '712226', }, { - "name":"冬山乡", - "code":"712227" + name: '冬山乡', + code: '712227', }, { - "name":"五结乡", - "code":"712228" + name: '五结乡', + code: '712228', }, { - "name":"三星乡", - "code":"712229" + name: '三星乡', + code: '712229', }, { - "name":"大同乡", - "code":"712230" + name: '大同乡', + code: '712230', }, { - "name":"南澳乡", - "code":"712231" - } - ] + name: '南澳乡', + code: '712231', + }, + ], }, { - "name":"桃园县", - "code":"712300", - "sub":[ + name: '桃园县', + code: '712300', + sub: [ { - "name":"桃园市", - "code":"712301" + name: '桃园市', + code: '712301', }, { - "name":"中坜市", - "code":"712302" + name: '中坜市', + code: '712302', }, { - "name":"平镇市", - "code":"712303" + name: '平镇市', + code: '712303', }, { - "name":"八德市", - "code":"712304" + name: '八德市', + code: '712304', }, { - "name":"杨梅市", - "code":"712305" + name: '杨梅市', + code: '712305', }, { - "name":"大溪镇", - "code":"712321" + name: '大溪镇', + code: '712321', }, { - "name":"芦竹乡", - "code":"712323" + name: '芦竹乡', + code: '712323', }, { - "name":"大园乡", - "code":"712324" + name: '大园乡', + code: '712324', }, { - "name":"龟山乡", - "code":"712325" + name: '龟山乡', + code: '712325', }, { - "name":"龙潭乡", - "code":"712327" + name: '龙潭乡', + code: '712327', }, { - "name":"新屋乡", - "code":"712329" + name: '新屋乡', + code: '712329', }, { - "name":"观音乡", - "code":"712330" + name: '观音乡', + code: '712330', }, { - "name":"复兴乡", - "code":"712331" - } - ] + name: '复兴乡', + code: '712331', + }, + ], }, { - "name":"新竹县", - "code":"712400", - "sub":[ + name: '新竹县', + code: '712400', + sub: [ { - "name":"竹北市", - "code":"712401" + name: '竹北市', + code: '712401', }, { - "name":"竹东镇", - "code":"712421" + name: '竹东镇', + code: '712421', }, { - "name":"新埔镇", - "code":"712422" + name: '新埔镇', + code: '712422', }, { - "name":"关西镇", - "code":"712423" + name: '关西镇', + code: '712423', }, { - "name":"湖口乡", - "code":"712424" + name: '湖口乡', + code: '712424', }, { - "name":"新丰乡", - "code":"712425" + name: '新丰乡', + code: '712425', }, { - "name":"芎林乡", - "code":"712426" + name: '芎林乡', + code: '712426', }, { - "name":"橫山乡", - "code":"712427" + name: '橫山乡', + code: '712427', }, { - "name":"北埔乡", - "code":"712428" + name: '北埔乡', + code: '712428', }, { - "name":"宝山乡", - "code":"712429" + name: '宝山乡', + code: '712429', }, { - "name":"峨眉乡", - "code":"712430" + name: '峨眉乡', + code: '712430', }, { - "name":"尖石乡", - "code":"712431" + name: '尖石乡', + code: '712431', }, { - "name":"五峰乡", - "code":"712432" - } - ] + name: '五峰乡', + code: '712432', + }, + ], }, { - "name":"苗栗县", - "code":"712500", - "sub":[ + name: '苗栗县', + code: '712500', + sub: [ { - "name":"苗栗市", - "code":"712501" + name: '苗栗市', + code: '712501', }, { - "name":"苑里镇", - "code":"712521" + name: '苑里镇', + code: '712521', }, { - "name":"通霄镇", - "code":"712522" + name: '通霄镇', + code: '712522', }, { - "name":"竹南镇", - "code":"712523" + name: '竹南镇', + code: '712523', }, { - "name":"头份镇", - "code":"712524" + name: '头份镇', + code: '712524', }, { - "name":"后龙镇", - "code":"712525" + name: '后龙镇', + code: '712525', }, { - "name":"卓兰镇", - "code":"712526" + name: '卓兰镇', + code: '712526', }, { - "name":"大湖乡", - "code":"712527" + name: '大湖乡', + code: '712527', }, { - "name":"公馆乡", - "code":"712528" + name: '公馆乡', + code: '712528', }, { - "name":"铜锣乡", - "code":"712529" + name: '铜锣乡', + code: '712529', }, { - "name":"南庄乡", - "code":"712530" + name: '南庄乡', + code: '712530', }, { - "name":"头屋乡", - "code":"712531" + name: '头屋乡', + code: '712531', }, { - "name":"三义乡", - "code":"712532" + name: '三义乡', + code: '712532', }, { - "name":"西湖乡", - "code":"712533" + name: '西湖乡', + code: '712533', }, { - "name":"造桥乡", - "code":"712534" + name: '造桥乡', + code: '712534', }, { - "name":"三湾乡", - "code":"712535" + name: '三湾乡', + code: '712535', }, { - "name":"狮潭乡", - "code":"712536" + name: '狮潭乡', + code: '712536', }, { - "name":"泰安乡", - "code":"712537" - } - ] + name: '泰安乡', + code: '712537', + }, + ], }, { - "name":"彰化县", - "code":"712700", - "sub":[ + name: '彰化县', + code: '712700', + sub: [ { - "name":"彰化市", - "code":"712701" + name: '彰化市', + code: '712701', }, { - "name":"鹿港镇", - "code":"712721" + name: '鹿港镇', + code: '712721', }, { - "name":"和美镇", - "code":"712722" + name: '和美镇', + code: '712722', }, { - "name":"线西乡", - "code":"712723" + name: '线西乡', + code: '712723', }, { - "name":"伸港乡", - "code":"712724" + name: '伸港乡', + code: '712724', }, { - "name":"福兴乡", - "code":"712725" + name: '福兴乡', + code: '712725', }, { - "name":"秀水乡", - "code":"712726" + name: '秀水乡', + code: '712726', }, { - "name":"花坛乡", - "code":"712727" + name: '花坛乡', + code: '712727', }, { - "name":"芬园乡", - "code":"712728" + name: '芬园乡', + code: '712728', }, { - "name":"员林镇", - "code":"712729" + name: '员林镇', + code: '712729', }, { - "name":"溪湖镇", - "code":"712730" + name: '溪湖镇', + code: '712730', }, { - "name":"田中镇", - "code":"712731" + name: '田中镇', + code: '712731', }, { - "name":"大村乡", - "code":"712732" + name: '大村乡', + code: '712732', }, { - "name":"埔盐乡", - "code":"712733" + name: '埔盐乡', + code: '712733', }, { - "name":"埔心乡", - "code":"712734" + name: '埔心乡', + code: '712734', }, { - "name":"永靖乡", - "code":"712735" + name: '永靖乡', + code: '712735', }, { - "name":"社头乡", - "code":"712736" + name: '社头乡', + code: '712736', }, { - "name":"二水乡", - "code":"712737" + name: '二水乡', + code: '712737', }, { - "name":"北斗镇", - "code":"712738" + name: '北斗镇', + code: '712738', }, { - "name":"二林镇", - "code":"712739" + name: '二林镇', + code: '712739', }, { - "name":"田尾乡", - "code":"712740" + name: '田尾乡', + code: '712740', }, { - "name":"埤头乡", - "code":"712741" + name: '埤头乡', + code: '712741', }, { - "name":"芳苑乡", - "code":"712742" + name: '芳苑乡', + code: '712742', }, { - "name":"大城乡", - "code":"712743" + name: '大城乡', + code: '712743', }, { - "name":"竹塘乡", - "code":"712744" + name: '竹塘乡', + code: '712744', }, { - "name":"溪州乡", - "code":"712745" - } - ] + name: '溪州乡', + code: '712745', + }, + ], }, { - "name":"南投县", - "code":"712800", - "sub":[ + name: '南投县', + code: '712800', + sub: [ { - "name":"南投市", - "code":"712801" + name: '南投市', + code: '712801', }, { - "name":"埔里镇", - "code":"712821" + name: '埔里镇', + code: '712821', }, { - "name":"草屯镇", - "code":"712822" + name: '草屯镇', + code: '712822', }, { - "name":"竹山镇", - "code":"712823" + name: '竹山镇', + code: '712823', }, { - "name":"集集镇", - "code":"712824" + name: '集集镇', + code: '712824', }, { - "name":"名间乡", - "code":"712825" + name: '名间乡', + code: '712825', }, { - "name":"鹿谷乡", - "code":"712826" + name: '鹿谷乡', + code: '712826', }, { - "name":"中寮乡", - "code":"712827" + name: '中寮乡', + code: '712827', }, { - "name":"鱼池乡", - "code":"712828" + name: '鱼池乡', + code: '712828', }, { - "name":"国姓乡", - "code":"712829" + name: '国姓乡', + code: '712829', }, { - "name":"水里乡", - "code":"712830" + name: '水里乡', + code: '712830', }, { - "name":"信义乡", - "code":"712831" + name: '信义乡', + code: '712831', }, { - "name":"仁爱乡", - "code":"712832" - } - ] + name: '仁爱乡', + code: '712832', + }, + ], }, { - "name":"云林县", - "code":"712900", - "sub":[ + name: '云林县', + code: '712900', + sub: [ { - "name":"斗六市", - "code":"712901" + name: '斗六市', + code: '712901', }, { - "name":"斗南镇", - "code":"712921" + name: '斗南镇', + code: '712921', }, { - "name":"虎尾镇", - "code":"712922" + name: '虎尾镇', + code: '712922', }, { - "name":"西螺镇", - "code":"712923" + name: '西螺镇', + code: '712923', }, { - "name":"土库镇", - "code":"712924" + name: '土库镇', + code: '712924', }, { - "name":"北港镇", - "code":"712925" + name: '北港镇', + code: '712925', }, { - "name":"古坑乡", - "code":"712926" + name: '古坑乡', + code: '712926', }, { - "name":"大埤乡", - "code":"712927" + name: '大埤乡', + code: '712927', }, { - "name":"莿桐乡", - "code":"712928" + name: '莿桐乡', + code: '712928', }, { - "name":"林内乡", - "code":"712929" + name: '林内乡', + code: '712929', }, { - "name":"二仑乡", - "code":"712930" + name: '二仑乡', + code: '712930', }, { - "name":"仑背乡", - "code":"712931" + name: '仑背乡', + code: '712931', }, { - "name":"麦寮乡", - "code":"712932" + name: '麦寮乡', + code: '712932', }, { - "name":"东势乡", - "code":"712933" + name: '东势乡', + code: '712933', }, { - "name":"褒忠乡", - "code":"712934" + name: '褒忠乡', + code: '712934', }, { - "name":"台西乡", - "code":"712935" + name: '台西乡', + code: '712935', }, { - "name":"元长乡", - "code":"712936" + name: '元长乡', + code: '712936', }, { - "name":"四湖乡", - "code":"712937" + name: '四湖乡', + code: '712937', }, { - "name":"口湖乡", - "code":"712938" + name: '口湖乡', + code: '712938', }, { - "name":"水林乡", - "code":"712939" - } - ] + name: '水林乡', + code: '712939', + }, + ], }, { - "name":"嘉义县", - "code":"713000", - "sub":[ + name: '嘉义县', + code: '713000', + sub: [ { - "name":"太保市", - "code":"713001" + name: '太保市', + code: '713001', }, { - "name":"朴子市", - "code":"713002" + name: '朴子市', + code: '713002', }, { - "name":"布袋镇", - "code":"713023" + name: '布袋镇', + code: '713023', }, { - "name":"大林镇", - "code":"713024" + name: '大林镇', + code: '713024', }, { - "name":"民雄乡", - "code":"713025" + name: '民雄乡', + code: '713025', }, { - "name":"溪口乡", - "code":"713026" + name: '溪口乡', + code: '713026', }, { - "name":"新港乡", - "code":"713027" + name: '新港乡', + code: '713027', }, { - "name":"六脚乡", - "code":"713028" + name: '六脚乡', + code: '713028', }, { - "name":"东石乡", - "code":"713029" + name: '东石乡', + code: '713029', }, { - "name":"义竹乡", - "code":"713030" + name: '义竹乡', + code: '713030', }, { - "name":"鹿草乡", - "code":"713031" + name: '鹿草乡', + code: '713031', }, { - "name":"水上乡", - "code":"713032" + name: '水上乡', + code: '713032', }, { - "name":"中埔乡", - "code":"713033" + name: '中埔乡', + code: '713033', }, { - "name":"竹崎乡", - "code":"713034" + name: '竹崎乡', + code: '713034', }, { - "name":"梅山乡", - "code":"713035" + name: '梅山乡', + code: '713035', }, { - "name":"番路乡", - "code":"713036" + name: '番路乡', + code: '713036', }, { - "name":"大埔乡", - "code":"713037" + name: '大埔乡', + code: '713037', }, { - "name":"阿里山乡", - "code":"713038" - } - ] + name: '阿里山乡', + code: '713038', + }, + ], }, { - "name":"屏东县", - "code":"713300", - "sub":[ + name: '屏东县', + code: '713300', + sub: [ { - "name":"屏东市", - "code":"713301" + name: '屏东市', + code: '713301', }, { - "name":"潮州镇", - "code":"713321" + name: '潮州镇', + code: '713321', }, { - "name":"东港镇", - "code":"713322" + name: '东港镇', + code: '713322', }, { - "name":"恒春镇", - "code":"713323" + name: '恒春镇', + code: '713323', }, { - "name":"万丹乡", - "code":"713324" + name: '万丹乡', + code: '713324', }, { - "name":"长治乡", - "code":"713325" + name: '长治乡', + code: '713325', }, { - "name":"麟洛乡", - "code":"713326" + name: '麟洛乡', + code: '713326', }, { - "name":"九如乡", - "code":"713327" + name: '九如乡', + code: '713327', }, { - "name":"里港乡", - "code":"713328" + name: '里港乡', + code: '713328', }, { - "name":"盐埔乡", - "code":"713329" + name: '盐埔乡', + code: '713329', }, { - "name":"高树乡", - "code":"713330" + name: '高树乡', + code: '713330', }, { - "name":"万峦乡", - "code":"713331" + name: '万峦乡', + code: '713331', }, { - "name":"内埔乡", - "code":"713332" + name: '内埔乡', + code: '713332', }, { - "name":"竹田乡", - "code":"713333" + name: '竹田乡', + code: '713333', }, { - "name":"新埤乡", - "code":"713334" + name: '新埤乡', + code: '713334', }, { - "name":"枋寮乡", - "code":"713335" + name: '枋寮乡', + code: '713335', }, { - "name":"新园乡", - "code":"713336" + name: '新园乡', + code: '713336', }, { - "name":"崁顶乡", - "code":"713337" + name: '崁顶乡', + code: '713337', }, { - "name":"林边乡", - "code":"713338" + name: '林边乡', + code: '713338', }, { - "name":"南州乡", - "code":"713339" + name: '南州乡', + code: '713339', }, { - "name":"佳冬乡", - "code":"713340" + name: '佳冬乡', + code: '713340', }, { - "name":"琉球乡", - "code":"713341" + name: '琉球乡', + code: '713341', }, { - "name":"车城乡", - "code":"713342" + name: '车城乡', + code: '713342', }, { - "name":"满州乡", - "code":"713343" + name: '满州乡', + code: '713343', }, { - "name":"枋山乡", - "code":"713344" + name: '枋山乡', + code: '713344', }, { - "name":"三地门乡", - "code":"713345" + name: '三地门乡', + code: '713345', }, { - "name":"雾台乡", - "code":"713346" + name: '雾台乡', + code: '713346', }, { - "name":"玛家乡", - "code":"713347" + name: '玛家乡', + code: '713347', }, { - "name":"泰武乡", - "code":"713348" + name: '泰武乡', + code: '713348', }, { - "name":"来义乡", - "code":"713349" + name: '来义乡', + code: '713349', }, { - "name":"春日乡", - "code":"713350" + name: '春日乡', + code: '713350', }, { - "name":"狮子乡", - "code":"713351" + name: '狮子乡', + code: '713351', }, { - "name":"牡丹乡", - "code":"713352" - } - ] + name: '牡丹乡', + code: '713352', + }, + ], }, { - "name":"台东县", - "code":"713400", - "sub":[ + name: '台东县', + code: '713400', + sub: [ { - "name":"台东市", - "code":"713401" + name: '台东市', + code: '713401', }, { - "name":"成功镇", - "code":"713421" + name: '成功镇', + code: '713421', }, { - "name":"关山镇", - "code":"713422" + name: '关山镇', + code: '713422', }, { - "name":"卑南乡", - "code":"713423" + name: '卑南乡', + code: '713423', }, { - "name":"鹿野乡", - "code":"713424" + name: '鹿野乡', + code: '713424', }, { - "name":"池上乡", - "code":"713425" + name: '池上乡', + code: '713425', }, { - "name":"东河乡", - "code":"713426" + name: '东河乡', + code: '713426', }, { - "name":"长滨乡", - "code":"713427" + name: '长滨乡', + code: '713427', }, { - "name":"太麻里乡", - "code":"713428" + name: '太麻里乡', + code: '713428', }, { - "name":"大武乡", - "code":"713429" + name: '大武乡', + code: '713429', }, { - "name":"绿岛乡", - "code":"713430" + name: '绿岛乡', + code: '713430', }, { - "name":"海端乡", - "code":"713431" + name: '海端乡', + code: '713431', }, { - "name":"延平乡", - "code":"713432" + name: '延平乡', + code: '713432', }, { - "name":"金峰乡", - "code":"713433" + name: '金峰乡', + code: '713433', }, { - "name":"达仁乡", - "code":"713434" + name: '达仁乡', + code: '713434', }, { - "name":"兰屿乡", - "code":"713435" - } - ] + name: '兰屿乡', + code: '713435', + }, + ], }, { - "name":"花莲县", - "code":"713500", - "sub":[ + name: '花莲县', + code: '713500', + sub: [ { - "name":"花莲市", - "code":"713501" + name: '花莲市', + code: '713501', }, { - "name":"凤林镇", - "code":"713521" + name: '凤林镇', + code: '713521', }, { - "name":"玉里镇", - "code":"713522" + name: '玉里镇', + code: '713522', }, { - "name":"新城乡", - "code":"713523" + name: '新城乡', + code: '713523', }, { - "name":"吉安乡", - "code":"713524" + name: '吉安乡', + code: '713524', }, { - "name":"寿丰乡", - "code":"713525" + name: '寿丰乡', + code: '713525', }, { - "name":"光复乡", - "code":"713526" + name: '光复乡', + code: '713526', }, { - "name":"丰滨乡", - "code":"713527" + name: '丰滨乡', + code: '713527', }, { - "name":"瑞穗乡", - "code":"713528" + name: '瑞穗乡', + code: '713528', }, { - "name":"富里乡", - "code":"713529" + name: '富里乡', + code: '713529', }, { - "name":"秀林乡", - "code":"713530" + name: '秀林乡', + code: '713530', }, { - "name":"万荣乡", - "code":"713531" + name: '万荣乡', + code: '713531', }, { - "name":"卓溪乡", - "code":"713532" - } - ] + name: '卓溪乡', + code: '713532', + }, + ], }, { - "name":"澎湖县", - "code":"713600", - "sub":[ + name: '澎湖县', + code: '713600', + sub: [ { - "name":"马公市", - "code":"713601" + name: '马公市', + code: '713601', }, { - "name":"湖西乡", - "code":"713621" + name: '湖西乡', + code: '713621', }, { - "name":"白沙乡", - "code":"713622" + name: '白沙乡', + code: '713622', }, { - "name":"西屿乡", - "code":"713623" + name: '西屿乡', + code: '713623', }, { - "name":"望安乡", - "code":"713624" + name: '望安乡', + code: '713624', }, { - "name":"七美乡", - "code":"713625" - } - ] - } - ] + name: '七美乡', + code: '713625', + }, + ], + }, + ], }, { - "name":"香港特别行政区", - "code":"810000", - "sub":[ + name: '香港特别行政区', + code: '810000', + sub: [ { - "name":"香港岛", - "code":"810100", - "sub":[ + name: '香港岛', + code: '810100', + sub: [ { - "name":"中西区", - "code":"810101" + name: '中西区', + code: '810101', }, { - "name":"湾仔区", - "code":"810102" + name: '湾仔区', + code: '810102', }, { - "name":"东区", - "code":"810103" + name: '东区', + code: '810103', }, { - "name":"南区", - "code":"810104" - } - ] + name: '南区', + code: '810104', + }, + ], }, { - "name":"九龙", - "code":"810200", - "sub":[ + name: '九龙', + code: '810200', + sub: [ { - "name":"油尖旺区", - "code":"810201" + name: '油尖旺区', + code: '810201', }, { - "name":"深水埗区", - "code":"810202" + name: '深水埗区', + code: '810202', }, { - "name":"九龙城区", - "code":"810203" + name: '九龙城区', + code: '810203', }, { - "name":"黄大仙区", - "code":"810204" + name: '黄大仙区', + code: '810204', }, { - "name":"观塘区", - "code":"810205" - } - ] + name: '观塘区', + code: '810205', + }, + ], }, { - "name":"新界", - "code":"810300", - "sub":[ + name: '新界', + code: '810300', + sub: [ { - "name":"荃湾区", - "code":"810301" + name: '荃湾区', + code: '810301', }, { - "name":"屯门区", - "code":"810302" + name: '屯门区', + code: '810302', }, { - "name":"元朗区", - "code":"810303" + name: '元朗区', + code: '810303', }, { - "name":"北区", - "code":"810304" + name: '北区', + code: '810304', }, { - "name":"大埔区", - "code":"810305" + name: '大埔区', + code: '810305', }, { - "name":"西贡区", - "code":"810306" + name: '西贡区', + code: '810306', }, { - "name":"沙田区", - "code":"810307" + name: '沙田区', + code: '810307', }, { - "name":"葵青区", - "code":"810308" + name: '葵青区', + code: '810308', }, { - "name":"离岛区", - "code":"810309" - } - ] - } - ] + name: '离岛区', + code: '810309', + }, + ], + }, + ], }, { - "name":"澳门特别行政区", - "code":"820000", - "sub":[ + name: '澳门特别行政区', + code: '820000', + sub: [ { - "name":"澳门半岛", - "code":"820100", - "sub":[ + name: '澳门半岛', + code: '820100', + sub: [ { - "name":"花地玛堂区", - "code":"820101" + name: '花地玛堂区', + code: '820101', }, { - "name":"圣安多尼堂区", - "code":"820102" + name: '圣安多尼堂区', + code: '820102', }, { - "name":"大堂区", - "code":"820103" + name: '大堂区', + code: '820103', }, { - "name":"望德堂区", - "code":"820104" + name: '望德堂区', + code: '820104', }, { - "name":"风顺堂区", - "code":"820105" - } - ] + name: '风顺堂区', + code: '820105', + }, + ], }, { - "name":"氹仔岛", - "code":"820200", - "sub":[ + name: '氹仔岛', + code: '820200', + sub: [ { - "name":"嘉模堂区", - "code":"820201" - } - ] + name: '嘉模堂区', + code: '820201', + }, + ], }, { - "name":"路环岛", - "code":"820300", - "sub":[ + name: '路环岛', + code: '820300', + sub: [ { - "name":"圣方济各堂区", - "code":"820301" - } - ] - } - ] - } + name: '圣方济各堂区', + code: '820301', + }, + ], + }, + ], + }, ]; diff --git a/src/app/example/picker/picker.component.html b/src/app/example/picker/picker.component.html index 6e771ab..852af26 100644 --- a/src/app/example/picker/picker.component.html +++ b/src/app/example/picker/picker.component.html @@ -1,102 +1,131 @@ - -

Form Result: {{ res | json }}

-
-
-
-
- -
-
- -
-
+

Form Result: {{ res | json }}

+ +
+
+
+
-
-
-
- -
-
- -
-
+
+
-
-
-
- -
-
- -
-
+
+
+
+
+
+
-
-
-
- -
-
- -
-
+
+
-
-
-
- -
-
- -
-
+
+
+
+
+
+
-
-
-
- -
-
- -
-
+
+
-
-
-
- -
-
- -
-
+
+
+
+
+
+
-
- +
+
- -
使用Service形式
-

Service Result: {{srvRes | json}}

+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+
- - - - - - +
- + +
使用Service形式
+

Service Result: {{ srvRes | json }}

+
+ + + + + + +
diff --git a/src/app/example/picker/picker.component.ts b/src/app/example/picker/picker.component.ts index 90eac37..18fde8a 100644 --- a/src/app/example/picker/picker.component.ts +++ b/src/app/example/picker/picker.component.ts @@ -1,135 +1,135 @@ -import { Component, ViewEncapsulation, OnDestroy } from '@angular/core'; -import { PickerData, PickerOptions, PickerService } from 'ngx-weui/picker'; +import { Component, OnDestroy, ViewEncapsulation } from '@angular/core'; +import { PickerService } from 'ngx-weui/picker'; import { DATA } from './cn'; @Component({ - selector: 'example-picker', - templateUrl: './picker.component.html', - styleUrls: ['./picker.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-picker', + templateUrl: './picker.component.html', + styleUrls: ['./picker.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoPickerComponent implements OnDestroy { - DT: any = { - min: new Date(2015, 1, 5), - max: new Date() - }; - res: any = { - city: '310105', - date: new Date() - }; + DT: any = { + min: new Date(2015, 1, 5), + max: new Date(), + }; + res: any = { + city: '310105', + date: new Date(), + }; - constructor(private srv: PickerService) {} + constructor(private srv: PickerService) {} - cityChange(item: any) { - console.log(item); - } + cityChange(item: any) { + console.log(item); + } - onSave() { - alert('请求数据:' + JSON.stringify(this.res)); - return false; - } + onSave() { + alert('请求数据:' + JSON.stringify(this.res)); + return false; + } - cityStatus: boolean = false; - cityOptions: any = { + cityStatus: boolean = false; + cityOptions: any = {}; + cityData: any = DATA; - }; - cityData: any = DATA; + onCityChange(data: any) { + console.log('onCityChange', data); + } + onCityGroupChange(data: any) { + console.log('onCityGroupChange', data); + } + onCityCancel() { + console.log('onCityCancel'); + } - onCityChange(data: any) { - console.log('onCityChange', data); - } - onCityGroupChange(data: any) { - console.log('onCityGroupChange', data); - } - onCityCancel() { - console.log('onCityCancel'); - } + items: string[] = Array(6) + .fill('') + .map((_v: string, idx: number) => `Item${idx}`); + itemGroup: any = [ + [ + { + label: 'Item1', + value: 1, + }, + { + label: 'Item2 (Disabled)', + disabled: true, + value: 2, + }, + { + label: 'Item3', + value: 3, + }, + { + label: 'Item4', + value: 4, + }, + { + label: 'Item5', + value: 5, + }, + ], + ]; + onItemChange(data: any) { + console.log('onItemChange', data); + } + onItemGroupChange(data: any) { + console.log('onItemGroupChange', data); + } + onItemCancel() { + console.log('onItemCancel'); + } - items: string[] = Array(6).fill('').map((v: string, idx: number) => `Item${idx}`); - itemGroup: any = [ - [ - { - label: 'Item1', - value: 1 - }, - { - label: 'Item2 (Disabled)', - disabled: true, - value: 2 - }, - { - label: 'Item3', - value: 3 - }, - { - label: 'Item4', - value: 4 - }, - { - label: 'Item5', - value: 5 - } - ] - ]; - onItemChange(data: any) { - console.log('onItemChange', data); - } - onItemGroupChange(data: any) { - console.log('onItemGroupChange', data); - } - onItemCancel() { - console.log('onItemCancel'); - } - - mData: any; + mData: any; - onMItemChange(data: any) { - console.log('onMItemChange', data); - } - onMItemGroupChange(data: any) { - console.log('onMItemGroupChange', data); - } - onMItemCancel() { - console.log('onMItemCancel'); - } + onMItemChange(data: any) { + console.log('onMItemChange', data); + } + onMItemGroupChange(data: any) { + console.log('onMItemGroupChange', data); + } + onMItemCancel() { + console.log('onMItemCancel'); + } - srvRes: any = ''; - onShowBySrv(type: string) { - switch (type) { - case 'city': - this.srv.showCity(this.cityData).subscribe((res: any) => { - this.srvRes = res.value; - }); - break; - case 'date-ym': - this.srv.showDateTime(type).subscribe((res: any) => { - this.srvRes = res.value; - }); - break; - case 'date': - this.srv.showDateTime(type).subscribe((res: any) => { - this.srvRes = res.value; - }); - break; - case 'datetime': - this.srv.showDateTime(type).subscribe((res: any) => { - this.srvRes = res.value; - }); - break; - case 'time': - this.srv.showDateTime(type).subscribe((res: any) => { - this.srvRes = res.value; - }); - break; - case 'data': - this.srv.show(this.items, 'Item3').subscribe((res: any) => { - this.srvRes = res.value; - }); - break; - } + srvRes: any = ''; + onShowBySrv(type: string) { + switch (type) { + case 'city': + this.srv.showCity(this.cityData).subscribe((res: any) => { + this.srvRes = res.value; + }); + break; + case 'date-ym': + this.srv.showDateTime(type).subscribe((res: any) => { + this.srvRes = res.value; + }); + break; + case 'date': + this.srv.showDateTime(type).subscribe((res: any) => { + this.srvRes = res.value; + }); + break; + case 'datetime': + this.srv.showDateTime(type).subscribe((res: any) => { + this.srvRes = res.value; + }); + break; + case 'time': + this.srv.showDateTime(type).subscribe((res: any) => { + this.srvRes = res.value; + }); + break; + case 'data': + this.srv.show(this.items, 'Item3').subscribe((res: any) => { + this.srvRes = res.value; + }); + break; } + } - ngOnDestroy() { - this.srv.destroyAll(); - } + ngOnDestroy() { + this.srv.destroyAll(); + } } diff --git a/src/app/example/popup/popup.component.html b/src/app/example/popup/popup.component.html index db81e4e..393c05f 100644 --- a/src/app/example/popup/popup.component.html +++ b/src/app/example/popup/popup.component.html @@ -1,62 +1,96 @@ + + + - - - - - - -
- -
-

Grid

-
- -
-

Grid

-
- -
-

Grid

-
- -
-

Grid

-
- -
-

Grid

-
- -
-

Grid

-
+ + + + + +
+

H1 Heading

+
+

H2 Title

+
+

H3 Heading

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex + ea commodo consequat. Duis aute +

+

+ truetrue +

+
+
+

H3 Heading

+

+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, cillum dolore eu fugiat nulla pariatur. Excepteur sint + occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +

+
+
+ +
+
+ + + diff --git a/src/app/example/popup/popup.component.ts b/src/app/example/popup/popup.component.ts index d141cea..c507110 100644 --- a/src/app/example/popup/popup.component.ts +++ b/src/app/example/popup/popup.component.ts @@ -1,22 +1,21 @@ -import { Component, ViewEncapsulation, ViewChild } from '@angular/core'; +import { Component, ViewChild, ViewEncapsulation } from '@angular/core'; -import { PopupComponent } from "ngx-weui/popup"; +import { PopupComponent } from 'ngx-weui/popup'; @Component({ - selector: 'example-popup', - templateUrl: './popup.component.html', - styleUrls: [ './popup.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-popup', + templateUrl: './popup.component.html', + styleUrls: ['./popup.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoPopupComponent { + @ViewChild('simple') simplePopup: PopupComponent; + @ViewChild('full') fullPopup: PopupComponent; + @ViewChild('subscribe') subPopup: PopupComponent; - @ViewChild('simple') simplePopup: PopupComponent; - @ViewChild('full') fullPopup: PopupComponent; - @ViewChild('subscribe') subPopup: PopupComponent; - - onSub() { - this.subPopup.show().subscribe((res: boolean) => { - alert('click confirm!!!'); - }); - } + onSub() { + this.subPopup.show().subscribe(() => { + alert('click confirm!!!'); + }); + } } diff --git a/src/app/example/preview/preview.component.html b/src/app/example/preview/preview.component.html index 247ee92..35814b1 100644 --- a/src/app/example/preview/preview.component.html +++ b/src/app/example/preview/preview.component.html @@ -1,54 +1,58 @@ - -
-
-
- - ¥2400.00 -
-
-
-
- - 电动打蛋机 -
-
- - 名字名字名字 -
-
- - 很长很长的名字很长很长的名字很长很长的名字很长很长的名字很长很长的名字 -
-
-
- 操作 -
+
+
+
+ + ¥2400.00 +
-
-
-
- - ¥2400.00 -
-
-
- - 电动打蛋机 -
-
- - 名字名字名字 -
-
- - 很长很长的名字很长很长的名字很长很长的名字很长很长的名字很长很长的名字 -
-
-
- 辅助操作 - -
+
+
+ + 电动打蛋机 +
+
+ + 名字名字名字 +
+
+ + 很长很长的名字很长很长的名字很长很长的名字很长很长的名字很长很长的名字 +
- +
+ 操作 +
+
+
+
+
+ + ¥2400.00 +
+
+
+ + 电动打蛋机 +
+
+ + 名字名字名字 +
+
+ + 很长很长的名字很长很长的名字很长很长的名字很长很长的名字很长很长的名字 +
+
+
+ 辅助操作 + +
+
diff --git a/src/app/example/preview/preview.component.ts b/src/app/example/preview/preview.component.ts index 83259a8..2219587 100644 --- a/src/app/example/preview/preview.component.ts +++ b/src/app/example/preview/preview.component.ts @@ -1,10 +1,9 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-preview', - templateUrl: './preview.component.html', - styleUrls: [ './preview.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-preview', + templateUrl: './preview.component.html', + styleUrls: ['./preview.component.scss'], + encapsulation: ViewEncapsulation.None, }) -export class PreviewComponent { -} +export class PreviewComponent {} diff --git a/src/app/example/progress/progress.component.html b/src/app/example/progress/progress.component.html index 5d85713..1a35275 100644 --- a/src/app/example/progress/progress.component.html +++ b/src/app/example/progress/progress.component.html @@ -1,12 +1,10 @@ + +
+ +
+ +
- -
- -
- -
- - - +
diff --git a/src/app/example/progress/progress.component.ts b/src/app/example/progress/progress.component.ts index 4e04cfb..1e0dce8 100644 --- a/src/app/example/progress/progress.component.ts +++ b/src/app/example/progress/progress.component.ts @@ -1,5 +1,5 @@ -import { Component, ViewEncapsulation, OnDestroy } from '@angular/core'; -import { Observable, Subscription, timer } from 'rxjs'; +import { Component, OnDestroy, ViewEncapsulation } from '@angular/core'; +import { timer, Subscription } from 'rxjs'; @Component({ selector: 'example-progress', @@ -14,7 +14,7 @@ export class DemoProgressComponent implements OnDestroy { g2: { value: 10, doing: false }, g3: { value: 50, doing: false }, }; - subscription: Subscription = null; + subscription: Subscription | null = null; onUpload() { this.onCancelAll(); @@ -25,7 +25,7 @@ export class DemoProgressComponent implements OnDestroy { g3: { value: 50, doing: true }, }; - this.subscription = timer(0, 40).subscribe((res: any) => { + this.subscription = timer(0, 40).subscribe(() => { let endCount = 0; Object.keys(this.res).forEach((key: string) => { const item = this.res[key]; diff --git a/src/app/example/ptr/ptr.component.html b/src/app/example/ptr/ptr.component.html index 365e73f..47fff9a 100644 --- a/src/app/example/ptr/ptr.component.html +++ b/src/app/example/ptr/ptr.component.html @@ -1,35 +1,37 @@ +
+ +
-
- + +
List with link
+ +
- -
List with link
-
- -
{{i}}
-
-
+
自定义Loaders样式
+ +
+
+
+
- - -
自定义Loaders样式
- -
-
-
- -
-
-
-
List with link
- -
- +
+
+
List with link
+ +
diff --git a/src/app/example/ptr/ptr.component.ts b/src/app/example/ptr/ptr.component.ts index a8e2b6e..4148883 100644 --- a/src/app/example/ptr/ptr.component.ts +++ b/src/app/example/ptr/ptr.component.ts @@ -1,5 +1,5 @@ -import { Component, ViewEncapsulation, OnDestroy, OnInit } from '@angular/core'; -import { Observable, timer } from 'rxjs'; +import { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { timer } from 'rxjs'; import { PTRComponent } from 'ngx-weui/ptr'; @@ -26,7 +26,7 @@ export class DemoPTRComponent implements OnInit { private genData() { this.items = Array(6) .fill({}) - .map((v: any, idx: number) => { + .map((_v: any, idx: number) => { return `${idx}:${Math.random()}`; }); } diff --git a/src/app/example/rating/rating.component.html b/src/app/example/rating/rating.component.html index 3d48015..1f23fed 100644 --- a/src/app/example/rating/rating.component.html +++ b/src/app/example/rating/rating.component.html @@ -1,19 +1,18 @@ - -
静态模式
-

value: {{rate}}

- -
动态模式
-

value: {{rate}} readonly: {{readonly}}

- -
- - -
-
自定义图标
-

value: {{rate}} readonly: {{readonly}}

- -
自定义图标与样式
-

value: {{rate}} readonly: {{readonly}}

- +
静态模式
+

value: {{ rate }}

+ +
动态模式
+

value: {{ rate }} readonly: {{ readonly }}

+ +
+ + +
+
自定义图标
+

value: {{ rate }} readonly: {{ readonly }}

+ +
自定义图标与样式
+

value: {{ rate }} readonly: {{ readonly }}

+
diff --git a/src/app/example/rating/rating.component.scss b/src/app/example/rating/rating.component.scss index 5224a56..01543a8 100644 --- a/src/app/example/rating/rating.component.scss +++ b/src/app/example/rating/rating.component.scss @@ -1,18 +1,18 @@ .rating { - >i { - display: inline-block; - &:before { - font-style: normal; - } + > i { + display: inline-block; + &::before { + font-style: normal; } - .off { - &:before { - content: '☆'; - } + } + .off { + &::before { + content: '☆'; } - .on { - &:before { - content: '★'; - } + } + .on { + &::before { + content: '★'; } + } } diff --git a/src/app/example/rating/rating.component.ts b/src/app/example/rating/rating.component.ts index 7a66b2d..0ee8d91 100644 --- a/src/app/example/rating/rating.component.ts +++ b/src/app/example/rating/rating.component.ts @@ -1,33 +1,32 @@ -import { Component, ViewEncapsulation, OnDestroy } from '@angular/core'; - -import { RatingComponent, RatingConfig } from 'ngx-weui/rating'; +import { Component, ViewEncapsulation } from '@angular/core'; +import { RatingConfig } from 'ngx-weui/rating'; @Component({ - selector: 'example-rating', - templateUrl: './rating.component.html', - styleUrls: ['./rating.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-rating', + templateUrl: './rating.component.html', + styleUrls: ['./rating.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoRatingComponent { - config: RatingConfig = { - max: 10 - }; - customIconsCog: RatingConfig = { - states: [ - { off: 'weui-icon-circle', on: 'weui-icon-download' }, - { off: 'weui-icon-circle', on: 'weui-icon-info' }, - { off: 'weui-icon-circle', on: 'weui-icon-warn' }, - { off: 'weui-icon-circle', on: 'weui-icon-waiting' }, - { off: 'weui-icon-circle', on: 'weui-icon-search' } - ] - }; - customIconsAndClassCog: RatingConfig = { - cls: 'rating', - stateOff: 'off', - stateOn: 'on' - }; + config: RatingConfig = { + max: 10, + }; + customIconsCog: RatingConfig = { + states: [ + { off: 'weui-icon-circle', on: 'weui-icon-download' }, + { off: 'weui-icon-circle', on: 'weui-icon-info' }, + { off: 'weui-icon-circle', on: 'weui-icon-warn' }, + { off: 'weui-icon-circle', on: 'weui-icon-waiting' }, + { off: 'weui-icon-circle', on: 'weui-icon-search' }, + ], + }; + customIconsAndClassCog: RatingConfig = { + cls: 'rating', + stateOff: 'off', + stateOn: 'on', + }; - rate: number = 3; + rate: number = 3; - readonly: boolean = false; + readonly: boolean = false; } diff --git a/src/app/example/searchbar/searchbar.component.html b/src/app/example/searchbar/searchbar.component.html index a98597c..e6f81c8 100644 --- a/src/app/example/searchbar/searchbar.component.html +++ b/src/app/example/searchbar/searchbar.component.html @@ -1,32 +1,31 @@ + - - -
-
查询淘宝【{{value}}】
-
-
-
-

{{item}}

-
-
-
Can't find any!
+
+
查询淘宝【{{ value }}】
+
+
+
+

{{ item }}

- -
-
Loading...
-
-
- - - +
+
Can't find any!
- + +
+
Loading...
+
+
+ + + +
diff --git a/src/app/example/searchbar/searchbar.component.ts b/src/app/example/searchbar/searchbar.component.ts index b5adebe..cc7a7ee 100644 --- a/src/app/example/searchbar/searchbar.component.ts +++ b/src/app/example/searchbar/searchbar.component.ts @@ -3,32 +3,31 @@ import { Observable } from 'rxjs'; import { TaobaoService } from './tb.service'; @Component({ - selector: 'example-searchbar', - templateUrl: './searchbar.component.html', - styleUrls: ['./searchbar.component.scss'], - encapsulation: ViewEncapsulation.None, - providers: [ TaobaoService ] + selector: 'example-searchbar', + templateUrl: './searchbar.component.html', + styleUrls: ['./searchbar.component.scss'], + encapsulation: ViewEncapsulation.None, + providers: [TaobaoService], }) export class DemoSearchBarComponent { + items: Observable; + value: string; + constructor(private tbService: TaobaoService) {} - items: Observable; - value: string; - constructor (private tbService: TaobaoService) { } + onSearch(term: string) { + this.value = term; + if (term) this.items = this.tbService.search(term); + } - onSearch(term: string) { - this.value = term; - if (term) this.items = this.tbService.search(term); - } + onCancel() { + console.log('onCancel'); + } - onCancel() { - console.log('onCancel'); - } + onClear() { + console.log('onCancel'); + } - onClear() { - console.log('onCancel'); - } - - onSubmit(value: string) { - console.log('onSubmit', value); - } + onSubmit(value: string) { + console.log('onSubmit', value); + } } diff --git a/src/app/example/searchbar/tb.service.ts b/src/app/example/searchbar/tb.service.ts index 6ce86e7..2ab3df1 100644 --- a/src/app/example/searchbar/tb.service.ts +++ b/src/app/example/searchbar/tb.service.ts @@ -4,7 +4,7 @@ import { map } from 'rxjs/operators'; @Injectable() export class TaobaoService { - constructor(private http: HttpClient) { } + constructor(private http: HttpClient) {} search(term: string) { const params = new URLSearchParams(); @@ -14,8 +14,6 @@ export class TaobaoService { return this.http .jsonp(`https://suggest.taobao.com/sug?${params.toString()}`, 'JSONP_CALLBACK') - .pipe( - map((response: any) => response.result.map((d: any[]) => d[0]).slice(0, 5)), - ); + .pipe(map((response: any) => response.result.map((d: any[]) => d[0]).slice(0, 5))); } } diff --git a/src/app/example/sidebar/sidebar.component.html b/src/app/example/sidebar/sidebar.component.html index d8b7879..699f72c 100644 --- a/src/app/example/sidebar/sidebar.component.html +++ b/src/app/example/sidebar/sidebar.component.html @@ -1,42 +1,38 @@ - -
-

这是侧边栏内容

- 关闭 - 使用指令[closeSidebar]关闭 -
-
- - - 打开 -
- Mode: - Over - Slide -
-
- Position: - Left - Right - Top - Bottom -
-
- 点击背景关闭: - 允许 - 禁止 -
- -
+ +
+

这是侧边栏内容

+ 关闭 + 使用指令[closeSidebar]关闭 +
+
+ + 打开 +
+ Mode: + Over + Slide +
+
+ Position: + Left + Right + Top + Bottom +
+
+ 点击背景关闭: + 允许 + 禁止 +
+
diff --git a/src/app/example/sidebar/sidebar.component.ts b/src/app/example/sidebar/sidebar.component.ts index 5878d9a..6a0fdc4 100644 --- a/src/app/example/sidebar/sidebar.component.ts +++ b/src/app/example/sidebar/sidebar.component.ts @@ -1,36 +1,34 @@ -import { Component, ViewEncapsulation, ViewChild } from '@angular/core'; - -import { SidebarComponent } from "ngx-weui/sidebar"; +import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-sidebar', - templateUrl: './sidebar.component.html', - styleUrls: ['./sidebar.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-sidebar', + templateUrl: './sidebar.component.html', + styleUrls: ['./sidebar.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoSidebarComponent { - _status: boolean = false; - mode: string = 'slide'; - position: string = 'left'; - backdrop: boolean = true; + _status: boolean = false; + mode: string = 'slide'; + position: string = 'left'; + backdrop: boolean = true; - toggleOpened(): void { - this._status = !this._status; - } + toggleOpened(): void { + this._status = !this._status; + } - openStart() { - console.log('openStart'); - } + openStart() { + console.log('openStart'); + } - opened() { - console.log('opened'); - } + opened() { + console.log('opened'); + } - closeStart() { - console.log('closeStart'); - } + closeStart() { + console.log('closeStart'); + } - closed() { - console.log('closed'); - } + closed() { + console.log('closed'); + } } diff --git a/src/app/example/slider/slider.component.html b/src/app/example/slider/slider.component.html index 6d6c7d3..6b52067 100644 --- a/src/app/example/slider/slider.component.html +++ b/src/app/example/slider/slider.component.html @@ -1,28 +1,21 @@ +

res1: {{ res1 }}

+ +
+ + -

res1: {{res1}}

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{{res2}}
-
- -
- -
- +
+ +
diff --git a/src/app/example/slider/slider.component.ts b/src/app/example/slider/slider.component.ts index 6e476a6..ccf4d2e 100644 --- a/src/app/example/slider/slider.component.ts +++ b/src/app/example/slider/slider.component.ts @@ -1,18 +1,18 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-slider', - templateUrl: './slider.component.html', - styleUrls: [ './slider.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-slider', + templateUrl: './slider.component.html', + styleUrls: ['./slider.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class SliderComponent { - res1: number = 0; - res2: number = 10; + res1: number = 0; + res2: number = 10; - switchState: boolean = true; + switchState: boolean = true; - onChange(value: any) { - console.log('new', value) - } + onChange(value: any) { + console.log('new', value); + } } diff --git a/src/app/example/stepper/stepper.component.html b/src/app/example/stepper/stepper.component.html index 8e21839..1a1d17a 100644 --- a/src/app/example/stepper/stepper.component.html +++ b/src/app/example/stepper/stepper.component.html @@ -1,29 +1,29 @@ -
Demos
-
-
-
-

很长的标题,真的,不骗人,就是很长。很长的标题,真的,不骗人,就是很长。【{{val1}}】

-
-
- -
-
-
-
-

精度为.1【{{val2}}】

-
-
- -
-
-
-
-

Disabled【{{val3}}】

-
-
- -
-
+
Demos
+
+
+
+

很长的标题,真的,不骗人,就是很长。很长的标题,真的,不骗人,就是很长。【{{ val1 }}】

+
+
+ +
+
+
+

精度为.1【{{ val2 }}】

+
+
+ +
+
+
+
+

Disabled【{{ val3 }}】

+
+
+ +
+
+
diff --git a/src/app/example/stepper/stepper.component.ts b/src/app/example/stepper/stepper.component.ts index 674847a..6bcecf7 100644 --- a/src/app/example/stepper/stepper.component.ts +++ b/src/app/example/stepper/stepper.component.ts @@ -1,13 +1,13 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-stepper', - templateUrl: './stepper.component.html', - styleUrls: ['./stepper.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-stepper', + templateUrl: './stepper.component.html', + styleUrls: ['./stepper.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoStepperComponent { - val1: number = 1; - val2: number = 1; - val3: number = 1; + val1: number = 1; + val2: number = 1; + val3: number = 1; } diff --git a/src/app/example/swiper/swiper.component.html b/src/app/example/swiper/swiper.component.html index 2b437bc..d75c673 100644 --- a/src/app/example/swiper/swiper.component.html +++ b/src/app/example/swiper/swiper.component.html @@ -1,34 +1,27 @@ - - -

log: {{log}}

- - -
- -
-
- Slide {{i}} -
-
- -
+ +

log: {{ log }}

+ + +
+ +
+
Slide {{ i }}
+
+ +
+
+
+

渐变效果

+ +
+ +
+
+
- -

渐变效果

- -
- -
-
- -
-
- -
-
-
- +
+ +
+
+
diff --git a/src/app/example/swiper/swiper.component.scss b/src/app/example/swiper/swiper.component.scss index b1aaff6..104e87e 100644 --- a/src/app/example/swiper/swiper.component.scss +++ b/src/app/example/swiper/swiper.component.scss @@ -1,7 +1,7 @@ .swiper-slide { - width: 100%; - height: 200px; - line-height: 200px; - text-align: center; - background: #fff; + width: 100%; + height: 200px; + line-height: 200px; + text-align: center; + background: #fff; } diff --git a/src/app/example/swiper/swiper.component.ts b/src/app/example/swiper/swiper.component.ts index f951043..0458914 100644 --- a/src/app/example/swiper/swiper.component.ts +++ b/src/app/example/swiper/swiper.component.ts @@ -1,24 +1,28 @@ import { Component, ViewEncapsulation } from '@angular/core'; @Component({ - selector: 'example-swiper', - templateUrl: './swiper.component.html', - styleUrls: ['./swiper.component.scss'], - encapsulation: ViewEncapsulation.None + selector: 'example-swiper', + templateUrl: './swiper.component.html', + styleUrls: ['./swiper.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoSwiperComponent { - log: string = ''; - options: any = { - onInit: () => { - setTimeout(() => { this.log = '初始化完成'; }); - }, - onSlideChangeEnd: (swiper: any) => { - setTimeout(() => { this.log = `移动至第 ${swiper.realIndex + 1} 张`; }); - } - }; - images: any[] = [ - { url: './assets/images/swiper-1.png', title: '标题1' }, - { url: './assets/images/swiper-2.png', title: '标题2' }, - { url: './assets/images/swiper-3.png', title: '标题3' } - ]; -} + log: string = ''; + options: any = { + onInit: () => { + setTimeout(() => { + this.log = '初始化完成'; + }); + }, + onSlideChangeEnd: (swiper: any) => { + setTimeout(() => { + this.log = `移动至第 ${swiper.realIndex + 1} 张`; + }); + }, + }; + images: any[] = [ + { url: './assets/images/swiper-1.png', title: '标题1' }, + { url: './assets/images/swiper-2.png', title: '标题2' }, + { url: './assets/images/swiper-3.png', title: '标题3' }, + ]; +} diff --git a/src/app/example/tabbar/tabbar.component.scss b/src/app/example/tabbar/tabbar.component.scss index 69b8cb4..b5e8b24 100644 --- a/src/app/example/tabbar/tabbar.component.scss +++ b/src/app/example/tabbar/tabbar.component.scss @@ -1,4 +1,8 @@ -html, body, app-root, example-tarbar, example-layout { - height: 100%; - display: block; +html, +body, +app-root, +example-tarbar, +example-layout { + display: block; + height: 100%; } diff --git a/src/app/example/tabbar/tabbar.component.ts b/src/app/example/tabbar/tabbar.component.ts index 908e632..45e5fd5 100644 --- a/src/app/example/tabbar/tabbar.component.ts +++ b/src/app/example/tabbar/tabbar.component.ts @@ -1,6 +1,6 @@ import { Component, ViewEncapsulation } from '@angular/core'; -import { timer } from 'rxjs'; import { InfiniteLoaderComponent } from 'ngx-weui/infiniteloader'; +import { timer } from 'rxjs'; @Component({ selector: 'example-tabbar', @@ -14,7 +14,9 @@ export class DemoTabbarComponent { this.time = new Date().getTime(); } - items: any[] = Array(20).fill(0).map((v: any, i: number) => i); + items: any[] = Array(20) + .fill(0) + .map((_v: any, i: number) => i); onLoadMore(comp: InfiniteLoaderComponent) { timer(1500).subscribe(() => { this.items.push( diff --git a/src/app/example/toast/toast.component.html b/src/app/example/toast/toast.component.html index cc81009..e427c16 100644 --- a/src/app/example/toast/toast.component.html +++ b/src/app/example/toast/toast.component.html @@ -1,17 +1,13 @@ - - -
使用组件形式
- - -
使用Service形式
- - - - - - - + +
使用组件形式
+ + +
使用Service形式
+ + + + + +
diff --git a/src/app/example/toast/toast.component.ts b/src/app/example/toast/toast.component.ts index ba59c4d..910978f 100644 --- a/src/app/example/toast/toast.component.ts +++ b/src/app/example/toast/toast.component.ts @@ -1,30 +1,28 @@ import { Component, ViewEncapsulation, ViewChild } from '@angular/core'; -import { ToastComponent, ToastService } from "ngx-weui/toast"; +import { ToastComponent, ToastService } from 'ngx-weui/toast'; @Component({ - selector: 'example-toast', - templateUrl: './toast.component.html', - styleUrls: [ './toast.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-toast', + templateUrl: './toast.component.html', + styleUrls: ['./toast.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoToastComponent { + @ViewChild('success') successToast: ToastComponent; + @ViewChild('loading') loadingToast: ToastComponent; + constructor(private srv: ToastService) {} - @ViewChild('success') successToast: ToastComponent; - @ViewChild('loading') loadingToast: ToastComponent; - constructor(private srv: ToastService) { } + onShow(type: 'success' | 'loading') { + (this[`${type}Toast`]).onShow(); + } - onShow(type: 'success' | 'loading') { - (this[`${type}Toast`]).onShow(); + onShowBySrv(type: 'success' | 'loading', forceHide: boolean = false) { + this.srv[type](); + if (forceHide === true) { + setTimeout(() => { + this.srv.hide(); + }, 1000); } - - onShowBySrv(type: 'success' | 'loading', forceHide: boolean = false) { - this.srv[type](); - if (forceHide === true) { - setTimeout(() => { - this.srv.hide(); - }, 1000) - } - } - + } } diff --git a/src/app/example/toptips/toptips.component.html b/src/app/example/toptips/toptips.component.html index 6e53ea8..0f21d8f 100644 --- a/src/app/example/toptips/toptips.component.html +++ b/src/app/example/toptips/toptips.component.html @@ -1,19 +1,15 @@ - - -
使用组件形式
- - - -
使用Service形式
- - - - - - - - + +
使用组件形式
+ + + +
使用Service形式
+ + + + + + +
diff --git a/src/app/example/toptips/toptips.component.ts b/src/app/example/toptips/toptips.component.ts index 5c6dc7a..98113d0 100644 --- a/src/app/example/toptips/toptips.component.ts +++ b/src/app/example/toptips/toptips.component.ts @@ -1,36 +1,36 @@ -import { Component, ViewEncapsulation, ViewChild } from '@angular/core'; +import { Component, ViewChild, ViewEncapsulation } from '@angular/core'; -import { ToptipsComponent, ToptipsService } from "ngx-weui/toptips"; +import { ToptipsComponent, ToptipsService, ToptipsType } from 'ngx-weui/toptips'; @Component({ - selector: 'example-toptips', - templateUrl: './toptips.component.html', - styleUrls: [ './toptips.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-toptips', + templateUrl: './toptips.component.html', + styleUrls: ['./toptips.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoToptipsComponent { + @ViewChild('toptips') toptips: ToptipsComponent; + text = ''; + type: ToptipsType; + constructor(private srv: ToptipsService) {} - @ViewChild('toptips') toptips: ToptipsComponent; - constructor(private srv: ToptipsService) { } - - onShow(type: 'warn' | 'info' | 'primary') { - this.toptips.type = type; - switch (type) { - case 'warn': - this.toptips.text = ' Oops, something is wrong! '; - break; - case 'primary': - this.toptips.text = ' Success submited! '; - break; - case 'info': - this.toptips.text = ' Thanks for coming! '; - break; - } - this.toptips.onShow(); - } - - onShowBySrv(type: 'warn' | 'info' | 'primary' | 'success' | 'default') { - this.srv[type]('这是一段文字'); + onShow(type: ToptipsType) { + this.type = type; + switch (type) { + case 'warn': + this.text = ' Oops, something is wrong! '; + break; + case 'primary': + this.text = ' Success submited! '; + break; + case 'info': + this.text = ' Thanks for coming! '; + break; } + this.toptips.onShow(); + } + onShowBySrv(type: 'warn' | 'info' | 'primary' | 'success' | 'default') { + this.srv[type]('这是一段文字'); + } } diff --git a/src/app/example/uploader/uploader.component.html b/src/app/example/uploader/uploader.component.html index 4b79ed0..475dbdb 100644 --- a/src/app/example/uploader/uploader.component.html +++ b/src/app/example/uploader/uploader.component.html @@ -1,37 +1,49 @@ - - -
-
-
-
-
-

图片上传

-
{{uploader?.uploadedCount}}/{{uploader?.queue?.length}}
-
-
-
    -
  • -
    {{item.progress}}%
    -
    - -
    -
  • -
-
- -
-
+ +
+
+
+
+
+

图片上传

+
{{ uploader?.uploadedCount }}/{{ uploader?.queue?.length }}
+
+
+
    +
  • +
    {{ item.progress }}%
    +
    +
    - +
  • +
+
+
+
+ +
-
- -
- +
+
+ +
diff --git a/src/app/example/uploader/uploader.component.ts b/src/app/example/uploader/uploader.component.ts index ad90153..e0f9390 100644 --- a/src/app/example/uploader/uploader.component.ts +++ b/src/app/example/uploader/uploader.component.ts @@ -1,85 +1,83 @@ -import { Component, ViewEncapsulation, ViewChild, Input } from '@angular/core'; -import { UploaderOptions, FileItem, Uploader, UploaderHeaders } from 'ngx-weui'; +import { Component, Input, ViewEncapsulation } from '@angular/core'; +import { Uploader, UploaderOptions } from 'ngx-weui'; @Component({ - selector: 'example-uploader', - templateUrl: './uploader.component.html', - styleUrls: [ './uploader.component.scss' ], - encapsulation: ViewEncapsulation.None + selector: 'example-uploader', + templateUrl: './uploader.component.html', + styleUrls: ['./uploader.component.scss'], + encapsulation: ViewEncapsulation.None, }) export class DemoUploaderComponent { - subTitle: string = ` + subTitle: string = ` 上传组件,一般配合组件Gallery来使用。`; - @Input() url: string = 'example'; + @Input() url: string = 'example'; - uploader: Uploader = new Uploader({ - url: './upload.php', - headers: [ - { name: 'auth', value: 'test' } - ], - params: { - a: 1, - b: new Date(), - c: 'test', - d: 12.123 - }, - // 自定义transport - // uploadTransport: function(item: FileItem) { - // return Observable.create(observer => { - // setTimeout(() => { - // observer.next(true); - // observer.complete(); - // }, 1000 * 3); - // }); - // }, - onFileQueued: function() { - console.log('onFileQueued', arguments); - }, - onFileDequeued: function() { - console.log('onFileDequeued', arguments); - }, - onStart: function() { - console.log('onStart', arguments); - }, - onCancel: function() { - console.log('onCancel', arguments); - }, - onFinished: function() { - console.log('onFinished', arguments); - }, - onUploadStart: function() { - console.log('onUploadStart', arguments); - }, - onUploadProgress: function() { - console.log('onUploadProgress', arguments); - }, - onUploadSuccess: function() { - console.log('onUploadSuccess', arguments); - }, - onUploadError: function() { - console.log('onUploadError', arguments); - }, - onUploadComplete: function() { - console.log('onUploadComplete', arguments); - }, - onUploadCancel: function() { - console.log('onUploadCancel', arguments); - }, - onError: function() { - console.log('onError', arguments); - } - }); + uploader: Uploader = new Uploader({ + url: './upload.php', + headers: [{ name: 'auth', value: 'test' }], + params: { + a: 1, + b: new Date(), + c: 'test', + d: 12.123, + }, + // 自定义transport + // uploadTransport: function(item: FileItem) { + // return Observable.create(observer => { + // setTimeout(() => { + // observer.next(true); + // observer.complete(); + // }, 1000 * 3); + // }); + // }, + onFileQueued() { + console.log('onFileQueued', arguments); + }, + onFileDequeued() { + console.log('onFileDequeued', arguments); + }, + onStart() { + console.log('onStart', arguments); + }, + onCancel() { + console.log('onCancel', arguments); + }, + onFinished() { + console.log('onFinished', arguments); + }, + onUploadStart() { + console.log('onUploadStart', arguments); + }, + onUploadProgress() { + console.log('onUploadProgress', arguments); + }, + onUploadSuccess() { + console.log('onUploadSuccess', arguments); + }, + onUploadError() { + console.log('onUploadError', arguments); + }, + onUploadComplete() { + console.log('onUploadComplete', arguments); + }, + onUploadCancel() { + console.log('onUploadCancel', arguments); + }, + onError() { + console.log('onError', arguments); + }, + } as UploaderOptions); - img: any; - imgShow: boolean = false; - onGallery(item: any) { - this.img = [{ file: item._file, item: item }]; - this.imgShow = true; - } + img: any; + imgShow: boolean = false; + onGallery(item: any) { + this.img = [{ file: item._file, item }]; + this.imgShow = true; + } - onDel(item: any) { - console.log(item); - this.uploader.removeFromQueue(item.item); - } + onDel(item: any) { + console.log(item); + this.uploader.removeFromQueue(item.item); + } } diff --git a/src/app/layout/default/default.component.html b/src/app/layout/default/default.component.html index ca0ce4a..878d05d 100644 --- a/src/app/layout/default/default.component.html +++ b/src/app/layout/default/default.component.html @@ -1,20 +1,21 @@ -
- - +
diff --git a/src/app/layout/default/default.component.ts b/src/app/layout/default/default.component.ts index d586f7b..478a5dd 100644 --- a/src/app/layout/default/default.component.ts +++ b/src/app/layout/default/default.component.ts @@ -1,45 +1,44 @@ -import { Router, ActivatedRoute, NavigationEnd, RouteConfigLoadStart } from '@angular/router'; import { Component, OnInit } from '@angular/core'; +import { NavigationEnd, Router, RouteConfigLoadStart } from '@angular/router'; import { MenuService } from '../../core/menu.service'; @Component({ - selector: 'app-layout-default', - templateUrl: './default.component.html', - host: { - '[class.App]': 'true' - } + selector: 'app-layout-default', + templateUrl: './default.component.html', + host: { + '[class.App]': 'true', + }, }) export class AppLayoutComponent implements OnInit { + locale: string = 'en-US'; + isFetching = false; - locale: string = 'en-US'; - isFetching = false; - - constructor(public menuService: MenuService, - private route: ActivatedRoute, - private router: Router) { } + constructor(public menuService: MenuService, private router: Router) {} - ngOnInit() { - if (typeof (Storage) !== 'undefined') { - const val = localStorage.getItem('angular-weuidoc-lang'); - this.locale = val ? val : this.locale; - } - this.router.events - .subscribe(e => { - if (!this.isFetching && e instanceof RouteConfigLoadStart) { - this.isFetching = true; - } - if (e instanceof NavigationEnd) { - this.isFetching = false; - this.showNav(e.urlAfterRedirects); - } - }); - this.showNav(this.router.url); + ngOnInit() { + if (typeof Storage !== 'undefined') { + const val = localStorage.getItem('angular-weuidoc-lang'); + this.locale = val ? val : this.locale; } + this.router.events.subscribe(e => { + if (!this.isFetching && e instanceof RouteConfigLoadStart) { + this.isFetching = true; + } + if (e instanceof NavigationEnd) { + this.isFetching = false; + this.showNav(e.urlAfterRedirects); + } + }); + this.showNav(this.router.url); + } - needNav: boolean = false; - private showNav(url: string) { - const key = url.split('?')[0].split('/').filter(w => !!w)[0]; - this.needNav = [ 'components', 'docs' ].includes(key); - } + needNav: boolean = false; + private showNav(url: string) { + const key = url + .split('?')[0] + .split('/') + .filter(w => !!w)[0]; + this.needNav = ['components', 'docs'].includes(key); + } } diff --git a/src/app/layout/layout.module.ts b/src/app/layout/layout.module.ts index 7b5419c..041fba5 100644 --- a/src/app/layout/layout.module.ts +++ b/src/app/layout/layout.module.ts @@ -3,18 +3,12 @@ import { NgModule } from '@angular/core'; import { SharedModule } from '../shared/shared.module'; import { AppLayoutComponent } from './default/default.component'; -const COMPONENTS = [ - AppLayoutComponent -]; +const COMPONENTS = [AppLayoutComponent]; @NgModule({ - imports: [SharedModule], - providers: [], - declarations: [ - ...COMPONENTS - ], - exports: [ - ...COMPONENTS - ] + imports: [SharedModule], + providers: [], + declarations: [...COMPONENTS], + exports: [...COMPONENTS], }) -export class LayoutModule { } +export class LayoutModule {} diff --git a/src/app/routes/components/article/article.component.html b/src/app/routes/components/article/article.component.html index b4e95a5..e0f73b5 100644 --- a/src/app/routes/components/article/article.component.html +++ b/src/app/routes/components/article/article.component.html @@ -8,41 +8,44 @@
- - -
-

- {{item.meta.title}} - {{item.meta.subtitle}} - -

-
- -

引用方式:

-
import { {{item.meta.module}} } from 'ngx-weui';
-

- 模块允许对{{item.meta.config}}全局配置。 -

-
-
-
-
- -
- - -
-
- -
-
- -
-
-
-
-
-
+ + +
+

+ {{ item.meta.title }} + {{ item.meta.subtitle }} + +

+
+ +

引用方式:

+
import { {{item.meta.module}} } from 'ngx-weui';
+

+ 模块允许对{{ item.meta.config }}全局配置。 +

+
+
+
+
+ +
+ + +
+
+ +
+
+ +
+
+
+
+
+
diff --git a/src/app/routes/components/article/article.component.ts b/src/app/routes/components/article/article.component.ts index 2de726c..27312ba 100644 --- a/src/app/routes/components/article/article.component.ts +++ b/src/app/routes/components/article/article.component.ts @@ -1,68 +1,71 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { MenuService } from '../../../core/menu.service'; -import { META } from '../meta'; import { EXAMPLE } from '../examples'; +import { META } from '../meta'; @Component({ - selector: 'app-article', - templateUrl: './article.component.html', - styles: [ - `:host { display: block; height: 100%; }` - ] + selector: 'app-article', + templateUrl: './article.component.html', + styles: [ + ` + :host { + display: block; + height: 100%; + } + `, + ], }) export class ArticleComponent implements OnInit { + menu: any; + item: any; - menu: any; - item: any; - - private genData(id: string) { - const menu = { ...this.menuService.getItems('components').find(w => w.name.toLowerCase() === id) }; - this.menu = Object.assign({ - id: menu.example || menu.name.toLowerCase() - }, menu); - if (!this.menu.id) { - this.router.navigateByUrl('/'); - return ; - } - this.item = Object.assign({ - name: this.menu.id, - data: {}, - meta: { - title: this.menu.name, - subtitle: '' - } - }, META.find(w => w.name === (this.menu.api || id))); - - // examples - const example = EXAMPLE[menu.example || this.menu.id]; - if (!!example) this.item.demo = example; - this.initHLJS(); + private genData(id: string) { + const menu = { ...this.menuService.getItems('components').find(w => w.name.toLowerCase() === id) }; + this.menu = { + id: menu.example || menu.name.toLowerCase(), + ...menu, + }; + if (!this.menu.id) { + this.router.navigateByUrl('/'); + return; } + this.item = { + name: this.menu.id, + data: {}, + meta: { + title: this.menu.name, + subtitle: '', + }, + ...META.find(w => w.name === (this.menu.api || id)), + }; - constructor( - private router: Router, - route: ActivatedRoute, - private menuService: MenuService - ) { - route.params.subscribe(params => this.genData('' + params['id'])); - } + // examples + const example = EXAMPLE[menu.example || this.menu.id]; + if (!!example) this.item.demo = example; + this.initHLJS(); + } - ngOnInit(): void { - this.initHLJS(); - } + constructor(private router: Router, route: ActivatedRoute, private menuService: MenuService) { + route.params.subscribe(params => this.genData('' + params.id)); + } - private initHLJS() { - setTimeout(() => { - const elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'); - for (let i = 0, element; element = elements[i++];) { - hljs.highlightBlock(element); - } - }, 250); - } + ngOnInit(): void { + this.initHLJS(); + } - changeCode() { - // this.initHLJS(); - } + private initHLJS() { + setTimeout(() => { + const elements = document.querySelectorAll( + 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code', + ); + for (let i = 0, element; (element = elements[i++]); ) { + hljs.highlightBlock(element); + } + }, 250); + } + changeCode() { + // this.initHLJS(); + } } diff --git a/src/app/routes/components/components.module.ts b/src/app/routes/components/components.module.ts index a83e1f8..02ec9a1 100644 --- a/src/app/routes/components/components.module.ts +++ b/src/app/routes/components/components.module.ts @@ -7,25 +7,18 @@ import { ExampleCoreModule } from '../../example/example.module'; // region: components -const COMPONENTS = [ ArticleComponent ]; +const COMPONENTS = [ArticleComponent]; -const routes: Routes = [ - { path: '', redirectTo: 'button' }, - { path: ':id', component: ArticleComponent }, -]; +const routes: Routes = [{ path: '', redirectTo: 'button' }, { path: ':id', component: ArticleComponent }]; // endregion @NgModule({ - imports: [ - SharedModule, - // AngularSplitModule, - ExampleCoreModule, - RouterModule.forChild(routes) - ], - declarations: [ - ...COMPONENTS - ] + imports: [ + SharedModule, + // AngularSplitModule, + ExampleCoreModule, + RouterModule.forChild(routes), + ], + declarations: [...COMPONENTS], }) -export class ComponentsModule { - -} +export class ComponentsModule {} diff --git a/src/app/routes/docs/article/article.component.html b/src/app/routes/docs/article/article.component.html index 9a4e6f2..f613579 100644 --- a/src/app/routes/docs/article/article.component.html +++ b/src/app/routes/docs/article/article.component.html @@ -1,8 +1,8 @@
-

- {{item.meta.title}} - {{item.meta.subtitle}} - -

-
+

+ {{ item.meta.title }} + {{ item.meta.subtitle }} + +

+
diff --git a/src/app/routes/docs/article/article.component.ts b/src/app/routes/docs/article/article.component.ts index 78a56af..381f412 100644 --- a/src/app/routes/docs/article/article.component.ts +++ b/src/app/routes/docs/article/article.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { META } from '../meta'; @@ -6,11 +6,13 @@ import { META } from '../meta'; selector: 'app-docs-article', templateUrl: './article.component.html', styles: [ - `:host { - display: block; - overflow-y: auto; - height: 100%; - }`, + ` + :host { + display: block; + overflow-y: auto; + height: 100%; + } + `, ], }) export class DocsArticleComponent implements OnInit { @@ -22,12 +24,12 @@ export class DocsArticleComponent implements OnInit { this.router.navigateByUrl('/'); return; } - this.item = Object.assign({}, item); + this.item = { ...item }; this.initHLJS(); } constructor(private router: Router, route: ActivatedRoute) { - route.params.subscribe(params => this.genData('' + params['id'])); + route.params.subscribe(params => this.genData('' + params.id)); } ngOnInit(): void { @@ -39,6 +41,7 @@ export class DocsArticleComponent implements OnInit { const elements = document.querySelectorAll( 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code', ); + // tslint:disable-next-line: no-conditional-assignment for (let i = 0, element; (element = elements[i++]); ) { hljs.highlightBlock(element); } diff --git a/src/app/routes/docs/docs.module.ts b/src/app/routes/docs/docs.module.ts index 695cf33..dfe4a7b 100644 --- a/src/app/routes/docs/docs.module.ts +++ b/src/app/routes/docs/docs.module.ts @@ -5,23 +5,13 @@ import { DocsArticleComponent } from './article/article.component'; // region: components -const COMPONENTS = [ DocsArticleComponent ]; +const COMPONENTS = [DocsArticleComponent]; -const routes: Routes = [ - { path: '', redirectTo: 'how' }, - { path: ':id', component: DocsArticleComponent }, -]; +const routes: Routes = [{ path: '', redirectTo: 'how' }, { path: ':id', component: DocsArticleComponent }]; // endregion @NgModule({ - imports: [ - SharedModule, - RouterModule.forChild(routes) - ], - declarations: [ - ...COMPONENTS - ] + imports: [SharedModule, RouterModule.forChild(routes)], + declarations: [...COMPONENTS], }) -export class DocsModule { - -} +export class DocsModule {} diff --git a/src/app/routes/example/container/container.component.ts b/src/app/routes/example/container/container.component.ts index 5dd9fb5..88f2e60 100644 --- a/src/app/routes/example/container/container.component.ts +++ b/src/app/routes/example/container/container.component.ts @@ -1,18 +1,20 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; import { MenuService } from '../home/menu.service'; @Component({ - selector: 'example-container', - template: `` + selector: 'example-container', + template: ` + + `, }) export class ExampleContainerComponent implements OnInit { - constructor(private route: ActivatedRoute, private router: Router, private menuService: MenuService) {} + constructor(private route: ActivatedRoute, private menuService: MenuService) {} - menu: any; - ngOnInit() { - this.route.params.subscribe(params => { - this.menu = this.menuService.getMenu(params['id']); - }); - } + menu: any; + ngOnInit() { + this.route.params.subscribe(params => { + this.menu = this.menuService.getMenu(params.id); + }); + } } diff --git a/src/app/routes/example/example.module.ts b/src/app/routes/example/example.module.ts index 5e010c4..a82b36f 100644 --- a/src/app/routes/example/example.module.ts +++ b/src/app/routes/example/example.module.ts @@ -1,25 +1,18 @@ import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; +import { RouterModule } from '@angular/router'; -import { SharedModule } from '../../shared/shared.module'; import { ExampleCoreModule } from '../../example/example.module'; +import { SharedModule } from '../../shared/shared.module'; -import { MenuService } from './home/menu.service'; -import { HomeComponent } from './home/home.component'; import { ExampleContainerComponent } from './container/container.component'; +import { HomeComponent } from './home/home.component'; +import { MenuService } from './home/menu.service'; -export const routes = [ - { path: '', component: HomeComponent }, - { path: ':id', component: ExampleContainerComponent } -]; +export const routes = [{ path: '', component: HomeComponent }, { path: ':id', component: ExampleContainerComponent }]; @NgModule({ - imports: [ - SharedModule, - ExampleCoreModule, - RouterModule.forChild(routes) - ], - declarations: [ HomeComponent, ExampleContainerComponent ], - providers: [ MenuService ] + imports: [SharedModule, ExampleCoreModule, RouterModule.forChild(routes)], + declarations: [HomeComponent, ExampleContainerComponent], + providers: [MenuService], }) export class ExampleModule {} diff --git a/src/app/routes/example/home/home.component.html b/src/app/routes/example/home/home.component.html index 9fafaec..1795c04 100644 --- a/src/app/routes/example/home/home.component.html +++ b/src/app/routes/example/home/home.component.html @@ -1,25 +1,26 @@ - - - - -
-

{{i.name}}

- + + + +
+

{{ i.name }}

+ +
+ +
+
diff --git a/src/app/routes/example/home/home.component.ts b/src/app/routes/example/home/home.component.ts index ecee15e..da14600 100644 --- a/src/app/routes/example/home/home.component.ts +++ b/src/app/routes/example/home/home.component.ts @@ -2,17 +2,17 @@ import { Component } from '@angular/core'; import { MenuService } from './menu.service'; @Component({ - selector: 'example-home', - templateUrl: './home.component.html' + selector: 'example-home', + templateUrl: './home.component.html', }) export class HomeComponent { - title: string = `weui`; + title: string = `weui`; - constructor(public menuService: MenuService) {} + constructor(public menuService: MenuService) {} - onSelecte(index: number) { - this.menuService.menus.forEach((item, idx) => { - item.show = idx === index; - }); - } + onSelecte(index: number) { + this.menuService.menus.forEach((item, idx) => { + item.show = idx === index; + }); + } } diff --git a/src/app/routes/example/home/menu.service.ts b/src/app/routes/example/home/menu.service.ts index 04a5834..5a38c04 100644 --- a/src/app/routes/example/home/menu.service.ts +++ b/src/app/routes/example/home/menu.service.ts @@ -2,247 +2,246 @@ import { Injectable } from '@angular/core'; @Injectable() export class MenuService { + menus: any[] = [ + { + name: '布局 Layout', + icon: 'icon_nav_form', + show: false, + items: [ + { + label: 'Flex', + id: 'flex', + }, + { + label: 'Grid', + id: 'grid', + }, + { + label: 'Article', + id: 'article', + }, + { + label: 'Footer', + id: 'footer', + }, + { + label: 'Preview', + id: 'preview', + }, + { + label: 'Panel', + id: 'panel', + }, + ], + }, + { + name: '导航 Navigation', + icon: 'icon_nav_nav', + show: false, + items: [ + { + label: 'Navbar', + id: 'navbar', + }, + { + label: 'Tabbar', + id: 'tabbar', + }, + { + label: 'Sidebar', + id: 'sidebar', + }, + { + label: 'Popup', + id: 'popup', + }, + { + label: 'Pagination 分页器', + id: 'pagination', + }, + ], + }, + { + name: '数据录入 Data Entry', + icon: 'icon_nav_form', + show: false, + items: [ + { + label: 'Button', + id: 'button', + }, + { + label: 'Input', + id: 'input', + }, + { + label: 'Slider', + id: 'slider', + }, + { + label: 'Picker', + id: 'picker', + }, + { + label: 'Uploader', + id: 'uploader', + }, + { + label: 'Rating', + id: 'rating', + }, + { + label: 'Loadmore', + id: 'loadmore', + }, + { + label: 'Progress', + id: 'progress', + }, + { + label: 'Stepper 步进器', + id: 'stepper', + }, + ], + }, + { + name: '数据展示 Data Display', + icon: 'icon_nav_form', + show: false, + items: [ + { + label: 'Accordion', + id: 'accordion', + }, + { + label: 'Badge', + id: 'badge', + }, + { + label: 'Icons', + id: 'icons', + }, + { + label: 'List', + id: 'list', + }, + { + label: 'Gallery', + id: 'gallery', + }, + { + label: 'Swiper', + id: 'swiper', + }, + ], + }, + { + name: '操作反馈 Feedback', + icon: 'icon_nav_feedback', + show: false, + items: [ + { + label: 'Actionsheet', + id: 'actionsheet', + }, + { + label: 'Dialog', + id: 'dialog', + }, + { + label: 'Msg', + id: 'msg', + }, + { + label: 'Msg', + id: 'msg_fail', + show: false, + }, + { + label: 'Msg', + id: 'msg_success', + show: false, + }, + { + label: 'Toast', + id: 'toast', + }, + { + label: 'Toptips', + id: 'toptips', + }, + ], + }, + { + name: '手势 Gesture', + icon: 'icon_nav_feedback', + show: false, + items: [ + { + label: 'Pull To Refresh', + id: 'ptr', + }, + { + label: 'Infinite Loader', + id: 'infiniteloader', + }, + ], + }, + { + name: '组合组件 Combination', + icon: 'icon_nav_search', + show: false, + items: [ + { + label: 'Search Bar', + id: 'searchbar', + }, + ], + }, + { + name: '其他 Other', + icon: 'icon_nav_layout', + show: false, + items: [ + { + label: '微信JS-SDK', + id: 'jweixin', + }, + { + label: 'Mask', + id: 'mask', + }, + ], + }, + { + name: 'Third Party', + icon: 'icon_nav_layout', + show: false, + items: [ + { + label: 'Chart G2-Mobile', + id: 'chart-g2', + }, + { + label: 'Countdown', + id: 'countdown', + }, + { + label: 'Gesture Password', + id: 'gesture-password', + }, + { + label: 'QQ Map', + id: 'map-qq', + }, + ], + }, + ]; - menus: any[] = [ - { - name: '布局 Layout', - icon: 'icon_nav_form', - show: false, - items: [ - { - label: 'Flex', - id: 'flex' - }, - { - label: 'Grid', - id: 'grid' - }, - { - label: 'Article', - id: 'article' - }, - { - label: 'Footer', - id: 'footer' - }, - { - label: 'Preview', - id: 'preview' - }, - { - label: 'Panel', - id: 'panel' - } - ] - }, - { - name: '导航 Navigation', - icon: 'icon_nav_nav', - show: false, - items: [ - { - label: 'Navbar', - id: 'navbar' - }, - { - label: 'Tabbar', - id: 'tabbar' - }, - { - label: 'Sidebar', - id: 'sidebar' - }, - { - label: 'Popup', - id: 'popup' - }, - { - label: 'Pagination 分页器', - id: 'pagination' - } - ] - }, - { - name: '数据录入 Data Entry', - icon: 'icon_nav_form', - show: false, - items: [ - { - label: 'Button', - id: 'button' - }, - { - label: 'Input', - id: 'input' - }, - { - label: 'Slider', - id: 'slider' - }, - { - label: 'Picker', - id: 'picker' - }, - { - label: 'Uploader', - id: 'uploader' - }, - { - label: 'Rating', - id: 'rating' - }, - { - label: 'Loadmore', - id: 'loadmore' - }, - { - label: 'Progress', - id: 'progress' - }, - { - label: 'Stepper 步进器', - id: 'stepper' - } - ] - }, - { - name: '数据展示 Data Display', - icon: 'icon_nav_form', - show: false, - items: [ - { - label: 'Accordion', - id: 'accordion' - }, - { - label: 'Badge', - id: 'badge' - }, - { - label: 'Icons', - id: 'icons' - }, - { - label: 'List', - id: 'list' - }, - { - label: 'Gallery', - id: 'gallery' - }, - { - label: 'Swiper', - id: 'swiper' - } - ] - }, - { - name: '操作反馈 Feedback', - icon: 'icon_nav_feedback', - show: false, - items: [ - { - label: 'Actionsheet', - id: 'actionsheet' - }, - { - label: 'Dialog', - id: 'dialog' - }, - { - label: 'Msg', - id: 'msg' - }, - { - label: 'Msg', - id: 'msg_fail', - show: false - }, - { - label: 'Msg', - id: 'msg_success', - show: false - }, - { - label: 'Toast', - id: 'toast' - }, - { - label: 'Toptips', - id: 'toptips' - } - ] - }, - { - name: '手势 Gesture', - icon: 'icon_nav_feedback', - show: false, - items: [ - { - label: 'Pull To Refresh', - id: 'ptr' - }, - { - label: 'Infinite Loader', - id: 'infiniteloader' - } - ] - }, - { - name: '组合组件 Combination', - icon: 'icon_nav_search', - show: false, - items: [ - { - label: 'Search Bar', - id: 'searchbar' - } - ] - }, - { - name: '其他 Other', - icon: 'icon_nav_layout', - show: false, - items: [ - { - label: '微信JS-SDK', - id: 'jweixin' - }, - { - label: 'Mask', - id: 'mask' - } - ] - }, - { - name: 'Third Party', - icon: 'icon_nav_layout', - show: false, - items: [ - { - label: 'Chart G2-Mobile', - id: 'chart-g2' - }, - { - label: 'Countdown', - id: 'countdown' - }, - { - label: 'Gesture Password', - id: 'gesture-password' - }, - { - label: 'QQ Map', - id: 'map-qq' - } - ] - } - ] - - getMenu(id: string) { - for (let mi of this.menus) { - const item = mi.items.find(w => w.id === id); - if (item) return item; - } + getMenu(id: string) { + for (let mi of this.menus) { + const item = mi.items.find(w => w.id === id); + if (item) return item; } + } } diff --git a/src/app/routes/issue/issue.component.ts b/src/app/routes/issue/issue.component.ts index bc23d53..50b8baa 100644 --- a/src/app/routes/issue/issue.component.ts +++ b/src/app/routes/issue/issue.component.ts @@ -1,20 +1,26 @@ import { Component } from '@angular/core'; @Component({ - selector: 'app-issue', - template: ` + selector: 'app-issue', + template: `

ngx-weui

- -

result: {{time}}

- + +

result: {{ time }}

+
- ` + `, }) export class IssueComponent { - time: any; + time: any; - clear() { - this.time = null; - } + clear() { + this.time = null; + } } diff --git a/src/app/routes/routes.module.ts b/src/app/routes/routes.module.ts index 32ff78c..f8d7391 100644 --- a/src/app/routes/routes.module.ts +++ b/src/app/routes/routes.module.ts @@ -7,21 +7,10 @@ import { DocsStartComponent } from './start/start.component'; import { IssueComponent } from './issue/issue.component'; @NgModule({ - imports: [ - SharedModule, - RouterModule.forRoot(routes, { useHash: true }) - ], - declarations: [ - DocsStartComponent, - IssueComponent - ], - providers: [ - ], - entryComponents: [ - ], - exports: [ - RouterModule - ] + imports: [SharedModule, RouterModule.forRoot(routes, { useHash: true })], + declarations: [DocsStartComponent, IssueComponent], + providers: [], + entryComponents: [], + exports: [RouterModule], }) -export class RoutesModule { -} +export class RoutesModule {} diff --git a/src/app/routes/routes.ts b/src/app/routes/routes.ts index d936017..4b69f76 100644 --- a/src/app/routes/routes.ts +++ b/src/app/routes/routes.ts @@ -3,18 +3,18 @@ import { AppLayoutComponent } from '../layout/default/default.component'; import { IssueComponent } from './issue/issue.component'; export const routes = [ - { - path: '', - component: AppLayoutComponent, - children: [ - { path: '', redirectTo: 'start', pathMatch: 'full' }, - { path: 'start', component: DocsStartComponent }, - { path: 'components', loadChildren: './components/components.module#ComponentsModule' }, - { path: 'docs', loadChildren: './docs/docs.module#DocsModule' }, - ] - }, - { path: 'example', loadChildren: './example/example.module#ExampleModule' }, - { path: 'issue', component: IssueComponent }, - // Not found - { path: '**', redirectTo: 'example' } + { + path: '', + component: AppLayoutComponent, + children: [ + { path: '', redirectTo: 'start', pathMatch: 'full' }, + { path: 'start', component: DocsStartComponent }, + { path: 'components', loadChildren: './components/components.module#ComponentsModule' }, + { path: 'docs', loadChildren: './docs/docs.module#DocsModule' }, + ], + }, + { path: 'example', loadChildren: './example/example.module#ExampleModule' }, + { path: 'issue', component: IssueComponent }, + // Not found + { path: '**', redirectTo: 'example' }, ]; diff --git a/src/app/routes/start/start.component.html b/src/app/routes/start/start.component.html index b671f1d..f052514 100644 --- a/src/app/routes/start/start.component.html +++ b/src/app/routes/start/start.component.html @@ -1,39 +1,63 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

Angular WeUI

-

Gorgeous WeUI Components rebuild in Angular

- -
+
+ +
+
+
+
+ +
+
-
-
-
- +
+
+
+
+
+
+

Angular WeUI

+

Gorgeous WeUI Components rebuild in Angular

+ +
- diff --git a/src/app/routes/start/start.component.ts b/src/app/routes/start/start.component.ts index fc0eb36..53c6cc2 100644 --- a/src/app/routes/start/start.component.ts +++ b/src/app/routes/start/start.component.ts @@ -1,9 +1,7 @@ import { Component } from '@angular/core'; @Component({ - selector: 'docs-start', - templateUrl: './start.component.html' + selector: 'docs-start', + templateUrl: './start.component.html', }) -export class DocsStartComponent { - -} +export class DocsStartComponent {} diff --git a/src/app/shared/docs-nav/docs-nav.component.html b/src/app/shared/docs-nav/docs-nav.component.html index 98f0be8..6efece3 100644 --- a/src/app/shared/docs-nav/docs-nav.component.html +++ b/src/app/shared/docs-nav/docs-nav.component.html @@ -1,18 +1,20 @@