@zero-library/common 3.1.4 → 3.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +11 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +11 -3
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1513,11 +1513,19 @@ var MarkdownPreview_default = ({ fileUrl, searchValue, asPlainText }) => {
|
|
|
1513
1513
|
if (res.status !== 200) {
|
|
1514
1514
|
throw new Error(`\u8BF7\u6C42\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${res.status}`);
|
|
1515
1515
|
}
|
|
1516
|
-
const
|
|
1517
|
-
|
|
1516
|
+
const buffer = await res.arrayBuffer();
|
|
1517
|
+
let markdownText = "";
|
|
1518
|
+
try {
|
|
1519
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
1520
|
+
markdownText = decoder.decode(buffer);
|
|
1521
|
+
} catch (e) {
|
|
1522
|
+
const gbkDecoder = new TextDecoder("gbk");
|
|
1523
|
+
markdownText = gbkDecoder.decode(buffer);
|
|
1524
|
+
}
|
|
1525
|
+
if (!markdownText) {
|
|
1518
1526
|
throw new Error("\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A");
|
|
1519
1527
|
}
|
|
1520
|
-
return
|
|
1528
|
+
return markdownText;
|
|
1521
1529
|
};
|
|
1522
1530
|
const init = async () => {
|
|
1523
1531
|
setContent("");
|