Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
But those who disbelieve and reject Our revelations—these will have a…
Browse files Browse the repository at this point in the history
… humiliating punishment.

The Holy Quran · Al-Hajj (The Pilgrimage) · 22:57
  • Loading branch information
raisfeld-ori committed Mar 23, 2024
1 parent ab7105a commit 0ec19b3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod data;
use std::fs::read_dir;
use std::path::PathBuf;
use fs::encryption::aes_decrypt;
use tauri::Runtime;
use tauri::{Manager, Runtime};
use crate::data::json::{init_user_data, user_get, create_value, user_make, system_get, system_make};
use dirs::data_dir;
use base64::{decode_config, encode_config, URL_SAFE};
Expand Down Expand Up @@ -53,10 +53,12 @@ async fn first_init<R: Runtime>(app: tauri::AppHandle<R>, window: tauri::Window<

#[tauri::command]
async fn console(value: String) {println!("{}", value)}
#[tauri::command]
async fn close_app<R: Runtime>(window: tauri::Window<R>) -> tauri::Result<()> {window.close()}

fn main() {
tauri::Builder::default().invoke_handler(tauri::generate_handler![
first_init, console, user_get, authenticate_user, save_user, user_exists, load_user, ls, pwd, cd, create_user,
create_value, mkdir, system_get, system_make, user_make,
create_value, mkdir, system_get, system_make, user_make, close_app,
]).run(tauri::generate_context!()).expect("failed to run the code");
}
5 changes: 3 additions & 2 deletions src/pages/main_page/internal_apps/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
}

.ApplicationDirectory {
position: absolute;
position:relative;
display: block;
margin-bottom: 1px;
height: 10svh;
border-top: 2px #0202022f;
border-left: 2px #0202022f;
border-top-right-radius: 20px;
Expand Down Expand Up @@ -87,7 +89,6 @@ border-radius: 20px;
font-size: 1.5em;
text-align: left;
font-weight: lighter;

color: rgb(189, 184, 184);

font-style: italic;
Expand Down
30 changes: 20 additions & 10 deletions src/pages/main_page/internal_apps/apps/file_system.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import App from '../App';
import { invoke } from '@tauri-apps/api';
import { useState, useEffect } from 'react';

async function create_file(){
console.log(await invoke('system_get', {key: 'name'}));
}
import img from '../../assets/terminal.png';

function file_system() : [JSX.Element, React.Dispatch<React.SetStateAction<string>>, JSX.Element]{
const [location, set_location] = useState("Home");
const [files, set_files] = useState([]);
const [files, set_files] = useState<React.JSX.Element[]>([]);
//@ts-expect-error
invoke("ls", {}).then(result => set_files(result)).catch(console.log);
//@ts-expect-error
Expand All @@ -20,27 +17,40 @@ function file_system() : [JSX.Element, React.Dispatch<React.SetStateAction<strin
document.addEventListener("click", () => set_ctx_display('none'));
return () => document.removeEventListener("click", () => set_ctx_display('none'));
}, [])

const right_click = (ev: React.MouseEvent) => {
ev.preventDefault();
console.log("right clicked");
set_ctx_display('inherit');
set_positions({dx: ev.clientX, dy: ev.clientY});
}
const make_files = () => {
const NewFile = () =>{
const [editing, set_editing] = useState(true);
const [text, set_text] = useState('');
const done_editing = () => {set_editing(false);}

return <div className='file'>
<img src={img} className='file_img'/><br />
{editing ? <input className='editing' onChange={e => set_text(e.target.value)}
onBlur={done_editing} onKeyDownCapture={e => {if (e.key == 'Enter'){done_editing()}}} autoFocus></input>
: <p className='file_name'>{text}</p>}
</div>
}
set_files([...files, <NewFile/>]);
}
let context_menu = <div className='ContextMenu'
style={{
top: dy + 2 + 'px',
left: dx + 2 + 'px',
display: `${ctx_display}`,
}}
><button onClick={create_file}>create dir</button></div>;
><button onClick={make_files}>
create dir</button></div>;
let Application = <div className='ApplicationDirectory'>
<h1 className='filesystemtxt2'>/{location}/</h1>
<>{files}</>
</div>
let app_html = <div className='frametest2' onContextMenu={right_click}>
{Application}
{Application}
<>{files}</>
</div>;
const [display, set_display] = useState('none');
let app = <App element={app_html} display={display} set_display={set_display} name='File System'/>;
Expand Down
3 changes: 1 addition & 2 deletions src/pages/main_page/main_page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import daddy from './assets/daddyishome.png';
import { invoke } from '@tauri-apps/api';



export default function MainPage() {
const navigate = useNavigate();
const [app, fs_display, ctx_menu] = file_system();
Expand Down Expand Up @@ -43,7 +42,7 @@ export default function MainPage() {
<img src={leaveicon} alt="leaveicon" />
</button>
<p className='hiddentxt'>Logout​</p>
<button className='exit' onClick={() => window.close()}>
<button className='exit' onClick={async () => await invoke('close_app', {})}>
<img src={exit} alt="exiticon" />
</button>
<p className='hiddenclose'>Exit 😭​</p>
Expand Down

0 comments on commit 0ec19b3

Please sign in to comment.