From c365ebc2c58554908d8fd1495cd1b05c242dc5a9 Mon Sep 17 00:00:00 2001
From: g122622 <51020363+g122622@users.noreply.github.com>
Date: Fri, 25 Aug 2023 09:31:10 +0800
Subject: [PATCH] v2.0.0
---
.gitignore | 11 +-
package.json | 143 +++++++++---------
public/index.html | 7 +-
src/api/registerBuiltinOpenMethods.ts | 93 ++++++------
src/assets/whatsNew.ts | 2 +-
src/background.js | 1 +
src/components/AceEditor/AceEditor.vue | 36 +++++
src/components/BuiltinFilePicker.vue | 4 +-
src/components/Dialogs/OpenMethodSelector.vue | 13 +-
src/components/FileMgr/FileMgr.vue | 25 ++-
src/components/FroalaEditor/FroalaEditor.vue | 2 +-
src/components/MonacoEditor/MonacoEditor.vue | 41 -----
.../MonacoEditor/MonacoEditorOld.vue | 57 -------
src/components/shared/ContextMenu.vue | 3 +-
src/ctx.d.ts | 1 +
src/utils/getExtName.ts | 1 +
src/utils/shell/pickFile.ts | 5 +-
17 files changed, 216 insertions(+), 229 deletions(-)
create mode 100644 src/components/AceEditor/AceEditor.vue
delete mode 100644 src/components/MonacoEditor/MonacoEditor.vue
delete mode 100644 src/components/MonacoEditor/MonacoEditorOld.vue
diff --git a/.gitignore b/.gitignore
index c148942..1b8c659 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,4 +23,13 @@ pnpm-debug.log*
*.sw?
#Electron-builder output
-/dist_electron
\ No newline at end of file
+/dist_electron
+.VSCodeCounter/2023-08-18_16-41-55/details.md
+.VSCodeCounter/2023-08-18_16-41-55/diff-details.md
+.VSCodeCounter/2023-08-18_16-41-55/diff.csv
+.VSCodeCounter/2023-08-18_16-41-55/diff.md
+.VSCodeCounter/2023-08-18_16-41-55/diff.txt
+.VSCodeCounter/2023-08-18_16-41-55/results.csv
+.VSCodeCounter/2023-08-18_16-41-55/results.json
+.VSCodeCounter/2023-08-18_16-41-55/results.md
+.VSCodeCounter/2023-08-18_16-41-55/results.txt
diff --git a/package.json b/package.json
index 4573c26..7cd4084 100644
--- a/package.json
+++ b/package.json
@@ -1,71 +1,74 @@
{
- "name": "gcrypt",
- "version": "2.0.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": {
- "@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-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
- ]
- }
-}
\ No newline at end of file
+ "name": "gcrypt",
+ "version": "2.0.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": {
+ "@mdi/font": "5.9.55",
+ "ace-builds": "^1.24.1",
+ "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",
+ "get-windows-shortcut-properties": "^1.1.0",
+ "lodash": "^4.17.21",
+ "mitt": "^3.0.0",
+ "pinia": "^2.1.3",
+ "roboto-fontface": "*",
+ "vue": "^3.3.4",
+ "vue-router": "^4.0.3",
+ "vue3-ace-editor": "^2.2.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
+ ]
+ }
+}
diff --git a/public/index.html b/public/index.html
index 0db037e..9f7702c 100644
--- a/public/index.html
+++ b/public/index.html
@@ -52,6 +52,11 @@
font-style: normal
}
+
+
-
\ No newline at end of file
+
+
+
+
diff --git a/src/api/registerBuiltinOpenMethods.ts b/src/api/registerBuiltinOpenMethods.ts
index 60ee175..696a33c 100644
--- a/src/api/registerBuiltinOpenMethods.ts
+++ b/src/api/registerBuiltinOpenMethods.ts
@@ -4,10 +4,9 @@ import ImageViewer from "@/components/ImageViewer/ImageViewer.vue"
import File from "@/api/File";
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 pickFile from "@/utils/shell/pickFile";
-import path from 'path'
+import AceEditor from "@/components/AceEditor/AceEditor.vue";
/**
* 注册内置方法
@@ -46,48 +45,6 @@ export default async function registerBulitinOpenMethods(mgr) {
)
}
})
- mgr.registerMethod({
- name: "生成md5值",
- icon: 'mdi-folder-pound',
- fileType: /./,
- async onSelected(file: File) {
- const dialogStore = (await import("@/store/dialog")).useDialogStore()
- const md5 = await getDigest(await file.read(), 'md5')
- dialogStore.addDialog({
- isPersistent: false,
- isDialogOpen: true,
- title: 'md5生成结果',
- destroyAfterClose: true,
- width: '450px',
- // height: '250px',
- HTMLContent: `文件名: ${file.filename}
-
- md5: ${md5}
- `
- })
- }
- })
- mgr.registerMethod({
- name: "生成sha1值",
- icon: 'mdi-folder-pound',
- fileType: /./,
- async onSelected(file: File) {
- const dialogStore = (await import("@/store/dialog")).useDialogStore()
- const sha1 = await getDigest(await file.read(), 'sha1')
- dialogStore.addDialog({
- isPersistent: false,
- isDialogOpen: true,
- title: 'sha1生成结果',
- destroyAfterClose: true,
- width: '550px',
- // height: '250px',
- HTMLContent: `文件名: ${file.filename}
-
- sha1: ${sha1}
- `
- })
- }
- })
mgr.registerMethod({
name: "外部打开(写入本地文件系统缓存,并监听写入以同步)",
icon: 'mdi-open-in-new',
@@ -114,14 +71,14 @@ export default async function registerBulitinOpenMethods(mgr) {
}
})
mgr.registerMethod({
- name: "MonacoEditor",
+ name: "AceEditor",
icon: 'mdi-microsoft-visual-studio-code',
fileType: ['txt', 'html', 'js', 'json', 'vue', 'ts'],
async onSelected(file: File) {
emitter.emit("Action::addTab",
{
- name: 'MonacoEditor-' + file.filename,
- component: MonacoEditor,
+ name: 'AceEditor-' + file.filename,
+ component: AceEditor,
icon: "mdi-microsoft-visual-studio-code",
onClick: () => null,
props: { file }
@@ -138,4 +95,46 @@ export default async function registerBulitinOpenMethods(mgr) {
await file.exportToExt(directory)
}
})
+ mgr.registerMethod({
+ name: "生成md5值",
+ icon: 'mdi-folder-pound',
+ fileType: /./,
+ async onSelected(file: File) {
+ const dialogStore = (await import("@/store/dialog")).useDialogStore()
+ const md5 = await getDigest(await file.read(), 'md5')
+ dialogStore.addDialog({
+ isPersistent: false,
+ isDialogOpen: true,
+ title: 'md5生成结果',
+ destroyAfterClose: true,
+ width: '450px',
+ // height: '250px',
+ HTMLContent: `文件名: ${file.filename}
+
+ md5: ${md5}
+ `
+ })
+ }
+ })
+ mgr.registerMethod({
+ name: "生成sha1值",
+ icon: 'mdi-folder-pound',
+ fileType: /./,
+ async onSelected(file: File) {
+ const dialogStore = (await import("@/store/dialog")).useDialogStore()
+ const sha1 = await getDigest(await file.read(), 'sha1')
+ dialogStore.addDialog({
+ isPersistent: false,
+ isDialogOpen: true,
+ title: 'sha1生成结果',
+ destroyAfterClose: true,
+ width: '550px',
+ // height: '250px',
+ HTMLContent: `文件名: ${file.filename}
+
+ sha1: ${sha1}
+ `
+ })
+ }
+ })
}
diff --git a/src/assets/whatsNew.ts b/src/assets/whatsNew.ts
index 9ca92d9..1285c5a 100644
--- a/src/assets/whatsNew.ts
+++ b/src/assets/whatsNew.ts
@@ -7,5 +7,5 @@ export default {
"1.3.1": ['应用锁bug修复'],
"1.4.0": ['支持从外部拖入文件以导入', "完全重写加密引擎,支持异步加密,且显著优化输出文件大小", "改正一处错别字", "临时文件自动销毁"],
"1.5.0": ['若干bug和细节修复', '任务处理并行化,显著提高运行效率', '支持导出文件', '支持快捷打开store所在的目录'],
- "2.0.0": ['若干bug和细节修复', '增加内置文件选择器', '内置浏览器可用'],
+ "2.0.0": ['若干bug和细节修复', '增加内置文件选择器', '内置浏览器可用', '内置代码编辑器可用'],
}
diff --git a/src/background.js b/src/background.js
index f58ec6b..6e2567e 100644
--- a/src/background.js
+++ b/src/background.js
@@ -60,6 +60,7 @@ class ApplicationMain {
nodeIntegration: true,
contextIsolation: false,
devTools: true,
+ webSecurity: false
}
})
diff --git a/src/components/AceEditor/AceEditor.vue b/src/components/AceEditor/AceEditor.vue
new file mode 100644
index 0000000..8fa54ad
--- /dev/null
+++ b/src/components/AceEditor/AceEditor.vue
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/BuiltinFilePicker.vue b/src/components/BuiltinFilePicker.vue
index 0c9b160..68cee5c 100644
--- a/src/components/BuiltinFilePicker.vue
+++ b/src/components/BuiltinFilePicker.vue
@@ -36,7 +36,7 @@ const filePickers = ref<{
emitter.on("Action::openFilePicker", async ({ directory, taskId, onlyAllowFolderSelection, allowMultipleSelection }) => {
const adapter = new Adapter()
- await adapter.initAdapter(directory)
+ await adapter.initAdapter(directory ?? "/")
filePickers.value.push({
isDialogOpen: true,
adapter,
@@ -63,6 +63,8 @@ emitter.on("Action::openFilePicker", async ({ directory, taskId, onlyAllowFolder
filePickers.value.find(item => item.taskId === taskId).isDialogOpen = false
},
cancellHandler: () => {
+ emitter.emit("Action::filePickerCancelled" + taskId)
+ emitter.off("Action::filePickerCancelled" + taskId)
filePickers.value.find(item => item.taskId === taskId).isDialogOpen = false
}
})
diff --git a/src/components/Dialogs/OpenMethodSelector.vue b/src/components/Dialogs/OpenMethodSelector.vue
index d104bf8..1d90090 100644
--- a/src/components/Dialogs/OpenMethodSelector.vue
+++ b/src/components/Dialogs/OpenMethodSelector.vue
@@ -11,6 +11,10 @@
+
+ 显示所有
+
+
@@ -32,6 +36,7 @@ const store = useSettingsStore()
const fileType = ref('')
const isShowing = ref(false)
const isRememberMethod = ref(false)
+const isShowingAllMethods = ref(false)
const openMethodMgr = new OpenMethodMgr()
let currentFile: File = null
let currentExtra = null
@@ -42,7 +47,11 @@ const appointedFileOpenMethods = computed(() => {
// 用于显示的列表
const methodsList = computed(() => {
- return openMethodMgr.getMatchedMethod(fileType.value)
+ if (isShowingAllMethods.value) {
+ return openMethodMgr.getMatchedMethod("")
+ } else {
+ return openMethodMgr.getMatchedMethod(fileType.value)
+ }
})
// 设置记住的打开方式
@@ -68,6 +77,8 @@ onMounted(() => {
currentFile = fileArg
currentExtra = extraArg
fileType.value = fileTypeArg
+ isRememberMethod.value = false
+ isShowingAllMethods.value = false
if (Object.hasOwn(appointedFileOpenMethods.value, fileTypeArg)) {
const name = appointedFileOpenMethods.value[fileTypeArg]
openMethodMgr.getMethodByName(name).onSelected(currentFile, currentExtra)
diff --git a/src/components/FileMgr/FileMgr.vue b/src/components/FileMgr/FileMgr.vue
index 38a204c..15df25e 100644
--- a/src/components/FileMgr/FileMgr.vue
+++ b/src/components/FileMgr/FileMgr.vue
@@ -157,6 +157,8 @@ import prettyBytes from "@/utils/prettyBytes";
import notification from "@/api/notification";
import pickFile from "@/utils/shell/pickFile";
import { FileMgrOptions } from "./types/FileMgrOptions"
+import getWindowsShortcutProperties from 'get-windows-shortcut-properties'
+import path from 'path'
import ContextMenu from "../shared/ContextMenu.vue";
import FileItem from "./FileItem.vue";
@@ -263,6 +265,15 @@ const back = () => {
}
const openFile = (filename, fileguid) => {
+ // 先判断是否为快捷方式,是的话则跳转
+ if (process.platform === 'win32' && getExtName(filename) === 'lnk') {
+ const output = getWindowsShortcutProperties.sync(path.join(currentDir.value.toPathStr(), filename));
+ if (output) {
+ currentDir.value = new Addr(output[0].TargetPath)
+ return
+ }
+ }
+
const fileArg = new File(fileguid)
fileArg.fromAdapter(props.adapter, filename)
@@ -633,12 +644,14 @@ const handleExtDrop = async (event) => {
// <文件导出>
const handleFileExport = async () => {
- const directory = (await pickFile("G:/", true, false, true))[0]
- selectedItems.value.forEach(item => {
- const file = new File()
- file.fromAdapter(props.adapter, item.name)
- file.exportToExt(directory)
- })
+ try {
+ const directory = (await pickFile(null, true, false, true))[0]
+ selectedItems.value.forEach(item => {
+ const file = new File()
+ file.fromAdapter(props.adapter, item.name)
+ file.exportToExt(directory)
+ })
+ } catch (e) { }
}
diff --git a/src/components/FroalaEditor/FroalaEditor.vue b/src/components/FroalaEditor/FroalaEditor.vue
index c07da4d..1a72121 100644
--- a/src/components/FroalaEditor/FroalaEditor.vue
+++ b/src/components/FroalaEditor/FroalaEditor.vue
@@ -5,7 +5,7 @@
diff --git a/src/components/MonacoEditor/MonacoEditorOld.vue b/src/components/MonacoEditor/MonacoEditorOld.vue
deleted file mode 100644
index f922172..0000000
--- a/src/components/MonacoEditor/MonacoEditorOld.vue
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/src/components/shared/ContextMenu.vue b/src/components/shared/ContextMenu.vue
index 6629ad2..3d24bc3 100644
--- a/src/components/shared/ContextMenu.vue
+++ b/src/components/shared/ContextMenu.vue
@@ -19,7 +19,8 @@
-
+
diff --git a/src/ctx.d.ts b/src/ctx.d.ts
index 0c64a76..4e680e4 100644
--- a/src/ctx.d.ts
+++ b/src/ctx.d.ts
@@ -6,3 +6,4 @@ declare const COMPILE_ENV: string
declare const COMPILE_CPU: string
declare const COMPILE_MEM: string
declare const FroalaEditor: any
+declare const ace: any
diff --git a/src/utils/getExtName.ts b/src/utils/getExtName.ts
index b450e03..e90770f 100644
--- a/src/utils/getExtName.ts
+++ b/src/utils/getExtName.ts
@@ -1,4 +1,5 @@
function getExtName(arg: string) {
+ if (!arg) return arg
const tokens = arg.split(".")
if (tokens.length <= 1) {
return ""
diff --git a/src/utils/shell/pickFile.ts b/src/utils/shell/pickFile.ts
index 7831590..afa6127 100644
--- a/src/utils/shell/pickFile.ts
+++ b/src/utils/shell/pickFile.ts
@@ -2,13 +2,16 @@ import emitter from "@/eventBus"
import sharedUtils from "../sharedUtils"
export default function pickFile(directory: string, onlyAllowFolderSelection: boolean, allowMultipleSelection: boolean, useBuiltin = true): Promise {
- return new Promise((resolve) => {
+ return new Promise((resolve, reject) => {
if (useBuiltin) {
const taskId = sharedUtils.getHash(16)
emitter.emit("Action::openFilePicker", { directory, taskId, onlyAllowFolderSelection, allowMultipleSelection })
emitter.on("Action::filePicked" + taskId, (result: string[]) => {
resolve(result)
})
+ emitter.on("Action::filePickerCancelled" + taskId, () => {
+ reject(new Error("filePickerCancelled"))
+ })
} else {
const inputElement = document.createElement("input")
inputElement.type = 'file'