init
commit
dffc739c40
|
@ -0,0 +1,23 @@
|
|||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
|
@ -0,0 +1,70 @@
|
|||
# Getting Started with Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `npm start`
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
||||
|
||||
The page will reload when you make changes.\
|
||||
You may also see any lint errors in the console.
|
||||
|
||||
### `npm test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `npm run build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `npm run eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
||||
|
||||
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
||||
|
||||
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
|
||||
### Code Splitting
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
||||
|
||||
### Analyzing the Bundle Size
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
||||
|
||||
### Making a Progressive Web App
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
||||
|
||||
### Deployment
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
||||
|
||||
### `npm run build` fails to minify
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
|
@ -0,0 +1,25 @@
|
|||
const { openSite } = require("./site");
|
||||
const { ipcRenderer } = require("electron");
|
||||
const { reSize } = require("./windows");
|
||||
const ipc = {
|
||||
site: {
|
||||
open: openSite,
|
||||
},
|
||||
windows: {
|
||||
reSize: reSize,
|
||||
},
|
||||
};
|
||||
|
||||
function getAPI(namespace) {
|
||||
let api = {};
|
||||
for (const key in ipc[namespace]) {
|
||||
api[key] = (...props) => ipcRenderer.send(namespace + "-" + key, ...props);
|
||||
}
|
||||
console.log(api);
|
||||
return api;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ipc,
|
||||
getAPI,
|
||||
};
|
|
@ -0,0 +1,18 @@
|
|||
const { shell } = require("electron");
|
||||
|
||||
const openSite = (url, success, fail) => {
|
||||
console.log("opensite");
|
||||
console.log(url);
|
||||
shell
|
||||
.openExternal(url)
|
||||
.then(() => {
|
||||
if (success) success();
|
||||
})
|
||||
.catch((e) => {
|
||||
if (fail) fail(e);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
openSite,
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
const reSize = (width, height) => {
|
||||
global.windows.setSize(width, height);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
reSize,
|
||||
};
|
|
@ -0,0 +1,80 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, Menu, ipcMain } = require("electron");
|
||||
const path = require("path");
|
||||
const ipc = require("./ipc/ipc").ipc;
|
||||
|
||||
global.windows = {};
|
||||
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
global.windows = new BrowserWindow({
|
||||
width: 1000,
|
||||
height: 650,
|
||||
minHeight: 600,
|
||||
minWidth: 800,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: true,
|
||||
preload: path.join(__dirname, "preload.js"),
|
||||
},
|
||||
});
|
||||
|
||||
global.windows.loadURL("http://127.0.0.1:3000").then((r) => {
|
||||
console.log(r);
|
||||
});
|
||||
|
||||
// mainWindow.loadFile('./build/index.html')
|
||||
|
||||
// Open the DevTools.
|
||||
global.windows.webContents.openDevTools();
|
||||
|
||||
global.windows.setTitle("Todo App");
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
|
||||
app.on("activate", function () {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
});
|
||||
});
|
||||
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
// for applications and their menu bar to stay active until the user quits
|
||||
// explicitly with Cmd + Q.
|
||||
app.on("window-all-closed", function () {
|
||||
// if (process.platform !== "darwin") app.quit();
|
||||
app.quit();
|
||||
});
|
||||
|
||||
for (const key in ipc) {
|
||||
for (const event in ipc[key]) {
|
||||
console.log("registering ipc event", key, event);
|
||||
ipcMain.on(key + "-" + event, (e, ...args) => {
|
||||
console.log("ipc event", key, event, args);
|
||||
ipc[key][event](...args);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//设置菜单
|
||||
// let dockMenu = Menu.buildFromTemplate([
|
||||
// {
|
||||
// label: "fileset",
|
||||
// submenu: [{ label: "文件" }],
|
||||
// },
|
||||
// {
|
||||
// label: "编辑",
|
||||
// submenu: [{ label: "保存" }, { label: "另存" }],
|
||||
// },
|
||||
// { label: "帮助", submenu: [{ label: "关于" }] },
|
||||
// ]);
|
||||
// Menu.setApplicationMenu(dockMenu);
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and require them here.
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "fileset",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"main": "main.js",
|
||||
"dependencies": {
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0",
|
||||
"react-scripts": "5.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test --env=jsdom",
|
||||
"eject": "react-scripts eject",
|
||||
"electron-start": "electron ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^10.4.4",
|
||||
"electron": "^18.0.1",
|
||||
"postcss": "^8.4.12",
|
||||
"tailwindcss": "^3.0.23"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
const { contextBridge } = require("electron");
|
||||
const ipc = require("./ipc/ipc").ipc;
|
||||
const getAPI = require("./ipc/ipc").getAPI;
|
||||
|
||||
console.log(ipc);
|
||||
for (const key in ipc) {
|
||||
console.log(key);
|
||||
contextBridge.exposeInMainWorld(key, getAPI(key));
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<title>Fileset</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,4 @@
|
|||
.box {
|
||||
grid-template-columns: 250px 1fr;
|
||||
@apply w-screen h-screen;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
import "./App.css";
|
||||
import Fileset from "./Fileset";
|
||||
|
||||
function App() {
|
||||
let openSite = () => {
|
||||
// console.log(window);
|
||||
// window["windows"].reSize(1000, 1000);
|
||||
};
|
||||
return (
|
||||
<div className="App">
|
||||
<div className={"grid box"}>
|
||||
<div className={"bg-gray-100"}>
|
||||
<div className={"flex gap-2 ml-2 my-2 items-center"}>
|
||||
<div
|
||||
className={"border rounded-full w-[80px] h-[80px] bg-blue-500"}
|
||||
/>
|
||||
<div className={"flex flex-col"}>
|
||||
<div
|
||||
className={"text-3xl select-none text-gray-700 font-bold"}
|
||||
onClick={openSite}
|
||||
>
|
||||
Fileset.io
|
||||
</div>
|
||||
<div className={"text-sm text-gray-400 mt-2 select-none"}>
|
||||
fileset of telegram api
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr className={"my-2 bg-amber-900"} />
|
||||
<ol className={"mt-5 w-full text-center text-xl"}>
|
||||
<MenuItem>文件集</MenuItem>
|
||||
<MenuItem>同步盘</MenuItem>
|
||||
<MenuItem>收藏夹</MenuItem>
|
||||
<MenuItem>保险箱</MenuItem>
|
||||
<MenuItem>回收站</MenuItem>
|
||||
<hr className={"my-2 bg-amber-900"} />
|
||||
<MenuItem>我的分享</MenuItem>
|
||||
<MenuItem>传输列表</MenuItem>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<Fileset />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MenuItem(props) {
|
||||
return (
|
||||
<li className={"py-2 cursor-pointer select-none hover:bg-gray-200"}>
|
||||
{props.children}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
|
@ -0,0 +1,62 @@
|
|||
import useContextMenu from "./hook/contextMenu";
|
||||
|
||||
function Fileset() {
|
||||
let { anchorPoint, show } = useContextMenu({ minX: 250 });
|
||||
|
||||
return (
|
||||
<div className={"bg-gray-200 flex flex-col"}>
|
||||
<div className={"h-[200px]"}>
|
||||
<div
|
||||
data-key={"fileset1"}
|
||||
onDoubleClick={() => {
|
||||
console.log("double click");
|
||||
}}
|
||||
>
|
||||
文件集
|
||||
</div>
|
||||
{show ? (
|
||||
<div
|
||||
className={"fixed bg-white shadow px-1 select-none"}
|
||||
style={
|
||||
anchorPoint.y < window.innerHeight - 300
|
||||
? { top: anchorPoint.y, left: anchorPoint.x }
|
||||
: {
|
||||
bottom: window.innerHeight - anchorPoint.y,
|
||||
left: anchorPoint.x,
|
||||
}
|
||||
}
|
||||
>
|
||||
<ContextMenuItem>下载</ContextMenuItem>
|
||||
<ContextMenuItem>分享</ContextMenuItem>
|
||||
<ContextMenuItem>收藏</ContextMenuItem>
|
||||
<hr />
|
||||
<ContextMenuItem>重命名</ContextMenuItem>
|
||||
<ContextMenuItem>移动</ContextMenuItem>
|
||||
<ContextMenuItem>查看详细信息</ContextMenuItem>
|
||||
<hr />
|
||||
<ContextMenuItem important>移到回收站</ContextMenuItem>
|
||||
</div>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</div>
|
||||
<div className={"w-full h-full"}>content</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ContextMenuItem(props) {
|
||||
return (
|
||||
<div
|
||||
className={`py-2 px-5 my-1.5 cursor-pointer rounded-xl ${
|
||||
props.important
|
||||
? "text-red-500 hover:text-red-700"
|
||||
: "text-gray-900 hover:text-gray-500"
|
||||
}`}
|
||||
>
|
||||
{props.children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Fileset;
|
|
@ -0,0 +1,31 @@
|
|||
import { useEffect, useCallback, useState } from "react";
|
||||
|
||||
const useContextMenu = (range) => {
|
||||
const [anchorPoint, setAnchorPoint] = useState({ x: 0, y: 0 });
|
||||
const [show, setShow] = useState(false);
|
||||
|
||||
const handleContextMenu = useCallback(
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
if (range.minX && event.pageX < range.minX) return;
|
||||
|
||||
setAnchorPoint({ x: event.pageX, y: event.pageY });
|
||||
setShow(true);
|
||||
},
|
||||
[setShow, setAnchorPoint]
|
||||
);
|
||||
|
||||
const handleClick = useCallback(() => (show ? setShow(false) : null), [show]);
|
||||
|
||||
useEffect(() => {
|
||||
document.addEventListener("click", handleClick);
|
||||
document.addEventListener("contextmenu", handleContextMenu);
|
||||
return () => {
|
||||
document.removeEventListener("click", handleClick);
|
||||
document.removeEventListener("contextmenu", handleContextMenu);
|
||||
};
|
||||
});
|
||||
return { anchorPoint, show };
|
||||
};
|
||||
|
||||
export default useContextMenu;
|
|
@ -0,0 +1,4 @@
|
|||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind screens;
|
||||
@tailwind utilities;
|
|
@ -0,0 +1,10 @@
|
|||
import React from "react";
|
||||
import * as ReactDOMClient from "react-dom/client";
|
||||
import "./index.css";
|
||||
import App from "./App";
|
||||
|
||||
ReactDOMClient.createRoot(document.getElementById("root")).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
|
@ -0,0 +1,7 @@
|
|||
module.exports = {
|
||||
content: ["./src/**/*.{js,jsx,ts,tsx}"],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
Loading…
Reference in New Issue