Browse Source

chore: add TDesign/maptalks tooling and map config skeleton

main
xiaosi 1 month ago
parent
commit
776e5deca8
  1. 4
      .env.development
  2. 1088
      package-lock.json
  3. 7
      package.json
  4. 24
      src/config/map.js
  5. 2
      src/config/urls.js
  6. 28
      vite.config.js

4
.env.development

@ -0,0 +1,4 @@
APP_TIANDITU_TOKEN=
APP_MAP_CENTER_LNG=106.62341584179686
APP_MAP_CENTER_LAT=26.657826154258505
APP_MAP_ZOOM=5

1088
package-lock.json

File diff suppressed because it is too large

7
package.json

@ -9,15 +9,18 @@
"preview": "vite preview"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.1",
"axios": "^1.6.8",
"element-plus": "^2.7.3",
"less": "^4.9.0",
"maptalks": "^1.12.1",
"pinia": "^2.1.7",
"tdesign-vue-next": "^1.20.6",
"vue": "^3.4.27",
"vue-router": "^4.3.2"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"unplugin-auto-import": "^21.1.0",
"unplugin-vue-components": "^32.1.0",
"vite": "^5.2.11"
}
}

24
src/config/map.js

@ -0,0 +1,24 @@
const token = import.meta.env.APP_TIANDITU_TOKEN || import.meta.env.VITE_TIANDITU_TOKEN || ''
export default {
token,
center: [
Number(import.meta.env.APP_MAP_CENTER_LNG) || 106.62341584179686,
Number(import.meta.env.APP_MAP_CENTER_LAT) || 26.657826154258505,
],
zoom: Number(import.meta.env.APP_MAP_ZOOM) || 5,
}
/** 天地图影像 + 注记(WGS84 lk 系列) */
export function createTiandituLayerOptions(tk) {
return {
img: {
urlTemplate: `https://t{s}.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${tk}`,
subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
},
cia: {
urlTemplate: `https://t{s}.tianditu.gov.cn/cia_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${tk}`,
subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
},
}
}

2
src/config/urls.js

@ -0,0 +1,2 @@
export const BASE_URL = '/api'
// 后续从调用点抽全;本轮允许仅占位

28
vite.config.js

@ -1,8 +1,26 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { TDesignResolver } from 'unplugin-vue-components/resolvers'
export default defineConfig({
plugins: [vue()],
plugins: [
vue(),
AutoImport({
resolvers: [TDesignResolver({ library: 'vue-next' })],
}),
Components({
resolvers: [TDesignResolver({ library: 'vue-next' })],
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
envPrefix: ['APP_', 'VITE_'],
server: {
host: '0.0.0.0',
port: 5173,
@ -10,8 +28,8 @@ export default defineConfig({
'/api': {
target: 'http://127.0.0.1:8080',
changeOrigin: true,
rewrite: (p) => p.replace(/^\/api/, '')
}
}
}
rewrite: (p) => p.replace(/^\/api/, ''),
},
},
},
})

Loading…
Cancel
Save