Merge branch 'dev' into docs-pena-team
This commit is contained in:
commit
8a361d260d
4
.github/scripts/auto-sign.sh
vendored
4
.github/scripts/auto-sign.sh
vendored
@ -7,6 +7,6 @@ if [[ -z "$APP_PATH" ]] || [[ -z "$DEVELOPER_ID" ]]; then
|
||||
fi
|
||||
|
||||
# If both variables are set, execute the following commands
|
||||
find "$APP_PATH" \( -type f -perm +111 -o -name "*.node" \) -exec codesign -s "$DEVELOPER_ID" --options=runtime {} \;
|
||||
find "$APP_PATH" \( -type f -perm +111 -o -name "*.node" \) -exec codesign --force -s "$DEVELOPER_ID" --options=runtime {} \;
|
||||
|
||||
find "$APP_PATH" -type f -name "*.o" -exec codesign -s "$DEVELOPER_ID" --options=runtime {} \;
|
||||
find "$APP_PATH" -type f -name "*.o" -exec codesign --force -s "$DEVELOPER_ID" --options=runtime {} \;
|
||||
|
||||
20
README.md
20
README.md
@ -43,31 +43,31 @@ Jan is an open-source ChatGPT alternative that runs 100% offline on your compute
|
||||
<tr style="text-align:center">
|
||||
<td style="text-align:center"><b>Stable (Recommended)</b></td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://github.com/janhq/jan/releases/download/v0.4.7/jan-win-x64-0.4.7.exe'>
|
||||
<a href='https://github.com/janhq/jan/releases/download/v0.4.8/jan-win-x64-0.4.8.exe'>
|
||||
<img src='./docs/static/img/windows.png' style="height:14px; width: 14px" />
|
||||
<b>jan.exe</b>
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://github.com/janhq/jan/releases/download/v0.4.7/jan-mac-x64-0.4.7.dmg'>
|
||||
<a href='https://github.com/janhq/jan/releases/download/v0.4.8/jan-mac-x64-0.4.8.dmg'>
|
||||
<img src='./docs/static/img/mac.png' style="height:15px; width: 15px" />
|
||||
<b>Intel</b>
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://github.com/janhq/jan/releases/download/v0.4.7/jan-mac-arm64-0.4.7.dmg'>
|
||||
<a href='https://github.com/janhq/jan/releases/download/v0.4.8/jan-mac-arm64-0.4.8.dmg'>
|
||||
<img src='./docs/static/img/mac.png' style="height:15px; width: 15px" />
|
||||
<b>M1/M2</b>
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://github.com/janhq/jan/releases/download/v0.4.7/jan-linux-amd64-0.4.7.deb'>
|
||||
<a href='https://github.com/janhq/jan/releases/download/v0.4.8/jan-linux-amd64-0.4.8.deb'>
|
||||
<img src='./docs/static/img/linux.png' style="height:14px; width: 14px" />
|
||||
<b>jan.deb</b>
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://github.com/janhq/jan/releases/download/v0.4.7/jan-linux-x86_64-0.4.7.AppImage'>
|
||||
<a href='https://github.com/janhq/jan/releases/download/v0.4.8/jan-linux-x86_64-0.4.8.AppImage'>
|
||||
<img src='./docs/static/img/linux.png' style="height:14px; width: 14px" />
|
||||
<b>jan.AppImage</b>
|
||||
</a>
|
||||
@ -76,31 +76,31 @@ Jan is an open-source ChatGPT alternative that runs 100% offline on your compute
|
||||
<tr style="text-align:center">
|
||||
<td style="text-align:center"><b>Experimental (Nightly Build)</b></td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://delta.jan.ai/latest/jan-win-x64-0.4.7-304.exe'>
|
||||
<a href='https://delta.jan.ai/latest/jan-win-x64-0.4.8-310.exe'>
|
||||
<img src='./docs/static/img/windows.png' style="height:14px; width: 14px" />
|
||||
<b>jan.exe</b>
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://delta.jan.ai/latest/jan-mac-x64-0.4.7-304.dmg'>
|
||||
<a href='https://delta.jan.ai/latest/jan-mac-x64-0.4.8-310.dmg'>
|
||||
<img src='./docs/static/img/mac.png' style="height:15px; width: 15px" />
|
||||
<b>Intel</b>
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://delta.jan.ai/latest/jan-mac-arm64-0.4.7-304.dmg'>
|
||||
<a href='https://delta.jan.ai/latest/jan-mac-arm64-0.4.8-310.dmg'>
|
||||
<img src='./docs/static/img/mac.png' style="height:15px; width: 15px" />
|
||||
<b>M1/M2</b>
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://delta.jan.ai/latest/jan-linux-amd64-0.4.7-304.deb'>
|
||||
<a href='https://delta.jan.ai/latest/jan-linux-amd64-0.4.8-310.deb'>
|
||||
<img src='./docs/static/img/linux.png' style="height:14px; width: 14px" />
|
||||
<b>jan.deb</b>
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://delta.jan.ai/latest/jan-linux-x86_64-0.4.7-304.AppImage'>
|
||||
<a href='https://delta.jan.ai/latest/jan-linux-x86_64-0.4.8-310.AppImage'>
|
||||
<img src='./docs/static/img/linux.png' style="height:14px; width: 14px" />
|
||||
<b>jan.AppImage</b>
|
||||
</a>
|
||||
|
||||
@ -27,6 +27,7 @@ import { setupReactDevTool } from './utils/dev'
|
||||
import { cleanLogs } from './utils/log'
|
||||
|
||||
import { registerShortcut } from './utils/selectedText'
|
||||
import { createSystemTray } from './utils/tray'
|
||||
|
||||
const preloadPath = join(__dirname, 'preload.js')
|
||||
const rendererPath = join(__dirname, '..', 'renderer')
|
||||
@ -48,33 +49,14 @@ app
|
||||
.then(setupMenu)
|
||||
.then(handleIPCs)
|
||||
.then(handleAppUpdates)
|
||||
.then(createQuickAskWindow)
|
||||
.then(() => process.env.CI !== 'e2e' && createQuickAskWindow())
|
||||
.then(createMainWindow)
|
||||
.then(() => {
|
||||
if (!app.isPackaged) {
|
||||
windowManager.mainWindow?.webContents.openDevTools()
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
const iconPath = join(app.getAppPath(), 'icons', 'icon-tray.png')
|
||||
const tray = new Tray(iconPath)
|
||||
tray.setToolTip(app.getName())
|
||||
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Open Jan',
|
||||
type: 'normal',
|
||||
click: () => windowManager.showMainWindow(),
|
||||
},
|
||||
{
|
||||
label: 'Open Quick Ask',
|
||||
type: 'normal',
|
||||
click: () => windowManager.showQuickAskWindow(),
|
||||
},
|
||||
{ label: 'Quit', type: 'normal', click: () => app.quit() },
|
||||
])
|
||||
tray.setContextMenu(contextMenu)
|
||||
})
|
||||
.then(() => process.env.CI !== 'e2e' && createSystemTray())
|
||||
.then(() => {
|
||||
log(`Version: ${app.getVersion()}`)
|
||||
})
|
||||
|
||||
@ -41,7 +41,6 @@
|
||||
"notarize": {
|
||||
"teamId": "F8AH6NHVY5"
|
||||
},
|
||||
|
||||
"icon": "icons/icon.png"
|
||||
},
|
||||
"linux": {
|
||||
@ -92,7 +91,7 @@
|
||||
"request": "^2.88.2",
|
||||
"request-progress": "^3.0.0",
|
||||
"ulid": "^2.3.0",
|
||||
"@hurdlegroup/robotjs": "^0.11.4"
|
||||
"@nut-tree/nut-js": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron/notarize": "^2.1.0",
|
||||
|
||||
@ -1,19 +1,24 @@
|
||||
import { clipboard, globalShortcut } from "electron";
|
||||
import { keyTap, keys } from "@hurdlegroup/robotjs";
|
||||
import { clipboard, globalShortcut } from 'electron'
|
||||
import { keyboard, Key } from '@nut-tree/nut-js'
|
||||
|
||||
/**
|
||||
* Gets selected text by synthesizing the keyboard shortcut
|
||||
* "CommandOrControl+c" then reading text from the clipboard
|
||||
*/
|
||||
export const getSelectedText = async () => {
|
||||
const currentClipboardContent = clipboard.readText(); // preserve clipboard content
|
||||
clipboard.clear();
|
||||
keyTap("c" as keys, process.platform === "darwin" ? "command" : "control");
|
||||
await new Promise((resolve) => setTimeout(resolve, 200)); // add a delay before checking clipboard
|
||||
const selectedText = clipboard.readText();
|
||||
clipboard.writeText(currentClipboardContent);
|
||||
return selectedText;
|
||||
};
|
||||
const currentClipboardContent = clipboard.readText() // preserve clipboard content
|
||||
clipboard.clear()
|
||||
const hotkeys: Key[] = [
|
||||
process.platform === 'darwin' ? Key.LeftCmd : Key.LeftControl,
|
||||
Key.C,
|
||||
]
|
||||
await keyboard.pressKey(...hotkeys)
|
||||
await keyboard.releaseKey(...hotkeys)
|
||||
await new Promise((resolve) => setTimeout(resolve, 200)) // add a delay before checking clipboard
|
||||
const selectedText = clipboard.readText()
|
||||
clipboard.writeText(currentClipboardContent)
|
||||
return selectedText
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a global shortcut of `accelerator`. The `callback` is called
|
||||
@ -26,14 +31,14 @@ export const registerShortcut = (
|
||||
callback: (selectedText: string) => void
|
||||
) => {
|
||||
return globalShortcut.register(accelerator, async () => {
|
||||
callback(await getSelectedText());
|
||||
});
|
||||
};
|
||||
callback(await getSelectedText())
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a global shortcut of `accelerator` and
|
||||
* is equivalent to electron.globalShortcut.unregister
|
||||
*/
|
||||
export const unregisterShortcut = (accelerator: Electron.Accelerator) => {
|
||||
globalShortcut.unregister(accelerator);
|
||||
};
|
||||
globalShortcut.unregister(accelerator)
|
||||
}
|
||||
|
||||
24
electron/utils/tray.ts
Normal file
24
electron/utils/tray.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { join } from 'path'
|
||||
import { Tray, app, Menu } from 'electron'
|
||||
import { windowManager } from '../managers/window'
|
||||
|
||||
export const createSystemTray = () => {
|
||||
const iconPath = join(app.getAppPath(), 'icons', 'icon-tray.png')
|
||||
const tray = new Tray(iconPath)
|
||||
tray.setToolTip(app.getName())
|
||||
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Open Jan',
|
||||
type: 'normal',
|
||||
click: () => windowManager.showMainWindow(),
|
||||
},
|
||||
{
|
||||
label: 'Open Quick Ask',
|
||||
type: 'normal',
|
||||
click: () => windowManager.showQuickAskWindow(),
|
||||
},
|
||||
{ label: 'Quit', type: 'normal', click: () => app.quit() },
|
||||
])
|
||||
tray.setContextMenu(contextMenu)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user