Skip to content

Commit 53ad4cd

Browse files
author
webbery
committed
🚧美化视图;调整数据解析流,加快预览
1 parent f711bb2 commit 53ad4cd

File tree

22 files changed

+182
-373
lines changed

22 files changed

+182
-373
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
编译安装方式:
3535
- 确保自己平台的node版本是node 14及以上,C++编译器支持C++17。如果使用的是Ubuntu16,可以使用`update-alternatives`命令安装并切换高版本的gcc
3636
- 在下载的源代码目录下,运行`npm install`安装相关的依赖包
37-
- 依赖包安装完毕后,可以尝试运行`npm run dev`查看开发环境下是否能正常运行
38-
- 如果能够正常运行,可以执行`npm run build`打包安装包
37+
- 执行`npm run build`打包安装包;执行该命令会安装插件的依赖项
3938
- 如果是在Mac环境下,请确保自己的环境能够进行签名打包
4039

4140
### 相关资源

extensions/grid_view/view.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,9 @@
299299
return
300300
}
301301
const selections = GridViewCache.getSelection()
302-
acquireCivetApi().injectCommandParams('exportResources', selections)
303-
acquireCivetApi().injectCommandParams('deleteResources', selections)
302+
const ids = selections.map(item => item[0])
303+
acquireCivetApi().injectCommandParams('exportResources', ids)
304+
acquireCivetApi().injectCommandParams('deleteResources', ids)
304305
}
305306
}
306307
function onGridClick(itemid, elm) {

extensions/map_view/view.html

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,33 @@
1919
border: 0;
2020
background-color: transparent;
2121
}
22-
/* ._cv_horizon-image {
23-
transform: rotate(90deg);
24-
} */
25-
/* ::-webkit-scrollbar{
26-
width:4px;
27-
height:2px;
28-
}
29-
::-webkit-scrollbar-button{
30-
width:4px;
31-
height:2px;
32-
} */
33-
#resources {
34-
height:20%;
35-
/* background-color: #222933; */
22+
#__cv_map_resources {
23+
height:25vh;
3624
width: 100%;
37-
white-space: nowrap;
25+
}
26+
.__cv_map_image {
27+
display: flex;
28+
flex-wrap: wrap;
3829
overflow-y: hidden;
3930
overflow-x: auto;
40-
display: flex;
4131
}
42-
#container {
43-
height:75%;
32+
.__cv_map_image::after {
33+
content: '';
34+
flex-grow: 99999;
35+
}
36+
.__cv_mapbox {
37+
margin: 2px;
38+
object-fit: cover;
39+
}
40+
#__cv_map_container {
41+
height:75vh;
4442
}
4543
._cv_gv_mini-cover {
4644
border-radius: 8px;
4745
border: 2px solid;
4846
box-sizing: border-box;
47+
height: 18vh;
48+
object-fit: cover;
4949
}
5050
._cv_gv_trans-border{
5151
border-color: transparent;
@@ -56,8 +56,10 @@
5656
</style>
5757
</head>
5858
<body>
59-
<div id="container" draggable="true" ondragstart="MapLayout.preventDrag(event)" ondrag="MapLayout.preventDrag(event)"></div>
60-
<div id="resources"></div>
59+
<div id="__cv_map_container" draggable="true" ondragstart="MapLayout.preventDrag(event)" ondrag="MapLayout.preventDrag(event)"></div>
60+
<div id="__cv_map_resources">
61+
<div class="__cv_map_image"></div>
62+
</div>
6163
<script type="text/javascript"
6264
src="https://webapi.amap.com/maps?v=2.0&key=6918ecca2a3cbfafb6ab59369768ae21&plugin=AMap.MarkerClusterer"></script>
6365
<script type="text/javascript">
@@ -101,29 +103,25 @@
101103
function generateFromTemplate(item) {
102104
let div = document.createElement('div')
103105
// div.setAttribute('class', '_cv_horizon-image')
104-
// div.style.left = `0px`
106+
div.style['flex-grow'] = 1
105107
// div.style.top = `${item.top}px`
106-
div.style.width = `${item.width - 15}px`
107-
div.style.height = `${item.height - 10}px`
108+
// div.style.width = `${item.width - 15}px`
109+
// div.style.height = `${item.height - 10}px`
108110
// In Chrome 59, the right-mouse-button triggers onmousedown and onmouseup, but not onclick
109-
const html = `<div draggable="true" class="image">
110-
<div class="el-card is-never-shadow" style="border: 0px;">
111-
<div class="el-card__body" style="padding: 4px;">
112-
<div class="frame" onclick="MapLayout.onResourceClick(${item.id}, this)" oncontextmenu="MapLayout.onResourceClick(${item.id}, this)" ondblclick="MapLayout.onDbResourceClick(${item.id}, this)">
113-
<img src="${item.thumbnail?item.thumbnail:item.src}" width="100%" class="_cv_gv_mini-cover _cv_gv_trans-border">
114-
</div>
115-
<div style="padding: 2px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; text-align: center; font-size: 12px;">
116-
<span class="context">${item.name}</span>
117-
</div>
118-
</div>
111+
const html = `<div draggable="true" class="__cv_mapbox" style="border: 0px;padding: 4px;">
112+
<div class="frame" onclick="MapLayout.onResourceClick(${item.id}, this)" oncontextmenu="MapLayout.onResourceClick(${item.id}, this)" ondblclick="MapLayout.onDbResourceClick(${item.id}, this)">
113+
<img src="${item.thumbnail?item.thumbnail:item.src}" height="95%" class="_cv_gv_mini-cover _cv_gv_trans-border">
114+
</div>
115+
<div style="padding: 2px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; text-align: center; font-size: 12px;">
116+
<span class="context">${item.name}</span>
119117
</div>
120118
</div>`
121119
acquireCivetApi().setHtml('mapview', div, html)
122120
return div
123121
}
124122
function addHorizonItem(item) {
125123
// const items = document.querySelectorAll('#resources')
126-
const root = document.getElementById('resources')
124+
const root = document.getElementsByClassName('__cv_image')[0]
127125
const defaultHeight = root.offsetHeight
128126
console.info('Item Height', defaultHeight)
129127
let block = {}, src = undefined
@@ -194,11 +192,19 @@
194192
}
195193
console.info('map right click')
196194
const selections = MapViewCache.getSelection()
197-
acquireCivetApi().injectCommandParams('exportResources', selections)
198-
acquireCivetApi().injectCommandParams('deleteResources', selections)
195+
const ids = selections.map(item => item[0])
196+
acquireCivetApi().injectCommandParams('exportResources', ids)
197+
acquireCivetApi().injectCommandParams('deleteResources', ids)
199198
}
200199
}
201200

201+
function onDbResourceClick(itemid) {
202+
acquireCivetApi().postMessage({
203+
command: 'showResourceDetail',
204+
id: itemid
205+
})
206+
}
207+
202208
function onResourceClick(itemid, element) {
203209
if (!MapViewCache.getTimer()) {
204210
const id = window.setTimeout(() => {
@@ -229,6 +235,9 @@
229235
MapLayout.add(resource)
230236
}
231237
})
238+
acquireCivetApi().Overview.on('click', (data) => {
239+
MapViewCache.resetSelection()
240+
})
232241
return {
233242
add: function(item) {
234243
let longitude, latitude
@@ -265,10 +274,11 @@
265274
// if (cluster) {
266275
// cluster.setMap(null);
267276
// }
268-
let root = document.getElementById('resources')
277+
let root = document.getElementsByClassName('__cv_image')[0]
269278
root.innerHTML = ''
270279
},
271280
onResourceClick: onResourceClick,
281+
onDbResourceClick: onDbResourceClick,
272282
preventDrag: preventDrag,
273283
}
274284
})()

package-lock.json

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

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@
167167
"ajv": "^6.5.0",
168168
"babel-eslint": "^10.1.0",
169169
"babel-loader": "^8.1.0",
170-
"babel-plugin-transform-remove-strict-mode": "^0.0.2",
171170
"cfonts": "^2.1.2",
172171
"chai": "^4.3.0",
173172
"chalk": "^2.4.1",
@@ -178,7 +177,7 @@
178177
"devtron": "^1.4.0",
179178
"dts-bundle": "^0.7.3",
180179
"ejs": "^3.1.6",
181-
"electron": "^11.5.0",
180+
"electron": "^12.2.0",
182181
"electron-builder": "^22.9.0",
183182
"electron-builder-squirrel-windows": "^22.3.5",
184183
"electron-debug": "^1.5.0",
@@ -199,15 +198,15 @@
199198
"eslint-plugin-promise": "^3.8.0",
200199
"eslint-plugin-standard": "^3.1.0",
201200
"file-loader": "^1.1.11",
202-
"html-webpack-plugin": "^3.2.0",
201+
"html-webpack-plugin": "^4.2.0",
203202
"inject-loader": "^4.0.1",
204203
"less": "^4.1.1",
205204
"less-loader": "^7.3.0",
206205
"mini-css-extract-plugin": "^0.4.0",
207206
"mocha": "^8.2.1",
208207
"multispinner": "^0.2.1",
209208
"node-loader": "^1.0.0",
210-
"node-sass": "^4.9.2",
209+
"node-sass": "^5.0.0",
211210
"p-finally": "^2.0.1",
212211
"puppeteer-core": "^10.4.0",
213212
"puppeteer-in-electron": "^3.0.4",

src/civet.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ declare module 'civet' {
189189
onDidChangeOverviewVisibleRanges(listener: (e: OverviewVisibleRangesChangeEvent) => void, thisArg?: any): void;
190190
}
191191

192+
export interface Anotator {}
193+
192194
/**
193195
* @brief a view which is display content
194196
*/

src/main/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ function createRendererWindow() {
9090
nodeIntegrationInWorker: true,
9191
enableRemoteModule: true,
9292
webSecurity: false,
93+
contextIsolation: false,
9394
additionalArguments: ['renderer']
9495
},
9596
backgroundColor: '#222933',
@@ -139,6 +140,7 @@ function createWorkerWindow (bFirst) {
139140
nodeIntegration: true,
140141
nodeIntegrationInWorker: true,
141142
enableRemoteModule: true,
143+
contextIsolation: false,
142144
additionalArguments: ['worker']
143145
}
144146
})

src/public/Emitter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ export class Emitter {
77
this.#event = new EventEmitter()
88
}
99

10-
on(event: string, listener: (...args: any[]) => void) {
10+
on(event: string, listener: (...args: any[]) => void, option: any = undefined) {
1111
const done = (...args: any[]) => {
12-
listener(args)
12+
if (!option) listener(args)
13+
else listener(option, args)
1314
this.#event.emit('done')
1415
}
1516
this.#event.on(event, done)

src/renderer/components/Control/VueTreeList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113

114114
<script>
115115
import { TreeNode } from './Tree'
116-
import { addHandler, removeHandler } from './tools.js'
116+
import { addHandler, removeHandler } from './tools'
117117
import { isEmpty } from '@/../public/Utility'
118118
119119
let compInOperation = null
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Created by ayou on 18/2/6.
33
*/
44

5-
let handlerCache
5+
let handlerCache: any;
66

7-
export const addHandler = function(element, type, handler) {
7+
export const addHandler = function(element: any, type: string, handler: any) {
88
handlerCache = handler
99
if (element.addEventListener) {
1010
element.addEventListener(type, handler, false)
@@ -15,7 +15,7 @@ export const addHandler = function(element, type, handler) {
1515
}
1616
}
1717

18-
export const removeHandler = function(element, type) {
18+
export const removeHandler = function(element: any, type: string) {
1919
if (element.removeEventListener) {
2020
element.removeEventListener(type, handlerCache, false)
2121
} else if (element.detachEvent) {
@@ -26,7 +26,7 @@ export const removeHandler = function(element, type) {
2626
}
2727

2828
// depth first search
29-
export const traverseTree = root => {
29+
export const traverseTree = (root: any) => {
3030
const newRoot = {}
3131

3232
for (const k in root) {
@@ -36,9 +36,9 @@ export const traverseTree = root => {
3636
}
3737

3838
if (root.children && root.children.length > 0) {
39-
newRoot.children = []
39+
newRoot['children'] = []
4040
for (let i = 0, len = root.children.length; i < len; i++) {
41-
newRoot.children.push(traverseTree(root.children[i]))
41+
newRoot['children'].push(traverseTree(root.children[i]))
4242
}
4343
}
4444
return newRoot

0 commit comments

Comments
 (0)