@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.cjs.js
CHANGED
|
@@ -1560,11 +1560,19 @@ var MarkdownPreview_default = ({ fileUrl, searchValue, asPlainText }) => {
|
|
|
1560
1560
|
if (res.status !== 200) {
|
|
1561
1561
|
throw new Error(`\u8BF7\u6C42\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${res.status}`);
|
|
1562
1562
|
}
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1563
|
+
const buffer = await res.arrayBuffer();
|
|
1564
|
+
let markdownText = "";
|
|
1565
|
+
try {
|
|
1566
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
1567
|
+
markdownText = decoder.decode(buffer);
|
|
1568
|
+
} catch (e) {
|
|
1569
|
+
const gbkDecoder = new TextDecoder("gbk");
|
|
1570
|
+
markdownText = gbkDecoder.decode(buffer);
|
|
1571
|
+
}
|
|
1572
|
+
if (!markdownText) {
|
|
1565
1573
|
throw new Error("\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A");
|
|
1566
1574
|
}
|
|
1567
|
-
return
|
|
1575
|
+
return markdownText;
|
|
1568
1576
|
};
|
|
1569
1577
|
const init = async () => {
|
|
1570
1578
|
setContent("");
|