feat: project scaffold + bridge + maplibre engine
- Vite + Vue 3 + TypeScript strict - @yuto-water/js-bridge (types, detector, browser provider) - MapLibre engine (MapManager singleton, MapFactory, LayerFactory) - Map composables (useMap, useLayer, usePopup) - Tianditu tile source, 6 layer type factory - SCSS design tokens (water-blue theme, dark mode) - Vant 4, maplibre-gl, axios, pinia, echarts deps - Build passes (vue-tsc + vite)
This commit is contained in:
67
src/bridge/index.ts
Normal file
67
src/bridge/index.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* 桥接层统一入口
|
||||
*
|
||||
* 导出类型定义、环境检测器以及各环境提供者,
|
||||
* 并提供 createBridge() 工厂函数自动选择合适的提供者实例。
|
||||
*
|
||||
* @module bridge
|
||||
*/
|
||||
|
||||
// ── 类型定义 ──
|
||||
export type {
|
||||
IBridge,
|
||||
GetLocationOptions,
|
||||
LocationResult,
|
||||
ScanType,
|
||||
ScanCodeOptions,
|
||||
ScanCodeResult,
|
||||
OpenMapParams,
|
||||
ImageSourceType,
|
||||
ChooseImageOptions,
|
||||
ChooseImageResult,
|
||||
DeviceInfo,
|
||||
} from './types'
|
||||
|
||||
// ── 环境检测 ──
|
||||
export {
|
||||
detectEnvironment,
|
||||
isWechatMiniProgram,
|
||||
isUniappWebView,
|
||||
isBrowser,
|
||||
} from './detector'
|
||||
export type { Environment } from './detector'
|
||||
|
||||
// ── 提供者 ──
|
||||
export { default as browserProvider } from './providers/browser'
|
||||
|
||||
// ── 工厂函数 ──
|
||||
import type { IBridge } from './types'
|
||||
import { detectEnvironment } from './detector'
|
||||
import browserProvider from './providers/browser'
|
||||
|
||||
/**
|
||||
* 根据当前运行环境自动创建对应的 Bridge 实例
|
||||
*
|
||||
* - 普通浏览器:返回 browserProvider(基于 Web API 降级实现)
|
||||
* - 微信小程序 WebView:待实现
|
||||
* - uni-app WebView:待实现
|
||||
*
|
||||
* @returns 符合 IBridge 接口的提供者实例
|
||||
*/
|
||||
export function createBridge(): IBridge {
|
||||
const env = detectEnvironment()
|
||||
|
||||
switch (env) {
|
||||
case 'wechat-mp':
|
||||
// TODO: 引入 WechatProvider 后替换
|
||||
throw new Error('微信小程序 WebView Bridge 尚未实现')
|
||||
|
||||
case 'uniapp-webview':
|
||||
// TODO: 引入 UniappProvider 后替换
|
||||
throw new Error('uni-app WebView Bridge 尚未实现')
|
||||
|
||||
case 'browser':
|
||||
default:
|
||||
return browserProvider
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user