ソースを参照

编辑添加登录验证

huwhois 3 年 前
コミット
469592efde
共有11 個のファイルを変更した323 個の追加56 個の削除を含む
  1. 1 0
      .gitignore
  2. 70 3
      application/Index.php
  3. 10 1
      application/MySqlite.php
  4. 18 0
      application/RRException.php
  5. 4 1
      application/start.php
  6. 5 0
      composer.json
  7. 72 0
      composer.lock
  8. 128 49
      public/html/index.html
  9. 1 1
      public/info.php
  10. 5 1
      public/static/css/index.css
  11. 9 0
      public/static/js/axios.min.js

+ 1 - 0
.gitignore

@ -0,0 +1 @@
1
/vendor

+ 70 - 3
application/Index.php

@ -1,8 +1,11 @@
1 1
<?php
2 2
namespace app;
3 3
use app\View;
4
use app\Route;
4
use app\RRException;
5
use \Firebase\JWT\JWT;
6
use app\MySqlite;
5 7
8
define('KEY', 'bf731bcb3f5e52ec1b8b12c95f503d7a'); //密钥
6 9
7 10
class Index extends View
8 11
{
@ -60,8 +63,17 @@ class Index extends View
60 63
61 64
    public function save()
62 65
    {
63
        $doc = $_POST['doc'];
64
        $content = $_POST['content'];
66
        $this->validate();
67
68
        // $doc = $_POST['doc'];
69
        // $content = $_POST['content'];
70
71
        // 获取payload json数据,转换成数组形式
72
        $postData = file_get_contents('php://input');
73
        $requests = !empty($postData) ? json_decode($postData, true) : [];
74
75
        $doc = $requests['doc'];
76
        $content = $requests['content'];
65 77
66 78
        $pathinfo = pathinfo($doc);
67 79
        
@ -82,4 +94,59 @@ class Index extends View
82 94
        }
83 95
        die();
84 96
    }
97
98
    public function login()
99
    {
100
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
101
            $username = htmlentities($_POST['username']);
102
            $password = htmlentities($_POST['password']);
103
104
            $sql = "select * from sys_user where username='" . $username . "' limit 0,1";
105
106
            $mysqlite = new MySqlite();
107
108
            $user = $mysqlite->getOne($sql);
109
110
            if ($username !== $user['username'] && md5($password) !== $user['password']) {
111
                throw new RRException("用户名或密码错误!", 401);
112
            }
113
    
114
            // 用户名和密码正确,则签发tokon
115
            $nowtime = time();
116
            $jwtInfo = [
117
                'iss' => 'huwhois@163.com', //签发者
118
                'iat' => $nowtime, //签发时间
119
                'nbf' => $nowtime + 10, //在什么时间之后该jwt才可用
120
                'exp' => $nowtime + 64800, //过期时间-18h
121
                'data' => [
122
                    'userid' => $user['id'],
123
                    'username' => $username
124
                ]
125
            ];
126
            $token = JWT::encode($jwtInfo, KEY);
127
            echo json_encode(['code'=>0, 'msg'=>'success', 'token'=>$token]);
128
        }
129
        die();
130
    }
131
132
    private function validate ()
133
    {
134
        $jwt = isset($_SERVER['HTTP_TOKEN']) ? $_SERVER['HTTP_TOKEN'] : '';
135
        if (empty($jwt)) {
136
            throw new RRException("You do not have permission to access.", 401);
137
        }
138
    
139
        try {
140
            JWT::$leeway = 60;
141
            $decoded = JWT::decode($jwt, KEY, ['HS256']);
142
            $arr = (array)$decoded;
143
            if ($arr['exp'] < time()) {
144
                throw new RRException("认证信息已过期, 请重新登录.", 401);
145
            }
146
        } catch(\Exception $e) {
147
            throw new RRException($e->getMessage(), 401);
148
        }
149
150
        return true;
151
    }
85 152
}

+ 10 - 1
application/MySqlite.php

@ -1,7 +1,7 @@
1 1
<?php
2 2
namespace app;
3 3
4
class HuSqlite
4
class MySqlite
5 5
{
6 6
    private $mydb;
7 7
    protected $tablename;
@ -73,6 +73,15 @@ class HuSqlite
73 73
        return $data;
74 74
    }
75 75
76
    public function getOne(string $sql = "")
77
    {
78
        $result = $this->mydb->query($sql);
79
        // var_dump($result);
80
        $data = $result->fetchArray(SQLITE3_ASSOC);
81
        // var_dump($data);
82
        return $data;
83
    }
84
76 85
    /**
77 86
     * 单列合计
78 87
     */

+ 18 - 0
application/RRException.php

@ -0,0 +1,18 @@
1
<?php
2
namespace app;
3
use \Exception;
4
5
class RRException extends Exception
6
{
7
    protected  $msg;
8
    protected  $code = 500;
9
10
    public function __construct(string $message = "", int $code = 0)
11
    {
12
        $res['msg'] = $message;
13
        $res['code'] = $code;
14
15
        echo json_encode($res);
16
        exit;
17
    }
18
}

+ 4 - 1
application/start.php

@ -4,6 +4,7 @@ namespace app;
4 4
//定义系统常量
5 5
define("DB", __DIR__ . '/../db');
6 6
define("DS", DIRECTORY_SEPARATOR);
7
define("VENDOR", __DIR__ . '/../vendor');
7 8
8 9
// 环境常量
9 10
define('IS_CLI', PHP_SAPI == 'cli' ? true : false);
@ -15,8 +16,10 @@ require "function.php";
15 16
require (APP_PATH . "App.php");
16 17
require (APP_PATH . "View.php");
17 18
require (APP_PATH . "Index.php");
19
require (APP_PATH . "MySqlite.php");
20
require (APP_PATH . "RRException.php");
18 21
require (APP_PATH . "parsedown/Parsedown.php");
19 22
require (APP_PATH . "parsedown/ParsedownExtension.php");
20
23
require (VENDOR . "/autoload.php");
21 24
// 执行应用
22 25
App::run();

+ 5 - 0
composer.json

@ -0,0 +1,5 @@
1
{
2
    "require": {
3
        "firebase/php-jwt": "^5.4"
4
    }
5
}

+ 72 - 0
composer.lock

@ -0,0 +1,72 @@
1
{
2
    "_readme": [
3
        "This file locks the dependencies of your project to a known state",
4
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
        "This file is @generated automatically"
6
    ],
7
    "content-hash": "efa5297a9696754572ee8408c3556978",
8
    "packages": [
9
        {
10
            "name": "firebase/php-jwt",
11
            "version": "v5.4.0",
12
            "source": {
13
                "type": "git",
14
                "url": "https://github.com/firebase/php-jwt.git",
15
                "reference": "d2113d9b2e0e349796e72d2a63cf9319100382d2"
16
            },
17
            "dist": {
18
                "type": "zip",
19
                "url": "https://api.github.com/repos/firebase/php-jwt/zipball/d2113d9b2e0e349796e72d2a63cf9319100382d2",
20
                "reference": "d2113d9b2e0e349796e72d2a63cf9319100382d2",
21
                "shasum": ""
22
            },
23
            "require": {
24
                "php": ">=5.3.0"
25
            },
26
            "require-dev": {
27
                "phpunit/phpunit": ">=4.8 <=9"
28
            },
29
            "suggest": {
30
                "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present"
31
            },
32
            "type": "library",
33
            "autoload": {
34
                "psr-4": {
35
                    "Firebase\\JWT\\": "src"
36
                }
37
            },
38
            "notification-url": "https://packagist.org/downloads/",
39
            "license": [
40
                "BSD-3-Clause"
41
            ],
42
            "authors": [
43
                {
44
                    "name": "Neuman Vong",
45
                    "email": "neuman+pear@twilio.com",
46
                    "role": "Developer"
47
                },
48
                {
49
                    "name": "Anant Narayanan",
50
                    "email": "anant@php.net",
51
                    "role": "Developer"
52
                }
53
            ],
54
            "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
55
            "homepage": "https://github.com/firebase/php-jwt",
56
            "keywords": [
57
                "jwt",
58
                "php"
59
            ],
60
            "time": "2021-06-23T19:00:23+00:00"
61
        }
62
    ],
63
    "packages-dev": [],
64
    "aliases": [],
65
    "minimum-stability": "stable",
66
    "stability-flags": [],
67
    "prefer-stable": false,
68
    "prefer-lowest": false,
69
    "platform": [],
70
    "platform-dev": [],
71
    "plugin-api-version": "1.1.0"
72
}

+ 128 - 49
public/html/index.html

@ -1,10 +1,12 @@
1 1
<html lang="zh-cn">
2
2 3
<head>
3 4
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
4 5
    <link rel="stylesheet" href="/static/css/index.css">
5 6
    <script src="/static/js/jquery.min.js"></script>
6 7
    <script src="/static/js/bootstrap.min.js"></script>
7
8
    <script src="/static/js/axios.min.js"></script>
9
    <!-- <script src="https://cdn.bootcss.com/axios/0.17.1/axios.min.js"></script> -->
8 10
    <!-- <link href="/static/css/markdown.css" rel="stylesheet" /> -->
9 11
    <script src="/static/ace/ace.js"></script>
10 12
    <script src="/static/ace/mode-markdown.js"></script>
@ -19,12 +21,15 @@
19 21
20 22
    <link rel="stylesheet" href="/static/highlight/styles/solarized-light.css">
21 23
    <script src="/static/highlight/highlight.pack.js"></script>
22
    <title>MarkDown-Wiki:<?php echo $doc;?></title>
24
    <title>MarkDown-Wiki:
25
        <?php echo $doc;?>
26
    </title>
23 27
</head>
28
24 29
<body>
25 30
    <header>
26 31
        <span class="logo">
27
            <a href="/index" >HUWIKI</a>
32
            <a href="/index">HUWIKI</a>
28 33
        </span>
29 34
    </header>
30 35
    <aside>
@ -39,14 +44,18 @@
39 44
                        continue;
40 45
                    } else {
41 46
            ?>
42
                <span> / <a href="<?php echo $temp.$val.'/index.md';?>"><?php echo $val;?></a></span>
47
            <span> / <a href="<?php echo $temp.$val.'/index.md';?>">
48
                    <?php echo $val;?>
49
                </a></span>
43 50
            <?php
44 51
                    }
45 52
                    $temp .= $val ."/";
46 53
                }
47 54
            ?>
48 55
        </div>
49
        <div class="toc"><?php echo $toc;?></div>
56
        <div class="toc">
57
            <?php echo $toc;?>
58
        </div>
50 59
    </aside>
51 60
    <!--article标签中就是我们编写的文本内容-->
52 61
    <article>
@ -70,33 +79,65 @@
70 79
            ?>
71 80
        </div>
72 81
    </article>
73
    
74
    <!-- Modal -->
82
83
    <!-- 编辑 Modal  -->
75 84
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
76 85
        <div class="modal-dialog" role="document">
77
            <div class="modal-content">
78
            <div class="modal-header">
79
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
80
                <h4 class="modal-title" id="myModalLabel">编辑</h4>
81
            </div>
82
            <div class="modal-body">
83
                <div class="editor-content" id="mdeditor" style="height: 70%;"><?php echo $text;?></div>
84
                <!-- <textarea class="form-control" rows="20" style="resize:vertical" id="mdeditor" name="mdeditor"><?php echo $text;?></textarea> -->
85
                <!-- begin code -->
86
                <!-- <textarea class="form-control" id="mdeditor" name="mdeditor"><?php echo $text;?></textarea> -->
87
                <!-- end code-->
88
            </div>
89
            <div class="modal-footer">
90
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
91
                <button type="button" class="btn btn-primary" onclick="save('<?php echo $doc;?>')">Save changes</button>
86
            <div class="modal-content modal-edit">
87
                <div class="modal-header">
88
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
89
                            aria-hidden="true">&times;</span></button>
90
                    <h4 class="modal-title" id="myModalLabel">编辑</h4>
91
                </div>
92
                <div class="modal-body">
93
                    <div class="editor-content" id="mdeditor" style="height: 70%;">
94
                        <?php echo $text;?>
95
                    </div>
96
                    <!-- <textarea class="form-control" rows="20" style="resize:vertical" id="mdeditor" name="mdeditor"><?php echo $text;?></textarea> -->
97
                    <!-- begin code -->
98
                    <!-- <textarea class="form-control" id="mdeditor" name="mdeditor"><?php echo $text;?></textarea> -->
99
                    <!-- end code-->
100
                </div>
101
                <div class="modal-footer">
102
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
103
                    <button type="button" class="btn btn-primary" onclick="save('<?php echo $doc;?>')">Save
104
                        changes</button>
105
                </div>
92 106
            </div>
107
        </div>
108
    </div>
109
110
    <!-- 登录 Modal  -->
111
    <div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="loginModalLabel">
112
        <div class="modal-dialog" role="document" style="margin-top: 200px;">
113
            <div class="modal-content modal-login">
114
                <div class="modal-header">
115
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
116
                            aria-hidden="true">&times;</span></button>
117
                    <h4 class="modal-title" id="loginModalLabel">登录</h4>
118
                </div>
119
                <div class="modal-body">
120
                    <div class="form-group">
121
                        <label for="username">用户名</label>
122
                        <input type="text" class="form-control" id="username" placeholder="请输入用户名">
123
                    </div>
124
                    <div class="form-group">
125
                        <label for="password">密码</label>
126
                        <input type="password" class="form-control" id="password" placeholder="请输入密码">
127
                    </div>
128
                </div>
129
                <div class="modal-footer">
130
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
131
                    <button type="button" class="btn btn-primary" onclick="login()">LOGIN</button>
132
                </div>
93 133
            </div>
94 134
        </div>
95 135
    </div>
96 136
137
97 138
    <script>
98 139
        // 表格加上边框
99
        $(document).ready(function(){
140
        $(document).ready(function () {
100 141
            $("table").addClass('table table-bordered');
101 142
        });
102 143
        // 代码高亮
@ -112,7 +153,7 @@
112 153
        editor.getSession().setMode('ace/mode/markdown');
113 154
        editor.renderer.setShowPrintMargin(false);
114 155
115
        var imgUrl='';//上传图片返回的url
156
        var imgUrl = '';//上传图片返回的url
116 157
117 158
        // codemirror
118 159
        // var editor = CodeMirror.fromTextArea(document.getElementById("mdeditor"), {
@ -132,42 +173,80 @@
132 173
        //     getValue() {
133 174
        //         return $("#mdeditor").val();
134 175
        //     }
135
        // };        
176
        // };     
177
        var storage = window.sessionStorage
136 178
137 179
        function edit() {
180
            if (storage == 'undefined') {
181
                alert("浏览暂不支持sessionStorage, 无法启用编辑")
182
            } else {
183
                if (storage.getItem("token")) {
184
                    $("#myModal").modal('show');
185
                } else {
186
                    $("#loginModal").modal('show');
187
                }
188
            }
138 189
            // console.log(editor.getValue());
139
            $("#myModal").modal('show');
140 190
            // window.location.href="/editor";
141 191
        }
142 192
193
        function login() {
194
            let username = document.querySelector('#username').value;
195
            let password = document.querySelector('#password').value;
196
197
            var params = new URLSearchParams();
198
            params.append('username', username);
199
            params.append('password', password);
200
            axios.post(
201
                '/login',
202
                params
203
            ).then((res) => {
204
                if (res.data.code === 0) {
205
                    // 本地存储token
206
                    storage.setItem('token', res.data.token);
207
                    $("#loginModal").modal('hide');
208
                    // 弹出编辑框
209
                    $("#myModal").modal('show');
210
                } else {
211
                    console.log(res.data.msg);
212
                }
213
            }).catch(function (error) {
214
                console.log(error);
215
            });
216
        }
217
143 218
        function save(doc) {
144 219
            var text = editor.getValue();
145 220
            // console.log(editor.getValue());
146 221
            // return false;
147
            $.ajax({
148
                url: "/save",
149
                type: "POST",
150
                data: {
151
                    'doc': doc,
152
                    'content': text
153
                },
154
                dataType: 'JSON',
155
                success: function (res) {
156
                    if (res.code==0) {
157
                        // acen_edit.destroy();
158
                        // acen_edit.container.remove();
159
                        console.log(res.msg);
160
                        alert("保存成功");
161
                        $("#myModal").modal('hide');
162
                        setTimeout(window.location.reload(), 1500);
163
                    } else {
164
                        alert("保存失败, 请稍后重试.");
165
                    }
222
            params = {
223
                'doc': doc,
224
                'content': text
225
            };
226
            axios({
227
                method: "POST",
228
                url: `/save`,
229
                data: JSON.stringify(params),
230
                headers: {
231
                    'token': storage.getItem("token"),
232
                    'Content-Type': 'application/json'
166 233
                }
167
            })
168
169
234
            }).then(function (res) {
235
                if (res.data.code == 0) {
236
                    // acen_edit.destroy();
237
                    // acen_edit.container.remove();
238
                    console.log(res.data.msg);
239
                    alert("保存成功");
240
                    $("#myModal").modal('hide');
241
                    setTimeout(window.location.reload(), 1500);
242
                } else {
243
                    alert(res.data.msg);
244
                }
245
            }).catch(function (error) {
246
                console.log(error);
247
            });
170 248
        }
171 249
    </script>
172 250
</body>
173
</html>
251
252
</html>

+ 1 - 1
public/info.php

@ -1,2 +1,2 @@
1 1
<?php
2
phpinfo();
2
echo md5("admin");

+ 5 - 1
public/static/css/index.css

@ -50,6 +50,10 @@ article .content {
50 50
    font-size: 22px;
51 51
}
52 52
53
.modal-content {
53
.modal-edit {
54 54
    width: 800px;
55
}
56
57
.modal-login {
58
    width: 400px;
55 59
}

+ 9 - 0
public/static/js/axios.min.js

@ -0,0 +1,9 @@
1
/* axios v0.17.1 | (c) 2017 by Matt Zabriskie */
2
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new s(e),n=i(s.prototype.request,t);return o.extend(n,s.prototype,t),o.extend(n,t),n}var o=n(2),i=n(3),s=n(5),u=n(6),a=r(u);a.Axios=s,a.create=function(e){return r(o.merge(u,e))},a.Cancel=n(23),a.CancelToken=n(24),a.isCancel=n(20),a.all=function(e){return Promise.all(e)},a.spread=n(25),e.exports=a,e.exports.default=a},function(e,t,n){"use strict";function r(e){return"[object Array]"===R.call(e)}function o(e){return"[object ArrayBuffer]"===R.call(e)}function i(e){return"undefined"!=typeof FormData&&e instanceof FormData}function s(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function u(e){return"string"==typeof e}function a(e){return"number"==typeof e}function c(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function p(e){return"[object Date]"===R.call(e)}function d(e){return"[object File]"===R.call(e)}function l(e){return"[object Blob]"===R.call(e)}function h(e){return"[object Function]"===R.call(e)}function m(e){return f(e)&&h(e.pipe)}function y(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function w(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function g(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function v(e,t){if(null!==e&&"undefined"!=typeof e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}function x(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=x(t[n],e):t[n]=e}for(var t={},n=0,r=arguments.length;n<r;n++)v(arguments[n],e);return t}function b(e,t,n){return v(t,function(t,r){n&&"function"==typeof t?e[r]=E(t,n):e[r]=t}),e}var E=n(3),C=n(4),R=Object.prototype.toString;e.exports={isArray:r,isArrayBuffer:o,isBuffer:C,isFormData:i,isArrayBufferView:s,isString:u,isNumber:a,isObject:f,isUndefined:c,isDate:p,isFile:d,isBlob:l,isFunction:h,isStream:m,isURLSearchParams:y,isStandardBrowserEnv:g,forEach:v,merge:x,extend:b,trim:w}},function(e,t){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function r(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}/*!
3
	 * Determine if an object is a Buffer
4
	 *
5
	 * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
6
	 * @license  MIT
7
	 */
8
e.exports=function(e){return null!=e&&(n(e)||r(e)||!!e._isBuffer)}},function(e,t,n){"use strict";function r(e){this.defaults=e,this.interceptors={request:new s,response:new s}}var o=n(6),i=n(2),s=n(17),u=n(18);r.prototype.request=function(e){"string"==typeof e&&(e=i.merge({url:arguments[0]},arguments[1])),e=i.merge(o,this.defaults,{method:"get"},e),e.method=e.method.toLowerCase();var t=[u,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},i.forEach(["delete","get","head","options"],function(e){r.prototype[e]=function(t,n){return this.request(i.merge(n||{},{method:e,url:t}))}}),i.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(i.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=r},function(e,t,n){"use strict";function r(e,t){!i.isUndefined(e)&&i.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}function o(){var e;return"undefined"!=typeof XMLHttpRequest?e=n(8):"undefined"!=typeof process&&(e=n(8)),e}var i=n(2),s=n(7),u={"Content-Type":"application/x-www-form-urlencoded"},a={adapter:o(),transformRequest:[function(e,t){return s(t,"Content-Type"),i.isFormData(e)||i.isArrayBuffer(e)||i.isBuffer(e)||i.isStream(e)||i.isFile(e)||i.isBlob(e)?e:i.isArrayBufferView(e)?e.buffer:i.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):i.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};a.headers={common:{Accept:"application/json, text/plain, */*"}},i.forEach(["delete","get","head"],function(e){a.headers[e]={}}),i.forEach(["post","put","patch"],function(e){a.headers[e]=i.merge(u)}),e.exports=a},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(9),i=n(12),s=n(13),u=n(14),a=n(10),c="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(15);e.exports=function(e){return new Promise(function(t,f){var p=e.data,d=e.headers;r.isFormData(p)&&delete d["Content-Type"];var l=new XMLHttpRequest,h="onreadystatechange",m=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in l||u(e.url)||(l=new window.XDomainRequest,h="onload",m=!0,l.onprogress=function(){},l.ontimeout=function(){}),e.auth){var y=e.auth.username||"",w=e.auth.password||"";d.Authorization="Basic "+c(y+":"+w)}if(l.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l[h]=function(){if(l&&(4===l.readyState||m)&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in l?s(l.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?l.response:l.responseText,i={data:r,status:1223===l.status?204:l.status,statusText:1223===l.status?"No Content":l.statusText,headers:n,config:e,request:l};o(t,f,i),l=null}},l.onerror=function(){f(a("Network Error",e,null,l)),l=null},l.ontimeout=function(){f(a("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",l)),l=null},r.isStandardBrowserEnv()){var g=n(16),v=(e.withCredentials||u(e.url))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;v&&(d[e.xsrfHeaderName]=v)}if("setRequestHeader"in l&&r.forEach(d,function(e,t){"undefined"==typeof p&&"content-type"===t.toLowerCase()?delete d[t]:l.setRequestHeader(t,e)}),e.withCredentials&&(l.withCredentials=!0),e.responseType)try{l.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&l.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){l&&(l.abort(),f(e),l=null)}),void 0===p&&(p=null),l.send(p)})}},function(e,t,n){"use strict";var r=n(10);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(11);e.exports=function(e,t,n,o,i){var s=new Error(e);return r(s,t,n,o,i)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e}},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(2);e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(o.isURLSearchParams(t))i=t.toString();else{var s=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)&&(t+="[]"),o.isArray(e)||(e=[e]),o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),s.push(r(t)+"="+r(e))}))}),i=s.join("&")}return i&&(e+=(e.indexOf("?")===-1?"?":"&")+i),e}},function(e,t,n){"use strict";var r=n(2),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;"set-cookie"===t?s[t]=(s[t]?s[t]:[]).concat([n]):s[t]=s[t]?s[t]+", "+n:n}}),s):s}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t){"use strict";function n(){this.message="String contains an invalid character"}function r(e){for(var t,r,i=String(e),s="",u=0,a=o;i.charAt(0|u)||(a="=",u%1);s+=a.charAt(63&t>>8-u%1*8)){if(r=i.charCodeAt(u+=.75),r>255)throw new n;t=t<<8|r}return s}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",e.exports=r},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,i,s){var u=[];u.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&u.push("expires="+new Date(n).toGMTString()),r.isString(o)&&u.push("path="+o),r.isString(i)&&u.push("domain="+i),s===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(2);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t,n){"use strict";function r(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var o=n(2),i=n(19),s=n(20),u=n(6),a=n(21),c=n(22);e.exports=function(e){r(e),e.baseURL&&!a(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=e.adapter||u.adapter;return t(e).then(function(t){return r(e),t.data=i(t.data,t.headers,e.transformResponse),t},function(t){return s(t)||(r(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])});
9
//# sourceMappingURL=axios.min.map