Skip to content

Commit

Permalink
feat: 优化组件以及文件的名称
Browse files Browse the repository at this point in the history
  • Loading branch information
heiyehk committed Jun 16, 2022
1 parent 0329ac1 commit 618e754
Show file tree
Hide file tree
Showing 30 changed files with 250 additions and 136 deletions.
34 changes: 34 additions & 0 deletions public/3.8.10/dist/css/content-theme/light.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
8 changes: 8 additions & 0 deletions public/3.8.10/dist/js/i18n/zh_CN.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions public/3.8.10/dist/js/icons/ant.min.js

Large diffs are not rendered by default.

File renamed without changes.
26 changes: 24 additions & 2 deletions public/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,23 @@ body {
.black-content {
transition: background-color 0.4s;
background-color: #696969 !important;
color: #fff;
/* color: #fff; */
}


/* 针对富文本做特定的样式 */
.black-content .vditor-copy {
color: #24292D !important;
}
.black-content .vditor-copy span {
color: #24292D !important;
}
.black-content .vditor-copy path {
color: #24292D !important;
}

.black-content .vditor-ir__node--expand .vditor-ir__marker--heading {
color: #fff !important;
}

.black-content * {
Expand All @@ -206,8 +222,14 @@ body {

.window-blur-hide .vditor-toolbar {
top: 40px !important;
transition: top 0.4s;
height: 0 !important;
transition: top 0.4s, height 0.4s;
}

.vditor-reset p {
margin-bottom: 8px;
}

.window-blur-hide .vditor-content {

}
2 changes: 1 addition & 1 deletion public/css/common.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 8 additions & 88 deletions src/background.ts
Original file line number Diff line number Diff line change
@@ -1,91 +1,11 @@
import { app, protocol, BrowserWindow, globalShortcut } from 'electron';
import {
createProtocol
// installVueDevtools
} from 'vue-cli-plugin-electron-builder/lib';
import { app } from 'electron';
import startWindow from './start';

import { browserWindowOption, winURL, disabledKeys } from './config';
// 获取锁,判断是否已经启动
const gotTheLock = app.requestSingleInstanceLock();

const isDevelopment = process.env.NODE_ENV !== 'production';

let win: BrowserWindow | null;

// 将计划注册为标准将允许通过文件系统 API访问文件。否则,渲染器将为计划抛出一个安全错误。
// 此方法只能在模块事件发出之前使用,并且只能调用一次。`ready app`
protocol.registerSchemesAsPrivileged([
{
scheme: 'app',
privileges: {
secure: true,
standard: true
}
}
]);

function createWindow() {
// 如果有webpack启动的server
if (process.env.WEBPACK_DEV_SERVER_URL) {
win = new BrowserWindow(browserWindowOption());
// 默认打开webpack启动的serve
win.loadURL(process.env.WEBPACK_DEV_SERVER_URL);
if (!process.env.IS_TEST) win.webContents.openDevTools();
} else {
const argv = process.argv[1];
// 注册一个协议
createProtocol('app');

// 判断是否是新增
if (argv === '--editor') {
const editorWinOptions = browserWindowOption();
win = new BrowserWindow(editorWinOptions);
win.loadURL(`${winURL}#/editor`);
} else {
win = new BrowserWindow(browserWindowOption());
win.loadURL(winURL);
}
}
// win.webContents.openDevTools();
// sequelizeInit();

win.on('closed', () => {
win = null;
});
}

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
if (win === null) {
createWindow();
}
});

app.on('ready', async () => {
// 快捷键禁用
for (const key of disabledKeys()) {
// eslint-disable-next-line @typescript-eslint/no-empty-function
globalShortcut.register(key, () => {});
}
createWindow();
});

// TODO 待开发的内容
// app.setUserTasks(userTasks);

if (isDevelopment) {
if (process.platform === 'win32') {
process.on('message', data => {
if (data === 'graceful-exit') {
app.quit();
}
});
} else {
process.on('SIGTERM', () => {
app.quit();
});
}
if (!gotTheLock) {
app.quit();
} else {
startWindow();
}
5 changes: 3 additions & 2 deletions src/components/Editor.vue → src/components/IEditor.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="editor-markdown" :class="className" ref="editorRef"></div>
<div class="editor-markdown vditor" :class="className" ref="editorRef"></div>
</template>

<script setup lang="ts">
Expand Down Expand Up @@ -109,6 +109,7 @@ onMounted(() => {
input: value => {
emits('on-input', vditor.value?.getHTML(), value);
},
// cdn: './',
after: () => {
vditorLoad();
}
Expand Down Expand Up @@ -136,7 +137,7 @@ const vditorLoad = () => {
height: 40px;
position: relative;
top: 0;
transition: top 0.4s;
transition: top 0.4s, height 0.4s;
.vditor-toolbar__item {
width: 40px;
height: 40px;
Expand Down
11 changes: 8 additions & 3 deletions src/components/Header.vue → src/components/IHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</button>
</template>
<!-- 标题拖动 -->
<div class="drag-header flex1 flex-center" :style="computedPaddingLeft">
<div class="drag-header flex1 flex-center" @contextmenu.prevent="click" :style="computedPaddingLeft">
<transition name="header-fadein" v-if="platformWindows">
<span :key="title">{{ title }}</span>
</transition>
Expand Down Expand Up @@ -57,11 +57,11 @@
</template>

<script lang="ts">
import { remote } from 'electron';
import { computed, defineComponent, ref } from 'vue';
import { onBeforeRouteUpdate, useRoute } from 'vue-router';
import { browserWindowOption } from '@/config';
import { createBrowserWindow, transitCloseWindow } from '@/utils';
import { remote } from 'electron';
export default defineComponent({
emits: ['option-click', 'on-close'],
Expand Down Expand Up @@ -114,6 +114,10 @@ export default defineComponent({
transitCloseWindow();
};
const click = () => {
console.log(123);
};
return {
openNewWindow,
currentRouteName,
Expand All @@ -124,7 +128,8 @@ export default defineComponent({
isAlwaysOnTop,
title,
// 只在windows上显示
platformWindows: process.platform === 'win32'
platformWindows: process.platform === 'win32',
click
};
}
});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/config/electronConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export const browserWindowOption = (type?: 'editor'): Electron.BrowserWindowCons
frame: false,
hasShadow: true,
transparent: true,
fullscreen: false,
webPreferences: {
enableRemoteModule: true,
nodeIntegration: true,
contextIsolation: false,
webSecurity: false
Expand Down
18 changes: 17 additions & 1 deletion src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
import { classNames } from './inotesConfig';
import { browserWindowOption, winURL, disabledKeys, userTasks } from './electronConfig';

export { classNames, browserWindowOption, winURL, disabledKeys, userTasks };
const isDev = process.env.NODE_ENV === 'development';

/** 日志地址 */
const constErrorLogPath = `/resources/inotesError${isDev ? '-dev' : ''}.log`;

/** db地址 */
const constStoragePath = `/resources/db/notes${isDev ? '-dev' : ''}.db`;

export {
classNames,
browserWindowOption,
winURL,
disabledKeys,
userTasks,
constErrorLogPath,
constStoragePath
};
3 changes: 2 additions & 1 deletion src/service/initSequelize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { Sequelize } from 'sequelize';
import sqlite3 from 'sqlite3';
import { join } from 'path';
import { remote } from 'electron';
import { constStoragePath } from '@/config';

const storagePath = join(remote.app.getPath('userData'), '/resources/db/notes.db');
const storagePath = join(remote.app.getPath('userData'), constStoragePath);

export const sequelize = new Sequelize({
database: 'reading',
Expand Down
Loading

0 comments on commit 618e754

Please sign in to comment.