UNPKG

@simoko/tw-zip

Version:

台灣縣市、行政區、郵遞區號(3碼/6碼)查詢工具,支援 React/Vue/Svelte/SolidJS/Angular

55 lines (52 loc) 1.68 kB
import * as vue from 'vue'; import { isCityCached, clearCache } from '../zip6/loader.cjs'; interface SearchResult { city: string; area: string; road: string; } interface Zip6Result { zipcode: string; zip3: string; city: string; area: string; road: string; } interface UseTwZip6Options { /** 資料來源 URL(預設使用 jsDelivr CDN) */ baseUrl?: string; /** 預載入的縣市列表 */ preload?: string[]; } declare function useTwZip6(options?: UseTwZip6Options): { loading: vue.Ref<boolean, boolean>; cities: vue.Ref<string[], string[]>; areas: vue.Ref<string[], string[]>; roads: vue.Ref<string[], string[]>; city: vue.Ref<string, string>; area: vue.Ref<string, string>; road: vue.Ref<string, string>; number: vue.Ref<number | undefined, number | undefined>; lane: vue.Ref<number | undefined, number | undefined>; alley: vue.Ref<number | undefined, number | undefined>; setCity: (value: string) => Promise<void>; setArea: (value: string) => void; setRoad: (value: string) => void; searchRoads: (keyword: string) => void; searchResults: vue.Ref<{ city: string; area: string; road: string; }[], SearchResult[] | { city: string; area: string; road: string; }[]>; zipCode: vue.ComputedRef<string>; zip3: vue.ComputedRef<string>; result: vue.ComputedRef<Zip6Result | undefined>; preloadCities: (citiesToPreload: string[]) => Promise<void>; isCityCached: typeof isCityCached; clearCache: typeof clearCache; }; export { type SearchResult, type UseTwZip6Options, type Zip6Result, useTwZip6 };