perf: build map
This commit is contained in:
parent
5df2adc5b0
commit
d0d0fc65e5
7 changed files with 23 additions and 15 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -25,3 +25,4 @@ logs
|
|||
.wrangler
|
||||
site
|
||||
cache
|
||||
assets/location/world-topo.json
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
1
assets/location/world.json
Normal file
1
assets/location/world.json
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -1,20 +1,8 @@
|
|||
<script setup>
|
||||
import { VisSingleContainer, VisTopoJSONMap, VisTopoJSONMapSelectors } from '@unovis/vue'
|
||||
import { WorldMapSimplestTopoJSON } from '@unovis/ts/maps'
|
||||
import WorldMapTopoJSON from '@/assets/location/world-topo.json' // https://github.com/apache/echarts/blob/master/test/data/map/json/world.json
|
||||
import { ChartTooltip } from '@/components/ui/chart'
|
||||
|
||||
WorldMapTopoJSON.objects.states.geometries.map((state) => {
|
||||
const name = state.properties.name
|
||||
const country = WorldMapSimplestTopoJSON.objects.countries.geometries.find(country => country.properties.name === name)
|
||||
state.id = state.name || ''
|
||||
if (country) {
|
||||
state.id = country.id || ''
|
||||
state.properties = country.properties
|
||||
}
|
||||
return state
|
||||
})
|
||||
|
||||
const id = inject('id')
|
||||
const startAt = inject('startAt')
|
||||
const endAt = inject('endAt')
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import withNuxt from './.nuxt/eslint.config.mjs'
|
|||
export default withNuxt(
|
||||
// antfu(),
|
||||
{
|
||||
ignores: ['components/ui'],
|
||||
ignores: ['components/ui', 'scripts/build-map.js'],
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@
|
|||
"scripts": {
|
||||
"dev": "nuxt dev",
|
||||
"build": "nuxt build",
|
||||
"build:map": "node scripts/build-map.js",
|
||||
"preview": "wrangler pages dev dist",
|
||||
"deploy": "wrangler pages deploy dist",
|
||||
"postinstall": "nuxt prepare",
|
||||
"postinstall": "npm run build:map && nuxt prepare",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix",
|
||||
"typecheck": "nuxt typecheck",
|
||||
|
|
|
|||
17
scripts/build-map.js
Normal file
17
scripts/build-map.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { writeFileSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import { WorldMapSimplestTopoJSON } from '@unovis/ts/maps.js'
|
||||
import WorldMapTopoJSON from '../assets/location/world.json' with { type: "json" } // https://github.com/apache/echarts/blob/master/test/data/map/json/world.json
|
||||
|
||||
WorldMapTopoJSON.objects.states.geometries.map((state) => {
|
||||
const name = state.properties.name
|
||||
const country = WorldMapSimplestTopoJSON.objects.countries.geometries.find(country => country.properties.name === name)
|
||||
state.id = state.name || ''
|
||||
if (country) {
|
||||
state.id = country.id || ''
|
||||
state.properties = country.properties
|
||||
}
|
||||
return state
|
||||
})
|
||||
|
||||
writeFileSync(join(import.meta.dirname, '../assets/location/world-topo.json'), JSON.stringify(WorldMapTopoJSON), 'utf8')
|
||||
Loading…
Reference in a new issue