Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows build #2

Open
wants to merge 13 commits into
base: release
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/tauri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: setup node
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 14

- name: install Rust stable
uses: actions-rs/toolchain@v1
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 14.21.3
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "smaug-desktop",
"version": "0.1.1",
"version": "0.1.2",
"private": true,
"dependencies": {
"@auth0/auth0-react": "^1.8.0",
"@craco/craco": "^6.2.0",
"@headlessui/react": "^1.4.1",
"@heroicons/react": "^1.0.4",
"@tailwindcss/forms": "^0.3.3",
"@tauri-apps/api": "^1.0.0-beta.8",
"@tauri-apps/api": "1.0.0-beta.8",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
Expand Down Expand Up @@ -53,27 +53,27 @@
}
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
],
"devDependencies": {
"@babel/core": "^7.24.3",
"@babel/helper-environment-visitor": "^7.22.20",
"@babel/helper-string-parser": "^7.24.1",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/preset-env": "^7.24.3",
"@jridgewell/gen-mapping": "^0.3.5",
"@storybook/addon-actions": "^6.3.8",
"@storybook/addon-essentials": "^6.3.8",
"@storybook/addon-links": "^6.3.8",
"@storybook/node-logger": "^6.3.8",
"@storybook/preset-create-react-app": "^3.2.0",
"@storybook/react": "^6.3.8",
"@tauri-apps/cli": "^1.0.0-beta.10",
"@tauri-apps/cli": "1.0.0-beta.10",
"autoprefixer": "^9",
"babel-loader": "8.3.0",
"postcss": "^7",
"tailwindcss": "npm:@tailwindcss/postcss7-compat"
}
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

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

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "smaug-desktop"
version = "0.1.1"
version = "0.1.2"
description = "A tool to manage your DragonRuby Game Toolkit projects"
authors = [ "Logan Koester <[email protected]>" ]
license = "© 2021 Erebor Studios"
Expand Down
27 changes: 25 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,33 @@ fn main() {
.expect("error while running tauri application");
}

#[cfg(target_family = "unix")]
fn kill_process_unix(pid: i32) {
let p: nix::unistd::Pid = nix::unistd::Pid::from_raw(pid);
nix::sys::signal::kill(p, nix::sys::signal::Signal::SIGHUP).unwrap();
}

#[cfg(target_family = "windows")]
fn kill_process_windows(pid: i32) {
let output = std::process::Command::new("taskkill")
.arg("/PID")
.arg(pid.to_string())
.arg("/F")
.output()
.expect("Failed to execute taskkill command");

if !output.status.success() {
panic!("Failed to kill process with PID: {}", pid);
}
}

#[tauri::command]
fn kill_process(pid: i32) {
let p: nix::unistd::Pid = nix::unistd::Pid::from_raw(pid);
nix::sys::signal::kill(p, nix::sys::signal::Signal::SIGHUP).unwrap();
#[cfg(target_family = "unix")]
kill_process_unix(pid);

#[cfg(target_family = "windows")]
kill_process_windows(pid);
}

#[tauri::command]
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"package": {
"productName": "Smaug Desktop",
"version": "0.1.1"
"version": "0.1.2"
},
"build": {
"distDir": "../build",
Expand Down
11 changes: 11 additions & 0 deletions src/components/Breakpoints.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default () => {
return(
<>
<div id="breakpoint-sm" className="hidden sm:block md:hidden lg:hidden xl:hidden 2xl:hidden w-0 h-0"></div>
<div id="breakpoint-md" className="hidden sm:hidden md:block lg:hidden xl:hidden 2xl:hidden w-0 h-0"></div>
<div id="breakpoint-lg" className="hidden sm:hidden md:hidden lg:block xl:hidden 2xl:hidden w-0 h-0"></div>
<div id="breakpoint-xl" className="hidden sm:hidden md:hidden lg:hidden xl:block 2xl:hidden w-0 h-0"></div>
<div id="breakpoint-2xl" className="hidden sm:hidden md:hidden lg:hidden xl:hidden 2xl:block w-0 h-0"></div>
</>
)
}
62 changes: 62 additions & 0 deletions src/components/DesktopNav.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { useStoreState, useStoreActions } from 'easy-peasy';
import { useState, useEffect } from 'react';
import { getVersion } from '@tauri-apps/api/app'
import { NavLink } from "react-router-dom";

function classNames(...classes) {
return classes.filter(Boolean).join(' ')
}

export default ({ navigation }) => {
const sidebarOpen = useStoreState((state) => state.sidebar.open);

const [version, setVersion] = useState(null);

const getVersionAsync = async () => {
const v = await getVersion();
setVersion(v);
}

useEffect(() => {
if (!version) getVersionAsync();
}, [version]);

return(
<div className={classNames(sidebarOpen ? "md:flex md:flex-shrink-0" : "hidden", "bg-black")}>
<div className="flex flex-col w-40 z-20">
{/* Sidebar component, swap this element with another sidebar if you like */}
<div className="flex flex-col flex-1 min-h-0">
<div className="flex items-center flex-shrink-0 h-16 px-4 bg-gray-800">
<img
className="w-auto h-8 mt-1 mr-3"
src="https://smaug.dev/smaug.png"
alt="Smaug"
/>
<div className="flex-1 text-left">
<h2 className="text-lg font-bold text-white">
smaug
</h2>
<h3 className="text-xs tracking-widest text-gray-400 font-base">
v{version}
</h3>
</div>
</div>
<div className="flex flex-col flex-1 overflow-y-auto">
<nav className="static-sidebar">
{navigation.map((item) => (
<NavLink
exact
key={item.name}
to={item.href}
activeClassName="active">
<item.icon className="icon" aria-hidden="true" />
{item.name}
</NavLink>
))}
</nav>
</div>
</div>
</div>
</div>
)
}
143 changes: 7 additions & 136 deletions src/components/Layout.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import { Fragment, useState, useEffect } from 'react'
import { Dialog, Transition } from '@headlessui/react'
import { useStoreState, useStoreActions } from 'easy-peasy';
import { getVersion } from '@tauri-apps/api/app'
import {
NavLink
} from "react-router-dom";
import { useStoreActions } from 'easy-peasy';

import {
HomeIcon,
MenuAlt2Icon,
XIcon,
CollectionIcon,
CodeIcon,
BookOpenIcon,
CogIcon
} from '@heroicons/react/outline'
import './Layout.css';
import Header from './Header';
import LogViewer from './LogViewer';
import MobileNav from './MobileNav';
import DesktopNav from './DesktopNav';

const navigation = [
{ name: 'Dashboard', href: '/', icon: HomeIcon },
Expand All @@ -26,138 +20,15 @@ const navigation = [
{ name: 'System', href: '/system', icon: CogIcon }
]

function classNames(...classes) {
return classes.filter(Boolean).join(' ')
}

export default function Layout({ header, hero, children, ...props }) {
const sidebarOpen = useStoreState((state) => state.sidebar.open);
const openSidebar = useStoreActions((actions) => actions.openSidebar);
const closeSidebar = useStoreActions((actions) => actions.closeSidebar);
const [version, setVersion] = useState(null);

const getVersionAsync = async () => {
const v = await getVersion();
setVersion(v);
}

useEffect(() => {
if (!version) getVersionAsync();
}, [version]);

//const [sidebarOpen, setSidebarOpen] = useState(false)

return (
<div className="flex h-screen overflow-hidden bg-gray-100">
<Transition.Root show={sidebarOpen} as={Fragment}>
<Dialog as="div" className="fixed inset-0 z-40 flex md:hidden" onClose={openSidebar}>
<Transition.Child
as={Fragment}
enter="transition-opacity ease-linear duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="transition-opacity ease-linear duration-300"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<Dialog.Overlay className="fixed inset-0 bg-gray-600 bg-opacity-75" />
</Transition.Child>
<Transition.Child
as={Fragment}
enter="transition ease-in-out duration-300 transform"
enterFrom="-translate-x-full"
enterTo="translate-x-0"
leave="transition ease-in-out duration-300 transform"
leaveFrom="translate-x-0"
leaveTo="-translate-x-full"
>
<div className="relative flex flex-col flex-1 w-full max-w-xs pt-5 pb-4 bg-gray-800">
<Transition.Child
as={Fragment}
enter="ease-in-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in-out duration-300"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="absolute top-0 right-0 pt-2 -mr-12">
<button
type="button"
className="flex items-center justify-center w-10 h-10 ml-1 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white"
onClick={() => closeSidebar()}
>
<span className="sr-only">Close sidebar</span>
<XIcon className="w-6 h-6 text-white" aria-hidden="true" />
</button>
</div>
</Transition.Child>
<div className="flex items-center flex-shrink-0 px-4">
<img
className="w-auto h-8"
src="https://smaug.dev/smaug.png"
alt="Smaug"
/>
</div>
<div className="flex-1 h-0 mt-5 overflow-y-auto">
<nav className="sidebar">
{navigation.map((item) => (
<NavLink
exact
key={item.name}
to={item.href}
activeClassName="active">
<item.icon className="icon" aria-hidden="true" />
{item.name}
</NavLink>
))}
</nav>
</div>
</div>
</Transition.Child>
<div className="flex-shrink-0 w-14" aria-hidden="true">
{/* Dummy element to force sidebar to shrink to fit close icon */}
</div>
</Dialog>
</Transition.Root>

{/* Static sidebar for desktop */}
<div className={classNames(sidebarOpen ? "md:flex md:flex-shrink-0" : "hidden")}>
<div className="flex flex-col w-40">
{/* Sidebar component, swap this element with another sidebar if you like */}
<div className="flex flex-col flex-1 min-h-0">
<div className="flex items-center flex-shrink-0 h-16 px-4 bg-gray-800">
<img
className="w-auto h-8 mt-1 mr-3"
src="https://smaug.dev/smaug.png"
alt="Smaug"
/>
<div className="flex-1 text-left">
<h2 className="text-lg font-bold text-white">
smaug
</h2>
<h3 className="text-xs tracking-widest text-gray-400 font-base">
v{version}
</h3>
</div>
</div>
<div className="flex flex-col flex-1 overflow-y-auto">
<nav className="static-sidebar">
{navigation.map((item) => (
<NavLink
exact
key={item.name}
to={item.href}
activeClassName="active">
<item.icon className="icon" aria-hidden="true" />
{item.name}
</NavLink>
))}
</nav>
</div>
</div>
</div>
</div>
<MobileNav navigation={navigation} />
<DesktopNav navigation={navigation} />

<div className="flex flex-col flex-1 w-0 h-screen overflow-hidden">
<div className="relative z-10 flex flex-shrink-0 h-16 bg-gray-800 shadow">
<button
Expand Down
Loading