Skip to content

Commit

Permalink
To vite vue (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
nekobato authored Jan 6, 2024
1 parent 46b4d7c commit 4868a81
Show file tree
Hide file tree
Showing 92 changed files with 7,844 additions and 36,695 deletions.
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

20 changes: 0 additions & 20 deletions composables/hazyRoute.ts

This file was deleted.

13 changes: 6 additions & 7 deletions electron-builder.config.js → electron-builder.json5
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const package = require("./package.json");

module.exports = {
{
$schema: "https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json",
appId: "net.nekobato.hazy",
asar: true,
productName: "hazy",
directories: {
output: "release/${version}",
},
files: [".output/**/*", "dist-electron"],
files: ["dist", "dist-electron"],
mac: {
category: "public.app-category.social-networking",
icon: ".output/public/icons/mac/icon.icns",
icon: "dist/icons/mac/icon.icns",
artifactName: "${productName}_${version}.${ext}",
target: ["dmg"],
publish: [
Expand All @@ -35,5 +35,4 @@ module.exports = {
allowToChangeInstallationDirectory: true,
deleteAppDataOnUninstall: false,
},
buildVersion: package.version,
};
}
6 changes: 0 additions & 6 deletions electron/tsconfig.json

This file was deleted.

12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>hazy</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 22 additions & 2 deletions electron/db.ts → main/db.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { safeStorage } from "electron";
import Store from "electron-store";
import { nanoid } from "nanoid/non-secure";
import type { Instance, Timeline, User, Settings } from "@/types/store";
import { storeDefaults } from "../utils/statics";
import type { Instance, Timeline, User, Settings, InstanceStore } from "../shared/types/store";

export type StoreSchema = {
timelines: Timeline[];
Expand All @@ -11,6 +10,27 @@ export type StoreSchema = {
settings: Settings;
};

export const storeDefaults = {
users: [] as User[],
instances: [] as InstanceStore[],
timelines: [] as Timeline[],
settings: {
opacity: 50,
hazyMode: "show",
windowSize: {
width: 475,
height: 600,
},
maxPostCount: 1000,
postStyle: "all",
shortcuts: {},
shouldAppUpdate: true,
misskey: {
hideCw: false,
},
} as Settings,
};

const schema: Store.Schema<StoreSchema> = {
timelines: {
type: "array",
Expand Down
17 changes: 17 additions & 0 deletions main/electron-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// <reference types="vite-plugin-electron/electron-env" />

declare namespace NodeJS {
interface ProcessEnv {
DIST: string;
VITE_PUBLIC: string;
}
}

interface Window {
ipc: {
send: (event: string, payload?: any) => void;
invoke: (event: string, payload?: any) => Promise<any>;
on: (event: string, callback: (event: Electron.IpcRendererEvent, ...args: any[]) => void) => void;
};
openUrl: (e: Event, url: string) => void;
}
File renamed without changes.
9 changes: 7 additions & 2 deletions electron/index.ts → main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import menuTemplate from "./menu";
import * as db from "./db";
import { apiRequest } from "./api";
import { checkUpdate } from "./autoupdate";
import type { Settings } from "@/types/store";
import type { Settings } from "../shared/types/store";

process.on("uncaughtException", function (error) {
dialog.showErrorBox("Error", error.message);
Expand Down Expand Up @@ -238,4 +238,9 @@ if (DEBUG) {
}
}

app.whenReady().then(start);
app
.whenReady()
.then(start)
.catch((error) => {
dialog.showErrorBox("Error", error.message);
});
36 changes: 23 additions & 13 deletions electron/menu.ts → main/menu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import electron from "electron";
import electron, { app, dialog } from "electron";

type MenuTemplate = (electron.MenuItemConstructorOptions | electron.MenuItem)[];

Expand All @@ -8,9 +8,19 @@ const menuTemplate = ({ mainWindow }: { mainWindow: electron.BrowserWindow | nul
label: "hazy",
submenu: [
{
id: "quit",
label: "Quit hazy",
role: "quit",
label: "About Hazy",
click: () => {
dialog.showMessageBox({
type: "info",
icon: `${__dirname}/../public/icons/png/128x128.png`,
title: "Hazy",
message: `Hazy`,
detail: `Version: ${app.getVersion()}\n\nhttps://github.com/nekobato/hazy/`,
});
},
},
{
type: "separator",
},
{
id: "reload",
Expand All @@ -19,19 +29,19 @@ const menuTemplate = ({ mainWindow }: { mainWindow: electron.BrowserWindow | nul
mainWindow?.webContents.reload();
},
},
{
type: "separator",
},
{
id: "quit",
label: "Quit Hazy",
role: "quit",
},
],
},
{
label: "Edit",
submenu: [
{ label: "Undo", role: "undo" },
{ label: "Redo", role: "redo" },
{ type: "separator" },
{ label: "Cut", role: "cut" },
{ label: "Copy", role: "copy" },
{ label: "Paste", role: "paste" },
{ label: "Select All", role: "selectAll" },
],
role: "editMenu",
},
// @ts-ignore: viewMenu is not defined in d.ts
{
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion electron/static.ts → main/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ process.env.ROOT = path.join(__dirname, "..");
process.env.DIST = path.join(process.env.ROOT, "dist-electron");
process.env.VITE_PUBLIC = process.env.VITE_DEV_SERVER_URL
? path.join(process.env.ROOT, "public")
: path.join(process.env.ROOT, ".output/public");
: path.join(process.env.ROOT, "dist");
process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";

export const preload = path.join(process.env.DIST, "preload.js");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 0 additions & 20 deletions nuxt.config.ts

This file was deleted.

Loading

0 comments on commit 4868a81

Please sign in to comment.