Skip to content

Commit

Permalink
feat: Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nuintun committed Feb 29, 2024
1 parent eceeedb commit ee12b0c
Show file tree
Hide file tree
Showing 16 changed files with 203 additions and 205 deletions.
2 changes: 1 addition & 1 deletion packages/examples/src/js/pages/Encode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default memo(function Encode() {
</Col>
<Col md={6} sm={12} xs={24}>
<FormItem name="charset" label="字符编码">
<Select disabled={mode !== 'Auto'}>
<Select disabled={mode !== 'Auto' && mode !== 'Byte'}>
<Option value="ASCII">ASCII</Option>
<Option value="UTF_8">UTF-8</Option>
<Option value="ISO_8859_1">ISO-8859-1</Option>
Expand Down
12 changes: 5 additions & 7 deletions packages/examples/src/js/workers/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ export interface EncodedError {
}

export interface EncodeMessage {
fnc1: string;
mode: string;
charset: string;
content: string;
quietZone: number;
background: string;
foreground: string;
moduleSize: number;
aimIndicator: number;
version: 'Auto' | number;
fnc1: 'None' | 'GS1' | 'AIM';
level: 'L' | 'M' | 'Q' | 'H';
charset: keyof typeof Charset;
mode: 'Auto' | 'Numeric' | 'Alphanumeric' | 'Byte' | 'Kanji' | 'Hanzi';
}

export type CharsetNames = keyof typeof Charset;

export type EncodeResultMessage = EncodedOk | EncodedError;

function hex2rgb(hex: string): [R: number, G: number, B: number] {
Expand Down Expand Up @@ -79,7 +77,7 @@ function chooseBestMode({ mode, content, charset }: EncodeMessage): Byte | Hanzi
// 跳过错误
}

return new Byte(content, Charset[charset as CharsetNames]);
return new Byte(content, Charset[charset]);
case 'Hanzi':
return new Hanzi(content);
case 'Kanji':
Expand All @@ -89,7 +87,7 @@ function chooseBestMode({ mode, content, charset }: EncodeMessage): Byte | Hanzi
case 'Alphanumeric':
return new Alphanumeric(content);
default:
return new Byte(content, Charset[charset as CharsetNames]);
return new Byte(content, Charset[charset]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/examples/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"/><title>二维码</title><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="icon" href="public/favicon.ico"/><script defer="defer" src="public/js/f8a083a23fa2b5dd.js"></script><script defer="defer" src="public/js/175c9380a8034ab8.js"></script><script defer="defer" src="public/js/74f86b78eb5f6b88.js"></script><link href="public/css/be1a0c0d225bc424.css" rel="stylesheet"/></head><body><noscript>您已禁用 JavaScript,网站无法正常工作,请启用 JavaScript!</noscript><div id="app"></div></body></html>
<!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"/><title>二维码</title><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="icon" href="public/favicon.ico"/><script defer="defer" src="public/js/f4e9504632b8c322.js"></script><script defer="defer" src="public/js/32ffb57c5e7713c1.js"></script><script defer="defer" src="public/js/e9fad0bc649f1349.js"></script><link href="public/css/be1a0c0d225bc424.css" rel="stylesheet"/></head><body><noscript>您已禁用 JavaScript,网站无法正常工作,请启用 JavaScript!</noscript><div id="app"></div></body></html>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

113 changes: 0 additions & 113 deletions packages/examples/static/public/js/175c9380a8034ab8.js

This file was deleted.

Loading

0 comments on commit ee12b0c

Please sign in to comment.