{"id":10021010,"date":"2025-09-23T21:23:20","date_gmt":"2025-09-23T13:23:20","guid":{"rendered":"https:\/\/itmax.cn\/?p=10021010"},"modified":"2025-09-23T21:23:20","modified_gmt":"2025-09-23T13:23:20","slug":"%e5%9f%ba%e4%ba%8e%e6%b5%8f%e8%a7%88%e5%99%a8%e6%89%a9%e5%b1%95-api-mock-%e5%b7%a5%e5%85%b7%e5%bc%80%e5%8f%91%e6%8e%a2%e7%b4%a2%ef%bd%9c%e5%be%97%e7%89%a9%e6%8a%80%e6%9c%af","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10021010","title":{"rendered":"\u57fa\u4e8e\u6d4f\u89c8\u5668\u6269\u5c55 API Mock \u5de5\u5177\u5f00\u53d1\u63a2\u7d22\uff5c\u5f97\u7269\u6280\u672f"},"content":{"rendered":"<h2>\u4e00\u3001\u524d \u8a00<\/h2>\n<p>\u5728\u65e5\u5e38\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u5076\u5c14\u4f1a\u9047\u5230\u540e\u7aef\u63a5\u53e3\u672a\u5b8c\u6210\u6216\u8005\u67d0\u4e2a\u73af\u5883\u51fa\u73b0\u95ee\u9898\u9700\u8981\u6839\u636e\u63a5\u53e3\u8fd4\u56de\u6765\u590d\u73b0\u7b49\u7b49\u573a\u666f\u3002\u521a\u597d\u6700\u8fd1\u5728\u5b66\u4e60\u6d4f\u89c8\u5668\u63d2\u4ef6\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e76\u5728\u6b64\u80cc\u666f\u4e0b\u5f00\u53d1\u4e86\u4e00\u6b3e\u57fa\u4e8e\u6d4f\u89c8\u5668\u63d2\u4ef6\u7684 Mock \u5de5\u5177\u3002\u8be5\u5de5\u5177\u4e13\u6ce8\u4e8e API\u00a0<strong>\u8bf7\u6c42\u62e6\u622a\u548c\u6570\u636e\u6a21\u62df<\/strong>\uff0c\u65e8\u5728\u5e2e\u52a9\u5f00\u53d1\u8005\u63d0\u5347\u5f00\u53d1\u6548\u7387\uff0c\u80fd\u591f\u89e3\u51b3\u4e00\u4e9b\u95ee\u9898\u3002<\/p>\n<h2>\u4e8c\u3001\u6d4f\u89c8\u5668\u63d2\u4ef6\u4ecb\u7ecd<\/h2>\n<p><strong>\u4ec0\u4e48\u662f\u6d4f\u89c8\u5668\u63d2\u4ef6<\/strong><\/p>\n<p>\u6d4f\u89c8\u5668\u63d2\u4ef6\uff08Extensions \u6216 Add-ons\uff09\u662f\u4e00\u7c7b\u8fd0\u884c\u4e8e<strong>\u6d4f\u89c8\u5668\u8fdb\u7a0b\u4e2d\u7684\u8f7b\u91cf\u7ea7\u529f\u80fd\u589e\u5f3a\u6a21\u5757<\/strong>\uff0c\u5176\u6838\u5fc3\u4ef7\u503c\u5728\u4e8e\u901a\u8fc7\u6807\u51c6\u5316\u63a5\u53e3\u5b9e\u73b0\u5bf9\u6d4f\u89c8\u5668\u5185\u6838\u80fd\u529b\u7684\u6df1\u5ea6\u6574\u5408\u4e0e\u5b9a\u5236\u3002\u6839\u636e Mozilla \u5f00\u53d1\u8005\u6587\u6863\u5b9a\u4e49\uff0c\u63d2\u4ef6\u672c\u8d28\u4e0a\u662f\u201c\u80fd\u591f\u4fee\u6539\u548c\u589e\u5f3a\u6d4f\u89c8\u5668\u80fd\u529b\u7684\u5e94\u7528\u7a0b\u5e8f\u201d\uff0cFirefox\u3001Chrome \u7b49\u4e3b\u6d41\u6d4f\u89c8\u5668\u5747\u91c7\u7528 WebExtensions API \u8fd9\u4e00\u8de8\u6d4f\u89c8\u5668\u6280\u672f\u6784\u5efa\u63d2\u4ef6\u751f\u6001\u3002\u4e0e\u7f51\u9875\u5e94\u7528\uff08Web App\uff09\u9700\u4f9d\u8d56\u6d4f\u89c8\u5668\u6807\u7b7e\u9875\u8fd0\u884c\u3001\u539f\u751f\u5e94\u7528\uff08Native App\uff09\u9700\u72ec\u7acb\u5b89\u88c5\u7684\u7279\u6027\u4e0d\u540c\uff0c\u63d2\u4ef6\u4ee5<strong>\u8f7b\u91cf\u5316\u90e8\u7f72<\/strong>\u4e3a\u663e\u8457\u7279\u5f81\u2014\u2014\u65e0\u9700\u590d\u6742\u8bbe\u7f6e\u5373\u53ef\u76f4\u63a5\u5728\u6d4f\u89c8\u5668\u73af\u5883\u5185\u8fd0\u884c\uff0c\u540c\u65f6\u5177\u5907\u6807\u7b7e\u63a7\u5236\u3001\u7f51\u7edc\u8bf7\u6c42\u62e6\u622a\u3001\u672c\u5730\u5b58\u50a8\u8bbf\u95ee\u7b49\u7f51\u9875\u5e94\u7528\u65e0\u6cd5\u5b9e\u73b0\u7684\u5e95\u5c42\u80fd\u529b\u3002<\/p>\n<p><strong>Manifest V3 \u67b6\u6784<\/strong><\/p>\n<p>Manifest V3 \u5bf9\u6d4f\u89c8\u5668\u63d2\u4ef6\u7684\u5e95\u5c42\u67b6\u6784\u8fdb\u884c\u4e86\u98a0\u8986\u6027\u91cd\u6784\uff0c\u4e3b\u8981\u4f53\u73b0\u5728\u80cc\u666f\u6267\u884c\u673a\u5236\u3001\u7f51\u7edc\u8bf7\u6c42\u63a7\u5236\u548c\u4ee3\u7801\u5b89\u5168\u6a21\u578b\u4e09\u4e2a\u6838\u5fc3\u7ef4\u5ea6\u3002\u4ee5\u4e0b\u4ece\u6280\u672f\u5b9e\u73b0\u4e0e\u8bbe\u8ba1\u52a8\u673a\u89d2\u5ea6\u8fdb\u884c\u5168\u9762\u5bf9\u6bd4\uff1a<br \/><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"142\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmyJe\" alt=\"image.png\" title=\"image.png\"><\/p>\n<p><strong>\u5173\u952e\u67b6\u6784\u53d8\u9769<\/strong>\uff1aV3 \u91c7\u7528&#8221;\u9759\u6001\u58f0\u660e+\u5185\u6838\u7ea7\u5904\u7406&#8221;\u6a21\u5f0f\u66ff\u4ee3 V2 \u7684&#8221;\u52a8\u6001\u811a\u672c+\u63d2\u4ef6\u81ea\u4e3b\u63a7\u5236&#8221;\u6a21\u5f0f\uff0c\u901a\u8fc7\u6d4f\u89c8\u5668\u5185\u6838\u76f4\u63a5\u4ecb\u5165\u5173\u952e\u6d41\u7a0b\uff08\u5982\u7f51\u7edc\u62e6\u622a\uff09\uff0c\u5728\u6027\u80fd\u4e0e\u5b89\u5168\u6027\u4e4b\u95f4\u53d6\u5f97\u5e73\u8861\u3002<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"457\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmyJf\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p><strong>\u6838\u5fc3\u914d\u7f6e\u5dee\u5f02\u793a\u4f8b<\/strong><\/p>\n<p><strong>\u80cc\u666f\u6267\u884c\u6a21\u5757\u914d\u7f6e<\/strong><\/p>\n<pre><code>\/\/ V2 \u6301\u4e45\u5316\u80cc\u666f\u9875\u914d\u7f6e&quot;\nbackground&quot;: {\n\u00a0 &quot;scripts&quot;: [&quot;background.js&quot;], \u00a0\n\u00a0\u00a0&quot;persistent&quot;: true \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0\n}\n\n\n\/\/ V3 Service Worker \u914d\u7f6e\n&quot;background&quot;: {\n\u00a0 \u00a0&quot;service_worker&quot;:\u00a0&quot;background.js&quot;, \u00a0\n\u00a0 \u00a0&quot;type&quot;:\u00a0&quot;module&quot;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\n}\n<\/code><\/pre>\n<p><strong>\u7f51\u7edc\u8bf7\u6c42\u89c4\u5219\u914d\u7f6e<\/strong><\/p>\n<p>V3 \u9700\u5728 Manifest \u4e2d\u58f0\u660e DNR \u6743\u9650\u53ca\u89c4\u5219\u6587\u4ef6\uff1a<\/p>\n<pre><code>\/\/ V3 declarativeNetRequest \u914d\u7f6e\n&quot;permissions&quot;:\u00a0[&quot;declarativeNetRequest&quot;],\n&quot;host_permissions&quot;:\u00a0[&quot;&lt;all_urls&gt;&quot;],\n&quot;declarative_net_request&quot;:\u00a0{\n\u00a0 \u00a0&quot;rule_resources&quot;:\u00a0[\n\u00a0 \u00a0 \u00a0 \u00a0{&quot;id&quot;:\u00a0&quot;ruleset_1&quot;,&quot;enabled&quot;:\u00a0true,&quot;path&quot;:\u00a0&quot;rules.json&quot;\u00a0\u00a0}\n\u00a0 \u00a0\u00a0]\n}\n<\/code><\/pre>\n<h2>\u4e09\u3001Mock \u63d2\u4ef6\u5b9e\u73b0\u7684\u57fa\u672c\u539f\u7406<\/h2>\n<p><strong>\u8bf7\u6c42\u62e6\u622a\u7684\u6838\u5fc3\u539f\u7406<\/strong><\/p>\n<p>\u7531\u4e8e Manifest V3 \u79fb\u9664\u4e86webRequest\u00a0API \u7684\u963b\u585e\u80fd\u529b\uff0cdeclarativeNetRequest\u53c8\u65e0\u6cd5\u91cd\u5b9a\u5411\u5230\u81ea\u5b9a\u4e49\u6570\u636e\uff0c\u4e8e\u662f\u65b9\u6848\u4e0a\u9009\u62e9\u7684\u662f\u5728\u9875\u9762\u4e0a\u4e0b\u6587\u4e2d\u91cd\u5199\u539f\u751f API\uff0c\u76ee\u524d\u91cd\u5199\u4e86fetch\u8ddfXMLHttpRequest\u3002<\/p>\n<pre><code>\/\/ injected.js - \u5728\u9875\u9762\u73af\u5883\u4e2d\u91cd\u5199fetch\nconst\u00a0originalFetch =\u00a0window.fetch;\nwindow.fetch\u00a0=\u00a0async\u00a0function(url, options = {}) {\n\u00a0\u00a0\/\/ 1. \u53d1\u9001\u62e6\u622a\u8bf7\u6c42\u5230content script\n\u00a0\u00a0const\u00a0response =\u00a0await\u00a0sendMockRequest(url, options);\n\n\n\u00a0\u00a0\/\/ 2. \u5982\u679c\u6709\u5339\u914d\u7684Mock\u89c4\u5219\uff0c\u8fd4\u56deMock\u6570\u636e\n\u00a0\u00a0if\u00a0(response.shouldMock) {\n\u00a0 \u00a0\u00a0return\u00a0new\u00a0Response(\n\u00a0 \u00a0 \u00a0\u00a0JSON.stringify(response.mockData),\n\u00a0 \u00a0 \u00a0 {\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0status: response.status,\n\u00a0 \u00a0 \u00a0 \u00a0\u00a0headers: response.headers\n\u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 );\n\u00a0 }\n\n\n\u00a0\u00a0\/\/ 3. \u5426\u5219\u6267\u884c\u539f\u59cb\u8bf7\u6c42\n\u00a0\u00a0return\u00a0originalFetch.call(this, url, options);\n};\n<\/code><\/pre>\n<p><strong>\u811a\u672c\u6ce8\u5165<\/strong><\/p>\n<p>\u901a\u8fc7\u591a\u91cd\u6ce8\u5165\u7b56\u7565 + \u52a8\u6001\u68c0\u6d4b\u7684\u65b9\u5f0f\u5b9e\u73b0\uff0c \u76f4\u63a5\u5f15\u5165\u4f1a\u89e6\u53d1 Content Security Policy \u963b\u6b62\u5185\u8054\u811a\u672c\u6267\u884c\u3002<\/p>\n<pre><code>\/\/ content.js\nasync\u00a0function\u00a0injectScript() {\n\u00a0\u00a0\/\/ \u7b56\u75651: \u5185\u8054\u811a\u672c\u6ce8\u5165\n\u00a0\u00a0try\u00a0{\n\u00a0 \u00a0\u00a0await\u00a0injectInlineScript();\n\u00a0 \u00a0\u00a0if\u00a0(await\u00a0checkScriptActivation())\u00a0return;\n\u00a0 }\u00a0catch\u00a0(e) {\n\u00a0 \u00a0\u00a0console.warn('\u5185\u8054\u6ce8\u5165\u5931\u8d25:', e);\n\u00a0 }\n\n\n\u00a0\u00a0\/\/ \u7b56\u75652: \u5916\u90e8\u811a\u672c\u6ce8\u5165\n\u00a0\u00a0try\u00a0{\n\u00a0 \u00a0\u00a0await\u00a0injectExternalScript();\n\u00a0 \u00a0\u00a0if\u00a0(await\u00a0checkScriptActivation())\u00a0return;\n\u00a0 }\u00a0catch\u00a0(e) {\n\u00a0 \u00a0\u00a0console.warn('\u5916\u90e8\u6ce8\u5165\u5931\u8d25:', e);\n\u00a0 }\n\n\n\u00a0\u00a0\/\/ \u7b56\u75653: \u6700\u7b80\u5355\u6ce8\u5165\u65b9\u5f0f\n\u00a0\u00a0await\u00a0attemptSimpleInjection();\n}\n<\/code><\/pre>\n<h2>\u56db\u3001\u6574\u4f53\u5b9e\u73b0\u67b6\u6784\u4e0e\u6d41\u7a0b<\/h2>\n<p><strong>\u9879\u76ee\u7ed3\u6784\u8bbe\u8ba1<\/strong><\/p>\n<pre><code>chrome-mock\/\n\u251c\u2500\u2500\u00a0build-script\/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# rollup \u8fdb\u884c\u6784\u5efa\n\u251c\u2500\u2500\u00a0static\/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u9759\u6001\u6587\u4ef6\u5f15\u5165\uff0c\u5982mockjs\n\u251c\u2500\u2500 debug\/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0# \u672c\u5730\u8c03\u8bd5\u76f8\u5173\u7684\u9875\u9762\n\u251c\u2500\u2500 manifest.json \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u63d2\u4ef6\u914d\u7f6e\n\u251c\u2500\u2500 background.js \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u6838\u5fc3\u903b\u8f91\u5904\u7406\n\u251c\u2500\u2500 content.js \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u811a\u672c\u6ce8\u5165\u548c\u6d88\u606f\u4e2d\u8f6c\n\u251c\u2500\u2500 injected.js \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0# \u8bf7\u6c42\u62e6\u622a\u5b9e\u73b0\n\u251c\u2500\u2500 options.html \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u7ba1\u7406\u754c\u9762\n\u251c\u2500\u2500 options.js \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u7ba1\u7406\u754c\u9762\u903b\u8f91\n\u251c\u2500\u2500 options.css \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0# \u7ba1\u7406\u754c\u9762\u6837\u5f0f\n\u251c\u2500\u2500 popup.html \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u5f39\u7a97\u754c\u9762\n\u251c\u2500\u2500 popup.js \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u5f39\u7a97\u903b\u8f91\n\u251c\u2500\u2500 popup.css \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0# \u5f39\u7a97\u6837\u5f0f\n\u2514\u2500\u2500 icons\/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0# \u56fe\u6807\u8d44\u6e90\n<\/code><\/pre>\n<p><strong>\u76f8\u5173\u529f\u80fd\u4ecb\u7ecd<\/strong><\/p>\n<p><strong>\u521b\u5efa Mock \u89c4\u5219<\/strong><\/p>\n<p>\u521b\u5efa Mock \u89c4\u5219\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u5f0f\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u662f\u5feb\u901f\u8054\u8c03\u7684\u573a\u666f\uff0c\u53ef\u4ee5\u7528\u5f97\u7269API\u7ba1\u7406\u5e73\u53f0\u5bfc\u5165\u7684\u65b9\u5f0f\u3002<\/li>\n<li>\u5728\u6392\u67e5\u67d0\u4e2a\u73af\u5883\u95ee\u9898\uff0c\u9700\u8981\u6839\u636e\u670d\u52a1\u7aef\u63a5\u53e3\u8fd4\u56de\u6570\u636e\u590d\u73b0\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728\u7ba1\u7406\u89c4\u5219\u9875\u9762\u624b\u52a8\u65b0\u5efa\u3002<\/li>\n<\/ul>\n<p><strong>\u65b9\u6cd5\u4e00\uff1a\u5feb\u6377\u64cd\u4f5c\u5f39\u7a97\u914d\u7f6e<\/strong><\/p>\n<ul>\n<li><strong>\u6253\u5f00 Mock \u7ba1\u7406\u9875\u9762<\/strong><\/li>\n<li>\n<ul>\n<li>\u70b9\u51fb\u6d4f\u89c8\u5668\u5de5\u5177\u680f\u4e2d\u7684 Mock Frog \u56fe\u6807\uff1b<\/li>\n<li>\u9009\u62e9&#8221;\u7ba1\u7406\u89c4\u5219&#8221;\u6216\u76f4\u63a5\u8bbf\u95ee\u6269\u5c55\u9009\u9879\u9875\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&lt;!&#8212;-&gt;<\/p>\n<ul>\n<li><strong>\u6dfb\u52a0\u65b0\u89c4\u5219<\/strong><\/li>\n<\/ul>\n<p><img decoding=\"async\" width=\"607\" height=\"612\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmyJg\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p><strong>\u65b9\u5f0f\u4e00<\/strong>\uff1a\u590d\u5236\u7c98\u8d34\u5f97\u7269API\u7ba1\u7406\u5e73\u53f0\u5730\u5740\uff0c\u70b9\u51fb\u5bfc\u5165\uff0c\u81ea\u52a8\u751f\u6210\u3002\u8fd9\u4e2a\u5f39\u7a97\u6bd4\u8f83\u5c0f\u9002\u5408\u81ea\u52a8\u5bfc\u5165\u7684\u573a\u666f\uff0c\u4e5f\u53ef\u4ee5\u70b9\u51fb\u4e0a\u9762 popup \u7684\u7ba1\u7406\u89c4\u5219\u518d\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n<p><em>\u5982\uff1ahttps\/:\/apiManage.test.com\/project\/interface?id=3xxxx\/&amp;projectId=5xxxx<\/em><\/p>\n<p><img decoding=\"async\" width=\"514\" height=\"559\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmyJi\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u672c\u5730\u8c03\u7528\u53ef\u80fd\u4f1a\u6709\u4ee3\u7406\u589e\u52a0\u4e86\u524d\u7f00\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5728\u8def\u5f84\u524d\u6dfb\u52a0\u901a\u914d\u7b26\u00a0*<\/p>\n<p><strong>\u65b9\u5f0f\u4e8c<\/strong>\uff1a\u590d\u5236\u63a5\u53e3\u5730\u5740\u5230\u5339\u914d URL \u8f93\u5165\u6846\u4e2d\u81ea\u884c\u914d\u7f6e\u6570\u636e\uff0c\u8fd9\u4e00\u6b65\u5efa\u8bae\u5230\u7ba1\u7406\u89c4\u5219\u4e2d\u624d\u65bd\u5c55\u7684\u5f00\u3002<\/p>\n<p>\u652f\u6301\u6839\u636e\u63a5\u53e3\u5e73\u53f0\u7684 JSON Schema \u751f\u6210\u5bf9\u5e94\u7c7b\u578b\u7684 Mock \u6570\u636e\u3002<\/p>\n<p>Mock \u6548\u679c\u6f14\u793a\uff1a<\/p>\n<p>\uff0c\u65f6\u957f00:14\uff08\u89c6\u9891\u53ef\u524d\u5f80\u5f97\u7269\u6280\u672f\u516c\u4f17\u53f7\u8be5\u6587\u7ae0\u67e5\u770b\uff09<\/p>\n<p><strong>\u65b9\u6cd5\u4e8c\uff1a\u7ba1\u7406\u89c4\u5219\u9875\u914d\u7f6e<\/strong><\/p>\n<p>\u7531\u4e8e popup \u754c\u9762\u5927\u5c0f\u6709\u9650\uff0c\u70b9\u51fb\u5176\u4ed6\u533a\u57df\u5f39\u7a97\u4e5f\u4f1a\u5173\u95ed\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u6bd4\u8f83\u8be6\u7ec6\u7684\u7ba1\u7406\u9875\u53ef\u4ee5\u4fee\u6539\u6dfb\u52a0\u89c4\u5219\u3002<\/p>\n<p>\u89c4\u5219\u5217\u8868\uff1a<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"252\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmyJl\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u65b0\u5efa Mock \u89c4\u5219\uff1a<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"580\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmyJp\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p><strong>\u9875\u9762\u767d\u540d\u5355\u7ba1\u7406<\/strong><\/p>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u9488\u5bf9\u6240\u6709\u9875\u9762\u90fd\u8fdb\u884c\u62e6\u622a\u53ef\u80fd\u4f1a\u5bfc\u81f4\u9875\u9762\u5361\u987f\uff0c\u5f71\u54cd\u6574\u4f53\u6027\u80fd\uff0c\u4e8e\u662f\u589e\u52a0\u4e86\u767d\u540d\u5355\u63a7\u5236\uff0c\u63a7\u5236 Mock \u529f\u80fd\u5728\u54ea\u4e9b\u573a\u666f\u4e0b\u624d\u751f\u6548\u3002\u540c\u65f6\u4e5f\u63d0\u4f9b\u4e86\u5168\u5c40\u751f\u6548\u6a21\u5f0f\uff0c\u65b9\u4fbf\u5feb\u901f\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u4f7f\u7528\u65b9\u6cd5\uff1a<\/strong><\/p>\n<ul>\n<li><strong>\u5f00\u542f\u767d\u540d\u5355\u529f\u80fd<\/strong><\/li>\n<li>\n<ul>\n<li>\u8fdb\u5165\u6269\u5c55\u8bbe\u7f6e\u9875\u9762<\/li>\n<li>\u627e\u5230&#8221;\u9875\u9762\u767d\u540d\u5355&#8221;\u914d\u7f6e<\/li>\n<li>\u542f\u7528&#8221;\u4f7f\u7528\u9875\u9762\u767d\u540d\u5355&#8221;<br \/>*<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u6dfb\u52a0\u767d\u540d\u5355\u57df\u540d<\/strong><\/li>\n<\/ul>\n<p>&lt;!&#8212;-&gt;<\/p>\n<pre><code>\u652f\u6301\u683c\u5f0f\uff1a\n- http:\/\/localhost:3000 \u00a0 \u00a0 \u00a0 \u00a0# \u5b8c\u6574URL\n- *.example.com \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0# \u901a\u914d\u7b26\u57df\u540d\n- dev.company.com \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0# \u5177\u4f53\u57df\u540d\n- http:\/\/dev.company.com \u00a0 \u00a0 \u00a0# \u5e26\u534f\u8bae\u7684\u57df\u540d\n<\/code><\/pre>\n<p><img decoding=\"async\" width=\"723\" height=\"375\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmyJq\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p><strong>\u8bf7\u6c42\u65e5\u5fd7<\/strong><\/p>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u8bb0\u5f55\u6240\u6709 Mock \u8bf7\u6c42\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u4fbf\u4e8e\u8c03\u8bd5\u3002<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"347\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmyJr\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p><strong>\u6574\u4f53\u6d41\u7a0b<\/strong><\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"749\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmyJs\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"583\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdmyJt\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<h2>\u4e94\u3001\u603b\u7ed3\u4e0e\u6536\u83b7<\/h2>\n<p>\u672c\u6b21\u63d2\u4ef6\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u63a2\u7d22\u4e86\u6d4f\u89c8\u5668\u6269\u5c55\u63d2\u4ef6\u7684\u80fd\u529b\uff0c\u5b66\u4e60\u4e86 Manifest V3 \u7684\u65b0\u77e5\u8bc6\uff0c\u638c\u63e1\u4e86\u6d4f\u89c8\u5668\u63d2\u4ef6\u5f00\u53d1\u76f8\u5173\u6280\u672f\u70b9\u3002\u968f\u4e4b\u800c\u6765\u5e26\u6765\u7684\u601d\u8003\u4fbf\u662f\u5728 AI \u7684\u6d6a\u6f6e\u4e0b\uff0c\u6d4f\u89c8\u5668\u63d2\u4ef6\u662f\u5426\u80fd\u6709\u66f4\u591a\u7684\u53ef\u80fd\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u672c\u6b21\u5f88\u591a\u529f\u80fd\u70b9\u7684\u5b9e\u73b0\u4e5f\u4f9d\u8d56\u4e86 Cursor\uff0c\u63a2\u7d22\u6d4f\u89c8\u5668\u63d2\u4ef6\u7684\u540c\u65f6\u4e5f\u6df1\u5165\u7684\u5b66\u4e60\u4e86Cursor\u7684\u5e94\u7528\uff0c\u611f\u53d7\u5230\u4e86Cursor\u4ece 0 \u5230 1 \u642d\u5efa\u8fc7\u7a0b\u4e2d\u7684\u901f\u5ea6\u548c\u6548\u7387\u3002\u4f46\u662f\u5728\u540e\u7eed\u9700\u8981\u5bf9\u529f\u80fd\u70b9\u8fdb\u884c\u6539\u9020\u65f6\uff0c\u4f7f\u7528\u6548\u7387\u5e76\u4e0d\u662f\u9ad8\uff0c\u5982\u4f55\u5efa\u7acb\u89c4\u5219\u548c\u7ec4\u7ec7\u8bdd\u672f\uff0c\u8ba9 AI \u66f4\u52a0\u89c4\u8303\u3001\u9ad8\u6548\u5730\u8f85\u52a9\u5f00\u53d1\u662f\u4e00\u4e2a\u503c\u5f97\u6df1\u601d\u7684\u95ee\u9898\uff0c\u5f53\u7136\u901a\u8fc7 rules \u662f\u80fd\u591f\u89e3\u51b3\u5927\u90e8\u5206\u95ee\u9898\u3002<\/p>\n<h2>\u516d\u3001\u672a\u6765\u5c55\u671b<\/h2>\n<p><strong>\u529f\u80fd\u5347\u7ea7<\/strong>\uff1a\u5728\u590d\u6742\u4e1a\u52a1\u573a\u666f\u4e2d\uff0c\u5f80\u5f80\u9700\u8981Mock\u7684\u63a5\u53e3\u90fd\u6bd4\u8f83\u591a\u3002\u5982\u679c\u80fd\u76d1\u542c\u9875\u9762\u6240\u6709\u8bf7\u6c42\uff0c\u7136\u540e\u63d0\u4f9b\u901a\u8fc7\u9009\u4e2d\u67d0\u4e2a\u5386\u53f2\u8bf7\u6c42\u5373\u53efMock\u63a5\u53e3\u7684\u65b9\u5f0f\uff0c\u5c31\u80fd\u5feb\u901f\u5b9e\u73b0\u63a5\u53e3\u7684Mock\u3002<\/p>\n<p><strong>\u80fd\u529b\u62d3\u5c55<\/strong>\uff1a\u63a2\u7d22\u5728\u6d4f\u89c8\u5668\u63d2\u4ef6\u4e0a\u7ed3\u5408 AI \u80fd\u529b\u7684\u5e94\u7528\uff0c\u57fa\u4e8e\u89c4\u5219\u8ddf\u7528\u6237\u7684\u8981\u6c42\u66f4\u5feb\u901f\u7684\u751f\u6210 Mock \u6570\u636e\u3002<\/p>\n<p><strong>\u5f80\u671f\u56de\u987e<\/strong><\/p>\n<p>1.\u00a0\u7834\u89e3gh-ost\u53d8\u66f4\u5bfc\u81f4MySQL\u8868\u81a8\u80c0\u4e4b\u8c1c\uff5c\u5f97\u7269\u6280\u672f<\/p>\n<p>2.\u00a0MySQL\u5355\u8868\u4e3a\u4f55\u522b\u8d852000\u4e07\u884c\uff1f\u63ed\u79d8B+\u6811\u4e0e16KB\u9875\u7684\u751f\u6b7b\u535a\u5f08\uff5c\u5f97\u7269\u6280\u672f<\/p>\n<p>3.\u00a00\u57fa\u7840\u5e26\u4f60\u7cbe\u901aJava\u5bf9\u8c61\u5e8f\u5217\u5316&#8211;\u4ee5Hessian\u4e3a\u4f8b\uff5c\u5f97\u7269\u6280\u672f<\/p>\n<p>4.\u00a0\u524d\u7aef\u65e5\u5fd7\u56de\u635e\u7cfb\u7edf\u7684\u6027\u80fd\u4f18\u5316\u5b9e\u8df5\uff5c\u5f97\u7269\u6280\u672f<\/p>\n<p>5.\u00a0\u5f97\u7269\u7075\u7280\u641c\u7d22\u63a8\u8350\u8bcd\u5206\u53d1\u5e73\u53f0\u6f14\u8fdb3.0<\/p>\n<p>\u6587 \/\u6bb5\u58f9<\/p>\n<p>\u5173\u6ce8\u5f97\u7269\u6280\u672f\uff0c\u6bcf\u5468\u66f4\u65b0\u6280\u672f\u5e72\u8d27<\/p>\n<p>\u8981\u662f\u89c9\u5f97\u6587\u7ae0\u5bf9\u4f60\u6709\u5e2e\u52a9\u7684\u8bdd\uff0c\u6b22\u8fce\u8bc4\u8bba\u8f6c\u53d1\u70b9\u8d5e\uff5e<\/p>\n<p>\u672a\u7ecf\u5f97\u7269\u6280\u672f\u8bb8\u53ef\u4e25\u7981\u8f6c\u8f7d\uff0c\u5426\u5219\u4f9d\u6cd5\u8ffd\u7a76\u6cd5\u5f8b\u8d23\u4efb\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000047283391\">https:\/\/segmentfault.com\/a\/1190000047283391<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u524d \u8a00 \u5728\u65e5\u5e38\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u5076\u5c14\u4f1a\u9047\u5230\u540e\u7aef\u63a5\u53e3\u672a\u5b8c\u6210\u6216\u8005\u67d0\u4e2a\u73af\u5883\u51fa\u73b0\u95ee\u9898\u9700\u8981\u6839\u636e\u63a5\u53e3\u8fd4\u56de\u6765\u590d\u73b0\u7b49\u7b49\u573a\u666f\u3002\u521a\u597d [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10021010","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10021010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10021010"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10021010\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10021010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10021010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10021010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}