diff --git a/package.json b/package.json index 2d5c8ad..b64cf04 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "dependencies": { "@element-plus/icons-vue": "2.3.1", "@highlightjs/vue-plugin": "2.1.0", + "@turf/turf": "^7.2.0", "@vueup/vue-quill": "1.2.0", "@vueuse/core": "11.3.0", "animate.css": "4.1.1", @@ -38,6 +39,7 @@ "highlight.js": "11.9.0", "image-conversion": "2.1.1", "js-cookie": "3.0.5", + "js-md5": "^0.8.3", "jsencrypt": "3.3.2", "mitt": "^3.0.1", "nprogress": "0.2.0", diff --git a/src/App.vue b/src/App.vue index 500c7f6..efc2c67 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,11 +1,6 @@ @@ -14,22 +9,7 @@ import useSettingsStore from '@/store/modules/settings'; import { handleThemeStyle } from '@/utils/theme'; import useAppStore from '@/store/modules/app'; import { getProjectTeam } from './utils/projectTeam'; -import request from '@/utils/request'; const appStore = useAppStore(); -const fullscreenLoading = ref(false); -const aarr = ref([]); -const a = () => { - fullscreenLoading.value = true; - request({ - url: '/project/project/json', - method: 'get' - }).then((res) => { - console.log(res); - aarr.value = res.data.layers; - - fullscreenLoading.value = false; - }); -}; onMounted(() => { nextTick(() => { @@ -39,3 +19,20 @@ onMounted(() => { }); }); + diff --git a/src/api/project/project/index.ts b/src/api/project/project/index.ts index 0e56609..0bf193c 100644 --- a/src/api/project/project/index.ts +++ b/src/api/project/project/index.ts @@ -16,6 +16,19 @@ export const listProject = (query?: ProjectQuery): AxiosPromise => }); }; +/** + * 查询项目dxf + * @param query + * @returns {*} + */ + +export const listDXFProject = (id: string | number): AxiosPromise => { + return request({ + url: '/project/projectFile/json/' + id, + method: 'get' + }); +}; + /** * 查询项目详细 * @param id @@ -51,6 +64,18 @@ export const updateProject = (data: ProjectForm) => { }); }; +/** + * 上传dxf文件 + * @param data + */ +export const upLoadProjectDXF = (data: any) => { + return request({ + url: '/project/projectFile/upload/dxf', + method: 'post', + data: data + }); +}; + /** * 删除项目 * @param id diff --git a/src/api/project/project/types.ts b/src/api/project/project/types.ts index 3ef4de6..f78eb29 100644 --- a/src/api/project/project/types.ts +++ b/src/api/project/project/types.ts @@ -2,7 +2,7 @@ export interface ProjectVO { /** * id */ - id: string | number; + id: string; /** * 项目名称 @@ -13,7 +13,7 @@ export interface ProjectVO { * 项目简称 */ shortName: string; - + designId: string; /** * 父项目id */ diff --git a/src/components/openLayersMap/index.vue b/src/components/openLayersMap/index.vue index 47c125a..15524b2 100644 --- a/src/components/openLayersMap/index.vue +++ b/src/components/openLayersMap/index.vue @@ -1,5 +1,18 @@ - diff --git a/src/utils/snowflake.ts b/src/utils/snowflake.ts new file mode 100644 index 0000000..12ad0e1 --- /dev/null +++ b/src/utils/snowflake.ts @@ -0,0 +1,71 @@ +export class Snowflake { + private startTimeStamp: number = 1609459200000; + private workerIdBits: number = 5; + private dataCenterIdBits: number = 5; + private sequenceBits: number = 12; + + private maxWorkerId: number = -1 ^ (-1 << this.workerIdBits); + private maxDataCenterId: number = -1 ^ (-1 << this.dataCenterIdBits); + + private workerIdShift: number = this.sequenceBits; + private dataCenterIdShift: number = this.sequenceBits + this.workerIdBits; + private timestampLeftShift: number = this.sequenceBits + this.workerIdBits + this.dataCenterIdBits; + private sequenceMask: number = -1 ^ (-1 << this.sequenceBits); + + private workerId: number; + private dataCenterId: number; + private sequence: number = 0; + private lastTimestamp: number = -1; + + constructor(workerId: number, dataCenterId: number) { + if (workerId > this.maxWorkerId || workerId < 0) { + throw new Error(`Worker ID 不能大于 ${this.maxWorkerId} 或小于 0`); + } + if (dataCenterId > this.maxDataCenterId || dataCenterId < 0) { + throw new Error(`数据中心 ID 不能大于 ${this.maxDataCenterId} 或小于 0`); + } + this.workerId = workerId; + this.dataCenterId = dataCenterId; + } + + public nextId(): number { + let timestamp = this.getCurrentTimestamp(); + if (timestamp < this.lastTimestamp) { + throw new Error('检测到时钟回拨,拒绝生成 ID'); + } + if (timestamp === this.lastTimestamp) { + this.sequence = (this.sequence + 1) & this.sequenceMask; + if (this.sequence === 0) { + timestamp = this.waitNextMillis(this.lastTimestamp); + } + } else { + this.sequence = 0; + } + this.lastTimestamp = timestamp; + return ( + ((timestamp - this.startTimeStamp) << this.timestampLeftShift) | + (this.dataCenterId << this.dataCenterIdShift) | + (this.workerId << this.workerIdShift) | + this.sequence + ); + } + + private getCurrentTimestamp(): number { + return Date.now(); + } + + private waitNextMillis(lastTimestamp: number): number { + let timestamp = this.getCurrentTimestamp(); + while (timestamp <= lastTimestamp) { + timestamp = this.getCurrentTimestamp(); + } + return timestamp; + } +} + +// 使用示例 +// const workerId: number = 1; +// const dataCenterId: number = 1; +// const snowflake = new Snowflake(workerId, dataCenterId); +// const id: number = snowflake.nextId(); +// console.log('生成的唯一 ID:', id); diff --git a/src/views/index.vue b/src/views/index.vue index fbfc3c9..ed0e91c 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -16,7 +16,6 @@

{{ visitCount }}

- diff --git a/src/views/project/project/index.vue b/src/views/project/project/index.vue index c2c5552..ee30b2c 100644 --- a/src/views/project/project/index.vue +++ b/src/views/project/project/index.vue @@ -69,12 +69,34 @@ + + + - + + + - + + + + +