Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改课表缓存 & 尝试解决安卓数据表不显示问题 #186

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions src/common/components/chart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,23 @@ const LineChart: React.FC<LineChartProps> = (props) => {
}, []);
const drawLineChart = () => {
const query = Taro.createSelectorQuery();
query
.select(`#${id ?? DEFAULT_CHART_ID}`)
.fields({ node: true, size: true })
.exec((res) => {
const dpr = Taro.getSystemInfoSync().pixelRatio;
const canvas = res[0].node as CanvasInterface;
const { width, height } = canvas;
canvas.width = width * dpr;
canvas.height = height * dpr;
// 设置 canvas 组件的样式宽高
setSize({ x: width ?? 200, y: height ?? 200 });
const ctx = canvas.getContext('2d') as CanvasContext;
ctx.scale(dpr, dpr);
drawChart(ctx);
});
setTimeout(() => {
query
.select(`#${id ?? DEFAULT_CHART_ID}`)
.fields({ node: true, size: true })
.exec((res) => {
const dpr = Taro.getSystemInfoSync().pixelRatio;
const canvas = res[0].node as CanvasInterface;
const { width, height } = canvas;
canvas.width = width * dpr;
canvas.height = height * dpr;
// 设置 canvas 组件的样式宽高
setSize({ x: width ?? 200, y: height ?? 200 });
const ctx = canvas.getContext('2d') as CanvasContext;
ctx.scale(dpr, dpr);
drawChart(ctx);
});
}, 200);
};

const drawChart = (ctx: CanvasContext) => {
Expand Down Expand Up @@ -178,14 +180,15 @@ const LineChart: React.FC<LineChartProps> = (props) => {
return (
<Canvas
id={id ?? DEFAULT_CHART_ID}
width={(size?.x ?? DEFAULT_WIDTH + 'px') as string}
height={(size?.y ?? DEFAULT_HEIGHT + 'px') as string}
// width={(size?.x ?? DEFAULT_WIDTH + 'px') as string}
// height={(size?.y ?? DEFAULT_HEIGHT + 'px') as string}
className={className}
style={{
...style,
...{
width: `${propWidth ?? DEFAULT_WIDTH}px`,
height: `${propHeight ?? DEFAULT_HEIGHT}px`,
flex: 1,
},
}}
type="2d"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/classInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default function Index() {
<Label3 key={keyindex} content={feature} />
))}
</View>
<View className="h-1/3 pt-1.5">
<View className="mx-auto flex w-[90%] pt-1.5">
<LineChart
className="mx-auto text-center"
data={yData}
Expand Down
1 change: 1 addition & 0 deletions src/pages/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function Index() {
const handleChangeType = (type) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
dispatch.changeType(type);
void dispatch.refershComments();
};

useEffect(() => {
Expand Down
Loading