Browse Source

初始化工程

master
Cmen 3 years ago
commit
b37e821345
  1. 7
      .gitignore
  2. 14
      index.html
  3. 26
      package.json
  4. 4
      src/editor/index.less
  5. 15
      src/editor/index.tsx
  6. 8
      src/index.less
  7. 11
      src/index.tsx
  8. 29
      src/mapStage/index.ts
  9. 7
      src/types/index.d.ts
  10. 20
      tsconfig.json
  11. 10
      vite.config.js
  12. 1692
      yarn.lock

7
.gitignore vendored

@ -0,0 +1,7 @@
node_modules
.DS_Store
dist
dist-ssr
*.local
.vscode/
package-lock.json

14
index.html

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app"></div>
<script src="https://webapi.amap.com/loader.js"></script>
<script type="module" src="./src/index.tsx"></script>
</body>
</html>

26
package.json

@ -0,0 +1,26 @@
{
"name": "fine-geojson-editor",
"version": "0.0.1",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"antd": "^4.16.13",
"less": "^4.1.2",
"lodash": "^4.17.21",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@amap/amap-jsapi-types": "^0.0.8",
"@types/react": "^17.0.33",
"@types/react-dom": "^17.0.10",
"@vitejs/plugin-react": "^1.0.7",
"ncp": "^2.0.0",
"typescript": "^4.4.4",
"vite": "^2.6.4",
"vitepress": "^0.20.0"
}
}

4
src/editor/index.less

@ -0,0 +1,4 @@
#mapStage{
height: 100%;
}

15
src/editor/index.tsx

@ -0,0 +1,15 @@
import { useEffect, useRef } from "react";
import { MapStage } from "../mapStage";
import "./index.less";
export const Editor = () => {
const mapStageRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const mapStage = new MapStage(mapStageRef.current!);
mapStage.init();
});
return <div id="mapStage" ref={mapStageRef}></div>
}

8
src/index.less

@ -0,0 +1,8 @@
html, body{
margin: 0;
padding: 0;
height: 100%;
}
#app{
height: 100%;
}

11
src/index.tsx

@ -0,0 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Editor } from './editor';
import './index.less';
ReactDOM.render(
<Editor />,
document.getElementById('app')
)

29
src/mapStage/index.ts

@ -0,0 +1,29 @@
import "@amap/amap-jsapi-types";
import "../types/index.d";
export class MapStage {
dom: HTMLDivElement;
private _map: AMap.Map | undefined;
constructor(dom: HTMLDivElement) {
this.dom = dom;
}
get map() {
return this._map;
}
async init() {
await AMapLoader.load({
key: "a4171ad2d7df42823b4de7d25c8c35ee",
version: "2.0",
plugins: [
"AMap.RectangleEditor",
"AMap.PolylineEditor",
"AMap.PolygonEditor",
"AMap.PlaceSearch",
"AMap.AutoComplete",
],
});
this._map = new AMap.Map(this.dom);
}
}

7
src/types/index.d.ts vendored

@ -0,0 +1,7 @@
declare global{
namespace AMapLoader {
const load: (config: any)=> Promise<AMap.Map>;
}
}
export {};

20
tsconfig.json

@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["./src"]
}

10
vite.config.js

@ -0,0 +1,10 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: 8080
},
})

1692
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save