Skip to content

Commit 39085e8

Browse files
author
webbery
committed
🚧fix build error;#17 迁移日志操作到logs目录;重构service中
1 parent 0065b4d commit 39085e8

29 files changed

Lines changed: 6468 additions & 8597 deletions

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<div align="center">
2-
<img src="https://raw.fastgit.org/webbery/civet/master/src/main/asset/icon/icon.png" alt=""/>
3-
<h1>Civet</h1>
2+
<h1><img src="src/main/asset/icon.png" alt="" height="35" width="35"/>Civet</h1>
43
<blockquote>资源管理新体验</blockquote>
54
<a href="https://github.com/webbery/civet/actions">
65
<img src="https://github.com/webbery/civet/workflows/win-build/badge.svg" alt="">
@@ -32,7 +31,7 @@
3231
当前windows环境下因为没有签名的原因,所以需要在安装文件的右键“属性”->“常规”中关闭掉安全选项
3332
由于版本更新比较慢,所以也可以自行编译。
3433
编译安装方式:
35-
- 确保自己平台的node版本是node 14及以上,C++编译器支持C++17。如果使用的是Ubuntu16,可以使用`update-alternatives`命令安装并切换高版本的gcc
34+
- 确保自己平台的node版本是**node 14**,C++编译器支持C++17。如果使用的是Ubuntu16,可以使用`update-alternatives`命令安装并切换高版本的gcc
3635
- 在下载的源代码目录下,运行`npm install`安装相关的依赖包
3736
- 执行`npm run build`打包安装包;执行该命令会安装插件的依赖项
3837
- 如果是在Mac环境下,请确保自己的环境能够进行签名打包
@@ -53,11 +52,11 @@
5352
| PicSee | ObjectC | ObjectC | Realm | 私有 | Mac
5453

5554
#### RoadMap
56-
:white_square_button: 自定义界面扩展,增加数据源插件功能,以支持多种格式(本地及网页等)的数据读取和展示
55+
+ :white_square_button: 自定义界面扩展,增加数据源插件功能,以支持多种格式(本地及网页等)的数据读取和展示
5756
+ [ ] 增加存储插件功能,以支持多种数据存储方式(如本地复制、云存储等)
58-
:white_square_button: 增加信息提取插件功能,以增强不同文件类型的信息存储与检索
59-
+ [ ] 引入HTML5批注规范,为各种类型的文件增加批注功能
60-
+ [ ] 升级数据库,增强搜索功能
57+
+ :white_square_button: 增加信息提取插件功能,以增强不同文件类型的信息存储与检索
58+
+ [ ] 引入HTML5批注规范,为各种类型的文件增加批注功能
59+
+ [ ] 升级数据库,增强搜索功能
6160

6261
#### 技术细节
6362
开发过程踩过许多坑,在填坑的同时记录下这些过程,以便其他开发者在做类似功能的时候能避免踩坑:

extension.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,24 @@ function isExclude(extension) {
9696

9797
function getBuildLog() {
9898
if (fs.existsSync(logfile)) {
99-
return JSON.parse(fs.readFileSync(logfile))
99+
const str = fs.readFileSync(logfile).toString('utf-8')
100+
return JSON.parse(str)
100101
}
101102
fs.writeFileSync(logfile, '{}')
102103
return {}
103104
}
104105

105-
function shouldUpdate(package, lasttime) {
106+
function shouldUpdate(extension, package, lasttime) {
106107
let buildHistory = getBuildLog()
107-
if (!buildHistory[package]) {
108-
buildHistory[package] = lasttime
108+
if (!buildHistory[extension]) {
109+
buildHistory[extension] = lasttime
109110
fs.writeFileSync(logfile, JSON.stringify(buildHistory))
111+
console.info('scan', package)
110112
return true
111113
}
112-
if (buildHistory[package] === lasttime) return false
113-
buildHistory[package] = lasttime
114+
if (buildHistory[extension] === lasttime) return false
115+
buildHistory[extension] = lasttime
116+
console.info(package, 'will be update')
114117
fs.writeFileSync(logfile, JSON.stringify(buildHistory))
115118
return true
116119
}
@@ -122,7 +125,7 @@ function parseExtensions() {
122125
if (isExclude(extension) || !stat || stat.isFile()) continue
123126
const packagePath = path.join(__dirname, './extensions/' + extension + '/package.json')
124127
const stime = stat.mtime / 1000
125-
if (shouldUpdate(packagePath, stime)) {
128+
if (shouldUpdate(extension, packagePath, stime)) {
126129
const pack = fs.readFileSync(packagePath, 'utf-8')
127130
const jsn = JSON.parse(pack)
128131
for (let name in jsn['dependencies']) {
@@ -143,9 +146,13 @@ function parseExtensions() {
143146

144147
function installDependencies() {
145148
for (let name in installPackages) {
146-
if (fs.existsSync(path.resolve(__dirname, './extensions/node_modules/' + name))) {
147-
const stat = fs.statSync(path.resolve(__dirname, './extensions/node_modules/' + name))
148-
if (stat.isFile() || stat.isDirectory()) continue
149+
const filepath = path.resolve(__dirname, './extensions/node_modules/' + name)
150+
if (fs.existsSync(filepath)) {
151+
const stat = fs.statSync(filepath)
152+
if (stat.isFile() || stat.isDirectory()) {
153+
console.info('file', filepath, 'exist')
154+
continue
155+
}
149156
}
150157
console.info(`install ${name}@${installPackages[name]}`)
151158
runCommand('npm install --prefix extensions ' + name + '@' + installPackages[name])

extensions/datetime_filter/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"main": "./index.js",
1010
"civet": {
1111
"activeEvents": [
12-
"onContentType:img/jpeg,jpg,jpeg,bmp,tif,tiff,png",
1312
"onView:Search",
1413
"onSave:"
1514
]

extensions/grid_view/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"main": "./index.js",
1010
"civet": {
1111
"activeEvents": [
12-
"onContentType:img/jpeg,jpg,jpeg,bmp,tif,tiff,png",
1312
"onView:Overview",
1413
"onSave:"
1514
],

extensions/imagedata/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class DataParser{
1717
const image = Sharp(filepath)
1818
let scale = 1
1919
const w = this.getNumberProperty(file, 'width')
20+
console.debug('image:', w, file)
2021
if (w > 200) {
2122
scale = 200.0 / w
2223
}

extensions/img_content_view/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"main": "./index.js",
1010
"civet": {
1111
"activeEvents": [
12-
"onContentType: jpeg,jpg,jpeg,bmp,tif,tiff,png",
1312
"onView: ContentView",
1413
"onSave:"
1514
]

extensions/map_view/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"main": "./index.js",
1010
"civet": {
1111
"activeEvents": [
12-
"onContentType:img/jpeg,jpg,jpeg,bmp,tif,tiff,png",
1312
"onView:Overview",
1413
"onSave:"
1514
],

extensions/map_view/view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<script type="text/javascript">
6666
MapLayout = (function() {
6767
let markers = []
68-
let map = new AMap.Map('container', {
68+
let map = new AMap.Map('__cv_map_container', {
6969
resizeEnable: true,
7070
center: [116.397428, 39.90923],
7171
zoom: 10

extensions/meta3d/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
"main": "./index.js",
1010
"civet": {
1111
"activeEvents": [
12-
"onContentType: glb,gltf",
1312
"onView: ContentView",
1413
"onSave:"
1514
]
1615
},
1716
"dependencies": {
18-
"vue-3d-model": "^1.4.0"
1917
}
2018
}

extensions/storage/index.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { IResource, ResourceProperty, PropertyType, window, utility } from 'civet'
2+
3+
function convert2ValidDate(str: string): string {
4+
if (str.match(/[0-9]{4}:[0-9]{2}:[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/g)) {
5+
// YYYY:MM:DD hh:mm:ss
6+
const year = str.substr(0, 4)
7+
const month = str.substr(5, 2)
8+
const day = str.substr(8, 2)
9+
return year + '/' + month + '/' + day + str.substr(10, 9)
10+
}
11+
return str
12+
}
13+
14+
let contentView = window.createContentView('3dContentView',
15+
['glb', 'gltf']);
16+
contentView.onViewInitialize(():string => {
17+
const fs = require('fs')
18+
const html = fs.readFileSync(utility.extensionPath + '/meta3d/content.html', 'utf-8')
19+
return html
20+
});
21+
22+
class MetaParser {
23+
constructor() {}
24+
25+
parse(filepath: string, file: IResource) {
26+
console.info('3D model:', filepath)
27+
}
28+
29+
}
30+
31+
export function activate() {
32+
const metaParser = new MetaParser()
33+
return {
34+
read: (filepath: string, resource: IResource) => {
35+
metaParser.parse(filepath, resource)
36+
return true
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)