chore: 条形码使用 img 方便右键复制 Closes #3716 (#3720)

* chore: 条形码使用 img 方便右键复制 Closes #3716

* 更新 snapshot

* 修类型报错
This commit is contained in:
吴多益 2022-03-09 20:03:08 +08:00 committed by GitHub
parent 838d741764
commit d6159768eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 11 deletions

View File

@ -83,7 +83,7 @@ test('factory load Renderer on need', async () => {
session: 'loadRenderer',
loadRenderer: schema => {
interface MyProps extends RendererProps {
a: number;
a?: number;
}
class MyComponent extends React.Component<MyProps> {
@ -106,7 +106,7 @@ test('factory load Renderer on need', async () => {
test('factory:registerRenderer', () => {
interface MyProps extends RendererProps {
a: number;
a?: number;
}
class MyComponent extends React.Component<MyProps> {

View File

@ -2,10 +2,10 @@ import React = require('react');
import {render, fireEvent} from '@testing-library/react';
import '../../src/themes/default';
import {render as amisRender} from '../../src/index';
import {makeEnv} from '../helper';
import {makeEnv, wait} from '../helper';
import 'jest-canvas-mock';
test('Renderer:bar-code', () => {
test('Renderer:bar-code', async () => {
const {container} = render(
amisRender(
{
@ -19,6 +19,7 @@ test('Renderer:bar-code', () => {
makeEnv({})
)
);
await wait(500);
expect(container).toMatchSnapshot();
});

View File

@ -16,10 +16,11 @@ exports[`Renderer:bar-code 1`] = `
>
<div
class="cxd-BarCode"
style="display: none;"
/>
<div>
...
style=""
>
<img
src="data:image/png;base64,00"
/>
</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
.#{$ns}BarCode {
> svg {
> img {
display: block;
margin: 0 auto;
}

View File

@ -20,7 +20,7 @@ export class BarCode extends React.Component<BarCodeProps> {
constructor(props: BarCodeProps) {
super(props);
this.dom = React.createRef<SVGSVGElement>();
this.dom = React.createRef<HTMLImageElement>();
}
componentDidUpdate(prevProps: BarCodeProps) {
@ -43,7 +43,7 @@ export class BarCode extends React.Component<BarCodeProps> {
}
render() {
return <svg ref={this.dom}></svg>;
return <img ref={this.dom} />;
}
}