Commit 4bef6cf1 authored by m's avatar m
parents 1ba4a327 4a62b7ff
...@@ -6,76 +6,76 @@ ...@@ -6,76 +6,76 @@
"ossName": "/pk-math/2irQDt3fGBdeUKTjbKWMbjn5eeKY/164x140" "ossName": "/pk-math/2irQDt3fGBdeUKTjbKWMbjn5eeKY/164x140"
}, },
"part-bg-1.png": { "part-bg-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/3mpAEaHXT48jzwscgmPUqriAuxys/750x220", "u": "https://cdn.jkwljy.com/pk-math/gEJmJYZgrG9u6jXWnifEN8j64h6/750x220",
"w": 750, "w": 750,
"h": 220, "h": 220,
"ossName": "/pk-math/3mpAEaHXT48jzwscgmPUqriAuxys/750x220" "ossName": "/pk-math/gEJmJYZgrG9u6jXWnifEN8j64h6/750x220"
}, },
"part-bg-2.png": { "part-bg-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/9Y7D4BTfqQhmt4pE346geHxGRGj/750x220", "u": "https://cdn.jkwljy.com/pk-math/2F6cARyQxiz89hLJ9LBXTBLGR6hA/750x220",
"w": 750, "w": 750,
"h": 220, "h": 220,
"ossName": "/pk-math/9Y7D4BTfqQhmt4pE346geHxGRGj/750x220" "ossName": "/pk-math/2F6cARyQxiz89hLJ9LBXTBLGR6hA/750x220"
}, },
"part-bg-3.png": { "part-bg-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/35HK4qvcBuzDWpyTJEY54hpievz6/750x220", "u": "https://cdn.jkwljy.com/pk-math/VqqVjB2e8qUjVosLJUJoQoTmgu7/750x220",
"w": 750, "w": 750,
"h": 220, "h": 220,
"ossName": "/pk-math/35HK4qvcBuzDWpyTJEY54hpievz6/750x220" "ossName": "/pk-math/VqqVjB2e8qUjVosLJUJoQoTmgu7/750x220"
}, },
"part-start-1.png": { "part-start-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/2RVqjVm8g6Cdn7d42a8EEtFBNMxZ/750x336", "u": "https://cdn.jkwljy.com/pk-math/3ZpEK4KquHL5Rq5s9XTw2GGi4pkb/750x336",
"w": 750, "w": 750,
"h": 336, "h": 336,
"ossName": "/pk-math/2RVqjVm8g6Cdn7d42a8EEtFBNMxZ/750x336" "ossName": "/pk-math/3ZpEK4KquHL5Rq5s9XTw2GGi4pkb/750x336"
}, },
"part-start-2.png": { "part-start-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/2KJcZriVZBBjaSUmemaAVktitde/750x336", "u": "https://cdn.jkwljy.com/pk-math/nrr4mKxJmB1pYcwBshL94YuNCNT/750x336",
"w": 750, "w": 750,
"h": 336, "h": 336,
"ossName": "/pk-math/2KJcZriVZBBjaSUmemaAVktitde/750x336" "ossName": "/pk-math/nrr4mKxJmB1pYcwBshL94YuNCNT/750x336"
}, },
"part-start.png": { "part-start.png": {
"u": "https://cdn.jkwljy.com/pk-math/3MGDvwuhkhWAjLSRVgczHQhZs9rs/750x336", "u": "https://cdn.jkwljy.com/pk-math/C1qqMdk7hE5qhTVwNRKuePt9HCT/750x336",
"w": 750, "w": 750,
"h": 336, "h": 336,
"ossName": "/pk-math/3MGDvwuhkhWAjLSRVgczHQhZs9rs/750x336" "ossName": "/pk-math/C1qqMdk7hE5qhTVwNRKuePt9HCT/750x336"
}, },
"round-center-1.png": { "round-center-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/3krqkCRJxWv2CNA5Ndmy9N1fS6Ji/750x256", "u": "https://cdn.jkwljy.com/pk-math/2oePSWs3Ne6b2HUaWuVsMi7rpimf/750x256",
"w": 750, "w": 750,
"h": 256, "h": 256,
"ossName": "/pk-math/3krqkCRJxWv2CNA5Ndmy9N1fS6Ji/750x256" "ossName": "/pk-math/2oePSWs3Ne6b2HUaWuVsMi7rpimf/750x256"
}, },
"round-center-2.png": { "round-center-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/usdnLF5tfbU8MyUyAjCfCc4Vbkb/750x256", "u": "https://cdn.jkwljy.com/pk-math/3GSMw8wnCxEb2gCKieNueXZDAcw2/750x256",
"w": 750, "w": 750,
"h": 256, "h": 256,
"ossName": "/pk-math/usdnLF5tfbU8MyUyAjCfCc4Vbkb/750x256" "ossName": "/pk-math/3GSMw8wnCxEb2gCKieNueXZDAcw2/750x256"
}, },
"round-center-3.png": { "round-center-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/3cLQ3B1tAA6ArBH7jCVKPxadryE4/750x256", "u": "https://cdn.jkwljy.com/pk-math/4EaBiQBvVn6ktbsHQmSxHNunT6gR/750x256",
"w": 750, "w": 750,
"h": 256, "h": 256,
"ossName": "/pk-math/3cLQ3B1tAA6ArBH7jCVKPxadryE4/750x256" "ossName": "/pk-math/4EaBiQBvVn6ktbsHQmSxHNunT6gR/750x256"
}, },
"round-center-4.png": { "round-center-4.png": {
"u": "https://cdn.jkwljy.com/pk-math/2FcKPLj9jrU1tiLhPiMjdnojaTh5/750x256", "u": "https://cdn.jkwljy.com/pk-math/pA2qgJD7eWBRHogDUxwaVAoyc5c/750x256",
"w": 750, "w": 750,
"h": 256, "h": 256,
"ossName": "/pk-math/2FcKPLj9jrU1tiLhPiMjdnojaTh5/750x256" "ossName": "/pk-math/pA2qgJD7eWBRHogDUxwaVAoyc5c/750x256"
}, },
"round-center-5.png": { "round-center-5.png": {
"u": "https://cdn.jkwljy.com/pk-math/2ibypWkZMqQTnYPmJs8E49vYj1ax/750x256", "u": "https://cdn.jkwljy.com/pk-math/Q3qgyeXfxFz4G3JpvMFKyicvqGn/750x256",
"w": 750, "w": 750,
"h": 256, "h": 256,
"ossName": "/pk-math/2ibypWkZMqQTnYPmJs8E49vYj1ax/750x256" "ossName": "/pk-math/Q3qgyeXfxFz4G3JpvMFKyicvqGn/750x256"
}, },
"round-center-6.png": { "round-center-6.png": {
"u": "https://cdn.jkwljy.com/pk-math/3nuG2iMhVxBC3eEsfQ7pq22VgCcM/750x256", "u": "https://cdn.jkwljy.com/pk-math/2HGTWTvkNq7hFmhZ9dKZhuhn8x85/750x256",
"w": 750, "w": 750,
"h": 256, "h": 256,
"ossName": "/pk-math/3nuG2iMhVxBC3eEsfQ7pq22VgCcM/750x256" "ossName": "/pk-math/2HGTWTvkNq7hFmhZ9dKZhuhn8x85/750x256"
}, },
"scene-footer.png": { "scene-footer.png": {
"u": "https://cdn.jkwljy.com/pk-math/UGtFQyu8CUYCTgr2SRJnyUw6UxM/750x292", "u": "https://cdn.jkwljy.com/pk-math/UGtFQyu8CUYCTgr2SRJnyUw6UxM/750x292",
...@@ -84,10 +84,10 @@ ...@@ -84,10 +84,10 @@
"ossName": "/pk-math/UGtFQyu8CUYCTgr2SRJnyUw6UxM/750x292" "ossName": "/pk-math/UGtFQyu8CUYCTgr2SRJnyUw6UxM/750x292"
}, },
"scene-head.png": { "scene-head.png": {
"u": "https://cdn.jkwljy.com/pk-math/3J56uJAwwkpRthJJum2zsW3PAGWk/750x220", "u": "https://cdn.jkwljy.com/pk-math/k58p5ADHaLo9HdcDrxGbgpiP347/750x220",
"w": 750, "w": 750,
"h": 220, "h": 220,
"ossName": "/pk-math/3J56uJAwwkpRthJJum2zsW3PAGWk/750x220" "ossName": "/pk-math/k58p5ADHaLo9HdcDrxGbgpiP347/750x220"
}, },
"short-cut-arrow.png": { "short-cut-arrow.png": {
"u": "https://cdn.jkwljy.com/pk-math/42pbPGXs3hzTWK77EFWJ4jUU2XWj/60x60", "u": "https://cdn.jkwljy.com/pk-math/42pbPGXs3hzTWK77EFWJ4jUU2XWj/60x60",
......
assets/main/part-bg-1.png

23.8 KB | W: | H:

assets/main/part-bg-1.png

23.5 KB | W: | H:

assets/main/part-bg-1.png
assets/main/part-bg-1.png
assets/main/part-bg-1.png
assets/main/part-bg-1.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/part-bg-2.png

15.4 KB | W: | H:

assets/main/part-bg-2.png

15.4 KB | W: | H:

assets/main/part-bg-2.png
assets/main/part-bg-2.png
assets/main/part-bg-2.png
assets/main/part-bg-2.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/part-bg-3.png

18.1 KB | W: | H:

assets/main/part-bg-3.png

18.4 KB | W: | H:

assets/main/part-bg-3.png
assets/main/part-bg-3.png
assets/main/part-bg-3.png
assets/main/part-bg-3.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/part-start-1.png

14.4 KB | W: | H:

assets/main/part-start-1.png

14.4 KB | W: | H:

assets/main/part-start-1.png
assets/main/part-start-1.png
assets/main/part-start-1.png
assets/main/part-start-1.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/part-start-2.png

13.4 KB | W: | H:

assets/main/part-start-2.png

13.4 KB | W: | H:

assets/main/part-start-2.png
assets/main/part-start-2.png
assets/main/part-start-2.png
assets/main/part-start-2.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/part-start.png

6.1 KB | W: | H:

assets/main/part-start.png

5.86 KB | W: | H:

assets/main/part-start.png
assets/main/part-start.png
assets/main/part-start.png
assets/main/part-start.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/round-center-1.png

17.9 KB | W: | H:

assets/main/round-center-1.png

17.9 KB | W: | H:

assets/main/round-center-1.png
assets/main/round-center-1.png
assets/main/round-center-1.png
assets/main/round-center-1.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/round-center-2.png

14.4 KB | W: | H:

assets/main/round-center-2.png

14.2 KB | W: | H:

assets/main/round-center-2.png
assets/main/round-center-2.png
assets/main/round-center-2.png
assets/main/round-center-2.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/round-center-3.png

19.3 KB | W: | H:

assets/main/round-center-3.png

18.7 KB | W: | H:

assets/main/round-center-3.png
assets/main/round-center-3.png
assets/main/round-center-3.png
assets/main/round-center-3.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/round-center-4.png

20.1 KB | W: | H:

assets/main/round-center-4.png

19.9 KB | W: | H:

assets/main/round-center-4.png
assets/main/round-center-4.png
assets/main/round-center-4.png
assets/main/round-center-4.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/round-center-5.png

18.9 KB | W: | H:

assets/main/round-center-5.png

18.3 KB | W: | H:

assets/main/round-center-5.png
assets/main/round-center-5.png
assets/main/round-center-5.png
assets/main/round-center-5.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/round-center-6.png

20.7 KB | W: | H:

assets/main/round-center-6.png

20.4 KB | W: | H:

assets/main/round-center-6.png
assets/main/round-center-6.png
assets/main/round-center-6.png
assets/main/round-center-6.png
  • 2-up
  • Swipe
  • Onion skin
assets/main/scene-head.png

19.8 KB | W: | H:

assets/main/scene-head.png

20.1 KB | W: | H:

assets/main/scene-head.png
assets/main/scene-head.png
assets/main/scene-head.png
assets/main/scene-head.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -106,5 +106,11 @@ ...@@ -106,5 +106,11 @@
"w": 70, "w": 70,
"h": 28, "h": 28,
"ossName": "/pk-math/3GCGt4XjNrPVSmCXYAqivEd9uNRa/70x28" "ossName": "/pk-math/3GCGt4XjNrPVSmCXYAqivEd9uNRa/70x28"
},
"top-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/2jsKNyHsjg8BntgzZvPyydroF4hJ/192x80",
"w": 192,
"h": 80,
"ossName": "/pk-math/2jsKNyHsjg8BntgzZvPyydroF4hJ/192x80"
} }
} }
...@@ -16,3 +16,39 @@ declare namespace NodeJS { ...@@ -16,3 +16,39 @@ declare namespace NodeJS {
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd' TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
} }
} }
declare module 'html-parse-stringify' {
export interface TagNode {
type: 'tag';
name: string;
voidElement: boolean;
attrs: Record<string, string | undefined>;
children: Node[];
}
export interface TextNode {
type: 'text';
content: string;
}
export interface ComponentNode {
type: 'component';
name: string;
attrs: Record<string, string | undefined>;
voidElement: boolean;
children: [];
}
export type Node = TagNode | TextNode | ComponentNode;
export interface ParseOptions {
components: Record<string, boolean>;
}
namespace HtmlParseStringify {
function parse(html: string, options?: ParseOptions): Node[];
function stringify(doc: Node[]): string;
}
export default HtmlParseStringify
}
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
"@tarojs/shared": "3.6.2", "@tarojs/shared": "3.6.2",
"@tarojs/taro": "3.6.2", "@tarojs/taro": "3.6.2",
"easy-peasy": "^5.2.0", "easy-peasy": "^5.2.0",
"html-parse-stringify": "^3.0.1",
"preact": "^10.5.15", "preact": "^10.5.15",
"qs": "^6.11.1", "qs": "^6.11.1",
"react-redux": "^7.2.0", "react-redux": "^7.2.0",
......
...@@ -8,6 +8,7 @@ export default { ...@@ -8,6 +8,7 @@ export default {
pages: [ pages: [
'pages/main/main', 'pages/main/main',
'pages/group/index', 'pages/group/index',
'pages/game/play/index',
'pages/level-prepare/index', 'pages/level-prepare/index',
], ],
subPackages: {{packages}}, subPackages: {{packages}},
......
...@@ -7,62 +7,62 @@ export default { ...@@ -7,62 +7,62 @@ export default {
"h": 140 "h": 140
}, },
"part-bg-1.png": { "part-bg-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/3mpAEaHXT48jzwscgmPUqriAuxys/750x220", "u": "https://cdn.jkwljy.com/pk-math/gEJmJYZgrG9u6jXWnifEN8j64h6/750x220",
"w": 750, "w": 750,
"h": 220 "h": 220
}, },
"part-bg-2.png": { "part-bg-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/9Y7D4BTfqQhmt4pE346geHxGRGj/750x220", "u": "https://cdn.jkwljy.com/pk-math/2F6cARyQxiz89hLJ9LBXTBLGR6hA/750x220",
"w": 750, "w": 750,
"h": 220 "h": 220
}, },
"part-bg-3.png": { "part-bg-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/35HK4qvcBuzDWpyTJEY54hpievz6/750x220", "u": "https://cdn.jkwljy.com/pk-math/VqqVjB2e8qUjVosLJUJoQoTmgu7/750x220",
"w": 750, "w": 750,
"h": 220 "h": 220
}, },
"part-start-1.png": { "part-start-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/2RVqjVm8g6Cdn7d42a8EEtFBNMxZ/750x336", "u": "https://cdn.jkwljy.com/pk-math/3ZpEK4KquHL5Rq5s9XTw2GGi4pkb/750x336",
"w": 750, "w": 750,
"h": 336 "h": 336
}, },
"part-start-2.png": { "part-start-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/2KJcZriVZBBjaSUmemaAVktitde/750x336", "u": "https://cdn.jkwljy.com/pk-math/nrr4mKxJmB1pYcwBshL94YuNCNT/750x336",
"w": 750, "w": 750,
"h": 336 "h": 336
}, },
"part-start.png": { "part-start.png": {
"u": "https://cdn.jkwljy.com/pk-math/3MGDvwuhkhWAjLSRVgczHQhZs9rs/750x336", "u": "https://cdn.jkwljy.com/pk-math/C1qqMdk7hE5qhTVwNRKuePt9HCT/750x336",
"w": 750, "w": 750,
"h": 336 "h": 336
}, },
"round-center-1.png": { "round-center-1.png": {
"u": "https://cdn.jkwljy.com/pk-math/3krqkCRJxWv2CNA5Ndmy9N1fS6Ji/750x256", "u": "https://cdn.jkwljy.com/pk-math/2oePSWs3Ne6b2HUaWuVsMi7rpimf/750x256",
"w": 750, "w": 750,
"h": 256 "h": 256
}, },
"round-center-2.png": { "round-center-2.png": {
"u": "https://cdn.jkwljy.com/pk-math/usdnLF5tfbU8MyUyAjCfCc4Vbkb/750x256", "u": "https://cdn.jkwljy.com/pk-math/3GSMw8wnCxEb2gCKieNueXZDAcw2/750x256",
"w": 750, "w": 750,
"h": 256 "h": 256
}, },
"round-center-3.png": { "round-center-3.png": {
"u": "https://cdn.jkwljy.com/pk-math/3cLQ3B1tAA6ArBH7jCVKPxadryE4/750x256", "u": "https://cdn.jkwljy.com/pk-math/4EaBiQBvVn6ktbsHQmSxHNunT6gR/750x256",
"w": 750, "w": 750,
"h": 256 "h": 256
}, },
"round-center-4.png": { "round-center-4.png": {
"u": "https://cdn.jkwljy.com/pk-math/2FcKPLj9jrU1tiLhPiMjdnojaTh5/750x256", "u": "https://cdn.jkwljy.com/pk-math/pA2qgJD7eWBRHogDUxwaVAoyc5c/750x256",
"w": 750, "w": 750,
"h": 256 "h": 256
}, },
"round-center-5.png": { "round-center-5.png": {
"u": "https://cdn.jkwljy.com/pk-math/2ibypWkZMqQTnYPmJs8E49vYj1ax/750x256", "u": "https://cdn.jkwljy.com/pk-math/Q3qgyeXfxFz4G3JpvMFKyicvqGn/750x256",
"w": 750, "w": 750,
"h": 256 "h": 256
}, },
"round-center-6.png": { "round-center-6.png": {
"u": "https://cdn.jkwljy.com/pk-math/3nuG2iMhVxBC3eEsfQ7pq22VgCcM/750x256", "u": "https://cdn.jkwljy.com/pk-math/2HGTWTvkNq7hFmhZ9dKZhuhn8x85/750x256",
"w": 750, "w": 750,
"h": 256 "h": 256
}, },
...@@ -72,7 +72,7 @@ export default { ...@@ -72,7 +72,7 @@ export default {
"h": 292 "h": 292
}, },
"scene-head.png": { "scene-head.png": {
"u": "https://cdn.jkwljy.com/pk-math/3J56uJAwwkpRthJJum2zsW3PAGWk/750x220", "u": "https://cdn.jkwljy.com/pk-math/k58p5ADHaLo9HdcDrxGbgpiP347/750x220",
"w": 750, "w": 750,
"h": 220 "h": 220
}, },
......
...@@ -90,5 +90,10 @@ export default { ...@@ -90,5 +90,10 @@ export default {
"u": "https://cdn.jkwljy.com/pk-math/3GCGt4XjNrPVSmCXYAqivEd9uNRa/70x28", "u": "https://cdn.jkwljy.com/pk-math/3GCGt4XjNrPVSmCXYAqivEd9uNRa/70x28",
"w": 70, "w": 70,
"h": 28 "h": 28
},
"top-bg.png": {
"u": "https://cdn.jkwljy.com/pk-math/2jsKNyHsjg8BntgzZvPyydroF4hJ/192x80",
"w": 192,
"h": 80
} }
} as const } as const
.blank {
text-decoration: underline;
display: inline-block;
width: 60PX;
height: 30PX;
margin: 0 8px;
border: 1px solid;
vertical-align: middle;
}
import { View } from '@tarojs/components'
import styles from './answer-blank.module.scss'
const AnswerBlank = () => {
return (
<View className={styles.blank}></View>
)
}
export default AnswerBlank
import { View, Text, Image } from '@tarojs/components'
import { useMemo } from 'react'
import htmlParser, { type Node } from 'html-parse-stringify'
import cs from './rich-text.module.scss'
import AnswerBlank from './answer-blank'
import type { BlankQuestion } from '../types'
type QuestionBlankProps = {
question: BlankQuestion
}
function renderNode (node: Node) {
if (node.type === 'text') {
return (
<Text decode className={cs.plain}>{node.content}</Text>
)
}
if (node.type === 'tag') {
if (node.name === 'img') {
const { src, style, width, height } = node.attrs
let _style = style
if (width) {
_style = `${_style || ''};width:${width}px`
}
if (height) {
_style = `${_style || ''};height:${height}px`
}
if (src) {
return (
<Image src={src} style={_style}></Image>
)
}
}
const renderChildren = (filter?: string[]) => {
if (filter) {
return node.children?.filter(c => c.type === 'tag' && filter.includes(c.name)).map(renderNode)
}
return node.children?.map(renderNode)
}
if (!node.voidElement) {
switch (node.name) {
case 'i': {
return (
<Text className={cs.italy}>{renderChildren()}</Text>
)
}
case 'b': {
return (
<Text className={cs.bold}>{renderChildren()}</Text>
)
}
case 'u': {
return (
<Text className={cs.underline}>{renderChildren()}</Text>
)
}
case 'table': {
return (
<View className={cs.table}>{renderChildren(['tbody', 'thead'])}</View>
)
}
case 'thead': {
return (
<View className={cs.thead}>{renderChildren(['tr'])}</View>
)
}
case 'tr': {
return (
<View className={cs.tr}>{renderChildren(['th', 'td'])}</View>
)
}
case 'th': {
return (
<View className={cs.th}>{renderChildren()}</View>
)
}
case 'td': {
return (
<View className={cs.td}>{renderChildren()}</View>
)
}
case 'tbody': {
return (
<View className={cs.tbody}>{renderChildren(['tr'])}</View>
)
}
}
return (
<View>
{renderChildren()}
</View>
)
}
if (node.name === 'AnswerBlank') {
return (
<AnswerBlank />
)
}
}
}
const QuestionBlank = (props: QuestionBlankProps) => {
const { question } = props
const tree = useMemo(() => {
return htmlParser.parse(question.contentText)
}, [question])
return (
<View>
{tree.map(item => renderNode(item))}
</View>
)
}
export default QuestionBlank
import { View } from '@tarojs/components'
import QuestionBlank from './question-blank'
import { type QuestionType, isBlankQuestion } from '../types'
type QuestionProps = {
question: QuestionType
}
const Question = (props: QuestionProps) => {
const { question } = props
if (isBlankQuestion(question)) {
return <QuestionBlank question={question} />
}
return (
<View>234&nbsp;&nbsp;</View>
)
}
export default Question
.italy {
font-style: italic;
}
.bold {
font-weight: bold;
}
.underline {
text-decoration: underline;
}
.plain {
line-height: 30px;
}
.table {
border-collapse: collapse;
border-spacing: 0;
display: table;
box-sizing: border-box;
text-indent: initial;
border: 1px solid #000;
margin: 0 auto;
}
.thead, .tbody {
display: table-header-group;
vertical-align: middle;
border-color: inherit;
}
.tr {
display: table-row;
vertical-align: inherit;
border-color: inherit;
}
.th {
display: table-cell;
vertical-align: inherit;
font-weight: bold;
text-align: left;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
padding: 4px 8px;
}
.td {
display: table-cell;
vertical-align: inherit;
text-align: left;
padding: 4px 8px;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
}
import { View } from '@tarojs/components'
import { useState } from 'react'
import htmlParser from 'html-parse-stringify'
import { QuestionContext } from './util'
import Question from './components/question'
const str = '<p>随着人们生活质量的提高,净水器已经慢慢走入了普通百姓家庭,某电器公司销售每台进价分别为2000元、1700元的<i>A</i>、<i>B</i>两种型号的净水器,下表是近两周的销售情况:</p> \n<table border="1"> \n <thead> \n <tr class="header"> \n <th style="text-align: left;">销售时段</th> \n <th style="text-align: left;">销售数量</th> \n <th style="text-align: left;">销售收入</th> \n <th style="text-align: left;"></th> \n </tr> \n </thead> \n <tbody> \n <tr class="odd"> \n <td style="text-align: left;"></td> \n <td style="text-align: left;"><i>A</i>种型号</td> \n <td style="text-align: left;"><i>B</i>种型号</td> \n <td style="text-align: left;"></td> \n </tr> \n <tr class="even"> \n <td style="text-align: left;">第一周</td> \n <td style="text-align: left;">3台</td> \n <td style="text-align: left;">5台</td> \n <td style="text-align: left;">18000元</td> \n </tr> \n <tr class="odd"> \n <td style="text-align: left;">第二周</td> \n <td style="text-align: left;">4台</td> \n <td style="text-align: left;">10台</td> \n <td style="text-align: left;">31000元</td> \n </tr> \n </tbody> \n</table> \n<p>(1)求<i>A</i>,<i>B</i>两种型号的净水器的销售单价;</p> \n<p>(2)若电器公司准备用不多于54000元的金额在采购这两种型号的净水器共30台,求<i>A</i>种型号的净水器最多能采购多少台?</p> \n<p>(3)在(2)的条件下,公司销售完这30台净水器能否实现利润为12800元的目标?若能,请给出相应的采购方案;若不能,请说明理由.</p>'
console.log(htmlParser.parse(str))
const question = {
contentText: str,
questionType: '填空题',
answers: []
}
const GamePlay = () => {
const [currentInputIndex, setCurrentInputIndex] = useState(0)
return (
<View>
<QuestionContext.Provider value={{ current: currentInputIndex }}>
&nbsp;&nbsp;
<Question question={question} />
</QuestionContext.Provider>
</View>
)
}
export default GamePlay
export interface QuestionItem {
questionType: string;
answers: { contentText: string; sort: number }[];
}
export interface BlankQuestion extends QuestionItem {
contentText: string;
questionType: '填空题';
}
export interface SelectionQuestion extends QuestionItem {
contentText: string;
questionType: '选择题';
options: QuestionOption[];
}
export interface RandomQuestion extends QuestionItem {
questionItems?: RandomQuestionItem[];
}
/** 带余除法 */
export interface DivisionWithRemainderQuestion extends QuestionItem {
questionType: '带余除法';
questionItems: [];
}
/** 竖式除法 */
export interface VerticalDivisionQuestion extends QuestionItem {
questionType: '竖式除法';
questionItems: [];
}
/** 乘法 */
export interface MultiplicationQuestion extends QuestionItem {
questionType: '乘法';
questionItems: [];
}
export type QuestionType = BlankQuestion | SelectionQuestion | RandomQuestion
export function isBlankQuestion (q: QuestionType): q is BlankQuestion {
return q?.questionType === '填空题'
}
export type QuestionOption = {
index: string;
contentText: string;
answer: boolean;
}
export type RandomQuestionItem = {
contentText: '$input' | `${number}`;
sort: number;
}
import { createContext } from 'react'
export const QuestionContext = createContext({ current: 0 })
/** 乘法验证 */
export function validateMultiplication (multiplier: number, multiplicand: number, product: number) {
return multiplier * multiplicand === product
}
/** 带余除法验证 */
export function validateDivisionWithRemainder (dividend: number, divisor: number, quotient: number, remainder: number) {
return dividend % divisor === remainder && (divisor * quotient + remainder) === dividend
}
/** 竖式除法验证 */
export function validateVerticalDivision (dividend: number, divisor: number, quotient: number, remainder: number) {
}
type InputItem = {
/** 用户输入答案 */
answer: number | null;
/** 正确答案 */
correctAnswer: number;
/** 顺序 */
inputIndex: number;
}
type Pair = {
offset: number;
top?: number | null;
bottom: number | null;
topInputList?: InputItem[];
bottomInputList?: InputItem[];
}
type RetType = {
quotientList: InputItem[];
processList: Pair[];
}
/** 获取竖式除法整个计算过程 */
export function buildVertivalDivisionMetric (dividend: number, divisor: number): RetType {
if (dividend < divisor) {
return {
quotientList: [],
processList: [],
}
}
const processList: Pair[] = []
const quotientList: InputItem[] = []
const quotient = Math.floor(dividend / divisor)
// const remainder = dividend % divisor
const quotientStr = `${quotient}`
const dividendStr = `${dividend}`
const dividendStrLength = dividendStr.length
const quotientStrLength = quotientStr.length
let top: number | null = null
const strStart = dividendStrLength - quotientStrLength
let inputIndex = 0
function getInputListFromNumber (num: number, isTop: boolean): InputItem[] {
const str = `${num}`
if (isTop) {
return str.split('').reverse().map(char => ({
answer: null,
correctAnswer: +char,
inputIndex: inputIndex++
})).reverse()
}
return str.split('').map(char => ({
answer: null,
correctAnswer: +char,
inputIndex: inputIndex++
}))
}
for (let start = 0; start < quotientStrLength; start++) {
const val = +quotientStr.charAt(start)
const product = val * divisor
let pair: Pair
if (top === null) {
const offset = start + strStart
const _top = dividendStr.slice(0, offset + 1)
top = +_top - product
quotientList.push({
answer: null,
correctAnswer: val,
inputIndex
})
pair = {
offset,
top: null,
bottom: product,
bottomInputList: getInputListFromNumber(product, false)
}
} else {
top = top * 10 + +dividendStr.charAt(start + strStart)
quotientList.push({
answer: null,
correctAnswer: val,
inputIndex
})
if (top < divisor) {
continue
}
pair = {
offset: start + strStart,
top,
topInputList: getInputListFromNumber(top, true),
bottom: product,
bottomInputList: getInputListFromNumber(product, false)
}
top = top - product
}
processList.push(pair)
}
processList.push({
top,
bottom: null,
offset: dividendStrLength
})
return {
processList,
quotientList
}
}
import { Image } from '@tarojs/components' import { Image } from '@tarojs/components'
import { useEffect, useRef, useMemo } from 'react' import { useEffect, useRef, useMemo } from 'react'
import assets from '@/assets/oss/assets-round'
import { usePageScroll, createIntersectionObserver, getCurrentInstance, getMenuButtonBoundingClientRect, IntersectionObserver } from '@tarojs/taro' import { usePageScroll, createIntersectionObserver, getCurrentInstance, getMenuButtonBoundingClientRect, IntersectionObserver } from '@tarojs/taro'
type RoundTagProps = { type RoundTagProps = {
url: string; url?: string;
className: string; className: string;
id: number | string; id: number | string;
ready: boolean; ready: boolean;
...@@ -13,43 +14,69 @@ const RoundTag = (props: RoundTagProps) => { ...@@ -13,43 +14,69 @@ const RoundTag = (props: RoundTagProps) => {
const nav = useRef(getMenuButtonBoundingClientRect()) const nav = useRef(getMenuButtonBoundingClientRect())
const { url, className, id, ready } = props const { url, className, id, ready } = props
const scrollRef = useRef(0) const scrollRef = useRef(0)
const lastEffectedScroll = useRef(0)
usePageScroll(payload => { usePageScroll(payload => {
scrollRef.current = payload.scrollTop scrollRef.current = payload.scrollTop
}) })
const uid = useMemo(() => `tag_${id}`, [id]) const uid = useMemo(() => `tag_${id}`, [id])
const bgid = useMemo(() => `bg_${id}`, [id])
useEffect(() => { useEffect(() => {
let observer: IntersectionObserver | null = null let observer: IntersectionObserver | null = null
if (ready) { if (ready) {
lastEffectedScroll.current = scrollRef.current
const navVal = nav.current const navVal = nav.current
// @ts-ignore // @ts-ignore
observer = createIntersectionObserver() observer = createIntersectionObserver()
let isAnimated = false
const animateBg = () => {
const page = getCurrentInstance().page
page?.animate?.(`#${bgid}`, [
{ opacity: 1 },
{ opacity: 0 },
], 700, () => {
observer?.disconnect()
observer = null
})
}
let timer: NodeJS.Timeout | null = null
if (url) {
observer observer
.relativeToViewport({ bottom: 0, top: -navVal.height - navVal.top - 5 }) .relativeToViewport({ bottom: 0, top: -navVal.height - navVal.top - 5 - 50 })
.observe(`#${uid}`, ({ intersectionRatio }) => { .observe(`#${uid}`, ({ intersectionRatio }) => {
const show = intersectionRatio > 0 if (intersectionRatio > 0) {
if (isAnimated) return
const isDown = lastEffectedScroll.current < scrollRef.current if (timer) {
const page = getCurrentInstance().page clearTimeout(timer)
}
if (show && !isDown) { timer = setTimeout(() => {
page?.animate?.(`#${uid}`, [ isAnimated = true
{ opacity: 0, translateY: 20, scale: [1, 1] }, getCurrentInstance().page?.animate?.(`#${uid}`, [
{ opacity: 1, translateY: 0, scale: [1, 1] }, { opacity: 0, translateY: 50, scale: [1, 1] },
{ opacity: 1, translateY: 0, scale: [1.2, 1.2], offset: 0.8 }, { opacity: 1, translateY: 20, scale: [1.5, 1.5], offset: 0.5 },
{ opacity: 1, translateY: 20, scale: [1.5, 1.5], offset: 0.75 },
{ opacity: 1, translateY: 0, scale: [1, 1] }, { opacity: 1, translateY: 0, scale: [1, 1] },
], 1200, () => { ], 600, animateBg)
page?.clearAnimation?.(`#${uid}`, () => {}) }, 500)
}
}) })
} else {
observer
.relativeToViewport({ bottom: 0, top: -navVal.height - navVal.top - 5 - 50 })
.observe(`#${bgid}`, ({ intersectionRatio }) => {
if (intersectionRatio > 0) {
if (isAnimated) return
if (timer) {
clearTimeout(timer)
}
timer = setTimeout(() => {
isAnimated = true
animateBg()
}, 900)
} }
lastEffectedScroll.current = scrollRef.current
}) })
} }
}
return () => { return () => {
if (observer) { if (observer) {
...@@ -57,10 +84,19 @@ const RoundTag = (props: RoundTagProps) => { ...@@ -57,10 +84,19 @@ const RoundTag = (props: RoundTagProps) => {
observer = null observer = null
} }
} }
}, [uid, ready]) }, [uid, ready, bgid, url])
if (!ready) {
return null
}
return ( return (
<Image src={url} className={className} id={uid}></Image> <>
{url && (
<Image src={url} className={className} style={{ opacity: 0 }} id={uid}></Image>
)}
<Image src={assets['top-bg.png'].u} className={className} id={bgid}></Image>
</>
) )
} }
......
...@@ -39,9 +39,9 @@ const getTagIcon = (tag?: string): ImageSource | null => { ...@@ -39,9 +39,9 @@ const getTagIcon = (tag?: string): ImageSource | null => {
case 'top30': { case 'top30': {
return assets['top-30.png'] return assets['top-30.png']
} }
case 'topn': { // case 'topn': {
return assets['top-n.png'] // return assets['top-n.png']
} // }
} }
return null return null
...@@ -119,9 +119,7 @@ const RoundComp = (props: RoundProps) => { ...@@ -119,9 +119,7 @@ const RoundComp = (props: RoundProps) => {
const tag = getTagIcon(round.tag) const tag = getTagIcon(round.tag)
return ( return (
<View className={styles.clear}> <View className={styles.clear}>
{!!tag && ( <RoundTag url={tag?.u} className={styles.tag} id={round.id} ready={ready} />
<RoundTag url={tag.u} className={styles.tag} id={round.id} ready={ready} />
)}
<Image src={getScoreIcon(round.score).u} className={styles.score} /> <Image src={getScoreIcon(round.score).u} className={styles.score} />
<Image src={getClearIcon(round.type).u} className={getIconClassNames(round.type, [styles.clearIcon])} /> <Image src={getClearIcon(round.type).u} className={getIconClassNames(round.type, [styles.clearIcon])} />
{!!round.upBonus && ( {!!round.upBonus && (
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
&.isShow { &.isShow {
opacity: 0; opacity: 0;
pointer-events: none;
transform: translateY(-30px); transform: translateY(-30px);
} }
} }
......
...@@ -8336,6 +8336,13 @@ html-minifier@4.0.0, html-minifier@^4.0.0: ...@@ -8336,6 +8336,13 @@ html-minifier@4.0.0, html-minifier@^4.0.0:
relateurl "^0.2.7" relateurl "^0.2.7"
uglify-js "^3.5.1" uglify-js "^3.5.1"
html-parse-stringify@^3.0.1:
version "3.0.1"
resolved "http://git.jksxb.cn:8081/repository/geek/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz#dfc1017347ce9f77c8141a507f233040c59c55d2"
integrity sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg==
dependencies:
void-elements "3.1.0"
html-tags@^2.0.0: html-tags@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.npmmirror.com/html-tags/-/html-tags-2.0.0.tgz#10b30a386085f43cede353cc8fa7cb0deeea668b" resolved "https://registry.npmmirror.com/html-tags/-/html-tags-2.0.0.tgz#10b30a386085f43cede353cc8fa7cb0deeea668b"
...@@ -14658,6 +14665,11 @@ vm2@^3.8.4: ...@@ -14658,6 +14665,11 @@ vm2@^3.8.4:
acorn "^8.7.0" acorn "^8.7.0"
acorn-walk "^8.2.0" acorn-walk "^8.2.0"
void-elements@3.1.0:
version "3.1.0"
resolved "http://git.jksxb.cn:8081/repository/geek/void-elements/-/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09"
integrity sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==
w3c-hr-time@^1.0.2: w3c-hr-time@^1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.npmmirror.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd" resolved "https://registry.npmmirror.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment