Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
g122622 committed Aug 1, 2023
1 parent 0042b2f commit 2bc0e51
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gcrypt",
"version": "1.1.0",
"version": "1.2.0",
"private": false,
"author": "g122622",
"repository": "https://github.com/g122622/gcrypt",
Expand Down
8 changes: 6 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
<ContextMenuGlobalRenderArea />
<!-- 打开方式管理器 -->
<OpenMethodSelector />

<!-- 本次更新内容对话框 -->
<PostUpdateInfo />
<!-- 动态对话框 -->
<DialogGenerator v-for="item in dialogStore.dialogs" :key="item.guid" v-bind="item"></DialogGenerator>

<div :style="{ opacity: backgroundOpacity }">
<v-app>
Expand Down Expand Up @@ -40,6 +42,7 @@ import { useSettingsStore } from "./store/settings"
import { useMainStore } from "./store/main"
import { useRoute } from 'vue-router'
import hexToRGB from "@/utils/hexToRGB"
import { useDialogStore } from "@/store/dialog";
// 组件
import MsgContainer from "./components/Msg/MsgContainer.vue"
Expand All @@ -50,9 +53,11 @@ import SystemBar from "./components/SystemBar.vue"
import OpenMethodSelector from './components/Dialogs/OpenMethodSelector.vue';
import SideColumn from "./components/SideColumn.vue";
import PostUpdateInfo from './components/Dialogs/PostUpdateInfo.vue'
import DialogGenerator from './components/shared/DialogGenerator.vue'
const settingsStore = useSettingsStore()
const mainStore = useMainStore()
const dialogStore = useDialogStore()
const route = useRoute()
const finishLoading = ref<boolean>(false)
Expand All @@ -74,7 +79,6 @@ onMounted(async () => {
<style lang="less">
@import './styles/globalVariables.less';
@import './styles/globalVuetifyOverrides.less';
@import './styles/scrollbars.less';
html {
Expand Down
6 changes: 6 additions & 0 deletions src/api/hash/getDigest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import crypto from "crypto"

export default function getDigest(data: Buffer, digestType: string) {
const hash = crypto.createHash(digestType).update(data).digest("hex");
return hash
}
37 changes: 36 additions & 1 deletion src/api/registerBuiltinOpenMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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"

/**
* 注册内置方法
Expand Down Expand Up @@ -48,7 +49,41 @@ export default async function registerBulitinOpenMethods(mgr) {
icon: 'mdi-folder-pound',
fileType: /./,
async onSelected(file: File) {
// TODO const md5 = await getMD5(await file.read())
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}
<br/>
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}
<br/>
sha1: ${sha1}
`
})
}
})
mgr.registerMethod({
Expand Down
46 changes: 27 additions & 19 deletions src/assets/json/defaultSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,6 @@ import SettingTypes from "@/types/settingTypes"
const text = "孩提时,我有许多美丽的憧憬,天真的梦。那时,我最喜欢看天上的星河。夏夜仰望那缀满星星的夜空,我会几个小时地坐着发痴,小脑瓜里整个儿盘旋着关于星星月亮的种种神话传说。于是,我总相信月宫里有嫦娥,早晚有一天会从那影影绰绰的桂花树下飘飘走出,而那璀璨的星星呢,一定是那些调皮的小仙女随意抛洒的宝石珠贝。我很想什么时候飞上天去,抓住天幕的一角轻轻一抖,让这些明亮得耀眼的珠宝纷纷飞落下来,穿过云端,落到人间。"

const defaultSettings = <Array<settingItem>>[
{
name: "use_shade",
type: SettingTypes.switcher,
value: false,
title: "背景黑色遮罩",
des: "绘制一个纯黑色窗口,覆盖屏幕工作区域",
category: "通用"
},
{
name: "on_top",
type: SettingTypes.switcher,
value: true,
title: "窗口悬浮顶层",
des: "没什么好说的",
category: "通用",
},
{
name: "is_dark",
type: SettingTypes.switcher,
Expand All @@ -31,7 +15,7 @@ const defaultSettings = <Array<settingItem>>[
{
name: "theme_color",
type: SettingTypes.color,
value: "",
value: "#3949AB",
title: "主题色",
des: "选择的颜色将作为界面主色展示",
category: "外观"
Expand All @@ -47,7 +31,7 @@ const defaultSettings = <Array<settingItem>>[
{
name: "background_img_blur",
type: SettingTypes.slider,
value: "70",
value: "0",
title: "背景图片模糊度",
des: "给背景图加上指定半径的高斯模糊filter,并不会修改原文件",
category: "外观",
Expand All @@ -59,7 +43,7 @@ const defaultSettings = <Array<settingItem>>[
{
name: "background_img_transp",
type: SettingTypes.slider,
value: "80",
value: "85",
title: "背景图片透明度",
des: "调低调高都不好",
category: "外观",
Expand All @@ -76,6 +60,30 @@ const defaultSettings = <Array<settingItem>>[
des: "是否从网络获取并显示列表底部的装饰性句子",
category: "外观"
},
{
name: "use_shade",
type: SettingTypes.switcher,
value: false,
title: "背景黑色遮罩",
des: "绘制一个纯黑色窗口,覆盖屏幕工作区域",
category: "通用"
},
{
name: "on_top",
type: SettingTypes.switcher,
value: true,
title: "窗口悬浮顶层",
des: "没什么好说的",
category: "通用",
},
{
name: "content_protection",
type: SettingTypes.switcher,
value: true,
title: "窗口捕获保护",
des: "阻止外部应用截获窗口",
category: "安全",
},
{
name: "appointed_file_open_methods",
type: SettingTypes.text,
Expand Down
3 changes: 2 additions & 1 deletion src/assets/whatsNew.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
"1.0.2": ["新增更新详情弹框", "顶栏增加版本展示", "支持选择主题色"],
"1.1.0": ["侧边栏优化", "右键菜单弹出位置优化", "文件管理器滚动条修复", "文件管理器增加底部状态条",
"文件可以支持选择了", "支持回车键确定密码", "任务管理器支持状态显示", "修复bug", "列表查找性能优化"]
"文件可以支持选择了", "支持回车键确定密码", "任务管理器支持状态显示", "修复bug", "列表查找性能优化"],
"1.2.0": ["文件哈希现已开放", "新增功能:屏幕捕获防护", "更新内容UI展示优化"]
}
2 changes: 2 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ class ApplicationMain {
thisRef.mainWindow.setAlwaysOnTop(false)
}
break;
case "setContentProtectionState":
thisRef.mainWindow.setContentProtection(arg.data)
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/components/Dialogs/PostUpdateInfo.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<DialogGenerator :title="'新版本简介 v' + mainStore.appVersion" v-model:isDialogOpen="isShowing" height="350px" width="600px"
<DialogGenerator :title="'新版本简介 v' + mainStore.appVersion" v-model:isDialogOpen="isShowing" width="600px"
:isPersistent="false" :bottomActions="[{ text: '明白', onClick: () => { isShowing = false } }]">
<template #mainContent>
<div style="margin-bottom: 25px;">
Expand Down Expand Up @@ -30,7 +30,7 @@ const displayNextTime = computed<boolean>({
}
})
if (mainStore.appVersion !== mainStore.appVersionOld) {
if ((mainStore.appVersion !== mainStore.appVersionOld) || settingsStore.getSetting("always_display_update_info")) {
isShowing.value = true
}
Expand Down
14 changes: 12 additions & 2 deletions src/components/shared/DialogGenerator.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<v-dialog v-model="isDialogOpen" :persistent="props.isPersistent || false" :width="props.width || 600"
:height="props.height || 400">
:height="props.height">
<v-card density="compact">
<v-card-title>
<span class="text-h6">{{ props.title }}</span>
Expand All @@ -9,6 +9,7 @@
<v-container>
<v-row>
<slot name="mainContent" />
<span v-if="!!props.HTMLContent" v-html="props.HTMLContent"></span>
</v-row>
</v-container>
<slot name="footer" />
Expand All @@ -28,6 +29,7 @@
<script setup lang="ts">
import { computed } from "vue"
import dialogBottomAction from "@/types/dialogBottomAction"
import { useDialogStore } from "@/store/dialog";
interface Props {
isDialogOpen: boolean,
Expand All @@ -36,15 +38,23 @@ interface Props {
bottomActions?: Array<dialogBottomAction>,
isPersistent?: boolean,
width?: string,
height?: string
height?: string,
guid?: string,
destroyAfterClose?: boolean,
HTMLContent?: string,
}
const props = defineProps<Props>()
const emit = defineEmits(['update:isDialogOpen'])
const dialogStore = useDialogStore()
const isDialogOpen = computed({
get() {
return props.isDialogOpen
},
set(value) {
// 检测到对话框关闭
if (!value && props.destroyAfterClose) {
dialogStore.remove(props.guid)
}
emit('update:isDialogOpen', value)
}
})
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class Application {
vuetify.theme.global.name.value = 'LightTheme'
document.querySelector("#app").setAttribute("data-theme-type", "light")
}
// 内容保护
Electron.ipcRenderer.send('mainService', { code: "setContentProtectionState", data: this.SettingsStore.getSetting("content_protection") })
}, 100)
}

Expand Down
40 changes: 40 additions & 0 deletions src/store/dialog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import dialogBottomAction from '@/types/dialogBottomAction'
import { defineStore } from 'pinia'
import sharedUtils from "@/utils/sharedUtils";

interface Dialog {
isDialogOpen: boolean,
footer?: string,
title: string,
bottomActions?: Array<dialogBottomAction>,
isPersistent?: boolean,
width?: string,
height?: string,
destroyAfterClose: boolean,
HTMLContent?: string,
guid: string
}

export const useDialogStore = defineStore("dialog", {
state() {
return {
dialogs: new Set() as Set<Dialog>
}
},
actions: {
addDialog(dialog: Omit<Dialog, "guid">) {
const guid = sharedUtils.getHash(16)
this.dialogs.add({ ...dialog, guid })
},
remove(guid: string) {
let tmp = null
this.dialogs.forEach(item => {
if (item.guid === guid) {
tmp = item
}
})
this.dialogs.delete(tmp)
}
}
}
)

0 comments on commit 2bc0e51

Please sign in to comment.