Giter Site home page Giter Site logo

companydataorganization's Introduction

CompanyDataOrganization for Dev

開発者用のドキュメントです。 環境構築の方法や各種TIPSを残していきます。

https://github.com/RyoIto-jp/CompanyDataOrganization

Installation

ベースにした Python(eel) × React テンプレート https://github.com/hrdtbs/template-create-react-app-eel

Python

https://www.notion.so/mathworks-lic-211102-854c3b7094c845cbbdaacfb26bc7b98b#05660e71d7ea42a8a7b25aa3a9deab66

pipの初期設定

python -m venv myvenv
myvenv\Scripts\activate
myvenv\scripts\python.exe -m pip install --upgrade pip

ライブラリのインストールと設定

  1. eel

    pip install eel
  2. playwright

    pip install playwright
    
    set PLAYWRIGHT_BROWSERS_PATH=0  
    playwright install chromium  
  3. driver設定 以下のフォルダからchrome-winフォルダをコピーして、開発Dir直下のdriverフォルダにペースト %localappdata%\ms-playwright

tips: recording

playwright codegen wikipedia.org playwright codegen lama05:8082/fuel

react

yarn install

rem reactサーバーの起動を確認
yarn start:js

rem build確認
yarn build:js

Eel

#rem reactサーバーをバインドして、Eelを起動
#rem 別ターミナルで実行すること
yarn start:js
yarn start:eel

#rem buildしたreactページをEelで起動
python index.py --product

index.pyカスタマイズ

# coding: utf-8
import eel.browsers
import eel
import sys
import os


@eel.expose
def hello():
    print('hello')
    

# ChromiumのAPIキー欠落アラートの非表示
def disable_chromium_api_message():
    "https://code-examples.net/ja/q/144a85b"
    os.environ["GOOGLE_API_KEY"] = 'no'
    os.environ["GOOGLE_DEFAULT_CLIENT_ID"] = 'no'
    os.environ["GOOGLE_DEFAULT_CLIENT_SECRET "] = 'no'


# develop用起動処理
def react_run():
    disable_chromium_api_message()
    eel.init("client", ['.tsx', '.ts', '.jsx', '.js', '.html'])
    eel.start({"port": 3000}, host="localhost", port=8888, size=(1400, 850), position=(200, 200), close_callback=python_exit)


# 終了時処置
def python_exit(page, sockets):
    if not sockets:
        sys.exit()


# Eel(GUI)を表示するブラウザをChromiumに設定(Chrome未インストールPC用)
ROOT_DIR = os.path.dirname(sys.argv[0])
chrome_path = os.path.join(ROOT_DIR, 'driver/chrome-win/chrome.exe')
if os.path.exists(chrome_path):
    eel.browsers.set_path('chrome', chrome_path)

if __name__ == '__main__':
    debug_mode = 1

    if len(sys.argv) > 2:
        debug_mode = 1 if sys.argv[1] == '--develop' else 0

    if  debug_mode == 1:
        eel.init('client')
        react_run()
    else:
        eel.init('build')
        eel.start('index.html')

フォルダ構成変更

React ./public, ./src, ./build がカレントDirから./webフォルダに変更する。 ./ -> web/

https://www.luku.work/create-react-app-rename-src

yarn add -D react-app-rewired

ROOTにconfig-overrides.jsを作成

const path = require('path');
module.exports = {
  paths: function(paths, env) {
    paths.appPublic = path.resolve(__dirname, 'web/public');
    paths.appHtml = path.resolve(__dirname, 'web/public/index.html');
    paths.appIndexJs = path.resolve(__dirname, 'web/src/index.js');
    paths.appSrc = path.resolve(__dirname, 'web/src');
    paths.appBuild = path.resolve(__dirname, 'web/build');
    return paths;
  }
};

package.jsonを修正

{
  "name": "create-react-app-with-eel",
   //...
  },
  "scripts": {
    //...
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    //...
  },

開発用サーバー立ち上げ

フロントエンド開発

# eelを起動
python gui.py --develop

# react(rewired)を起動
yarn start

この状態でフロントエンド側を開発する。

HOT-Reload

.envファイルを作って以下を記入

FAST_REFRESH = false
CHOKIDAR_USEPOLLING=true

py2exe

python -m eel gui.py web/build --onefile --clean

eel, playwright

eel api

browser

chrome ext alart

react環境構築

デバッグモード

build

deploy

companydataorganization's People

Contributors

ryoito-jp avatar

Watchers

 avatar

companydataorganization's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.