Skip to content
This repository was archived by the owner on Jun 21, 2024. It is now read-only.

Commit 51d8ca4

Browse files
committed
features: 设置增加沉浸、纯净模式,默认关闭。部分功能优化
其他的一些更改
1 parent 15efae9 commit 51d8ca4

26 files changed

+731
-227
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ npm-debug.log*
1414
yarn-debug.log*
1515
yarn-error.log*
1616
pnpm-debug.log*
17-
inoteError.log
17+
inotesError.log
1818

1919
# Editor directories and files
2020
.idea

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## [0.3.1](https://github.com/heiyehk/electron-vue3-inote/compare/0.2.3...0.3.1) (2021-09-01)
2+
3+
4+
### Features
5+
6+
* **沉浸模式**: 编辑框失去焦点后自动隐藏头部和编辑按钮
7+
* **纯净模式**: 在沉浸模式下不在自动显示头部和编辑按钮,需要按下`Esc`才能显示
8+
* **Input Component**: 输入框组件增加`disabled`功能
9+
* **Switch Component**: 开关组件增加`change`事件
10+
11+
### Ci
12+
13+
* **Sqlite**: 数据库路径改变
14+
15+
### Directory & Files
16+
17+
* 优化部分目录和文件结构
18+
19+
### Refactor
20+
21+
* `note` => `notes`

package.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "i-notes",
3-
"version": "0.2.4",
3+
"version": "0.3.1",
44
"private": true,
55
"author": "heiyehk",
66
"description": "I便笺拥有漂亮的过度效果,允许开启多个窗口方便在桌面端更方便的记录文字",
@@ -15,15 +15,16 @@
1515
"email": "[email protected]"
1616
},
1717
"scripts": {
18-
"lint": "vue-cli-service lint",
18+
"serve": "vue-cli-service electron:serve",
1919
"build": "node script/deleteBuild && vue-cli-service electron:build",
20-
"serve": "vue-cli-service electron:serve"
20+
"lint": "vue-cli-service lint",
21+
"commit": "cz"
2122
},
2223
"dependencies": {
2324
"core-js": "^3.15.2",
25+
"crypto-js": "^4.1.1",
2426
"dayjs": "^1.10.6",
2527
"fs-extra": "^10.0.0",
26-
"nedb": "^1.8.0",
2728
"pg-hstore": "^2.3.4",
2829
"sequelize": "^6.6.5",
2930
"sqlite3": "^5.0.2",
@@ -34,7 +35,7 @@
3435
"vue-router": "^4.0.10"
3536
},
3637
"devDependencies": {
37-
"@types/nedb": "^1.8.12",
38+
"@types/crypto-js": "^4.0.2",
3839
"@types/sequelize": "^4.28.10",
3940
"@types/sqlite3": "^3.1.7",
4041
"@typescript-eslint/eslint-plugin": "^4.8.2",
@@ -47,6 +48,7 @@
4748
"@vue/compiler-sfc": "^3.0.0",
4849
"@vue/eslint-config-prettier": "^6.0.0",
4950
"@vue/eslint-config-typescript": "^5.0.2",
51+
"cz-conventional-changelog": "3.3.0",
5052
"electron": "13.1.6",
5153
"electron-builder": "^22.9.1",
5254
"eslint": "^6.7.2",
@@ -61,6 +63,16 @@
6163
"typescript": "~3.9.3",
6264
"vue-cli-plugin-style-resources-loader": "~0.1.4"
6365
},
66+
"husky": {
67+
"hooks": {
68+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
69+
}
70+
},
71+
"config": {
72+
"commitizen": {
73+
"path": "cz-conventional-changelog"
74+
}
75+
},
6476
"gitHooks": {
6577
"pre-commit": "lint-staged"
6678
},

src/background.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function createWindow() {
2727
if (process.env.WEBPACK_DEV_SERVER_URL) {
2828
win = new BrowserWindow(browserWindowOption());
2929
// 默认打开webpack启动的serve
30-
win.loadURL(process.env.WEBPACK_DEV_SERVER_URL + '#/editor');
30+
win.loadURL(process.env.WEBPACK_DEV_SERVER_URL);
3131
if (!process.env.IS_TEST) win.webContents.openDevTools();
3232
} else {
3333
const argv = process.argv[1];

src/components/Editor.vue

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@input="changeEditorContent"
1313
></div>
1414
<!-- 功能 -->
15-
<section class="bottom-editor-tools" :class="windowBlur ? 'window-blur-hide' : ''">
15+
<section class="bottom-editor-tools" :class="bottomClass">
1616
<template v-for="item in bottomIcons" :key="item.name">
1717
<button class="icon" :title="item.title" @click="editorIconHandle($event, item.name)">
1818
<i class="iconfont" :class="item.icon"></i>
@@ -22,7 +22,7 @@
2222
</template>
2323

2424
<script lang="ts">
25-
import { defineComponent, nextTick, onMounted, ref, Ref, watch } from 'vue';
25+
import { computed, defineComponent, nextTick, onMounted, ref, Ref, watch } from 'vue';
2626
import { debounce } from '@/utils';
2727
import { editorIcons } from '@/config';
2828
import { notesState } from '@/store/notes.state';
@@ -35,6 +35,10 @@ export default defineComponent({
3535
windowBlur: {
3636
type: Boolean,
3737
default: true
38+
},
39+
windowLock: {
40+
type: Boolean,
41+
default: true
3842
}
3943
},
4044
emits: ['on-input', 'update:value'],
@@ -56,12 +60,24 @@ export default defineComponent({
5660
}
5761
}
5862
);
63+
const bottomClass = computed(() => {
64+
const classArr = [];
65+
if (props.windowBlur) {
66+
classArr.push('window-blur-hide');
67+
} else {
68+
if (props.windowLock) {
69+
// 当锁上的时候,编辑器任然处于失去焦点的情况
70+
// 需要解锁才能正常
71+
classArr.push('window-blur-hide');
72+
}
73+
}
74+
return classArr;
75+
});
5976
6077
// 第一次进入事件
6178
const firstHandle = () => {
6279
nextTick(() => {
6380
focus();
64-
console.dir(editor.value);
6581
editor.value?.scrollTo(0, editor.value.scrollHeight);
6682
firstIn.value = false;
6783
});
@@ -88,11 +104,40 @@ export default defineComponent({
88104
const changeEditorContent = debounce((e: InputEvent) => {
89105
const editorHtml = (e.target as Element).innerHTML;
90106
emit('on-input', editorHtml);
91-
}, notesState.syncDelay);
107+
}, notesState.value.syncDelay);
92108
93109
const paste = (e: ClipboardEvent) => {
94110
const pasteText = e.clipboardData?.getData('text/plain');
95-
document.execCommand('insertText', false, pasteText);
111+
const setText = (text?: string) => {
112+
document.execCommand('insertText', false, text);
113+
};
114+
const interceptPoint = 100000;
115+
// 做超长文本处理
116+
// TODO
117+
const len = pasteText!.length;
118+
if (!len) return;
119+
if (len < interceptPoint) {
120+
setText(pasteText);
121+
} else {
122+
const count = Math.ceil(len / interceptPoint);
123+
let control = 0;
124+
let interval: any = setInterval(() => {
125+
let text = '';
126+
if (control === 0) {
127+
text = pasteText!.substring(0, (control + 1) * interceptPoint);
128+
} else if (control !== 0 && control !== count) {
129+
text = pasteText!.substring(control * interceptPoint, (control + 1) * interceptPoint);
130+
}
131+
setText(text);
132+
if (control >= count) {
133+
text = '';
134+
clearInterval(interval);
135+
interval = null;
136+
editor.value?.scrollTo(0, editor.value.scrollHeight);
137+
}
138+
control++;
139+
}, 100);
140+
}
96141
};
97142
98143
return {
@@ -101,7 +146,8 @@ export default defineComponent({
101146
bottomIcons,
102147
changeEditorContent,
103148
paste,
104-
editorContent
149+
editorContent,
150+
bottomClass
105151
};
106152
}
107153
});

src/components/Input.vue

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
<template>
22
<div class="hy-input flex">
33
<div class="hy-input-box flex1">
4-
<input :maxlength="maxlength" :readonly="readonly" v-model="inputValue" @input="changeInput" />
4+
<input
5+
:maxlength="maxlength"
6+
:disabled="disabled"
7+
:readonly="readonly"
8+
v-model="inputValue"
9+
@input="changeInput"
10+
/>
511
</div>
612
<div class="hy-number-control flex" v-if="control">
713
<div
814
class="hy-number-control-add hy-number-button"
9-
:class="modelValue === max ? 'disabled' : ''"
10-
@click="calculateDelay('add')"
15+
:class="modelValue === max || disabled ? 'disabled' : ''"
16+
@click="disabled ? '' : calculateDelay('add')"
1117
>
1218
<i class="iconfont icon-arrow-up"></i>
1319
</div>
1420
<div
1521
class="hy-number-control-sub hy-number-button"
16-
:class="modelValue === min ? 'disabled' : ''"
17-
@click="calculateDelay('sub')"
22+
:class="modelValue === min || disabled ? 'disabled' : ''"
23+
@click="disabled ? '' : calculateDelay('sub')"
1824
>
1925
<i class="iconfont icon-arrow-down"></i>
2026
</div>
@@ -38,6 +44,7 @@ export default defineComponent({
3844
type: Boolean,
3945
default: false
4046
},
47+
disabled: Boolean,
4148
type: {
4249
type: String,
4350
default: 'text'

src/components/Switch.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</template>
1616

1717
<script lang="ts">
18-
import { defineComponent, ref } from 'vue';
18+
import { defineComponent, ref, watch } from 'vue';
1919
2020
export default defineComponent({
2121
props: {
@@ -26,14 +26,21 @@ export default defineComponent({
2626
styled: String,
2727
disabled: Boolean
2828
},
29-
emits: ['update:modelValue'],
29+
emits: ['update:modelValue', 'change'],
3030
setup(props, { emit }) {
3131
const checkedStatus = ref(props.modelValue);
32+
watch(
33+
() => props.modelValue,
34+
nv => {
35+
checkedStatus.value = nv;
36+
}
37+
);
3238
3339
const checkStatus = () => {
3440
if (props.disabled) return;
3541
checkedStatus.value = !checkedStatus.value;
3642
emit('update:modelValue', checkedStatus.value);
43+
emit('change', checkedStatus.value);
3744
};
3845
3946
return {

src/config/electronConfig.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Task } from 'electron';
22

3+
const isDevelopment = process.env.NODE_ENV !== 'production';
34
/**
45
* task事件
56
*/
@@ -33,14 +34,12 @@ export const disabledKeys = () => {
3334

3435
const shortcuts = ['Ctrl+N', 'SHIFT+F10', 'Ctrl+SHIFT+I'];
3536

36-
const exportKeys = process.env.NODE_ENV === 'development' ? shortcuts : [...devShortcuts, ...shortcuts];
37+
const exportKeys = isDevelopment ? shortcuts : [...devShortcuts, ...shortcuts];
3738
return exportKeys;
3839
};
3940

40-
const globalEnv = process.env.NODE_ENV;
41-
42-
const devWid = globalEnv === 'development' ? 950 : 0;
43-
const devHei = globalEnv === 'development' ? 600 : 0;
41+
const devWid = isDevelopment ? 950 : 0;
42+
const devHei = isDevelopment ? 600 : 0;
4443

4544
// 底部icon: 40*40
4645
const editorWindowOptions = {
@@ -78,7 +77,7 @@ export const browserWindowOption = (type?: 'editor'): Electron.BrowserWindowCons
7877
height: devHei || 600,
7978
minWidth: 320,
8079
...commonOptions,
81-
resizable: false
80+
resizable: isDevelopment ? true : false
8281
};
8382
}
8483
return {
@@ -92,4 +91,4 @@ export const browserWindowOption = (type?: 'editor'): Electron.BrowserWindowCons
9291
*
9392
* 正式环境: file://${__dirname}/index.html
9493
*/
95-
export const winURL = globalEnv === 'development' ? 'http://localhost:55225' : `file://${__dirname}/index.html`;
94+
export const winURL = isDevelopment ? 'http://localhost:55225' : `file://${__dirname}/index.html`;

src/config/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { editorIcons, classNames } from './noteConfig';
1+
import { editorIcons, classNames } from './inotesConfig';
22
import { browserWindowOption, winURL, disabledKeys, userTasks } from './electronConfig';
33

44
export { classNames, editorIcons, browserWindowOption, winURL, disabledKeys, userTasks };
File renamed without changes.

0 commit comments

Comments
 (0)