Commit 48509a02 by wanghao

初始发布

parent e49ea021

要显示的修改太多。

为保证性能只显示 1000 of 1000+ 个文件。

> 1%
last 2 versions
not dead
# base目录
VITE_BASE_URL=/
# example目录位置
VITE_EXAMPLE_SOURCE_PATH=src/example
# 示例页面是否可以编辑(显示源码编辑器)
VITE_EDITOR_MODE=1
# base目录
VITE_BASE_URL=/
# example目录位置
VITE_EXAMPLE_SOURCE_PATH=example
# 示例页面是否可以编辑(显示源码编辑器)
VITE_EDITOR_MODE=1
*.sh
node_modules
*.md
*.woff
*.ttf
.vscode
.idea
dist
/src/widgets/**/*.js
/public/lib/
/public/temp/
/src/common/*.js
/docs
.husky
.local
/bin
Dockerfile
module.exports = {
root: true,
env: {
node: true
},
extends: ["react-app", "standard"],
plugins: ["react-hooks"],
globals: {
currentPath: "readonly",
globalMsg: "readonly",
globalAlert: "readonly",
globalNotify: "readonly",
showLoading: "readonly",
hideLoading: "readonly",
Cesium: "readonly",
mars3d: "readonly",
L: "readonly",
mars2d: "readonly",
turf: "readonly",
THREE: "readonly",
Ammo: "readonly",
echarts: "readonly",
Terraformer: "readonly",
AMap: "readonly",
kgUtil: "readonly",
netcdfjs: "readonly",
ol: "readonly",
olcs: "readonly"
},
rules: {
// mars3d-react-example项目专用的配置(目的便于示例的开发调试) start
"no-unused-vars": "off", // 不允许有声明后未被使用的变量或参数
"prefer-regex-literals": "off", // 关闭只能使用正则字面量
"import/no-anonymous-default-export": ["off"],
"no-use-before-define": "off", // 允许 方法在未定义前使用
"multiline-ternary": "off",
"no-restricted-globals": "off",
"react-hooks/rules-of-hooks": "error", // 检查 Hook 的规则
"react-hooks/exhaustive-deps": "warn", // 检查 effect 的依赖
// mars3d-react-example项目专用的配置(目的便于示例的开发调试) end
"@typescript-eslint/no-explicit-any": "off", // ts:允许用any
"@typescript-eslint/no-useless-constructor": "error", // ts:不允许使用未定位类型自动转为any
"@typescript-eslint/no-var-requires": "off", // ts:是否允许使用var
"@typescript-eslint/no-non-null-assertion": "off", // ts:非空赋值
"@typescript-eslint/explicit-module-boundary-types": "off", // ts:是否需要显式定义函数将返回什么类型
"@typescript-eslint/ban-ts-comment": "off", // ts: 禁止ts注释
"@typescript-eslint/no-unused-vars": "off", // ts:允许定义未引用使用的变量
camelcase: "off", // 强制驼峰命名规则
indent: "off", // 强制一致的缩进风格
eqeqeq: "error", // 是否使用 === 替代 ==
quotes: ["error", "double", { avoidEscape: true, allowTemplateLiterals: true }], // 使用双引号
curly: ["error", "all"], // 强制所有控制语句使用一致的括号风格 @fixable if 后面必须要有 {,除非是单行 if
"padded-blocks": "off", // 块内行首行尾是否空行
"global-require": "off", // require 必须在全局作用域下
"comma-dangle": "error", // 强制在对象和数组文字中一致地使用尾随逗号
"valid-jsdoc": "off", // 强制使用有效的 JSDoc 注释
"consistent-return": "off", // 要求 return 语句要么总是指定返回的值,要么不指定
"default-case": "off", // switch 语句强制 default 分支,也可添加 // no default 注释取消此次警告
"block-scoped-var": "error", // 将 var 定义的变量视为块作用域,禁止在块外使用
"guard-for-in": "off", // for in 内部必须有 hasOwnProperty
"constructor-super": "error", // constructor 中必须有 super
"dot-location": ["off", "property"], // @fixable 链式调用的时候,点号必须放在第二行开头处,禁止放在第一行结尾处
"comma-style": ["error", "last"], // 控制逗号在行尾出现还是在行首出现 (默认行尾)
"space-before-function-paren": ["off", "always"], // 函数定义时括号前的空格
"object-curly-newline": ["error", { multiline: true, consistent: true }], // @fixable 大括号内的首尾必须有换行
"computed-property-spacing": ["error", "never"], // "SwitchCase" (默认:0) 强制 switch 语句中的 case 子句的缩进水平
"no-debugger": "warn", // 是否允许debugger
"no-console": "off", // 不允许出现console语句
"no-var": "error", // @fixable 禁止使用 var
"no-trailing-spaces": "off", // 一行最后不允许有空格
"no-prototype-builtins": "off", // 是否允许使用Object.prototype
"no-template-curly-in-string": "off", // 关闭${xxx}检测
"no-mixed-spaces-and-tabs": "error", // 不允许混用tab和空格
"no-new": "error", // 禁止在非赋值或条件语句中使用 new 操作符
"no-new-wrappers": "error", // 禁止对 String,Number 和 Boolean 使用 new 操作符
"no-self-assign": "error", // 禁止自我赋值
"no-self-compare": "error", // 禁止自身比较
"no-case-declarations": "error", // switch 的 case 内有变量定义的时候,必须使用大括号将 case 内变成一个代码块
"no-extend-native": "error", // 禁止修改原生对象
"no-extra-bind": "error", // @fixable 禁止出现没必要的 bind
"no-extra-label": "error", // @fixable 禁止出现没必要的 label
"no-fallthrough": "error", // switch 的 case 内必须有 break, return 或 throw
"no-floating-decimal": "error", // @fixable 表示小数时,禁止省略 0,比如 .5
"no-global-assign": "error", // 禁止对全局变量赋值
"no-multi-str": "error", // 禁止使用 \ 来换行字符串
"no-const-assign": "error", // 禁止对使用 const 定义的常量重新赋值
"no-dupe-class-members": "error", // 禁止重复定义类
"no-duplicate-imports": "off", // 禁止重复 import 模块
"no-useless-constructor": "off", // 禁止出现没必要的 constructor,比如 constructor(value) { super(value) }
"no-useless-escape": "off", // 可以使用\转义
"no-callback-literal": "off", // 关闭eslint标准模式callback回调报错
"no-dupe-keys": "error", // 禁止对象字面量中出现重复的 key
"no-func-assign": "error", // 禁止对 function 声明重新赋值
"no-nested-ternary": "error", // 禁用嵌套的三元表达式
"no-multiple-empty-lines": ["error", { max: 3 }], // 空行最多不能超过两行
"new-cap": "off" // 关闭eslint fromDegrees方法报错
}
}
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
public/lib/CesiumUnminified/
public/lib/mars3d/plugins/widget/
mars3d-*src.*
!mars3d-supermap-src.js*
!mars3d-tdt-src.js*
# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json
# IDEs and editors
/.vscode
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
package-lock.json
# 本地测试
src/example/a-test
{
"useTabs": false,
"eslintIntegration": true,
"singleQuote": false,
"semi": false,
"trailingComma": "none",
"bracketSpacing": true,
"printWidth": 150,
"arrowParens": "always"
}
差异被折叠。 点击展开。
/* eslint-disable prefer-regex-literals */
import fs from "fs"
export default function examplePlugin(mode: string) {
return {
name: "transform-example",
load(id: string) {
// 填坑:在transform中处理的是编译后的文件内容,导致了一些bug
if (id.endsWith(".tsx") || /widgets\/.*\/map.ts/.test(id)) {
const data = fs.readFileSync(id)
let source = data.toString()
if (source.indexOf(`from "./map.js"`) !== -1) {
// source = source.replace(/import \* as (\S*) from \"\.\/map\.js\"/g, "const $1 = window.mapWork")
source = source.replace(/import \* as (\S*) from \"\.\/map\.js\"/g, "")
source = source.replace(/ mapWork/g, " window.mapWork")
}
if (source.indexOf(`from "mars2d"`) !== -1) {
source = source.replace(/import \* as (\S*) from \"mars2d\"/g, "const $1 = window.mars2d")
}
if (source.indexOf(`from "mars3d"`) !== -1) {
source = source.replace(/import \* as (\S*) from \"mars3d\"/g, "const $1 = window.mars3d")
}
return source
}
},
transform(source: string, id: string) {
let code = source
if (/example\/.*\/map.js/.test(id) && mode === "development") {
// 替换let const
code = code.replace(new RegExp("export let ", "gm"), "var ")
code = code.replace(new RegExp("export const ", "gm"), "var ")
// 浏览器中运行时,删除export import
code = code.replace(new RegExp("export ", "gm"), "")
code = code.replace(new RegExp("import ", "gm"), "// import ")
// 删除const L = mars2d.L
code = code.replace("const L = mars2d.L", "")
// 删除const Cesium = mars3d.Cesium
code = code.replace("const Cesium = mars3d.Cesium", "")
}
return {
code
}
}
}
}
<!DOCTYPE html>
<html lang="zh-cn">
<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>功能示例(React版) | Mars3D三维可视化平台 | 火星科技</title>
<script src="lib/includeLibs.js"></script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/pages/editor/main.tsx"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="zh-cn">
<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>功能示例(React版)列表 | Mars3D三维可视化平台 | 火星科技</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/pages/index/main.tsx"></script>
</body>
</html>
{
"name": "mars3d-react-example",
"version": "3.3.0",
"description": "基于 React 的 Mars3D 功能示例项目",
"scripts": {
"serve": "vite --host",
"dev": "vite",
"clean-cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite",
"clean-lib": "rimraf node_modules",
"preview": "vite preview",
"build": "npm run lint && vite build",
"serve:dist": "http-server ./dist",
"lint": "npm run eslint",
"eslint": "eslint ./src/**/*.{js,jsx,vue,ts,tsx} --fix",
"prepare": "husky install"
},
"dependencies": {
"@icon-park/react": "^1.3.5",
"@marsgis/editor": "^1.0.4",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"antd": "^4.19.3",
"axios": "^0.26.1",
"babel-eslint": "^10.1.0",
"echarts": "^5.3.2",
"eslint": "^7.32.0",
"eslint-plugin-flowtype": "^5.10.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.2.0",
"eslint-plugin-react": "^7.29.4",
"http-server": "^14.1.0",
"lodash": "^4.17.21",
"mars3d": "^3.3.0",
"monaco-editor": "^0.29.1",
"nprogress": "^0.2.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-redux": "^8.0.1",
"redux": "^4.2.0",
"split.js": "^1.6.4",
"uuid": "^8.3.2"
},
"devDependencies": {
"@types/node": "^17.0.22",
"@types/react": "^18.0.8",
"@types/react-dom": "^18.0.3",
"@vitejs/plugin-react": "^1.0.7",
"autoprefixer": "^10.4.4",
"consola": "^2.15.3",
"eslint-config-react-app": "^6.0.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-react-hooks": "^4.3.0",
"husky": "^7.0.4",
"less": "^4.1.2",
"rollup-plugin-copy": "^3.4.0",
"typescript": "^4.5.4",
"vite": "2.8.6",
"vite-plugin-eslint": "^1.3.0",
"vite-plugin-mars3d": "^1.1.2",
"vite-plugin-monaco-editor": "^1.0.10",
"vite-plugin-style-import": "^2.0.0"
},
"engines": {
"node": ">=14.18.0",
"npm": "^7.23.0"
},
"repository": {
"type": "git",
"url": "https://github.com/marsgis/mars3d-react-example.git"
},
"bugs": {
"url": "https://github.com/marsgis/mars3d-react-example/issues",
"email": "wh@marsgis.cn"
},
"keywords": [
"marsgis",
"mars3d",
"cesium",
"react",
"gis",
"webgis"
],
"author": "火星科技",
"license": "Apache-2.0",
"homepage": "http://mars3d.cn",
"lint-staged": {
"*.{js,jsx,vue,ts,tsx}": [
"npm run eslint"
]
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论