-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07646c7
commit 460d2fd
Showing
23 changed files
with
50,221 additions
and
6,262 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/19014786f71a82c2ed340ac78c5432e2.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/213fc9aa70bc329f6e3c380e96d3556a.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"ast":null,"code":"import _Spin from \"antd/lib/spin\";\nimport _Select from \"antd/lib/select\";\nimport React from \"react\";\nvar __jsx = React.createElement;\nimport { useState, useCallback, useRef } from 'react';\nimport api from '../lib/api';\nimport debounce from 'lodash/debounce';\nconst {\n Option\n} = _Select;\nexport default function SearchUser({\n onChange,\n value\n}) {\n // {current: 0}\n const lastFetchIdRef = useRef(0);\n const {\n 0: fetching,\n 1: setFetching\n } = useState(false);\n const {\n 0: options,\n 1: setOptions\n } = useState([]);\n\n const handleChange = value => {\n setOptions([]);\n setFetching(false);\n onChange(value);\n };\n\n const fetchUser = useCallback(debounce(value => {\n lastFetchIdRef.current += 1;\n const fetchId = lastFetchIdRef.current;\n setFetching(true);\n setOptions([]);\n api.request({\n url: `/search/users?q=${value}`\n }).then(resp => {\n console.log('user:', resp);\n\n if (fetchId !== lastFetchIdRef.current) {\n return;\n }\n\n const data = resp.data.items.map(user => ({\n text: user.login,\n value: user.login\n }));\n setFetching(false);\n setOptions(data);\n });\n }, 500), []); //输入0.5秒后再请求\n\n return __jsx(_Select, {\n value: value,\n showSearch: true,\n notFoundContent: fetching ? __jsx(_Spin, {\n size: \"small\"\n }) : __jsx(\"span\", null, \"Not Found\"),\n filterOption: false,\n placeholder: \"search user\",\n allowClear: true,\n onSearch: fetchUser,\n onChange: handleChange,\n style: {\n width: 200\n }\n }, options.map(op => __jsx(Option, {\n value: op.value,\n key: op.value\n }, op.text)));\n}","map":{"version":3,"sources":["D:/编程/项目/next项目/next-github/components/SearchUser.jsx"],"names":["useState","useCallback","useRef","api","debounce","Option","SearchUser","onChange","value","lastFetchIdRef","fetching","setFetching","options","setOptions","handleChange","fetchUser","current","fetchId","request","url","then","resp","console","log","data","items","map","user","text","login","width","op"],"mappings":";;;;AACA,SAASA,QAAT,EAAmBC,WAAnB,EAAgCC,MAAhC,QAA8C,OAA9C;AACA,OAAOC,GAAP,MAAgB,YAAhB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AAEA,MAAM;AAAEC,EAAAA;AAAF,WAAN;AAEA,eAAe,SAASC,UAAT,CAAoB;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAApB,EAAyC;AACpD;AACA,QAAMC,cAAc,GAAGP,MAAM,CAAC,CAAD,CAA7B;AACA,QAAM;AAAA,OAACQ,QAAD;AAAA,OAAWC;AAAX,MAA0BX,QAAQ,CAAC,KAAD,CAAxC;AACA,QAAM;AAAA,OAACY,OAAD;AAAA,OAAUC;AAAV,MAAwBb,QAAQ,CAAC,EAAD,CAAtC;;AAEA,QAAMc,YAAY,GAAIN,KAAD,IAAW;AAC5BK,IAAAA,UAAU,CAAC,EAAD,CAAV;AACAF,IAAAA,WAAW,CAAC,KAAD,CAAX;AACAJ,IAAAA,QAAQ,CAACC,KAAD,CAAR;AACH,GAJD;;AAMA,QAAMO,SAAS,GAAGd,WAAW,CAACG,QAAQ,CAACI,KAAK,IAAI;AAC5CC,IAAAA,cAAc,CAACO,OAAf,IAA0B,CAA1B;AACA,UAAMC,OAAO,GAAGR,cAAc,CAACO,OAA/B;AACAL,IAAAA,WAAW,CAAC,IAAD,CAAX;AACAE,IAAAA,UAAU,CAAC,EAAD,CAAV;AAEAV,IAAAA,GAAG,CAACe,OAAJ,CAAY;AACRC,MAAAA,GAAG,EAAG,mBAAkBX,KAAM;AADtB,KAAZ,EAGCY,IAHD,CAGMC,IAAI,IAAI;AACVC,MAAAA,OAAO,CAACC,GAAR,CAAY,OAAZ,EAAqBF,IAArB;;AACA,UAAIJ,OAAO,KAAKR,cAAc,CAACO,OAA/B,EAAwC;AACpC;AACH;;AACD,YAAMQ,IAAI,GAAGH,IAAI,CAACG,IAAL,CAAUC,KAAV,CAAgBC,GAAhB,CAAoBC,IAAI,KAAK;AACtCC,QAAAA,IAAI,EAAED,IAAI,CAACE,KAD2B;AAEtCrB,QAAAA,KAAK,EAAEmB,IAAI,CAACE;AAF0B,OAAL,CAAxB,CAAb;AAIAlB,MAAAA,WAAW,CAAC,KAAD,CAAX;AACAE,MAAAA,UAAU,CAACW,IAAD,CAAV;AACH,KAdD;AAeH,GArBqC,EAqBnC,GArBmC,CAAT,EAqBpB,EArBoB,CAA7B,CAZoD,CAiCtC;;AAEd,SACI;AACI,IAAA,KAAK,EAAEhB,KADX;AAEI,IAAA,UAAU,EAAE,IAFhB;AAGI,IAAA,eAAe,EAAEE,QAAQ,GAAG;AAAM,MAAA,IAAI,EAAC;AAAX,MAAH,GAA2B,gCAHxD;AAII,IAAA,YAAY,EAAE,KAJlB;AAKI,IAAA,WAAW,EAAC,aALhB;AAMI,IAAA,UAAU,EAAE,IANhB;AAOI,IAAA,QAAQ,EAAEK,SAPd;AAQI,IAAA,QAAQ,EAAED,YARd;AASI,IAAA,KAAK,EAAE;AAAEgB,MAAAA,KAAK,EAAE;AAAT;AATX,KAYQlB,OAAO,CAACc,GAAR,CAAYK,EAAE,IACV,MAAC,MAAD;AAAQ,IAAA,KAAK,EAAEA,EAAE,CAACvB,KAAlB;AAAyB,IAAA,GAAG,EAAEuB,EAAE,CAACvB;AAAjC,KACKuB,EAAE,CAACH,IADR,CADJ,CAZR,CADJ;AAqBH","sourcesContent":["import { Select, Spin } from 'antd'\r\nimport { useState, useCallback, useRef } from 'react';\r\nimport api from '../lib/api'\r\nimport debounce from 'lodash/debounce'\r\n\r\nconst { Option } = Select;\r\n\r\nexport default function SearchUser({ onChange, value }) {\r\n // {current: 0}\r\n const lastFetchIdRef = useRef(0);\r\n const [fetching, setFetching] = useState(false);\r\n const [options, setOptions] = useState([]);\r\n\r\n const handleChange = (value) => {\r\n setOptions([]);\r\n setFetching(false);\r\n onChange(value);\r\n }\r\n\r\n const fetchUser = useCallback(debounce(value => {\r\n lastFetchIdRef.current += 1;\r\n const fetchId = lastFetchIdRef.current;\r\n setFetching(true);\r\n setOptions([]);\r\n\r\n api.request({\r\n url: `/search/users?q=${value}`\r\n })\r\n .then(resp => {\r\n console.log('user:', resp)\r\n if (fetchId !== lastFetchIdRef.current) {\r\n return;\r\n }\r\n const data = resp.data.items.map(user => ({\r\n text: user.login,\r\n value: user.login\r\n }))\r\n setFetching(false);\r\n setOptions(data);\r\n })\r\n }, 500), []); //输入0.5秒后再请求\r\n\r\n return (\r\n <Select \r\n value={value}\r\n showSearch={true}\r\n notFoundContent={fetching ? <Spin size=\"small\" /> : <span>Not Found</span>}\r\n filterOption={false}\r\n placeholder=\"search user\"\r\n allowClear={true}\r\n onSearch={fetchUser}\r\n onChange={handleChange}\r\n style={{ width: 200 }}\r\n >\r\n {\r\n options.map(op => (\r\n <Option value={op.value} key={op.value}>\r\n {op.text}\r\n </Option>\r\n ))\r\n }\r\n </Select>\r\n )\r\n}"]},"metadata":{},"sourceType":"module"} |
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/3a60eec1f7bbae0115d5550432a7338a.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/3ee109c30be765623851a8451aa4bfcb.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/4c14ce6ad88df64338520cdc8766b793.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/6f82d781f1381fb376b0da09180b0f65.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/7e6e882a7d423b4dbd6ba6de3ac3eae8.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/9396be51bf38d959acf3314f5e4679c4.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"ast":null,"code":"import _Spin from \"antd/lib/spin\";\nimport _Select from \"antd/lib/select\";\nimport React from \"react\";\nvar __jsx = React.createElement;\nimport { useState, useCallback, useRef } from 'react';\nimport api from '../lib/api';\nimport debounce from 'lodash/debounce';\nvar Option = _Select.Option;\nexport default function SearchUser(_ref) {\n var onChange = _ref.onChange,\n value = _ref.value;\n // {current: 0}\n var lastFetchIdRef = useRef(0);\n\n var _useState = useState(false),\n fetching = _useState[0],\n setFetching = _useState[1];\n\n var _useState2 = useState([]),\n options = _useState2[0],\n setOptions = _useState2[1];\n\n var handleChange = function handleChange(value) {\n setOptions([]);\n setFetching(false);\n onChange(value);\n };\n\n var fetchUser = useCallback(debounce(function (value) {\n lastFetchIdRef.current += 1;\n var fetchId = lastFetchIdRef.current;\n setFetching(true);\n setOptions([]);\n api.request({\n url: \"/search/users?q=\".concat(value)\n }).then(function (resp) {\n console.log('user:', resp);\n\n if (fetchId !== lastFetchIdRef.current) {\n return;\n }\n\n var data = resp.data.items.map(function (user) {\n return {\n text: user.login,\n value: user.login\n };\n });\n setFetching(false);\n setOptions(data);\n });\n }, 500), []); //输入0.5秒后再请求\n\n return __jsx(_Select, {\n value: value,\n showSearch: true,\n notFoundContent: fetching ? __jsx(_Spin, {\n size: \"small\"\n }) : __jsx(\"span\", null, \"Not Found\"),\n filterOption: false,\n placeholder: \"search user\",\n allowClear: true,\n onSearch: fetchUser,\n onChange: handleChange,\n style: {\n width: 200\n }\n }, options.map(function (op) {\n return __jsx(Option, {\n value: op.value,\n key: op.value\n }, op.text);\n }));\n}","map":{"version":3,"sources":["D:/编程/项目/next项目/next-github/components/SearchUser.jsx"],"names":["useState","useCallback","useRef","api","debounce","Option","SearchUser","onChange","value","lastFetchIdRef","fetching","setFetching","options","setOptions","handleChange","fetchUser","current","fetchId","request","url","then","resp","console","log","data","items","map","user","text","login","width","op"],"mappings":";;;;AACA,SAASA,QAAT,EAAmBC,WAAnB,EAAgCC,MAAhC,QAA8C,OAA9C;AACA,OAAOC,GAAP,MAAgB,YAAhB;AACA,OAAOC,QAAP,MAAqB,iBAArB;IAEQC,M,WAAAA,M;AAER,eAAe,SAASC,UAAT,OAAyC;AAAA,MAAnBC,QAAmB,QAAnBA,QAAmB;AAAA,MAATC,KAAS,QAATA,KAAS;AACpD;AACA,MAAMC,cAAc,GAAGP,MAAM,CAAC,CAAD,CAA7B;;AAFoD,kBAGpBF,QAAQ,CAAC,KAAD,CAHY;AAAA,MAG7CU,QAH6C;AAAA,MAGnCC,WAHmC;;AAAA,mBAItBX,QAAQ,CAAC,EAAD,CAJc;AAAA,MAI7CY,OAJ6C;AAAA,MAIpCC,UAJoC;;AAMpD,MAAMC,YAAY,GAAG,SAAfA,YAAe,CAACN,KAAD,EAAW;AAC5BK,IAAAA,UAAU,CAAC,EAAD,CAAV;AACAF,IAAAA,WAAW,CAAC,KAAD,CAAX;AACAJ,IAAAA,QAAQ,CAACC,KAAD,CAAR;AACH,GAJD;;AAMA,MAAMO,SAAS,GAAGd,WAAW,CAACG,QAAQ,CAAC,UAAAI,KAAK,EAAI;AAC5CC,IAAAA,cAAc,CAACO,OAAf,IAA0B,CAA1B;AACA,QAAMC,OAAO,GAAGR,cAAc,CAACO,OAA/B;AACAL,IAAAA,WAAW,CAAC,IAAD,CAAX;AACAE,IAAAA,UAAU,CAAC,EAAD,CAAV;AAEAV,IAAAA,GAAG,CAACe,O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} from 'antd'\r\nimport { useState, useCallback, useRef } from 'react';\r\nimport api from '../lib/api'\r\nimport debounce from 'lodash/debounce'\r\n\r\nconst { Option } = Select;\r\n\r\nexport default function SearchUser({ onChange, value }) {\r\n // {current: 0}\r\n const lastFetchIdRef = useRef(0);\r\n const [fetching, setFetching] = useState(false);\r\n const [options, setOptions] = useState([]);\r\n\r\n const handleChange = (value) => {\r\n setOptions([]);\r\n setFetching(false);\r\n onChange(value);\r\n }\r\n\r\n const fetchUser = useCallback(debounce(value => {\r\n lastFetchIdRef.current += 1;\r\n const fetchId = lastFetchIdRef.current;\r\n setFetching(true);\r\n setOptions([]);\r\n\r\n api.request({\r\n url: `/search/users?q=${value}`\r\n })\r\n .then(resp => {\r\n console.log('user:', resp)\r\n if (fetchId !== lastFetchIdRef.current) {\r\n return;\r\n }\r\n const data = resp.data.items.map(user => ({\r\n text: user.login,\r\n value: user.login\r\n }))\r\n setFetching(false);\r\n setOptions(data);\r\n })\r\n }, 500), []); //输入0.5秒后再请求\r\n\r\n return (\r\n <Select \r\n value={value}\r\n showSearch={true}\r\n notFoundContent={fetching ? <Spin size=\"small\" /> : <span>Not Found</span>}\r\n filterOption={false}\r\n placeholder=\"search user\"\r\n allowClear={true}\r\n onSearch={fetchUser}\r\n onChange={handleChange}\r\n style={{ width: 200 }}\r\n >\r\n {\r\n options.map(op => (\r\n <Option value={op.value} key={op.value}>\r\n {op.text}\r\n </Option>\r\n ))\r\n }\r\n </Select>\r\n )\r\n}"]},"metadata":{},"sourceType":"module"} |
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/9486b2e3e07b78660036067117ca5f12.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/9cc571e3b45df03658557b87f65cb1eb.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/c819197a368e50412218ad1aa3fc7f0f.json
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.next/cache/next-babel-loader/efb48bcd4af2a35e6d5bceeeda16b58b.json
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.