Skip to content

Commit

Permalink
v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
g122622 committed Aug 11, 2023
1 parent f65eff5 commit fd8bda8
Show file tree
Hide file tree
Showing 15 changed files with 277 additions and 184 deletions.
144 changes: 72 additions & 72 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
{
"name": "gcrypt",
"version": "1.4.0",
"private": false,
"author": "g122622",
"repository": "https://github.com/g122622/gcrypt",
"scripts": {
"serve": "SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts vue-cli-service serve",
"build": "SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts vue-cli-service build",
"lint": "SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts vue-cli-service lint",
"electron:build": "vue-cli-service electron:build",
"electron:serve": "vue-cli-service electron:serve",
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps"
},
"main": "background.js",
"dependencies": {
"@konghayao/vue-monaco-editor": "^3.0.3",
"@mdi/font": "5.9.55",
"axios": "^1.4.0",
"chart.js": "^4.3.0",
"core-js": "^3.8.3",
"dayjs": "^1.11.7",
"electron-store": "^8.1.0",
"fs-extra": "^11.1.0",
"lodash": "^4.17.21",
"mitt": "^3.0.0",
"pinia": "^2.1.3",
"roboto-fontface": "*",
"vue": "^3.3.4",
"vue-monaco-editor": "^0.0.19",
"vue-router": "^4.0.3",
"vuetify": "^3.0.0-beta.0",
"webfontloader": "^1.0.0"
},
"devDependencies": {
"@types/electron-devtools-installer": "^2.2.0",
"@types/webfontloader": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-plugin-typescript": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"@vue/eslint-config-standard": "^6.1.0",
"@vue/eslint-config-typescript": "^9.1.0",
"electron": "21.0.0",
"electron-devtools-installer": "^3.1.0",
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-vue": "^8.0.3",
"less": "^4.1.3",
"less-loader": "^11.1.0",
"typescript": "~4.5.5",
"vue-cli-plugin-electron-builder": "^2.1.1",
"vue-cli-plugin-vuetify": "~2.5.8",
"webpack-plugin-vuetify": "^2.0.0-alpha.0"
},
"binary": {
"module_name": "node_sqlite3",
"module_path": "./lib/binding/napi-v{napi_build_version}-{platform}-{libc}-{arch}",
"host": "https://github.com/TryGhost/node-sqlite3/releases/download/",
"remote_path": "v{version}",
"package_name": "napi-v{napi_build_version}-{platform}-{libc}-{arch}.tar.gz",
"napi_versions": [
3,
6
]
}
}
"name": "gcrypt",
"version": "1.5.0",
"private": false,
"author": "g122622",
"repository": "https://github.com/g122622/gcrypt",
"scripts": {
"serve": "SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts vue-cli-service serve",
"build": "SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts vue-cli-service build",
"lint": "SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts vue-cli-service lint",
"electron:build": "vue-cli-service electron:build",
"electron:serve": "vue-cli-service electron:serve",
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps"
},
"main": "background.js",
"dependencies": {
"@konghayao/vue-monaco-editor": "^3.0.3",
"@mdi/font": "5.9.55",
"axios": "^1.4.0",
"chart.js": "^4.3.0",
"core-js": "^3.8.3",
"dayjs": "^1.11.7",
"electron-store": "^8.1.0",
"fs-extra": "^11.1.0",
"lodash": "^4.17.21",
"mitt": "^3.0.0",
"pinia": "^2.1.3",
"roboto-fontface": "*",
"vue": "^3.3.4",
"vue-monaco-editor": "^0.0.19",
"vue-router": "^4.0.3",
"vuetify": "^3.3.11",
"webfontloader": "^1.0.0"
},
"devDependencies": {
"@types/electron-devtools-installer": "^2.2.0",
"@types/webfontloader": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-plugin-typescript": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"@vue/eslint-config-standard": "^6.1.0",
"@vue/eslint-config-typescript": "^9.1.0",
"electron": "21.0.0",
"electron-devtools-installer": "^3.1.0",
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-vue": "^8.0.3",
"less": "^4.1.3",
"less-loader": "^11.1.0",
"typescript": "~4.5.5",
"vue-cli-plugin-electron-builder": "^2.1.1",
"vue-cli-plugin-vuetify": "~2.5.8",
"webpack-plugin-vuetify": "^2.0.0-alpha.0"
},
"binary": {
"module_name": "node_sqlite3",
"module_path": "./lib/binding/napi-v{napi_build_version}-{platform}-{libc}-{arch}",
"host": "https://github.com/TryGhost/node-sqlite3/releases/download/",
"remote_path": "v{version}",
"package_name": "napi-v{napi_build_version}-{platform}-{libc}-{arch}.tar.gz",
"napi_versions": [
3,
6
]
}
}
15 changes: 15 additions & 0 deletions src/api/File.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { useSettingsStore } from "@/store/settings"
import { useMainStore } from "@/store/main"
import emitter from "@/eventBus";
import Addr from "./core/common/Addr";
import { useTaskStore } from '@/store/task'
import Task from "./Task";

let taskStore = null
let settingsStore = null
let mainStore = null

Expand All @@ -24,6 +27,7 @@ enum FileType {
emitter.on('LifeCycle::finishedLoadingApp', () => {
settingsStore = useSettingsStore(window['pinia'])
mainStore = useMainStore(window['pinia'])
taskStore = useTaskStore(window['pinia'])
})

class File {
Expand Down Expand Up @@ -131,6 +135,17 @@ class File {
}
}

/**
* 导出文件到外部
* @param path 不包含文件名称!
*/
public async exportToExt(folderPath: string) {
const destPath = path.join(folderPath, this.filename ?? sharedUtils.getHash(7))
taskStore.addTask(new Task(async () => {
await fs.writeFile(destPath, await this.read())
}, `导出文件 ${destPath}`), { runImmediately: true })
}

public destroy() {
// 先销毁文件watcher,再删除临时文件,
// 若顺序颠倒则会在删除的时候触动fileWatcher
Expand Down
1 change: 1 addition & 0 deletions src/api/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Task {
this.state = 'succeed'
} catch (err) {
this.state = 'failed'
this.lastError = err
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/api/core/types/EntryJson.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
interface EntryJson {
modifiedTime:number,
modifiedTime: number,
createdTime: number,
accessedTime: number,
storageName:string,
storageName: string,
comment: string,
storeType: string,
config: {
Expand Down
11 changes: 11 additions & 0 deletions src/api/registerBuiltinOpenMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Electron from 'electron'
import FroalaEditor from "@/components/FroalaEditor/FroalaEditor.vue";
import MonacoEditor from "@/components/MonacoEditor/MonacoEditor.vue";
import getDigest from "@/api/hash/getDigest"
import selectFile from "@/utils/shell/selectFile";
import path from 'path'

/**
* 注册内置方法
Expand Down Expand Up @@ -127,4 +129,13 @@ export default async function registerBulitinOpenMethods(mgr) {
)
}
})
mgr.registerMethod({
name: "导出文件到外部",
icon: 'mdi-export-variant',
fileType: /./,
async onSelected(file: File) {
const directory = path.dirname((await selectFile(true))[0].path)
await file.exportToExt(directory)
}
})
}
3 changes: 2 additions & 1 deletion src/assets/whatsNew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export default {
"1.2.0": ["文件哈希现已开放", "新增功能:屏幕捕获防护", "更新内容UI展示优化"],
"1.3.0": ["支持窗口锁定(应用锁)"],
"1.3.1": ['应用锁bug修复'],
"1.4.0": ['支持从外部拖入文件以导入', "完全重写加密引擎,支持异步加密,且显著优化输出文件大小", "改正一处错别字", "临时文件自动销毁"]
"1.4.0": ['支持从外部拖入文件以导入', "完全重写加密引擎,支持异步加密,且显著优化输出文件大小", "改正一处错别字", "临时文件自动销毁"],
"1.5.0": ['若干bug和细节修复', '任务处理并行化,显著提高运行效率', '支持导出文件', '支持快捷打开store所在的目录']
}
82 changes: 57 additions & 25 deletions src/components/FileMgr/FileMgr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@
<!-- 顶部工具栏 -->
<v-app-bar density="compact">
<!-- 导航按钮组 -->
<v-btn icon @click="back()">
<v-icon>mdi-arrow-left</v-icon>
<v-tooltip activator="parent" location="bottom">后退</v-tooltip>
</v-btn>
<v-btn icon @click="up()">
<v-icon>mdi-arrow-up</v-icon>
<v-tooltip activator="parent" location="bottom">上一级目录</v-tooltip>
</v-btn>
<IconBtn icon="mdi-arrow-left" tooltip="后退" @click="back()"></IconBtn>
<IconBtn icon="mdi-arrow-up" tooltip="上一级目录" @click="up()"></IconBtn>
<!-- 布局按钮组 -->
<v-menu>
<template v-slot:activator="{ props }">
Expand Down Expand Up @@ -75,11 +69,12 @@
</v-list>
</v-menu>
<!-- 引入按钮 -->
<v-btn icon @click="handleFileImportClick()">
<IconBtn icon="mdi-import" tooltip="从外部引入文件" @click="handleFileImportClick()">
<input type="file" id='file-import' style="display: none;" multiple />
<v-icon>mdi-import</v-icon>
<v-tooltip activator="parent" location="bottom">从外部引入文件</v-tooltip>
</v-btn>
</IconBtn>
<!-- 导出按钮 -->
<IconBtn icon="mdi-export-variant" tooltip="导出文件" @click="handleFileExport()"
:disabled="!selectedItems.size"></IconBtn>
<!-- 地址栏 -->
<div style="margin-left: 15px;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;">
<v-icon>mdi-map-marker</v-icon>
Expand All @@ -89,10 +84,7 @@
</div>
<v-spacer></v-spacer>
<!-- 刷新按钮 -->
<v-btn icon @click="refresh()">
<v-icon>mdi-refresh</v-icon>
<v-tooltip activator="parent" location="bottom">刷新内容</v-tooltip>
</v-btn>
<IconBtn icon="mdi-refresh" tooltip="刷新内容" @click="refresh()"></IconBtn>
</v-app-bar>

<!-- 主内容区 -->
Expand Down Expand Up @@ -146,9 +138,10 @@

<script setup lang="ts">
import { ref, computed, watch, reactive, onMounted } from "vue";
import Addr from "@/api/core/common/Addr"
import Addr from "@/api/core/common/Addr";
import getFileName from "@/utils/getFileName";
import fs from "fs-extra";
import path from 'path';
import Electron from "electron";
import lodash from "lodash";
import dirSingleItem from "@/api/core/types/dirSingleItem";
Expand All @@ -161,12 +154,13 @@ import { useTaskStore } from '@/store/task'
import Task from "@/api/Task";
import sharedUtils from "@/utils/sharedUtils";
import prettyBytes from "@/utils/prettyBytes";
import notification from "@/api/notification";
import selectFile from "@/utils/shell/selectFile";
import ContextMenu from "../shared/ContextMenu.vue";
import FileItem from "./FileItem.vue"
import FileItem from "./FileItem.vue";
import DialogMgr from "./DialogMgr.vue";
import BottomBar from "./BottomBar.vue"
import notification from "@/api/notification";
import BottomBar from "./BottomBar.vue";
interface Props {
adapter: AdapterBase
Expand Down Expand Up @@ -288,11 +282,29 @@ const importFile = async (files: FileList) => {
}
const deleteFile = async () => {
for (let item of selectedItems.value) {
await props.adapter.deleteFile(item.name)
await deleteThumbnail(item.key)
if (selectedItems.value.size === 0) {
return
}
const taskGroupId = sharedUtils.getHash(16)
for (const item of selectedItems.value) {
taskStore.addTask(new Task(async () => {
await props.adapter.deleteFile(item.name)
await deleteThumbnail(item.key)
}, `删除文件 ${item.name}`, taskGroupId), { runImmediately: false })
}
try {
await taskStore.runTaskGroup(taskGroupId)
} catch (error) {
emitter.emit("showMsg",
{
level: "error",
msg: `删除文件失败 ${error.message}`
})
return
} finally {
await refresh()
}
await refresh()
notification.success(`删除文件成功`)
}
// <UI>
Expand Down Expand Up @@ -514,9 +526,19 @@ const getThumbnail = async (filePath: string): Promise<Buffer> => {
}
const saveThumbnailFile = async () => {
await props.adapter.writeFile(".thumbnails", JSON.stringify(thumbnails.value))
const str = JSON.stringify(thumbnails.value)
if (str === '{}') {
await props.adapter.deleteFile(".thumbnails")
} else {
await props.adapter.writeFile(".thumbnails", str)
}
}
/**
* add缩略图。支持新增/更新
* @param key
* @param thumbnail
*/
const addThumbnail = async (key: string, thumbnail: Buffer) => {
if (thumbnail) {
thumbnails.value[key] = thumbnail.toString('base64')
Expand Down Expand Up @@ -560,6 +582,16 @@ const handleExtDrop = async (event) => {
event.preventDefault()
await importFile(event.dataTransfer.files)
}
// <文件导出>
const handleFileExport = async () => {
const directory = path.dirname((await selectFile(true))[0].path)
selectedItems.value.forEach(item => {
const file = new File()
file.fromAdapter(props.adapter, item.name)
file.exportToExt(directory)
})
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
Expand Down
1 change: 0 additions & 1 deletion src/components/SideColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import TabsMgr from '@/components/TabsMgr.vue';
import TaskMgr from "./TaskMgr.vue";
import FileStateManager from "@/components/FileStateManager.vue";
import { useRouter } from 'vue-router';
import sleep from "@/utils/sleep";
const router = useRouter()
const isSideDrawerOpen = ref<boolean>(true)
Expand Down
Loading

0 comments on commit fd8bda8

Please sign in to comment.