{"id":80500,"date":"2026-03-05T10:33:00","date_gmt":"2026-03-05T02:33:00","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/80500.html"},"modified":"2026-03-05T10:33:00","modified_gmt":"2026-03-05T02:33:00","slug":"%e8%b7%af%e7%94%b1%e4%b8%8e%e5%b8%83%e5%b1%80%e6%89%ab%e7%9b%b2%e7%af%87%ef%bc%9a%e7%99%bb%e5%bd%95%e6%80%81%e4%b8%8e%e8%b7%af%e7%94%b1%e5%ae%88%e5%8d%ab-token-%e6%a0%a1%e9%aa%8c%e3%80%81%e7%99%bd","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/80500.html","title":{"rendered":"\u8def\u7531\u4e0e\u5e03\u5c40\u626b\u76f2\u7bc7\uff1a\u767b\u5f55\u6001\u4e0e\u8def\u7531\u5b88\u536b | token \u6821\u9a8c\u3001\u767d\u540d\u5355\u3001\u91cd\u5b9a\u5411"},"content":{"rendered":"<p>\u540c\u5b66\u4eec\u597d&#xff0c;\u6211\u662f Eugene&#xff08;\u5c24\u91d1&#xff09;&#xff0c;\u4e00\u4e2a\u62e5\u6709\u591a\u5e74\u4e2d\u540e\u53f0\u5f00\u53d1\u7ecf\u9a8c\u7684\u524d\u7aef\u5de5\u7a0b\u5e08~<\/p>\n<p>&#xff08;Eugene \u53d1\u97f3\u5f88\u7b80\u5355&#xff0c;\/ju\u02d0\u02c8d\u0292i\u02d0n\/&#xff0c;\u5927\u5bb6\u600e\u4e48\u987a\u53e3\u600e\u4e48\u53eb\u5c31\u597d&#xff09;<\/p>\n<p>\u4f60\u662f\u5426\u4e5f\u6709\u8fc7&#xff1a;\u660e\u660e\u5b66\u8fc7\u5f88\u591a\u6280\u672f&#xff0c;\u4e00\u5230\u5173\u952e\u65f6\u5019\u5374\u8bb2\u4e0d\u51fa\u6765\u3001\u751a\u81f3\u5199\u4e0d\u51fa\u6765&#xff1f;<\/p>\n<p>\u4f60\u662f\u5426\u4e5f\u66fe\u6000\u7591\u81ea\u5df1&#xff0c;\u662f\u4e0d\u662f\u592a\u7b28\u4e86&#xff0c;\u660e\u660e\u611f\u89c9\u4f1a&#xff0c;\u5374\u603b\u5dee\u4e00\u53e3\u6c14&#xff1f;<\/p>\n<p>\u5c31\u7b97\u60f3\u6c89\u4e0b\u5fc3\u4ece\u5934\u68b3\u7406&#xff0c;\u53ef\u5de5\u4f5c\u90a3\u4e48\u5fd9&#xff0c;\u56de\u5bb6\u8fd8\u8981\u966a\u4f34\u5bb6\u4eba\u3002<\/p>\n<p>\u4e00\u5929\u53ea\u670924\u5c0f\u65f6&#xff0c;\u65f6\u95f4\u6c38\u8fdc\u4e0d\u591f\u7528&#xff0c;\u5e38\u5e38\u611f\u5230\u529b\u4e0d\u4ece\u5fc3\u3002<\/p>\n<p>\u6280\u672f\u884c\u4e1a&#xff0c;\u672c\u5c31\u662f\u9006\u6c34\u884c\u821f&#xff0c;\u4e0d\u8fdb\u5219\u9000\u3002<\/p>\n<p>\u5982\u679c\u4f60\u4e5f\u6709\u540c\u6837\u7684\u56f0\u6270&#xff0c;\u522b\u614c\u3002<\/p>\n<p>\u4ece\u73b0\u5728\u5f00\u59cb&#xff0c;\u8ddf\u7740\u6211\u4e00\u8d77\u5fc3\u6001\u5f52\u96f6&#xff0c;\u5229\u7528\u788e\u7247\u65f6\u95f4&#xff0c;\u6765\u4e00\u6b21\u5f7b\u5f7b\u5e95\u5e95\u7684\u57fa\u7840\u626b\u76f2\u3002<\/p>\n<p>\u8fd9\u4e00\u6b21&#xff0c;\u6211\u4eec\u4e00\u8d77\u6162\u6162\u6765&#xff0c;\u624e\u624e\u5b9e\u5b9e\u53d8\u5f3a\u3002<\/p>\n<p>\u4e0d\u641e\u82b1\u91cc\u80e1\u54e8\u7684\u7406\u8bba\u5806\u780c&#xff0c;\u53ea\u5206\u4eab\u770b\u5f97\u61c2\u3001\u7528\u5f97\u4e0a\u7684\u524d\u7aef\u5e72\u8d27&#xff0c;<\/p>\n<p>\u54b1\u4eec\u4e00\u8d77\u7a33\u6b65\u79ef\u7d2f&#xff0c;\u771f\u6b63\u6446\u8131\u201c\u9762\u5411\u641c\u7d22\u5f15\u64ce\u5199\u4ee3\u7801\u201d\u7684\u5c34\u5c2c\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u5148\u641e\u6e05\u695a\u51e0\u4e2a\u6982\u5ff5<\/h3>\n<h4>1.1 \u4ec0\u4e48\u662f\u767b\u5f55\u6001&#xff1f;<\/h4>\n<p>\u767b\u5f55\u6001\u5c31\u662f\u300c\u5f53\u524d\u7528\u6237\u662f\u5426\u5df2\u7ecf\u767b\u5f55\u300d\u7684\u72b6\u6001\u3002\u524d\u7aef\u901a\u5e38\u7528 token \u6765\u8868\u793a&#xff1a;<\/p>\n<ul>\n<li>\u6709 token&#xff1a;\u5df2\u767b\u5f55<\/li>\n<li>\u6ca1\u6709 token&#xff1a;\u672a\u767b\u5f55<\/li>\n<\/ul>\n<p>token \u4e00\u822c\u5b58\u5728 localStorage \u6216 sessionStorage \u91cc&#xff0c;\u767b\u5f55\u6210\u529f\u540e\u7531\u540e\u7aef\u8fd4\u56de&#xff0c;\u540e\u9762\u6bcf\u6b21\u8bf7\u6c42\u90fd\u5e26\u4e0a&#xff0c;\u540e\u7aef\u6839\u636e token \u8bc6\u522b\u7528\u6237\u3002<\/p>\n<h4>1.2 \u4ec0\u4e48\u662f\u8def\u7531\u5b88\u536b&#xff1f;<\/h4>\n<p>\u8def\u7531\u5b88\u536b\u5c31\u662f\u8def\u7531\u8df3\u8f6c\u524d\u7684\u300c\u5173\u5361\u300d&#xff0c;\u7528\u6765\u7edf\u4e00\u5904\u7406\u8df3\u8f6c\u903b\u8f91\u3002Vue Router \u91cc\u6700\u5e38\u7528\u7684\u5c31\u662f router.beforeEach&#xff1a;<\/p>\n<ul>\n<li>\u6bcf\u6b21\u8def\u7531\u8df3\u8f6c\u524d\u90fd\u4f1a\u6267\u884c<\/li>\n<li>\u53ef\u4ee5\u5728\u8fd9\u91cc\u505a token \u6821\u9a8c\u3001\u6743\u9650\u5224\u65ad<\/li>\n<li>\u53ef\u4ee5\u901a\u8fc7 next() \u63a7\u5236\u662f\u653e\u884c\u8fd8\u662f\u62e6\u622a\u3001\u91cd\u5b9a\u5411<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e8c\u3001\u6574\u4f53\u6d41\u7a0b&#xff1a;beforeEach \u91cc\u8981\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898&#xff1f;<\/h3>\n<p>\u6838\u5fc3\u5c31\u4e09\u6b65&#xff1a;<\/p>\n<p>\u7528\u6237\u8bbf\u95ee\u67d0\u4e2a\u9875\u9762<br \/>\n    \u2193<br \/>\nbeforeEach \u62e6\u622a<br \/>\n    \u2193<br \/>\n\u5224\u65ad&#xff1a;\u6709\u6ca1\u6709 token&#xff1f;<br \/>\n    \u251c\u2500 \u6709 token \u2192 \u5df2\u767b\u5f55&#xff0c;\u653e\u884c<br \/>\n    \u2514\u2500 \u6ca1 token \u2192 \u672a\u767b\u5f55<br \/>\n            \u2193<br \/>\n        \u76ee\u6807\u8def\u7531\u5728\u767d\u540d\u5355\u5417&#xff1f;<br \/>\n            \u251c\u2500 \u5728&#xff08;\u767b\u5f55\u9875\u3001404 \u7b49&#xff09;\u2192 \u653e\u884c<br \/>\n            \u2514\u2500 \u4e0d\u5728 \u2192 \u62e6\u622a&#xff0c;\u91cd\u5b9a\u5411\u5230\u767b\u5f55\u9875<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u767d\u540d\u5355&#xff1a;\u54ea\u4e9b\u8def\u7531\u4e0d\u9700\u8981\u767b\u5f55&#xff1f;<\/h3>\n<p>\u767d\u540d\u5355\u5c31\u662f\u300c\u4e0d\u7528\u767b\u5f55\u4e5f\u80fd\u8bbf\u95ee\u300d\u7684\u8def\u7531\u5217\u8868&#xff0c;\u6bd4\u5982&#xff1a;<\/p>\n<ul>\n<li>\u767b\u5f55\u9875 \/login<\/li>\n<li>\u6ce8\u518c\u9875 \/register<\/li>\n<li>404 \u9875 \/404<\/li>\n<li>\u9996\u9875 \/&#xff08;\u6709\u4e9b\u4ea7\u54c1\u9996\u9875\u53ef\u4ee5\u533f\u540d\u8bbf\u95ee&#xff09;<\/li>\n<\/ul>\n<p>\u505a\u6cd5&#xff1a;\u628a\u767d\u540d\u5355\u8def\u5f84\u5199\u5728\u4e00\u4e2a\u6570\u7ec4\u91cc&#xff0c;\u7528 includes \u5224\u65ad\u5f53\u524d\u8def\u5f84\u662f\u5426\u5728\u767d\u540d\u5355\u4e2d\u3002<\/p>\n<hr \/>\n<h3>\u56db\u3001\u91cd\u5b9a\u5411\u903b\u8f91&#xff1a;\u53bb\u54ea\u3001\u56de\u54ea<\/h3>\n<p>\u5e38\u89c1\u4e24\u79cd\u9700\u6c42&#xff1a;<\/p>\n<ul>\n<li>\u672a\u767b\u5f55\u8bbf\u95ee\u9700\u8981\u767b\u5f55\u7684\u9875\u9762 \u2192 \u8df3\u5230\u767b\u5f55\u9875<\/li>\n<li>\u767b\u5f55\u540e\u60f3\u56de\u5230\u300c\u4e4b\u524d\u60f3\u8bbf\u95ee\u7684\u9875\u9762\u300d<\/li>\n<\/ul>\n<p>\u7b2c\u4e8c\u4e2a\u7528 redirect \u53c2\u6570\u5b9e\u73b0&#xff1a;\u5728\u8df3\u8f6c\u767b\u5f55\u9875\u65f6\u628a\u76ee\u6807\u5730\u5740\u5e26\u4e0a&#xff0c;\u767b\u5f55\u6210\u529f\u540e\u6839\u636e redirect \u8df3\u56de\u53bb\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001beforeEach \u91cc\u300c\u5e94\u8be5\u300d\u505a\u4ec0\u4e48&#xff1f;<\/h3>\n<li>\u505a\u767b\u5f55\u6001\u68c0\u67e5&#xff1a;\u6839\u636e token \u5224\u65ad\u662f\u5426\u767b\u5f55<\/li>\n<li>\u767d\u540d\u5355\u5224\u65ad&#xff1a;\u5224\u65ad\u5f53\u524d\u8def\u7531\u662f\u5426\u5728\u767d\u540d\u5355<\/li>\n<li>\u7b80\u5355\u91cd\u5b9a\u5411&#xff1a;\u672a\u767b\u5f55\u65f6\u91cd\u5b9a\u5411\u5230\u767b\u5f55\u9875&#xff0c;\u5e76\u5e26\u4e0a redirect<\/li>\n<li>\u653e\u884c&#xff1a;\u6ee1\u8db3\u6761\u4ef6\u65f6\u8c03\u7528 next() \u653e\u884c<\/li>\n<p>\u53ef\u4ee5\u7b80\u5355\u6982\u62ec\u4e3a&#xff1a;\u53ea\u505a\u548c\u300c\u80fd\u4e0d\u80fd\u8fdb\u8fd9\u4e2a\u9875\u9762\u300d\u76f8\u5173\u7684\u5224\u65ad&#xff0c;\u522b\u7684\u90fd\u5c3d\u91cf\u653e\u5916\u9762\u3002<\/p>\n<hr \/>\n<h3>\u516d\u3001beforeEach \u91cc\u300c\u4e0d\u5e94\u8be5\u300d\u505a\u4ec0\u4e48&#xff1f;<\/h3>\n<li>\u5f02\u6b65\u8bf7\u6c42&#xff1a;\u4e0d\u5728 beforeEach \u91cc\u53d1\u63a5\u53e3\u8bf7\u6c42&#xff08;\u5982\u83b7\u53d6\u7528\u6237\u4fe1\u606f&#xff09;\u3002\u56e0\u4e3a beforeEach \u4f1a\u88ab\u9891\u7e41\u8c03\u7528&#xff0c;\u5bb9\u6613\u9020\u6210\u91cd\u590d\u8bf7\u6c42\u3001\u95ea\u70c1\u548c\u6027\u80fd\u95ee\u9898\u3002<\/li>\n<li>\u590d\u6742\u4e1a\u52a1\u903b\u8f91&#xff1a;\u6bd4\u5982\u83b7\u53d6\u83dc\u5355\u3001\u6743\u9650\u6811\u7b49&#xff0c;\u5e94\u653e\u5230\u767b\u5f55\u540e\u6216\u4e3b\u5e03\u5c40\u52a0\u8f7d\u65f6\u3002<\/li>\n<li>\u5168\u5c40\u526f\u4f5c\u7528&#xff1a;\u6bd4\u5982\u4fee\u6539 Vuex\/Pinia \u91cc\u5f88\u591a\u72b6\u6001&#xff0c;\u5bb9\u6613\u8ba9\u903b\u8f91\u96be\u4ee5\u8ffd\u8e2a\u3002<\/li>\n<li>\u8fc7\u5ea6\u4f9d\u8d56 router&#xff1a;\u907f\u514d\u5728\u5b88\u536b\u91cc\u505a\u5927\u91cf\u8def\u7531\u904d\u5386\u3001\u52a8\u6001\u6dfb\u52a0\u7b49\u590d\u6742\u64cd\u4f5c&#xff0c;\u4fdd\u6301\u5b88\u536b\u7b80\u6d01\u3002<\/li>\n<hr \/>\n<h3>\u4e03\u3001\u5b8c\u6574\u4ee3\u7801\u793a\u4f8b<\/h3>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u793a\u4f8b&#xff0c;\u5305\u542b&#xff1a;<\/p>\n<ul>\n<li>\u767d\u540d\u5355\u914d\u7f6e<\/li>\n<li>token \u83b7\u53d6<\/li>\n<li>redirect \u4fdd\u5b58\u4e0e\u4f7f\u7528<\/li>\n<li>\u6e05\u6670\u7684\u7ed3\u6784\u548c\u6ce8\u91ca<\/li>\n<\/ul>\n<p><span class=\"token comment\">\/\/ router\/index.js<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> createRouter<span class=\"token punctuation\">,<\/span> createWebHistory <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;vue-router&#039;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> getToken <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;&#064;\/utils\/auth&#039;<\/span>  <span class=\"token comment\">\/\/ \u5047\u8bbe\u4f60\u6709\u8fd9\u4e2a\u5de5\u5177\u51fd\u6570<\/span><\/p>\n<p><span class=\"token keyword\">const<\/span> routes <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><br \/>\n  <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token literal-property property\">path<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;\/login&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token literal-property property\">name<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;Login&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token function-variable function\">component<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token keyword\">import<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;&#064;\/views\/Login.vue&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token literal-property property\">meta<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">title<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;\u767b\u5f55&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token literal-property property\">requireAuth<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">false<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token literal-property property\">path<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;\/home&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token literal-property property\">name<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;Home&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token function-variable function\">component<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token keyword\">import<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;&#064;\/views\/Home.vue&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token literal-property property\">meta<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">title<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;\u9996\u9875&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token literal-property property\">requireAuth<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token literal-property property\">path<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;\/user&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token literal-property property\">name<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;User&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token function-variable function\">component<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token keyword\">import<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;&#064;\/views\/User.vue&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token literal-property property\">meta<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">title<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;\u4e2a\u4eba\u4e2d\u5fc3&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token literal-property property\">requireAuth<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">true<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token literal-property property\">path<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;\/:pathMatch(.*)*&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token literal-property property\">name<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;NotFound&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token function-variable function\">component<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token keyword\">import<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;&#064;\/views\/404.vue&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token literal-property property\">meta<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">title<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;404&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token literal-property property\">requireAuth<\/span><span class=\"token operator\">:<\/span> <span class=\"token boolean\">false<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">]<\/span><\/p>\n<p><span class=\"token keyword\">const<\/span> router <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">createRouter<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token literal-property property\">history<\/span><span class=\"token operator\">:<\/span> <span class=\"token function\">createWebHistory<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n  routes<br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\">\/\/ &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u767d\u540d\u5355&#xff1a;\u4e0d\u9700\u8981\u767b\u5f55\u5c31\u80fd\u8bbf\u95ee\u7684\u8def\u7531 &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> <span class=\"token constant\">WHITELIST<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#039;\/login&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;\/register&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;\/404&#039;<\/span><span class=\"token punctuation\">]<\/span><\/p>\n<p><span class=\"token comment\">\/**<br \/>\n * \u5224\u65ad\u76ee\u6807\u8def\u7531\u662f\u5426\u5728\u767d\u540d\u5355\u5185<br \/>\n * &#064;param {string} path &#8211; \u8def\u7531\u8def\u5f84<br \/>\n * &#064;returns {boolean}<br \/>\n *\/<\/span><br \/>\n<span class=\"token keyword\">function<\/span> <span class=\"token function\">isInWhitelist<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">path<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> <span class=\"token constant\">WHITELIST<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">some<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">item<\/span> <span class=\"token operator\">&#061;&gt;<\/span> path<span class=\"token punctuation\">.<\/span><span class=\"token function\">startsWith<\/span><span class=\"token punctuation\">(<\/span>item<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>router<span class=\"token punctuation\">.<\/span><span class=\"token function\">beforeEach<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">to<span class=\"token punctuation\">,<\/span> from<span class=\"token punctuation\">,<\/span> next<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ 1. \u8bbe\u7f6e\u9875\u9762\u6807\u9898&#xff08;\u53ef\u9009&#xff0c;\u548c\u767b\u5f55\u6821\u9a8c\u65e0\u76f4\u63a5\u5173\u7cfb&#xff09;<\/span><br \/>\n  document<span class=\"token punctuation\">.<\/span>title <span class=\"token operator\">&#061;<\/span> to<span class=\"token punctuation\">.<\/span>meta<span class=\"token operator\">?.<\/span>title <span class=\"token operator\">||<\/span> <span class=\"token string\">&#039;\u6211\u7684\u5e94\u7528&#039;<\/span><\/p>\n<p>  <span class=\"token keyword\">const<\/span> token <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">getToken<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n  <span class=\"token keyword\">const<\/span> isLoggedIn <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">!<\/span><span class=\"token operator\">!<\/span>token<\/p>\n<p>  <span class=\"token comment\">\/\/ 2. \u5df2\u767b\u5f55\u7528\u6237\u8bbf\u95ee\u767b\u5f55\u9875 \u2192 \u76f4\u63a5\u8df3\u5230\u9996\u9875&#xff08;\u907f\u514d\u91cd\u590d\u767b\u5f55&#xff09;<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>to<span class=\"token punctuation\">.<\/span>path <span class=\"token operator\">&#061;&#061;&#061;<\/span> <span class=\"token string\">&#039;\/login&#039;<\/span> <span class=\"token operator\">&amp;&amp;<\/span> isLoggedIn<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">next<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">path<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;\/&#039;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">return<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 3. \u767d\u540d\u5355\u5185\u7684\u8def\u7531&#xff0c;\u76f4\u63a5\u653e\u884c<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">isInWhitelist<\/span><span class=\"token punctuation\">(<\/span>to<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">next<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">return<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 4. \u672a\u767b\u5f55 &#043; \u975e\u767d\u540d\u5355 \u2192 \u62e6\u622a&#xff0c;\u91cd\u5b9a\u5411\u5230\u767b\u5f55\u9875&#xff0c;\u5e76\u5e26\u4e0a\u300c\u60f3\u53bb\u7684\u5730\u5740\u300d<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span>isLoggedIn<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">next<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token literal-property property\">path<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;\/login&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n      <span class=\"token literal-property property\">query<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">redirect<\/span><span class=\"token operator\">:<\/span> to<span class=\"token punctuation\">.<\/span>fullPath <span class=\"token punctuation\">}<\/span>  <span class=\"token comment\">\/\/ \u5173\u952e&#xff1a;\u8bb0\u4f4f\u7528\u6237\u60f3\u53bb\u54ea<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">return<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ 5. \u5df2\u767b\u5f55\u4e14\u4e0d\u662f\u8bbf\u95ee\u767b\u5f55\u9875&#xff0c;\u653e\u884c<\/span><br \/>\n  <span class=\"token function\">next<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">default<\/span> router<\/p>\n<p><span class=\"token comment\">\/\/ utils\/auth.js &#8211; token \u5b58\u53d6\u5de5\u5177&#xff08;\u793a\u4f8b&#xff09;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> <span class=\"token constant\">TOKEN_KEY<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;my_app_token&#039;<\/span><\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">getToken<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> localStorage<span class=\"token punctuation\">.<\/span><span class=\"token function\">getItem<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">TOKEN_KEY<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">setToken<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">token<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  localStorage<span class=\"token punctuation\">.<\/span><span class=\"token function\">setItem<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">TOKEN_KEY<\/span><span class=\"token punctuation\">,<\/span> token<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">removeToken<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  localStorage<span class=\"token punctuation\">.<\/span><span class=\"token function\">removeItem<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">TOKEN_KEY<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ views\/Login.vue &#8211; \u767b\u5f55\u6210\u529f\u540e&#xff0c;\u8df3\u56de redirect \u6216\u9996\u9875<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> useRouter<span class=\"token punctuation\">,<\/span> useRoute <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;vue-router&#039;<\/span><br \/>\n<span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> setToken <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;&#064;\/utils\/auth&#039;<\/span><\/p>\n<p><span class=\"token keyword\">export<\/span> <span class=\"token keyword\">default<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token function\">setup<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> router <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">useRouter<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">const<\/span> route <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">useRoute<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token keyword\">async<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function\">handleLogin<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token comment\">\/\/ \u6a21\u62df\u767b\u5f55\u63a5\u53e3<\/span><br \/>\n      <span class=\"token keyword\">const<\/span> res <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> api<span class=\"token punctuation\">.<\/span><span class=\"token function\">login<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> username<span class=\"token punctuation\">,<\/span> password <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><br \/>\n      <span class=\"token function\">setToken<\/span><span class=\"token punctuation\">(<\/span>res<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">.<\/span>token<span class=\"token punctuation\">)<\/span><\/p>\n<p>      <span class=\"token comment\">\/\/ \u91cd\u70b9&#xff1a;\u6709 redirect \u5c31\u8df3\u56de\u53bb&#xff0c;\u5426\u5219\u53bb\u9996\u9875<\/span><br \/>\n      <span class=\"token keyword\">const<\/span> redirect <span class=\"token operator\">&#061;<\/span> route<span class=\"token punctuation\">.<\/span>query<span class=\"token punctuation\">.<\/span>redirect <span class=\"token operator\">||<\/span> <span class=\"token string\">&#039;\/&#039;<\/span><br \/>\n      router<span class=\"token punctuation\">.<\/span><span class=\"token function\">push<\/span><span class=\"token punctuation\">(<\/span>redirect<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span> handleLogin <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<hr \/>\n<h3>\u516b\u3001\u5e38\u89c1\u8e29\u5751<\/h3>\n<table>\n<tr>\u573a\u666f\u95ee\u9898\u5efa\u8bae<\/tr>\n<tbody>\n<tr>\n<td>\u6b7b\u5faa\u73af<\/td>\n<td>\u91cd\u5b9a\u5411\u5230\u767b\u5f55\u9875\u65f6\u672a\u6392\u9664\u767b\u5f55\u9875\u672c\u8eab&#xff0c;\u5bfc\u81f4\u5728\u767d\u540d\u5355\u5224\u65ad\u548c\u767b\u5f55\u9875\u91cd\u5b9a\u5411\u95f4\u6765\u56de\u8df3<\/td>\n<td>\u628a \/login \u653e\u5165\u767d\u540d\u5355&#xff0c;\u6216\u5728\u91cd\u5b9a\u5411\u524d\u660e\u786e\u5224\u65ad<\/td>\n<\/tr>\n<tr>\n<td>\u5fd8\u8bb0\u8c03\u7528 next()<\/td>\n<td>\u5b88\u536b\u91cc\u65e2\u6ca1\u653e\u884c\u4e5f\u6ca1\u91cd\u5b9a\u5411<\/td>\n<td>\u6bcf\u4e2a\u5206\u652f\u90fd\u8981 next()&#xff0c;\u4e14\u53ea\u8c03\u7528\u4e00\u6b21<\/td>\n<\/tr>\n<tr>\n<td>\u91cd\u590d next()<\/td>\n<td>\u540c\u4e00\u5206\u652f\u91cc\u8c03\u7528\u591a\u6b21 next()<\/td>\n<td>\u6bcf\u4e2a\u5206\u652f\u8c03\u7528\u4e00\u6b21\u540e return&#xff0c;\u907f\u514d\u540e\u7eed\u518d\u6267\u884c<\/td>\n<\/tr>\n<tr>\n<td>\u5728 beforeEach \u91cc\u8bf7\u6c42\u7528\u6237\u4fe1\u606f<\/td>\n<td>\u6bcf\u6b21\u8def\u7531\u5207\u6362\u90fd\u8bf7\u6c42&#xff0c;\u6027\u80fd\u5dee\u3001\u4f53\u9a8c\u5dee<\/td>\n<td>\u5728\u767b\u5f55\u6210\u529f\u540e\u8bf7\u6c42\u4e00\u6b21&#xff0c;\u6216\u5728\u4e3b\u5e03\u5c40\u4e2d\u8bf7\u6c42&#xff0c;\u5b88\u536b\u53ea\u505a token \u6709\u65e0\u5224\u65ad<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u4e5d\u3001\u603b\u7ed3<\/h3>\n<ul>\n<li>\u767b\u5f55\u6001&#xff1a;\u7528 token \u8868\u793a&#xff0c;\u5b58 localStorage&#xff0c;\u7531\u540e\u7aef\u7b7e\u53d1\u548c\u6821\u9a8c\u3002<\/li>\n<li>\u767d\u540d\u5355&#xff1a;\u4e0d\u7528\u767b\u5f55\u4e5f\u80fd\u8bbf\u95ee\u7684\u8def\u7531&#xff0c;\u7528\u6570\u7ec4 &#043; includes\/some \u5224\u65ad\u3002<\/li>\n<li>\u91cd\u5b9a\u5411&#xff1a;\u672a\u767b\u5f55\u65f6\u8df3\u5230 \/login&#xff0c;\u5e76\u7528 query.redirect \u4fdd\u5b58\u76ee\u6807\u5730\u5740&#xff0c;\u767b\u5f55\u6210\u529f\u540e\u8df3\u56de\u3002<\/li>\n<li>beforeEach&#xff1a;\u53ea\u505a token \u5224\u65ad\u3001\u767d\u540d\u5355\u5224\u65ad\u3001\u7b80\u5355\u91cd\u5b9a\u5411\u548c\u653e\u884c&#xff1b;\u4e0d\u5728\u8fd9\u91cc\u53d1\u8bf7\u6c42\u3001\u4e0d\u505a\u590d\u6742\u4e1a\u52a1\u3001\u4e0d\u91cd\u590d\u8c03\u7528 next()\u3002<\/li>\n<li>\u8c03\u7528 next()&#xff1a;\u6bcf\u4e2a\u5206\u652f\u90fd\u8981\u6709&#xff0c;\u4e14\u53ea\u8c03\u7528\u4e00\u6b21&#xff0c;\u7528 return \u4fdd\u8bc1\u903b\u8f91\u6e05\u6670\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>&#x1f50d; \u672c\u7cfb\u5217\u4e13\u680f\u5bfc\u822a<\/h3>\n<p>\u4e00\u3001\u300a\u8def\u7531\u4e0e\u5e03\u5c40\u626b\u76f2\u7bc7&#xff1a;Vue Router \u5b9e\u6218 | \u52a8\u6001\u8def\u7531\u3001\u5d4c\u5957\u8def\u7531\u4e0e\u591a\u7ea7\u83dc\u5355\u300b \u4e8c\u3001\u300a\u8def\u7531\u4e0e\u5e03\u5c40\u626b\u76f2\u7bc7&#xff1a;\u767b\u5f55\u6001\u4e0e\u8def\u7531\u5b88\u536b | token \u6821\u9a8c\u3001\u767d\u540d\u5355\u3001\u91cd\u5b9a\u5411\u300b<\/p>\n<p>&#x1f449; \u8ddf\u7740\u7cfb\u5217\u6162\u6162\u5b66&#xff0c;\u628a\u6280\u672f\u529f\u5e95\u624e\u624e\u5b9e\u5b9e\u5730\u6253\u7262&#xff5e;<\/p>\n<hr \/>\n<p>\u5b66\u4e60\u672c\u5c31\u662f\u4e00\u573a\u6301\u4e45\u6218&#xff0c;\u4e0d\u9700\u8981\u6025\u7740\u4e00\u53e3\u5403\u6210\u80d6\u5b50\u3002\u54ea\u6015\u4eca\u5929\u4f60\u53ea\u8bb0\u4f4f\u4e86\u4e00\u70b9\u70b9&#xff0c;\u8fd9\u90fd\u662f\u5b9e\u6253\u5b9e\u7684\u8fdb\u6b65\u3002<\/p>\n<p>\u540e\u7eed\u6211\u8fd8\u4f1a\u7ee7\u7eed\u7528\u8fd9\u79cd\u5927\u767d\u8bdd\u3001\u8bb2\u5b9e\u6218\u65b9\u5f0f&#xff0c;\u5e26\u5927\u5bb6\u626b\u76f2\u66f4\u591a\u524d\u7aef\u57fa\u7840\u3002<\/p>\n<p>\u5173\u6ce8\u6211&#xff0c;\u4e0d\u8ff7\u8def&#xff0c;\u54b1\u4eec\u628a\u90a3\u4e9b\u66fe\u7ecf\u6a21\u7cca\u7684\u77e5\u8bc6\u70b9&#xff0c;\u4e00\u4e2a\u4e2a\u5f7b\u5e95\u641e\u6e05\u695a\u3002<\/p>\n<p>\u5982\u679c\u4f60\u89c9\u5f97\u8fd9\u7bc7\u5185\u5bb9\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u4e0d\u59a8\u70b9\u8d5e&#043;\u6536\u85cf&#xff0c;\u4e0b\u6b21\u5199\u4ee3\u7801\u5361\u58f3\u65f6&#xff0c;\u62ff\u51fa\u6765\u7ffb\u4e00\u7ffb&#xff0c;\u6bd4\u641c\u5f15\u64ce\u66f4\u9760\u8c31\u3002<\/p>\n<p>\u6211\u662f Eugene&#xff0c;\u4f60\u7684\u7535\u5b50\u5b66\u53cb&#xff0c;\u6211\u4eec\u4e0b\u4e00\u7bc7\u5e72\u8d27\u89c1&#xff5e;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u5b66\u4eec\u597d&#xff0c;\u6211\u662f Eugene&#xff08;\u5c24\u91d1&#xff09;&#xff0c;\u4e00\u4e2a\u62e5\u6709\u591a\u5e74\u4e2d\u540e\u53f0\u5f00\u53d1\u7ecf\u9a8c\u7684\u524d\u7aef\u5de5\u7a0b\u5e08~<br \/>\n&#xff08;Eugene \u53d1\u97f3\u5f88\u7b80\u5355&#xff0c;\/ju\u02d0\u02c8d\u0292i\u02d0n\/&#xff0c;\u5927\u5bb6\u600e\u4e48\u987a\u53e3\u600e\u4e48\u53eb\u5c31\u597d&#xff09;<br \/>\n\u4f60\u662f\u5426\u4e5f\u6709\u8fc7&#xff1a;\u660e\u660e\u5b66\u8fc7\u5f88\u591a\u6280\u672f&#xff0c;\u4e00\u5230\u5173\u952e\u65f6\u5019\u5374\u8bb2\u4e0d\u51fa\u6765\u3001\u751a\u81f3\u5199\u4e0d\u51fa\u6765&#xff1f;<br \/>\n\u4f60\u662f\u5426\u4e5f\u66fe\u6000\u7591\u81ea\u5df1&#xff0c;\u662f\u4e0d\u662f\u592a\u7b28\u4e86&#xff0c;\u660e\u660e\u611f\u89c9\u4f1a&#xff0c;\u5374<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[187,625,87,885,176],"topic":[],"class_list":["post-80500","post","type-post","status-publish","format-standard","hentry","category-server","tag-javascript","tag-vue-js","tag-87","tag-885","tag-176"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u8def\u7531\u4e0e\u5e03\u5c40\u626b\u76f2\u7bc7\uff1a\u767b\u5f55\u6001\u4e0e\u8def\u7531\u5b88\u536b | token \u6821\u9a8c\u3001\u767d\u540d\u5355\u3001\u91cd\u5b9a\u5411 - \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\/80500.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u8def\u7531\u4e0e\u5e03\u5c40\u626b\u76f2\u7bc7\uff1a\u767b\u5f55\u6001\u4e0e\u8def\u7531\u5b88\u536b | token \u6821\u9a8c\u3001\u767d\u540d\u5355\u3001\u91cd\u5b9a\u5411 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u540c\u5b66\u4eec\u597d&#xff0c;\u6211\u662f Eugene&#xff08;\u5c24\u91d1&#xff09;&#xff0c;\u4e00\u4e2a\u62e5\u6709\u591a\u5e74\u4e2d\u540e\u53f0\u5f00\u53d1\u7ecf\u9a8c\u7684\u524d\u7aef\u5de5\u7a0b\u5e08~ &#xff08;Eugene \u53d1\u97f3\u5f88\u7b80\u5355&#xff0c;\/ju\u02d0\u02c8d\u0292i\u02d0n\/&#xff0c;\u5927\u5bb6\u600e\u4e48\u987a\u53e3\u600e\u4e48\u53eb\u5c31\u597d&#xff09; \u4f60\u662f\u5426\u4e5f\u6709\u8fc7&#xff1a;\u660e\u660e\u5b66\u8fc7\u5f88\u591a\u6280\u672f&#xff0c;\u4e00\u5230\u5173\u952e\u65f6\u5019\u5374\u8bb2\u4e0d\u51fa\u6765\u3001\u751a\u81f3\u5199\u4e0d\u51fa\u6765&#xff1f; \u4f60\u662f\u5426\u4e5f\u66fe\u6000\u7591\u81ea\u5df1&#xff0c;\u662f\u4e0d\u662f\u592a\u7b28\u4e86&#xff0c;\u660e\u660e\u611f\u89c9\u4f1a&#xff0c;\u5374\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/80500.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-05T02:33:00+00:00\" \/>\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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/80500.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/80500.html\",\"name\":\"\u8def\u7531\u4e0e\u5e03\u5c40\u626b\u76f2\u7bc7\uff1a\u767b\u5f55\u6001\u4e0e\u8def\u7531\u5b88\u536b | token \u6821\u9a8c\u3001\u767d\u540d\u5355\u3001\u91cd\u5b9a\u5411 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-03-05T02:33:00+00:00\",\"dateModified\":\"2026-03-05T02:33:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/80500.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/80500.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/80500.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u8def\u7531\u4e0e\u5e03\u5c40\u626b\u76f2\u7bc7\uff1a\u767b\u5f55\u6001\u4e0e\u8def\u7531\u5b88\u536b | token \u6821\u9a8c\u3001\u767d\u540d\u5355\u3001\u91cd\u5b9a\u5411\"}]},{\"@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":"\u8def\u7531\u4e0e\u5e03\u5c40\u626b\u76f2\u7bc7\uff1a\u767b\u5f55\u6001\u4e0e\u8def\u7531\u5b88\u536b | token \u6821\u9a8c\u3001\u767d\u540d\u5355\u3001\u91cd\u5b9a\u5411 - \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\/80500.html","og_locale":"zh_CN","og_type":"article","og_title":"\u8def\u7531\u4e0e\u5e03\u5c40\u626b\u76f2\u7bc7\uff1a\u767b\u5f55\u6001\u4e0e\u8def\u7531\u5b88\u536b | token \u6821\u9a8c\u3001\u767d\u540d\u5355\u3001\u91cd\u5b9a\u5411 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u540c\u5b66\u4eec\u597d&#xff0c;\u6211\u662f Eugene&#xff08;\u5c24\u91d1&#xff09;&#xff0c;\u4e00\u4e2a\u62e5\u6709\u591a\u5e74\u4e2d\u540e\u53f0\u5f00\u53d1\u7ecf\u9a8c\u7684\u524d\u7aef\u5de5\u7a0b\u5e08~ &#xff08;Eugene \u53d1\u97f3\u5f88\u7b80\u5355&#xff0c;\/ju\u02d0\u02c8d\u0292i\u02d0n\/&#xff0c;\u5927\u5bb6\u600e\u4e48\u987a\u53e3\u600e\u4e48\u53eb\u5c31\u597d&#xff09; \u4f60\u662f\u5426\u4e5f\u6709\u8fc7&#xff1a;\u660e\u660e\u5b66\u8fc7\u5f88\u591a\u6280\u672f&#xff0c;\u4e00\u5230\u5173\u952e\u65f6\u5019\u5374\u8bb2\u4e0d\u51fa\u6765\u3001\u751a\u81f3\u5199\u4e0d\u51fa\u6765&#xff1f; \u4f60\u662f\u5426\u4e5f\u66fe\u6000\u7591\u81ea\u5df1&#xff0c;\u662f\u4e0d\u662f\u592a\u7b28\u4e86&#xff0c;\u660e\u660e\u611f\u89c9\u4f1a&#xff0c;\u5374","og_url":"https:\/\/www.wsisp.com\/helps\/80500.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-03-05T02:33:00+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/80500.html","url":"https:\/\/www.wsisp.com\/helps\/80500.html","name":"\u8def\u7531\u4e0e\u5e03\u5c40\u626b\u76f2\u7bc7\uff1a\u767b\u5f55\u6001\u4e0e\u8def\u7531\u5b88\u536b | token \u6821\u9a8c\u3001\u767d\u540d\u5355\u3001\u91cd\u5b9a\u5411 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-03-05T02:33:00+00:00","dateModified":"2026-03-05T02:33:00+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/80500.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/80500.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/80500.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u8def\u7531\u4e0e\u5e03\u5c40\u626b\u76f2\u7bc7\uff1a\u767b\u5f55\u6001\u4e0e\u8def\u7531\u5b88\u536b | token \u6821\u9a8c\u3001\u767d\u540d\u5355\u3001\u91cd\u5b9a\u5411"}]},{"@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\/80500","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=80500"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/80500\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=80500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=80500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=80500"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=80500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}