├── .eslintrc.cjs ├── .gitignore ├── .prettierignore ├── .prettierrc ├── LICENSE ├── README.md ├── functions └── api │ └── [[routes]].ts ├── index.html ├── lib └── hono │ ├── SQL │ ├── clipBoard.sql │ ├── friendSites.sql │ └── users.sql │ ├── clipboard-cleaner │ ├── index.d.ts │ └── index.js │ ├── index.ts │ ├── middleware │ └── errorHandle.ts │ ├── service │ ├── clipboardService.ts │ ├── friendSiteService.ts │ ├── siteService.ts │ └── userService.ts │ ├── types │ └── index.ts │ └── utils │ ├── encrypt.ts │ ├── sign.ts │ └── test.mjs ├── package.json ├── pnpm-lock.yaml ├── public ├── favicon.ico └── manifest.json ├── src ├── App.css ├── App.tsx ├── assets │ ├── baidu.png │ ├── bbs.png │ ├── copy.png │ ├── delete.png │ ├── github-light.png │ ├── github.png │ ├── googlefanyi.png │ ├── jd.png │ ├── new.png │ ├── qq.png │ ├── qqmail.png │ ├── react.svg │ ├── red_packet.png │ ├── red_packet_m.png │ ├── taobao.png │ ├── wangyiyun.png │ ├── weibo.png │ └── zhihu.png ├── component │ ├── FeaturePanel │ │ ├── index.css │ │ └── index.tsx │ ├── Footer │ │ ├── Footer.tsx │ │ └── index.css │ ├── FriendSite │ │ ├── FriendSite.tsx │ │ ├── dark.css │ │ └── index.css │ ├── GlobalMessage │ │ └── GlobalMessage.tsx │ ├── GyDialog │ │ ├── AddSiteDialog.tsx │ │ └── GyDialog.tsx │ ├── HeadBar │ │ ├── HeadBar.tsx │ │ ├── dark.css │ │ ├── index.css │ │ └── utils.ts │ ├── MarginHead │ │ ├── MarginHead.tsx │ │ └── index.css │ ├── Partition │ │ ├── Partition.tsx │ │ ├── dark.css │ │ └── index.css │ ├── PopularSite │ │ ├── PopularSite.tsx │ │ ├── dark.css │ │ └── index.css │ └── site │ │ ├── Site.tsx │ │ ├── dark.css │ │ └── index.css ├── index.css ├── main.tsx ├── pages │ ├── Home.tsx │ ├── Login.tsx │ ├── NotFound.tsx │ ├── home.css │ └── login.css ├── redux │ ├── actions.ts │ ├── middleware │ │ └── handlePart.ts │ ├── reducer.ts │ ├── store.ts │ └── types │ │ └── index.ts ├── router │ └── router.tsx ├── utils │ ├── Api.ts │ ├── DoubleClick.ts │ ├── EventEmitter.ts │ ├── Events.ts │ ├── SearchMarchine.ts │ ├── clipboard.ts │ ├── data.ts │ ├── debounce.ts │ ├── device.ts │ ├── http.ts │ ├── localStorageUtil.ts │ ├── throttle.ts │ └── veriLink.ts └── vite-env.d.ts ├── tsconfig.app.json ├── tsconfig.json ├── tsconfig.node.json ├── vite.config.ts └── wrangler.toml /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: [ 5 | 'eslint:recommended', 6 | 'plugin:@typescript-eslint/recommended', 7 | 'plugin:react-hooks/recommended', 8 | ], 9 | ignorePatterns: ['dist', '.eslintrc.cjs'], 10 | parser: '@typescript-eslint/parser', 11 | plugins: ['react-refresh'], 12 | rules: { 13 | 'react-refresh/only-export-components': [ 14 | 'warn', 15 | { allowConstantExport: true }, 16 | ], 17 | }, 18 | }; 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | .wrangler 11 | node_modules 12 | build 13 | dist 14 | dist-ssr 15 | *.local 16 | 17 | # Editor directories and files 18 | .vscode/* 19 | !.vscode/extensions.json 20 | .idea 21 | .DS_Store 22 | *.suo 23 | *.ntvs* 24 | *.njsproj 25 | *.sln 26 | *.sw? 27 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "printWidth": 80, 6 | "tabWidth": 2, 7 | "endOfLine": "lf" 8 | } 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React + TypeScript + Vite 2 | 3 | This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. 4 | 5 | Currently, two official plugins are available: 6 | 7 | - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh 8 | - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh 9 | 10 | ## Expanding the ESLint configuration 11 | 12 | If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: 13 | 14 | - Configure the top-level `parserOptions` property like this: 15 | 16 | ```js 17 | export default { 18 | // other rules... 19 | parserOptions: { 20 | ecmaVersion: 'latest', 21 | sourceType: 'module', 22 | project: ['./tsconfig.json', './tsconfig.node.json'], 23 | tsconfigRootDir: __dirname, 24 | }, 25 | }; 26 | ``` 27 | 28 | - Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` 29 | - Optionally add `plugin:@typescript-eslint/stylistic-type-checked` 30 | - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list 31 | -------------------------------------------------------------------------------- /functions/api/[[routes]].ts: -------------------------------------------------------------------------------- 1 | import { handle } from 'hono/cloudflare-pages'; 2 | import app from '../../lib/hono'; 3 | 4 | export const onRequest = handle(app); 5 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | 18 | 22 | 27 | 32 | 33 | 34 | 35 | 36 | 37 | GY导航 38 | 39 | 40 | 41 |
42 | 43 | 44 | 53 | 54 | -------------------------------------------------------------------------------- /lib/hono/SQL/clipBoard.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE clipboard ( 2 | id INTEGER PRIMARY KEY AUTOINCREMENT, 3 | user_id INTEGER NOT NULL, 4 | content TEXT NOT NULL, 5 | created_at DATETIME DEFAULT CURRENT_TIMESTAMP, 6 | updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, 7 | expires_at DATETIME NOT NULL 8 | ); 9 | -------------------------------------------------------------------------------- /lib/hono/SQL/friendSites.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE friendSites ( 2 | id INTEGER PRIMARY KEY AUTOINCREMENT, 3 | site_name TEXT NOT NULL, 4 | url TEXT NOT NULL 5 | ); 6 | -------------------------------------------------------------------------------- /lib/hono/SQL/users.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE users ( 2 | id INTEGER PRIMARY KEY AUTOINCREMENT, 3 | userName TEXT UNIQUE NOT NULL, 4 | passWord TEXT NOT NULL, 5 | emailAddr TEXT, 6 | verifyCode TEXT, 7 | outDate DATETIME, 8 | partData TEXT, 9 | partModifyDate DATETIME 10 | ); 11 | -------------------------------------------------------------------------------- /lib/hono/clipboard-cleaner/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Ctx } from '../types'; 2 | 3 | declare module 'index' { 4 | export async function scheduled( 5 | event: any, 6 | env: Ctx['env'], 7 | ctx: Ctx 8 | ): Promise; 9 | } 10 | -------------------------------------------------------------------------------- /lib/hono/clipboard-cleaner/index.js: -------------------------------------------------------------------------------- 1 | export default { 2 | async scheduled(event, env, ctx) { 3 | const db = env.DB; 4 | try { 5 | await db 6 | .prepare('DELETE FROM clipboard WHERE expires_at < CURRENT_TIMESTAMP') 7 | .run(); 8 | console.log('Expired clipboard content cleaned up successfully'); 9 | } catch (error) { 10 | console.error('Failed to clean up expired clipboard content', error); 11 | } 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /lib/hono/index.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono'; 2 | 3 | import { jwt } from 'hono/jwt'; 4 | 5 | import { Bindings } from './types'; 6 | import errorHandle from './middleware/errorHandle'; 7 | 8 | import UserService from './service/userService'; 9 | import SiteService from './service/siteService'; 10 | import FriendSiteService from './service/friendSiteService'; 11 | import ClipboardService from './service/clipboardService'; 12 | 13 | const app = new Hono<{ Bindings: Bindings }>(); 14 | 15 | const authFreeSet = new Set(['/api/login', '/api/signup', '/api/getAllFS']); 16 | 17 | app.use('/api/*', (c, next) => { 18 | if (authFreeSet.has(c.req.path)) { 19 | return next(); 20 | } 21 | 22 | const jwtMiddleware = jwt({ 23 | secret: c.env.TokenSecret, 24 | }); 25 | return jwtMiddleware(c, next); 26 | }); 27 | 28 | app.use(errorHandle); 29 | 30 | app.post('/api/login', async (ctx) => { 31 | const body = await ctx.req.parseBody(); 32 | const { userName, passWord } = body as any; 33 | 34 | // 检查是否提供了用户名和密码 35 | if (!userName || !passWord) { 36 | return ctx.json( 37 | { result: false, msg: 'Username and password are required' }, 38 | 400 39 | ); 40 | } 41 | 42 | return await UserService.login(ctx, { passWord, userName }); 43 | }); 44 | 45 | app.post('/api/signup', async (ctx) => { 46 | const body = await ctx.req.parseBody(); 47 | const { userName, passWord, partData } = body as any; 48 | 49 | // 检查是否提供了用户名和密码 50 | if (!userName || !passWord || !partData) { 51 | return ctx.json( 52 | { result: false, msg: 'Username and passWord are required' }, 53 | 400 54 | ); 55 | } 56 | return await UserService.signUp(ctx, { userName, passWord, partData }); 57 | }); 58 | 59 | app.post('/api/getPartData', async (ctx) => { 60 | return await SiteService.getPartData(ctx); 61 | }); 62 | 63 | app.post('/api/upPartData', async (ctx) => { 64 | const body = await ctx.req.parseBody(); 65 | const { partData } = body as any; 66 | 67 | // 检查是否提供了 partData 68 | if (!partData) { 69 | return ctx.json({ result: false, msg: 'partData is required' }); 70 | } 71 | 72 | return await SiteService.updatePartData(ctx, { partData }); 73 | }); 74 | 75 | app.post('/api/veriToken', async (ctx) => { 76 | return ctx.json({ result: true }); 77 | }); 78 | 79 | app.get('/api/getAllFS', async (ctx) => { 80 | return await FriendSiteService.getAllFSite(ctx); 81 | }); 82 | 83 | app.post('/api/writeClipBoard', async (ctx) => { 84 | const [body] = await Promise.all([ctx.req.parseBody()]); 85 | const { clipboardString } = body as any; 86 | 87 | if (!clipboardString) { 88 | return ctx.json({ result: false, msg: 'clipboardString is required' }, 400); 89 | } 90 | 91 | return await ClipboardService.writeClipBoard(ctx, { clipboardString }); 92 | }); 93 | 94 | app.post('/api/getClipBoard', async (ctx) => { 95 | return await ClipboardService.getClipBoard(ctx); 96 | }); 97 | 98 | export default app; 99 | -------------------------------------------------------------------------------- /lib/hono/middleware/errorHandle.ts: -------------------------------------------------------------------------------- 1 | import { Ctx } from '../types'; 2 | 3 | import { Next } from 'hono'; 4 | 5 | const errorHandle = async (ctx: Ctx, next: Next) => { 6 | return next().catch((err: any) => { 7 | if (err.status === 401) { 8 | // ctx.status = 401 9 | // ctx.body = { 10 | // message: '尚未登陆', 11 | // type: 'error', 12 | // } 13 | } else if (err.status === 403) { 14 | // ctx.status = 403 15 | // ctx.body = { 16 | // message: 'Token失效', 17 | // type: 'error', 18 | // } 19 | } else { 20 | throw err; 21 | } 22 | }); 23 | }; 24 | export default errorHandle; 25 | -------------------------------------------------------------------------------- /lib/hono/service/clipboardService.ts: -------------------------------------------------------------------------------- 1 | import { Ctx } from '../types'; 2 | 3 | import scheduled from '../clipboard-cleaner'; 4 | 5 | const scheduledDeleteClip = (scheduled as any).scheduled; 6 | 7 | import { encryptData, decryptData } from '../utils/encrypt'; 8 | 9 | export default class ClipboardService { 10 | public static writeClipBoard = async ( 11 | ctx: Ctx, 12 | { clipboardString }: { clipboardString: string } 13 | ) => { 14 | try { 15 | const payloadJson = ctx.get('jwtPayload'); 16 | // const payloadJson = JSON.parse(payload); 17 | const db = ctx.env.DB; 18 | 19 | const dataSecretKey = ctx.env.DataSecretKey; 20 | 21 | await scheduledDeleteClip(null, ctx.env, ctx); 22 | 23 | // 计算剪切板内容的过期时间 (当前时间加上 5 分钟) 24 | const expiresAt = new Date(Date.now() + 5 * 60 * 1000).toISOString(); 25 | 26 | const result = await db 27 | .prepare( 28 | 'INSERT INTO clipboard (user_id, content, expires_at) VALUES (?, ?, ?)' 29 | ) 30 | .bind( 31 | payloadJson.user.id, 32 | JSON.stringify( 33 | await encryptData( 34 | clipboardString, 35 | `${dataSecretKey}-${payloadJson.user.id}` 36 | ) 37 | ), 38 | expiresAt 39 | ) 40 | .run(); 41 | 42 | if (result.success) { 43 | return ctx.json({ 44 | result: true, 45 | msg: 'Clipboard content write successfully', 46 | }); 47 | } else { 48 | return ctx.json({ 49 | result: false, 50 | msg: 'Failed to write clipboard content', 51 | }); 52 | } 53 | } catch (error: any) { 54 | return ctx.json({ result: false, msg: error.message }, 500); 55 | } 56 | }; 57 | public static getClipBoard = async (ctx: Ctx) => { 58 | try { 59 | const dataSecretKey = ctx.env.DataSecretKey; 60 | const payloadJson = ctx.get('jwtPayload'); 61 | // const payloadJson = JSON.parse(payload); 62 | const db = ctx.env.DB; 63 | 64 | const now = new Date().toISOString(); 65 | const content = await db 66 | .prepare( 67 | 'SELECT content FROM clipboard WHERE user_id = ? AND expires_at > ? ORDER BY updated_at DESC LIMIT 1' 68 | ) 69 | .bind(payloadJson.user.id, now) 70 | .first(); 71 | 72 | if (!content) { 73 | return ctx.json({ 74 | result: false, 75 | data: '', 76 | msg: 'No valid clipboard content found', 77 | }); 78 | } 79 | 80 | const [data] = await Promise.all([ 81 | decryptData( 82 | JSON.parse(content.content as string), 83 | `${dataSecretKey}-${payloadJson.user.id}` 84 | ), 85 | scheduledDeleteClip(null, ctx.env, ctx), 86 | ]); 87 | 88 | return ctx.json({ result: true, data, msg: 'success' }); 89 | } catch (error: any) { 90 | return ctx.json({ result: false, msg: error.message }, 500); 91 | } 92 | }; 93 | } 94 | -------------------------------------------------------------------------------- /lib/hono/service/friendSiteService.ts: -------------------------------------------------------------------------------- 1 | import { Ctx, IFriendSite } from '../types'; 2 | 3 | export default class FriendSiteService { 4 | public static getAllFSite = async (ctx: Ctx) => { 5 | try { 6 | const db = ctx.env.DB; 7 | const sites = await db.prepare('SELECT * FROM friendSites').all(); 8 | const fsites = sites.results || []; 9 | fsites.push({ 10 | site_name: '友链申请', 11 | url: 'http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=zK2loLmjp7n6jL294q_joQ', 12 | }); 13 | 14 | return ctx.json({ result: true, fsites }); 15 | } catch (error: any) { 16 | return ctx.json({ result: false, msg: error.message }, 500); 17 | } 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /lib/hono/service/siteService.ts: -------------------------------------------------------------------------------- 1 | import { Ctx } from '../types'; 2 | 3 | export default class SiteService { 4 | public static getPartData = async (ctx: Ctx) => { 5 | try { 6 | const payloadJson = ctx.get('jwtPayload'); 7 | // const payloadJson = JSON.parse(payload); 8 | const db = ctx.env.DB; 9 | const user = await db 10 | .prepare('SELECT partData FROM users WHERE id = ?') 11 | .bind(payloadJson.user.id) 12 | .first(); 13 | 14 | if (!user) { 15 | return ctx.json({ result: false, msg: 'User not found' }); 16 | } 17 | 18 | return ctx.json({ result: true, partData: user.partData }); 19 | } catch (error: any) { 20 | return ctx.json({ result: false, msg: error.message }, 500); 21 | } 22 | }; 23 | public static updatePartData = async ( 24 | ctx: Ctx, 25 | { partData }: { partData: string } 26 | ) => { 27 | try { 28 | const payloadJson = ctx.get('jwtPayload'); 29 | // const payloadJson = JSON.parse(payload); 30 | const db = ctx.env.DB; 31 | 32 | const result = await db 33 | .prepare( 34 | 'UPDATE users SET partData = ?, partModifyDate = CURRENT_TIMESTAMP WHERE id = ?' 35 | ) 36 | .bind(partData, payloadJson.user.id) 37 | .run(); 38 | 39 | if (result.success) { 40 | return ctx.json({ result: true, msg: 'partData updated successfully' }); 41 | } else { 42 | return ctx.json({ result: false, msg: 'Failed to update partData' }); 43 | } 44 | } catch (error: any) { 45 | return ctx.json({ result: false, msg: error.message }, 500); 46 | } 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /lib/hono/service/userService.ts: -------------------------------------------------------------------------------- 1 | import { Ctx, IUser } from '../types'; 2 | 3 | import encrypt from '../utils/encrypt'; 4 | 5 | import { signToken } from '../utils/sign'; 6 | 7 | export default class UserService { 8 | public static login = async ( 9 | ctx: Ctx, 10 | { userName, passWord }: { userName: string; passWord: string } 11 | ) => { 12 | const tokenSecret = ctx.env.TokenSecret; 13 | 14 | try { 15 | const db = ctx.env.DB; 16 | const user = await db 17 | .prepare('SELECT * FROM users WHERE userName = ?') 18 | .bind(userName) 19 | .first(); 20 | 21 | if (!user) { 22 | return ctx.json({ result: false, msg: 'Invalid username or password' }); 23 | } 24 | 25 | const valiPass = await encrypt(passWord); 26 | 27 | // 验证密码 28 | const isPasswordValid = valiPass === user.passWord; 29 | if (!isPasswordValid) { 30 | return ctx.json({ result: false, msg: 'Invalid username or password' }); 31 | } 32 | 33 | const userToken = { 34 | id: user.id, 35 | userName: user.userName, 36 | // passWord: user.passWord, 37 | }; 38 | 39 | // 生成 JWT 40 | const token = await signToken({ user: userToken }, tokenSecret); 41 | 42 | return ctx.json({ 43 | result: true, 44 | user: { id: user.id, userName: user.userName, partData: user.partData }, 45 | msg: 'Login successful', 46 | token, 47 | }); 48 | } catch (error: any) { 49 | return ctx.json({ result: false, msg: error.message }, 500); 50 | } 51 | }; 52 | public static signUp = async ( 53 | ctx: Ctx, 54 | { 55 | userName, 56 | passWord, 57 | partData, 58 | }: { userName: string; passWord: string; partData: string | object } 59 | ) => { 60 | try { 61 | const tokenSecret = ctx.env.TokenSecret; 62 | 63 | // 加密密码 64 | const hashedPassword = await encrypt(passWord); 65 | 66 | const db = ctx.env.DB; 67 | const result = await db 68 | .prepare( 69 | 'INSERT INTO users (userName, passWord, partData) VALUES (?, ?, ?)' 70 | ) 71 | .bind( 72 | userName, 73 | hashedPassword, 74 | typeof partData === 'string' ? partData : JSON.stringify(partData) 75 | ) 76 | .run(); 77 | 78 | if (result.success) { 79 | // 获取新注册用户的ID 80 | const user = await db 81 | .prepare( 82 | 'SELECT id, userName, partData FROM users WHERE userName = ?' 83 | ) 84 | .bind(userName) 85 | .first(); 86 | if (user) { 87 | const userToken = { 88 | id: user.id, 89 | userName: user.userName, 90 | }; 91 | const token = await signToken({ user: userToken }, tokenSecret); 92 | return ctx.json({ result: true, user, msg: '', token }); 93 | } else { 94 | return ctx.json({ result: false, msg: 'User registration failed' }); 95 | } 96 | } else { 97 | return ctx.json({ result: false, msg: 'User registration failed' }); 98 | } 99 | } catch (error: any) { 100 | return ctx.json({ result: false, msg: error.message }); 101 | } 102 | }; 103 | } 104 | -------------------------------------------------------------------------------- /lib/hono/types/index.ts: -------------------------------------------------------------------------------- 1 | import { Context } from 'hono'; 2 | 3 | import { BlankInput } from 'hono/types'; 4 | 5 | export interface IFriendSite { 6 | site_name: string; 7 | url: string; 8 | } 9 | 10 | export interface IUser { 11 | userName: string; 12 | passWord: string; 13 | emailAddr: string; 14 | verifyCode: string; 15 | outDate: Date; 16 | partData: string; 17 | } 18 | 19 | export type Bindings = { 20 | // MY_KV: KVNamespace; 21 | DataSecretKey: string; 22 | PasswordSecret: string; 23 | TokenSecret: string; 24 | DB: D1Database; 25 | }; 26 | 27 | export type Ctx

= Context< 28 | { 29 | Bindings: Bindings; 30 | }, 31 | P, 32 | BlankInput 33 | >; 34 | -------------------------------------------------------------------------------- /lib/hono/utils/encrypt.ts: -------------------------------------------------------------------------------- 1 | async function sha1Hash(message: string) { 2 | const encoder = new TextEncoder(); 3 | const data = encoder.encode(message); 4 | const hashBuffer = await crypto.subtle.digest('SHA-1', data); 5 | const hashArray = Array.from(new Uint8Array(hashBuffer)); // 转换为字节数组 6 | const hashHex = hashArray 7 | .map((b) => b.toString(16).padStart(2, '0')) 8 | .join(''); // 转换为十六进制字符串 9 | return hashHex; 10 | } 11 | 12 | const encrypt = async (str: string) => { 13 | const res = await sha1Hash(await sha1Hash(str)); 14 | return res; 15 | }; 16 | 17 | const iv = new Uint8Array([21, 34, 56, 78, 90, 12, 43, 56, 78, 90, 11, 22]); 18 | 19 | async function convertKeyToFixedBits(secretKey: string) { 20 | const encoder = new TextEncoder(); 21 | const encodedKey = encoder.encode(secretKey); 22 | const hashBuffer = await crypto.subtle.digest('SHA-256', encodedKey); 23 | const hashArray = Array.from(new Uint8Array(hashBuffer)); 24 | const hashHex = hashArray 25 | .map((b) => b.toString(16).padStart(2, '0')) 26 | .join(''); 27 | return hashHex.substring(0, 32); 28 | // return hashHex; 29 | } 30 | 31 | export const encryptData = async (text: string, secretKey: string) => { 32 | const enc = new TextEncoder(); 33 | const encodedKey = enc.encode(await convertKeyToFixedBits(secretKey)); 34 | 35 | const key = await crypto.subtle.importKey( 36 | 'raw', 37 | encodedKey, 38 | { name: 'AES-GCM', length: 256 }, 39 | false, 40 | ['encrypt'] 41 | ); 42 | 43 | // const iv = crypto.getRandomValues(new Uint8Array(12)); 44 | const encodedText = enc.encode(text); 45 | const encryptedData = await crypto.subtle.encrypt( 46 | { name: 'AES-GCM', iv }, 47 | key, 48 | encodedText 49 | ); 50 | 51 | const buffer = new Uint8Array(encryptedData); 52 | const hexIv = Array.from(iv) 53 | .map((b) => b.toString(16).padStart(2, '0')) 54 | .join(''); 55 | const hexContent = Array.from(buffer) 56 | .map((b) => b.toString(16).padStart(2, '0')) 57 | .join(''); 58 | 59 | return { iv: hexIv, content: hexContent }; 60 | }; 61 | 62 | export const decryptData = async ( 63 | hash: { iv: string; content: string }, 64 | secretKey: string 65 | ) => { 66 | const dec = new TextDecoder(); 67 | const enc = new TextEncoder(); 68 | // const encodedKey = enc.encode(secretKey); 69 | const encodedKey = enc.encode(await convertKeyToFixedBits(secretKey)); 70 | const key = await crypto.subtle.importKey( 71 | 'raw', 72 | encodedKey, 73 | { name: 'AES-GCM', length: 256 }, 74 | false, 75 | ['decrypt'] 76 | ); 77 | 78 | const iv = new Uint8Array( 79 | (hash.iv.match(/.{1,2}/g) || []).map((byte) => parseInt(byte, 16)) 80 | ); 81 | const encryptedData = new Uint8Array( 82 | (hash.content.match(/.{1,2}/g) || []).map((byte) => parseInt(byte, 16)) 83 | ); 84 | 85 | const decryptedData = await crypto.subtle.decrypt( 86 | { name: 'AES-GCM', iv }, 87 | key, 88 | encryptedData 89 | ); 90 | 91 | return dec.decode(decryptedData); 92 | }; 93 | 94 | export default encrypt; 95 | -------------------------------------------------------------------------------- /lib/hono/utils/sign.ts: -------------------------------------------------------------------------------- 1 | import { sign } from 'hono/jwt'; 2 | 3 | export const signToken = (data: any, key: string) => { 4 | const time = Math.floor(new Date().getTime() / 1000); 5 | const expTime = time + 30 * 24 * 60 * 60; 6 | return sign({ ...data, exp: expTime, iat: time }, key); 7 | }; 8 | -------------------------------------------------------------------------------- /lib/hono/utils/test.mjs: -------------------------------------------------------------------------------- 1 | import crypto, { createHash } from 'crypto'; 2 | import { encryptData, decryptData } from './encrypt'; 3 | 4 | const encryp = (algorithm, content) => { 5 | let hash = createHash(algorithm); 6 | hash.update(content); 7 | return hash.digest('hex'); 8 | }; 9 | 10 | const sha1 = (content) => { 11 | return encryp('sha1', content); 12 | }; 13 | 14 | const encrypt = (str) => { 15 | return sha1(sha1(str)); 16 | }; 17 | 18 | console.info('--------', encrypt('test123fgy')); 19 | 20 | (async () => { 21 | console.log('start!!'); 22 | // 测试数据 23 | const secretKey = 'my-secret-key'; 24 | const originalText = 'Hello, world!'; 25 | 26 | try { 27 | // 加密 28 | const encryptedData = await encryptData(originalText, secretKey); 29 | console.log('加密后的数据:', encryptedData); 30 | 31 | // 解密 32 | const decryptedText = await decryptData(encryptedData, secretKey); 33 | console.log('解密后的文本:', decryptedText); 34 | 35 | // 验证是否与原始文本一致 36 | if (decryptedText === originalText) { 37 | console.log('解密成功!'); 38 | } else { 39 | console.log('解密失败!'); 40 | } 41 | } catch (error) { 42 | console.log('error', error); 43 | } 44 | })(); 45 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-vite-app", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc -b && vite build && cp -r functions build/ && cp -r lib build/", 9 | "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", 10 | "preview": "vite preview", 11 | "preview-api": "npm run build && wrangler pages dev" 12 | }, 13 | "dependencies": { 14 | "@emotion/react": "^11.11.4", 15 | "@emotion/styled": "^11.11.5", 16 | "@mui/icons-material": "^5.15.20", 17 | "@mui/material": "^5.15.20", 18 | "axios": "^0.19.0", 19 | "axios-jsonp-pro": "^1.1.6", 20 | "history": "4.10.1", 21 | "hono": "^4.4.6", 22 | "jsonp": "^0.2.1", 23 | "qs": "^6.9.0", 24 | "react": "^18.3.1", 25 | "react-dom": "^18.3.1", 26 | "react-hotkeys-hook": "^4.6.1", 27 | "react-redux": "^7.1.1", 28 | "react-router-dom": "^5.1.2", 29 | "react-sortablejs": "^1.5.1", 30 | "redux": "^4.0.4", 31 | "rxjs": "^7.8.1" 32 | }, 33 | "devDependencies": { 34 | "@cloudflare/workers-types": "^4.20240529.0", 35 | "@hono/vite-cloudflare-pages": "^0.4.0", 36 | "@hono/vite-dev-server": "^0.12.1", 37 | "@types/jsonp": "^0.2.3", 38 | "@types/qs": "^6.9.15", 39 | "@types/react": "^18.3.3", 40 | "@types/react-dom": "^18.3.0", 41 | "@types/react-redux": "^7.1.34", 42 | "@types/react-router-dom": "^5.3.3", 43 | "@typescript-eslint/eslint-plugin": "^7.13.1", 44 | "@typescript-eslint/parser": "^7.13.1", 45 | "@vitejs/plugin-react": "^4.3.1", 46 | "eslint": "^8.57.0", 47 | "eslint-plugin-react-hooks": "^4.6.2", 48 | "eslint-plugin-react-refresh": "^0.4.7", 49 | "prettier": "^3.3.2", 50 | "rollup-plugin-visualizer": "^5.12.0", 51 | "typescript": "^5.2.2", 52 | "vite": "^5.3.1", 53 | "wrangler": "^3.57.2" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/public/favicon.ico -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "GY Nav", 3 | "name": "A custom navigation page", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 13px; 3 | } 4 | 5 | @media screen and (min-width: 600px) { 6 | body { 7 | font-size: 14.5px; 8 | } 9 | } 10 | 11 | @media (prefers-color-scheme: dark) { 12 | body { 13 | background-color: #22272e; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect } from 'react'; 2 | import './App.css'; 3 | //import './dark.css'; 4 | import Router from './router/router'; 5 | import { setUser } from './redux/actions'; 6 | 7 | import { GetUserStore } from './utils/localStorageUtil'; 8 | 9 | import { useDispatch } from 'react-redux'; 10 | // @ts-ignore 11 | import React from 'react'; 12 | 13 | const App = () => { 14 | const dispatch = useDispatch(); 15 | 16 | const initUser = () => { 17 | const newUser = GetUserStore(); 18 | if (newUser !== null && newUser !== undefined) { 19 | console.log('从本地读取到了用户', newUser.userName); 20 | dispatch(setUser(newUser)); 21 | } 22 | }; 23 | 24 | useEffect(() => { 25 | initUser(); 26 | }, []); 27 | 28 | return ; 29 | }; 30 | 31 | export default App; 32 | -------------------------------------------------------------------------------- /src/assets/baidu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/baidu.png -------------------------------------------------------------------------------- /src/assets/bbs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/bbs.png -------------------------------------------------------------------------------- /src/assets/copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/copy.png -------------------------------------------------------------------------------- /src/assets/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/delete.png -------------------------------------------------------------------------------- /src/assets/github-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/github-light.png -------------------------------------------------------------------------------- /src/assets/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/github.png -------------------------------------------------------------------------------- /src/assets/googlefanyi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/googlefanyi.png -------------------------------------------------------------------------------- /src/assets/jd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/jd.png -------------------------------------------------------------------------------- /src/assets/new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/new.png -------------------------------------------------------------------------------- /src/assets/qq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/qq.png -------------------------------------------------------------------------------- /src/assets/qqmail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/qqmail.png -------------------------------------------------------------------------------- /src/assets/react.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/red_packet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/red_packet.png -------------------------------------------------------------------------------- /src/assets/red_packet_m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/red_packet_m.png -------------------------------------------------------------------------------- /src/assets/taobao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/taobao.png -------------------------------------------------------------------------------- /src/assets/wangyiyun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/wangyiyun.png -------------------------------------------------------------------------------- /src/assets/weibo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/weibo.png -------------------------------------------------------------------------------- /src/assets/zhihu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/assets/zhihu.png -------------------------------------------------------------------------------- /src/component/FeaturePanel/index.css: -------------------------------------------------------------------------------- 1 | .panel-container { 2 | /* position: relative; */ 3 | /* width: 100%; 4 | height: 100%; */ 5 | } 6 | 7 | .pull-ring { 8 | position: fixed; 9 | top: 0; 10 | left: 20px; 11 | 12 | width: 1px; 13 | height: 35px; 14 | background-color: rgb(51, 136, 255); 15 | /* border-radius: 50%; */ 16 | cursor: pointer; 17 | z-index: 1000; 18 | } 19 | 20 | .pull-ring::after { 21 | content: ''; 22 | height: 11px; 23 | width: 11px; 24 | border: 1px solid rgb(51, 136, 255); 25 | display: block; 26 | position: relative; 27 | border-radius: 50%; 28 | left: -6px; 29 | top: 35px; 30 | } 31 | 32 | .panel { 33 | position: fixed; 34 | top: -100%; 35 | left: 0; 36 | width: 100%; 37 | min-height: 110px; 38 | box-sizing: border-box; 39 | background-color: #fff; 40 | transition: top 0.3s ease; 41 | z-index: 1000; 42 | box-shadow: 43 | 0 3px 1px -2px rgba(0, 0, 0, 0.2), 44 | 0 2px 2px 0 rgba(0, 0, 0, 0.14), 45 | 0 1px 5px 0 rgba(0, 0, 0, 0.12); 46 | 47 | display: flex; 48 | align-items: center; 49 | flex-wrap: wrap; 50 | gap: 10px; 51 | padding: 10px; 52 | } 53 | 54 | .panel-item { 55 | height: 80px; 56 | width: 60px; 57 | 58 | cursor: pointer; 59 | 60 | display: flex; 61 | flex-direction: column; 62 | align-items: center; 63 | justify-content: center; 64 | 65 | border-radius: 8px; 66 | } 67 | 68 | .panel-item:hover { 69 | box-shadow: 70 | 0 5px 5px -3px rgba(0, 0, 0, 0.2), 71 | 0 8px 10px 1px rgba(0, 0, 0, 0.14), 72 | 0 3px 14px 2px rgba(0, 0, 0, 0.12); 73 | } 74 | 75 | .panel-item-icon { 76 | padding: 5px; 77 | height: 60px; 78 | width: 60px; 79 | box-sizing: border-box; 80 | } 81 | 82 | .panel-item-icon img { 83 | height: 100%; 84 | width: 100%; 85 | } 86 | 87 | .panel-item-name { 88 | height: 20px; 89 | line-height: 20px; 90 | font-size: 12px; 91 | /* width: 60px; */ 92 | } 93 | 94 | .panel-container:hover .panel { 95 | top: 0; 96 | } 97 | 98 | .panel-display .panel { 99 | top: 0 !important; 100 | } 101 | -------------------------------------------------------------------------------- /src/component/FeaturePanel/index.tsx: -------------------------------------------------------------------------------- 1 | import { useRef, useState } from 'react'; 2 | 3 | import { 4 | Tooltip, 5 | Dialog, 6 | DialogTitle, 7 | DialogContent, 8 | DialogContentText, 9 | Snackbar, 10 | Button, 11 | } from '@mui/material'; 12 | 13 | // @ts-ignore 14 | import { post } from '../../utils/http'; 15 | 16 | import { WriteRemoteClipBoard, GetRemoteClipBoard } from '../../utils/Api'; 17 | 18 | import { readFromClipboard, writeToClipboard } from '../../utils/clipboard'; 19 | 20 | import copy from '../../assets/copy.png'; 21 | import whatsnew from '../../assets/new.png'; 22 | 23 | import './index.css'; 24 | import { isSafari } from '../../utils/device'; 25 | 26 | const FeaturePanel = () => { 27 | const [display, setDisplay] = useState(false); 28 | 29 | const timer = useRef(null); 30 | 31 | const [msg, setMsg] = useState<{ 32 | content: string; 33 | callback: (() => void) | null; 34 | }>({ content: '', callback: null }); 35 | 36 | const [modalOpen, setModalOpen] = useState(false); 37 | 38 | const handleModalClose = () => { 39 | setModalOpen(false); 40 | }; 41 | 42 | const handleMsgClose = (_event: any, reason: string) => { 43 | if (reason === 'clickaway') { 44 | return; 45 | } 46 | 47 | setMsg({ content: '', callback: null }); 48 | }; 49 | 50 | const handleCopyClick = () => { 51 | if (timer.current) { 52 | clearTimeout(timer.current); 53 | } 54 | 55 | timer.current = setTimeout(async () => { 56 | const res = await post(GetRemoteClipBoard, {}); 57 | 58 | if (!res.result) { 59 | setMsg({ content: '云端剪切板为空或已过期', callback: null }); 60 | return; 61 | } 62 | const remoteClipBoard = res.data; 63 | if (isSafari()) { 64 | setMsg({ 65 | content: '点击复制', 66 | callback: () => { 67 | writeToClipboard(remoteClipBoard); 68 | setMsg({ content: '', callback: null }); 69 | }, 70 | }); 71 | } else { 72 | await writeToClipboard(remoteClipBoard); 73 | setMsg({ content: '拉取云剪切板成功', callback: null }); 74 | } 75 | }, 400); 76 | }; 77 | 78 | const handleCopyDbClick = async () => { 79 | if (timer.current) { 80 | clearTimeout(timer.current); 81 | } 82 | 83 | const clipboardData = await readFromClipboard(); 84 | if (clipboardData) { 85 | await post(WriteRemoteClipBoard, { clipboardString: clipboardData }); 86 | setMsg({ 87 | content: '成功复制内容到云剪切板,5分钟后失效', 88 | callback: null, 89 | }); 90 | } else { 91 | setMsg({ content: '剪切板为空', callback: null }); 92 | } 93 | }; 94 | 95 | const snackbarAction = 96 | msg.content && msg.callback ? ( 97 | 100 | ) : null; 101 | 102 | return ( 103 | <> 104 | 115 |

setDisplay(false)} 117 | onMouseLeave={() => setDisplay(false)} 118 | className={ 119 | display ? 'panel-container panel-display' : 'panel-container' 120 | } 121 | > 122 |
{ 125 | setDisplay(true); 126 | }} 127 | >
128 |
129 | 130 |
135 |
136 | copy 137 |
138 |
云剪切板
139 |
140 |
141 |
{ 144 | setModalOpen(true); 145 | setDisplay(false); 146 | }} 147 | > 148 |
149 | copy 150 |
151 |
更新日志
152 |
153 |
154 | 159 | 更新说明 160 | 161 | 162 | 云剪切板 (用于同一账户跨设备同步信息) 163 | 164 |
双击拷贝剪切板内容到云端,单击从云端拷贝剪切板内容到本地
165 |
166 | 隐私相关:用户剪切板内容加密存储,5分钟后过期自动从云端删除 167 |
168 |
但即便如此,仍不建议将密码等敏感信息存储到云剪切板
169 |
170 | 171 | 搜索引擎切换快捷键 172 |
使用快捷键切换搜索引擎,快捷键位悬停在搜索引擎上可查看
173 |
174 |
175 |
176 | 177 | ); 178 | }; 179 | 180 | export default FeaturePanel; 181 | -------------------------------------------------------------------------------- /src/component/Footer/Footer.tsx: -------------------------------------------------------------------------------- 1 | import './index.css'; 2 | import github from '../../assets/github-light.png'; 3 | 4 | const Footer = () => { 5 | return ( 6 | 30 | ); 31 | }; 32 | 33 | export default Footer; 34 | -------------------------------------------------------------------------------- /src/component/Footer/index.css: -------------------------------------------------------------------------------- 1 | footer { 2 | height: 100px; 3 | background-color: #2f2f29; 4 | display: -webkit-box; 5 | display: -ms-flexbox; 6 | display: flex; 7 | -webkit-box-pack: center; 8 | -ms-flex-pack: center; 9 | justify-content: center; 10 | -webkit-box-align: center; 11 | -ms-flex-align: center; 12 | align-items: center; 13 | width: 100%; 14 | } 15 | .about { 16 | color: #fff; 17 | text-align: center; 18 | } 19 | .about div a img { 20 | height: 32px; 21 | margin-bottom: -10px; 22 | } 23 | a { 24 | text-decoration: none; 25 | } 26 | .beian a:hover { 27 | text-decoration: underline; 28 | } 29 | 30 | /* .beian:hover a{ 31 | text-decoration: underline; 32 | } */ 33 | -------------------------------------------------------------------------------- /src/component/FriendSite/FriendSite.tsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from 'react'; 2 | import Site from '../site/Site'; 3 | import './index.css'; 4 | //import './dark.css'; 5 | // TODO 6 | // @ts-ignore 7 | import { get } from '../../utils/http'; 8 | import { GetAllFS } from '../../utils/Api'; 9 | import { ISite } from '../../redux/types'; 10 | 11 | const FriendSite = () => { 12 | const [sites, setSites] = useState([]); 13 | 14 | useEffect(() => { 15 | get(GetAllFS, {}) 16 | .then((data) => { 17 | if (data.result) { 18 | // this.setState({ 19 | // sites: data.fsites, 20 | // }); 21 | setSites(data.fsites as ISite[]); 22 | } 23 | }) 24 | .catch((err: any) => { 25 | console.log(err); 26 | }); 27 | }, []); 28 | 29 | return ( 30 |
31 | 友情链接: 32 | 33 |
34 | ); 35 | }; 36 | 37 | export default FriendSite; 38 | -------------------------------------------------------------------------------- /src/component/FriendSite/dark.css: -------------------------------------------------------------------------------- 1 | @media (prefers-color-scheme: dark) { 2 | .footer { 3 | background-color: #3c3c3c; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/component/FriendSite/index.css: -------------------------------------------------------------------------------- 1 | .footer { 2 | background-color: #dfdfdf; 3 | margin-top: 20px; 4 | padding-top: 10px; 5 | padding-left: 20px; 6 | padding-bottom: 10px; 7 | padding-right: 20px; 8 | color: #000; 9 | font-size: 13px; 10 | } 11 | .gy-shadow-2 { 12 | -webkit-box-shadow: 13 | 0 3px 1px -2px rgba(0, 0, 0, 0.2), 14 | 0 2px 2px 0 rgba(0, 0, 0, 0.14), 15 | 0 1px 5px 0 rgba(0, 0, 0, 0.12); 16 | box-shadow: 17 | 0 3px 1px -2px rgba(0, 0, 0, 0.2), 18 | 0 2px 2px 0 rgba(0, 0, 0, 0.14), 19 | 0 1px 5px 0 rgba(0, 0, 0, 0.12); 20 | } 21 | 22 | @media (prefers-color-scheme: dark) { 23 | .footer { 24 | background-color: #3c3c3c; 25 | color: #adbac7; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/component/GlobalMessage/GlobalMessage.tsx: -------------------------------------------------------------------------------- 1 | const GlobalMessage = () => { 2 | return
; 3 | }; 4 | 5 | export default GlobalMessage; 6 | -------------------------------------------------------------------------------- /src/component/GyDialog/AddSiteDialog.tsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from 'react'; 2 | import DialogTitle from '@mui/material/DialogTitle'; 3 | import DialogContent from '@mui/material/DialogContent'; 4 | import DialogActions from '@mui/material/DialogActions'; 5 | import Button from '@mui/material/Button'; 6 | import Dialog from '@mui/material/Dialog'; 7 | import TextField from '@mui/material/TextField'; 8 | // import Select from '@mui/material/Select'; 9 | // import MenuItem from '@mui/material/MenuItem'; 10 | // import FormControl from '@mui/material/FormControl'; 11 | // import InputLabel from '@mui/material/InputLabel'; 12 | import { linkPattern } from '../../utils/veriLink'; 13 | // import { setGlobalMsg } from '../../redux/actions'; 14 | // import { connect } from 'react-redux'; 15 | 16 | interface IAddSiteDialogProps { 17 | defaultName?: string; 18 | defaultAddr?: string; 19 | title: string; 20 | CancelText?: string; 21 | open: boolean; 22 | onClose: () => void; 23 | onConfirm: (siteName: string, siteAddr: string) => void; 24 | onCancel: () => void; 25 | ConfirmText?: string; 26 | } 27 | 28 | function AddSiteDialog(props: IAddSiteDialogProps) { 29 | //console.log(props); 30 | const [siteName, setSiteName] = useState( 31 | props.defaultName || '' 32 | ); 33 | const [siteAddr, setSiteAddr] = useState( 34 | props.defaultAddr || 'http://' 35 | ); 36 | const [isError, setIsError] = useState(false); 37 | const [helpText, setHelpText] = useState(''); 38 | //console.log("AddSiteDialog刷新了"); 39 | 40 | useEffect(() => { 41 | if (props.open) { 42 | setSiteAddr(props.defaultAddr || 'http://'); 43 | console.log('设置siteAddr'); 44 | } 45 | return () => {}; 46 | }, [props.open]); 47 | return ( 48 | { 51 | setSiteName(''); 52 | setSiteAddr(''); 53 | setIsError(false); 54 | setHelpText(''); 55 | props.onClose(); 56 | }} 57 | aria-labelledby="alert-dialog-title" 58 | // aria-describedby="alert-dialog-description" 59 | > 60 | {props.title} 61 | 62 | { 69 | setSiteName(event.target.value); 70 | event.stopPropagation(); 71 | }} 72 | /> 73 |
74 | 75 | { 84 | setSiteAddr(event.target.value); 85 | event.stopPropagation(); 86 | }} 87 | /> 88 |
89 | 90 | 102 | 119 | 120 |
121 | ); 122 | } 123 | 124 | // export default App; 125 | 126 | // export default connect(mapStateToProps, mapDispatchToProps)(AddSiteDialog); 127 | 128 | export default AddSiteDialog; 129 | -------------------------------------------------------------------------------- /src/component/GyDialog/GyDialog.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import DialogTitle from '@mui/material/DialogTitle'; 3 | import DialogContent from '@mui/material/DialogContent'; 4 | import DialogActions from '@mui/material/DialogActions'; 5 | import Button from '@mui/material/Button'; 6 | import Dialog from '@mui/material/Dialog'; 7 | import TextField from '@mui/material/TextField'; 8 | 9 | interface IGyDialogProps { 10 | open: boolean; 11 | title: string; 12 | onClose: () => void; 13 | onCancel: () => void; 14 | onConfirm: (partName: string) => void; 15 | } 16 | 17 | function GyDialog(props: IGyDialogProps) { 18 | //console.log(props); 19 | const [partName, setpartName] = useState(''); 20 | 21 | return ( 22 | { 25 | setpartName(''); 26 | props.onClose(); 27 | }} 28 | aria-labelledby="alert-dialog-title" 29 | aria-describedby="alert-dialog-description" 30 | > 31 | {props.title} 32 | 33 | { 39 | setpartName(event.target.value); 40 | event.stopPropagation(); 41 | }} 42 | /> 43 | 44 | {/**/} 45 | {/* Let Google help apps determine location. This means sending anonymous location data to*/} 46 | {/* Google, even when no apps are running.*/} 47 | {/**/} 48 | 49 | 50 | 59 | 68 | 69 | 70 | ); 71 | } 72 | 73 | export default GyDialog; 74 | -------------------------------------------------------------------------------- /src/component/HeadBar/HeadBar.tsx: -------------------------------------------------------------------------------- 1 | import { useCallback, useEffect, useRef, useState } from 'react'; 2 | import './index.css'; 3 | //import './dark.css'; 4 | import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; 5 | import Collapse from '@mui/material/Collapse'; 6 | import CancelIcon from '@mui/icons-material/Cancel'; 7 | import { useDispatch, useSelector } from 'react-redux'; 8 | import { 9 | setSugShow, 10 | setMarchineShow, 11 | setMarchineIndex, 12 | } from '../../redux/actions'; 13 | import Marchinelist from '../../utils/SearchMarchine'; 14 | import { linkPattern } from '../../utils/veriLink'; 15 | // @ts-ignore 16 | import eventBus from '../../utils/EventEmitter'; 17 | import { homeKeyDown } from '../../utils/Events'; 18 | import { StoreType } from '../../redux/store'; 19 | import { DeviceTypes } from '../../redux/types'; 20 | import { sugObservable, sugSubject } from './utils'; 21 | import { useHotkeys } from 'react-hotkeys-hook'; 22 | 23 | interface IHeadBarProps { 24 | Scrolled: boolean; 25 | } 26 | 27 | const hotkeyMap = Marchinelist.reduce( 28 | (prev, curv, index) => { 29 | const { hotkey } = curv; 30 | if (hotkey) { 31 | prev[hotkey] = index; 32 | } 33 | return prev; 34 | }, 35 | {} as Record 36 | ); 37 | 38 | const hotkeys = Object.keys(hotkeyMap); 39 | 40 | const HeadBar = ({ Scrolled }: IHeadBarProps) => { 41 | // const [showMarchine, setShowMarchine] = useState(false); 42 | const [sug, setSug] = useState([]); 43 | // const [showSug, setShowSug] = useState(false); 44 | const [keyWord, setKeyword] = useState(''); 45 | // const [Marchineselect_index, setMarchineselect_index] = useState(0); 46 | const [sugSelectIndex, setSugSelectIndex] = useState(0); 47 | 48 | // eslint-disable-next-line @typescript-eslint/no-unused-vars 49 | const [_random, setRandom] = useState(0); 50 | 51 | const { device, marchine, showSug, selectMcIndex } = useSelector< 52 | StoreType, 53 | { 54 | device: DeviceTypes; 55 | marchine: boolean; 56 | showSug: boolean; 57 | selectMcIndex: number; 58 | } 59 | >(({ Device, Show, MarchineIndex }) => ({ 60 | device: Device.device, 61 | marchine: Show.marchine, 62 | showSug: Show.sug, 63 | selectMcIndex: MarchineIndex.index, 64 | })); 65 | 66 | const dispatch = useDispatch(); 67 | 68 | const inputRef = useRef(null); 69 | 70 | useHotkeys( 71 | hotkeys, 72 | (_arg, arg1) => { 73 | const index = hotkeyMap[arg1.hotkey]; 74 | if (index !== undefined && index !== null) { 75 | dispatch(setMarchineIndex(index)); 76 | dispatch(setMarchineShow(false)); 77 | } 78 | }, 79 | { enableOnFormTags: ['INPUT'], preventDefault: true } 80 | ); 81 | 82 | const handleHomeKeyDown = (e: any) => { 83 | const focuEle = e.target.tagName; 84 | if (focuEle !== 'INPUT') { 85 | inputRef.current?.focus(); 86 | } 87 | }; 88 | 89 | useEffect(() => { 90 | eventBus.on(homeKeyDown, handleHomeKeyDown); 91 | return () => { 92 | eventBus.off(homeKeyDown, handleHomeKeyDown); 93 | }; 94 | }, []); 95 | 96 | useEffect(() => { 97 | const handleResize = () => { 98 | setRandom(Math.random()); 99 | }; 100 | 101 | window.addEventListener('resize', handleResize); 102 | 103 | return () => { 104 | window.removeEventListener('resize', handleResize); 105 | }; 106 | }, []); 107 | 108 | const Search = (keyword?: string) => { 109 | const keyword_ = keyword ?? keyWord; 110 | // let device = this.props.device; 111 | // let marchine = this.state.Marchinelist[this.state.Marchineselect_index]; 112 | if (linkPattern.test(keyword_)) { 113 | if (device === 'phone') { 114 | window.location.href = keyword_; 115 | } else { 116 | window.open(keyword_); 117 | } 118 | } 119 | const marchine = Marchinelist[selectMcIndex]; 120 | 121 | const url = 122 | marchine.searApi + encodeURIComponent(keyword_) + marchine.searApi_weizui; 123 | if (device === 'phone') { 124 | window.location.href = url; 125 | } else { 126 | window.open(url); 127 | } 128 | }; 129 | 130 | const keywordRef = useRef(keyWord); 131 | 132 | keywordRef.current = keyWord; 133 | 134 | useEffect(() => { 135 | const sub = sugObservable.subscribe((sugs: string[]) => { 136 | if (sugs?.length) { 137 | sugs.splice(0, 0, keywordRef.current); 138 | } 139 | 140 | setSug(sugs as any); 141 | dispatch(setSugShow(!!sugs.length)); 142 | 143 | setSugSelectIndex(0); 144 | }); 145 | 146 | return () => sub.unsubscribe(); 147 | }, []); 148 | 149 | const getSug = useCallback(() => { 150 | sugSubject.next(keywordRef.current); 151 | }, []); 152 | 153 | const switchSug = () => { 154 | console.log('switch'); 155 | const newshowSug = !showSug; 156 | dispatch(setMarchineShow(false)); 157 | if (newshowSug === true) { 158 | getSug(); 159 | return; 160 | } 161 | dispatch(setSugShow(newshowSug)); 162 | }; 163 | 164 | const wrapRef = useRef(null); 165 | const barRef = useRef(null); 166 | 167 | const searchBtnRef = useRef(null); 168 | 169 | const color = Marchinelist[selectMcIndex].color; 170 | const name = Marchinelist[selectMcIndex].button_value; 171 | 172 | const sugWidth = 173 | wrapRef.current && searchBtnRef.current 174 | ? wrapRef.current.clientWidth - searchBtnRef.current.clientWidth 175 | : 0; 176 | 177 | const headBase = 178 | device !== DeviceTypes.phone ? 'headBar headBarHoverbel' : 'headBar'; 179 | 180 | return ( 181 |
{ 184 | dispatch(setMarchineShow(false)); 185 | dispatch(setSugShow(false)); 186 | }} 187 | > 188 |
189 |
190 | { 194 | dispatch(setMarchineShow(!marchine)); 195 | dispatch(setSugShow(false)); 196 | e.stopPropagation(); 197 | }} 198 | /> 199 | 200 | 206 | {Marchinelist.map((item, index) => { 207 | return ( 208 | { 213 | dispatch(setMarchineIndex(index)); 214 | dispatch(setMarchineShow(false)); 215 | }} 216 | style={{ 217 | textDecoration: 'none', 218 | fontSize: 14, 219 | cursor: 'pointer', 220 | }} 221 | > 222 | {item.Marchine_name} 223 | 224 | ); 225 | })} 226 | 227 |
228 |
229 | { 235 | switchSug(); 236 | e.stopPropagation(); 237 | }} 238 | onKeyDown={(e) => { 239 | console.log(e.keyCode); //上为38,下为40 240 | 241 | if (e.keyCode === 38) { 242 | let selectIndex = sugSelectIndex; 243 | selectIndex = (sug.length + --selectIndex) % sug.length; 244 | setSugSelectIndex(selectIndex); 245 | setKeyword(sug[selectIndex]); 246 | } else if (e.keyCode === 40) { 247 | let selectIndex = sugSelectIndex; 248 | // selectIndex = (sug.length + --selectIndex)%sug.length; 249 | selectIndex = ++selectIndex % sug.length; 250 | 251 | setSugSelectIndex(selectIndex); 252 | setKeyword(sug[selectIndex]); 253 | } else if (e.keyCode === 13) { 254 | if (keyWord === '') return; 255 | Search(keywordRef.current); 256 | } 257 | }} 258 | value={keyWord} 259 | onChange={(e) => { 260 | setKeyword(e.target.value); 261 | keywordRef.current = e.target.value; 262 | getSug(); 263 | }} 264 | ref={inputRef} 265 | /> 266 | 267 | {keyWord && ( 268 |
{ 271 | setKeyword(''); 272 | keywordRef.current = ''; 273 | getSug(); 274 | inputRef.current?.focus(); 275 | }} 276 | > 277 | 278 |
279 | )} 280 |
281 | 282 | {sug.length !== 0 && showSug ? ( 283 | 316 | ) : null} 317 |
Search()} 323 | > 324 | {name} 325 |
326 |
327 |
328 | ); 329 | }; 330 | 331 | export default HeadBar; 332 | -------------------------------------------------------------------------------- /src/component/HeadBar/dark.css: -------------------------------------------------------------------------------- 1 | @media (prefers-color-scheme: dark) { 2 | /* html { 3 | filter: invert(1) hue-rotate(180deg); 4 | } */ 5 | .headBar, 6 | .sear_wrap, 7 | #input_bar { 8 | background-color: #1a1926; 9 | } 10 | .sug { 11 | background-color: #333; 12 | color: white; 13 | } 14 | .sear_marchine { 15 | color: #fff9; 16 | } 17 | #input_bar { 18 | color: #fff; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/component/HeadBar/index.css: -------------------------------------------------------------------------------- 1 | .headBar { 2 | width: 100%; 3 | display: -webkit-box; 4 | display: -ms-flexbox; 5 | display: flex; 6 | display: -webkit-flex; 7 | position: fixed; 8 | -webkit-box-pack: center; 9 | -ms-flex-pack: center; 10 | justify-content: center; 11 | -webkit-box-align: center; 12 | -ms-flex-align: center; 13 | align-items: center; 14 | top: 0; 15 | height: 70px; 16 | border-bottom-left-radius: 6px; 17 | border-bottom-right-radius: 6px; 18 | background-color: #fff; 19 | z-index: 100; 20 | } 21 | 22 | /* .headBar:hover { 23 | -webkit-box-shadow: 0 5px 5px -3px rgba(0,0,0,.2), 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12); 24 | box-shadow: 0 5px 5px -3px rgba(0,0,0,.2), 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12); 25 | } */ 26 | 27 | /* .headBar { 28 | -webkit-transition: -webkit-box-shadow .25s cubic-bezier(.4,0,.2,1); 29 | transition: -webkit-box-shadow .25s cubic-bezier(.4,0,.2,1); 30 | transition: box-shadow .25s cubic-bezier(.4,0,.2,1); 31 | transition: box-shadow .25s cubic-bezier(.4,0,.2,1),-webkit-box-shadow .25s cubic-bezier(.4,0,.2,1); 32 | will-change: box-shadow; 33 | } */ 34 | 35 | .headBarHoverbel:hover { 36 | -webkit-box-shadow: 37 | 0 5px 5px -3px rgba(0, 0, 0, 0.2), 38 | 0 8px 10px 1px rgba(0, 0, 0, 0.14), 39 | 0 3px 14px 2px rgba(0, 0, 0, 0.12); 40 | box-shadow: 41 | 0 5px 5px -3px rgba(0, 0, 0, 0.2), 42 | 0 8px 10px 1px rgba(0, 0, 0, 0.14), 43 | 0 3px 14px 2px rgba(0, 0, 0, 0.12); 44 | } 45 | 46 | .headBarHoverbel { 47 | -webkit-transition: -webkit-box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 48 | transition: -webkit-box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 49 | transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 50 | transition: 51 | box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), 52 | -webkit-box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 53 | will-change: box-shadow; 54 | } 55 | 56 | .gy-shadow-2 { 57 | -webkit-box-shadow: 58 | 0 3px 1px -2px rgba(0, 0, 0, 0.2), 59 | 0 2px 2px 0 rgba(0, 0, 0, 0.14), 60 | 0 1px 5px 0 rgba(0, 0, 0, 0.12); 61 | box-shadow: 62 | 0 3px 1px -2px rgba(0, 0, 0, 0.2), 63 | 0 2px 2px 0 rgba(0, 0, 0, 0.14), 64 | 0 1px 5px 0 rgba(0, 0, 0, 0.12); 65 | } 66 | 67 | .sear_wrap { 68 | text-align: center; 69 | border: 0.5px solid #3f51b5; 70 | outline: 0; 71 | background-color: #fff; 72 | } 73 | 74 | .sear_marchine { 75 | display: inline-block; 76 | margin-left: 3px; 77 | margin-right: 0; 78 | } 79 | 80 | .selected { 81 | background-color: #74b3b2; 82 | color: #fff; 83 | } 84 | 85 | .sugindex { 86 | display: -webkit-inline-box; 87 | display: -ms-inline-flexbox; 88 | display: inline-flex; 89 | -webkit-box-align: center; 90 | -ms-flex-align: center; 91 | align-items: center; 92 | -webkit-box-pack: center; 93 | -ms-flex-pack: center; 94 | justify-content: center; 95 | height: 16px; 96 | width: 16px; 97 | background-color: #3b4042; 98 | border-radius: 50%; 99 | font-size: 12px; 100 | margin-right: 5px; 101 | color: #fff; 102 | } 103 | 104 | #sear_marchine_select { 105 | margin-left: -4px; 106 | margin-top: 9px; 107 | width: 70px; 108 | } 109 | 110 | .sug { 111 | width: 50%; 112 | position: absolute; 113 | background-color: #fafafa; 114 | -webkit-box-shadow: 0 2px 6px 0 rgba(63, 81, 181, 0.5); 115 | box-shadow: 0 2px 6px 0 rgba(63, 81, 181, 0.5); 116 | margin: 0; 117 | padding: 0; 118 | border-radius: 6px; 119 | } 120 | 121 | .sug a { 122 | /*width: 100%;*/ 123 | height: 25px; 124 | line-height: 25px; 125 | text-align: left; 126 | padding-left: 6px; 127 | font-size: 16px; 128 | display: block; 129 | white-space: nowrap; 130 | overflow: hidden; 131 | } 132 | 133 | .sug a:hover { 134 | background-color: #828593; 135 | color: #fff; 136 | } 137 | 138 | .sug a:first-child { 139 | border-top-left-radius: 6px; 140 | border-top-right-radius: 6px; 141 | } 142 | .sug a:last-child { 143 | border-bottom-left-radius: 6px; 144 | border-bottom-right-radius: 6px; 145 | } 146 | 147 | /*.sug_list:first-child {*/ 148 | /* border-top-left-radius: 6px;*/ 149 | /* border-top-right-radius: 6px;*/ 150 | /*}*/ 151 | 152 | #seacing_bar { 153 | display: inline-flex; 154 | flex-wrap: nowrap; 155 | width: 120px; 156 | height: 32px; 157 | margin-bottom: -12.5px; 158 | overflow: hidden; 159 | } 160 | 161 | #input_bar { 162 | padding: 0; 163 | display: inline-block; 164 | width: 100%; 165 | height: 100%; 166 | border: 0; 167 | outline: 0; 168 | font-size: 14px; 169 | } 170 | 171 | #seaching { 172 | border-radius: 0; 173 | } 174 | 175 | .gy-button { 176 | position: relative; 177 | display: inline-block; 178 | width: 88px; 179 | height: 36px; 180 | -webkit-box-sizing: border-box; 181 | box-sizing: border-box; 182 | padding: 0 16px; 183 | margin: 0; 184 | overflow: hidden; 185 | font-size: 14px; 186 | font-weight: 500; 187 | line-height: 36px; 188 | color: inherit; 189 | text-align: center; 190 | text-decoration: none; 191 | text-transform: uppercase; 192 | letter-spacing: 0.04em; 193 | white-space: nowrap; 194 | vertical-align: middle; 195 | -ms-touch-action: manipulation; 196 | touch-action: manipulation; 197 | cursor: pointer; 198 | zoom: 1; 199 | -webkit-user-select: none; 200 | -moz-user-select: none; 201 | -ms-user-select: none; 202 | user-select: none; 203 | background: 0 0; 204 | border: none; 205 | border-radius: 2px; 206 | outline: 0; 207 | -webkit-transition: 208 | all 0.2s cubic-bezier(0.4, 0, 0.2, 1), 209 | -webkit-box-shadow 0.2s cubic-bezier(0.4, 0, 1, 1); 210 | transition: 211 | all 0.2s cubic-bezier(0.4, 0, 0.2, 1), 212 | -webkit-box-shadow 0.2s cubic-bezier(0.4, 0, 1, 1); 213 | transition: 214 | all 0.2s cubic-bezier(0.4, 0, 0.2, 1), 215 | box-shadow 0.2s cubic-bezier(0.4, 0, 1, 1); 216 | transition: 217 | all 0.2s cubic-bezier(0.4, 0, 0.2, 1), 218 | box-shadow 0.2s cubic-bezier(0.4, 0, 1, 1), 219 | -webkit-box-shadow 0.2s cubic-bezier(0.4, 0, 1, 1); 220 | will-change: box-shadow; 221 | -webkit-user-drag: none; 222 | color: #fff; 223 | background-color: #3f51b5; 224 | } 225 | 226 | .gy-button:hover { 227 | opacity: 0.87; 228 | } 229 | 230 | @media screen and (min-width: 320px) { 231 | #seacing_bar { 232 | width: 160px; 233 | } 234 | } 235 | @media screen and (min-width: 375px) { 236 | #seacing_bar { 237 | width: 212px; 238 | } 239 | } 240 | @media screen and (min-width: 425px) { 241 | #seacing_bar { 242 | width: 268px; 243 | } 244 | } 245 | 246 | @media screen and (min-width: 600px) { 247 | #seacing_bar { 248 | width: 319px; 249 | } 250 | } 251 | 252 | @media screen and (min-width: 768px) { 253 | .headBar { 254 | height: 90px; 255 | } 256 | #seacing_bar { 257 | width: 500px; 258 | } 259 | } 260 | @media screen and (min-width: 960px) { 261 | #seacing_bar { 262 | width: 470px; 263 | } 264 | } 265 | @media screen and (min-width: 1024px) { 266 | .headBar { 267 | height: 110px; 268 | } 269 | #seacing_bar { 270 | width: 500px; 271 | } 272 | } 273 | 274 | @media screen and (min-width: 1200px) { 275 | #seacing_bar { 276 | width: 680px; 277 | } 278 | } 279 | @media screen and (min-width: 1440px) { 280 | #seacing_bar { 281 | width: 680px; 282 | } 283 | } 284 | @media screen and (min-width: 1920px) { 285 | #seacing_bar { 286 | width: 850px; 287 | } 288 | } 289 | 290 | @media (prefers-color-scheme: dark) { 291 | .headBar, 292 | .sear_wrap, 293 | #input_bar { 294 | background-color: #22272e; 295 | } 296 | .sug { 297 | background-color: #333; 298 | color: #adbac7; 299 | } 300 | .sear_marchine { 301 | color: #fff9; 302 | } 303 | #input_bar { 304 | color: #fff; 305 | } 306 | } 307 | -------------------------------------------------------------------------------- /src/component/HeadBar/utils.ts: -------------------------------------------------------------------------------- 1 | import jsonp from 'jsonp'; 2 | import { SUGTIP } from '../../utils/Api'; 3 | import { debounceTime, Subject, switchMap } from 'rxjs'; 4 | 5 | export const jsonpWithPromise = (keyword: string): Promise => { 6 | return new Promise((resolve, reject) => { 7 | if (!keyword) { 8 | resolve([]); 9 | } 10 | try { 11 | jsonp( 12 | SUGTIP + keyword, 13 | { 14 | param: 'cb', 15 | }, 16 | (_err: any, data: any) => { 17 | const fetchSug = data?.s || []; 18 | resolve(fetchSug); 19 | } 20 | ); 21 | } catch (error) { 22 | reject(error); 23 | } 24 | }); 25 | }; 26 | 27 | export const sugSubject = new Subject(); 28 | 29 | export const sugObservable = sugSubject.pipe( 30 | debounceTime(200), 31 | switchMap((keyword) => jsonpWithPromise(keyword)) 32 | ); 33 | 34 | -------------------------------------------------------------------------------- /src/component/MarginHead/MarginHead.tsx: -------------------------------------------------------------------------------- 1 | import './index.css'; 2 | 3 | const MarginHead = () => { 4 | return
; 5 | }; 6 | 7 | export default MarginHead; 8 | -------------------------------------------------------------------------------- /src/component/MarginHead/index.css: -------------------------------------------------------------------------------- 1 | .autoMargin { 2 | margin-top: 70px; 3 | margin-bottom: 90px; 4 | } 5 | 6 | @media screen and (min-width: 768px) { 7 | .autoMargin { 8 | margin-top: 90px; 9 | margin-bottom: 110px; 10 | } 11 | } 12 | @media screen and (min-width: 1024px) { 13 | .autoMargin { 14 | margin-top: 110px; 15 | margin-bottom: 130px; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/component/Partition/Partition.tsx: -------------------------------------------------------------------------------- 1 | import { useState, useMemo } from 'react'; 2 | import Divider from '@mui/material/Divider'; 3 | import Paper from '@mui/material/Paper'; 4 | import Grid from '@mui/material/Grid'; 5 | import Input from '@mui/material/Input'; 6 | import Button from '@mui/material/Button'; 7 | import Fab from '@mui/material/Fab'; 8 | // @ts-ignore 9 | import ReactSortable from 'react-sortablejs'; 10 | import AddIcon from '@mui/icons-material/Add'; 11 | import Site from '../site/Site'; 12 | import { useDispatch, useSelector } from 'react-redux'; 13 | 14 | import AddSiteDialog from '../GyDialog/AddSiteDialog'; 15 | import Snackbar from '@mui/material/Snackbar'; 16 | 17 | import { 18 | // addPart2Rear, 19 | addSite2Part, 20 | delPart as delPartAction, 21 | // delSite, 22 | modifyPart, 23 | // modifySite, 24 | // setPartition, 25 | insertPart, 26 | movePart, 27 | } from '../../redux/actions'; 28 | 29 | import './index.css'; 30 | import { StoreType } from '../../redux/store'; 31 | import { DeviceTypes, PartSiteData } from '../../redux/types'; 32 | //import './dark.css'; 33 | 34 | interface IPartitionProps { 35 | Edit: boolean; 36 | } 37 | 38 | const Partition = (props: IPartitionProps) => { 39 | const [selectedIndex, setSelectedIndex] = useState(-1); 40 | const [delPartIndex, setDelPartIndex] = useState(-1); 41 | const [delPart, setDelPart] = useState(null); 42 | 43 | const { Partition, device } = useSelector< 44 | StoreType, 45 | { Partition: PartSiteData[]; device: DeviceTypes } 46 | >((state) => ({ 47 | Partition: state.Partition.data, 48 | device: state.Device.device, 49 | })); 50 | 51 | const dispatch = useDispatch(); 52 | 53 | const list = useMemo(() => { 54 | const pts = Array.isArray(Partition) ? Partition : []; 55 | console.log(pts); 56 | const edit = props.Edit; 57 | return pts.map((item, index) => { 58 | return ( 59 | 60 | 65 | {edit === true ? ( 66 |
67 | { 71 | // this.props.modifyPart(index, e.target.value); 72 | dispatch(modifyPart(index, e.target.value)); 73 | e.stopPropagation(); 74 | // console.log(e.target.value) 75 | }} 76 | /> 77 | 90 | { 96 | setSelectedIndex(index); 97 | }} 98 | > 99 | 100 | 101 |
102 | ) : ( 103 |
{item.categoryname}
104 | )} 105 | 109 | 110 |
111 |
112 | ); 113 | }); 114 | }, [Partition, dispatch, props.Edit]); 115 | 116 | const edit = props.Edit; 117 | const key = 'PlaceHolderKey-' + (edit ? 'on' : 'off'); 118 | 119 | return ( 120 |
121 | { 128 | dispatch(movePart(evt.oldIndex, evt.newIndex)); 129 | }} 130 | options={{ 131 | animation: 150, 132 | easing: 'cubic-bezier(1, 0, 0, 1)', 133 | ghostClass: 'sortable-ghost', 134 | disabled: !edit || device === DeviceTypes.phone, 135 | }} 136 | > 137 | {list} 138 | 139 | 140 | = 0} 142 | title={'添加新站点'} 143 | ConfirmText={'添加'} 144 | onClose={() => { 145 | setSelectedIndex(-1); 146 | }} 147 | onCancel={() => { 148 | setSelectedIndex(-1); 149 | }} 150 | onConfirm={(siteName, siteAddr) => { 151 | if (siteName && siteAddr) { 152 | //这里应该加验证 153 | 154 | dispatch(addSite2Part(selectedIndex, siteName, siteAddr)); 155 | } else { 156 | console.log('给点东西吧'); 157 | } 158 | setSelectedIndex(-1); 159 | }} 160 | /> 161 | 162 | = 0} 165 | autoHideDuration={3000} 166 | onClose={() => { 167 | setDelPartIndex(-1); 168 | setDelPart(null); 169 | }} 170 | action={ 171 | 184 | } 185 | message="已删除" 186 | key={'jcndjcdjbk'} 187 | /> 188 |
189 | ); 190 | }; 191 | 192 | export default Partition; 193 | -------------------------------------------------------------------------------- /src/component/Partition/dark.css: -------------------------------------------------------------------------------- 1 | @media (prefers-color-scheme: dark) { 2 | .partition { 3 | background-color: #333 !important; 4 | } 5 | .partition .title { 6 | color: #fff; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/component/Partition/index.css: -------------------------------------------------------------------------------- 1 | .partition { 2 | min-height: 50px; 3 | padding: 10px; 4 | } 5 | .partition .title { 6 | display: inline-block; 7 | font-size: 1em; 8 | margin-top: 5px; 9 | margin-bottom: 5px; 10 | color: #0d47a1; 11 | } 12 | .gy-container-full { 13 | margin-top: 10px; 14 | max-width: 1095px; 15 | } 16 | .gy-container, 17 | .gy-container-full { 18 | -webkit-box-sizing: border-box; 19 | box-sizing: border-box; 20 | padding-right: 8px; 21 | padding-left: 8px; 22 | margin-right: auto; 23 | margin-left: auto; 24 | } 25 | .sortable-ghost { 26 | opacity: 0.5; 27 | background: #c8ebfb; 28 | } 29 | 30 | .editWrap { 31 | display: flex; 32 | } 33 | 34 | .flexInput { 35 | flex: 1; 36 | } 37 | 38 | @media (prefers-color-scheme: dark) { 39 | .partition { 40 | background-color: #22282d !important; 41 | } 42 | .partition .title { 43 | color: #adbac7; 44 | } 45 | .divider { 46 | background-color: #373e47; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/component/PopularSite/PopularSite.tsx: -------------------------------------------------------------------------------- 1 | import './index.css'; 2 | //import './dark.css'; 3 | import Divider from '@mui/material/Divider'; 4 | import { useSelector } from 'react-redux'; 5 | 6 | import { StoreType } from '../../redux/store'; 7 | 8 | // import { setPopularSite } from '../../redux/actions'; 9 | 10 | const PopularSite = () => { 11 | const { popularSite } = useSelector< 12 | StoreType, 13 | { popularSite: StoreType['PopularSite'] } 14 | >((state) => ({ 15 | popularSite: state.PopularSite, 16 | })); 17 | 18 | // const dispatch = useDispatch(); 19 | 20 | const pts = popularSite.pSite; 21 | 22 | return ( 23 |
24 |
常用站点
25 | 26 |
27 | {pts.map((item, index) => { 28 | return ( 29 | 41 | ); 42 | })} 43 |
44 |
45 | ); 46 | }; 47 | 48 | export default PopularSite; 49 | -------------------------------------------------------------------------------- /src/component/PopularSite/dark.css: -------------------------------------------------------------------------------- 1 | @media (prefers-color-scheme: dark) { 2 | .gy-container { 3 | background-color: #1e1f2b; 4 | } 5 | .title { 6 | color: #fff; 7 | } 8 | a, 9 | a:hover { 10 | color: white; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/component/PopularSite/index.css: -------------------------------------------------------------------------------- 1 | .gy-container { 2 | width: 96%; 3 | max-width: 1080px; 4 | -webkit-box-sizing: border-box; 5 | box-sizing: border-box; 6 | padding-right: 15px; 7 | padding-left: 15px; 8 | background-color: #fff; 9 | border-radius: 6px; 10 | margin: 22px auto; 11 | padding-bottom: 8px; 12 | } 13 | .site-container { 14 | width: 100%; 15 | /*height: 100px;*/ 16 | /*background-color: rgba(26, 52, 30, 0.47);*/ 17 | display: flex; 18 | flex-wrap: wrap; 19 | justify-content: space-around; 20 | align-items: center; 21 | } 22 | .site-container div { 23 | display: flex; 24 | justify-content: center; 25 | align-items: center; 26 | width: 33%; 27 | /*background-color: #0d47a1;*/ 28 | height: 100%; 29 | } 30 | .site { 31 | width: 75px; 32 | display: inline-block; 33 | height: 95px; 34 | text-align: center; 35 | margin: 0 2px; 36 | padding: 3px; 37 | border-radius: 6px; 38 | /* transition: .3s; */ 39 | } 40 | /* .site:hover{ 41 | transform: translate3d(0,-4px,0); 42 | } */ 43 | .site img { 44 | margin-bottom: -5px; 45 | } 46 | .site-title { 47 | text-align: center; 48 | white-space: nowrap; 49 | } 50 | .site-icon { 51 | width: 70px; 52 | height: 70px; 53 | } 54 | .gy-hoverable { 55 | -webkit-transition: -webkit-box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 56 | transition: -webkit-box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 57 | transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 58 | transition: 59 | box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), 60 | -webkit-box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 61 | will-change: box-shadow; 62 | } 63 | .title { 64 | display: inline-block; 65 | font-size: 1em; 66 | margin-top: 15px; 67 | margin-bottom: 10px; 68 | color: #0d47a1; 69 | } 70 | .gy-shadow-2 { 71 | -webkit-box-shadow: 72 | 0 3px 1px -2px rgba(0, 0, 0, 0.2), 73 | 0 2px 2px 0 rgba(0, 0, 0, 0.14), 74 | 0 1px 5px 0 rgba(0, 0, 0, 0.12); 75 | box-shadow: 76 | 0 3px 1px -2px rgba(0, 0, 0, 0.2), 77 | 0 2px 2px 0 rgba(0, 0, 0, 0.14), 78 | 0 1px 5px 0 rgba(0, 0, 0, 0.12); 79 | } 80 | @media screen and (min-width: 600px) { 81 | .gy-container { 82 | width: 94%; 83 | } 84 | } 85 | 86 | @media screen and (min-width: 960px) { 87 | .site-container div { 88 | width: 11%; 89 | } 90 | } 91 | 92 | @media (prefers-color-scheme: dark) { 93 | .gy-container { 94 | background-color: #22282d; 95 | } 96 | .title { 97 | color: #adbac7; 98 | } 99 | a, 100 | a:hover { 101 | color: #adbac7; 102 | } 103 | .divider { 104 | background-color: #373e47 !important; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/component/site/Site.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import './index.css'; 3 | //import './dark.css'; 4 | import EditIcon from '@mui/icons-material/Edit'; 5 | import DeleteIcon from '@mui/icons-material/Delete'; 6 | // @ts-ignore 7 | import ReactSortable from 'react-sortablejs'; 8 | 9 | import { useSelector, useDispatch } from 'react-redux'; 10 | import { 11 | // addSite2Part, 12 | delSite, 13 | modifySite, 14 | moveSite, 15 | // @ts-ignore 16 | } from '../../redux/actions'; 17 | 18 | // @ts-ignore 19 | import AddSiteDialog from '../GyDialog/AddSiteDialog'; 20 | 21 | const Site = ({ 22 | Sites: sites = [], 23 | PartIndex, 24 | Edit, 25 | }: { 26 | Sites: { site_name: string; url: string; id?: number }[]; 27 | PartIndex?: number; 28 | Edit?: boolean; 29 | }) => { 30 | const [selectedIndex, setSelectedIndex] = useState(-1); 31 | 32 | const edit = Edit && PartIndex !== null; 33 | const partIndex = 34 | PartIndex !== undefined && PartIndex !== null ? PartIndex : -1; 35 | const key = 'PlaceHolderKey-' + (edit ? 'on' : 'off'); 36 | 37 | const { device } = useSelector((state: any) => ({ 38 | device: state.Device.device, 39 | })); 40 | 41 | const dispatch = useDispatch(); 42 | 43 | return ( 44 |
45 | { 48 | if (partIndex < 0) return; 49 | dispatch(moveSite(partIndex, evt.oldIndex, evt.newIndex)); 50 | }} 51 | options={{ 52 | animation: 150, 53 | easing: 'cubic-bezier(1, 0, 0, 1)', 54 | ghostClass: 'sortable-ghost', 55 | disabled: !edit, 56 | }} 57 | > 58 | {sites.map((item, index) => { 59 | return ( 60 |
65 | {edit && device === 'phone' ? ( 66 |
{item.site_name ? item.site_name : '网站名缺失'}
67 | ) : ( 68 | 69 | {item.site_name ? item.site_name : '网站名缺失'} 70 | 71 | )} 72 | 73 | {edit === true && ( 74 |
75 |
{ 87 | setSelectedIndex(index); 88 | }} 89 | > 90 | 95 |
96 |
{ 108 | dispatch(delSite(partIndex, index)); 109 | }} 110 | > 111 | 116 |
117 |
118 | )} 119 |
120 | ); 121 | })} 122 |
123 | {selectedIndex >= 0 && ( 124 | = 0} 126 | title={'编辑站点'} 127 | ConfirmText={'修改'} 128 | defaultName={sites[selectedIndex].site_name} 129 | defaultAddr={sites[selectedIndex].url} 130 | onClose={() => { 131 | setSelectedIndex(-1); 132 | }} 133 | onCancel={() => { 134 | setSelectedIndex(-1); 135 | }} 136 | onConfirm={(siteName: string, siteAddr: string) => { 137 | if (siteName && siteAddr) { 138 | dispatch( 139 | modifySite(partIndex, selectedIndex, siteName, siteAddr) 140 | ); 141 | } else { 142 | console.log('给点东西吧'); 143 | } 144 | setSelectedIndex(-1); 145 | }} 146 | /> 147 | )} 148 |
149 | ); 150 | }; 151 | 152 | export default Site; 153 | -------------------------------------------------------------------------------- /src/component/site/dark.css: -------------------------------------------------------------------------------- 1 | @media (prefers-color-scheme: dark) { 2 | a { 3 | color: #fff; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/component/site/index.css: -------------------------------------------------------------------------------- 1 | .site-noicon { 2 | position: relative; 3 | display: inline-block; 4 | padding: 5px 10px; 5 | margin: 5px 5px 0 0; 6 | text-align: center; 7 | border-radius: 6px; 8 | } 9 | a { 10 | text-decoration: none; 11 | } 12 | a, 13 | a:hover { 14 | color: inherit; 15 | } 16 | .gy-hoverable { 17 | -webkit-transition: -webkit-box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 18 | transition: -webkit-box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 19 | transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 20 | transition: 21 | box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), 22 | -webkit-box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1); 23 | will-change: box-shadow; 24 | } 25 | 26 | .gy-hoverable:hover { 27 | -webkit-box-shadow: 28 | 0 5px 5px -3px rgba(0, 0, 0, 0.2), 29 | 0 8px 10px 1px rgba(0, 0, 0, 0.14), 30 | 0 3px 14px 2px rgba(0, 0, 0, 0.12); 31 | box-shadow: 32 | 0 5px 5px -3px rgba(0, 0, 0, 0.2), 33 | 0 8px 10px 1px rgba(0, 0, 0, 0.14), 34 | 0 3px 14px 2px rgba(0, 0, 0, 0.12); 35 | } 36 | /* .site-noicon:hover{ 37 | min-width: 40px; 38 | } */ 39 | .site-noicon:hover a { 40 | color: #e65100; 41 | text-decoration: underline; 42 | } 43 | .site-noicon:hover .delMenu { 44 | display: flex; 45 | } 46 | .delMenu { 47 | position: absolute; 48 | display: none; 49 | align-items: center; 50 | justify-content: space-around; 51 | width: 100%; 52 | height: 100%; 53 | top: 0; 54 | left: 0; 55 | /*background: rgba(214, 230, 236, 0.5);*/ 56 | overflow: hidden; 57 | animation: menutrans 100ms linear; 58 | -webkit-animation: menutrans 200ms linear; /*Safari and Chrome*/ 59 | } 60 | 61 | @keyframes menutrans { 62 | from { 63 | height: 0; 64 | } 65 | to { 66 | height: 100%; 67 | } 68 | } 69 | 70 | @-webkit-keyframes menutrans /*Safari and Chrome*/ { 71 | from { 72 | height: 0; 73 | } 74 | to { 75 | height: 100%; 76 | } 77 | } 78 | 79 | .sortable-ghost { 80 | opacity: 0.5; 81 | background: #c8ebfb; 82 | } 83 | 84 | @media (prefers-color-scheme: dark) { 85 | .site-noicon:hover a { 86 | color: #539bf5; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | // @ts-ignore 4 | import App from './App'; 5 | import { Provider as StoreProvider } from 'react-redux'; 6 | import store from './redux/store'; 7 | import './index.css'; 8 | 9 | ReactDOM.createRoot(document.getElementById('root')!).render( 10 | 11 | 12 | 13 | 14 | 15 | ); 16 | -------------------------------------------------------------------------------- /src/pages/Home.tsx: -------------------------------------------------------------------------------- 1 | import { useCallback, useEffect, useRef, useState } from 'react'; 2 | // import './App.css'; 3 | import './home.css'; 4 | import HeadBar from '../component/HeadBar/HeadBar'; 5 | import Partition from '../component/Partition/Partition'; 6 | import Fab from '@mui/material/Fab'; 7 | import AddIcon from '@mui/icons-material/Add'; 8 | import FriendSite from '../component/FriendSite/FriendSite'; 9 | import Footer from '../component/Footer/Footer'; 10 | import FeaturePanel from '../component/FeaturePanel/index'; 11 | import SettingsIcon from '@mui/icons-material/Settings'; 12 | import DoneIcon from '@mui/icons-material/Done'; 13 | //import Paper from '@mui/material/Paper'; 14 | //import Grid from '@mui/material/Grid'; 15 | import MarginHead from '../component/MarginHead/MarginHead'; 16 | import PopularSite from '../component/PopularSite/PopularSite'; 17 | import { useDispatch, useSelector } from 'react-redux'; 18 | import { 19 | setDevice, 20 | setSugShow, 21 | setMarchineShow, 22 | setMarchineIndex, 23 | // setUser, 24 | addPart2Rear, 25 | setPartition, 26 | setGlobalMsg, 27 | } from '../redux/actions'; 28 | import Marchinelist from '../utils/SearchMarchine'; 29 | import GyDialog from '../component/GyDialog/GyDialog'; 30 | import Snackbar from '@mui/material/Snackbar'; 31 | //import Button from '@mui/material/Button'; 32 | import { Link } from 'react-router-dom'; 33 | // import Dialog from '@mui/material/Dialog'; 34 | // import DialogActions from '@mui/material/DialogActions'; 35 | // import DialogContent from '@mui/material/DialogContent'; 36 | // import DialogContentText from '@mui/material/DialogContentText'; 37 | // import DialogTitle from '@mui/material/DialogTitle'; 38 | import Tooltip from '@mui/material/Tooltip'; 39 | import { post } from '../utils/http'; 40 | import { ValidToken, GetPartData } from '../utils/Api'; 41 | import { 42 | GetMarchineIndexStore, 43 | // SetUserStore, 44 | GetUserStore, 45 | GetPartDataStore, 46 | } from '../utils/localStorageUtil'; 47 | 48 | import throttle from '../utils/throttle'; 49 | import eventBus from '../utils/EventEmitter'; 50 | import { homeKeyDown } from '../utils/Events'; 51 | import { KeyboardEvent } from 'hono/jsx'; 52 | import { DeviceTypes } from '../redux/types'; 53 | import { StoreType } from '../redux/store'; 54 | 55 | const Home = () => { 56 | const appRef = useRef(null); 57 | const [edit, setEdit] = useState(false); 58 | const [scrolled, setScrolled] = useState(false); 59 | const [addPartOpen, setAddPartOpen] = useState(false); 60 | // const [datas, setDatas] = useState([]); 61 | const userRef = useRef(null); 62 | 63 | const { selectMcIndex, user, globalMsg, Show } = useSelector< 64 | StoreType, 65 | { 66 | device: StoreType['Device']['device']; 67 | selectMcIndex: StoreType['MarchineIndex']['index']; 68 | user: StoreType['User']['user']; 69 | globalMsg: StoreType['GlobalMsg']; 70 | Show: StoreType['Show']; 71 | } 72 | >(({ Device, MarchineIndex, User, GlobalMsg, Show }) => ({ 73 | device: Device.device, 74 | selectMcIndex: MarchineIndex.index, 75 | user: User.user, 76 | globalMsg: GlobalMsg, 77 | Show, 78 | })); 79 | 80 | const dispatch = useDispatch(); 81 | 82 | const handleKeyDown = useCallback((e: KeyboardEvent) => { 83 | console.log('home监听', e); 84 | eventBus.emit(homeKeyDown, [e]); 85 | }, []); 86 | 87 | // const handleScroll = () => { 88 | // if ( 89 | // (window.pageYOffset || 90 | // document.documentElement.scrollTop || 91 | // //safari浏览器的拖动会使其为负数 92 | // document.body.scrollTop) <= 0 93 | // ) { 94 | // setScrolled(false); 95 | // console.log('不添加阴影'); 96 | // } else { 97 | // if (scrolled === false) { 98 | // setScrolled(true); 99 | // console.log('添加阴影'); 100 | // } 101 | // } 102 | // }; 103 | 104 | // eslint-disable-next-line react-hooks/exhaustive-deps 105 | const throttleHandleScroll = useCallback( 106 | throttle(() => { 107 | if ( 108 | (window.pageYOffset || 109 | document.documentElement.scrollTop || 110 | //safari浏览器的拖动会使其为负数 111 | document.body.scrollTop) <= 0 112 | ) { 113 | setScrolled(false); 114 | console.log('不添加阴影'); 115 | } else { 116 | if (scrolled === false) { 117 | setScrolled(true); 118 | console.log('添加阴影'); 119 | } 120 | } 121 | }, 30), 122 | [] 123 | ); 124 | 125 | const initMarchine = () => { 126 | const marchineIndex = GetMarchineIndexStore(); 127 | console.log('启动时读取搜索引擎选择', marchineIndex); 128 | if (marchineIndex !== null && marchineIndex !== undefined) { 129 | dispatch(setMarchineIndex(Number.parseInt(marchineIndex), false)); 130 | } 131 | }; 132 | 133 | const initUser = () => { 134 | const user = GetUserStore(); 135 | if (user !== null && user !== undefined) { 136 | console.log('从本地读取到了用户', user.userName); 137 | userRef.current = user; 138 | } 139 | }; 140 | 141 | // const handleParClose = () => { 142 | // setAddPartOpen(false); 143 | // }; 144 | 145 | const judgeDevice = () => { 146 | const sUserAgent = navigator.userAgent; 147 | const mobileAgents = [ 148 | 'Android', 149 | 'iPhone', 150 | 'Symbian', 151 | 'WindowsPhone', 152 | 'iPod', 153 | 'BlackBerry', 154 | 'Windows CE', 155 | ]; 156 | for (let i = 0; i < mobileAgents.length; i++) { 157 | if (sUserAgent.indexOf(mobileAgents[i]) > -1) { 158 | dispatch(setDevice(DeviceTypes.phone)); 159 | break; 160 | } 161 | } 162 | }; 163 | 164 | useEffect(() => { 165 | document.title = 'GY导航'; 166 | // window.addEventListener('scroll', this.handleScroll); 167 | window.addEventListener('scroll', throttleHandleScroll); 168 | window.addEventListener('keydown', handleKeyDown); 169 | judgeDevice(); 170 | // 读取搜索引擎数据 171 | initMarchine(); 172 | initUser(); 173 | if (userRef.current) { 174 | console.log('验证token'); 175 | post(ValidToken, {}); 176 | } 177 | if (userRef.current === null) { 178 | console.log('读取本地'); 179 | 180 | const partData = GetPartDataStore(); 181 | if (partData) { 182 | dispatch(setPartition(partData, false, false)); 183 | } 184 | } else { 185 | //优先读取网络partData,不成功则读取本地partData 186 | console.log('读取服务器数据...'); 187 | post(GetPartData, {}) 188 | .then((data) => { 189 | console.log('服务器返回的数据', data); 190 | if (data.result) { 191 | console.log('使用服务器的数据'); 192 | dispatch(setPartition(JSON.parse(data.partData), true, false)); 193 | } else { 194 | console.log('使用本地的数据'); 195 | const partData = GetPartDataStore(); 196 | if (partData) { 197 | dispatch(setPartition(partData, false, false)); //从本地读取,所以没必要再存回本地 198 | } 199 | } 200 | }) 201 | .catch((err) => { 202 | console.log('使用本地的数据'); 203 | const partData = GetPartDataStore(); 204 | if (partData) { 205 | dispatch(setPartition(partData, false, false)); //从本地读取,所以没必要再存回本地 206 | } 207 | 208 | console.log(err); 209 | }); 210 | } 211 | return () => { 212 | window.removeEventListener('scroll', throttleHandleScroll); 213 | window.removeEventListener('keydown', handleKeyDown); 214 | }; 215 | }, []); 216 | 217 | const fabColor = Marchinelist[selectMcIndex].color; 218 | 219 | return ( 220 |
{ 224 | if (Show.marchine) { 225 | dispatch(setMarchineShow(false)); 226 | } 227 | if (Show.sug) { 228 | dispatch(setSugShow(false)); 229 | } 230 | }} 231 | > 232 | 233 | 234 | 235 | 236 | 240 | {edit && ( 241 |
249 | { 254 | setAddPartOpen(true); 255 | }} 256 | > 257 | 258 | 259 |
260 | )} 261 | 262 |
263 | { 276 | setEdit((v) => !v); 277 | }} 278 | > 279 | {edit ? ( 280 | 281 | ) : ( 282 | 283 | )} 284 | 285 | 286 | 287 | {}} 301 | > 302 | {user?.userName[0] || '未'} 303 | 304 | 305 | 306 | 307 | { 311 | setAddPartOpen(false); 312 | }} 313 | onCancel={() => { 314 | setAddPartOpen(false); 315 | }} 316 | onConfirm={(partName) => { 317 | if (partName) { 318 | dispatch(addPart2Rear(partName)); 319 | } else { 320 | console.log('给点东西吧'); 321 | } 322 | setAddPartOpen(false); 323 | }} 324 | /> 325 | 326 | { 331 | dispatch(setGlobalMsg('', false)); 332 | }} 333 | message={globalMsg.msg} 334 | key={'globalMsg'} 335 | /> 336 |
337 | ); 338 | }; 339 | 340 | export default Home; 341 | -------------------------------------------------------------------------------- /src/pages/Login.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useRef, useState } from 'react'; 2 | // import LoginRegister from 'react-mui-login-register'; 3 | import { useDispatch, useSelector } from 'react-redux'; 4 | import { setUser, setPartition } from '../redux/actions'; 5 | import { 6 | AppBar, 7 | Toolbar, 8 | Typography, 9 | Paper, 10 | Button, 11 | Avatar, 12 | } from '@mui/material'; 13 | import Tabs from '@mui/material/Tabs'; 14 | import Tab from '@mui/material/Tab'; 15 | import TextField from '@mui/material/TextField'; 16 | import { post } from '../utils/http'; 17 | import { Signin, SignUp } from '../utils/Api'; 18 | import { pswPattern } from '../utils/veriLink'; 19 | import { Link } from 'react-router-dom'; 20 | import './login.css'; 21 | 22 | import { 23 | SetUserStore, 24 | GetTokenStore, 25 | SetTokenStore, 26 | GetUserStore, 27 | } from '../utils/localStorageUtil'; 28 | import { history } from '../router/router'; 29 | import { StoreType } from '../redux/store'; 30 | 31 | function a11yProps(index: number) { 32 | return { 33 | id: `full-width-tab-${index}`, 34 | 'aria-controls': `full-width-tabpanel-${index}`, 35 | }; 36 | } 37 | 38 | const Login = () => { 39 | const [index, setIndex] = useState(0); 40 | const [userName, setUserName] = useState(''); 41 | const [passWord, setPassWord] = useState(''); 42 | const [passWord1, setPassWord1] = useState(''); 43 | const [tipText, setTipText] = useState(''); 44 | const [validToken, setValidToken] = useState(false); 45 | const userRef = useRef(null); 46 | 47 | const { user, Partition } = useSelector< 48 | StoreType, 49 | { 50 | // device: StoreType['Device']['device']; 51 | user: StoreType['User']['user']; 52 | Partition: StoreType['Partition']['data']; 53 | } 54 | >(({ User, Partition }) => ({ 55 | // device: Device.device, 56 | user: User.user, 57 | Partition: Partition.data, 58 | })); 59 | 60 | const dispatch = useDispatch(); 61 | 62 | const initUser = () => { 63 | const user = GetUserStore(); 64 | if (user !== null && user !== undefined) { 65 | console.log('从本地读取到了用户', user.userName); 66 | userRef.current = user; 67 | } 68 | }; 69 | 70 | useEffect(() => { 71 | document.title = '注册/登陆'; 72 | initUser(); 73 | if (userRef.current !== null) { 74 | // let userinfo = localStorage.getItem("userInfo"); 75 | // console.log(userinfo); 76 | // this.props.setUser(JSON.parse(userinfo)) 77 | // let userinfo = GetlocalStorage('userInfo'); 78 | // this.props.setUser(userinfo); 79 | setUserName(userRef.current.userName); 80 | setPassWord(userRef.current.passWord); 81 | } 82 | const token = GetTokenStore(); 83 | if (token) { 84 | setValidToken(true); 85 | } 86 | }, []); 87 | 88 | const handleChange = (_: any, newValue: number) => { 89 | // setValue(newValue); 90 | // console.log(newValue) 91 | // this.setState({ 92 | // index: newValue, 93 | // tipText: '', 94 | // }); 95 | setIndex(newValue); 96 | setTipText(''); 97 | }; 98 | 99 | const handleSignin = () => { 100 | if (!userName || !passWord) return; 101 | const data = { userName, passWord }; 102 | post(Signin, data) 103 | .then((data) => { 104 | console.log(data); 105 | if (data.result === false) { 106 | setTipText(data.msg); 107 | return; 108 | } 109 | 110 | //剔除partData属性,并把相关东西存起来 111 | //localStorage.userInfo = JSON.stringify(data); 112 | //SetlocalStorage('userInfo',data); 113 | 114 | const user = data.user; 115 | const partData = user.partData; 116 | delete user.partData; 117 | user.passWord = passWord; 118 | 119 | dispatch(setPartition(JSON.parse(partData), true, false)); 120 | dispatch(setUser(user)); 121 | 122 | history.replace('/'); 123 | }) 124 | .catch((err) => { 125 | console.log(err); 126 | }); 127 | }; 128 | 129 | const handleSignup = () => { 130 | if (passWord.length < 6 || pswPattern.test(passWord)) { 131 | setTipText('密码不能少于6位,且不能含有中文'); 132 | return; 133 | } 134 | if (passWord !== passWord1) { 135 | setTipText('两次输入的密码不一致'); 136 | return; 137 | } 138 | 139 | const data = { 140 | userName, 141 | passWord, 142 | partData: JSON.stringify(Partition), 143 | }; 144 | post(SignUp, data) 145 | .then((data) => { 146 | console.log(data); 147 | if (data.result === false) { 148 | setTipText(data.msg); 149 | return; 150 | } 151 | 152 | //TODO 剔除partData属性 153 | 154 | const user = data.user; 155 | const partData = user.partData; 156 | delete user.partData; 157 | user.passWord = passWord; 158 | 159 | dispatch(setPartition(JSON.parse(partData), true, false)); 160 | dispatch(setUser(user)); 161 | 162 | history.replace('/'); 163 | }) 164 | .catch((err) => { 165 | console.log(err); 166 | }); 167 | }; 168 | 169 | const isLogin = user !== null && validToken; 170 | 171 | return ( 172 |
173 |
174 | 175 | {isLogin ? ( 176 |
177 | 178 | 179 | 180 | {'欢迎你, ' + user?.userName} 181 | 182 | 183 | 184 |
185 |
193 | {user?.userName?.[0]} 194 |
195 | 196 | 197 | 204 | 205 | 218 |
219 |
220 | ) : ( 221 |
222 | 223 | 224 | 225 | 欢迎 226 | 227 | 228 | 237 | 238 | 239 | 240 | 241 | {index === 0 && ( 242 |
243 | { 249 | setUserName(event.target.value); 250 | setTipText(''); 251 | }} 252 | /> 253 | { 260 | setPassWord(event.target.value); 261 | setTipText(''); 262 | }} 263 | /> 264 | {tipText &&
{tipText}
} 265 | 266 | 277 |
278 | )} 279 | {index === 1 && ( 280 |
281 | { 287 | setUserName(event.target.value); 288 | setTipText(''); 289 | }} 290 | /> 291 | { 298 | setPassWord(event.target.value); 299 | setTipText(''); 300 | }} 301 | /> 302 | { 309 | setPassWord1(event.target.value); 310 | setTipText(''); 311 | }} 312 | /> 313 | {tipText &&
{tipText}
} 314 | 325 |
326 | )} 327 |
328 | )} 329 |
330 |
331 |
332 | ); 333 | }; 334 | 335 | export default Login; 336 | -------------------------------------------------------------------------------- /src/pages/NotFound.tsx: -------------------------------------------------------------------------------- 1 | function NotFound() { 2 | return ( 3 |
4 |

404 Not Found

5 |

请联系网站管理员

6 |
7 | ); 8 | } 9 | 10 | export default NotFound; 11 | -------------------------------------------------------------------------------- /src/pages/home.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailuoku6/gy_nav/9afb9ddf3310f19f0747c44ead767e08c73f954a/src/pages/home.css -------------------------------------------------------------------------------- /src/pages/login.css: -------------------------------------------------------------------------------- 1 | a:hover { 2 | text-decoration: none; 3 | } 4 | 5 | .login-wrap { 6 | width: 100%; 7 | height: 100vh; 8 | display: flex; 9 | justify-content: center; 10 | background-color: rgb(3, 169, 244); 11 | } 12 | 13 | @media (prefers-color-scheme: dark) { 14 | .login-wrap { 15 | background-color: #22272e; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/redux/actions.ts: -------------------------------------------------------------------------------- 1 | import { 2 | TYPE, 3 | IUserData, 4 | DeviceTypes, 5 | PartSiteData, 6 | PopularSite, 7 | } from './types'; 8 | 9 | export const setUser = (user: IUserData | null, isStore = true) => ({ 10 | type: TYPE.SET_USER, 11 | user, 12 | isStore, 13 | }); 14 | 15 | export const setDevice = (device: DeviceTypes) => ({ 16 | type: TYPE.SET_DEVICE, 17 | device, 18 | }); 19 | export const setMarchineShow = (show: boolean) => ({ 20 | type: TYPE.SET_MARCHINE_SHOW, 21 | show, 22 | }); 23 | export const setSugShow = (show: boolean) => ({ 24 | type: TYPE.SET_SUG_SHOW, 25 | show, 26 | }); 27 | export const setMarchineIndex = (index: number, isStore = true) => ({ 28 | type: TYPE.SET_MARCHINE_INDEX, 29 | index, 30 | isStore, 31 | }); 32 | 33 | export const setPartition = ( 34 | partition: PartSiteData[], 35 | isStore = true, 36 | isUp = true 37 | ) => ({ 38 | type: TYPE.SET_PARTITION, 39 | partition, 40 | isStore, 41 | isUp, 42 | }); 43 | 44 | export const addPart2Rear = (partName: string) => ({ 45 | type: TYPE.ADD_PART2REAR, 46 | partName, 47 | }); 48 | 49 | export const addSite2Part = ( 50 | partIndex: number, 51 | siteName: string, 52 | siteAddr: string 53 | ) => ({ 54 | type: TYPE.ADD_SITE2PART, 55 | partIndex, 56 | siteName, 57 | siteAddr, 58 | }); 59 | 60 | export const delPart = (index: number) => ({ 61 | type: TYPE.DEL_PART, 62 | index, 63 | }); 64 | 65 | export const delSite = (partIndex: number, siteIndex: number) => ({ 66 | type: TYPE.DEL_SITE, 67 | partIndex, 68 | siteIndex, 69 | }); 70 | 71 | export const modifyPart = (partIndex: number, partName: string) => ({ 72 | type: TYPE.MODIFY_PART, 73 | partIndex, 74 | partName, 75 | }); 76 | 77 | export const modifySite = ( 78 | partIndex: number, 79 | siteIndex: number, 80 | siteName: string, 81 | siteAddr: string 82 | ) => ({ 83 | type: TYPE.MODIFY_SITE, 84 | partIndex, 85 | siteIndex, 86 | siteName, 87 | siteAddr, 88 | }); 89 | 90 | export const movePart = (oldPartIndex: number, curPartIndex: number) => ({ 91 | type: TYPE.MOVE_PART, 92 | oldPartIndex, 93 | curPartIndex, 94 | }); 95 | 96 | export const moveSite = ( 97 | partIndex: number, 98 | oldSiteIndex: number, 99 | curSiteIndex: number 100 | ) => ({ 101 | type: TYPE.MOVE_SITE, 102 | partIndex, 103 | oldSiteIndex, 104 | curSiteIndex, 105 | }); 106 | 107 | export const insertPart = (index: number, part: PartSiteData) => ({ 108 | type: TYPE.INSERT_PART, 109 | index, 110 | part, 111 | }); 112 | 113 | export const setGlobalMsg = (msg: string, show: boolean) => ({ 114 | type: TYPE.SET_GLOBALMSG, 115 | msg, 116 | show, 117 | }); 118 | 119 | export const setPopularSite = (pSite: PopularSite[]) => ({ 120 | type: TYPE.SET_POPULARSITE, 121 | pSite, 122 | }); 123 | -------------------------------------------------------------------------------- /src/redux/middleware/handlePart.ts: -------------------------------------------------------------------------------- 1 | 2 | // @ts-ignore 3 | import debounce from '../../utils/debounce'; 4 | // import { TYPE } from '../actions'; 5 | import { TYPE } from '../types'; 6 | // @ts-ignore 7 | import { UpPartData } from '../../utils/Api'; 8 | import { 9 | SetMarchineIndexStore, 10 | SetUserStore, 11 | SetPartDataStore, 12 | // @ts-ignore 13 | } from '../../utils/localStorageUtil'; 14 | // @ts-ignore 15 | import { post } from '../../utils/http'; 16 | import { PartSiteData } from '../types'; 17 | import { AnyAction, Dispatch, MiddlewareAPI } from 'redux'; 18 | 19 | const debounceGet = debounce((_data: any) => { 20 | //get('http://www.baidu.com',data); 21 | }, 1500); 22 | 23 | const debouncePost = debounce((data: PartSiteData[]) => { 24 | post(UpPartData, { partData: JSON.stringify(data) }); 25 | }, 1500); 26 | 27 | const debounceStorePart = debounce((partData: PartSiteData[]) => { 28 | //防止频繁写入 29 | SetPartDataStore(partData); 30 | }, 1000); 31 | 32 | const handlePart = 33 | (store: MiddlewareAPI) => 34 | (next: Dispatch) => 35 | (action: any) => { 36 | // console.log('prev state',store.getState()) 37 | console.log('dispatch', action); 38 | 39 | const result = next(action); 40 | 41 | //console.log('next state',store.getState()); 42 | if ( 43 | action.type.indexOf('PART') !== -1 || 44 | action.type.indexOf('SITE') !== -1 45 | ) { 46 | console.log('修改分区时触发'); 47 | debounceGet(store.getState().Partition.data); 48 | if (action.type === TYPE.SET_PARTITION) { 49 | // 50 | if (action.isStore) debounceStorePart(store.getState().Partition.data); 51 | if (action.isUp && store.getState().User.user) 52 | debouncePost(store.getState().Partition.data); 53 | } else { 54 | debounceStorePart(store.getState().Partition.data); 55 | if (store.getState().User.user) { 56 | debouncePost(store.getState().Partition.data); 57 | } 58 | } 59 | } else if (action.type === TYPE.SET_MARCHINE_INDEX && action.isStore) { 60 | console.log('保存搜索引擎选择', store.getState().MarchineIndex.index); 61 | SetMarchineIndexStore(store.getState().MarchineIndex.index); 62 | } else if (action.type === TYPE.SET_USER && action.isStore) { 63 | const user = store.getState().User.user; 64 | SetUserStore(user); 65 | } 66 | 67 | return result; 68 | }; 69 | 70 | export default handlePart; 71 | -------------------------------------------------------------------------------- /src/redux/reducer.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-case-declarations */ 2 | import { combineReducers } from 'redux'; 3 | // import { TYPE } from './actions'; 4 | import data from '../utils/data'; 5 | import { popularSite } from '../utils/data'; 6 | 7 | import { 8 | IUserData, 9 | DeviceTypes, 10 | PopularSite as IPopularSite, 11 | PartSiteData, 12 | TYPE, 13 | IShowAction, 14 | IPartitionAction, 15 | } from './types'; 16 | 17 | const User = ( 18 | state: { user: IUserData | null | undefined } = { user: null }, 19 | action: { type: string; user: IUserData | null | undefined } 20 | ) => { 21 | console.log('设置user', state.user, action.user); 22 | switch (action.type) { 23 | case TYPE.SET_USER: 24 | //if(action.user===state.user) return state; 25 | const user = action.user !== undefined ? action.user : state.user; 26 | console.log('下一个user', action, user); 27 | return { ...state, user: user }; 28 | default: 29 | return { ...state }; 30 | } 31 | }; 32 | 33 | const Device = ( 34 | state: { device: DeviceTypes } = { device: DeviceTypes.pc }, 35 | action: { type: string; device: DeviceTypes } 36 | ) => { 37 | switch (action.type) { 38 | case TYPE.SET_DEVICE: 39 | return { ...state, device: action.device }; 40 | default: 41 | return { ...state }; 42 | } 43 | }; 44 | 45 | const Show = ( 46 | state: { marchine: boolean; sug: boolean } = { marchine: false, sug: false }, 47 | action: IShowAction 48 | ) => { 49 | switch (action.type) { 50 | case TYPE.SET_MARCHINE_SHOW: 51 | //if(action.show===state.marchine) return state; 52 | return { ...state, marchine: action.show }; 53 | case TYPE.SET_SUG_SHOW: 54 | //if(action.show===state.sug) return state; 55 | return { ...state, sug: action.show }; 56 | default: 57 | return { ...state }; 58 | } 59 | }; 60 | 61 | const MarchineIndex = ( 62 | state: { index: number } = { index: 0 }, 63 | action: { type: string; index: number } 64 | ) => { 65 | switch (action.type) { 66 | case TYPE.SET_MARCHINE_INDEX: 67 | return { ...state, index: action.index }; 68 | default: 69 | return { ...state }; 70 | } 71 | }; 72 | 73 | const Partition = ( 74 | state: { data: PartSiteData[] } = { data: data }, 75 | action: IPartitionAction 76 | ): { data: PartSiteData[] } => { 77 | console.log('partData被修改', action, state); 78 | const data = [...state.data]; 79 | switch (action.type) { 80 | case TYPE.ADD_PART2REAR: 81 | const newPart: Partial = {}; 82 | newPart.categoryname = action.partName; 83 | newPart.sitelist = []; 84 | data.push(newPart as PartSiteData); 85 | return { ...state, data: data }; 86 | case TYPE.ADD_SITE2PART: 87 | const sitelist = [...data[action.partIndex || 0].sitelist]; 88 | sitelist.push({ 89 | url: action.siteAddr || '', 90 | site_name: action.siteName || '', 91 | }); 92 | data[action.partIndex || 0].sitelist = sitelist; 93 | return { ...state, data: data }; 94 | case TYPE.DEL_PART: 95 | data.splice(action.index || 0, 1); 96 | return { ...state, data: data }; 97 | case TYPE.DEL_SITE: 98 | console.log('删除站点', data, action); 99 | // data[action.partIndex].siteList.splice(action.siteIndex,1); 100 | const pSiteList = [...data[action.partIndex || 0].sitelist]; 101 | pSiteList.splice(action.siteIndex || 0, 1); 102 | data[action.partIndex || 0].sitelist = pSiteList; 103 | return { ...state, data: data }; 104 | case TYPE.MODIFY_PART: 105 | data[action.partIndex || 0].categoryname = action.partName || ''; 106 | return { ...state, data: data }; 107 | case TYPE.MODIFY_SITE: 108 | //data[action.partIndex].siteList[action.siteIndex] = action.site; 109 | const pSiteList__ = [...data[action.partIndex || 0].sitelist]; 110 | pSiteList__[action.siteIndex || 0] = { 111 | url: action.siteAddr || '', 112 | site_name: action.siteName || '', 113 | }; 114 | data[action.partIndex || 0].sitelist = pSiteList__; 115 | return { ...state, data: data }; 116 | case TYPE.SET_PARTITION: 117 | //state.data = action.partition; 118 | return { ...state, data: action.partition || [] }; 119 | case TYPE.MOVE_PART: 120 | const temp = data[action.oldPartIndex]; 121 | data.splice(action.oldPartIndex, 1); 122 | data.splice(action.curPartIndex, 0, temp); 123 | return { ...state, data: data }; 124 | case TYPE.MOVE_SITE: 125 | const pSiteList_ = [...data[action.partIndex].sitelist]; 126 | const temp_ = pSiteList_[action.oldSiteIndex]; 127 | pSiteList_.splice(action.oldSiteIndex, 1); 128 | pSiteList_.splice(action.curSiteIndex, 0, temp_); 129 | data[action.partIndex || 0].sitelist = pSiteList_; 130 | return { ...state, data: data }; 131 | case TYPE.INSERT_PART: 132 | data.splice(action.index || 0, 0, action.part); 133 | return { ...state, data: data }; 134 | default: 135 | return { ...state }; 136 | } 137 | }; 138 | 139 | const GlobalMsg = ( 140 | state: { show: boolean; msg: string } = { show: false, msg: '' }, 141 | action: { type: string; show: boolean; msg: string } 142 | ) => { 143 | switch (action.type) { 144 | case TYPE.SET_GLOBALMSG: 145 | return { ...state, show: action.show, msg: action.msg }; 146 | default: 147 | return { ...state }; 148 | } 149 | }; 150 | 151 | const PopularSite = ( 152 | state: { pSite: IPopularSite[] } = { pSite: popularSite }, 153 | action: { type: string; pSite: IPopularSite[] } 154 | ) => { 155 | switch (action.type) { 156 | case TYPE.SET_POPULARSITE: 157 | return { ...state, pSite: action.pSite }; 158 | default: 159 | return { ...state }; 160 | } 161 | }; 162 | 163 | export default combineReducers({ 164 | User, 165 | Device, 166 | Show, 167 | MarchineIndex, 168 | Partition, 169 | GlobalMsg, 170 | PopularSite, 171 | }); 172 | -------------------------------------------------------------------------------- /src/redux/store.ts: -------------------------------------------------------------------------------- 1 | import { createStore } from 'redux'; 2 | import reducer from './reducer'; 3 | 4 | import handlePart from './middleware/handlePart'; 5 | import { applyMiddleware } from 'redux'; 6 | 7 | const store = createStore(reducer, applyMiddleware(handlePart)); 8 | 9 | 10 | export type StoreType = ReturnType; 11 | 12 | export default store; 13 | -------------------------------------------------------------------------------- /src/redux/types/index.ts: -------------------------------------------------------------------------------- 1 | export interface IUserData { 2 | id: string; 3 | userName: string; 4 | passWord?: string; 5 | } 6 | 7 | export enum DeviceTypes { 8 | pc = 'pc', 9 | phone = 'phone', 10 | } 11 | 12 | export interface ISite { 13 | site_name: string; 14 | url: string; 15 | id?: number; 16 | } 17 | 18 | export type PartSiteData = { 19 | categoryname: string; 20 | sitelist: ISite[]; 21 | }; 22 | 23 | export type PopularSite = ISite & { 24 | icon: string; 25 | }; 26 | 27 | export enum TYPE { 28 | SET_USER = 'SET_USER', 29 | SET_DEVICE = 'SET_DEVICE', 30 | SET_MARCHINE_SHOW = 'SET_MARCHINE_SHOW', 31 | SET_SUG_SHOW = 'SET_SUG_SHOW', 32 | SET_MARCHINE_INDEX = 'SET_MARCHINE_INDEX', 33 | ADD_PART2REAR = 'ADD_PART2REAR', 34 | INSERT_PART = 'INSERT_PART', 35 | ADD_SITE2PART = 'ADD_SITE2PART', 36 | DEL_PART = 'DEL_PART', 37 | DEL_SITE = 'DEL_SITE', 38 | MODIFY_PART = 'MODIFY_PART', 39 | MODIFY_SITE = 'MODIFY_SITE', 40 | SET_PARTITION = 'SET_PARTITION', 41 | MOVE_PART = 'MOVE_PART', 42 | MOVE_SITE = 'MOVE_SITE', 43 | SET_GLOBALMSG = 'SET_GLOBALMSG', 44 | SET_POPULARSITE = 'SET_POPULARSITE', 45 | } 46 | 47 | export type IShowAction = 48 | | { 49 | type: TYPE.SET_MARCHINE_SHOW; 50 | show: boolean; 51 | } 52 | | { 53 | type: TYPE.SET_SUG_SHOW; 54 | show: boolean; 55 | }; 56 | 57 | export type IPartitionAction = 58 | | { 59 | type: TYPE.ADD_PART2REAR; 60 | partName: string; 61 | } 62 | | { 63 | type: TYPE.ADD_SITE2PART; 64 | partIndex: number; 65 | siteAddr: string; 66 | siteName: string; 67 | } 68 | | { 69 | type: TYPE.DEL_PART; 70 | index: number; 71 | } 72 | | { 73 | type: TYPE.DEL_SITE; 74 | partIndex: number; 75 | siteIndex: number; 76 | } 77 | | { 78 | type: TYPE.MODIFY_PART; 79 | partIndex: number; 80 | partName: string; 81 | } 82 | | { 83 | type: TYPE.MODIFY_SITE; 84 | partIndex: number; 85 | siteIndex: number; 86 | siteAddr: string; 87 | siteName: string; 88 | } 89 | | { 90 | type: TYPE.SET_PARTITION; 91 | partition?: PartSiteData[]; 92 | } 93 | | { 94 | type: TYPE.MOVE_PART; 95 | oldPartIndex: number; 96 | curPartIndex: number; 97 | } 98 | | { 99 | type: TYPE.MOVE_SITE; 100 | partIndex: number; 101 | oldSiteIndex: number; 102 | curSiteIndex: number; 103 | } 104 | | { 105 | type: TYPE.INSERT_PART; 106 | index: number; 107 | part: PartSiteData; 108 | }; 109 | -------------------------------------------------------------------------------- /src/router/router.tsx: -------------------------------------------------------------------------------- 1 | import React, { Suspense } from 'react'; 2 | import { CircularProgress } from '@mui/material'; 3 | 4 | const Home = React.lazy(() => import('../pages/Home')); 5 | const Login = React.lazy(() => import('../pages/Login')); 6 | const NotFound = React.lazy(() => import('../pages/NotFound')); 7 | // import About from './pages/about'; 8 | //引入一些模块 9 | //Router 10 | // import { 11 | // BrowserRouter as Router, 12 | // Switch, 13 | // Route, 14 | // Redirect, 15 | // } from 'react-router-dom'; 16 | import { Router, Switch, Route, Redirect } from 'react-router-dom'; 17 | 18 | // @ts-ignore 19 | import { createBrowserHistory } from 'history'; 20 | 21 | const history = createBrowserHistory(); 22 | 23 | const Loading = () => { 24 | return ( 25 |
34 | 35 |
36 | ); 37 | }; 38 | 39 | const route = ( 40 | 41 | 42 | {/**/} 43 | ( 46 | }> 47 | 48 | 49 | )} 50 | /> 51 | ( 54 | }> 55 | 56 | 57 | )} 58 | /> 59 | ( 63 | }> 64 | 65 | 66 | )} 67 | /> 68 | 69 | 70 | 71 | {/**/} 72 | 73 | ); 74 | 75 | function router() { 76 | return route; 77 | } 78 | export { history }; 79 | export default router; 80 | -------------------------------------------------------------------------------- /src/utils/Api.ts: -------------------------------------------------------------------------------- 1 | const SUGTIP = 'https://suggestion.baidu.com/su?wd='; //参数wd,GET 2 | // const BaseUrl_dev = 'http://127.0.0.1:7001'; 3 | const BaseUrl_prod = ''; 4 | const BaseUrl = BaseUrl_prod; 5 | 6 | const Signin = '/api/login'; 7 | const SignUp = '/api/signup'; 8 | const GetPartData = '/api/getPartData'; 9 | const UpPartData = '/api/upPartData'; 10 | const ValidToken = 'api/veriToken'; 11 | const GetAllFS = '/api/getAllFS'; 12 | const WriteRemoteClipBoard = '/api/writeClipBoard'; 13 | const GetRemoteClipBoard = '/api/getClipBoard'; 14 | 15 | const GetInitData = 'getInitData'; 16 | 17 | export { 18 | SUGTIP, 19 | BaseUrl, 20 | Signin, 21 | SignUp, 22 | GetInitData, 23 | ValidToken, 24 | GetPartData, 25 | UpPartData, 26 | GetAllFS, 27 | WriteRemoteClipBoard, 28 | GetRemoteClipBoard, 29 | }; 30 | -------------------------------------------------------------------------------- /src/utils/DoubleClick.ts: -------------------------------------------------------------------------------- 1 | class DoubleClick { 2 | private keys: { [key: number]: Date }; 3 | 4 | constructor() { 5 | this.keys = {}; 6 | } 7 | 8 | // eslint-disable-next-line @typescript-eslint/ban-types 9 | doubleClick(keyCode: number, callBack: Function, args: any[]) { 10 | args = args || []; 11 | const now = new Date(); 12 | const lastTime = this.keys[keyCode]; 13 | // @ts-ignore 14 | if (lastTime && now - lastTime < 200) { 15 | callBack(...args); 16 | } 17 | this.keys[keyCode] = now; 18 | } 19 | } 20 | 21 | const doubleClick = new DoubleClick(); 22 | 23 | export default doubleClick; 24 | -------------------------------------------------------------------------------- /src/utils/EventEmitter.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/ban-types */ 2 | class EventEmitter { 3 | private events: { [key: string]: Array }; 4 | 5 | constructor() { 6 | this.events = {}; 7 | } 8 | 9 | on(event: string, callBack: Function) { 10 | const callBacks = this.events[event] || []; 11 | callBacks.push(callBack); 12 | this.events[event] = callBacks; 13 | } 14 | 15 | off(event: string, callBack: Function) { 16 | const callBacks = this.events[event] || []; 17 | this.events[event] = callBacks.filter((item) => item !== callBack); 18 | // this.events[event] = callBacks; 19 | } 20 | emit(event: string, data: any) { 21 | data = data || []; 22 | const callBacks = this.events[event] || []; 23 | callBacks.forEach((callb) => { 24 | callb(...data); 25 | }); 26 | } 27 | 28 | once(event: string, callBack: Function) { 29 | const func = function () { 30 | // eslint-disable-next-line prefer-rest-params 31 | callBack(...arguments); 32 | // @ts-ignore 33 | this.off(event, func); 34 | }; 35 | this.on(event, func); 36 | } 37 | } 38 | 39 | const eventBus = new EventEmitter(); 40 | 41 | export default eventBus; 42 | -------------------------------------------------------------------------------- /src/utils/Events.ts: -------------------------------------------------------------------------------- 1 | const homeKeyDown = 'homeKeyDown'; 2 | 3 | export { homeKeyDown }; 4 | -------------------------------------------------------------------------------- /src/utils/SearchMarchine.ts: -------------------------------------------------------------------------------- 1 | export interface IMarchine { 2 | Marchine_name: string; 3 | button_value: string; 4 | searApi: string; 5 | searApi_weizui: string; 6 | color: string; 7 | hotkey?: string; 8 | } 9 | 10 | const hotkeyPrefix = 'ctrl'; 11 | 12 | const Marchinelist: IMarchine[] = [ 13 | { 14 | Marchine_name: 'AI搜', 15 | button_value: 'AI搜', 16 | searApi: 'https://metaso.cn/?q=', 17 | searApi_weizui: '&s=hzda0&referrer_s=hzda0', 18 | color: '#175CD3', 19 | hotkey: `${hotkeyPrefix}+a`, 20 | }, 21 | { 22 | Marchine_name: '百度', 23 | button_value: '百度一下', 24 | searApi: 'https://www.baidu.com/s?wd=', 25 | searApi_weizui: '', 26 | color: '#38F', 27 | hotkey: `${hotkeyPrefix}+b`, 28 | }, 29 | { 30 | Marchine_name: '谷歌', 31 | button_value: '谷歌一下', 32 | searApi: 'https://www.google.com/search?q=', 33 | searApi_weizui: '', 34 | color: '#3b78e7', 35 | hotkey: `${hotkeyPrefix}+g`, 36 | }, 37 | { 38 | Marchine_name: '搜狗', 39 | button_value: '搜狗搜索', 40 | searApi: 'https://www.sogou.com/web?query=', 41 | searApi_weizui: '', 42 | color: '#ff5943', 43 | hotkey: `${hotkeyPrefix}+s+g`, 44 | }, 45 | { 46 | Marchine_name: '360搜索', 47 | button_value: '360搜', 48 | searApi: 'https://www.so.com/s?ie=utf-8&fr=none&src=360sou_newhome&q=', 49 | searApi_weizui: '', 50 | color: '#19b955', 51 | hotkey: `${hotkeyPrefix}+3`, 52 | }, 53 | { 54 | Marchine_name: '必应搜索', 55 | button_value: '必应搜索', 56 | searApi: 'https://www.bing.com/search?q=', 57 | searApi_weizui: '', 58 | color: '#1688b1', 59 | hotkey: `${hotkeyPrefix}+b+y`, 60 | }, 61 | { 62 | Marchine_name: '必应CN', 63 | button_value: '必应CN', 64 | searApi: 65 | 'https://cn.bing.com/search?form=QBLH&sp=-1&lq=0&pq=123&sc=12-3&qs=n&sk=&cvid=4EE766F92F614AC8B04A56414D3B40A0&ghsh=0&ghacc=0&ghpl=&q=', 66 | searApi_weizui: '', 67 | color: '#1688b1', 68 | hotkey: `${hotkeyPrefix}+b+c`, 69 | }, 70 | { 71 | Marchine_name: 'Github', 72 | button_value: 'Github', 73 | searApi: 'https://github.com/search?q=', 74 | searApi_weizui: '', 75 | color: '#00302e', 76 | hotkey: `${hotkeyPrefix}+g+h`, 77 | }, 78 | { 79 | Marchine_name: '知乎搜索', 80 | button_value: '知乎搜索', 81 | searApi: 'https://www.zhihu.com/search?type=content&q=', 82 | searApi_weizui: '', 83 | color: '#0077e6', 84 | }, 85 | { 86 | Marchine_name: '百度文库', 87 | button_value: '搜文库', 88 | searApi: 'https://wk.baidu.com/search?word=', 89 | searApi_weizui: '', 90 | color: '#38F', 91 | }, 92 | { 93 | Marchine_name: '图片搜索', 94 | button_value: '图片搜索', 95 | searApi: 'http://image.so.com/i?q=', 96 | searApi_weizui: '&src=srp', 97 | color: '#19b955', 98 | }, 99 | { 100 | Marchine_name: '贴吧', 101 | button_value: '贴吧搜索', 102 | searApi: 'https://tieba.baidu.com/f?kw=', 103 | searApi_weizui: '', 104 | color: '#38F', 105 | }, 106 | { 107 | Marchine_name: '知道', 108 | button_value: '百度知道', 109 | searApi: 'https://zhidao.baidu.com/search?word=', 110 | searApi_weizui: '', 111 | color: '#38F', 112 | }, 113 | { 114 | Marchine_name: '网盘', 115 | button_value: '搜网盘', 116 | searApi: 'http://www.panduoduo.net/s/name/', 117 | searApi_weizui: '', 118 | color: '#3f51b5', 119 | }, 120 | { 121 | Marchine_name: 'csdn', 122 | button_value: '搜csdn', 123 | searApi: 'http://so.csdn.net/so/search/s.do?q=', 124 | searApi_weizui: '', 125 | color: '#be1a21', 126 | }, 127 | ]; 128 | 129 | export default Marchinelist; 130 | -------------------------------------------------------------------------------- /src/utils/clipboard.ts: -------------------------------------------------------------------------------- 1 | export async function readFromClipboard() { 2 | try { 3 | const text = await navigator.clipboard.readText(); 4 | console.log('Text read from clipboard: ', text); 5 | return text; 6 | } catch (err) { 7 | console.error('Failed to read from clipboard: ', err); 8 | } 9 | } 10 | 11 | export async function writeToClipboard(text: string) { 12 | try { 13 | await navigator.clipboard.writeText(text); 14 | console.log('Text copied to clipboard'); 15 | } catch (err) { 16 | console.error('Failed to write to clipboard: ', err); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/utils/data.ts: -------------------------------------------------------------------------------- 1 | import baidu from '../assets/baidu.png'; 2 | import taobao from '../assets/taobao.png'; 3 | import jd from '../assets/jd.png'; 4 | import zhihu from '../assets/zhihu.png'; 5 | import googlefanyi from '../assets/googlefanyi.png'; 6 | import github from '../assets/github.png'; 7 | import qqmail from '../assets/qqmail.png'; 8 | import weibo from '../assets/weibo.png'; 9 | import wangyiyun from '../assets/wangyiyun.png'; 10 | 11 | import { PartSiteData, PopularSite } from '../redux/types'; 12 | 13 | const data: PartSiteData[] = [ 14 | { 15 | categoryname: '酷站', 16 | sitelist: [ 17 | { site_name: '创造狮', url: 'http://www.chuangzaoshi.com/' }, 18 | { site_name: '果壳网', url: 'http://www.guokr.com' }, 19 | { site_name: '36氪', url: 'http://36kr.com' }, 20 | { site_name: '网易公开课', url: 'http://open.163.com' }, 21 | { site_name: '中国科学引文数据库', url: 'http://sdb.csdl.ac.cn' }, 22 | { site_name: 'CALIS学位论文库', url: 'http://www.calis.edu.cn' }, 23 | { site_name: 'Justin Guitar', url: 'http://www.justinguitar.com' }, 24 | { site_name: '中国知网', url: 'http://www.cnki.net' }, 25 | { site_name: '中国大学MOOC', url: 'http://www.icourse163.org/' }, 26 | ], 27 | }, 28 | { 29 | categoryname: '办公与邮箱', 30 | sitelist: [ 31 | { site_name: '演界网', url: 'http://www.yanj.cn' }, 32 | { 33 | site_name: 'officeplus', 34 | url: 'http://office.mmais.com.cn/Template/Home.shtml', 35 | }, 36 | { site_name: '欧酷PPT', url: 'http://www.pptxok.com' }, 37 | { site_name: '稻壳网', url: 'http://www.docer.com' }, 38 | { 39 | site_name: 'Material Design文档', 40 | url: 'https://www.mdui.org/design/material-design/introduction.html#', 41 | }, 42 | { site_name: '网易163邮箱', url: 'http://mail.163.com/' }, 43 | { site_name: 'QQ邮箱', url: 'https://mail.qq.com' }, 44 | { site_name: '阿里邮箱', url: 'https://mail.aliyun.com/' }, 45 | ], 46 | }, 47 | { 48 | categoryname: '音乐与视频', 49 | sitelist: [ 50 | { site_name: 'QQ音乐', url: 'https://y.qq.com/' }, 51 | { site_name: '网易云音乐', url: 'http://music.163.com/' }, 52 | { site_name: '酷狗音乐', url: 'http://www.kugou.com/' }, 53 | { site_name: '百度音乐', url: 'http://music.baidu.com/' }, 54 | { site_name: '腾讯视频', url: 'https://v.qq.com/' }, 55 | { site_name: '优酷视频', url: 'http://www.youku.com/' }, 56 | { site_name: '爱奇艺视频', url: 'http://www.iqiyi.com/' }, 57 | { site_name: '哔哩哔哩', url: 'https://www.bilibili.com/' }, 58 | { site_name: '乐视视频', url: 'http://www.le.com/' }, 59 | ], 60 | }, 61 | { 62 | categoryname: '少壮不努力,长大学设计', 63 | sitelist: [ 64 | { site_name: '创意人', url: 'http://www.ccihr.com' }, 65 | { site_name: '全景网', url: 'http://www.quanjing.com/' }, 66 | { site_name: '花瓣网', url: 'http://www.huaban.com' }, 67 | { site_name: 'UI中国', url: 'http://www.ui.cn/' }, 68 | { site_name: '千图网', url: 'http://www.58pic.com/' }, 69 | { site_name: 'Dribbble', url: 'https://dribbble.com/' }, 70 | { site_name: '阿里图标平台', url: 'http://www.iconfont.cn/plus' }, 71 | { site_name: 'Easyicon', url: 'http://www.easyicon.net/' }, 72 | { site_name: 'Sketch站点资源', url: 'http://sketch.im/' }, 73 | ], 74 | }, 75 | { 76 | categoryname: '购物与剁手', 77 | sitelist: [ 78 | { site_name: '淘宝网', url: 'https://www.taobao.com/' }, 79 | { site_name: '天猫商城', url: 'https://www.tmall.com' }, 80 | { site_name: '京东商城', url: 'http://www.jd.com' }, 81 | { site_name: '当当网', url: 'http://www.dangdang.com' }, 82 | { site_name: '亚马逊', url: 'https://www.amazon.cn/' }, 83 | { site_name: '苏宁易购', url: 'https://www.suning.com' }, 84 | { site_name: '闲鱼二手', url: 'https://2.taobao.com/' }, 85 | { site_name: '支付宝', url: 'https://www.alipay.com/' }, 86 | { site_name: '小米商城', url: 'https://www.mi.com/' }, 87 | { site_name: '快递100', url: 'http://www.kuaidi100.com/' }, 88 | ], 89 | }, 90 | { 91 | categoryname: '实用在线小工具', 92 | sitelist: [ 93 | { site_name: '图片在线压缩', url: 'http://cut.ailuoku6.top/' }, 94 | { site_name: '图片无损放大', url: 'http://waifu2x.udp.jp/' }, 95 | { site_name: '草料二维码', url: 'https://cli.im/' }, 96 | { site_name: 'PS网页版', url: 'http://www.uupoop.com/' }, 97 | { site_name: '在线进制转换', url: 'http://tool.lu/hexconvert/' }, 98 | { site_name: '邮编区号查询', url: 'http://tool.lu/zipcode/' }, 99 | { site_name: '百度网盘搜索', url: 'http://www.pansoso.com/' }, 100 | { site_name: '微词云', url: 'https://www.weiciyun.com/' }, 101 | { site_name: '更多在线工具', url: 'http://tool.lu/' }, 102 | ], 103 | }, 104 | ]; 105 | 106 | const popularSite: PopularSite[] = [ 107 | { site_name: '百度', url: 'https://www.baidu.com/', icon: baidu }, 108 | { site_name: '淘宝', url: 'https://www.taobao.com', icon: taobao }, 109 | { site_name: '京东', url: 'https://www.jd.com', icon: jd }, 110 | { site_name: '知乎', url: 'https://www.zhihu.com', icon: zhihu }, 111 | { 112 | site_name: '谷歌翻译', 113 | url: 'https://translate.google.cn/', 114 | icon: googlefanyi, 115 | }, 116 | { site_name: 'Github', url: 'https://github.com/', icon: github }, 117 | { site_name: 'QQ邮箱', url: 'https://mail.qq.com', icon: qqmail }, 118 | { site_name: '新浪微博', url: 'https://weibo.com', icon: weibo }, 119 | { site_name: '网易云音乐', url: 'https://music.163.com', icon: wangyiyun }, 120 | ]; 121 | 122 | export { popularSite }; 123 | 124 | export default data; 125 | -------------------------------------------------------------------------------- /src/utils/debounce.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/ban-types 2 | const debounce = (func: Function, wait = 0) => { 3 | let timeout: number | null = null; 4 | let args: any[] | undefined; 5 | function debounced(...arg: any[]) { 6 | args = arg; 7 | if (timeout) { 8 | clearTimeout(timeout); 9 | timeout = null; 10 | } 11 | // 以Promise的形式返回函数执行结果 12 | return new Promise((res, rej) => { 13 | timeout = setTimeout(async () => { 14 | try { 15 | // @ts-ignore 16 | const result = await func.apply(this, args); 17 | res(result); 18 | console.log('啊啊啊啊啊', timeout); 19 | } catch (e) { 20 | rej(e); 21 | } 22 | }, wait); 23 | }); 24 | } 25 | // 允许取消 26 | function cancel() { 27 | if (timeout) { 28 | clearTimeout(timeout); 29 | } 30 | 31 | timeout = null; 32 | } 33 | // 允许立即执行 34 | function flush() { 35 | cancel(); 36 | // @ts-ignore 37 | return func.apply(this, args); 38 | } 39 | debounced.cancel = cancel; 40 | debounced.flush = flush; 41 | return debounced; 42 | }; 43 | 44 | export default debounce; 45 | -------------------------------------------------------------------------------- /src/utils/device.ts: -------------------------------------------------------------------------------- 1 | export function isSafari() { 2 | const userAgent = navigator.userAgent; 3 | return ( 4 | userAgent.includes('Safari') && 5 | !userAgent.includes('Chrome') && 6 | !userAgent.includes('CriOS') 7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /src/utils/http.ts: -------------------------------------------------------------------------------- 1 | /**axios封装 2 | * 请求拦截、相应拦截、错误统一处理 3 | */ 4 | import axios from 'axios'; 5 | import QS from 'qs'; 6 | import { BaseUrl } from './Api'; 7 | import { GetTokenStore, SetTokenStore } from './localStorageUtil'; 8 | import { history } from '../router/router'; 9 | 10 | const backToLogin = () => { 11 | history.replace('/login'); 12 | }; 13 | 14 | // const BaseUrl = "http://127.0.0.1:7001/"; 15 | 16 | // 环境的切换 17 | // if (process.env.NODE_ENV == 'development') { 18 | // axios.defaults.baseURL = '/api'; 19 | // } else if (process.env.NODE_ENV == 'debug') { 20 | // axios.defaults.baseURL = ''; 21 | // } else if (process.env.NODE_ENV == 'production') { 22 | // axios.defaults.baseURL = 'http://api.123dailu.com/'; 23 | // } 24 | 25 | axios.defaults.baseURL = ''; 26 | 27 | // 请求超时时间 28 | axios.defaults.timeout = 3000; 29 | 30 | // post请求头 31 | axios.defaults.headers.post['Content-Type'] = 32 | 'application/x-www-form-urlencoded;charset=UTF-8'; 33 | 34 | // 请求拦截器 35 | axios.interceptors.request.use( 36 | (config) => { 37 | // 每次发送请求之前判断是否存在token,如果存在,则统一在http请求的header都加上token,不用每次请求都手动添加了 38 | // 即使本地存在token,也有可能token是过期的,所以在响应拦截器中要对返回状态进行判断 39 | // const token = store.state.token; 40 | // token && (config.headers.Authorization = token); 41 | // return config; 42 | const token = GetTokenStore(); 43 | if (token) { 44 | // 判断是否存在token,如果存在的话,则每个http header都加上token 45 | // Bearer是JWT的认证头部信息 46 | config.headers.common['Authorization'] = 'Bearer ' + token; 47 | } 48 | return config; 49 | }, 50 | (error) => { 51 | return Promise.reject(error); 52 | } 53 | ); 54 | 55 | // 响应拦截器 56 | axios.interceptors.response.use( 57 | (response) => { 58 | if (response.status === 200) { 59 | console.log(response); 60 | const data = response.data; 61 | if (data.token) { 62 | SetTokenStore(data.token); 63 | } 64 | return Promise.resolve(response); 65 | } else { 66 | return Promise.reject(response); 67 | } 68 | }, 69 | // 服务器状态码不是200的情况 70 | (error) => { 71 | const status = (error.response && error.response.status) || null; 72 | // console.log("尝试跳转到登陆"); 73 | if (status) { 74 | // console.log("尝试跳转到登陆"); 75 | switch (status) { 76 | // 401: 未登录 77 | // 未登录则跳转登录页面,并携带当前页面的路径 78 | // 在登录成功后返回当前页面,这一步需要在登录页操作。 79 | case 401: 80 | backToLogin(); 81 | SetTokenStore(''); 82 | break; 83 | // 403 token过期 84 | // 登录过期对用户进行提示 85 | // 清除本地token和清空vuex中token对象 86 | // 跳转登录页面 87 | case 403: 88 | backToLogin(); 89 | SetTokenStore(''); 90 | break; 91 | // 404请求不存在 92 | case 404: 93 | // Toast({ 94 | // message: '网络请求不存在', 95 | // duration: 1500, 96 | // forbidClick: true 97 | // }); 98 | break; 99 | // 其他错误,直接抛出错误提示 100 | default: 101 | // Toast({ 102 | // message: error.response.data.message, 103 | // duration: 1500, 104 | // forbidClick: true 105 | // }); 106 | } 107 | return Promise.reject(error.response); 108 | } 109 | } 110 | ); 111 | /** 112 | * get方法,对应get请求 113 | * @param {String} url [请求的url地址] 114 | * @param {Object} params [请求时携带的参数] 115 | */ 116 | export function get( 117 | url: string, 118 | params: { [key: string]: any } 119 | ): Promise<{ result: boolean } & Record> { 120 | console.log('发起请求'); 121 | return new Promise((resolve, reject) => { 122 | axios 123 | .get(BaseUrl + url, { 124 | params: params, 125 | }) 126 | .then((res) => { 127 | console.log('请求成功'); 128 | resolve(res.data); 129 | }) 130 | .catch((err) => { 131 | console.log('请求失败'); 132 | reject(err.data); 133 | }); 134 | }); 135 | } 136 | /** 137 | * post方法,对应post请求 138 | * @param {String} url [请求的url地址] 139 | * @param {Object} params [请求时携带的参数] 140 | */ 141 | export function post( 142 | url: string, 143 | params: { [key: string]: any } 144 | ): Promise<{ result: boolean; [key: string]: any }> { 145 | return new Promise((resolve, reject) => { 146 | axios 147 | .post(BaseUrl + url, QS.stringify(params)) 148 | .then((res) => { 149 | resolve(res?.data); 150 | }) 151 | .catch((err) => { 152 | reject(err?.data); 153 | }); 154 | }); 155 | } 156 | -------------------------------------------------------------------------------- /src/utils/localStorageUtil.ts: -------------------------------------------------------------------------------- 1 | const SetlocalStorage = (key: string, value: any) => { 2 | console.log('保存至localStorage', key, value); 3 | if (typeof value !== 'string') { 4 | value = JSON.stringify(value); 5 | } 6 | console.log('保存至localStorage(parse)', key, value); 7 | window.localStorage.setItem(key, value); 8 | }; 9 | 10 | const RemovelocalStorage = (key: string) => { 11 | window.localStorage.removeItem(key); 12 | }; 13 | 14 | const GetlocalStorage = (key: string) => { 15 | const value = window.localStorage.getItem(key); 16 | console.log('读取localStorage', key, value); 17 | if (value === null || value === '') return null; 18 | try { 19 | const parseValue = JSON.parse(value); 20 | return parseValue; 21 | } catch (e) { 22 | console.log(e); 23 | } 24 | return value; 25 | }; 26 | 27 | const SetMarchineIndexStore = (value: any) => { 28 | SetlocalStorage('searchEngine', value); 29 | }; 30 | 31 | const GetMarchineIndexStore = () => { 32 | return GetlocalStorage('searchEngine'); 33 | }; 34 | /* 35 | { 36 | user:string 37 | password:string 38 | } 39 | */ 40 | const SetUserStore = (value: any) => { 41 | SetlocalStorage('userInfo', value); 42 | }; 43 | 44 | const GetUserStore = () => { 45 | const userinfo: any = GetlocalStorage('userInfo'); 46 | if (userinfo !== null) return userinfo; 47 | const userpre: any = GetlocalStorage('userpre'); //兼容旧数据 48 | if (userpre == null || typeof userpre != 'object') return null; 49 | return { 50 | userName: userpre.user ? userpre.user : '', 51 | passWord: userpre.password ? userpre.password : '', 52 | }; 53 | }; 54 | 55 | const SetTokenStore = (token: string) => { 56 | SetlocalStorage('token', token); 57 | }; 58 | 59 | const GetTokenStore = () => { 60 | return GetlocalStorage('token'); 61 | }; 62 | 63 | const GetPartDataStore = () => { 64 | const partData = GetlocalStorage('partData'); 65 | if (partData !== null) return partData; 66 | const siteData1 = GetlocalStorage('siteData1'); //兼容旧数据(什么鬼命名...) 67 | return siteData1; 68 | }; 69 | 70 | const SetPartDataStore = (value: any) => { 71 | SetlocalStorage('partData', value); 72 | }; 73 | 74 | export { 75 | SetlocalStorage, 76 | RemovelocalStorage, 77 | GetlocalStorage, 78 | SetMarchineIndexStore, 79 | GetMarchineIndexStore, 80 | SetUserStore, 81 | GetUserStore, 82 | SetTokenStore, 83 | GetTokenStore, 84 | GetPartDataStore, 85 | SetPartDataStore, 86 | }; 87 | -------------------------------------------------------------------------------- /src/utils/throttle.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/ban-types 2 | export default function throttle(fn: Function, delay: number) { 3 | let valid = true; 4 | return function () { 5 | if (!valid) { 6 | return false; 7 | } 8 | // 工作时间,执行函数并且在间隔期内把状态位设为无效 9 | valid = false; 10 | setTimeout(() => { 11 | fn(); 12 | valid = true; 13 | }, delay); 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /src/utils/veriLink.ts: -------------------------------------------------------------------------------- 1 | const linkPattern = /(http:\/\/|https:\/\/)[\w\W]+\.[\w\W]+(\.)*[\w\W]+/; 2 | 3 | const pswPattern = /[^\x00-\xff]+/; 4 | 5 | export { linkPattern, pswPattern }; 6 | -------------------------------------------------------------------------------- /src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", 5 | "target": "ES2020", 6 | "useDefineForClassFields": true, 7 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 8 | "module": "ESNext", 9 | "skipLibCheck": true, 10 | 11 | /* Bundler mode */ 12 | "moduleResolution": "bundler", 13 | "allowImportingTsExtensions": true, 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "moduleDetection": "force", 17 | "noEmit": true, 18 | "jsx": "react-jsx", 19 | 20 | /* Linting */ 21 | "strict": true, 22 | "noUnusedLocals": true, 23 | "noUnusedParameters": true, 24 | "noFallthroughCasesInSwitch": true 25 | }, 26 | "include": ["src"] 27 | } 28 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [], 3 | "references": [ 4 | { 5 | "path": "./tsconfig.app.json" 6 | }, 7 | { 8 | "path": "./tsconfig.node.json" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", 5 | "skipLibCheck": true, 6 | "module": "ESNext", 7 | "moduleResolution": "bundler", 8 | "allowSyntheticDefaultImports": true, 9 | "strict": true, 10 | "noEmit": true, 11 | "types": ["@cloudflare/workers-types", "vite/client"] 12 | }, 13 | "include": ["vite.config.ts"] 14 | } 15 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import react from '@vitejs/plugin-react'; 3 | import { visualizer } from 'rollup-plugin-visualizer'; 4 | 5 | // import build from "@hono/vite-cloudflare-pages"; 6 | // import devServer from "@hono/vite-dev-server"; 7 | // import adapter from "@hono/vite-dev-server/cloudflare"; 8 | 9 | // https://vitejs.dev/config/ 10 | export default defineConfig({ 11 | esbuild: { 12 | drop: ['console', 'debugger'], 13 | }, 14 | plugins: [ 15 | react(), 16 | visualizer({ 17 | filename: 'dist/bundle-visualizer.html', // 生成报告的文件路径 18 | open: true, // 打开生成的报告 19 | }), 20 | ], 21 | build: { 22 | outDir: 'build', 23 | // rollupOptions: { 24 | // external: ['react', 'react-dom'], 25 | // output: { 26 | // format: 'umd', 27 | // globals: { 28 | // react: 'React', 29 | // 'react-dom': 'ReactDOM', 30 | // }, 31 | // }, 32 | // }, 33 | }, 34 | }); 35 | -------------------------------------------------------------------------------- /wrangler.toml: -------------------------------------------------------------------------------- 1 | # Generated by Wrangler on Wed Jun 19 2024 00:55:08 GMT+0800 (中国标准时间) 2 | name = "gy-nav" 3 | pages_build_output_dir = "build" 4 | compatibility_date = "2024-06-18" 5 | 6 | compatibility_flags = ["nodejs_compat"] 7 | 8 | [[d1_databases]] 9 | database_id = "468b4939-9622-4192-b867-fc20fb41b456" 10 | binding = "DB" 11 | database_name = "DB" 12 | 13 | [env.preview] 14 | compatibility_date = "2024-06-18" 15 | 16 | [[env.preview.d1_databases]] 17 | database_id = "30166e34-c12a-4b94-b298-90b8e99606f3" 18 | binding = "DB" 19 | database_name = "DB" 20 | 21 | [env.production] 22 | compatibility_date = "2024-06-18" 23 | 24 | [[env.production.d1_databases]] 25 | database_id = "468b4939-9622-4192-b867-fc20fb41b456" 26 | binding = "DB" 27 | database_name = "DB" 28 | 29 | --------------------------------------------------------------------------------