Skip to content

Commit

Permalink
perf: Optimize search result display
Browse files Browse the repository at this point in the history
perf: Optimize the export html interface
feat: add insert network image short key
  • Loading branch information
1943time committed Sep 4, 2023
1 parent 40307fc commit d4dd4b1
Show file tree
Hide file tree
Showing 23 changed files with 242 additions and 613 deletions.
91 changes: 0 additions & 91 deletions .github/workflows/mas.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: ls
run: |
wget https://github.com/1943time/bs-web/releases/download/v0.5.1/web.zip
wget https://pic.bluestone.blog/web/web.zip
chmod 755 web.zip
unzip web.zip
- name: Build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ build/entitlements.mas.plist
build/entitlements.mas.loginhelper.plist
src/renderer/src/share
mas-builder.yml
src/main/auth.ts
11 changes: 8 additions & 3 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ files:
asarUnpack:
- resources/*
artifactName: "Bluestone-${os}-${arch}-${version}.${ext}"
#extraResources:
# - web
extraResources:
- web
fileAssociations:
ext: md
role: Editor
Expand All @@ -42,7 +42,7 @@ mac:
target:
- target: dmg
arch:
- x64
# - x64
- arm64
linux:
target:
Expand All @@ -56,3 +56,8 @@ publish:
provider: github
owner: '1943time'
repo: 'bluestone'

protocols:
name: Bluestone Markdown
schemes:
- bluestone-markdown
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bluestone",
"version": "0.8.0",
"version": "0.8.1",
"description": "",
"main": "./out/main/index.js",
"license": "AGPL-3.0",
Expand All @@ -16,7 +16,7 @@
"build": "npm run typecheck && electron-vite build",
"postinstall": "electron-builder install-app-deps",
"build:win": "electron-builder --win --arm64 --x64 --config",
"build:mac": "electron-builder --macos --arm64 --x64 --config",
"build:mac": "electron-builder --macos --config",
"build:mas": "npm run build && electron-builder --macos --config mas-builder.yml",
"build:linux": "electron-builder --linux --config",
"unpackage": "rm -rf unpackage && asar extract dist/mac-arm64/bluestone.app/Contents/Resources/app.asar ./unpackage",
Expand Down
4 changes: 4 additions & 0 deletions src/main/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const baseUrl = is.dev && process.env['ELECTRON_RENDERER_URL'] ? process.
const workerPath = join(__dirname, '../renderer/worker.html')
import BrowserWindowConstructorOptions = Electron.BrowserWindowConstructorOptions
import fetch from 'node-fetch'
import {openAuth} from './auth'

export const windowOptions: BrowserWindowConstructorOptions = {
show: false,
Expand Down Expand Up @@ -50,6 +51,9 @@ export const registerApi = () => {
ipcMain.handle('get-path', (e, type: Parameters<typeof app.getPath>[0]) => {
return app.getPath(type)
})
ipcMain.on('open-auth', (e, type: 'github') => {
openAuth(type)
})
ipcMain.handle('get-env', () => {
return {
isPackaged: app.isPackaged,
Expand Down
54 changes: 40 additions & 14 deletions src/main/appMenus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export const createAppMenus = () => {
italic: 'Italic',
strikethrough: 'Strikethrough',
inlineCode: 'Inline Code',
insertPicture: 'Insert Picture',
clear: 'Clear',
view: 'View',
zoomIn: 'Zoom In',
Expand Down Expand Up @@ -164,9 +163,19 @@ export const createAppMenus = () => {
{type: 'separator'},
{
label: menusLabel.pdf,
id: 'print-pdf',
enabled: false,
click: (e, win) => {
win?.webContents.send('call-print-pdf')
}
},
{
label: menusLabel.html,
id: 'print-html',
enabled: false,
click: (e, win) => {
win?.webContents.send('call-print-html')
}
}
]
})
Expand Down Expand Up @@ -309,19 +318,32 @@ export const createAppMenus = () => {
click: task('code')
},
{
label: menusLabel.insertPicture,
label: 'Image',
accelerator: `${cmd}+p`,
click: (e, win) => {
dialog.showOpenDialog({
properties: ['openFile'],
filters: [{extensions: ['png', 'jpg', 'jpeg', 'gif', 'webp'], name: 'Image'}],
securityScopedBookmarks: true
}).then(res => {
if (res.filePaths.length) {
win?.webContents.send('key-task', 'insertImage', res.filePaths[0])
submenu: [
{
label: 'Insert local image',
accelerator: `${cmd}+p`,
click: (e, win) => {
dialog.showOpenDialog({
properties: ['openFile'],
filters: [{extensions: ['png', 'jpg', 'jpeg', 'gif', 'webp'], name: 'Image'}],
securityScopedBookmarks: true
}).then(res => {
if (res.filePaths.length) {
win?.webContents.send('key-task', 'insertImage', res.filePaths[0])
}
})
}
})
}
},
{
accelerator: `${cmd}+shift+p`,
label: 'Insert image via url',
click: (e, win) => {
win?.webContents.send('key-task', 'insertNetworkImage')
}
}
]
},
{type: 'separator'},
{
Expand All @@ -347,8 +369,6 @@ export const createAppMenus = () => {
}
]
const devTools:MenuOptions[number]['submenu'] = is.dev ? [
{type: 'separator'},
{role: 'reload'},
{role: 'toggleDevTools'}
] : []
menus.push(
Expand Down Expand Up @@ -379,6 +399,8 @@ export const createAppMenus = () => {
BrowserWindow.getFocusedWindow()?.webContents.send('open-search')
}
},
{type: 'separator'},
{role: 'reload'},
...devTools
],
}
Expand Down Expand Up @@ -459,4 +481,8 @@ export const createAppMenus = () => {
break
}
})
ipcMain.on('open-file', (e, isMarkdown: boolean) => {
instance.getMenuItemById('print-pdf')!.enabled = isMarkdown
instance.getMenuItemById('print-html')!.enabled = isMarkdown
})
}
6 changes: 6 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {baseUrl, isDark, registerApi, windowOptions} from './api'
import {createAppMenus} from './appMenus'
import {registerMenus} from './menus'
import {store} from './store'
import log from 'electron-log'
import {AppUpdate} from './update'
const isWindows = process.platform === 'win32'

Expand All @@ -18,6 +19,7 @@ type WinOptions = {
}

const windows = new Map<number, WinOptions>()
app.setAsDefaultProtocolClient('bluestone-markdown')
function createWindow(initial?: WinOptions): void {
const dark = isDark()
const {width, height} = screen.getPrimaryDisplay().workAreaSize
Expand Down Expand Up @@ -84,6 +86,10 @@ app.on('will-finish-launching', () => {
openFiles(file)
}
})
app.on('open-url', (event, url) => {
log.info('open-url', url)
BrowserWindow.getFocusedWindow()?.webContents.send('open-schema', url)
})
})
const openFiles = (filePath: string) => {
try {
Expand Down
7 changes: 7 additions & 0 deletions src/main/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ export const registerMenus = () => {
win?.webContents.send('call-print-pdf')
}
},
{
label: menusLabel.html,
enabled: filePath?.endsWith('.md'),
click: (e, win) => {
win?.webContents.send('call-print-html')
}
},
{
type: 'separator'
},
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/src/api/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export const MainApi = {
closeWindow() {
ipcRenderer.send('close-window')
},
openAuth(type: 'github') {
ipcRenderer.send('open-auth', type)
},
getSystemDark() {
return ipcRenderer.invoke('get-system-dark')
},
Expand Down
26 changes: 26 additions & 0 deletions src/renderer/src/components/AceCode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import AceEditor from 'react-ace'

export function AceCode(props: {
value?: string
onChange?: (v: string) => void
}) {
return (
<div className={'pt-2'}>
<AceEditor
mode={'json'}
setOptions={{
showGutter: false,
highlightActiveLine: false,
useWorker: false
}}
theme="cloud9_night"
height={'400px'}
width={'100%'}
tabSize={2}
value={props.value}
onChange={props.onChange}
editorProps={{ $blockScrolling: true}}
/>
</div>
)
}
Loading

0 comments on commit d4dd4b1

Please sign in to comment.