{"id":1313,"date":"2026-09-14T15:28:53","date_gmt":"2026-09-14T15:28:53","guid":{"rendered":"https:\/\/boochlin.com\/?p=1313"},"modified":"2026-09-19T16:21:27","modified_gmt":"2026-09-19T16:21:27","slug":"funny-vote-app-%e4%ba%94%e7%be%8e%e5%85%83%e4%bc%ba%e6%9c%8d%e5%99%a8%e9%99%a3%e4%ba%a1%e5%be%8c%ef%bc%9a%e7%94%a8-firebase-%e8%88%87%e8%80%81%e5%88%86%e6%94%af%e7%ba%8c%e5%91%bd%e7%9a%84","status":"publish","type":"post","link":"https:\/\/boochlin.com\/?p=1313","title":{"rendered":"Funny vote APP \u2013 \u4e94\u7f8e\u5143\u4f3a\u670d\u5668\u9663\u4ea1\u5f8c\uff1a\u7528 Firebase \u8207\u8001\u5206\u652f\u7e8c\u547d\u7684\u96f2\u7aef\u63db\u5fc3\u96dc\u8a18\uff08\u4e03\uff09"},"content":{"rendered":"<div class=\"wp-block-group\" style=\"border-left:4px solid #C14420;background:#f8f9fa;padding:14px 18px;margin-bottom:28px;border-radius:0 6px 6px 0\">\n<p style=\"margin:0;font-size:0.95em;color:#444\">\n    \u672c\u6587\u70ba<strong>\u300aFunny Vote \u5341\u5e74\u6f14\u9032\u7cfb\u5217\u300b<\/strong>\u7b2c 7 \u7bc7\uff08\u5168\u7cfb\u5217\u5171 8 \u7bc7\uff09\uff5c<a href=\"https:\/\/boochlin.com\/?page_id=1319\" style=\"font-weight:bold;color:#C14420;text-decoration:underline\">\u67e5\u770b\u5168\u7cfb\u5217\u67b6\u69cb\u5c0e\u89bd<\/a>\n  <\/p>\n<\/div>\n<p><img decoding=\"async\" src=\"..\/..\/assets\/images\/post1313_firebase_banner.png\" alt=\"Funny Vote Firebase \u96f2\u7aef\u63db\u5fc3\u65d7\u8266\u5c01\u9762\"><\/p>\n<p>\u73fe\u5be6\u7e3d\u662f\u6703\u5728\u5de5\u7a0b\u5e2b\u6700\u5f97\u610f\u7684\u6642\u5019\uff0c\u72e0\u72e0\u8cde\u4f60\u4e00\u8a18\u8033\u5149\u3002<\/p>\n<p>\u4e0a\u4e00\u7bc7\u6211\u5011\u804a\u5230\u4e86\u5f37\u8feb\u75c7\u767c\u4f5c\uff0c\u5728 <code>modern-android<\/code> \u5206\u652f\u88e1\u628a\u5341\u5e74\u524d\u6240\u6709\u7684\u756b\u9762\u3001\u5c0e\u89bd\u6559\u5b78\u3001\u95dc\u65bc\u5b50\u9801\u9762 100% \u5fa9\u523b\u9032\u4e86 Material 3\u3002<\/p>\n<p>\u4f46\u6b63\u5982\u4e0a\u4e00\u7bc7\u7d50\u5c3e\u8aaa\u7684\uff0c\u7576\u6211\u958b\u958b\u5fc3\u5fc3\u5730\u628a App \u6253\u5305\u5b89\u88dd\u5230\u624b\u6a5f\u4e0a\uff0c\u6e96\u5099\u5728\u670b\u53cb\u9762\u524d\u70ab\u8000\u4e00\u756a\u6642\uff0c\u7576\u5834\u88ab\u51b7\u9177\u7684\u73fe\u5be6\u6f51\u4e86\u4e00\u76c6\u51b0\u6c34\uff1a<br \/>\n<strong>\u300c\u5e79\uff0c\u5f8c\u7aef\u4f3a\u670d\u5668\u5341\u5e74\u524d\u65e9\u5c31\u6b20\u8cbb\u95dc\u6a5f\u4e86\u554a\uff01\u300d<\/strong><\/p>\n<p>\u7576\u5e74\u70ba\u4e86\u8b93 Funny Vote \u4e0a\u7dda\uff0c\u6211\u6bcf\u500b\u6708\u81ea\u638f\u8170\u5305\u82b1 5 \u7f8e\u5143\u79df\u4e86\u4e00\u53f0\u4fbf\u5b9c\u7684\u6d77\u5916 VPS\uff0c\u4e0a\u9762\u8dd1\u8457 MySQL\u3001PHP \u8ddf\u967d\u6625\u7684 REST API\u3002\u5f8c\u4f86 App \u4e0b\u67b6\u3001\u751f\u6d3b\u8b8a\u5fd9\uff0c\u4fe1\u7528\u5361\u904e\u671f\u6c92\u88dc\uff0c\u4e3b\u6a5f\u5546\u65e9\u5c31\u628a\u865b\u64ec\u6a5f\u7d66\u683c\u5f0f\u5316\u56de\u6536\u4e86\uff0c\u9023\u4e00\u584a\u786c\u789f\u78c1\u5340\u90fd\u6c92\u7559\u4e0b\u3002<\/p>\n<p>\u8eab\u70ba\u4e00\u500b\u4fe1\u5949\u300c\u6020\u60f0\u662f\u958b\u767c\u7684\u6e90\u982d\u3001\u80fd\u767d\u5ad6\u96f2\u7aef\u514d\u8cbb\u984d\u5ea6\u5c31\u7d55\u4e0d\u638f\u4fe1\u7528\u5361\u300d\u7684\u8cc7\u6df1\u5de5\u7a0b\u5e2b\uff0c\u91cd\u65b0\u79df\u4e00\u53f0 Linux \u4f3a\u670d\u5668\u3001\u5f9e\u982d\u914d\u7f6e Nginx\u3001\u8a2d\u5b9a SSL \u6191\u8b49\u518d\u5beb\u4e00\u5957\u5f8c\u7aef CRUD\uff0c\u5149\u7528\u60f3\u7684\u5c31\u8b93\u4eba\u982d\u76ae\u767c\u9ebb\u3002<\/p>\n<p>\u4f46\u4e0d\u80fd\u9023\u7db2\u3001\u4e0d\u80fd\u8de8\u88dd\u7f6e\u5373\u6642\u6295\u7968\u7684 App\uff0c\u5c31\u53ea\u662f\u4e00\u5177\u6c92\u6709\u9748\u9b42\u7684\u5851\u81a0\u4eba\u5076\u3002<\/p>\n<p>\u65bc\u662f\uff0c\u6211\u958b\u4e86 <code>feature\/firebase-backend<\/code> \u5206\u652f\uff0c\u6c7a\u5b9a\u5c55\u958b\u4e00\u5834\u5fb9\u5e95\u63a8\u5012\u91cd\u4f86\u7684**\u300cServerless \u96f2\u7aef\u63db\u5fc3\u5927\u624b\u8853\u300d**\uff1a\u4e0d\u67b6\u4efb\u4f55\u4e00\u53f0\u5be6\u9ad4\u4f3a\u670d\u5668\uff0c\u5229\u7528 Google Firebase \u7684\u751f\u614b\u5708\uff0c\u8b93\u5341\u5e74\u524d\u7684\u8001\u5c08\u6848\u5728\u73fe\u4ee3\u96f2\u7aef\u67b6\u69cb\u4e0a\u6eff\u8840\u5fa9\u6d3b\uff01<\/p>\n<p>\u5b8c\u6574\u5206\u652f\u539f\u59cb\u78bc\u50b3\u9001\u9580\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/boochlin06\/FunnyVote\/tree\/feature\/firebase-backend\">Funny Vote feature\/firebase-backend \u96f2\u539f\u751f\u5206\u652f<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/boochlin06\/funnyvote-backend\">\u96f2\u7aef Firestore \u898f\u5247\u8207\u7a2e\u5b50\u8173\u672c\u7368\u7acb\u5009\u5eab<\/a><\/li>\n<\/ul>\n<hr>\n<h2>1. \u6bba\u6b7b\u81ea\u5df1\u7684\u67b6\u69cb\uff1a\u70ba\u4ec0\u9ebc\u6211\u5927\u81bd\u780d\u6389\u4e86 800 \u884c Room \u4ee3\u78bc\uff1f<\/h2>\n<p>\u5728\u6c7a\u5b9a\u5168\u9762\u5c0e\u5165 Firebase Cloud Firestore \u4e4b\u5f8c\uff0c\u64fa\u5728\u773c\u524d\u7b2c\u4e00\u500b\u91cd\u5927\u7684\u67b6\u69cb\u6289\u64c7\u662f\uff1a<strong>\u8981\u4e0d\u8981\u4fdd\u7559\u4e0a\u4e00\u7bc7\u8f9b\u82e6\u523b\u5b8c\u7684 Room \u8cc7\u6599\u5eab\u505a\u672c\u5730\u5feb\u53d6\uff1f<\/strong><\/p>\n<p>\u5f88\u591a\u67b6\u69cb\u72c2\u71b1\u8005\u6700\u559c\u6b61\u756b\u9019\u7a2e\u300c\u770b\u8d77\u4f86\u5f88\u5065\u5168\u300d\u7684\u67b6\u69cb\u5716\uff1a<br \/>\n<code>Firestore (\u9060\u7aef) \u2794 Network DTO \u2794 Repository \u2794 Room Entity \u2794 Room DAO \u2794 Domain Model \u2794 UiState<\/code>\u3002<\/p>\n<p>\u5728\u5de5\u4f4d\u4e0a\u76ef\u8457\u9019\u689d\u843d\u843d\u9577\u7684\u4f9d\u8cf4\u93c8\u770b\u5341\u5206\u9418\uff0c\u6211\u76f4\u63a5\u7f75\u4e86\u53e5\u9ad2\u8a71\u3002<\/p>\n<p>\u5927\u5bb6\u4ed4\u7d30\u60f3\u4e00\u60f3\uff1a<br \/>\nFirestore \u5b98\u65b9\u7684 Android SDK \u672c\u8eab\u5c31\u81ea\u5e36\u6975\u5176\u6050\u6016\u7684<strong>\u539f\u751f\u96e2\u7dda\u6301\u4e45\u5316\u5f15\u64ce\uff08<code>persistentCacheSettings<\/code>\uff09<\/strong>\uff01\u7576\u4f60\u5728\u88dd\u7f6e\u65b7\u7db2\u6642\uff0cFirestore SDK \u6703\u81ea\u52d5\u628a\u4f60\u7684\u67e5\u8a62\u8207\u5beb\u5165\u5feb\u53d6\u5728\u672c\u5730 SQLite \u4e2d\uff1b\u4e00\u65e6\u7db2\u8def\u6062\u5fa9\uff0cSDK \u6703\u81ea\u52d5\u5728\u80cc\u666f\u5b8c\u6210 Transaction \u540c\u6b65\u8207\u885d\u7a81\u6d88\u89e3\u3002<\/p>\n<p>\u5982\u679c\u4f60\u5728\u5916\u9762\u786c\u5957\u4e00\u5c64 Room\uff1a<\/p>\n<ol>\n<li>\u4f60\u5f97\u70ba\u5e7e\u5341\u500b\u8868\u591a\u5beb 800 \u591a\u884c DAO\u3001Entity \u4ee5\u53ca\u96d9\u5411\u8f49\u63db\u7684 Mapper \u6a23\u677f\u4ee3\u78bc\uff1b<\/li>\n<li>\u4f60\u5f97\u89aa\u624b\u5beb\u4e00\u5957\u6a5f\u5236\u53bb\u76e3\u807d Firestore Snapshot\u3001\u624b\u52d5\u628a\u8cc7\u6599\u5beb\u5165 Room\uff0c\u518d\u5f9e Room \u8b80\u51fa\u4f86\u66b4\u9732\u7d66 UI\uff1b<\/li>\n<li>\u6700\u81f4\u547d\u7684\u662f\uff0c<strong>\u4f60\u6703\u89aa\u624b\u5275\u9020\u51fa\u5169\u500b\u300c\u672c\u5730\u8cc7\u6599\u5eab\u300d<\/strong>\uff0c\u4e00\u65e6\u7db2\u8def\u6296\u52d5\u5f15\u767c\u5feb\u53d6\u4e0d\u4e00\u81f4\uff0c\u4f60\u6839\u672c\u4e0d\u77e5\u9053\u756b\u9762\u4e0a\u7684\u8cc7\u6599\u5230\u5e95\u662f\u4ee5 Room \u70ba\u6e96\u9084\u662f\u4ee5 Firestore \u672c\u5730\u5feb\u53d6\u70ba\u6e96\uff01<\/li>\n<\/ol>\n<p>\u9019\u7a2e\u812b\u8932\u5b50\u653e\u5c41\u7684\u904e\u5ea6\u8a2d\u8a08\uff0c\u5b8c\u5168\u9055\u80cc\u4e86\u8edf\u9ad4\u5de5\u7a0b\u7684\u5967\u574e\u5243\u5200\u539f\u5247\u3002<\/p>\n<p>\u65bc\u662f\uff0c\u6211\u76f4\u63a5\u624b\u8d77\u5200\u843d\uff0c\u628a <code>Room<\/code> \u76f8\u95dc\u7684\u6a21\u7d44\u5168\u90e8\u62d4\u9664\uff0c\u76f4\u63a5\u4ee5 <strong>Firestore \u7684\u672c\u5730\u6301\u4e45\u5316\u4e32\u6d41\u4f5c\u70ba\u55ae\u4e00\u771f\u7406\u4f86\u6e90\uff08SSOT\uff09<\/strong>\uff1a<\/p>\n<pre><code class=\"language-kotlin\">\/\/ 2026 \u5e74\u5728 FunnyVoteApplication.kt \u88e1\u7684\u771f\u5be6\u914d\u7f6e\uff1a\u89e3\u9396\u96e2\u7dda\u6301\u4e45\u5316\nval firestoreSettings = firestoreSettings {\n    setLocalCacheSettings(persistentCacheSettings {\n        \/\/ \u8a2d\u5b9a 100MB \u672c\u5730\u5feb\u53d6\u4e0a\u9650\uff0c\u652f\u63f4\u96e2\u7dda\u79d2\u958b\u8207\u80cc\u666f\u7121\u611f\u540c\u6b65\n        setSizeBytes(100L * 1024 * 1024)\n    })\n}\nFirebase.firestore.firestoreSettings = firestoreSettings\n<\/code><\/pre>\n<p>\u4ee3\u78bc\u91cf\u77ac\u9593\u780d\u6389 40%\uff0c\u67b6\u69cb\u4e7e\u6de8\u5230\u50cf\u5439\u904e\u79cb\u98a8\u7684\u9ad8\u539f\u3002<\/p>\n<hr>\n<h2>2. \u96f2\u7aef\u6473\u9580\u5b78\uff1a\u53cd\u6b63\u898f\u5316\u5feb\u53d6\uff0c\u8b80\u53d6\u6210\u672c\u66b4\u964d 90%<\/h2>\n<p>\u641e\u5b9a\u67b6\u69cb\u4e4b\u5f8c\uff0c\u7b2c\u4e8c\u500b\u73fe\u5be6\u8003\u9a57\u7acb\u523b\u6bba\u5230\u773c\u524d\uff1a<strong>\u96f2\u7aef\u8a08\u8cbb\u6a21\u578b<\/strong>\u3002<\/p>\n<p>Firestore \u7684\u8a08\u50f9\u908f\u8f2f\u975e\u5e38\u55ae\u7d14\uff0c\u751a\u81f3\u53ef\u4ee5\u8aaa\u662f\u6b98\u9177\uff1a\u5b83\u662f\u6309\u7167 <strong>\u300cDocument \u8b80\u53d6\u6b21\u6578\u300d<\/strong> \u4f86\u7b97\u9322\u7684\uff08\u96d6\u7136\u514d\u8cbb\u984d\u5ea6\u6bcf\u5929\u6709 50,000 \u6b21\u8b80\u53d6\uff0c\u4f46\u8eab\u70ba\u767d\u5ad6\u9ee8\uff0c\u4efb\u4f55\u6d6a\u8cbb\u90fd\u662f\u53ef\u6065\u7684\uff09\u3002<\/p>\n<p>\u5728\u5341\u5e74\u524d\u7684\u8001\u95dc\u806f\u5f0f\u8cc7\u6599\u5eab\u601d\u7dad\u88e1\uff0c\u6211\u5011\u5f88\u7fd2\u6163\u628a\u8cc7\u6599\u6b63\u898f\u5316\uff1a<\/p>\n<ul>\n<li>\u4e00\u500b <code>polls<\/code> \u96c6\u5408\uff08\u5132\u5b58\u6295\u7968\u6a19\u984c\u3001\u4f5c\u8005\u3001\u6642\u9593\uff09\uff1b<\/li>\n<li>\u5e95\u4e0b\u639b\u4e00\u500b <code>options<\/code> \u5b50\u96c6\u5408\uff08\u5132\u5b58\u6295\u7968\u9078\u9805\u8207\u500b\u5225\u5f97\u7968\u6578\uff09\u3002<\/li>\n<\/ul>\n<p>\u5047\u8a2d\u9996\u9801\u8981\u5c55\u793a 20 \u7b46\u71b1\u9580\u6295\u7968\uff0c\u800c\u6bcf\u7b46\u6295\u7968\u5e73\u5747\u6709 4 \u500b\u9078\u9805\u3002<br \/>\n\u5982\u679c\u6309\u7167\u50b3\u7d71\u4f5c\u6cd5\uff1a<\/p>\n<ol>\n<li>\u67e5\u8a62 20 \u7b46 <code>polls<\/code> \u2794 \u6d88\u8017 20 \u6b21\u8b80\u53d6\uff1b<\/li>\n<li>\u70ba\u4e86\u5728\u5361\u7247\u4e0a\u986f\u793a\u524d\u5169\u5927\u9818\u5148\u9078\u9805\uff0c\u5f97\u5c0d 20 \u500b\u6295\u7968\u5206\u5225\u53bb\u67e5\u5b50\u96c6\u5408 \u2794 \u6d88\u8017 20 \u6b21\u8b80\u53d6\uff1b<\/li>\n<li><strong>\u4f7f\u7528\u8005\u5728\u9996\u9801\u96a8\u624b\u4e0b\u62c9\u5237\u65b0\u4e00\u6b21\uff0c80~100 \u6b21\u8b80\u53d6\u5c31\u9019\u6a23\u84b8\u767c\u4e86\uff01<\/strong><\/li>\n<\/ol>\n<p>\u53ea\u8981\u6709\u5e7e\u500b\u71b1\u5fc3\u4f7f\u7528\u8005\u5728\u9996\u9801\u591a\u5237\u5e7e\u4e0b\uff0c\u514d\u8cbb\u984d\u5ea6\u534a\u5929\u5c31\u88ab\u5e79\u7a7f\uff0c\u63a5\u8457\u5c31\u662f\u5e33\u55ae\u4f3a\u5019\u3002<\/p>\n<p>\u70ba\u4e86\u7701\u9322\uff0c\u6211\u5728 Firestore \u7684\u6587\u4ef6\u8a2d\u8a08\u4e0a\u796d\u51fa\u4e86\u4e00\u62db\u7d93\u5178\u7684 <strong>\u300c\u53cd\u6b63\u898f\u5316\u5feb\u53d6\uff08Denormalized Cache\uff09\u300d<\/strong>\uff1a<\/p>\n<pre><code class=\"language-kotlin\">\/\/ \u6295\u7968\u4e3b\u6587\u4ef6\uff1a\u76f4\u63a5\u5167\u5d4c\u5f97\u7968\u6700\u9ad8\u7684\u524d\u5169\u540d\u9078\u9805\u6458\u8981\ndata class FirestorePoll(\n    val pollId: String = &quot;&quot;,\n    val title: String = &quot;&quot;,\n    val authorName: String = &quot;&quot;,\n    val totalVotes: Int = 0,\n    \/\/ \u95dc\u9375\u6473\u9580\u8a2d\u8a08\uff1a\u9996\u9801\u6e32\u67d3\u6240\u9700\u8cc7\u6599\u4e00\u6b65\u5230\u4f4d\uff0c\u7d55\u4e0d\u767c\u8d77\u4e8c\u6b21\u67e5\u8a62\n    val topOptions: List&lt;OptionSummary&gt; = emptyList(),\n    val searchKeywords: List&lt;String&gt; = emptyList()\n)\n<\/code><\/pre>\n<p>\u7576\u6709\u4f7f\u7528\u8005\u6295\u7968\u6642\uff0c\u96f2\u7aef\u4e8b\u52d9\uff08Transaction\uff09\u5728\u589e\u52a0\u9078\u9805\u7968\u6578\u7684\u540c\u6642\uff0c\u9806\u624b\u8a08\u7b97\u4e26\u5237\u65b0\u4e3b\u6587\u4ef6\u88e1\u7684 <code>topOptions<\/code>\u3002<\/p>\n<p>\u9019\u6a23\u4e00\u4f86\uff0c\u9996\u9801\u52a0\u8f09 20 \u7b46\u5361\u7247\uff0c<strong>\u8b80\u53d6\u6b21\u6578\u56b4\u683c\u9396\u6b7b\u5728 20 \u6b21<\/strong>\uff0c\u8b80\u53d6\u6210\u672c\u76f4\u63a5\u66b4\u964d\u5c07\u8fd1 90%\uff01\u7701\u4e0b\u7684\u7b97\u529b\u8207\u984d\u5ea6\uff0c\u8db3\u5920\u8b93\u9019\u96bb App \u514d\u8cbb\u518d\u8dd1\u5341\u5e74\u3002<\/p>\n<hr>\n<h2>3. \u96f2\u7aef\u5168\u6587\u641c\u5c0b\u6551\u8d16\uff1a\u4e2d\u82f1\u6df7\u6392 Bi-gram \u5206\u8a5e\u6aa2\u7d22<\/h2>\n<p>\u53e6\u4e00\u500b\u5dee\u9ede\u8b93\u4eba\u6293\u72c2\u7684\u5751\u662f\uff1a<strong>\u641c\u5c0b\u529f\u80fd<\/strong>\u3002<\/p>\n<p>\u5341\u5e74\u524d\u5728 MySQL \u88e1\uff0c\u6211\u5011\u96a8\u624b\u5beb\u500b <code>WHERE title LIKE %\u95dc\u9375\u5b57%<\/code> \u5c31\u80fd\u641e\u5b9a\u6a21\u7cca\u641c\u5c0b\u3002\u4f46\u5728\u5206\u6563\u5f0f NoSQL \u8cc7\u6599\u5eab Firestore \u88e1\uff0c\u70ba\u4e86\u4fdd\u8b49\u767e\u5104\u7d1a\u5225\u8cc7\u6599\u7684\u67e5\u8a62\u901f\u5ea6\uff0c\u5b83<strong>\u5b8c\u5168\u4e0d\u652f\u63f4\u96d9\u5411\u6a21\u7cca\u67e5\u8a62<\/strong>\uff0c\u53ea\u652f\u63f4\u5b57\u9996\u5339\u914d\uff08Prefix match\uff09\u3002<\/p>\n<p>\u5982\u679c\u4f60\u60f3\u5728\u641c\u5c0b\u6846\u8f38\u5165\u300cAI\u300d\u6216\u8005\u300c\u6295\u7968\u300d\uff0c\u8981\u627e\u5230\u300c2026 \u6700\u65b0 AI \u6295\u7968\u300d\uff0c\u539f\u751f\u7684 Firestore \u76f4\u63a5\u8209\u767d\u65d7\u6295\u964d\u3002<\/p>\n<p>\u5b98\u65b9\u6587\u4ef6\u7684\u5efa\u8b70\u662f\u53bb\u6574\u5408\u7b2c\u4e09\u65b9\u4ed8\u8cbb\u670d\u52d9\uff08\u4f8b\u5982 Algolia \u6216 ElasticSearch\uff09\u2014\u2014\u958b\u4ec0\u9ebc\u73a9\u7b11\uff1f\u8eab\u70ba\u514d\u8cbb\u958b\u6e90\u5c08\u6848\uff0c\u600e\u9ebc\u53ef\u80fd\u70ba\u4e86\u641c\u5c0b\u53bb\u63a5\u4ed8\u8cbb SaaS\uff1f<\/p>\n<p>\u6700\u5f8c\u6211\u63a1\u53d6\u7684\u89e3\u6cd5\uff0c\u662f\u5728\u4f7f\u7528\u8005\u7aef\u5efa\u7acb\u6295\u7968\u6642\uff0c\u81ea\u52d5\u57f7\u884c <strong>\u300cBi-gram \u96d9\u5b57\u5143\u5207\u8a5e\u7d22\u5f15\u300d<\/strong>\u3002\u6ce8\u610f\uff0c\u9047\u5230\u82f1\u6578\u6df7\u6392\u6642\u4e0d\u80fd\u66b4\u529b\u5207\u96d9\u5b57\u5143\uff0c\u5fc5\u9808\u5148\u7528\u6b63\u5247\u62bd\u96e2\u55ae\u8a5e\uff0c\u4e2d\u6587\u90e8\u5206\u518d\u6ed1\u52d5\u7a97\u53e3\u5207\u5206\uff1a<\/p>\n<pre><code class=\"language-kotlin\">\/\/ \u5efa\u7acb\u6295\u7968\u6642\u81ea\u52d5\u5207\u5206 Bi-gram \u7d22\u5f15\u95dc\u9375\u5b57\uff08\u652f\u63f4\u4e2d\u82f1\u6df7\u6392\uff09\nfun generateSearchKeywords(title: String): List&lt;String&gt; {\n    val clean = title.lowercase().trim()\n    val set = mutableSetOf&lt;String&gt;()\n    \n    \/\/ 1. \u62bd\u53d6\u5b8c\u6574\u82f1\u6578\u55ae\u8a5e\n    val words = Regex(&quot;[a-z0-9]+&quot;).findAll(clean).map { it.value }\n    words.forEach { word -&gt;\n        set.add(word)\n        for (i in 1..word.length) set.add(word.substring(0, i)) \/\/ \u524d\u7db4\u7d22\u5f15\n    }\n    \n    \/\/ 2. \u4e2d\u6587\u5b57\u5143\u96d9\u5b57\u5143\u6ed1\u52d5\u7a97\u53e3\u5207\u5206\n    val cjk = clean.replace(Regex(&quot;[a-z0-9\\s]&quot;), &quot;&quot;)\n    for (i in 0 until cjk.length) {\n        set.add(cjk[i].toString())\n        if (i + 1 &lt; cjk.length) set.add(cjk.substring(i, i + 2))\n    }\n    return set.toList()\n}\n<\/code><\/pre>\n<p>\u628a\u5207\u5206\u51fa\u4f86\u7684\u95dc\u9375\u5b57\u9663\u5217\u5b58\u9032\u4e3b\u6587\u4ef6\u7684 <code>searchKeywords<\/code> \u6b04\u4f4d\u3002\u7576\u4f7f\u7528\u8005\u641c\u5c0b\u300cAI\u300d\u6642\uff0c\u67e5\u8a62\u8a9e\u6cd5\u76f4\u63a5\u547c\u53eb\uff1a<\/p>\n<pre><code class=\"language-kotlin\">\/\/ \u6beb\u79d2\u7d1a\u8907\u5408\u7d22\u5f15\u67e5\u8a62\uff0c\u514d\u82b1\u4e00\u6bdb\u9322\nfirestore.collection(&quot;polls&quot;)\n    .whereEqualTo(&quot;security&quot;, &quot;00&quot;)\n    .whereArrayContains(&quot;searchKeywords&quot;, query.lowercase())\n    .limit(20)\n<\/code><\/pre>\n<p>\u4e0d\u9700\u8981\u4f9d\u8cf4\u4efb\u4f55\u5916\u90e8\u4ed8\u8cbb\u670d\u52d9\uff0c\u96f6\u6210\u672c\u5be6\u73fe\u6beb\u79d2\u7d1a\u7684\u4e2d\u82f1\u6587\u6a21\u7cca\u641c\u5c0b\u3002<\/p>\n<hr>\n<h2>4. \u96f6\u4fe1\u4efb\u5bc6\u78bc\u9632\u79a6\uff1a\u62d2\u7d55\u628a\u5bc6\u78bc\u7576\u767d\u83dc\u50b3\u8f38<\/h2>\n<p>\u5728\u539f\u7248 Funny Vote \u4e2d\uff0c\u6709\u4e00\u7a2e\u300c\u52a0\u5bc6\u6295\u7968\u300d\u529f\u80fd\uff1a\u767c\u8d77\u4eba\u53ef\u4ee5\u8a2d\u5b9a\u5bc6\u78bc\uff0c\u53ea\u6709\u8f38\u5165\u6b63\u78ba\u5bc6\u78bc\u7684\u4eba\u624d\u80fd\u9032\u5165\u6295\u7968\u3002<\/p>\n<p>\u5341\u5e74\u524d\u7684\u50bb\u767d\u751c\u5beb\u6cd5\uff0c\u662f\u628a\u5bc6\u78bc\u660e\u6587\u8ddf\u8457 API \u4e00\u8d77\u56de\u50b3\u5230\u624b\u6a5f\u7aef\uff0c\u5728\u624b\u6a5f\u4e0a\u5beb <code>if (input == poll.password)<\/code> \u505a\u6bd4\u5c0d\u3002\u73fe\u5728\u56de\u982d\u770b\uff0c\u9019\u7c21\u76f4\u662f\u628a\u5167\u8932\u7a7f\u5728\u5916\u9762\u5230\u8655\u8dd1\u3002<\/p>\n<p>\u5728\u96f2\u539f\u751f\u67b6\u69cb\u88e1\uff0c\u6211\u5011\u5be6\u4f5c\u4e86<strong>\u96f6\u4fe1\u4efb\uff08Zero-Trust\uff09\u5b89\u5168\u9ad4\u7cfb<\/strong>\uff1a<\/p>\n<ol>\n<li>\u4e3b\u6587\u4ef6 <code>polls\/{pollId}<\/code> \u7d55\u4e0d\u5305\u542b\u4efb\u4f55\u5bc6\u78bc\u6b04\u4f4d\uff1b<\/li>\n<li>\u5bc6\u78bc\u5728\u767c\u8d77\u6642\uff0c\u7d93\u904e <code>SHA-256(pollId:password)<\/code> \u52a0\u9e7d\u96dc\u6e4a\uff0c\u5beb\u5165\u7368\u7acb\u7684\u5bc6\u9470\u96c6\u5408 <code>secure_polls<\/code>\uff1b<\/li>\n<li><code>firestore.rules<\/code> \u96f2\u7aef\u5b89\u5168\u898f\u5247\u56b4\u683c\u7981\u6b62\u4efb\u4f55\u4eba\u904d\u6b77\uff08<code>list<\/code>\uff09\u8a72\u96c6\u5408\uff0c\u53ea\u5141\u8a31\u7cbe\u78ba\u6587\u4ef6\u547d\u4e2d\uff08<code>get<\/code>\uff09\u3002<\/li>\n<\/ol>\n<p>\u4f7f\u7528\u8005\u5982\u679c\u8f38\u5165\u932f\u8aa4\u5bc6\u78bc\uff0c\u4ed6\u5728\u7db2\u8def\u5c64\u9023\u4e00\u689d\u8cc7\u6599\u90fd\u78b0\u4e0d\u5230\uff0c\u5fb9\u5e95\u675c\u7d55\u649e\u5eab\u8207\u9006\u5411\u7834\u89e3\u3002<\/p>\n<hr>\n<h2>5. \u96f2\u7aef\u5fa9\u7526\u8207\u4e0b\u4e00\u7ad9\uff1aAI \u63a5\u7ba1<\/h2>\n<p>\u9019\u5834\u96f2\u7aef\u63db\u5fc3\u624b\u8853\u6b77\u6642\u5169\u9031\uff0c\u7d50\u7b97\u6230\u679c\uff1a<\/p>\n<ul>\n<li><strong>\u67b6\u69cb\u5168\u9762 Serverless<\/strong>\uff1a\u96f6\u7dad\u8b77\u4f3a\u670d\u5668\u6210\u672c\uff0c\u96f6\u904b\u7dad\u8ca0\u64d4\uff1b<\/li>\n<li><strong>\u771f\u6a5f\u8de8\u88dd\u7f6e\u9a57\u8b49\u901a\u904e<\/strong>\uff1a\u62ff\u8457 Samsung S23 \u8207\u6e2c\u8a66\u6a5f\uff0c\u5728\u4e0d\u540c\u7db2\u8def\u4e0b\u9ede\u64ca\u6295\u7968\uff0c\u5f97\u7968\u7387\u9577\u689d\u5716\u5728\u5169\u96bb\u624b\u6a5f\u4e0a\u5373\u6642\u540c\u6b65\u589e\u9577\uff1b<\/li>\n<li><strong>\u96e2\u7dda\u8207\u6301\u4e45\u5316\u56fa\u82e5\u91d1\u6e6f<\/strong>\uff1a\u62d4\u6389 Wi-Fi \u4f9d\u7136\u80fd\u79d2\u958b App\u3001\u700f\u89bd\u5feb\u53d6\u4e26\u767c\u8d77\u96e2\u7dda\u6295\u7968\uff0c\u91cd\u9023\u5f8c\u81ea\u52d5\u843d\u5eab\u3002<\/li>\n<\/ul>\n<p>\u770b\u8457\u9019\u6b3e\u8a95\u751f\u65bc\u5341\u5e74\u524d\u7684 Side Project\uff0c\u5728\u7d93\u6b77\u4e86 Java \u2794 MVP \u2794 Kotlin \u2794 Compose \u2794 MVI \u2794 Firebase \u7684\u516d\u91cd\u86fb\u8b8a\u5f8c\uff0c\u7d42\u65bc\u4ee5\u6700\u5b8c\u6574\u7684\u59ff\u614b\u5e73\u7a69\u904b\u884c\u5728 2026 \u5e74\u7684 Android 16 \u771f\u6a5f\u4e0a\uff0c\u5fc3\u88e1\u771f\u7684\u6709\u4e00\u7a2e\u96e3\u4ee5\u8a00\u55bb\u7684\u611f\u6168\u3002<\/p>\n<p>\u4f46\u9019\u6bb5\u65c5\u7a0b\u9084\u6c92\u6709\u7d50\u675f\u3002<br \/>\n\u5728\u6700\u5f8c\u7684\u7d42\u5c40\u7bc7\u88e1\uff0c\u6211\u60f3\u8df3\u812b\u7d14\u67b6\u69cb\u7684\u6280\u8853\u7d30\u7bc0\uff0c\u804a\u804a\u4e00\u500b\u66f4\u885d\u64ca\u3001\u4e5f\u66f4\u5177\u6642\u4ee3\u610f\u7fa9\u7684\u8b70\u984c\uff1a<br \/>\n<strong>\u770b\u6211\u600e\u9ebc\u5728\u5de5\u4f4d\u4e0a\u8ddf Codex \u4e92\u6390\uff0c\u6293\u5305\u5b83\u90a3\u4e9b\u770b\u4f3c\u5b8c\u7f8e\u5be6\u5247\u81f4\u547d\u7684\u9006\u5929\u8cc7\u5b89\u5730\u96f7\u3002<\/strong><\/p>\n<p>\u6211\u5011\u4e0b\u4e00\u7bc7\uff0c\u7d42\u5c40\u898b\u3002<\/p>\n<p>\u4ee5\u4e0a\u662f\u672c\u6b21\u5c0f\u5f1f\u7684\u611f\u60f3\uff0c\u6211\u771f\u7684\u61f6\u5f97\u8cbc\u843d\u843d\u9577\u7684\u5168\u5c08\u6848 CODE\uff0c\u5404\u4f4d\u771f\u7684\u60f3\u770b\u5b8c\u6574 Firebase \u4e32\u63a5\u7d30\u7bc0\uff0c\u53bb GitHub \u7ffb <code>feature\/firebase-backend<\/code> \u5206\u652f\u5427\uff0c\u901a\u901a\u90fd\u653e\u5728\u90a3\uff0c\u4e0d\u6d6a\u8cbb\u7248\u9762\u3002<\/p>\n<p>\u611f\u8b1d\u89c0\u770b\uff0c\u6536\u5de5\u3002<\/p>\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n<div class=\"wp-block-group\" style=\"border:1px solid #e2e8f0;background:#ffffff;padding:18px 20px;margin-top:32px;margin-bottom:24px;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,0.05)\">\n<p style=\"margin:0 0 12px 0;font-size:0.9em;color:#888;font-weight:bold;text-transform:uppercase;letter-spacing:1px\">\u300aFunny Vote \u5341\u5e74\u6f14\u9032\u7cfb\u5217\u300b\u7ae0\u7bc0\u5c0e\u822a<\/p>\n<div style=\"display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:12px;font-size:0.95em\">\n    <a href=\"https:\/\/boochlin.com\/?p=1299\" style=\"color:#C14420;text-decoration:none;font-weight:500\">\u2190 \u4e0a\u4e00\u7bc7\uff1a\u9752\u6625\u642c\u9032 Material 3\uff08\u516d\uff09<\/a><br \/>\n    <a href=\"https:\/\/boochlin.com\/?page_id=1319\" style=\"color:#666;text-decoration:none;font-size:0.85em;background:#edf2f7;padding:4px 10px;border-radius:4px\">\u7cfb\u5217\u76ee\u9304<\/a><br \/>\n    <a href=\"https:\/\/boochlin.com\/?p=1315\" style=\"color:#C14420;text-decoration:none;font-weight:500\">\u4e0b\u4e00\u7bc7\uff1aCodex \u63a5\u7ba1\u5de5\u4f4d\u7d42\u5c40\u7bc7\uff08\u516b\uff09 \u2192<\/a>\n  <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u70ba\u300aFunny Vote \u5341\u5e74\u6f14\u9032\u7cfb\u5217\u300b\u7b2c 7 \u7bc7\uff08\u5168\u7cfb\u5217\u5171 8 \u7bc7\uff09\uff5c\u67e5\u770b\u5168\u7cfb\u5217\u67b6\u69cb\u5c0e\u89bd \u73fe\u5be6\u7e3d\u662f\u6703\u5728\u5de5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1312,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86,169],"tags":[6,172,179,128],"_links":{"self":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/1313"}],"collection":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1313"}],"version-history":[{"count":6,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/1313\/revisions"}],"predecessor-version":[{"id":1494,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/posts\/1313\/revisions\/1494"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=\/wp\/v2\/media\/1312"}],"wp:attachment":[{"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/boochlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}