Implement three divination modes, learn pages, and PM2 deploy on port 3130.
Add liuyao/bazi/combined flows with shared calc and AI infrastructure, 64-gua learn routes, and update Ubuntu PM2 deployment docs for port 3130. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import regionsData from "@/lib/data/regions.json";
|
||||
|
||||
export interface RegionNode {
|
||||
name: string;
|
||||
longitude: number;
|
||||
children?: Record<string, RegionNode>;
|
||||
}
|
||||
|
||||
export type RegionsData = Record<string, RegionNode>;
|
||||
|
||||
export const regions = regionsData as RegionsData;
|
||||
|
||||
export function getProvinces(): { code: string; name: string }[] {
|
||||
return Object.entries(regions).map(([code, node]) => ({
|
||||
code,
|
||||
name: node.name,
|
||||
}));
|
||||
}
|
||||
|
||||
export function getCities(provinceCode: string): { code: string; name: string }[] {
|
||||
const province = regions[provinceCode];
|
||||
if (!province?.children) {
|
||||
return [];
|
||||
}
|
||||
return Object.entries(province.children).map(([code, node]) => ({
|
||||
code,
|
||||
name: node.name,
|
||||
}));
|
||||
}
|
||||
|
||||
export function getRegionLocation(
|
||||
provinceCode: string,
|
||||
cityCode: string,
|
||||
): { name: string; longitude: number } | null {
|
||||
const province = regions[provinceCode];
|
||||
if (!province) {
|
||||
return null;
|
||||
}
|
||||
const city = province.children?.[cityCode];
|
||||
if (city) {
|
||||
return {
|
||||
name: `${province.name}${city.name}`,
|
||||
longitude: city.longitude,
|
||||
};
|
||||
}
|
||||
return {
|
||||
name: province.name,
|
||||
longitude: province.longitude,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user