mirror of
https://github.com/silenty4ng/k5web
synced 2025-01-22 03:34:44 +00:00
Compare commits
4 commits
c56e4e5608
...
f7fbcfefef
Author | SHA1 | Date | |
---|---|---|---|
f7fbcfefef | |||
fc8eacd2be | |||
ca3a01ef2e | |||
b0df237cbc |
2 changed files with 19 additions and 12 deletions
|
@ -78,6 +78,7 @@
|
||||||
calendar: [],
|
calendar: [],
|
||||||
rom: [],
|
rom: [],
|
||||||
bl: undefined,
|
bl: undefined,
|
||||||
|
blName: '',
|
||||||
nowDrag: -1,
|
nowDrag: -1,
|
||||||
showAdd: '',
|
showAdd: '',
|
||||||
status: ''
|
status: ''
|
||||||
|
@ -125,7 +126,9 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
const loadBL = async() => {
|
const loadBL = async() => {
|
||||||
const fontPacket = await fetch('/L_BL001.bin')
|
const latestVersion = JSON.parse(await (await fetch('https://k5.vicicode.com/diyapi/bl.json')).text())!.latest;
|
||||||
|
state.blName = latestVersion;
|
||||||
|
const fontPacket = await fetch('https://k5.vicicode.com/diyapi/' + latestVersion);
|
||||||
if(fontPacket.body){
|
if(fontPacket.body){
|
||||||
const reader = fontPacket.body.getReader();
|
const reader = fontPacket.body.getReader();
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
|
@ -174,7 +177,7 @@
|
||||||
await writeRange(0x40000, new Uint8Array([firmware.length]), '固件数量');
|
await writeRange(0x40000, new Uint8Array([firmware.length]), '固件数量');
|
||||||
|
|
||||||
const _name_bl_array = new Uint8Array(8);
|
const _name_bl_array = new Uint8Array(8);
|
||||||
_name_bl_array.set(stringToUint8Array("L_BL001"))
|
_name_bl_array.set(stringToUint8Array(state.blName.split('.')[0]))
|
||||||
await writeRange(0X40008, _name_bl_array, '引导程序版本')
|
await writeRange(0X40008, _name_bl_array, '引导程序版本')
|
||||||
|
|
||||||
const writeMeta: any = [];
|
const writeMeta: any = [];
|
||||||
|
@ -182,7 +185,7 @@
|
||||||
const _meta_name = new Uint8Array(16)
|
const _meta_name = new Uint8Array(16)
|
||||||
const _meta_address_start = new Uint8Array(4)
|
const _meta_address_start = new Uint8Array(4)
|
||||||
const _meta_address_end = new Uint8Array(4)
|
const _meta_address_end = new Uint8Array(4)
|
||||||
_meta_name.set(stringToUint8Array(item.binaryName))
|
_meta_name.set(stringToUint8Array(item.binaryName.replace(/[^\x00-\xff]/g, '')))
|
||||||
_meta_address_start.set(hexReverseStringToUint8Array((item.start).toString(16)));
|
_meta_address_start.set(hexReverseStringToUint8Array((item.start).toString(16)));
|
||||||
_meta_address_end.set(hexReverseStringToUint8Array((item.end).toString(16)));
|
_meta_address_end.set(hexReverseStringToUint8Array((item.end).toString(16)));
|
||||||
writeMeta.push(..._meta_name, ..._meta_address_start, ..._meta_address_end, ...new Uint8Array(8))
|
writeMeta.push(..._meta_name, ..._meta_address_start, ..._meta_address_end, ...new Uint8Array(8))
|
||||||
|
@ -194,22 +197,26 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
await eeprom_reboot(appStore.connectPort);
|
await eeprom_reboot(appStore.connectPort);
|
||||||
|
state.status = state.status + "写入完成<br/>";
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectFile = () => {
|
const selectFile = () => {
|
||||||
const input = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
input.type = 'file';
|
input.type = 'file';
|
||||||
|
input.multiple = true;
|
||||||
input.onchange = async () => {
|
input.onchange = async () => {
|
||||||
if(input.files){
|
if(input.files){
|
||||||
const blob = new Blob([input.files[0]], { type: 'application/octet-stream' });
|
for(let i = 0; i < input.files.length; i++){
|
||||||
const rawEEPROM = new Uint8Array(await blob.arrayBuffer());
|
const blob = new Blob([input.files[i]], { type: 'application/octet-stream' });
|
||||||
const firmware = {
|
const rawEEPROM = new Uint8Array(await blob.arrayBuffer());
|
||||||
binaryFile: unpack(rawEEPROM),
|
const firmware = {
|
||||||
binaryName: input.files[0].name,
|
binaryFile: unpack(rawEEPROM),
|
||||||
color: getColor()
|
binaryName: input.files[i].name.replace(/[^\x00-\xff]/g, ''),
|
||||||
|
color: getColor()
|
||||||
|
}
|
||||||
|
state.rom.push(firmware)
|
||||||
}
|
}
|
||||||
state.rom.push(firmware)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
input.click();
|
input.click();
|
||||||
|
@ -289,7 +296,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeName = (val: any) => {
|
const changeName = (val: any) => {
|
||||||
state.rom[val].binaryName = state.rom[val].binaryName.replace(/[^\a-\z\A-\Z0-9.]/g, '')
|
state.rom[val].binaryName = state.rom[val].binaryName.replace(/[^\x00-\xff]/g, '')
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<div>
|
<div>
|
||||||
<a-radio-group type="button" size="mini" v-model="state.protocol">
|
<a-radio-group type="button" size="mini" v-model="state.protocol">
|
||||||
<a-radio value="Official">Official</a-radio>
|
<a-radio value="Official">Official</a-radio>
|
||||||
<a-radio value="Losehu">Losehu</a-radio>
|
<!-- <a-radio value="Losehu">Losehu</a-radio> -->
|
||||||
</a-radio-group>
|
</a-radio-group>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue