{"id":76179,"date":"2026-02-21T21:57:35","date_gmt":"2026-02-21T13:57:35","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/76179.html"},"modified":"2026-02-21T21:57:35","modified_gmt":"2026-02-21T13:57:35","slug":"flutter-for-openharmony%ef%bc%9ashelf_static-%e6%9e%81%e9%80%9f%e6%90%ad%e5%bb%ba%e9%9d%99%e6%80%81%e6%96%87%e4%bb%b6%e6%9c%8d%e5%8a%a1%e5%99%a8%ef%bc%8c%e5%ae%9e%e7%8e%b0%e6%9c%ac%e5%9c%b0%e8%a7%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/76179.html","title":{"rendered":"Flutter for OpenHarmony\uff1ashelf_static \u6781\u901f\u642d\u5efa\u9759\u6001\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u672c\u5730\u89c6\u9891\u6d41\u64ad\u653e\uff0c\u6df1\u5ea6\u89e3\u6790\u4e0e\u9e3f\u8499\u9002\u914d\u6307\u5357"},"content":{"rendered":"<p>\u6b22\u8fce\u52a0\u5165\u5f00\u6e90\u9e3f\u8499\u8de8\u5e73\u53f0\u793e\u533a&#xff1a;https:\/\/openharmonycrossplatform.csdn.net<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260221135719-6999b9bf0c3e1.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u524d\u8a00<\/h3>\n<p>\u5728 Web \u5f00\u53d1\u4e2d&#xff0c;Nginx\/Apache \u662f\u9759\u6001\u6587\u4ef6\u670d\u52a1\u7684\u9738\u4e3b\u3002\u4f46\u5728 Flutter\/Dart \u5f00\u53d1\u7684\u79fb\u52a8\u5e94\u7528\u6216\u5d4c\u5165\u5f0f\u8bbe\u5907\u4e2d&#xff0c;\u5982\u679c\u6211\u4eec\u9700\u8981\u5c06\u672c\u5730\u6587\u4ef6&#xff08;\u5982 HTML5 \u79bb\u7ebf\u5305\u3001\u4e0b\u8f7d\u7684\u89c6\u9891\u3001\u65e5\u5fd7\u6587\u4ef6&#xff09;\u66b4\u9732\u7ed9 WebView \u6216\u5c40\u57df\u7f51\u5176\u4ed6\u8bbe\u5907\u8bbf\u95ee&#xff0c;\u5f15\u5165 Nginx \u663e\u7136\u592a\u91cd\u4e86\u3002<\/p>\n<p>Shelf \u662f Dart \u5b98\u65b9\u7ef4\u62a4\u7684 Web Server \u6846\u67b6&#xff08;\u7c7b\u4f3c\u4e8e Node.js \u7684 Express \u6838\u5fc3&#xff09;\u3002\u800c shelf_static \u5219\u662f\u5176\u5b98\u65b9\u63d0\u4f9b\u7684\u4e2d\u95f4\u4ef6&#xff0c;\u4e13\u95e8\u7528\u4e8e\u5904\u7406\u9759\u6001\u6587\u4ef6\u8bf7\u6c42\u3002\u8fd9\u4e0d\u4ec5\u4ec5\u662f\u7b80\u5355\u7684\u201c\u8bfb\u6587\u4ef6\u8fd4\u56de\u201d&#xff0c;\u5b83\u8fd8\u5904\u7406\u4e86\u7f13\u5b58\u63a7\u5236&#xff08;Cache-Control&#xff09;\u3001MIME \u7c7b\u578b\u63a8\u65ad\u3001\u5c24\u5176\u662f Range Request&#xff08;\u65ad\u70b9\u7eed\u4f20\/\u89c6\u9891\u6d41&#xff09; \u7b49\u590d\u6742\u534f\u8bae\u7ec6\u8282\u3002<\/p>\n<p>\u5bf9\u4e8e OpenHarmony \u5f00\u53d1\u8005&#xff0c;\u8fd9\u610f\u5473\u7740\u4f60\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06\u4f60\u7684 App \u53d8\u6210\u4e00\u4e2a\u5fae\u578b Web \u670d\u52a1\u5668&#xff0c;\u65e0\u8bba\u662f\u670d\u52a1\u4e8e\u5185\u7f6e\u7684 ArkWeb \u7ec4\u4ef6&#xff0c;\u8fd8\u662f\u5b9e\u73b0\u8de8\u8bbe\u5907\u6587\u4ef6\u4f20\u8f93\u3002<\/p>\n<h3>\u4e00\u3001\u6838\u5fc3\u539f\u7406\u4e0e HTTP \u534f\u8bae\u6df1\u5ea6\u89e3\u6790<\/h3>\n<h4>1.1 \u9759\u6001\u8d44\u6e90\u54cd\u5e94\u6d41\u7a0b<\/h4>\n<p>\u5f53\u6d4f\u89c8\u5668\u8bf7\u6c42 GET \/index.html \u65f6&#xff0c;shelf_static \u4f1a\u505a\u4ee5\u4e0b\u51e0\u4ef6\u4e8b&#xff1a;<\/p>\n<li>\u5b89\u5168\u6027\u68c0\u67e5&#xff1a;\u9632\u6b62\u76ee\u5f55\u904d\u5386\u653b\u51fb&#xff08;\u5982\u8bf7\u6c42 GET \/..\/..\/etc\/passwd&#xff09;\u3002<\/li>\n<li>\u6587\u4ef6\u67e5\u627e&#xff1a;\u5728\u6307\u5b9a\u7684\u6839\u76ee\u5f55&#xff08;\u5982 assets\/web&#xff09;\u67e5\u627e index.html\u3002<\/li>\n<li>MIME Type&#xff1a;\u6839\u636e\u540e\u7f00\u540d&#xff08;.html -&gt; text\/html&#xff09;\u8bbe\u7f6e Content-Type\u3002<\/li>\n<li>\u534f\u5546\u7f13\u5b58&#xff1a;\u6bd4\u8f83 Last-Modified \u6216 ETag&#xff0c;\u5982\u679c\u672a\u4fee\u6539\u5219\u8fd4\u56de 304 Not Modified\u3002<\/li>\n<h4>1.2 Range Request&#xff08;\u89c6\u9891\u6d41\u7684\u6838\u5fc3&#xff09;<\/h4>\n<p>\u4e3a\u4ec0\u4e48\u7528 shelf_static \u800c\u4e0d\u662f\u81ea\u5df1\u5199 File(path).readAsBytes()&#xff1f; \u6700\u5173\u952e\u7684\u539f\u56e0\u662f Range \u8bf7\u6c42\u3002<\/p>\n<p>\u5f53\u4f60\u62d6\u52a8\u89c6\u9891\u8fdb\u5ea6\u6761\u65f6&#xff0c;\u6d4f\u89c8\u5668\u53d1\u9001\u7684\u8bf7\u6c42\u5934\u5305\u542b&#xff1a; Range: bytes&#061;1000-2000<\/p>\n<p>\u670d\u52a1\u5668\u5fc5\u987b\u89e3\u6790\u8fd9\u4e2a\u5934&#xff0c;\u5b9a\u4f4d\u6587\u4ef6\u6307\u9488&#xff0c;\u53ea\u8bfb\u53d6 1000 \u5230 2000 \u5b57\u8282&#xff0c;\u5e76\u8fd4\u56de 206 Partial Content&#xff0c;\u54cd\u5e94\u5934\u5305\u542b&#xff1a; Content-Range: bytes 1000-2000\/50000<\/p>\n<p>shelf_static \u5b8c\u7f8e\u5c01\u88c5\u4e86\u8fd9\u4e00\u903b\u8f91\u3002\u5982\u679c\u81ea\u5df1\u5199&#xff0c;\u4f60\u9700\u8981\u5904\u7406\u6781\u5176\u7e41\u7410\u7684\u8fb9\u754c\u60c5\u51b5\u3002<\/p>\n<p>  #mermaid-svg-LpGIYK8sZ3laJcKs{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-LpGIYK8sZ3laJcKs .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-LpGIYK8sZ3laJcKs .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-LpGIYK8sZ3laJcKs .error-icon{fill:#552222;}#mermaid-svg-LpGIYK8sZ3laJcKs .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-LpGIYK8sZ3laJcKs .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-LpGIYK8sZ3laJcKs .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-LpGIYK8sZ3laJcKs .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-LpGIYK8sZ3laJcKs .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-LpGIYK8sZ3laJcKs .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-LpGIYK8sZ3laJcKs .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-LpGIYK8sZ3laJcKs .marker{fill:#333333;stroke:#333333;}#mermaid-svg-LpGIYK8sZ3laJcKs .marker.cross{stroke:#333333;}#mermaid-svg-LpGIYK8sZ3laJcKs svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-LpGIYK8sZ3laJcKs p{margin:0;}#mermaid-svg-LpGIYK8sZ3laJcKs .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-LpGIYK8sZ3laJcKs .cluster-label text{fill:#333;}#mermaid-svg-LpGIYK8sZ3laJcKs .cluster-label span{color:#333;}#mermaid-svg-LpGIYK8sZ3laJcKs .cluster-label span p{background-color:transparent;}#mermaid-svg-LpGIYK8sZ3laJcKs .label text,#mermaid-svg-LpGIYK8sZ3laJcKs span{fill:#333;color:#333;}#mermaid-svg-LpGIYK8sZ3laJcKs .node rect,#mermaid-svg-LpGIYK8sZ3laJcKs .node circle,#mermaid-svg-LpGIYK8sZ3laJcKs .node ellipse,#mermaid-svg-LpGIYK8sZ3laJcKs .node polygon,#mermaid-svg-LpGIYK8sZ3laJcKs .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-LpGIYK8sZ3laJcKs .rough-node .label text,#mermaid-svg-LpGIYK8sZ3laJcKs .node .label text,#mermaid-svg-LpGIYK8sZ3laJcKs .image-shape .label,#mermaid-svg-LpGIYK8sZ3laJcKs .icon-shape .label{text-anchor:middle;}#mermaid-svg-LpGIYK8sZ3laJcKs .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-LpGIYK8sZ3laJcKs .rough-node .label,#mermaid-svg-LpGIYK8sZ3laJcKs .node .label,#mermaid-svg-LpGIYK8sZ3laJcKs .image-shape .label,#mermaid-svg-LpGIYK8sZ3laJcKs .icon-shape .label{text-align:center;}#mermaid-svg-LpGIYK8sZ3laJcKs .node.clickable{cursor:pointer;}#mermaid-svg-LpGIYK8sZ3laJcKs .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-LpGIYK8sZ3laJcKs .arrowheadPath{fill:#333333;}#mermaid-svg-LpGIYK8sZ3laJcKs .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-LpGIYK8sZ3laJcKs .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-LpGIYK8sZ3laJcKs .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-LpGIYK8sZ3laJcKs .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-LpGIYK8sZ3laJcKs .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-LpGIYK8sZ3laJcKs .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-LpGIYK8sZ3laJcKs .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-LpGIYK8sZ3laJcKs .cluster text{fill:#333;}#mermaid-svg-LpGIYK8sZ3laJcKs .cluster span{color:#333;}#mermaid-svg-LpGIYK8sZ3laJcKs div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-LpGIYK8sZ3laJcKs .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-LpGIYK8sZ3laJcKs rect.text{fill:none;stroke-width:0;}#mermaid-svg-LpGIYK8sZ3laJcKs .icon-shape,#mermaid-svg-LpGIYK8sZ3laJcKs .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-LpGIYK8sZ3laJcKs .icon-shape p,#mermaid-svg-LpGIYK8sZ3laJcKs .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-LpGIYK8sZ3laJcKs .icon-shape rect,#mermaid-svg-LpGIYK8sZ3laJcKs .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-LpGIYK8sZ3laJcKs .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-LpGIYK8sZ3laJcKs .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-LpGIYK8sZ3laJcKs :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>GET \/video.mp4 Range:0-1MB<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u89e3\u6790\u8bf7\u6c42\u5934 (Parse Header)<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u6253\u5f00\u6587\u4ef6 (Open File)<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>\u5b9a\u4f4d\u5e76\u8bfb\u53d6 (Seek &amp; Read)<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"edgeLabel\"><\/p>\n<p>206 \u90e8\u5206\u5185\u5bb9\u54cd\u5e94 (206 Partial Content)<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u6d4f\u89c8\u5668 (WebView\/Browser)<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>Shelf \u670d\u52a1\u5668<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u9759\u6001\u5904\u7406\u5668 (shelf_static)<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u6587\u4ef6\u7cfb\u7edf (File System)<\/p>\n<p><\/span><\/p>\n<p>         <span class=\"nodeLabel\"><\/p>\n<p>\u6570\u636e\u5757 (Data Chunk)<\/p>\n<p><\/span><\/p>\n<h3>\u4e8c\u3001\u6838\u5fc3 API \u8be6\u89e3<\/h3>\n<h4>2.1 \u57fa\u7840\u7528\u6cd5&#xff1a;\u66b4\u9732\u6574\u4e2a\u76ee\u5f55<\/h4>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;package:shelf\/shelf.dart&#039;<\/span><\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;package:shelf\/shelf_io.dart&#039;<\/span><\/span> <span class=\"token operator\">as<\/span> io<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;package:shelf_static\/shelf_static.dart&#039;<\/span><\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">async<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ 1. \u521b\u5efa\u9759\u6001\u6587\u4ef6\u5904\u7406\u5668<\/span><br \/>\n  <span class=\"token comment\">\/\/ defaultDocument: \u8bbf\u95ee\u6839\u76ee\u5f55\u65f6\u9ed8\u8ba4\u8fd4\u56de\u7684\u6587\u4ef6<\/span><br \/>\n  <span class=\"token comment\">\/\/ listDirectories: \u662f\u5426\u5141\u8bb8\u5217\u51fa\u6587\u4ef6\u76ee\u5f55&#xff08;\u751f\u4ea7\u73af\u5883\u5efa\u8bae false&#xff09;<\/span><br \/>\n  <span class=\"token keyword\">var<\/span> handler <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">createStaticHandler<\/span><span class=\"token punctuation\">(<\/span><br \/>\n    <span class=\"token string-literal\"><span class=\"token string\">&#039;public&#039;<\/span><\/span><span class=\"token punctuation\">,<\/span><br \/>\n    defaultDocument<span class=\"token punctuation\">:<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;index.html&#039;<\/span><\/span><span class=\"token punctuation\">,<\/span><br \/>\n    listDirectories<span class=\"token punctuation\">:<\/span> <span class=\"token boolean\">true<\/span><br \/>\n  <span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 2. \u542f\u52a8\u670d\u52a1<\/span><br \/>\n  <span class=\"token keyword\">var<\/span> server <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> io<span class=\"token punctuation\">.<\/span><span class=\"token function\">serve<\/span><span class=\"token punctuation\">(<\/span>handler<span class=\"token punctuation\">,<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;localhost&#039;<\/span><\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">8080<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token function\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-literal\"><span class=\"token string\">&#039;Serving at http:\/\/<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">${<\/span><span class=\"token expression\">server<span class=\"token punctuation\">.<\/span>address<span class=\"token punctuation\">.<\/span>host<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">:<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">${<\/span><span class=\"token expression\">server<span class=\"token punctuation\">.<\/span>port<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#039;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260221135719-6999b9bf2db3a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>2.2 \u865a\u62df\u76ee\u5f55\u6620\u5c04&#xff08;Virtual Directory&#xff09;<\/h4>\n<p>\u6709\u65f6\u5019\u6211\u4eec\u60f3\u5c06 \/static\/ \u8def\u5f84\u6620\u5c04\u5230\u7269\u7406\u76ee\u5f55 \/data\/files\/\u3002\u8fd9\u65f6\u7ed3\u5408 shelf_router \u4f7f\u7528\u6548\u679c\u66f4\u4f73\u3002<\/p>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;package:shelf_router\/shelf_router.dart&#039;<\/span><\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">final<\/span> app <span class=\"token operator\">&#061;<\/span> <span class=\"token class-name\">Router<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u5c06 \/files\/ \u4e0b\u7684\u6240\u6709\u8bf7\u6c42\u8f6c\u53d1\u7ed9 shelf_static<\/span><br \/>\n<span class=\"token comment\">\/\/ \u6ce8\u610f&#xff1a;web_files \u5fc5\u987b\u662f\u7269\u7406\u5b58\u5728\u7684\u76ee\u5f55<\/span><br \/>\n<span class=\"token comment\">\/\/ stripPrefix: \u53bb\u6389 URL \u524d\u7f00\u518d\u67e5\u627e\u6587\u4ef6<\/span><br \/>\napp<span class=\"token punctuation\">.<\/span><span class=\"token function\">mount<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-literal\"><span class=\"token string\">&#039;\/files\/&#039;<\/span><\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">createStaticHandler<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-literal\"><span class=\"token string\">&#039;\/data\/storage\/files&#039;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260221135722-6999b9c2bd6cd.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u4e09\u3001OpenHarmony \u5e73\u53f0\u9002\u914d\u5b9e\u6218<\/h3>\n<p>\u5728\u9e3f\u8499\u7cfb\u7edf\u4e0a&#xff0c;\u6700\u5178\u578b\u7684\u5e94\u7528\u573a\u666f\u662f&#xff1a;App\u5185\u7f6e\u5fae\u670d\u52a1&#xff0c;\u4f9b Web \u7ec4\u4ef6\u8c03\u7528\u3002<\/p>\n<h4>3.1 \u9e3f\u8499\u5e94\u7528\u6c99\u7bb1\u8def\u5f84<\/h4>\n<p>\u9e3f\u8499\u7684\u6c99\u7bb1\u673a\u5236\u975e\u5e38\u4e25\u683c\u3002\u5982\u679c\u4f60\u7684 H5 \u8d44\u6e90\u6253\u5305\u5728 assets \u4e2d&#xff08;\u5728\u9e3f\u8499\u662f rawfile&#xff09;&#xff0c;Dart \u662f\u65e0\u6cd5\u76f4\u63a5\u901a\u8fc7\u6587\u4ef6\u8def\u5f84\u8bbf\u95ee\u7684&#xff08;\u56e0\u4e3a rawfile \u5728 hap \u5305\u5185&#xff0c;\u662f\u538b\u7f29\u7684&#xff09;\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848&#xff1a;<\/p>\n<li>\u9996\u6b21\u542f\u52a8\u590d\u5236&#xff1a;App \u542f\u52a8\u65f6&#xff0c;\u5c06 rawfile \u4e0b\u7684\u8d44\u6e90\u89e3\u538b\/\u590d\u5236\u5230 getApplicationDocumentsDirectory() \u4e0b\u7684\u67d0\u4e2a\u76ee\u5f55&#xff08;\u5982 www&#xff09;\u3002<\/li>\n<li>\u670d\u52a1\u8be5\u76ee\u5f55&#xff1a;\u4f7f\u7528 shelf_static \u6307\u5411\u8fd9\u4e2a www \u76ee\u5f55\u3002<\/li>\n<p><span class=\"token comment\">\/\/ 1. \u590d\u5236\u8d44\u6e90 (\u4f7f\u7528 flutter\/services)<\/span><br \/>\n<span class=\"token class-name\">Future<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> <span class=\"token function\">copyAssets<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">async<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">final<\/span> dir <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> <span class=\"token function\">getApplicationDocumentsDirectory<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">final<\/span> indexFile <span class=\"token operator\">&#061;<\/span> <span class=\"token class-name\">File<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-literal\"><span class=\"token string\">&#039;<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">${<\/span><span class=\"token expression\">dir<span class=\"token punctuation\">.<\/span>path<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">\/www\/index.html&#039;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span>indexFile<span class=\"token punctuation\">.<\/span><span class=\"token function\">existsSync<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u8bfb\u53d6 Asset<\/span><br \/>\n    <span class=\"token keyword\">final<\/span> bytes <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> rootBundle<span class=\"token punctuation\">.<\/span><span class=\"token function\">load<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-literal\"><span class=\"token string\">&#039;assets\/www\/index.html&#039;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u5199\u5165\u6587\u4ef6\u7cfb\u7edf<\/span><br \/>\n    <span class=\"token keyword\">await<\/span> indexFile<span class=\"token punctuation\">.<\/span><span class=\"token function\">create<\/span><span class=\"token punctuation\">(<\/span>recursive<span class=\"token punctuation\">:<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">await<\/span> indexFile<span class=\"token punctuation\">.<\/span><span class=\"token function\">writeAsBytes<\/span><span class=\"token punctuation\">(<\/span>bytes<span class=\"token punctuation\">.<\/span>buffer<span class=\"token punctuation\">.<\/span><span class=\"token function\">asUint8List<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260221135726-6999b9c650e34.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>3.2 \u5b9e\u6218&#xff1a;\u672c\u5730\u89c6\u9891\u6d41\u670d\u52a1\u5668<\/h4>\n<p>\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u529f\u80fd\u3002\u5f88\u591a\u89c6\u9891\u64ad\u653e\u5668\u4e0d\u652f\u6301\u76f4\u63a5\u64ad\u653e\u79c1\u6709\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6&#xff0c;\u6216\u8005\u4e0d\u652f\u6301\u590d\u6742\u7684\u52a0\u5bc6\u6d41\u3002\u6211\u4eec\u53ef\u4ee5\u7528 Shelf \u642d\u5efa\u4e00\u4e2a\u672c\u5730\u4ee3\u7406\u3002<\/p>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;dart:io&#039;<\/span><\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;package:shelf\/shelf.dart&#039;<\/span><\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;package:shelf\/shelf_io.dart&#039;<\/span><\/span> <span class=\"token operator\">as<\/span> shelf_io<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;package:shelf_static\/shelf_static.dart&#039;<\/span><\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;package:path_provider\/path_provider.dart&#039;<\/span><\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">VideoServer<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token class-name\">HttpServer<\/span><span class=\"token operator\">?<\/span> _server<span class=\"token punctuation\">;<\/span><br \/>\n  int <span class=\"token keyword\">get<\/span> port <span class=\"token operator\">&#061;<\/span><span class=\"token operator\">&gt;<\/span> _server<span class=\"token operator\">?<\/span><span class=\"token punctuation\">.<\/span>port <span class=\"token operator\">?<\/span><span class=\"token operator\">?<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token class-name\">Future<\/span><span class=\"token generics\"><span class=\"token punctuation\">&lt;<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">&gt;<\/span><\/span> <span class=\"token function\">start<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">async<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">final<\/span> docsDir <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> <span class=\"token function\">getApplicationDocumentsDirectory<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">final<\/span> videoDir <span class=\"token operator\">&#061;<\/span> <span class=\"token class-name\">Directory<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-literal\"><span class=\"token string\">&#039;<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">${<\/span><span class=\"token expression\">docsDir<span class=\"token punctuation\">.<\/span>path<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">\/videos&#039;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u786e\u4fdd\u76ee\u5f55\u5b58\u5728<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span><span class=\"token keyword\">await<\/span> videoDir<span class=\"token punctuation\">.<\/span><span class=\"token function\">exists<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token keyword\">await<\/span> videoDir<span class=\"token punctuation\">.<\/span><span class=\"token function\">create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u5173\u952e\u914d\u7f6e&#xff1a;\u5f00\u542f Range \u652f\u6301<\/span><br \/>\n    <span class=\"token keyword\">final<\/span> staticHandler <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">createStaticHandler<\/span><span class=\"token punctuation\">(<\/span><br \/>\n      videoDir<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">,<\/span><br \/>\n      serveFilesOutsidePath<span class=\"token punctuation\">:<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/\/ \u5b89\u5168\u914d\u7f6e<\/span><br \/>\n      listDirectories<span class=\"token punctuation\">:<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u589e\u52a0\u65e5\u5fd7\u4e2d\u95f4\u4ef6<\/span><br \/>\n    <span class=\"token keyword\">final<\/span> handler <span class=\"token operator\">&#061;<\/span> <span class=\"token class-name\">Pipeline<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token function\">addMiddleware<\/span><span class=\"token punctuation\">(<\/span><span class=\"token function\">logRequests<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token function\">addHandler<\/span><span class=\"token punctuation\">(<\/span>staticHandler<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u7ed1\u5b9a localhost (\u4ec5\u672c\u673a\u53ef\u8bbf\u95ee&#xff0c;\u66f4\u5b89\u5168)<\/span><br \/>\n    _server <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> shelf_io<span class=\"token punctuation\">.<\/span><span class=\"token function\">serve<\/span><span class=\"token punctuation\">(<\/span>handler<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">InternetAddress<\/span><span class=\"token punctuation\">.<\/span>loopbackIPv4<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-literal\"><span class=\"token string\">&#039;Video Server running on port <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">${<\/span><span class=\"token expression\">_server<span class=\"token operator\">!<\/span><span class=\"token punctuation\">.<\/span>port<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#039;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u83b7\u53d6\u89c6\u9891\u64ad\u653e URL<\/span><br \/>\n  <span class=\"token class-name\">String<\/span> <span class=\"token function\">getVideoUrl<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">String<\/span> filename<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;http:\/\/127.0.0.1:<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">$<\/span><span class=\"token expression\">port<\/span><\/span><span class=\"token string\">\/<\/span><span class=\"token interpolation\"><span class=\"token punctuation\">$<\/span><span class=\"token expression\">filename<\/span><\/span><span class=\"token string\">&#039;<\/span><\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260221135730-6999b9ca28124.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>3.3 \u5728 Web \u7ec4\u4ef6\u4e2d\u4f7f\u7528<\/h4>\n<p>\u542f\u52a8 Server \u540e&#xff0c;\u6211\u4eec\u5728 Flutter \u7684 WebView \u6216\u9e3f\u8499\u539f\u751f\u7684 ArkWeb \u4e2d\u52a0\u8f7d&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u5047\u8bbe\u5df2\u542f\u52a8 Server<\/span><br \/>\n<span class=\"token keyword\">final<\/span> url <span class=\"token operator\">&#061;<\/span> videoServer<span class=\"token punctuation\">.<\/span><span class=\"token function\">getVideoUrl<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-literal\"><span class=\"token string\">&#039;movie.mp4&#039;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u4f7f\u7528 video_player \u4e5f\u662f\u4e00\u6837\u7684\u539f\u7406<\/span><br \/>\n<span class=\"token class-name\">VideoPlayerController<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">network<\/span><span class=\"token punctuation\">(<\/span>url<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">initialize<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u7531\u4e8e shelf_static \u652f\u6301 HTTP Range&#xff0c;\u89c6\u9891\u64ad\u653e\u5668\u53ef\u4ee5&#xff1a;<\/p>\n<li>\u79d2\u5f00&#xff1a;\u53ea\u8bf7\u6c42\u524d\u51e0 KB \u6570\u636e\u89e3\u6790 Metadata\u3002<\/li>\n<li>\u968f\u610f\u62d6\u52a8&#xff1a;\u76f4\u63a5 seek \u5230\u4e2d\u95f4\u4f4d\u7f6e&#xff0c;\u670d\u52a1\u5668\u53ea\u8fd4\u56de\u540e\u534a\u6bb5\u6570\u636e\u3002<\/li>\n<h3>\u56db\u3001\u9ad8\u7ea7\u8fdb\u9636&#xff1a;\u5b89\u5168\u6027\u4e0e\u6027\u80fd\u4f18\u5316<\/h3>\n<h4>4.1 \u76ee\u5f55\u904d\u5386\u653b\u51fb (Directory Traversal)<\/h4>\n<p>\u8fd9\u662f\u9759\u6001\u6587\u4ef6\u670d\u52a1\u6700\u5927\u7684\u5b89\u5168\u9690\u60a3\u3002\u653b\u51fb\u8005\u53ef\u80fd\u8bf7\u6c42 GET \/..\/..\/..\/..\/etc\/passwd\u3002 shelf_static \u9ed8\u8ba4\u542f\u7528\u4e86\u9632\u5fa1\u673a\u5236&#xff0c;\u5b83\u4f1a\u89c4\u8303\u5316\u8def\u5f84\u5e76\u5728\u8bbf\u95ee\u524d\u68c0\u67e5\u662f\u5426\u9003\u9038\u51fa\u4e86 root \u76ee\u5f55\u3002 \u4f46\u662f&#xff0c;\u5982\u679c\u4f60\u5f00\u542f\u4e86\u7b26\u53f7\u94fe\u63a5&#xff08;Symlink&#xff09;\u652f\u6301&#xff0c;\u9700\u683c\u5916\u5c0f\u5fc3\u3002<\/p>\n<p>\u5efa\u8bae&#xff1a;\u59cb\u7ec8\u8bbe\u7f6e serveFilesOutsidePath: false\u3002<\/p>\n<h4>4.2 \u7f13\u5b58\u7b56\u7565 (Cache-Control)<\/h4>\n<p>\u5bf9\u4e8e\u9759\u6001\u8d44\u6e90&#xff0c;\u5408\u7406\u7684\u7f13\u5b58\u80fd\u51cf\u5c11 IO&#xff0c;\u63d0\u5347\u52a0\u8f7d\u901f\u5ea6\u3002<\/p>\n<p><span class=\"token comment\">\/\/ \u81ea\u5b9a\u4e49 Header \u4e2d\u95f4\u4ef6<\/span><br \/>\n<span class=\"token class-name\">Handler<\/span> <span class=\"token function\">cacheMiddleware<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">Handler<\/span> innerHandler<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">(<\/span>request<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">async<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">final<\/span> response <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> <span class=\"token function\">innerHandler<\/span><span class=\"token punctuation\">(<\/span>request<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u5982\u679c\u662f\u56fe\u7247&#xff0c;\u7f13\u5b58 1 \u5929<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>response<span class=\"token punctuation\">.<\/span>mimeType<span class=\"token operator\">?<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">startsWith<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-literal\"><span class=\"token string\">&#039;image\/&#039;<\/span><\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">?<\/span><span class=\"token operator\">?<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token keyword\">return<\/span> response<span class=\"token punctuation\">.<\/span><span class=\"token function\">change<\/span><span class=\"token punctuation\">(<\/span>headers<span class=\"token punctuation\">:<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token string-literal\"><span class=\"token string\">&#039;Cache-Control&#039;<\/span><\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string-literal\"><span class=\"token string\">&#039;public, max-age&#061;86400&#039;<\/span><\/span><span class=\"token punctuation\">,<\/span><br \/>\n      <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> response<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h4>4.3 \u6027\u80fd&#xff1a;Sendfile<\/h4>\n<p>\u5728 Linux\/Android \u4e0a&#xff0c;\u9ad8\u6027\u80fd Web Server&#xff08;\u5982 Nginx&#xff09;\u4f1a\u4f7f\u7528\u5185\u6838\u7ea7\u7684 sendfile \u7cfb\u7edf\u8c03\u7528&#xff08;\u96f6\u62f7\u8d1d&#xff09;\u3002 Dart \u7684 shelf_static \u76ee\u524d\u4e3b\u8981\u662f\u5e94\u7528\u5c42\u8bfb\u5199\u3002\u5bf9\u4e8e\u8d85\u5927\u6587\u4ef6\u5e76\u53d1&#xff08;\u5982 100 \u4eba\u540c\u65f6\u4e0b\u8f7d&#xff09;&#xff0c;\u6027\u80fd\u4e0d\u5982 Nginx\u3002\u4f46\u5bf9\u4e8e\u79fb\u52a8\u7aef\u672c\u5730\u670d\u52a1&#xff08;\u901a\u5e38\u53ea\u6709 1 \u4e2a\u5ba2\u6237\u7aef&#xff09;&#xff0c;\u6027\u80fd\u7ef0\u7ef0\u6709\u4f59\u3002<\/p>\n<h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<p>shelf_static \u662f Dart \u5168\u6808\u5f00\u53d1\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u5757\u62fc\u56fe\u3002\u5b83\u7528\u6781\u5c11\u7684\u4ee3\u7801\u6781\u5176\u4f18\u96c5\u5730\u89e3\u51b3\u4e86\u201c\u6587\u4ef6\u670d\u52a1\u201d\u8fd9\u4e00\u57fa\u7840\u9700\u6c42\u3002<\/p>\n<p>\u5728 OpenHarmony \u5e73\u53f0\u4e0a&#xff0c;\u5b83\u5c55\u73b0\u4e86\u5f3a\u5927\u7684\u751f\u547d\u529b&#xff1a;<\/p>\n<li>\u517c\u5bb9\u6027\u5f3a&#xff1a;\u7eaf Dart \u5b9e\u73b0&#xff0c;\u65e0 Native \u4f9d\u8d56&#xff0c;\u9e3f\u8499\u65e0\u7f1d\u8fd0\u884c\u3002<\/li>\n<li>\u534f\u8bae\u6807\u51c6&#xff1a;\u5bf9 HTTP Range \u7684\u5b8c\u7f8e\u652f\u6301&#xff0c;\u4f7f\u5176\u6210\u4e3a\u672c\u5730\u591a\u5a92\u4f53\u670d\u52a1\u7684\u57fa\u77f3\u3002<\/li>\n<li>\u5b89\u5168\u6027\u9ad8&#xff1a;\u5185\u7f6e\u8def\u5f84\u68c0\u67e5&#xff0c;\u9632\u6b62\u6587\u4ef6\u6cc4\u9732\u3002<\/li>\n<p>\u6700\u4f73\u5b9e\u8df5&#xff1a;<\/p>\n<ul>\n<li>\u4e0d\u8981\u5728 UI \u7ebf\u7a0b\u542f\u52a8 Server&#xff08;\u867d\u7136\u662f\u5f02\u6b65 IO&#xff0c;\u4f46\u8bf7\u6c42\u5904\u7406\u903b\u8f91\u5728 Isolate \u5185&#xff09;\u3002\u5efa\u8bae\u653e\u5728\u72ec\u7acb\u7684 Isolate \u542f\u52a8 shelf \u670d\u52a1&#xff0c;\u7279\u522b\u662f\u9700\u8981\u5904\u7406\u5927\u91cf\u5e76\u53d1\u8bf7\u6c42\u65f6\u3002<\/li>\n<\/ul>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u6b22\u8fce\u52a0\u5165\u5f00\u6e90\u9e3f\u8499\u8de8\u5e73\u53f0\u793e\u533a&#xff1a;https:\/\/openharmonycrossplatform.csdn.net \u524d\u8a00<br \/>\n\u5728 Web \u5f00\u53d1\u4e2d&#xff0c;Nginx\/Apache \u662f\u9759\u6001\u6587\u4ef6\u670d\u52a1\u7684\u9738\u4e3b\u3002\u4f46\u5728 Flutter\/Dart \u5f00\u53d1\u7684\u79fb\u52a8\u5e94\u7528\u6216\u5d4c\u5165\u5f0f\u8bbe\u5907\u4e2d&#xff0c;\u5982\u679c\u6211\u4eec\u9700\u8981\u5c06\u672c\u5730\u6587\u4ef6&#xff08;\u5982 HTML5 \u79bb\u7ebf\u5305\u3001\u4e0b\u8f7d\u7684\u89c6\u9891\u3001\u65e5\u5fd7\u6587\u4ef6&#xff09;\u66b4\u9732\u7ed9 WebView \u6216\u5c40\u57df\u7f51\u5176\u4ed6\u8bbe\u5907\u8bbf\u95ee&#xff0c;\u5f15\u5165 Nginx \u663e\u7136\u592a\u91cd\u4e86\u3002<\/p>\n","protected":false},"author":2,"featured_media":76174,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2878,280,93,1380,67,43,44],"topic":[],"class_list":["post-76179","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-flutter","tag-harmonyos","tag-json","tag-rpc","tag-67","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Flutter for OpenHarmony\uff1ashelf_static \u6781\u901f\u642d\u5efa\u9759\u6001\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u672c\u5730\u89c6\u9891\u6d41\u64ad\u653e\uff0c\u6df1\u5ea6\u89e3\u6790\u4e0e\u9e3f\u8499\u9002\u914d\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/76179.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Flutter for OpenHarmony\uff1ashelf_static \u6781\u901f\u642d\u5efa\u9759\u6001\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u672c\u5730\u89c6\u9891\u6d41\u64ad\u653e\uff0c\u6df1\u5ea6\u89e3\u6790\u4e0e\u9e3f\u8499\u9002\u914d\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6b22\u8fce\u52a0\u5165\u5f00\u6e90\u9e3f\u8499\u8de8\u5e73\u53f0\u793e\u533a&#xff1a;https:\/\/openharmonycrossplatform.csdn.net \u524d\u8a00 \u5728 Web \u5f00\u53d1\u4e2d&#xff0c;Nginx\/Apache \u662f\u9759\u6001\u6587\u4ef6\u670d\u52a1\u7684\u9738\u4e3b\u3002\u4f46\u5728 Flutter\/Dart \u5f00\u53d1\u7684\u79fb\u52a8\u5e94\u7528\u6216\u5d4c\u5165\u5f0f\u8bbe\u5907\u4e2d&#xff0c;\u5982\u679c\u6211\u4eec\u9700\u8981\u5c06\u672c\u5730\u6587\u4ef6&#xff08;\u5982 HTML5 \u79bb\u7ebf\u5305\u3001\u4e0b\u8f7d\u7684\u89c6\u9891\u3001\u65e5\u5fd7\u6587\u4ef6&#xff09;\u66b4\u9732\u7ed9 WebView \u6216\u5c40\u57df\u7f51\u5176\u4ed6\u8bbe\u5907\u8bbf\u95ee&#xff0c;\u5f15\u5165 Nginx \u663e\u7136\u592a\u91cd\u4e86\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/76179.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-21T13:57:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260221135719-6999b9bf0c3e1.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76179.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/76179.html\",\"name\":\"Flutter for OpenHarmony\uff1ashelf_static \u6781\u901f\u642d\u5efa\u9759\u6001\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u672c\u5730\u89c6\u9891\u6d41\u64ad\u653e\uff0c\u6df1\u5ea6\u89e3\u6790\u4e0e\u9e3f\u8499\u9002\u914d\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-21T13:57:35+00:00\",\"dateModified\":\"2026-02-21T13:57:35+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/76179.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/76179.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76179.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Flutter for OpenHarmony\uff1ashelf_static \u6781\u901f\u642d\u5efa\u9759\u6001\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u672c\u5730\u89c6\u9891\u6d41\u64ad\u653e\uff0c\u6df1\u5ea6\u89e3\u6790\u4e0e\u9e3f\u8499\u9002\u914d\u6307\u5357\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Flutter for OpenHarmony\uff1ashelf_static \u6781\u901f\u642d\u5efa\u9759\u6001\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u672c\u5730\u89c6\u9891\u6d41\u64ad\u653e\uff0c\u6df1\u5ea6\u89e3\u6790\u4e0e\u9e3f\u8499\u9002\u914d\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/76179.html","og_locale":"zh_CN","og_type":"article","og_title":"Flutter for OpenHarmony\uff1ashelf_static \u6781\u901f\u642d\u5efa\u9759\u6001\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u672c\u5730\u89c6\u9891\u6d41\u64ad\u653e\uff0c\u6df1\u5ea6\u89e3\u6790\u4e0e\u9e3f\u8499\u9002\u914d\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6b22\u8fce\u52a0\u5165\u5f00\u6e90\u9e3f\u8499\u8de8\u5e73\u53f0\u793e\u533a&#xff1a;https:\/\/openharmonycrossplatform.csdn.net \u524d\u8a00 \u5728 Web \u5f00\u53d1\u4e2d&#xff0c;Nginx\/Apache \u662f\u9759\u6001\u6587\u4ef6\u670d\u52a1\u7684\u9738\u4e3b\u3002\u4f46\u5728 Flutter\/Dart \u5f00\u53d1\u7684\u79fb\u52a8\u5e94\u7528\u6216\u5d4c\u5165\u5f0f\u8bbe\u5907\u4e2d&#xff0c;\u5982\u679c\u6211\u4eec\u9700\u8981\u5c06\u672c\u5730\u6587\u4ef6&#xff08;\u5982 HTML5 \u79bb\u7ebf\u5305\u3001\u4e0b\u8f7d\u7684\u89c6\u9891\u3001\u65e5\u5fd7\u6587\u4ef6&#xff09;\u66b4\u9732\u7ed9 WebView \u6216\u5c40\u57df\u7f51\u5176\u4ed6\u8bbe\u5907\u8bbf\u95ee&#xff0c;\u5f15\u5165 Nginx \u663e\u7136\u592a\u91cd\u4e86\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/76179.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-21T13:57:35+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260221135719-6999b9bf0c3e1.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/76179.html","url":"https:\/\/www.wsisp.com\/helps\/76179.html","name":"Flutter for OpenHarmony\uff1ashelf_static \u6781\u901f\u642d\u5efa\u9759\u6001\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u672c\u5730\u89c6\u9891\u6d41\u64ad\u653e\uff0c\u6df1\u5ea6\u89e3\u6790\u4e0e\u9e3f\u8499\u9002\u914d\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-21T13:57:35+00:00","dateModified":"2026-02-21T13:57:35+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/76179.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/76179.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/76179.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Flutter for OpenHarmony\uff1ashelf_static \u6781\u901f\u642d\u5efa\u9759\u6001\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u672c\u5730\u89c6\u9891\u6d41\u64ad\u653e\uff0c\u6df1\u5ea6\u89e3\u6790\u4e0e\u9e3f\u8499\u9002\u914d\u6307\u5357"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=76179"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76179\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/76174"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=76179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=76179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=76179"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=76179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}