2023年2月3日

electron編譯出錯

 error globalThis.....

在hmtl中加入

<script>
        this.globalThis || (this.globalThis = this)
    </script>

避免錯誤訊息

2023年1月24日

osep scratch3 編譯

 1.安裝git 和node js

2.在家目錄下指令

git  clone https://github.com/estea8968/osep_web_serial.git

cd osep_web_serial

npm install

npm run copy

npm start

如果是win系統

 git  clone https://github.com/estea8968/osep_web_serial.git

cd osep_web_serial

npm install

npm run copy:win

npm run start:win

打包npm run build

2022年12月18日

google calendar連結

 https://calendar.google.com/calendar/render?action=TEMPLATE&text=Birthday&dates=20180201T090000/20180201T180000&sprop=&sprop=name:

text=主題

dates=起時間/終時間


https://calendar.google.com/calendar/render?action=TEMPLATE&text=Example+Google+Calendar+Event&details=More+help+see:+https://support.google.com/calendar/thread/81344786&dates=20201231T160000/20201231T170000&recur=RRULE:FREQ%3DWEEKLY;UNTIL%3D20210603&ctz=America/Toronto


https://github.com/InteractionDesignFoundation/add-event-to-calendar-docs/blob/main/services/google.md

2022年6月14日

scratch3增加擴充積木(進階)

30天通github

https://github.com/doggy8088/Learn-Git-in-30-days

java script快速入門播放清單

https://youtube.com/playlist?list=PLxNBsYH_m6ywXdOfpVgibRbJzidecajoX

scratch-vm index.js結構

 //require基本架構

const ArgumentType = require('../../extension-support/argument-type');
const BlockType = require('../../extension-support/block-type');
const formatMessage = require('format-message');
const msg = require('./translation');

 

物件

class 物件名稱 {

//物件架構

  constructor(runtime) {
        the_locale = this._setLocale();
        this.runtime = runtime;
    }

//物件資料

  getInfo() {
        the_locale = this._setLocale();
        return {
            id: 'mqtt',
            color1: '#003D79', //'#0C5986',
            color2: '#34B0F7',
            name: 'MQTT',
            blockIconURI: 'data:image/png;base64,',
            blocks: [
                {

               }

}

function(){

}

module.exports = 物件名稱;


語系

方法1:

在index.js中有

const msg = require('./translation');

物件中要有function定義語系

_setLocale() {
        let now_locale = '';
        switch (formatMessage.setup().locale) {
            case 'zh-tw':
                now_locale = 'zh-tw';
                break;
            default:
                now_locale = 'en';
                break;
        }
        return now_locale;
    } 

物件架構是呼叫function定義語系

constructor(runtime) {
        the_locale = this._setLocale();
        this.runtime = runtime;
    }

使用方法:

msg.disconnect[the_locale];

在資料夾下,要有translation.js

 檔案內容:

export const disconnect = {
    'en': 'disconnected',
    'zh-tw': '未連線',
};

方法2:

在index.js中加入語系物件

const formatMessage = require('format-message');

const FormLcdShow = {
    'en': 'LCD show text [VALUE] at [ROW] row',
    'zh-tw': 'LCD顯示文字[VALUE]在第[ROW]列',
};

在物件中加入架構

constructor(runtime,util) {
        the_locale = this._setLocale();
        this.runtime = runtime;
    }

需要有function _setLocale()

_setLocale () {
        let now_locale = '';
        switch (formatMessage.setup().locale){
            case 'en':
                now_locale='en';
                break;
            case 'zh-tw':
                now_locale= 'zh-tw';
                break;
            default:
                now_locale='en';
                break;
        }
        return now_locale;
    }

使用方法

FormLcdShow [the_locale]


積木表示

在物件中使用陣列blocks: [ ]包括所有積木。

每個積木為一物件{}。內容為

opcode: 'digital_write',
                    blockType: BlockType.COMMAND,
                    text: FormDigitalWrite[the_locale],
                    arguments: {
                        PIN: {
                            type: ArgumentType.NUMBER,
                            defaultValue: 'D2',
                            menu: "digital_pins"
                        },

                     }

方法3:

/src/lib/libraries/extensions/index.jsx的

翻譯檔案在/node_modules/scratch-l10n/locales/editor-msgs.js

中文語系在最後面。

格式範例:

"gui.extension.microbitMore.description":"玩轉 micro:bit 的所有功能。(v2-0.2.4)",