diff --git a/.env b/.env index 5ed58914..8637115c 100755 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -UMI_UI=true -NODE_ENV=production \ No newline at end of file +UMI_UI=false +NODE_ENV=development \ No newline at end of file diff --git a/.umirc.js b/.umirc.js index bbb3964c..dee47d86 100644 --- a/.umirc.js +++ b/.umirc.js @@ -1,15 +1,19 @@ import { defineConfig } from 'umi'; +import slash from 'slash'; -const { resolve } = require('path'); +const { resolve, join } = require('path'); export default defineConfig({ hash: false, - ignoreMomentLocale: true, + dynamicImport: { + loading: 'components/Loader/Loader.js', + }, + // dynamicImport: false, + // history: { type: "hash" }, + targets: { ie: 9 }, - dynamicImport: { - loading: 'components/Loader/Loader.js', - }, dva: { immer: true }, + ignoreMomentLocale: true, nodeModulesTransform: { type: 'none', }, @@ -23,6 +27,7 @@ export default defineConfig({ components: resolve(__dirname, './src/components'), models: resolve(__dirname, './src/models'), routes: resolve(__dirname, './src/routes'), + node_modules: resolve(__dirname, './node_modules') }, extraBabelPlugins: [ [ @@ -35,6 +40,28 @@ export default defineConfig({ 'lodash', ], ], + // externals(context, request, callback) { + // const isDev = process.env.NODE_ENV === 'development'; + // let isExternal = false; + // const load = [ + // 'electron', + // 'fs', + // 'path', + // 'os', + // 'child_process' + // ]; + // if (load.includes(request)) { + // isExternal = `require("${request}")`; + // } + // const appDeps = Object.keys(require('./package.json').dependencies); + // if (appDeps.includes(request)) { + // const orininalPath = slash(join(__dirname, 'node_modules', request)); + // const requireAbsolute = `require('${orininalPath}')`; + // console.log(isDev) + // isExternal = isDev ? requireAbsolute : `require('${request}')`; + // } + // callback(null, isExternal); + // }, // plugins: [themePlugin], // chainWebpack: function(config, { webpack }) { // config.module diff --git a/comty_dev.service b/comty_dev.service deleted file mode 100755 index 7ac93caa..00000000 --- a/comty_dev.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Comty_Development - -[Service] -ExecStart=npm start -Restart=always -User=root -WorkingDirectory=/ycore/development/comty-development - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/comty_dist.service b/comty_dist.service deleted file mode 100755 index 09c4cc50..00000000 --- a/comty_dist.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Comty_Development - -[Service] -ExecStart=serve ./dist -Restart=always -User=root -WorkingDirectory=/ycore/development/comty-development - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/dev-server.sh b/dev-server.sh deleted file mode 100755 index 1dc991f4..00000000 --- a/dev-server.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh - -pause(){ - read -p "Press [Enter] key to continue..." fackEnterKey -} - -start_cli_dev(){ - sudo npm start -} - -start_dev(){ - sudo systemctl start comty_dev - echo "Starting dev server..." -} - -stop_dev(){ - sudo systemctl stop comty_dev - echo "Stoping dev server..." -} -show_logs(){ - sudo journalctl -u comty_dev -} -update(){ - git reset --merge&&git fetch --all&&git reset --hard origin/master - - -} - -show_menus() { - clear - echo "~~~~~~~~~~~~~~~~~~~~~" - echo " Development Server " - echo "~~~~~~~~~~~~~~~~~~~~~" - echo "1. Start CLI Server" - echo "2. Start Server" - echo "3. Stop Server" - echo "4. Show DevServer Logs" - echo "5. Update from Git" - echo "" - echo "0. Exit" -} - -read_options(){ - local choice - read -p "Enter choice [ 1 - 5 ] " choice - case $choice in - 0) exit 0;; - 1) start_cli_dev ;; - 2) start_dev ;; - 3) stop_dev ;; - 4) show_logs;; - 5) update;; - *) echo -e "${RED}Error...${STD}" && sleep 2 - esac -} - -trap '' SIGINT SIGQUIT SIGTSTP - -while true -do - - show_menus - read_options -done \ No newline at end of file diff --git a/dist-server.sh b/dist-server.sh deleted file mode 100755 index d99979fc..00000000 --- a/dist-server.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh - -pause(){ - read -p "Press [Enter] key to continue..." fackEnterKey -} - -start_cli_dev(){ - sudo serve ./dist -} - -start_dev(){ - sudo systemctl start comty_dist - echo "Starting dev server..." -} - -stop_dev(){ - sudo systemctl stop comty_dist - echo "Stoping dev server..." -} -show_logs(){ - sudo journalctl -u comty_dist - pause -} - - -show_menus() { - clear - echo "~~~~~~~~~~~~~~~~~~~~~" - echo " BuildServe Server " - echo "~~~~~~~~~~~~~~~~~~~~~" - echo "1. Start CLI Server" - echo "2. Start Server" - echo "3. Stop Server" - echo "4. Show DevServer Logs" - echo "" - echo "0. Exit" -} - -read_options(){ - local choice - read -p "Enter choice [ 1 - 4 ] " choice - case $choice in - 0) exit 0;; - 1) start_cli_dev ;; - 2) start_dev ;; - 3) stop_dev ;; - 4) show_logs;; - *) echo -e "${RED}Error...${STD}" && sleep 2 - esac -} - -trap '' SIGINT SIGQUIT SIGTSTP - -while true -do - - show_menus - read_options -done \ No newline at end of file diff --git a/electron-builder.yml b/electron-builder.yml new file mode 100644 index 00000000..6cac0d4d --- /dev/null +++ b/electron-builder.yml @@ -0,0 +1,12 @@ +appId: com.example.bruh +productName: Bruh +copyright: Copyright © Bruh +directories: + output: dist + buildResources: resources +files: + - from: . + filter: + - package.json + - app +publish: null diff --git a/main/configs/config.js b/main/configs/config.js new file mode 100644 index 00000000..2dbfdd50 --- /dev/null +++ b/main/configs/config.js @@ -0,0 +1,3 @@ +const Config = require('electron-config') + +module.exports = new Config({ name: 'config' }); \ No newline at end of file diff --git a/main/index.js b/main/index.js new file mode 100644 index 00000000..511e4cae --- /dev/null +++ b/main/index.js @@ -0,0 +1,83 @@ +const { app, BrowserWindow, Menu, Tray, nativeImage } = require('electron') +const { join } = require('path') +const path = require('path') +const packagejson = require('../package.json') +const is = require('electron-is') +const waitOn = require('wait-on'); + +let app_path = `file://${join(__dirname, '..', 'renderer')}/index.html`; + +if (is.dev()) { + require('electron-debug')(); // eslint-disable-line global-require +} + +if (is.dev()) { + app_path = 'http://127.0.0.1:8000/'; +} + +// app.on('window-all-closed', () => { +// if (process.platform !== 'darwin') { +// app.quit(); +// } +// }); + +app.on('activate', () => { + // inits +}); + +app.on('ready', () => { + loadWindow = new BrowserWindow({ + icon: nativeImage.createFromPath(path.join(__dirname, '/public/favicon.png')), + width: 700, + height: 600, + frame: false, + resizable: false, + center: true, + transparent: true, + + }); + + mainWindow = new BrowserWindow({ + icon: nativeImage.createFromPath(path.join(__dirname, '/public/favicon.png')), + show: false, + width: 1280, + height: 720, + frame: false, + webPreferences: { + nodeIntegration: true + } + }); + + tray = new Tray(nativeImage.createFromPath(path.join(__dirname, '/public/favicon.png'))) + + const contextMenu = Menu.buildFromTemplate([ + { label: 'Open', type: 'normal', click: function(){ + mainWindow.show(); + } }, + { label: 'bruh', type: 'radio', checked: true }, + ]) + tray.setToolTip(packagejson.title) + tray.setContextMenu(contextMenu) + + if (is.dev()) { + loadWindow.loadURL(`file://${__dirname}/statics/loading_dev.html`) + }else{ + loadWindow.loadURL(`file://${__dirname}/statics/loading.html`) + } + + waitOn({ resources: [app_path] }, function (err) { + if (err) { + return console.log(err, ' | electron Aborted create window') + } + loadWindow.close() + mainWindow.show() + mainWindow.loadURL(app_path); + }); + +}); + +app.on('close', (event) => { + event.preventDefault(); + mainWindow.hide(); +}); + diff --git a/main/statics/loading.css b/main/statics/loading.css new file mode 100644 index 00000000..649da376 --- /dev/null +++ b/main/statics/loading.css @@ -0,0 +1,97 @@ +body { + background-color: transparent; + border-radius: 12px; + resize: none; + font-family: 'Alata', sans-serif; +} +.wrapper { + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + background-color: #222222; + color: #efefef; + border-radius: 12px; + text-align: center; + padding: 20px; +} +.bouncy-logo { + width: 400px; + height: 400px; + margin: 0 auto; + position: relative; + } + .bouncy-logo .ball img { + position: absolute; + height: 200px; + width: 200px; + top: 0; + left: 43%; + transform: translate(-50%, 0); + -webkit-animation-direction: alternate; + -webkit-animation-duration: 1s; + -webkit-animation-name: my-bounce; + -webkit-animation-iteration-count: infinite; + animation-direction: alternate; + animation-duration: 1s; + animation-name: my-bounce; + animation-iteration-count: infinite; + } + .bouncy-logo .ball-shadow { + background: radial-gradient(50% 50%, #ccc 0%, transparent 100%); + height: 50px; + width: 200px; + position: absolute; + top: 230px; + left: 50%; + transform: translate(-50%, 0); + -webkit-animation-direction: alternate; + -webkit-animation-duration: 1s; + -webkit-animation-name: my-grow; + -webkit-animation-iteration-count: infinite; + animation-direction: alternate; + animation-duration: 1s; + animation-name: my-grow; + animation-iteration-count: infinite; + } + + @-webkit-keyframes my-grow { + from { + width: 200px; + height: 50px; + top: 230px; + } + to { + width: 150px; + height: 10px; + top: 240px; + } + } + @keyframes my-grow { + from { + width: 200px; + height: 50px; + top: 230px; + } + to { + width: 150px; + height: 10px; + top: 240px; + } + } + @-webkit-keyframes my-bounce { + from { + top: 0; + } + to { + top: 10%; + } + } + @keyframes my-bounce { + from { + top: 0; + } + to { + top: 10%; + } + } \ No newline at end of file diff --git a/main/statics/loading.html b/main/statics/loading.html new file mode 100644 index 00000000..94fa0747 --- /dev/null +++ b/main/statics/loading.html @@ -0,0 +1,12 @@ + + + + +
+ +
+ + \ No newline at end of file diff --git a/main/statics/loading_dev.html b/main/statics/loading_dev.html new file mode 100644 index 00000000..b8b776cc --- /dev/null +++ b/main/statics/loading_dev.html @@ -0,0 +1,13 @@ + + + + +
+ +

Starting the development server...

+
+ + \ No newline at end of file diff --git a/package.json b/package.json index a35e1e89..8b43a7fe 100755 --- a/package.json +++ b/package.json @@ -3,30 +3,32 @@ "UUID": "C8mVSr-4nmPp2-pr5Vrz-CU4kg4", "title": "Comty™", "DevBuild": true, - "version": "0.8.22", + "version": "0.8.27", "stage": "dev-pre", "description": "", "author": "RageStudio", "license": "ISC", "private": true, + "main": "main/index.js", + "build": { + "files": [ + "./dist/**/*", + "./pages/**/*", + "./node_modules/**/*" + ], + "appId": "com.rstudio.comty", + "asar": false + }, "scripts": { "start": "umi dev", - "build": "umi build", - "postinstall": "umi generate tmp", - "prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'", - "test": "umi-test", - "test:coverage": "umi-test --coverage" - }, - "gitHooks": { - "pre-commit": "lint-staged" - }, - "lint-staged": { - "*.{js,jsx,less,md,json}": [ - "prettier --write" - ], - "*.ts?(x)": [ - "prettier --parser=typescript --write" - ] + "postinstall": "electron-builder install-app-deps", + "dev": "concurrently \"electron .\" \"umi dev\"", + "build": "npm run build:main && npm run build:renderer", + "build:main": "ESLINT=none roadhog build", + "build:renderer": "ESLINT=none umi build", + "pack": "npm run build && npm run rebuild && build", + "pack:dir": "npm run build && npm run rebuild && build --dir", + "pack:dirOnly": "build --dir" }, "dependencies": { "@icons-pack/react-simple-icons": "^3.8.0", @@ -36,27 +38,26 @@ "@material-ui/core": "^4.9.9", "@material-ui/icons": "^4.9.1", "@ragestudio/ycorejs-lib": "^0.1.22", - "@steveeeie/react-page-transition": "^1.2.0", - "antd": "^4.5.1", + "antd": "^4.6.1", "axios": "^0.19.2", "babel-core": "^6.26.3", "classnames": "^2.2.6", - "dva-model-extend": "^0.1.2", + "electron-config": "^2.0.0", + "electron-is": "^3.0.0", + "electron-log": "^4.2.4", "enquire-js": "^0.2.1", "feather-reactjs": "^2.0.13", "jquery": "^3.5.1", "less-vars-to-js": "^1.3.0", - "lint-staged": "^10.0.7", "localforage": "^1.7.4", "lodash": "^4.17.19", "moment": "^2.27.0", "node-sass": "^4.13.1", "nprogress": "^0.2.0", "path-to-regexp": "^6.1.0", - "prettier": "^1.19.1", - "prop-types": "^15.7.2", + "platform": "^1.3.6", "radium": "^0.26.0", - "react": "^16.12.0", + "react": "^16.13.1", "react-animations": "^1.0.0", "react-color": "^2.18.1", "react-dazzle": "^1.4.0", @@ -66,27 +67,39 @@ "react-helmet": "^5.2.1", "react-linkify": "^1.0.0-alpha", "react-perfect-scrollbar": "^1.5.8", + "react-redux": "^7.2.1", "react-reveal": "^1.2.2", "react-scripts": "^3.4.1", - "react-transition-group": "^4.4.1", "react-virtualized": "^9.21.2", "simple-icons": "^3.3.0", + "slash": "^3.0.0", "stack-trace": "0.0.10", "store": "^2.0.12", "styled-components": "^5.1.1", - "timeago.js": "^4.0.2" + "timeago.js": "^4.0.2", + "wait-on": "^5.2.0" }, "devDependencies": { "@lingui/babel-preset-react": "^2.9.0", "@lingui/cli": "^2.9.0", "@lingui/loader": "^2.9.0", "@umijs/preset-react": "^1.4.0", + "electron": "^10.0.1", + "electron-debug": "^2.0.0", + "electron-rebuild": "^1.7.3", + "electron-builder": "^22.8.0", + "electron-devtools-installer": "^3.1.1", + "concurrently": "^3.5.1", "babel-eslint": "^10.0.1", "babel-plugin-dev-expression": "^0.2.1", "babel-plugin-module-resolver": "^4.0.0", "cross-env": "^6.0.0", - "typescript": "^3.8.3", + "dva-model-extend": "^0.1.2", "jsdoc": "^3.6.5", - "umi": "^3.2.9" + "typescript": "^3.8.3", + "umi": "^3.2.17", + "@babel/plugin-syntax-dynamic-import": "^7.8.3", + "@types/electron-devtools-installer": "^2.2.0", + "@types/node": "^12.12.52" } } diff --git a/public/favicon.png b/public/favicon.png new file mode 100644 index 00000000..0f5ca319 Binary files /dev/null and b/public/favicon.png differ diff --git a/src/components/About/index.js b/src/components/About/index.js index 25a79ae7..a7feb70f 100644 --- a/src/components/About/index.js +++ b/src/components/About/index.js @@ -1,12 +1,13 @@ import React from 'react' import styles from './index.less' import { app_info, UUAID, package_json } from 'core' +import * as Icons from 'components/Icons' import * as antd from 'antd' -const { logo, name, version, stage } = app_info +const { logo, name, version, stage, os, layout } = app_info export default class App_About extends React.Component { - DetectNoNStableBuild() { + renderStableTag() { if (package_json.DevBuild == false) { return Stable } else { @@ -21,9 +22,13 @@ export default class App_About extends React.Component {

{name}

{UUAID}
- v{version} - {stage} - {this.DetectNoNStableBuild()} + {os.toString()} + v{version} + {stage} + Render with {layout} + {this.renderStableTag()} + + ) diff --git a/src/components/Layout/WindowNavbar/index.js b/src/components/Layout/WindowNavbar/index.js new file mode 100644 index 00000000..5ec2417a --- /dev/null +++ b/src/components/Layout/WindowNavbar/index.js @@ -0,0 +1,12 @@ +import React from 'react' +import styles from './index.less' + +export default class WindowNavbar extends React.Component{ + render(){ + return( +
+ +
+ ) + } +} \ No newline at end of file diff --git a/src/components/Layout/WindowNavbar/index.less b/src/components/Layout/WindowNavbar/index.less new file mode 100644 index 00000000..d7f83aa6 --- /dev/null +++ b/src/components/Layout/WindowNavbar/index.less @@ -0,0 +1,11 @@ +.navbar{ + display: block; + -webkit-app-region: drag; + height: 35px; + width: 100%; + position: absolute; + z-index: 5000; + top: 0; + right: 0; + background-color: rgba(45, 45, 45, 0.274); +} \ No newline at end of file diff --git a/src/components/Layout/index.js b/src/components/Layout/index.js index a755a706..4566e41a 100755 --- a/src/components/Layout/index.js +++ b/src/components/Layout/index.js @@ -1,5 +1,6 @@ import Sider from './Sider' import Control from './ControlBar' import Overlay from './Overlay/index.tsx' +import WindowNavbar from './WindowNavbar/index.js' -export { Sider, Control, Overlay } +export { Sider, Control, Overlay, WindowNavbar } diff --git a/src/core/cores/router/index.js b/src/core/cores/router/index.js index 1002cc10..b9f0624d 100644 --- a/src/core/cores/router/index.js +++ b/src/core/cores/router/index.js @@ -18,11 +18,11 @@ export const router = { }, go: e => { router.push(e); - goTo.element('primaryContent'); + // goTo.element('primaryContent'); }, goprofile: () => { router.push(`/@${e}`); - goTo.element('primaryContent'); + // goTo.element('primaryContent'); }, }; diff --git a/src/core/index.js b/src/core/index.js index 22369d69..858b54e8 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -4,6 +4,7 @@ import { cloneDeep } from 'lodash'; import store from 'store'; import { i18n, app_config } from 'config'; import * as errorHandlers from 'core/libs/errorhandler' +import platform from 'platform' const { pathToRegexp } = require('path-to-regexp'); @@ -23,6 +24,8 @@ export const app_info = { version: package_json.version, logo: app_config.FullLogoPath, logo_dark: app_config.DarkFullLogoPath, + os: platform.os, + layout: platform.layout }; export function imageToBase64(img, callback){ diff --git a/src/layouts/BaseLayout.js b/src/layouts/BaseLayout.js index abe1bf21..928f7cc1 100755 --- a/src/layouts/BaseLayout.js +++ b/src/layouts/BaseLayout.js @@ -5,6 +5,7 @@ import { Loader } from 'components' import NProgress from 'nprogress' import { withRouter, connect } from 'umi' import { queryLayout } from 'core' +import WindowNavbar from 'components/Layout/WindowNavbar' import config from 'config' import PrimaryLayout from './PrimaryLayout' @@ -43,6 +44,7 @@ class BaseLayout extends React.Component { {config.app_config.siteName} + {this.props.app.electron? : null} {Loader(this.renderLoading)} {children} diff --git a/src/layouts/PrimaryLayout.js b/src/layouts/PrimaryLayout.js index 3fa23546..fdb0de13 100755 --- a/src/layouts/PrimaryLayout.js +++ b/src/layouts/PrimaryLayout.js @@ -53,7 +53,6 @@ class PrimaryLayout extends React.Component { store.set('collapsed', !fromStore) } - render() { const { location, dispatch, children } = this.props const { collapsed, isMobile } = this.state @@ -85,7 +84,7 @@ class PrimaryLayout extends React.Component { window.DarkMode = isActive(currentTheme["darkmode"])? true : false return ( - + {isActive(currentTheme['backgroundImage'])?
: null} - +
- { + if (!this.props.app) { + return false + } let tmp = [] const keys = Object.keys(this.props.app) const values = Object.values(this.props.app) const lenght = keys.length - for (let i = 0; i < lenght; i++) { - let obj = {} - obj.key = keys[i] - obj.value = values[i] - - tmp[i] = obj - } - - const map = tmp.map(e => { - const v = JSON.stringify(e.value) - return( -
-

{e.key}

- {v.length < 500? {v} : {v}} -
- ) - }) + if(lenght > 0){ + for (let i = 0; i < lenght; i++) { + let obj = {} + obj.key = keys[i] + obj.value = values[i] + + tmp[i] = obj + } + + const map = tmp.map(e => { + try { + const v = JSON.stringify(e.value) + if(!v) return false + return( +
+

{e.key}

+ {v.length < 500? {v} : {v}} +
+ ) + } catch (error) { + return null + } + }) - return map + return map + } + return null } - return (
Redux state}> diff --git a/src/theme/base/index.less b/src/theme/base/index.less index 630d2902..28ad5413 100644 --- a/src/theme/base/index.less +++ b/src/theme/base/index.less @@ -38,7 +38,10 @@ } #app { + -webkit-app-region: no-drag; overflow: hidden; + border-radius: 12px; + color: @AppTheme_global_color!important; background-color: @AppTheme_global_background!important; background-repeat: repeat-x; @@ -48,7 +51,7 @@ overflow: hidden; background-color: transparent; margin: auto; - height: 100vh; + height: 100%; width: 100vw; transition: all @__Global_Components_transitions_dur linear; @@ -79,6 +82,8 @@ } body { + -webkit-app-region: no-drag; + scroll-behavior: smooth; height: 100%; @@ -88,7 +93,7 @@ body { line-height: @base-line-height; font-family: @__Global_texted_font; - + border-radius: 12px; } @media (max-width: @bp-small){ @@ -113,10 +118,6 @@ body { } - - - - .text-overflow { white-space: nowrap; text-overflow: ellipsis;