{{ props.title }}
4 |
18 |
19 | ### Mac
20 |
21 |
22 | ## 启动
23 | ```
24 | yarn serve
25 | ```
26 |
27 | ## 打包
28 | ```
29 | yarn build
30 | ```
31 |
32 | ## 教程
33 | 【electron+vue3+ts实战便笺exe】一、搭建框架配置
34 | https://juejin.cn/post/6909723449246089224
35 |
36 | 【electron+vue3+ts实战便笺exe】二、electron+vue3开发内容
37 | https://juejin.cn/post/6909725365107687431
38 |
39 | 【electron+vue3+ts实战便笺exe】终章:markdown编辑器以及右键功能实现
40 | https://juejin.cn/post/7187704994731130938
41 |
42 | 
43 |
44 | ```
45 | electron-vue3-inote
46 | ├── babel.config.js
47 | ├── package.json
48 | ├── public
49 | │ ├── css
50 | │ ├── favicon.ico
51 | │ ├── font
52 | │ └── index.html
53 | ├── script # 打包删除脚本
54 | │ └── deleteBuild.js
55 | ├── src
56 | │ ├── App.vue
57 | │ ├── assets
58 | │ ├── background.ts
59 | │ ├── components
60 | │ ├── config # electron和软件的一些配置项
61 | │ ├── less
62 | │ ├── main.ts
63 | │ ├── router # 路由
64 | │ ├── service # 存放sqlite3 db服务
65 | │ ├── shims-vue.d.ts
66 | │ ├── store
67 | │ ├── types
68 | │ ├── utils
69 | │ └── views
70 | ├── tsconfig.json
71 | └── vue.config.js
72 | ```
73 |
--------------------------------------------------------------------------------
/public/3.8.10/dist/js/i18n/zh_CN.js:
--------------------------------------------------------------------------------
1 | window.VditorI18n = {
2 | 'alignCenter': '居中',
3 | 'alignLeft': '居左',
4 | 'alignRight': '居右',
5 | 'alternateText': '替代文本',
6 | 'bold': '粗体',
7 | 'both': '编辑 & 预览',
8 | 'check': '任务列表',
9 | 'close': '关闭',
10 | 'code': '代码块',
11 | 'code-theme': '代码块主题预览',
12 | 'column': '列',
13 | 'comment': '评论',
14 | 'confirm': '确定',
15 | 'content-theme': '内容主题预览',
16 | 'copied': '已复制',
17 | 'copy': '复制',
18 | 'delete-column': '删除列',
19 | 'delete-row': '删除行',
20 | 'devtools': '开发者工具',
21 | 'down': '下',
22 | 'downloadTip': '该浏览器不支持下载功能',
23 | 'edit': '编辑',
24 | 'edit-mode': '切换编辑模式',
25 | 'emoji': '表情',
26 | 'export': '导出',
27 | 'fileTypeError': '文件类型不允许上传,请压缩后再试',
28 | 'footnoteRef': '脚注标识',
29 | 'fullscreen': '全屏切换',
30 | 'generate': '生成中',
31 | 'headings': '标题',
32 | 'heading1': '一级标题',
33 | 'heading2': '二级标题',
34 | 'heading3': '三级标题',
35 | 'heading4': '四级标题',
36 | 'heading5': '五级标题',
37 | 'heading6': '六级标题',
38 | 'help': '帮助',
39 | 'imageURL': '图片地址',
40 | 'indent': '列表缩进',
41 | 'info': '关于',
42 | 'inline-code': '行内代码',
43 | 'insert-after': '末尾插入行',
44 | 'insert-before': '起始插入行',
45 | 'insertColumnLeft': '在左边插入一列',
46 | 'insertColumnRight': '在右边插入一列',
47 | 'insertRowAbove': '在上方插入一行',
48 | 'insertRowBelow': '在下方插入一行',
49 | 'instantRendering': '即时渲染',
50 | 'italic': '斜体',
51 | 'language': '语言',
52 | 'line': '分隔线',
53 | 'link': '链接',
54 | 'linkRef': '引用标识',
55 | 'list': '无序列表',
56 | 'more': '更多',
57 | 'nameEmpty': '文件名不能为空',
58 | 'ordered-list': '有序列表',
59 | 'outdent': '列表反向缩进',
60 | 'outline': '大纲',
61 | 'over': '超过',
62 | 'performanceTip': '实时预览需 ${x}ms,可点击编辑 & 预览按钮进行关闭',
63 | 'preview': '预览',
64 | 'quote': '引用',
65 | 'record': '开始录音/结束录音',
66 | 'record-tip': '该设备不支持录音功能',
67 | 'recording': '录音中...',
68 | 'redo': '重做',
69 | 'remove': '删除',
70 | 'row': '行',
71 | 'spin': '旋转',
72 | 'splitView': '分屏预览',
73 | 'strike': '删除线',
74 | 'table': '表格',
75 | 'textIsNotEmpty': '文本(不能为空)',
76 | 'title': '标题',
77 | 'tooltipText': '提示文本',
78 | 'undo': '撤销',
79 | 'up': '上',
80 | 'update': '更新',
81 | 'upload': '上传图片或文件',
82 | 'uploadError': '上传错误',
83 | 'uploading': '上传中...',
84 | 'wysiwyg': '所见即所得',
85 | }
86 |
--------------------------------------------------------------------------------
/src/utils/errorLog.ts:
--------------------------------------------------------------------------------
1 | import { ComponentPublicInstance } from 'vue';
2 | import dayjs from 'dayjs';
3 | import fs from 'fs-extra';
4 | import os from 'os';
5 | import { remote } from 'electron';
6 | import { join, dirname } from 'path';
7 | import useMessage from '@/components/IMessage';
8 | import { constErrorLogPath } from '@/config';
9 |
10 | function getShortStack(stack?: string): string {
11 | const splitStack = stack?.split('\n ');
12 | if (!splitStack) return '';
13 | const newStack: string[] = [];
14 | for (const line of splitStack) {
15 | // 其他信息
16 | if (line.includes('bundler')) continue;
17 |
18 | // 只保留错误文件信息
19 | if (line.includes('?!.')) {
20 | newStack.push(line.replace(/webpack-internal:\/\/\/\.\/node_modules\/.+\?!/, ''));
21 | } else {
22 | newStack.push(line);
23 | }
24 | }
25 | // 转换string
26 | return newStack.join('\n ');
27 | }
28 |
29 | export const errorLogPath = join(dirname(remote.app.getPath('exe')), constErrorLogPath);
30 |
31 | export default function(error: unknown, vm: ComponentPublicInstance | null, info: string): void {
32 | const { message, stack } = error as Error;
33 | const { electron, chrome, node, v8 } = process.versions;
34 | const { outerWidth, outerHeight, innerWidth, innerHeight } = window;
35 | const { width, height } = window.screen;
36 |
37 | // 报错信息
38 | const errorInfo = {
39 | errorInfo: info,
40 | errorMessage: message,
41 | errorStack: getShortStack(stack)
42 | };
43 |
44 | // electron
45 | const electronInfo = { electron, chrome, node, v8 };
46 |
47 | // 浏览器窗口信息
48 | const browserInfo = { outerWidth, outerHeight, innerWidth, innerHeight };
49 |
50 | const errorLog = {
51 | versions: remote.app.getVersion(),
52 | date: dayjs().format('YYYY-MM-DD HH:mm'),
53 | error: errorInfo,
54 | electron: electronInfo,
55 | window: {
56 | type: os.type(),
57 | platform: os.platform()
58 | },
59 | browser: browserInfo,
60 | screen: { width, height }
61 | };
62 |
63 | useMessage('程序出现异常', 'error');
64 |
65 | if (process.env.NODE_ENV === 'production') {
66 | fs.writeFileSync(errorLogPath, JSON.stringify(errorLog) + '\n', { flag: 'a' });
67 | } else {
68 | console.log(errorInfo.errorStack);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Electron Build
2 |
3 | on:
4 | push:
5 | branches:
6 | - main # 执行分支on:
7 | workflow_dispatch:
8 |
9 | env:
10 | GH_TOKEN: ${{ secrets.GH_TOKEN }}
11 |
12 | jobs:
13 | build_macos:
14 | runs-on: macos-latest
15 | steps:
16 | - uses: actions/checkout@v2
17 | - name: Set up Node.js 16.x
18 | uses: actions/setup-node@v2
19 | with:
20 | node-version: '16.x'
21 | - name: Install Dependencies
22 | run: npm install
23 | - name: Build macOS app
24 | env:
25 | GH_TOKEN: ${{ secrets.GH_TOKEN }}
26 | run: |
27 | npm run build
28 | GH_TOKEN=${{ secrets.GH_TOKEN }} npm run pack:mac
29 | - name: Upload macOS Artifact
30 | uses: actions/upload-artifact@v2.2.4
31 | with:
32 | name: release-${{env.BUILD_TIME}}-mac
33 | path: ./dist_electron/*.dmg
34 |
35 | build_windows:
36 | runs-on: windows-latest
37 | steps:
38 | - uses: actions/checkout@v2
39 | - name: Set up Node.js 16.x
40 | uses: actions/setup-node@v2
41 | with:
42 | node-version: '16.x'
43 | - name: Install Dependencies
44 | run: npm install
45 | - name: Build Windows app
46 | env:
47 | GH_TOKEN: ${{ secrets.GH_TOKEN }}
48 | run: |
49 | npm run build
50 | GH_TOKEN=${{ secrets.GH_TOKEN }} npm run pack:windows
51 | - name: Upload Windows Artifact
52 | uses: actions/upload-artifact@v2.2.4
53 | with:
54 | name: release-${{env.BUILD_TIME}}-win
55 | path: ./dist_electron/*.exe
56 |
57 | build_linux:
58 | runs-on: ubuntu-latest
59 | steps:
60 | - uses: actions/checkout@v2
61 | - name: Set up Node.js 16.x
62 | uses: actions/setup-node@v2
63 | with:
64 | node-version: '16.x'
65 | - name: Install Dependencies
66 | run: npm install
67 | - name: Build Linux app
68 | env:
69 | GH_TOKEN: ${{ secrets.GH_TOKEN }}
70 | run: |
71 | npm run build
72 | GH_TOKEN=${{ secrets.GH_TOKEN }} npm run pack:linux
73 | - name: Upload Linux Artifact
74 | uses: actions/upload-artifact@v2.2.4
75 | with:
76 | name: release-${{env.BUILD_TIME}}-linux
77 | path: ./dist_electron/*.AppImage
78 |
--------------------------------------------------------------------------------
/vue.config.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable @typescript-eslint/no-var-requires */
2 | const path = require('path');
3 |
4 | module.exports = {
5 | lintOnSave: false,
6 | pages: {
7 | index: {
8 | entry: 'src/main.ts',
9 | template: 'public/index.html',
10 | filename: 'index.html',
11 | title: 'I便笺',
12 | // chunks: ['chunk-vendors', 'chunk-common', 'index'],
13 | platform: process.platform
14 | }
15 | },
16 | // productionSourceMap: false,
17 | configureWebpack: config => {
18 | config.externals = {
19 | sqlite3: 'commonjs sqlite3'
20 | };
21 | // if (process.env.NODE_ENV !== 'development') {
22 | // config.optimization.minimizer[0].options.terserOptions.warnings = false;
23 | // config.optimization.minimizer[0].options.terserOptions.compress = {
24 | // warnings: false,
25 | // drop_console: true,
26 | // drop_debugger: true,
27 | // pure_funcs: ['console.log']
28 | // };
29 | // }
30 | },
31 | pluginOptions: {
32 | electronBuilder: {
33 | nodeIntegration: true,
34 | builderOptions: {
35 | productName: 'I便笺',
36 | appId: 'com.inotes.heiyehk',
37 | copyright: 'heiyehk',
38 | compression: 'store', // "store" | "normal"| "maximum" 打包压缩情况(store 相对较快),store 39749kb, maximum 39186kb
39 | // directories: {
40 | // output: 'build' // 输出文件夹
41 | // },
42 | win: {
43 | // icon: 'xxx/icon.ico',
44 | target: ['nsis', 'zip']
45 | },
46 | nsis: {
47 | oneClick: false, // 一键安装
48 | // guid: 'xxxx', // 注册表名字,不推荐修改
49 | perMachine: true, // 是否开启安装时权限限制(此电脑或当前用户)
50 | allowElevation: true, // 允许请求提升。 如果为false,则用户必须使用提升的权限重新启动安装程序。
51 | allowToChangeInstallationDirectory: true, // 允许修改安装目录
52 | // installerIcon: './build/icons/aaa.ico', // 安装图标
53 | // uninstallerIcon: './build/icons/bbb.ico', // 卸载图标
54 | // installerHeaderIcon: './build/icons/aaa.ico', // 安装时头部图标
55 | createDesktopShortcut: true, // 创建桌面图标
56 | createStartMenuShortcut: true, // 创建开始菜单图标
57 | shortcutName: 'I便笺' // 图标名称
58 | },
59 | publish: ['github']
60 | }
61 | },
62 | 'style-resources-loader': {
63 | preProcessor: 'less',
64 | patterns: [path.resolve(__dirname, 'src/less/index.less')] // 引入全局样式变量
65 | }
66 | },
67 | devServer: {
68 | port: 55225
69 | }
70 | };
71 |
--------------------------------------------------------------------------------
/src/config/electronConfig.ts:
--------------------------------------------------------------------------------
1 | import { Task } from 'electron';
2 |
3 | const isDevelopment = process.env.NODE_ENV !== 'production';
4 |
5 | /**
6 | * task事件
7 | */
8 | export const userTasks: Task[] = [
9 | {
10 | program: process.execPath,
11 | arguments: '--editor',
12 | iconPath: process.execPath,
13 | iconIndex: 0,
14 | title: '新建便笺',
15 | description: '创建新的便笺'
16 | },
17 | {
18 | program: process.execPath,
19 | arguments: '--setting',
20 | iconPath: process.execPath,
21 | iconIndex: 0,
22 | title: '设置',
23 | description: '打开设置'
24 | }
25 | ];
26 |
27 | /**
28 | * 主要禁用
29 | * - F11 禁用全屏放大
30 | * - CTRL+R 禁用刷新
31 | * - CTRL+SHIFT+R 禁用刷新
32 | */
33 | export const disabledKeys = () => {
34 | const devShortcuts = ['F11', 'Ctrl+R', 'Ctrl+SHIFT+R'];
35 |
36 | const shortcuts = ['Ctrl+N', 'SHIFT+F10', 'Ctrl+SHIFT+I'];
37 |
38 | const exportKeys = isDevelopment ? shortcuts : [...devShortcuts, ...shortcuts];
39 | return exportKeys;
40 | };
41 |
42 | /**
43 | * BrowserWindow的配置项
44 | * @param type 单独给编辑窗口的配置
45 | */
46 | export const browserWindowOption = (type?: 'editor'): Electron.BrowserWindowConstructorOptions => {
47 | const devWid = isDevelopment ? 950 : 0;
48 | const devHei = isDevelopment ? 600 : 0;
49 |
50 | // 底部icon: 40*40
51 | const editorWindowOptions = {
52 | width: devWid || 290,
53 | height: devHei || 320,
54 | minWidth: 290
55 | };
56 | const commonOptions: Electron.BrowserWindowConstructorOptions = {
57 | minHeight: 48,
58 | frame: false,
59 | hasShadow: true,
60 | transparent: true,
61 | fullscreen: false,
62 | webPreferences: {
63 | enableRemoteModule: true,
64 | nodeIntegration: true,
65 | contextIsolation: false,
66 | webSecurity: false
67 | }
68 | };
69 | // 兼容mac
70 | if (process.platform === 'darwin') {
71 | commonOptions.frame = true;
72 | commonOptions.transparent = false;
73 | commonOptions.backgroundColor = '#ffffff';
74 | }
75 | if (!type) {
76 | return {
77 | width: devWid || 350,
78 | height: devHei || 600,
79 | minWidth: 320,
80 | ...commonOptions,
81 | resizable: isDevelopment ? true : false
82 | };
83 | }
84 | return {
85 | ...editorWindowOptions,
86 | ...commonOptions
87 | };
88 | };
89 |
90 | /**
91 | * 开发环境: http://localhost:55225
92 | *
93 | * 正式环境: file://${__dirname}/index.html
94 | */
95 | export const winURL = isDevelopment ? 'http://localhost:55225' : `file://${__dirname}/index.html`;
96 |
--------------------------------------------------------------------------------
/public/3.8.10/dist/css/content-theme/light.min.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Minified by jsDelivr using clean-css v5.2.2.
3 | * Original file: /npm/vditor@3.8.10/dist/css/content-theme/light.css
4 | *
5 | * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
6 | */
7 | /*!
8 | * Vditor - A markdown editor written in TypeScript.
9 | *
10 | * MIT License
11 | *
12 | * Copyright (c) 2018-present B3log 开源, b3log.org
13 | *
14 | * Permission is hereby granted, free of charge, to any person obtaining a copy
15 | * of this software and associated documentation files (the "Software"), to deal
16 | * in the Software without restriction, including without limitation the rights
17 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | * copies of the Software, and to permit persons to whom the Software is
19 | * furnished to do so, subject to the following conditions:
20 | *
21 | * The above copyright notice and this permission notice shall be included in all
22 | * copies or substantial portions of the Software.
23 | *
24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 | * SOFTWARE.
31 | *
32 | */
33 | .vditor-reset h1,.vditor-reset h2{padding-bottom:.3em;border-bottom:1px solid #eaecef}.vditor-reset hr{background-color:#eaecef}.vditor-reset blockquote{color:#6a737d;border-left:.25em solid #eaecef}.vditor-reset iframe{border:1px solid #d1d5da}.vditor-reset table tr{border-top:1px solid #c6cbd1;background-color:#fafbfc}.vditor-reset table td,.vditor-reset table th{border:1px solid #dfe2e5}.vditor-reset table tbody tr:nth-child(2n){background-color:#fff}.vditor-reset code:not(.hljs):not(.highlight-chroma){background-color:rgba(27,31,35,.05)}.vditor-reset kbd{color:#24292e;background-color:#fafbfc;border:solid 1px #d1d5da;box-shadow:inset 0 -1px 0 #d1d5da}.vditor-speech{background-color:#f6f8fa;border:1px solid #d1d5da;color:#586069}.vditor-speech--current,.vditor-speech:hover{color:#4285f4}.vditor-linkcard a{background-color:#f6f8fa}.vditor-linkcard a:visited .vditor-linkcard__abstract{color:rgba(88,96,105,.36)}.vditor-linkcard__title{color:#24292e}.vditor-linkcard__abstract{color:#586069}.vditor-linkcard__site{color:#4285f4}.vditor-linkcard__image{background-color:rgba(88,96,105,.36)}
34 | /*# sourceMappingURL=/sm/089ee1b23348ed2cbc928ec11193da90b974f1b065d2cdf85a1e81d521e5ae45.map */
--------------------------------------------------------------------------------
/src/components/IMessageBox.vue:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
44 |
45 |
116 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "i-notes",
3 | "version": "0.6.1",
4 | "private": true,
5 | "author": "heiyehk",
6 | "description": "I便笺拥有漂亮的过度效果,允许开启多个窗口方便在桌面端更方便的记录文字",
7 | "main": "background.js",
8 | "repository": {
9 | "type": "git",
10 | "url": "https://github.com/heiyehk/electron-vue3-inote"
11 | },
12 | "license": "MIT",
13 | "bugs": {
14 | "url": "https://github.com/heiyehk/electron-vue3-inote/issues",
15 | "email": "heiyehk@foxmail.com"
16 | },
17 | "scripts": {
18 | "serve": "vue-cli-service electron:serve",
19 | "build": "node script/deleteBuild && vue-cli-service electron:build",
20 | "publish": "yarn build -p always",
21 | "lint": "vue-cli-service lint",
22 | "log": "conventional-changelog -p angular -i CHANGELOG.md -s",
23 | "commit": "yarn log && git add . && cz",
24 | "cz": "cz"
25 | },
26 | "dependencies": {
27 | "conventional-changelog-cli": "^2.2.2",
28 | "core-js": "^3.15.2",
29 | "crypto-js": "^4.1.1",
30 | "dayjs": "^1.10.6",
31 | "electron-log": "^4.4.7",
32 | "electron-updater": "^5.0.1",
33 | "fs-extra": "^10.0.0",
34 | "pg-hstore": "^2.3.4",
35 | "sequelize": "^6.6.5",
36 | "sqlite3": "^5.1.7",
37 | "style-resources-loader": "^1.4.1",
38 | "vditor": "^3.9.0",
39 | "vue": "3.2.26",
40 | "vue-cli-plugin-electron-builder": "^2.1.1",
41 | "vue-router": "^4.0.12"
42 | },
43 | "devDependencies": {
44 | "@types/crypto-js": "^4.0.2",
45 | "@types/sequelize": "^4.28.10",
46 | "@types/sqlite3": "^3.1.7",
47 | "@typescript-eslint/eslint-plugin": "^4.8.2",
48 | "@typescript-eslint/parser": "^4.8.2",
49 | "@vue/cli-plugin-babel": "~4.5.0",
50 | "@vue/cli-plugin-eslint": "~4.5.0",
51 | "@vue/cli-plugin-router": "~4.5.0",
52 | "@vue/cli-plugin-typescript": "~4.5.0",
53 | "@vue/cli-service": "~4.5.0",
54 | "@vue/compiler-sfc": "^3.2.26",
55 | "@vue/eslint-config-prettier": "^6.0.0",
56 | "@vue/eslint-config-typescript": "^5.0.2",
57 | "cz-conventional-changelog": "3.3.0",
58 | "electron": "11.5.0",
59 | "electron-builder": "22.14.5",
60 | "eslint": "^6.7.2",
61 | "eslint-config-prettier": "^6.15.0",
62 | "eslint-plugin-prettier": "^3.1.4",
63 | "eslint-plugin-vue": "^7.1.0",
64 | "less": "^3.0.4",
65 | "less-loader": "^5.0.0",
66 | "lint-staged": "^9.5.0",
67 | "prettier": "^1.19.1",
68 | "rimraf": "^3.0.2",
69 | "typescript": "4.4.4",
70 | "vue-cli-plugin-style-resources-loader": "~0.1.4"
71 | },
72 | "husky": {
73 | "hooks": {
74 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
75 | }
76 | },
77 | "config": {
78 | "commitizen": {
79 | "path": "cz-conventional-changelog"
80 | }
81 | },
82 | "gitHooks": {
83 | "pre-commit": "lint-staged"
84 | },
85 | "lint-staged": {
86 | "*.{js,jsx,vue,ts,tsx}": [
87 | "vue-cli-service lint",
88 | "git add"
89 | ]
90 | },
91 | "publish": [
92 | "github"
93 | ],
94 | "engines": {
95 | "node": "<=16"
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [0.6.1](https://github.com/heiyehk/electron-vue3-inote/compare/0.5.2...0.6.1) (2024-06-15)
2 |
3 |
4 | ### Features
5 |
6 | feature: [#11](https://github.com/heiyehk/electron-vue3-inote/issues/11) 调整储存位置为当前软件目录下 ([b44ace7](https://github.com/heiyehk/electron-vue3-inote/commit/b44ace721cdf28b3a327fd3fb6b56dea2ccf0392))
7 |
8 |
9 |
10 | ## [0.5.2](https://github.com/heiyehk/electron-vue3-inote/compare/0.5.1...0.5.2) (2023-01-31)
11 |
12 |
13 | ### Features
14 |
15 | * **ieditor.vue:** 升级vditor版本,调整属性 ([c3d50d0](https://github.com/heiyehk/electron-vue3-inote/commit/c3d50d0f3411561c95124a50edfad9ed550b228a))
16 |
17 |
18 |
19 | ## [0.5.1](https://github.com/heiyehk/electron-vue3-inote/compare/0.4.1...0.5.1) (2023-01-07)
20 |
21 |
22 | ### Features
23 |
24 | * 对编辑器的优化,增加右键功能以及本地图片的缓存,修复了部分bug ([c1c0c0f](https://github.com/heiyehk/electron-vue3-inote/commit/c1c0c0f676a29adce8dc46582f17f550d0c079ce))
25 |
26 |
27 |
28 | ## [0.3.2](https://github.com/heiyehk/electron-vue3-inote/compare/0.3.1...0.3.2) (2021-11-18)
29 |
30 |
31 | ### Bug Fixes
32 |
33 | * 修复一些bug ([bd99c01](https://github.com/heiyehk/electron-vue3-inote/commit/bd99c0143a5867893d4a452558ee0e3b6f101ee9))
34 |
35 |
36 |
37 | ## [0.3.1](https://github.com/heiyehk/electron-vue3-inote/compare/0.2.3...0.3.1) (2021-09-01)### Features
38 |
39 | * **沉浸模式**: 编辑框失去焦点后自动隐藏头部和编辑按钮
40 | * **纯净模式**: 在沉浸模式下不在自动显示头部和编辑按钮,需要按下`Esc`才能显示
41 | * **Input Component**: 输入框组件增加`disabled`功能
42 | * **Switch Component**: 开关组件增加`change`事件
43 |
44 |
45 |
46 | ## [0.2.3](https://github.com/heiyehk/electron-vue3-inote/compare/0.2.2...0.2.3) (2021-08-27)
47 |
48 |
49 | ### Bug Fixes
50 |
51 | * 文件大小写问题 ([40d14c4](https://github.com/heiyehk/electron-vue3-inote/commit/40d14c4e769de2ac34fc1458bf8fd8f408ac8684))
52 | * 文件大小写问题 ([51e9542](https://github.com/heiyehk/electron-vue3-inote/commit/51e954229360d7a6f27c20f20e2bb7d40362402c))
53 | * 修复编辑的时候光标错误 ([302683f](https://github.com/heiyehk/electron-vue3-inote/commit/302683f50f95d33ca697a9c8c36fac59a14ba8f5))
54 | * 修复创建db时找不到文件错误 ([ba47627](https://github.com/heiyehk/electron-vue3-inote/commit/ba476279d73f6237cc7b327e44d0bf56149d1adc))
55 |
56 |
57 |
58 | ## [0.2.2](https://github.com/heiyehk/electron-vue3-inote/compare/0.2.1...0.2.2) (2021-08-06)
59 |
60 |
61 | ### Features
62 |
63 | * 兼容mac以及暗黑模式 ([c1400cd](https://github.com/heiyehk/electron-vue3-inote/commit/c1400cdfe6dcd114f3ae90376ca0c090c70d8c82))
64 |
65 |
66 |
67 | ## [0.2.1](https://github.com/heiyehk/electron-vue3-inote/compare/0.1.2...0.2.1) (2021-07-19)
68 |
69 |
70 |
71 | ## [0.1.2](https://github.com/heiyehk/electron-vue3-inote/compare/0.1.1...0.1.2) (2021-02-01)
72 |
73 |
74 | ### Bug Fixes
75 |
76 | * 首页双击重复点击导致打开多个一样的 ([0bd5cfe](https://github.com/heiyehk/electron-vue3-inote/commit/0bd5cfe240c85ed6909d24ed6e42d8a262bcbe9d))
77 |
78 |
79 |
80 | ## [0.1.1](https://github.com/heiyehk/electron-vue3-inote/compare/0.1.0...0.1.1) (2021-01-11)
81 |
82 |
83 | ### Bug Fixes
84 |
85 | * 修复editorIcons.options文件命名问题 ([b0c2849](https://github.com/heiyehk/electron-vue3-inote/commit/b0c284994ce4656808fe080e78a17722be2af3fe))
86 |
87 |
88 |
89 | # 0.1.0 (2020-12-25)
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/src/start.ts:
--------------------------------------------------------------------------------
1 | import { app, protocol, BrowserWindow, globalShortcut } from 'electron';
2 | import { createProtocol } from 'vue-cli-plugin-electron-builder/lib';
3 | import path from 'path';
4 |
5 | import { browserWindowOption, winURL, disabledKeys, userTasks } from './config';
6 | import updater from './updater';
7 |
8 | const startWindow = () => {
9 | const isDevelopment = process.env.NODE_ENV !== 'production';
10 | let win: BrowserWindow | null;
11 | app.on('second-instance', () => {
12 | // 当运行第二个实例时,将会聚焦到win这个窗口
13 | if (win) {
14 | if (win.isMinimized()) win.restore();
15 | win.focus();
16 | }
17 | });
18 | app.whenReady().then(() => {
19 | // 这个需要在app.ready触发之后使用
20 | protocol.registerFileProtocol('atom', (request, callback) => {
21 | const url = request.url.substring(7);
22 | callback(decodeURI(path.normalize(url)));
23 | });
24 | });
25 |
26 | // 将计划注册为标准将允许通过文件系统 API访问文件。否则,渲染器将为计划抛出一个安全错误。
27 | // 此方法只能在模块事件发出之前使用,并且只能调用一次。`ready app`
28 | protocol.registerSchemesAsPrivileged([
29 | {
30 | scheme: 'app',
31 | privileges: {
32 | secure: true,
33 | standard: true
34 | }
35 | }
36 | ]);
37 |
38 | const createWindow = () => {
39 | // 如果有webpack启动的server
40 | if (process.env.WEBPACK_DEV_SERVER_URL) {
41 | win = new BrowserWindow(browserWindowOption());
42 | // 默认打开webpack启动的serve
43 | win.loadURL(process.env.WEBPACK_DEV_SERVER_URL);
44 | if (!process.env.IS_TEST) win.webContents.openDevTools();
45 | } else {
46 | const argv = process.argv[1];
47 | // 注册一个协议
48 | createProtocol('app');
49 |
50 | // 判断是否是新增
51 | if (argv === '--editor') {
52 | const editorWinOptions = browserWindowOption();
53 | win = new BrowserWindow(editorWinOptions);
54 | win.loadURL(`${winURL}#/editor`);
55 | } else {
56 | win = new BrowserWindow(browserWindowOption());
57 | win.loadURL(winURL);
58 | }
59 | }
60 | // win.webContents.openDevTools();
61 |
62 | win.on('closed', () => {
63 | win = null;
64 | });
65 | };
66 |
67 | app.on('window-all-closed', () => {
68 | if (process.platform !== 'darwin') {
69 | app.quit();
70 | }
71 | });
72 |
73 | app.on('activate', () => {
74 | if (win === null) {
75 | createWindow();
76 | }
77 | });
78 |
79 | app.on('ready', async () => {
80 | // 快捷键禁用
81 | for (const key of disabledKeys()) {
82 | globalShortcut.register(key, () => void 0);
83 | }
84 | updater();
85 | createWindow();
86 | });
87 |
88 | // TODO 待开发的内容
89 | app.setUserTasks(userTasks);
90 |
91 | if (isDevelopment) {
92 | if (process.platform === 'win32') {
93 | process.on('message', data => {
94 | if (data === 'graceful-exit') {
95 | app.quit();
96 | }
97 | });
98 | } else {
99 | process.on('SIGTERM', () => {
100 | app.quit();
101 | });
102 | }
103 | }
104 | };
105 |
106 | export default startWindow;
107 |
--------------------------------------------------------------------------------
/src/store/notes.state.ts:
--------------------------------------------------------------------------------
1 | import { ipcRenderer, remote } from 'electron';
2 | import { ref, watch } from 'vue';
3 | import { join, dirname } from 'path';
4 | import { constImagesPath } from '@/config';
5 | interface NotesState {
6 | [key: string]: any;
7 | syncDelay: number;
8 | serverAddress: string;
9 | serverToken: string;
10 | switchStatus: {
11 | [key: string]: any;
12 | /**
13 | * 开启提示
14 | */
15 | textTip: boolean;
16 |
17 | /**
18 | * 删除确认
19 | */
20 | deleteTip: boolean;
21 |
22 | /**
23 | * 自动沉浸
24 | */
25 | autoNarrow: boolean;
26 | /**
27 | * 纯净模式
28 | */
29 | autoNarrowPure: boolean;
30 |
31 | /**
32 | * 自动隐藏
33 | */
34 | autoHide: boolean;
35 |
36 | /**
37 | * 打开同步
38 | */
39 | openSync: boolean;
40 | };
41 | /** 本地图片缓存地址 */
42 | imagesCacheUrl: string;
43 | }
44 |
45 | const defaultNotesState: NotesState = {
46 | syncDelay: 100,
47 | serverAddress: '',
48 | serverToken: '',
49 | switchStatus: {
50 | /**
51 | * 开启提示
52 | */
53 | textTip: true,
54 |
55 | /**
56 | * 删除确认
57 | */
58 | deleteTip: false,
59 |
60 | /**
61 | * 自动缩小
62 | */
63 | autoNarrow: false,
64 | /**
65 | * 缩小纯净模式
66 | */
67 | autoNarrowPure: false,
68 |
69 | /**
70 | * 自动隐藏
71 | */
72 | autoHide: false,
73 |
74 | /**
75 | * 打开同步
76 | */
77 | openSync: false
78 | },
79 | imagesCacheUrl: join(dirname(remote.app.getPath('exe')), constImagesPath)
80 | };
81 |
82 | export const notesState = ref版本:{{ version }}
95 |Electron: {{ appInfo.electron }}
96 |Chrome: {{ appInfo.chrome }}
97 |Node.js: {{ appInfo.node }}
98 |V8: {{ appInfo.v8 }}
99 |Copyright (c) {{ currentYear }} {{ packageJson.author }}.
100 |清除缓存后配置将重置,可能会出现错误。确认清除?
105 |是否删除此便笺
19 |