Skip to content

Commit 46f1675

Browse files
authored
Merge pull request #17 from thingraph/feature/add-list
add example list
2 parents 9b60faa + 4c71457 commit 46f1675

File tree

366 files changed

+3052799
-16104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

366 files changed

+3052799
-16104
lines changed

.github/workflows/workflow.yml

Lines changed: 29 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,43 @@
1-
# .github/workflows/auto-deploy.yml
2-
3-
name: auto deploy 🚀
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
43

54
on:
6-
# 监听push操作
5+
# Runs on pushes targeting the default branch
76
push:
8-
branches:
9-
- main # 这里只配置了main分支,所以只有推送main分支才会触发以下任务
10-
pull_request:
7+
branches: ["main"]
118

12-
# 这个选项可以使你手动在 Action tab 页面触发工作流
13-
# workflow_dispatch:
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
1411

12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1513
permissions:
16-
# 允许对仓库的内容进行写操作。包括创建、修改和删除文件、目录以及提交更改等
17-
# 这里只配置了push,所以只有推送main分支才会触发以下任务
18-
contents: write
19-
# 允许管理 GitHub Pages 服务并对其进行写操作
14+
contents: read
2015
pages: write
16+
id-token: write
2117

18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
2223

2324
jobs:
24-
# 任务ID
25-
build-and-deploy:
26-
# 运行环境
27-
# runs-on: macos-latest
28-
# runs-on: windows-latest
25+
# Single deploy job since we're just deploying
26+
deploy:
27+
environment:
28+
name: github-pages
29+
url: ${{ steps.deployment.outputs.page_url }}
2930
runs-on: ubuntu-latest
30-
concurrency:
31-
group: ${{ github.workflow }}-${{ github.ref }}
32-
33-
# 步骤
3431
steps:
35-
# 官方action,将代码拉取到虚拟机
3632
- name: Checkout
37-
uses: actions/checkout@v3
38-
39-
# 建一个名为setup-node的步骤(安装指定版本的Node.js)
40-
- name: setup-node
41-
# 使用setup-node@v3这个action
42-
uses: actions/setup-node@v3
43-
# 指定某个action 可能需要输入的参数
44-
with:
45-
node-version: '20'
46-
47-
# 安装 pnpm
48-
- name: Install pnpm
49-
run: npm install pnpm -g
50-
51-
# 安装依赖
52-
- name: Install dependencies
53-
run: pnpm i
54-
# 打包
55-
- name: Build application 🔧
56-
run: pnpm run build
57-
58-
# 部署 https://github.com/JamesIves/github-pages-deploy-action
59-
- name: Deploy 🚀
60-
uses: JamesIves/github-pages-deploy-action@v4
61-
if: github.ref == 'refs/heads/main'
33+
uses: actions/checkout@v4
34+
- name: Setup Pages
35+
uses: actions/configure-pages@v5
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v3
6238
with:
63-
token: ${{ secrets.GITHUB_TOKEN }}
64-
branch: gh-pages # default: gh-pages
65-
folder: dist
66-
clean: true # Automatically remove deleted files from the deploy branch
67-
# commit-message: ${{ github.event.head_commit.message }} # default: `Deploying to gh-pages from @ 3238feb 🚀`
68-
# commit-message: "deploy: ${{ github.sha }} (${{ github.event.head_commit.message }}) 🚀 "
39+
# Upload entire repository
40+
path: '.'
41+
- name: Deploy to GitHub Pages
42+
id: deployment
43+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1 @@
1-
.DS_Store
21
node_modules
3-
/dist
4-
5-
6-
# local env files
7-
.env.local
8-
.env.*.local
9-
10-
# Log files
11-
npm-debug.log*
12-
yarn-debug.log*
13-
yarn-error.log*
14-
pnpm-debug.log*
15-
16-
# Editor directories and files
17-
.idea
18-
.vscode
19-
*.suo
20-
*.ntvs*
21-
*.njsproj
22-
*.sln
23-
*.sw?

README.md

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
# dxf-viewer-examples
2-
Examples for viewing DXF files using Three.js and Vue3.
2+
Examples for viewing DXF files using Three.js.
33

4-
## Project setup
4+
## Run examples
55
```
6-
npm install
6+
npm start
77
```
88

9-
### Compiles and hot-reloads for development
10-
```
11-
npm run serve
12-
```
13-
14-
### Compiles and minifies for production
15-
```
16-
npm run build
17-
```
18-
19-
### Lints and fixes files
20-
```
21-
npm run lint
22-
```
23-
24-
259
# dxf-viewer
2610
This example project is built on a WebGL based JS SDK, which provides a Viewer2d.
2711

@@ -59,18 +43,18 @@ viewer.goToHomeView();
5943
- Supported entity types includes: POINT, 3DFACE, ARC, ATTDEF, ATTRIB, CIRCLE, DIMENSION, MLEADER, MULTILEADER, ELLIPSE, HATCH, INSERT, LEADER, LINE, LWPOLYLINE, MTEXT, RAY, POLYLINE, SOLID, SPLINE, TEXT, VERTEX, VIEWPORT, XLINE, etc. IMAGE, OLE2FRAME, REGION are partially supported.
6044

6145
- Load and view dxf file
62-
<img src="public/images/snapshots/load_and_view.gif" width="400">
46+
<img src="images/snapshots/load_and_view.gif" width="400">
6347
- Switch between layouts
64-
<img src="public/images/snapshots/layouts.gif" width="400">
48+
<img src="images/snapshots/layouts.gif" width="400">
6549
- Distance measurement
66-
<img src="public/images/snapshots/measure_dist.gif" width="400">
50+
<img src="images/snapshots/measure_dist.gif" width="400">
6751
- Area measurement
6852
- Angle measurement
6953
- Markups
70-
<img src="public/images/snapshots/markups.gif" width="400">
54+
<img src="images/snapshots/markups.gif" width="400">
7155
- Comparison
72-
<img src="public/images/snapshots/dxf_compare_2_viewports.gif" width="400">
73-
<img src="public/images/snapshots/dxf_compare.png" width="400">
56+
<img src="images/snapshots/dxf_compare_2_viewports.gif" width="400">
57+
<img src="images/snapshots/dxf_compare.png" width="400">
7458
- Undo/redo
7559

7660
### Limitations

babel.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

compare/dxfComparePanel.css

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
b {
2+
font-weight: bold;
3+
}
4+
5+
.compare-hide {
6+
opacity: 0;
7+
}
8+
9+
.compare-panel-container {
10+
position: absolute;
11+
top: 80px;
12+
right: 10px;
13+
width: 160px;
14+
height: auto;
15+
min-height: 200px;
16+
padding: 10px;
17+
z-index: 100;
18+
box-sizing: border-box;
19+
background-color: #fff;
20+
user-select: none;
21+
}
22+
.compare-panel-container h3 {
23+
position: fixed;
24+
margin: 0;
25+
padding-left: 5px;
26+
line-height: 30px;
27+
border-bottom: 1px solid #aaa;
28+
font-size: 14px;
29+
font-weight: bold;
30+
}
31+
32+
.compare-detail {
33+
margin-top: 35px;
34+
max-height: 500px;
35+
overflow: hidden;
36+
cursor: pointer;
37+
}
38+
.compare-list {
39+
margin-top: 6px;
40+
}
41+
.list-title {
42+
display: flex;
43+
align-items: center;
44+
}
45+
.title-icon {
46+
padding: 5px;
47+
}
48+
.title-icon::before {
49+
content: '';
50+
display: block;
51+
width: 0;
52+
height: 0;
53+
border-right: 8px solid #666;
54+
border-top: 8px solid transparent;
55+
}
56+
.compare-collapse .title-icon::before {
57+
transform: rotate(-40deg);
58+
}
59+
.title-content {
60+
font-size: 12px;
61+
}
62+
.compare-detail ul {
63+
margin-left: 18px;
64+
max-height: 150px;
65+
font-size: 12px;
66+
overflow-x: none;
67+
overflow-y: scroll;
68+
}
69+
70+
.compare-detail ul li {
71+
margin: 6px 0;
72+
}

compare/dxfComparePanel.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/* eslint-disable no-undef */
2+
export default class DxfComparePanel {
3+
compareDetail;
4+
container;
5+
compareHelper;
6+
7+
constructor(compareHelper, container = document.body) {
8+
this.init(compareHelper, container);
9+
}
10+
11+
init(compareHelper, container) {
12+
this.compareHelper = compareHelper;
13+
this.container = container;
14+
15+
this.buildPanel();
16+
this.initEvents();
17+
}
18+
19+
buildPanel() {
20+
const panelContainer = document.createElement("div");
21+
panelContainer.classList.add("compare-panel-container");
22+
23+
const header = document.createElement("h3");
24+
panelContainer.appendChild(header);
25+
this.container.appendChild(panelContainer);
26+
27+
const compareDetail = document.createElement("div");
28+
compareDetail.classList.add("compare-detail");
29+
panelContainer.appendChild(compareDetail);
30+
this.compareDetail = compareDetail;
31+
32+
const changes = this.compareHelper.getChanges();
33+
if (!changes) {
34+
return;
35+
}
36+
const changesValues = Object.values(changes);
37+
38+
header.innerHTML = `差异列表(${changesValues.length})`;
39+
40+
const addedChangesValues = changesValues.filter((val) => val.type === "Added");
41+
const deletedChangeValues = changesValues.filter((val) => val.type === "Removed");
42+
const modifiedChanageValues = changesValues.filter((val) => val.type === "Modified");
43+
44+
if (addedChangesValues.length > 0) {
45+
this.buildList(addedChangesValues, "新增");
46+
}
47+
48+
if (deletedChangeValues.length > 0) {
49+
this.buildList(deletedChangeValues, "删除");
50+
}
51+
52+
if (modifiedChanageValues.length > 0) {
53+
this.buildList(modifiedChanageValues, "修改");
54+
}
55+
}
56+
57+
buildList(changesValues, text) {
58+
const section = document.createElement("div");
59+
section.classList.add("compare-list", "compare-add");
60+
this.compareDetail.appendChild(section);
61+
this.buildListTitle(section, `${text}(<b>${changesValues.length}</b>)`);
62+
const listEle = document.createElement("ul");
63+
listEle.classList.add("list", "hide");
64+
section.appendChild(listEle);
65+
66+
let listFragment = "";
67+
changesValues.forEach((val) => {
68+
listFragment += `<li data-id=${val.id} class="list-item">${val.handle}</li>`;
69+
});
70+
listEle.innerHTML = listFragment;
71+
}
72+
73+
buildListTitle(group, title) {
74+
const listTitle = document.createElement("div");
75+
listTitle.classList.add("list-title", "compare-collapse");
76+
group.appendChild(listTitle);
77+
78+
const titleIcon = document.createElement("span");
79+
titleIcon.classList.add("title-icon");
80+
listTitle.appendChild(titleIcon);
81+
82+
const titleContent = document.createElement("span");
83+
titleContent.classList.add("title-content");
84+
titleContent.innerHTML = title;
85+
listTitle.appendChild(titleContent);
86+
}
87+
88+
initEvents() {
89+
const listTitles = document.querySelectorAll(".list-title");
90+
listTitles.forEach((listTitle) => {
91+
listTitle.addEventListener("click", () => {
92+
listTitle.classList.toggle("compare-collapse");
93+
listTitle.nextSibling?.classList.toggle("hide");
94+
});
95+
});
96+
97+
const lists = document.querySelectorAll(".list");
98+
lists.forEach((list) => {
99+
list.addEventListener("click", (e) => {
100+
if (e.target.tagName.toUpperCase() === "LI" && e.target.dataset.id) {
101+
this.compareHelper.zoomToChange(e.target.dataset.id);
102+
}
103+
});
104+
});
105+
}
106+
107+
destroy() {
108+
this.container.remove();
109+
this.container = undefined;
110+
}
111+
}

dist/css/about.d8e79f23.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.about{padding-top:30px}

dist/css/app.fc3af217.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)