Repository: LiuYuYang01/ThriveX-Admin Branch: main Commit: 6ef1271b5240 Files: 159 Total size: 500.0 KB Directory structure: gitextract_u6ur3t29/ ├── .dockerignore ├── .gitignore ├── .prettierrc ├── .vite/ │ └── deps_temp_474a67bf/ │ └── package.json ├── LICENSE ├── README.md ├── dockerfile ├── eslint.config.js ├── index.html ├── package.json ├── postcss.config.cjs ├── public/ │ └── _redirects ├── src/ │ ├── App.tsx │ ├── api/ │ │ ├── album_cate.ts │ │ ├── album_image.ts │ │ ├── article.ts │ │ ├── assistant.ts │ │ ├── auth.ts │ │ ├── cate.ts │ │ ├── comment.ts │ │ ├── config.ts │ │ ├── email.ts │ │ ├── file.ts │ │ ├── footprint.ts │ │ ├── oss.ts │ │ ├── record.ts │ │ ├── rss.ts │ │ ├── statis.ts │ │ ├── swiper.ts │ │ ├── tag.ts │ │ ├── user.ts │ │ ├── wall.ts │ │ └── web.ts │ ├── components/ │ │ ├── CardDataStats/ │ │ │ └── index.tsx │ │ ├── ClickOutside.tsx │ │ ├── Drawer/ │ │ │ └── index.tsx │ │ ├── Dropdowns/ │ │ │ └── DropdownDefault.tsx │ │ ├── Empty/ │ │ │ └── index.tsx │ │ ├── FileUpload/ │ │ │ └── index.tsx │ │ ├── HasPermission/ │ │ │ └── index.tsx │ │ ├── Header/ │ │ │ ├── DarkModeSwitcher.tsx │ │ │ ├── DropdownUser.tsx │ │ │ └── index.tsx │ │ ├── Loader/ │ │ │ └── index.tsx │ │ ├── Material/ │ │ │ ├── index.scss │ │ │ └── index.tsx │ │ ├── NotFound/ │ │ │ └── index.tsx │ │ ├── PageTab/ │ │ │ └── index.tsx │ │ ├── PageTitle.tsx │ │ ├── RandomAvatar/ │ │ │ └── index.tsx │ │ ├── RouteList/ │ │ │ └── index.tsx │ │ ├── Sidebar/ │ │ │ ├── SidebarLinkGroup.tsx │ │ │ └── index.tsx │ │ ├── StatusTag/ │ │ │ └── index.tsx │ │ ├── SystemNotification/ │ │ │ └── index.tsx │ │ ├── Title/ │ │ │ └── index.tsx │ │ └── WangEditor/ │ │ ├── index.scss │ │ └── index.tsx │ ├── hooks/ │ │ ├── useAssistant.tsx │ │ ├── useAuthRedirect.tsx │ │ ├── useLocalStorage.tsx │ │ └── useVersionData.tsx │ ├── layout/ │ │ └── DefaultLayout.tsx │ ├── main.tsx │ ├── pages/ │ │ ├── article/ │ │ │ ├── components/ │ │ │ │ ├── ArticleExport.tsx │ │ │ │ └── ArticleImportModal.tsx │ │ │ └── index.tsx │ │ ├── assistant/ │ │ │ └── index.tsx │ │ ├── cate/ │ │ │ ├── index.scss │ │ │ └── index.tsx │ │ ├── comment/ │ │ │ └── index.tsx │ │ ├── config/ │ │ │ └── index.tsx │ │ ├── create/ │ │ │ ├── components/ │ │ │ │ ├── Editor/ │ │ │ │ │ ├── index.scss │ │ │ │ │ ├── index.tsx │ │ │ │ │ ├── markdown.scss │ │ │ │ │ └── plugins.tsx │ │ │ │ └── PublishForm/ │ │ │ │ ├── index.scss │ │ │ │ └── index.tsx │ │ │ └── index.tsx │ │ ├── create_record/ │ │ │ ├── index.scss │ │ │ └── index.tsx │ │ ├── dashboard/ │ │ │ ├── components/ │ │ │ │ ├── HeaderInfo/ │ │ │ │ │ └── index.tsx │ │ │ │ ├── Info/ │ │ │ │ │ └── index.tsx │ │ │ │ └── Stats/ │ │ │ │ ├── components/ │ │ │ │ │ ├── NewOldVisitors/ │ │ │ │ │ │ └── index.tsx │ │ │ │ │ └── VisitorsStatisChat/ │ │ │ │ │ ├── index.tsx │ │ │ │ │ └── type.d.ts │ │ │ │ └── index.tsx │ │ │ └── index.tsx │ │ ├── decycle/ │ │ │ └── index.tsx │ │ ├── draft/ │ │ │ └── index.tsx │ │ ├── file/ │ │ │ ├── index.scss │ │ │ └── index.tsx │ │ ├── footprint/ │ │ │ └── index.tsx │ │ ├── iterative/ │ │ │ └── index.tsx │ │ ├── login/ │ │ │ └── index.tsx │ │ ├── page/ │ │ │ └── my.tsx │ │ ├── record/ │ │ │ └── index.tsx │ │ ├── setup/ │ │ │ ├── components/ │ │ │ │ ├── My/ │ │ │ │ │ └── index.tsx │ │ │ │ ├── Other/ │ │ │ │ │ └── index.tsx │ │ │ │ ├── System/ │ │ │ │ │ └── index.tsx │ │ │ │ ├── Theme/ │ │ │ │ │ ├── components/ │ │ │ │ │ │ ├── RecordTheme/ │ │ │ │ │ │ │ └── index.tsx │ │ │ │ │ │ └── SynthesisTheme/ │ │ │ │ │ │ ├── index.tsx │ │ │ │ │ │ └── type.d.ts │ │ │ │ │ └── index.tsx │ │ │ │ └── Web/ │ │ │ │ └── index.tsx │ │ │ └── index.tsx │ │ ├── storage/ │ │ │ └── index.tsx │ │ ├── swiper/ │ │ │ └── index.tsx │ │ ├── tag/ │ │ │ └── index.tsx │ │ ├── wall/ │ │ │ └── index.tsx │ │ ├── web/ │ │ │ └── index.tsx │ │ └── work/ │ │ ├── components/ │ │ │ └── List/ │ │ │ └── index.tsx │ │ └── index.tsx │ ├── services/ │ │ └── assistant.ts │ ├── stores/ │ │ ├── index.ts │ │ └── modules/ │ │ ├── config.ts │ │ ├── tabs.ts │ │ ├── user.ts │ │ └── web.ts │ ├── styles/ │ │ ├── antd.scss │ │ ├── custom.scss │ │ ├── index.css │ │ ├── sty.ts │ │ └── var.scss │ ├── types/ │ │ ├── app/ │ │ │ ├── album.d.ts │ │ │ ├── article.d.ts │ │ │ ├── assistant.d.ts │ │ │ ├── brand.d.ts │ │ │ ├── cate.d.ts │ │ │ ├── chat.d.ts │ │ │ ├── comment.d.ts │ │ │ ├── config.d.ts │ │ │ ├── email.d.ts │ │ │ ├── file.d.ts │ │ │ ├── footprint.d.ts │ │ │ ├── oss.d.ts │ │ │ ├── package.d.ts │ │ │ ├── permission.d.ts │ │ │ ├── product.d.ts │ │ │ ├── record.d.ts │ │ │ ├── role.d.ts │ │ │ ├── route.d.ts │ │ │ ├── rss.d.ts │ │ │ ├── swiper.d.ts │ │ │ ├── tag.d.ts │ │ │ ├── user.d.ts │ │ │ ├── wall.d.ts │ │ │ └── web.d.ts │ │ ├── env.d.ts │ │ ├── global.d.ts │ │ └── response.d.ts │ └── utils/ │ ├── index.ts │ ├── permission.ts │ ├── request.ts │ └── route.tsx ├── tsconfig.json ├── tsconfig.node.json ├── vercel.json └── vite.config.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .dockerignore ================================================ node_modules npm-debug.log Dockerfile .dockerignore ================================================ FILE: .gitignore ================================================ # Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* pnpm-debug.log* lerna-debug.log* node_modules dist dist-ssr *.local # Editor directories and files .vscode/* !.vscode/extensions.json .idea .DS_Store *.suo *.ntvs* *.njsproj *.sln *.sw? ================================================ FILE: .prettierrc ================================================ { "singleQuote": true, "jsxSingleQuote": false, "printWidth": 999, "semi": true, "bracketSpacing": true, "arrowParens": "always" } ================================================ FILE: .vite/deps_temp_474a67bf/package.json ================================================ { "type": "module" } ================================================ FILE: LICENSE ================================================ GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . ================================================ FILE: README.md ================================================

ThriveX logo

ThriveX Admin

License: AGPL-3.0 Stars Forks

## 📖 项目简介 **ThriveX Admin** 是 ThriveX 博客系统的现代化管理后台,采用 Next.js 15 + React 19 + Ant Design 构建,提供全功能的内容管理、用户管理、系统配置等一站式解决方案。 作为 ThriveX 全栈解决方案的核心组成部分,Admin 控制端与前端博客([ThriveX-Blog](https://github.com/LiuYuYang01/ThriveX-Blog))和后端服务([ThriveX-Server](https://github.com/LiuYuYang01/ThriveX-Server))共同构成了一个完整的开源博客生态系统。 ## ✨ 核心特性 - 🎨 **现代化 UI**:基于 Ant Design 6.x + Tailwind CSS 4.x,提供优雅的视觉体验 - 📝 **富文本编辑器**:集成 WangEditor + ByteMD,支持 Markdown/HTML 双模式 - 📊 **数据可视化**:ECharts 图表展示访问统计、文章分类、用户增长等关键指标 - 🎯 **权限管理**:细粒度的 RBAC 权限控制,支持角色分配与权限配置 - 📁 **文件管理**:支持本地存储与多种 OSS 服务商(阿里云、腾讯云、七牛云等) - 📧 **邮件系统**:内置 SMTP 邮件服务,支持评论回复、通知推送 - 📱 **响应式设计**:完美适配桌面端与平板设备 - 🌓 **暗色模式**:支持主题切换,保护用户视力 - ⚡ **性能优化**:代码分割、懒加载、缓存策略,确保极致性能 ## 📸 界面预览
ThriveX Admin Dashboard
## 🚀 快速开始 https://docs.liuyuyang.net/docs/项目部署/1Panel.html ## 📂 项目结构 ``` ThriveX-Admin/ ├── src/ │ ├── api/ # API 接口定义 │ ├── components/ # 公共组件 │ ├── hooks/ # 自定义 Hooks │ ├── layout/ # 布局组件 │ ├── pages/ # 页面路由 │ │ ├── article/ # 文章管理 │ │ ├── cate/ # 分类管理 │ │ ├── comment/ # 评论管理 │ │ ├── config/ # 系统配置 │ │ ├── dashboard/ # 仪表盘 │ │ ├── file/ # 文件管理 │ │ ├── storage/ # 存储配置 │ │ └── user/ # 用户管理 │ ├── services/ # 服务层 │ ├── stores/ # 状态管理 │ ├── styles/ # 样式文件 │ ├── types/ # TypeScript 类型定义 │ └── utils/ # 工具函数 ├── public/ # 静态资源 ├── .env # 环境变量配置 ├── package.json # 项目配置 └── vite.config.js # Vite 配置 ``` ## 🌐 项目链接 | 名称 | 链接 | 说明 | | ----------- | -------------------------------------------------------------------------------------------- | ------------ | | 博客预览 | [https://liuyuyang.net](https://liuyuyang.net) | 前端博客展示 | | 官网地址 | [https://thrivex.liuyuyang.net](https://thrivex.liuyuyang.net) | 项目官网 | | 文档中心 | [https://docs.liuyuyang.net](https://docs.liuyuyang.net) | 使用文档 | | GitHub 主页 | [https://github.com/LiuYuYang01/ThriveX-Admin](https://github.com/LiuYuYang01/ThriveX-Admin) | 源码仓库 | ## 📝 开源协议 本项目采用 **AGPL-3.0** 许可证。 **使用须知**: - ✅ 允许商业使用、修改、分发 - ✅ 必须保留原始版权说明 - ✅ 修改后的版本必须开源 - ❌ 禁止任何闭源商业行为 在项目 Star 突破 2K 后,您可以自由选择保留或删除版权信息。 ## ⭐ Star History [![Star History Chart](https://api.star-history.com/svg?repos=LiuYuYang01/ThriveX-Admin&type=Date)](https://star-history.com/#LiuYuYang01/ThriveX-Admin&Date) ## 👨‍💻 作者信息 **刘宇阳** - GitHub: [@LiuYuYang01](https://github.com/LiuYuYang01) - 我的博客: [https://liuyuyang.net](https://liuyuyang.net) - 关于我:[https://my.liuyuyang.net](https://my.liuyuyang.net) - 邮箱: [liuyuyang1024@yeah.net](mailto:liuyuyang1024@yeah.net) ## 💬 交流群 欢迎加入 ThriveX 官方交流群,与开发者和其他用户交流:
WeChat Group
**加群方式**:添加微信 `liuyuyang2023`,备注 "ThriveX" ## 🙏 鸣谢 感谢所有为 ThriveX 项目做出贡献的开发者和用户! 特别感谢以下项目提供的灵感与技术支持: - [zw-blog](https://blog.zwying.com/) - [blatr](https://www.blatr.cn/) - [poetize](https://poetize.cn/) ## 🔒 免责声明 本项目仅供学习交流使用,不提供任何技术咨询或技术支持服务。使用者在使用本项目时应遵守当地法律法规,不得用于任何违法活动。 ================================================ FILE: dockerfile ================================================ # 使用官方的Node.js镜像作为基础镜像 FROM registry.cn-hangzhou.aliyuncs.com/liuyi778/node-20-alpine AS builder # 设置工作目录 WORKDIR /thrive # 复制 package.json 和 package-lock.json COPY package*.json ./ # 配置 npm 镜像源 RUN npm config set registry https://registry.npmmirror.com # 安装依赖 RUN npm install # 复制项目文件 COPY . . # 构建项目 RUN npm run build # 使用 Nginx 作为生产环境的基础镜像 FROM nginx:alpine # 复制构建输出到 Nginx 的默认静态文件目录 COPY --from=builder /thrive/dist /usr/share/nginx/html # 暴露端口 EXPOSE 80 # 启动 Nginx CMD ["nginx", "-g", "daemon off;"] ================================================ FILE: eslint.config.js ================================================ import js from '@eslint/js'; import globals from 'globals'; import tseslint from 'typescript-eslint'; import pluginReact from 'eslint-plugin-react'; import { defineConfig } from 'eslint/config'; import reactHooks from 'eslint-plugin-react-hooks'; import reactRefresh from 'eslint-plugin-react-refresh'; export default defineConfig([ { ignores: ['dist'] }, { files: ['**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], plugins: { js }, extends: ['js/recommended'], }, { files: ['**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], languageOptions: { globals: globals.browser }, }, { plugins: { 'react-hooks': reactHooks, 'react-refresh': reactRefresh, }, }, tseslint.configs.recommended, pluginReact.configs.flat.recommended, { settings: { react: { // 从 package.json 自动检测 React 版本 version: 'detect', }, }, }, { rules: { 'no-unused-vars': 'off', // 关闭未使用变量的检查 'react-refresh/only-export-components': 'off', 'react/display-name': 'off', // 约束js使用单引号,允许jsx双引号 quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }], 'jsx-quotes': ['error', 'prefer-double'], 'react-hooks/exhaustive-deps': 'off', 'react/react-in-jsx-scope': 'off', // 禁止使用 any 类型 '@typescript-eslint/no-explicit-any': 'error', }, }, ]); ================================================ FILE: index.html ================================================ ThriveX 现代化博客管理系统
================================================ FILE: package.json ================================================ { "name": "thrivex-admin", "private": true, "version": "3.0", "type": "module", "scripts": { "dev": "eslint . && vite", "build": "eslint . && vite build", "preview": "vite preview", "lint": "eslint ." }, "author": { "name": "刘宇阳", "email": "liuyuyang1024@yeah.net", "url": "https://liuyuyang.net" }, "engines": { "node": ">=20", "npm": ">=10" }, "dependencies": { "@ant-design/icons": "^6.1.0", "@bytemd/plugin-gemoji": "^1.21.0", "@bytemd/plugin-gfm": "^1.21.0", "@bytemd/plugin-highlight": "^1.21.0", "@bytemd/plugin-math": "^1.21.0", "@bytemd/react": "^1.21.0", "@codemirror/lang-json": "^6.0.2", "@dicebear/collection": "^7.0.0", "@dicebear/core": "^7.0.0", "@uiw/react-codemirror": "^4.23.14", "@wangeditor-next/editor": "^5.6.45", "@wangeditor-next/editor-for-react": "^1.0.10", "antd": "^6.3.1", "apexcharts": "^4.7.0", "axios": "^1.7.2", "bytemd": "^1.22.0", "compressorjs": "^1.2.1", "dayjs": "^1.11.13", "echarts": "^5.6.0", "echarts-for-react": "^3.0.2", "eslint-plugin-react-hooks": "^5.2.0", "file-saver": "^2.0.5", "highlight.js": "^11.11.1", "jszip": "^3.10.1", "katex": "^0.16.11", "react": "19.2.4", "react-apexcharts": "^1.7.0", "react-dom": "19.2.4", "react-github-calendar": "^4.2.2", "react-icons": "^4.12.0", "react-masonry-css": "^1.0.16", "react-router-dom": "^6.14.2", "rehype-callouts": "^1.4.1", "remark-mark-highlight": "^0.1.1", "sass": "^1.77.8", "unified": "^11.0.4", "unist-util-visit": "^5.0.0", "vite": "^7.3.1", "vite-plugin-sass-dts": "^1.3.25", "zustand": "^4.5.4" }, "devDependencies": { "@eslint/js": "^9.31.0", "@tailwindcss/postcss": "^4.2.1", "@types/file-saver": "^2.0.7", "@types/hast": "^3.0.4", "@types/react": "19.2.14", "@types/react-dom": "19.2.3", "@vitejs/plugin-react": "^4.0.3", "codemod": "^1.5.4", "eslint": "^9.31.0", "eslint-plugin-react": "^7.37.5", "eslint-plugin-react-refresh": "^0.4.20", "globals": "^16.3.0", "postcss": "^8.4.27", "prettier": "^3.0.0", "prettier-plugin-tailwindcss": "^0.7.2", "tailwindcss": "^4.2.1", "typescript-eslint": "^8.37.0" }, "pnpm": { "onlyBuiltDependencies": [ "@parcel/watcher", "es5-ext", "esbuild", "sharp" ] } } ================================================ FILE: postcss.config.cjs ================================================ // eslint-disable-next-line no-undef module.exports = { plugins: { '@tailwindcss/postcss': {}, }, } ================================================ FILE: public/_redirects ================================================ /* /index.html 200 ================================================ FILE: src/App.tsx ================================================ import { useEffect } from 'react'; import { useLocation } from 'react-router-dom'; import useAuthRedirect from '@/hooks/useAuthRedirect'; import { App as AntdApp, ConfigProvider, theme } from 'antd'; import RouteList from './components/RouteList'; import '@/styles/antd.scss'; import { getWebConfigDataAPI } from '@/api/config'; import { useWebStore, useUserStore, useConfigStore } from './stores'; import { Web } from './types/app/config'; import zhCN from 'antd/locale/zh_CN'; import 'dayjs/locale/zh-cn'; function App() { useAuthRedirect(); const token = useUserStore((state) => state.token); const colorMode = useConfigStore((state) => state.colorMode); const { pathname } = useLocation(); useEffect(() => { window.scrollTo(0, 0); }, [pathname]); const setWeb = useWebStore((state) => state.setWeb); const getWebData = async () => { if (!token) return; const { data } = await getWebConfigDataAPI<{ value: Web }>('web'); setWeb(data.value); }; useEffect(() => { getWebData(); }, [token]); return ( ); } export default App; ================================================ FILE: src/api/album_cate.ts ================================================ import Request from '@/utils/request' import { AlbumCate, AlbumImage } from '@/types/app/album' // 新增相册 export const addAlbumCateDataAPI = (data: AlbumCate) => Request('POST', '/album/cate', { data }) // 删除相册 export const delAlbumCateDataAPI = (id: number) => Request('DELETE', `/album/cate/${id}`) // 修改相册 export const editAlbumCateDataAPI = (data: AlbumCate) => Request('PATCH', '/album/cate', { data }) // 获取相册 export const getAlbumCateDataAPI = (id?: number) => Request('GET', `/album/cate/${id}`) // 获取相册列表 export const getAlbumCateListAPI = (data?: QueryData) => Request('POST', '/album/cate/list', { data: { ...data?.query } }); // 分页获取相册列表 export const getAlbumCatePagingAPI = (data?: QueryData) => Request>('POST', `/album/cate/paging`, { data: { ...data?.query }, params: { ...data?.pagination } }) // 获取指定相册中的所有照片 export const getImagesByAlbumIdAPI = (id: number, page: number = 1, size: number = 10) => Request>('GET', `/album/cate/${id}/images`, { params: { page, size } }) ================================================ FILE: src/api/album_image.ts ================================================ import Request from '@/utils/request' import { AlbumImage } from '@/types/app/album' // 新增照片 export const addAlbumImageDataAPI = (data: AlbumImage) => Request('POST', '/album/image', { data }) // 删除照片 export const delAlbumImageDataAPI = (id: number) => Request('DELETE', `/album/image/${id}`) // 修改照片 export const editAlbumImageDataAPI = (data: AlbumImage) => Request('PATCH', '/album/image', { data }) // 获取照片 export const getAlbumImageDataAPI = (id?: number) => Request('GET', `/album/image/${id}`) // 获取照片列表 export const getAlbumImageListAPI = (data?: QueryData) => Request('POST', '/album/image/list', { data: { ...data?.query } }); // 分页获取照片列表 export const getAlbumImagePagingAPI = (data?: QueryData) => Request>('POST', `/album/image/paging`, { data: { ...data?.query }, params: { ...data?.pagination } }) ================================================ FILE: src/api/article.ts ================================================ import Request from '@/utils/request'; import { Article, ArticleFilterQueryParams } from '@/types/app/article'; // 新增文章 export const addArticleDataAPI = (data: Article) => Request('POST', '/article', { data }); // 删除文章 export const delArticleDataAPI = (id: number, isDel?: boolean) => Request('DELETE', isDel ? `/article/${id}/1` : `/article/${id}/0`); // 批量删除文章 export const delBatchArticleDataAPI = (ids: number[]) => Request('DELETE', '/article/batch', { data: ids }); // 还原被删除的文章 export const reductionArticleDataAPI = (id: number) => Request('PATCH', `/article/reduction/${id}`); // 编辑文章 export const editArticleDataAPI = (data: Article) => Request('PATCH', '/article', { data }); // 获取文章 export const getArticleDataAPI = (id?: number) => Request
('GET', `/article/${id}`) // 获取文章列表 export const getArticlePagingAPI = (params?: ArticleFilterQueryParams) => Request>('GET', `/article`, { params }) // 导入文章 export const importArticleDataAPI = (list: File[]) => { const formData = new FormData(); list.forEach((file) => { formData.append(`list`, file); }); return Request('POST', '/article/import', { data: formData, headers: { 'Content-Type': 'multipart/form-data' } }); } ================================================ FILE: src/api/assistant.ts ================================================ import Request from '@/utils/request' import { Assistant } from '@/types/app/assistant' // 新增助手 export const addAssistantDataAPI = (data: Assistant) => Request('POST', '/assistant', { data }) // 删除助手 export const delAssistantDataAPI = (id: number) => Request('DELETE', `/assistant/${id}`) // 修改助手 export const editAssistantDataAPI = (data: Assistant) => Request('PATCH', '/assistant', { data }) // 获取助手 export const getAssistantDataAPI = (id?: number) => Request('GET', `/assistant/${id}`) // 获取助手列表 export const getAssistantListAPI = (data?: QueryData) => Request('POST', '/assistant/list', { data: { ...data?.query } }); // 设置默认助手 export const setDefaultAssistantAPI = (id: number) => Request('PATCH', `/assistant/default/${id}`) ================================================ FILE: src/api/auth.ts ================================================ import { LoginReturn } from '@/types/app/user' import Request from '@/utils/request' // 授权 github 登录 export const authGitHubLoginAPI = (code: string) => Request('POST', `/auth/github/login?code=${code}`) // 绑定 github 登录 export const bindGitHubLoginAPI = (code: string, userId: string) => Request('POST', `/auth/github/bind?code=${code}&userId=${userId}`) ================================================ FILE: src/api/cate.ts ================================================ import Request from '@/utils/request' import { Cate, CateFilterQueryParams } from '@/types/app/cate' // 新增分类 export const addCateDataAPI = (data: Cate) => Request('POST', '/cate', { data }) // 删除分类 export const delCateDataAPI = (id: number) => Request('DELETE', `/cate/${id}`) // 修改分类 export const editCateDataAPI = (data: Cate) => Request('PATCH', '/cate', { data }) // 获取分类 export const getCateDataAPI = (id?: number) => Request('GET', `/cate/${id}`) // 获取分类列表 export const getCateListAPI = (params?: CateFilterQueryParams) => Request>('GET', `/cate`, { params }) ================================================ FILE: src/api/comment.ts ================================================ import Request from '@/utils/request' import { Comment } from '@/types/app/comment' // 新增评论 export const addCommentDataAPI = (data: Comment) => Request('POST', '/comment', { data }) // 删除评论 export const delCommentDataAPI = (id: number) => Request('DELETE', `/comment/${id}`) // 审核评论 export const auditCommentDataAPI = (id: number) => Request('PATCH', `/comment/audit/${id}`) // 修改评论 export const editCommentDataAPI = (data: Comment) => Request('PATCH', '/comment', { data }) // 获取评论 export const getCommentDataAPI = (id?: number) => Request>('GET', `/comment/${id}`) // 获取评论列表 export const getCommentListAPI = (data?: QueryData) => Request('POST', `/comment/list`, { data: { ...data, ...data?.query }, }) // 分页获取评论列表 export const getCommentPagingAPI = (data?: QueryData) => Request>('POST', `/comment/paging`, { data: { ...data?.query }, params: { ...data?.pagination } }) ================================================ FILE: src/api/config.ts ================================================ import Request from '@/utils/request'; import { Config, EnvConfigName, WebConfigType } from '@/types/app/config'; // 获取网站配置 export const getWebConfigDataAPI = (name: WebConfigType) => Request('GET', `/web_config/name/${name}`); // 修改网站配置 export const editWebConfigDataAPI = (name: WebConfigType, data: object) => Request('PATCH', `/web_config/json/name/${name}`, { data }); // 获取环境配置 export const getEnvConfigDataAPI = (name: EnvConfigName) => Request('GET', `/env_config/name/${name}`); // 获取环境配置列表 export const getEnvConfigListAPI = () => Request('GET', `/env_config/list`); // 更新环境配置 export const updateEnvConfigDataAPI = (data: Config) => Request('PATCH', `/env_config/json/${data.id}`, { data: data.value }); // 根据id获取页面配置 export const getPageConfigDataAPI = (id: number) => Request('GET', `/page_config/${id}`); // 根据名称获取页面配置 export const getPageConfigDataByNameAPI = (name: string) => Request('GET', `/page_config/name/${name}`); // 获取页面配置列表 export const getPageConfigListAPI = () => Request('GET', `/page_config/list`); // 更新页面配置 export const updatePageConfigDataAPI = (id: number, data: object) => Request('PATCH', `/page_config/json/${id}`, { data }); ================================================ FILE: src/api/email.ts ================================================ import Request from '@/utils/request' import { DismissEmail, ReplyWallEmail } from '@/types/app/email' // 发送驳回邮件 export const sendDismissEmailAPI = async (data: DismissEmail) => { return await Request('POST', `/email/dismiss`, { data }); } // 发送回复留言邮件 export const sendReplyWallEmailAPI = async (data: ReplyWallEmail) => { return await Request('POST', `/email/reply_wall`, { data }); } ================================================ FILE: src/api/file.ts ================================================ import Request from '@/utils/request' import { File, FileDir } from '@/types/app/file' // 删除文件 export const delFileDataAPI = (filePath: string) => Request('DELETE', `/file?filePath=${filePath}`) // 获取文件 export const getFileDataAPI = (filePath: string) => Request('GET', `/file/info?filePath=${filePath}`) // 获取文件列表 export const getFileListAPI = (dir: string, paging?: Page) => Request>('GET', `/file/list?dir=${dir}`, { params: { ...paging } }) // 获取目录列表 export const getDirListAPI = () => Request('GET', '/file/dir') ================================================ FILE: src/api/footprint.ts ================================================ import Request from '@/utils/request' import { Footprint } from '@/types/app/footprint' // 新增足迹 export const addFootprintDataAPI = (data: Footprint) => Request('POST', '/footprint', { data }) // 删除足迹 export const delFootprintDataAPI = (id: number) => Request('DELETE', `/footprint/${id}`) // 修改足迹 export const editFootprintDataAPI = (data: Footprint) => Request('PATCH', '/footprint', { data }) // 获取足迹 export const getFootprintDataAPI = (id?: number) => Request('GET', `/footprint/${id}`) // 获取足迹列表 export const getFootprintListAPI = (data?: QueryData) => Request('POST', '/footprint/list', { data: { ...data?.query } }); ================================================ FILE: src/api/oss.ts ================================================ import Request from '@/utils/request' import { Oss } from '@/types/app/oss' // 新增OSS export const addOssDataAPI = (data: Oss) => Request('POST', '/oss', { data }) // 删除OSS export const delOssDataAPI = (id: number) => Request('DELETE', `/oss/${id}`) // 修改OSS export const editOssDataAPI = (data: Oss) => Request('PATCH', '/oss', { data }) // 获取OSS export const getOssDataAPI = (id?: number) => Request('GET', `/oss/${id}`) // 获取OSS列表 export const getOssListAPI = () => Request('POST', `/oss/list`) // 获取启用的OSS列表 export const getOssEnableListAPI = () => Request('GET', `/oss/getEnableOss`) // 启用OSS export const enableOssDataAPI = (id: number) => Request('PATCH', `/oss/enable/${id}`) // 禁用OSS export const disableOssDataAPI = (id: number) => Request('PATCH', `/oss/disable/${id}`) // 获取支持的OSS平台列表 export const getOssPlatformListAPI = () => Request<{ name: string, value: string }[]>('GET', `/oss/platform`) ================================================ FILE: src/api/record.ts ================================================ import Request from '@/utils/request' import { Record } from '@/types/app/record' // 新增说说 export const addRecordDataAPI = (data: Record) => Request('POST', '/record', { data }) // 删除说说 export const delRecordDataAPI = (id: number) => Request('DELETE', `/record/${id}`) // 修改说说 export const editRecordDataAPI = (data: Record) => Request('PATCH', '/record', { data }) // 获取说说 export const getRecordDataAPI = (id?: number) => Request('GET', `/record/${id}`) // 获取说说列表 export const getRecordListAPI = (data?: QueryData) => Request('POST', `/record/list`, { data: { ...data?.query }, }) // 分页获取说说列表 export const getRecordPagingAPI = (data?: QueryData) => Request>('POST', `/record/paging`, { data: { ...data?.query }, params: { ...data?.pagination } }) ================================================ FILE: src/api/rss.ts ================================================ import { Rss } from '@/types/app/rss'; import Request from '@/utils/request'; // 获取订阅数据列表 export const getRssListAPI = (data?: QueryData) => Request('GET', `/rss/list`, { data: { ...data?.query }, }) // 分页获取订阅列表 export const getRssPagingAPI = (data?: QueryData) => Request>('POST', `/rss/paging`, { data: { ...data?.query }, params: { ...data?.pagination } }) ================================================ FILE: src/api/statis.ts ================================================ import Request from '@/utils/request'; type StatisType = 'overview' | 'new-visitor' | 'basic-overview'; // overview(概览趋势), new-visitor(新访客趋势), basic-overview(基础概览趋势) // 获取 PV量、IP量、跳出率、平均访问时长 export const getStatisAPI = (type: StatisType, startDate: string, endDate: string) => Request('GET', `/statis`, { params: { startDate, endDate, type }, }) ================================================ FILE: src/api/swiper.ts ================================================ import Request from '@/utils/request' import { Swiper } from '@/types/app/swiper' // 新增轮播图 export const addSwiperDataAPI = (data: Swiper) => Request('POST', '/swiper', { data }) // 删除轮播图 export const delSwiperDataAPI = (id: number) => Request('DELETE', `/swiper/${id}`) // 修改轮播图 export const editSwiperDataAPI = (data: Swiper) => Request('PATCH', '/swiper', { data }) // 获取轮播图 export const getSwiperDataAPI = (id?: number) => Request('GET', `/swiper/${id}`) // 获取轮播图数据列表 export const getSwiperListAPI = (data?: QueryData) => Request('POST', `/swiper/list`, { data: { ...data?.query }, }) // 分页获取轮播图列表 export const getSwiperPagingAPI = (data?: QueryData) => Request>('POST', `/swiper/paging`, { data: { ...data?.query }, params: { ...data?.pagination } }) ================================================ FILE: src/api/tag.ts ================================================ import Request from '@/utils/request' import { Tag } from '@/types/app/tag' // 新增标签 export const addTagDataAPI = (data: Tag) => Request('POST', '/tag', { data }) // 删除标签 export const delTagDataAPI = (id: number) => Request('DELETE', `/tag/${id}`) // 修改标签 export const editTagDataAPI = (data: Tag) => Request('PATCH', '/tag', { data }) // 获取标签 export const getTagDataAPI = (id?: number) => Request('GET', `/tag/${id}`) // 获取标签列表 // export const getTagListAPI = (data?: QueryData) => Request('POST', `/tag/list`, { // data: { ...data?.query }, // }) // 统计每个标签下的文章数量 export const getTagListAPI = () => Request('GET', '/tag/article/count') // 分页获取标签列表 export const getTagPagingAPI = (data?: QueryData) => Request>('POST', `/tag/paging`, { data: { ...data?.query }, params: { ...data?.pagination } }) ================================================ FILE: src/api/user.ts ================================================ import Request from '@/utils/request' import { LoginReturn, EditUser, Login, User, UserInfo } from '@/types/app/user' // 新增用户 export const addUserDataAPI = (data: User) => Request('POST', '/user', { data }); // 删除用户 export const delUserDataAPI = (id: number) => Request('DELETE', `/user/${id}`); // 编辑用户 export const editUserDataAPI = (data: UserInfo) => Request('PATCH', '/user', { data }) // 获取用户 export const getUserDataAPI = (id?: number) => Request('GET', `/user/${id}`) // 获取用户列表 export const getUserListAPI = (data?: QueryData) => Request('POST', `/user/list`, { data: { ...data?.query }, }) // 分页获取用户列表 export const getUserPagingAPI = (data?: QueryData) => Request>('POST', `/user/paging`, { data: { ...data?.query }, params: { ...data?.pagination } }) // 登录 export const loginDataAPI = (data: Login) => Request('POST', '/user/login', { data }) // 修改管理员密码 export const editAdminPassAPI = (data: EditUser) => Request('PATCH', '/user/pass', { data }) // 判断当前token是否有效 export const checkTokenAPI = (token: string) => Request('GET', `/user/check?token=${token}`) ================================================ FILE: src/api/wall.ts ================================================ import Request from '@/utils/request' import { Wall, Cate } from '@/types/app/wall' // 新增留言 export const addWallDataAPI = (data: Wall) => Request('POST', '/wall', { data }) // 删除留言 export const delWallDataAPI = (id: number) => Request('DELETE', `/wall/${id}`) // 审核留言 export const auditWallDataAPI = (id: number) => Request('PATCH', `/wall/audit/${id}`) // 修改留言 export const editWallDataAPI = (data: Wall) => Request('PATCH', '/wall', { data }) // 获取留言 export const getWallDataAPI = (id?: number) => Request>('GET', `/wall/${id}`) // 获取留言列表 export const getWallListAPI = (data?: QueryData) => Request('POST', `/wall/list`, { data: { ...data?.query }, }) // 分页获取留言列表 export const getWallPagingAPI = (data?: QueryData) => Request>('POST', `/wall/paging`, { data: { ...data?.query }, params: { ...data?.pagination } }) // 获取留言分类列表 export const getWallCateListAPI = () => Request('GET', `/wall/cate`) // 设置与取消精选 export const updateChoiceAPI = (id: number) => Request('PATCH', `/wall/choice/${id}`) ================================================ FILE: src/api/web.ts ================================================ import Request from '@/utils/request' import { Web, WebType } from '@/types/app/web' // 新增网站 export const addLinkDataAPI = (data: Web) => Request('POST', '/link', { data }) // 删除网站 export const delLinkDataAPI = (id: number) => Request('DELETE', `/link/${id}`) // 修改网站 export const editLinkDataAPI = (data: Web) => Request('PATCH', '/link', { data }) // 获取网站 export const getLinkDataAPI = (id?: number) => Request('GET', `/link/${id}`) // 获取网站列表 export const getLinkListAPI = (data?: QueryData) => Request('POST', `/link/list`, { data: { ...data?.query }, }) // 分页获取评论列表 export const getLinkPagingAPI = (data?: QueryData) => Request>('POST', `/link/paging`, { data: { ...data?.query }, params: { ...data?.pagination } }) // 获取网站类型列表 export const getWebTypeListAPI = () => { return Request('GET', `/link/type`); }; // 审核网站 export const auditWebDataAPI = (id: number) => Request('PATCH', `/link/audit/${id}`) ================================================ FILE: src/components/CardDataStats/index.tsx ================================================ import { ReactNode } from 'react'; interface Props { title: string; total: string; children: ReactNode; } export default ({ title, total, children }: Props) => { return (

{title}

{total}

{children}
); }; ================================================ FILE: src/components/ClickOutside.tsx ================================================ import React, { useRef, useEffect } from 'react'; interface Props { children: React.ReactNode; exceptionRef?: React.RefObject; onClick: () => void; className?: string; } const ClickOutside: React.FC = ({ children, exceptionRef, onClick, className, }) => { const wrapperRef = useRef(null); useEffect(() => { const handleClickListener = (event: MouseEvent) => { let clickedInside: null | boolean = false; if (exceptionRef) { clickedInside = (wrapperRef.current && wrapperRef.current.contains(event.target as Node)) || (exceptionRef.current && exceptionRef.current === event.target) || (exceptionRef.current && exceptionRef.current.contains(event.target as Node)); } else { clickedInside = wrapperRef.current && wrapperRef.current.contains(event.target as Node); } if (!clickedInside) onClick(); }; document.addEventListener('mousedown', handleClickListener); return () => { document.removeEventListener('mousedown', handleClickListener); }; }, [exceptionRef, onClick]); return (
{children}
); }; export default ClickOutside; ================================================ FILE: src/components/Drawer/index.tsx ================================================ import { Drawer } from 'antd'; import { CloseOutlined } from '@ant-design/icons'; interface Props { title: string; loading?: boolean; open?: boolean; onClose?: (open: boolean) => void; className?: string; children: React.ReactNode; } export default ({ title, children, open, onClose, loading, className }: Props) => { const Title = () => { return (
{title}
onClose?.(false)} className="group p-3 px-6 hover:bg-red-500 hover:text-white transition-colors cursor-pointer" >
); }; return ( } open={open} onClose={() => onClose?.(false)} height="100vh" placement="bottom" closeIcon={null} className={`[&>.ant-drawer-header]:p-0! ${className}`} > {children} ); }; ================================================ FILE: src/components/Dropdowns/DropdownDefault.tsx ================================================ import { useEffect, useRef, useState } from 'react'; const DropdownDefault = () => { const [dropdownOpen, setDropdownOpen] = useState(false); const trigger = useRef(null); const dropdown = useRef(null); // 监听点击事件,如果点击发生在下拉菜单外部,则关闭下拉菜单 useEffect(() => { const clickHandler = ({ target }: MouseEvent) => { // 如果下拉菜单未挂载,直接返回 if (!dropdown.current || !trigger.current) return; // 如果下拉菜单未打开,或者点击目标在下拉菜单或触发按钮内部,则不做处理 if (!dropdownOpen || dropdown.current.contains(target as Node) || trigger.current.contains(target as Node)) return; // 否则关闭下拉菜单 setDropdownOpen(false); }; // 添加全局点击事件监听 document.addEventListener('click', clickHandler); // 组件卸载时移除监听 return () => document.removeEventListener('click', clickHandler); }); // 监听键盘事件,如果按下的是 ESC 键,则关闭下拉菜单 useEffect(() => { const keyHandler = (event: KeyboardEvent) => { // 如果下拉菜单未打开或按下的不是 ESC 键,则不做处理 if (!dropdownOpen || event.key !== 'Escape') return; // 关闭下拉菜单 setDropdownOpen(false); }; // 添加全局键盘按下事件监听 document.addEventListener('keydown', keyHandler); // 组件卸载时移除监听 return () => document.removeEventListener('keydown', keyHandler); }); return (
setDropdownOpen(true)} onBlur={() => setDropdownOpen(false)} className={`absolute right-0 top-full z-40 w-40 space-y-1 rounded-xs border border-stroke dark:border-strokedark bg-white p-1.5 shadow-default dark:bg-boxdark ${dropdownOpen === true ? 'block' : 'hidden'}`}>
); }; export default DropdownDefault; ================================================ FILE: src/components/Empty/index.tsx ================================================ import Empty from './empty.svg'; export default () => { return (
空空如也
); }; ================================================ FILE: src/components/FileUpload/index.tsx ================================================ import { useRef, useState, useCallback } from 'react'; import { InboxOutlined } from '@ant-design/icons'; import { message, Modal, Radio, Select, Spin } from 'antd'; import { useUserStore } from '@/stores'; import { DirList } from '@/types/app/file'; import { baseURL } from '@/utils/request'; import Compressor from 'compressorjs'; interface Props { multiple?: boolean; dir: DirList; open: boolean; onSuccess: (urls: string[]) => void; onCancel: () => void; } export default ({ multiple, dir, open, onCancel, onSuccess }: Props) => { const store = useUserStore(); const dragCounterRef = useRef(0); const fileInputRef = useRef(null); const [quality, setQuality] = useState(1000); const [isCompressionUpload, setIsCompressionUpload] = useState(false); const [isLoading, setIsLoading] = useState(false); const [isDragging, setIsDragging] = useState(false); const onUploadFile = async (files: File[]) => { try { setIsLoading(true); // 上传前先压缩文件大小 const compressedFiles = await Promise.all( files.map((file) => { return new Promise((resolve, reject) => { new Compressor(file, { quality, success: (blob) => { // 将 Blob 转换为 File const f = new File([blob], file.name, { type: file.type, lastModified: Date.now(), }); resolve(f); }, error: (err) => reject(err), }); }); }), ); // 处理成后端需要的格式 const formData = new FormData(); formData.append('dir', dir); for (let i = 0; i < compressedFiles.length; i++) { formData.append('files', compressedFiles[i]); } // 发起网络请求 const res = await fetch(`${baseURL}/file`, { method: 'POST', body: formData, headers: { Authorization: `Bearer ${store.token}`, }, }); const { code, message: msg, data } = await res.json(); if (code !== 200) return message.error('文件上传失败:' + msg); try { // 把数据写入到剪贴板 await navigator.clipboard.writeText(data.join('\n')); } catch (error) { console.error(error); message.error('复制到剪贴板失败,请手动复制'); onSuccess(data); setIsLoading(false); return; } message.success(`🎉 文件上传成功,URL链接已复制到剪贴板`); onSuccess(data); onCloseModel(); } catch (error) { message.error('文件上传失败:' + (error as Error).message); onCloseModel(); } }; const onCloseModel = () => { setIsCompressionUpload(false); setQuality(1000); setIsLoading(false); onCancel(); }; // 文件上传 const handleFileInput = (e: React.ChangeEvent) => { if (e.target.files) { onUploadFile([...e.target.files]); } }; // 拖拽上传 const handleDragOver = useCallback((e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); }, []); // 拖拽进入 const handleDragEnter = useCallback((e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); dragCounterRef.current++; if (dragCounterRef.current === 1) { setIsDragging(true); } }, []); // 拖拽离开 const handleDragLeave = useCallback((e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); dragCounterRef.current--; if (dragCounterRef.current === 0) { setIsDragging(false); } }, []); // 拖拽放下 const handleDrop = useCallback( (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); dragCounterRef.current = 0; setIsDragging(false); const files = Array.from(e.dataTransfer.files); if (files.length > 0) { onUploadFile(files); } }, [onUploadFile], ); return ( <>
setIsCompressionUpload(e.target.value ? true : false)} > 无损上传 压缩上传 {isCompressionUpload && ( ); }; ================================================ FILE: src/components/HasPermission/index.tsx ================================================ import { useHasPermission } from '@/utils/permission'; interface Props { code: string; children: React.ReactNode; } export default ({ code, children }: Props) => { const hasPermission = useHasPermission(code); return hasPermission ? children : null; } ================================================ FILE: src/components/Header/DarkModeSwitcher.tsx ================================================ import { useConfigStore } from '../../stores'; const DarkModeSwitcher = () => { const colorMode = useConfigStore((state) => state.colorMode); const setColorMode = useConfigStore((state) => state.setColorMode); return (
  • ); }; export default DarkModeSwitcher; ================================================ FILE: src/components/Header/DropdownUser.tsx ================================================ import { Link } from 'react-router-dom'; import { Dropdown, MenuProps } from 'antd'; import { useUserStore } from '@/stores'; const DropdownUser = () => { const store = useUserStore(); // 菜单项配置 const items: MenuProps['items'] = [ { key: 'profile', label: ( 我的资料 ), }, { key: 'setup', label: ( 网站配置 ), }, { type: 'divider', }, { key: 'logout', label: ( ), }, ]; return (
    {store.user?.name} 超级管理员 User
    ); }; export default DropdownUser; ================================================ FILE: src/components/Header/index.tsx ================================================ import { Link } from 'react-router-dom'; import { useEffect, useState } from 'react'; import { Skeleton } from 'antd'; import { useUserStore } from '@/stores'; import DropdownUser from './DropdownUser'; import DarkModeSwitcher from './DarkModeSwitcher'; import logo from '/logo.png'; import PageTab from '../PageTab'; const Header = (props: { sidebarOpen: string | boolean | undefined; setSidebarOpen: (arg0: boolean) => void }) => { const user = useUserStore((state) => state.user); const [initialLoading, setInitialLoading] = useState(true); // 等待用户信息加载完成后,取消初始加载状态 useEffect(() => { if (user?.name) { setInitialLoading(false); } else { // 如果用户信息未加载,等待最多 500ms 后显示内容 const timer = setTimeout(() => { setInitialLoading(false); }, 500); return () => clearTimeout(timer); } }, [user]); // 初始加载时显示骨架屏 if (initialLoading) { return (
    {/* 移动端菜单按钮和 Logo 骨架屏 */}
    {/* PageTab 骨架屏 */}
    {[1, 2, 3].map((item) => ( ))}
    {/* 右侧操作栏骨架屏 */}
    ); } return (
    logo
    ); }; export default Header; ================================================ FILE: src/components/Loader/index.tsx ================================================ export default () => { return (
    ); }; ================================================ FILE: src/components/Material/index.scss ================================================ .FilePage { .ant-image { display: block; width: 100%; .ant-image-img { width: 100%; height: auto; display: block; } } } // 自定义图片预览样式 .customAntdPreviewsItem { overflow: hidden; background: #fff; border-radius: 10px; .anticon { font-size: 20px; color: #5d5d5d; padding: 10px; &:hover { color: #60a5fa; } } } ================================================ FILE: src/components/Material/index.tsx ================================================ import { useEffect, useState, useRef } from 'react'; import { Image, Spin, message, Button } from 'antd'; import { CheckOutlined } from '@ant-design/icons'; import { Modal } from 'antd'; import Masonry from 'react-masonry-css'; import { getFileListAPI, getDirListAPI } from '@/api/file'; import { File, FileDir } from '@/types/app/file'; import errorImg from '@/pages/file/image/error.png'; import fileSvg from '@/pages/file/image/file.svg'; import { PiKeyReturnFill } from 'react-icons/pi'; import FileUpload from '@/components/FileUpload'; import './index.scss'; interface Props { multiple?: boolean; maxCount?: number; open: boolean; onClose: () => void; onSelect?: (files: string[]) => void; } // Masonry 布局的响应式断点配置 const breakpointColumnsObj = { default: 4, 1100: 3, 700: 2, 500: 1, }; export default ({ multiple, open, onClose, onSelect, maxCount }: Props) => { // 加载状态 const [loading, setLoading] = useState(false); // 当前页码 const [page, setPage] = useState(1); // 是否还有更多数据 const [hasMore, setHasMore] = useState(true); // 防止重复加载的引用 const loadingRef = useRef(false); // 文件列表数据 const [fileList, setFileList] = useState([]); // 目录列表数据 const [dirList, setDirList] = useState([]); // 当前选中的目录 const [dirName, setDirName] = useState(''); // 选中的文件列表 const [selectedFiles, setSelectedFiles] = useState([]); // 上传文件弹窗 const [isUploadModalOpen, setIsUploadModalOpen] = useState(false); // 获取目录列表 const getDirList = async () => { try { setLoading(true); const { data } = await getDirListAPI(); const dirList = ['default', 'equipment', 'record', 'article', 'footprint', 'swiper', 'album']; dirList.forEach((dir) => { if (!data.some((item: FileDir) => item.name === dir)) { data.push({ name: dir, path: '' }); } }); setDirList(data); setLoading(false); } catch (error) { console.error(error); setLoading(false); } }; useEffect(() => { getDirList(); }, []); // 获取文件列表 const getFileList = async (dir: string, isLoadMore = false) => { // 防止重复加载 if (loadingRef.current) return; try { loadingRef.current = true; setLoading(true); // 请求文件列表数据,如果是加载更多则页码+1 const { data } = await getFileListAPI(dir, { page: isLoadMore ? page + 1 : 1, size: 15 }); // 根据是否是加载更多来决定是替换还是追加数据 if (!isLoadMore) { setFileList(data.result); setPage(1); } else { setFileList((prev) => [...prev, ...data.result]); setPage((prev) => prev + 1); } // 判断是否还有更多数据 setHasMore(data.result.length === 15); setLoading(false); loadingRef.current = false; } catch (error) { console.error(error); setLoading(false); loadingRef.current = false; } }; // 处理滚动事件,实现下拉加载更多 const handleScroll = (e: React.UIEvent) => { const { scrollTop, scrollHeight, clientHeight } = e.currentTarget; // 当滚动到底部(距离底部小于50px)且还有更多数据时,触发加载更多 if (scrollHeight - scrollTop - clientHeight < 50 && hasMore && !loading) { getFileList(dirName, true); } }; // 取消选择 const onCancelSelect = () => { reset(); onClose(); }; // 打开目录 const openDir = (dir: string) => { setDirName(dir); getFileList(dir); }; // 处理选中的图片 const onHandleSelectImage = (item: File) => { setSelectedFiles((prev) => { // 如果 maxCount 不为 1,则开启多选 const isMultiple = multiple || (maxCount !== undefined && maxCount !== 1); if (isMultiple) { // 多选模式 const isSelected = prev.some((file) => file.url === item.url); if (isSelected) { return prev.filter((file) => file.url !== item.url); } else { // 检查是否超过最大数量限制 if (maxCount && prev.length >= maxCount) { message.warning(`最多只能选择 ${maxCount} 个文件`); return prev; } return [...prev, item]; } } else { // 单选模式 return [item]; } }); }; // 处理文件上传成功做的事情 const onUpdateSuccess = (urls: string[]) => { setIsUploadModalOpen(false); if (onSelect) onSelect(urls); reset(); onClose(); }; // 确认选择 const onHandleSelect = () => { const list = selectedFiles.map((item) => item.url); if (onSelect) onSelect(list); reset(); onClose(); }; const reset = () => { setFileList([]); setSelectedFiles([]); setDirName(''); }; return ( 取消 , , ] : null } zIndex={1100} >
    {!fileList.length && !dirName ? : } {dirName && ( )}
    {fileList.length || (!fileList.length && dirName) ? ( {fileList.map((item, index) => (
    file.url === item.url) ? 'border-primary' : 'border-gray-100'}`} onClick={() => onHandleSelectImage(item)}>
    {selectedFiles.some((file) => file.url === item.url) && (
    )}
    ))}
    ) : ( dirList.map((item, index) => (
    openDir(item.name)}>

    {item.name}

    )) )}
    {/* 文件上传弹窗 */} setIsUploadModalOpen(false)} />
    ); }; ================================================ FILE: src/components/NotFound/index.tsx ================================================ import { Button, Result } from 'antd' export default () => { return ( <> window.open('https://github.com/LiuYuYang01/ThriveX-Admin')}>借此机会帮忙点个star} /> ) } ================================================ FILE: src/components/PageTab/index.tsx ================================================ import { useEffect, useRef } from 'react'; import { useNavigate, useLocation } from 'react-router-dom'; import { AiOutlineClose } from 'react-icons/ai'; import useTabsStore, { TabItem } from '@/stores/modules/tabs'; import { getRouteConfig } from '@/utils/route'; export default () => { const navigate = useNavigate(); const location = useLocation(); const { tabs, activeTab, addTab, removeTab, setActiveTab } = useTabsStore(); const tabsContainerRef = useRef(null); // 监听路由变化,自动添加标签 useEffect(() => { const pathname = location.pathname; const routeConfig = getRouteConfig(pathname); if (routeConfig) { addTab({ path: pathname, title: routeConfig.title, }); setActiveTab(pathname); } }, [location.pathname, addTab, setActiveTab]); // 检查滚动状态 const checkScroll = () => { if (!tabsContainerRef.current) return; }; useEffect(() => { checkScroll(); const container = tabsContainerRef.current; if (container) { container.addEventListener('scroll', checkScroll); window.addEventListener('resize', checkScroll); } return () => { if (container) { container.removeEventListener('scroll', checkScroll); } window.removeEventListener('resize', checkScroll); }; }, [tabs]); // 切换到指定标签 const handleTabClick = (tab: TabItem) => { setActiveTab(tab.path); navigate(tab.path); }; // 关闭标签 const handleCloseTab = (e: React.MouseEvent, tab: TabItem) => { e.stopPropagation(); if (tabs.length <= 1) { return; // 至少保留一个标签 } const currentIndex = tabs.findIndex((t) => t.path === tab.path); const isActiveTab = activeTab === tab.path; // 如果关闭的是当前激活的标签,先导航到新的激活标签 if (isActiveTab) { let newActivePath = '/'; if (currentIndex > 0) { newActivePath = tabs[currentIndex - 1].path; } else if (tabs.length > 1) { newActivePath = tabs[1].path; } navigate(newActivePath); } // 移除标签 removeTab(tab.path); }; // 获取标签图标 const getTabIcon = (path: string) => { const routeConfig = getRouteConfig(path); return routeConfig?.icon || null; }; return (
    {/* 标签容器 */}
    {tabs.map((tab) => { const isActive = activeTab === tab.path; const icon = getTabIcon(tab.path); return (
    handleTabClick(tab)} className={` relative flex items-center gap-2 px-4 h-10 cursor-pointer transition-all duration-200 hover:text-primary! ${isActive ? 'text-primary' : 'text-gray-500 dark:text-gray-400'} `} > {icon && {icon}} {tab.title} {tabs.length > 1 && ( )}
    ); })}
    ); }; ================================================ FILE: src/components/PageTitle.tsx ================================================ import { useEffect } from 'react'; import { useLocation } from 'react-router-dom'; interface Props { title: string; } export default ({ title }: Props) => { const location = useLocation(); useEffect(() => { document.title = title; }, [location, title]); return null; }; ================================================ FILE: src/components/RandomAvatar/index.tsx ================================================ import { useMemo } from 'react'; import { createAvatar } from '@dicebear/core'; // 使用指定风格头像 import { pixelArt } from '@dicebear/collection'; export default ({ className }: { className?: string }) => { const avatar = useMemo(() => { // 生成一个随机种子 const seed = Math.random().toString(36).substring(2, 15); // 创建头像 return createAvatar(pixelArt, { seed: seed, // 使用随机种子 size: 128, // 其他选项 }).toDataUri(); }, []); return Avatar } ================================================ FILE: src/components/RouteList/index.tsx ================================================ import { useEffect } from 'react'; import DefaultLayout from '@/layout/DefaultLayout'; import { Route, Routes, useLocation, useNavigate } from 'react-router-dom'; import Home from '@/pages/dashboard'; import Create from '@/pages/create'; import CreateRecord from '@/pages/create_record'; import Cate from '@/pages/cate'; import Article from '@/pages/article'; import Comment from '@/pages/comment'; import Wall from '@/pages/wall'; import Tag from '@/pages/tag'; import Web from '@/pages/web'; import Swiper from '@/pages/swiper'; import Footprint from '@/pages/footprint'; import Setup from '@/pages/setup'; import File from '@/pages/file'; import Iterative from '@/pages/iterative'; import Login from '@/pages/login'; import Work from '@/pages/work'; import Draft from '@/pages/draft'; import Decycle from '@/pages/decycle'; import Record from '@/pages/record'; import Storage from '@/pages/storage'; import Assistant from '@/pages/assistant'; import Config from '@/pages/config'; import PageTitle from '../PageTitle'; import { useUserStore } from '@/stores'; import { checkTokenAPI } from '@/api/user'; import NotFound from '../NotFound'; export default () => { const navigate = useNavigate(); const store = useUserStore(); const { pathname } = useLocation(); const isLoginRoute = pathname === '/login' || pathname === '/auth'; const routes = [ { path: '/', title: '仪表盘', component: }, { path: '/create', title: '发挥灵感', component: }, { path: '/create_record', title: '闪念', component: }, { path: '/draft', title: '草稿箱', component: }, { path: '/recycle', title: '回收站', component: }, { path: '/cate', title: '导航管理', component: }, { path: '/article', title: '文章管理', component:
    }, { path: '/record', title: '说说管理', component: }, { path: '/tag', title: '标签管理', component: }, { path: '/comment', title: '评论管理', component: }, { path: '/wall', title: '评论管理', component: }, { path: '/web', title: '网站管理', component: }, { path: '/swiper', title: '轮播图管理', component: }, { path: '/footprint', title: '足迹管理', component: }, { path: '/storage', title: '存储管理', component: }, { path: '/setup', title: '项目配置', component: }, { path: '/file', title: '文件管理', component: }, { path: '/iter', title: '项目更新记录', component: }, { path: '/work', title: '工作台', component: }, { path: '/assistant', title: '助手管理', component: }, { path: '/config', title: '项目配置', component: }, ]; useEffect(() => { // 如果没有token并且不在登录相关页面就跳转到登录页 if (!store.token && !isLoginRoute) return navigate('/login'); }, [store, isLoginRoute]); useEffect(() => { if (store.token) checkTokenAPI(store.token); }, [store, pathname]); if (isLoginRoute) { return ( } /> ); } return ( {routes.map(({ path, title, component }) => ( {component} } /> ))} } /> ); }; ================================================ FILE: src/components/Sidebar/SidebarLinkGroup.tsx ================================================ import { ReactNode, useState } from 'react'; interface SidebarLinkGroupProps { children: (handleClick: () => void, open: boolean) => ReactNode; activeCondition: boolean; } const SidebarLinkGroup = ({ children, activeCondition, }: SidebarLinkGroupProps) => { const [open, setOpen] = useState(activeCondition); const handleClick = () => { setOpen(!open); }; return
  • {children(handleClick, open)}
  • ; }; export default SidebarLinkGroup; ================================================ FILE: src/components/Sidebar/index.tsx ================================================ import React, { useEffect, useRef, useState } from 'react'; import { NavLink, useLocation } from 'react-router-dom'; import { Skeleton } from 'antd'; import SidebarLinkGroup from './SidebarLinkGroup'; import { BiEditAlt, BiFolderOpen, BiHomeSmile, BiSliderAlt, BiCategoryAlt, BiBug } from 'react-icons/bi'; import { TbBrandAirtable } from 'react-icons/tb'; import logo from '/logo.png'; interface SidebarProps { sidebarOpen: boolean; setSidebarOpen: (arg: boolean) => void; } // 定义导航项的类型 interface MenuItem { to: string; path: string; icon: React.ReactNode; name: string | React.ReactNode; subMenu?: SubMenuItem[]; } interface SubMenuItem { to: string; path: string; name: string; } const Sidebar = ({ sidebarOpen, setSidebarOpen }: SidebarProps) => { const location = useLocation(); const { pathname } = location; const [initialLoading, setInitialLoading] = useState(true); // 创建 ref 用于触发器和侧边栏元素 const trigger = useRef(null); const sidebar = useRef(null); // 从 localStorage 获取侧边栏展开状态 const storedSidebarExpanded = localStorage.getItem('sidebar-expanded'); const [sidebarExpanded, setSidebarExpanded] = useState(storedSidebarExpanded === null ? false : storedSidebarExpanded === 'true'); // 点击事件处理:点击侧边栏外部时关闭侧边栏 useEffect(() => { const clickHandler = ({ target }: MouseEvent) => { if (!sidebar.current || !trigger.current) return; if (!sidebarOpen || sidebar.current.contains(target as Node) || trigger.current.contains(target as Node)) return; setSidebarOpen(false); }; document.addEventListener('click', clickHandler); return () => document.removeEventListener('click', clickHandler); }); // 键盘事件处理:按 ESC 键关闭侧边栏 useEffect(() => { const keyHandler = ({ keyCode }: KeyboardEvent) => { if (!sidebarOpen || keyCode !== 27) return; setSidebarOpen(false); }; document.addEventListener('keydown', keyHandler); return () => document.removeEventListener('keydown', keyHandler); }); // 侧边栏展开状态持久化处理 useEffect(() => { localStorage.setItem('sidebar-expanded', sidebarExpanded.toString()); if (sidebarExpanded) { document.querySelector('body')?.classList.add('sidebar-expanded'); } else { document.querySelector('body')?.classList.remove('sidebar-expanded'); } }, [sidebarExpanded]); // 版本数据加载完成后,取消初始加载状态 useEffect(() => { setInitialLoading(false); }, []); const [isSideBarTheme] = useState<'dark' | 'light'>('light'); // 定义导航项的样式类 const sidebarItemStyDark = 'group relative flex items-center gap-2.5 py-2 px-4 text-[#DEE4EE]! duration-300 ease-in-out hover:bg-graydark dark:hover:bg-[#313D4A] rounded-xs font-medium hover:text-primary! dark:hover:text-primary!'; const sidebarItemStyLight = 'group relative flex items-center gap-2.5 py-2 px-4 text-[#444]! dark:text-slate-200! duration-300 ease-in-out hover:bg-[rgba(241,241,244,0.9)] dark:hover:bg-[#313D4A] rounded-md hover:backdrop-blur-[15px] hover:text-primary! dark:hover:text-primary!'; const sidebarItemActiveSty = `${isSideBarTheme === 'dark' ? 'bg-graydark' : 'text-primary!'}`; // 箭头图标组件:用于显示子菜单的展开/收起状态 const Arrow = ({ open }: { open: boolean }) => { return ( ); }; // 定义完整的路由列表配置 const routes: { group: string; list: MenuItem[] }[] = [ { group: '', list: [ { to: '/', path: 'dashboard', icon: , name: '仪表盘', }, { to: '#', path: 'write', icon: , name: '创作', subMenu: [ { to: '/create', path: 'create', name: '谱写', }, { to: '/create_record', path: 'create_record', name: '闪念', }, { to: '/draft', path: 'draft', name: '草稿箱', }, { to: '/recycle', path: 'recycle', name: '回收站', }, ], }, { to: '#', path: 'manage', icon: , name: '管理', subMenu: [ { to: '/article', path: 'article', name: '文章管理', }, { to: '/assistant', path: 'assistant', name: '助手管理', }, { to: '/record', path: 'record', name: '说说管理', }, { to: '/tag', path: 'tag', name: '标签管理', }, { to: '/comment', path: 'comment', name: '评论管理', }, { to: '/wall', path: 'wall', name: '留言管理', }, { to: '/cate', path: 'cate', name: '导航管理', }, { to: '/web', path: 'web', name: '网站管理', }, { to: '/swiper', path: 'swiper', name: '轮播图管理', }, { to: '/footprint', path: 'footprint', name: '足迹管理', }, { to: '/storage', path: 'storage', name: '存储管理', }, { to: '/config', path: 'config', name: '项目配置', }, ], }, { to: '/setup', path: 'setup', icon: , name: '系统', }, ], }, { group: 'New', list: [ { to: '/work', path: 'work', icon: , name: '工作台', }, { to: '/file', path: 'file', icon: , name: '文件系统', }, { to: '/iter', path: 'iter', icon: , name: (
    更新日志
    ), }, ], }, ]; // 初始加载时显示骨架屏 if (initialLoading) { return ( ); } // 渲染侧边栏组件 return ( ); }; export default Sidebar; ================================================ FILE: src/components/StatusTag/index.tsx ================================================ interface StatusTagProps { status: number | boolean; className?: string; flash?: boolean; } export default ({ status, className, flash = false }: StatusTagProps) => { const enabled = Boolean(status); const animateClass = flash ? 'animate-pulse' : ''; const pingClass = flash ? 'animate-ping' : ''; return (
    {enabled ? (
    ) : (
    )}
    ); }; ================================================ FILE: src/components/SystemNotification/index.tsx ================================================ import { Modal, Button } from 'antd'; import { GithubOutlined } from '@ant-design/icons'; const SHOW_NOTIFICATION_KEY = 'show_login_notification'; const GITHUB_URL = 'https://github.com/LiuYuYang01/ThriveX-Admin'; interface Props { open: boolean; onClose: () => void; } export default ({ open, onClose }: Props) => { // 关闭通知框 const handleClose = () => { localStorage.removeItem(SHOW_NOTIFICATION_KEY); onClose(); }; // 跳转到 GitHub const handleGoToGitHub = () => { window.open(GITHUB_URL, '_blank'); }; return (

    ⭐ 喜欢 ThriveX 吗?

    如果这个项目对你有帮助,欢迎在 GitHub 上给我们一个 Star!
    你的支持是我们持续更新的最大动力 🚀

    ThriveX 是一个年轻、高颜值、全开源、永不收费的现代化博客管理系统

    ); }; // 导出工具函数:设置显示通知标记 export const setShowLoginNotification = () => { localStorage.setItem(SHOW_NOTIFICATION_KEY, 'true'); }; // 导出工具函数:检查是否需要显示通知 export const shouldShowLoginNotification = (): boolean => { return localStorage.getItem(SHOW_NOTIFICATION_KEY) === 'true'; }; ================================================ FILE: src/components/Title/index.tsx ================================================ import { ReactNode } from 'react' interface Props { value: string, children?: ReactNode, className?: string } export default ({ value, children }: Props) => { return (

    {value}

    {children}
    ) } ================================================ FILE: src/components/WangEditor/index.scss ================================================ .w-e-text-container { .w-e-bar { display: none; } } ================================================ FILE: src/components/WangEditor/index.tsx ================================================ import { useState, useEffect, useImperativeHandle, forwardRef } from 'react'; import { Editor, Toolbar } from '@wangeditor-next/editor-for-react'; import { IDomEditor, IEditorConfig, IToolbarConfig } from '@wangeditor-next/editor'; import '@wangeditor-next/editor/dist/css/style.css'; import './index.scss'; export default forwardRef((_props, ref) => { // editor 实例 const [editor, setEditor] = useState(null); // 编辑器内容 const [html, setHtml] = useState(''); // 工具栏配置 const toolbarConfig: Partial = { excludeKeys: ['headerSelect', 'blockquote', 'emotion', 'group-video', 'group-image', 'formatPainter', 'divider', 'codeBlock', 'numberedList', 'bulletedList', 'todo', 'fontFamily', 'fontSize', 'fontColor'], }; // 编辑器配置 const editorConfig: Partial = { placeholder: '记录此刻美好...', autoFocus: true, // 默认获取焦点 }; useEffect(() => { return () => { if (editor == null) return; editor.destroy(); setEditor(null); }; }, [editor]); // 暴露方法 useImperativeHandle(ref, () => { return { setValue: (value: string) => { setHtml(value); }, getValue: () => { return editor?.getHtml(); }, }; }, [editor]); return (
    setHtml(editor.getHtml())} mode="default" className="min-h-64" />
    ); }); ================================================ FILE: src/hooks/useAssistant.tsx ================================================ import { useState, useEffect } from 'react'; import { message } from 'antd'; import { testAssistantConnection, callAssistantAPI } from '@/services/assistant'; import { Assistant } from '@/types/app/assistant'; import { delAssistantDataAPI, getAssistantListAPI, addAssistantDataAPI, editAssistantDataAPI, setDefaultAssistantAPI } from '@/api/assistant'; export default function useAssistant() { const [loading, setLoading] = useState(false); const [testingMap, setTestingMap] = useState>({}); const [list, setList] = useState([]); const [assistant, setAssistant] = useState(null); // 获取助手列表 const getAssistantList = async () => { const { data } = await getAssistantListAPI(); setList(data); // 设置默认助手 const defaultAssistant = data.find((a) => a.isDefault); if (defaultAssistant) setAssistant(String(defaultAssistant.id)); }; // 初始化加载助手列表 useEffect(() => { getAssistantList(); }, []); // 添加或更新助手 const saveAssistant = async (assistant: Assistant) => { setLoading(true); try { if (assistant.id) { // 更新现有助手 await editAssistantDataAPI(assistant); } else { // 添加新助手 await addAssistantDataAPI(assistant); } // 更新成功后重新获取列表 await getAssistantList(); message.success(assistant.id ? '助手已更新' : '助手已添加'); return true; } catch (error) { console.error(error); return false; } finally { setLoading(false); } }; // 删除助手 const delAssistantData = async (id: number) => { await delAssistantDataAPI(id); getAssistantList(); message.success('助手已删除'); }; // 设置默认助手 const setDefaultAssistant = async (id: number) => { await setDefaultAssistantAPI(id); getAssistantList(); message.success('默认助手已更新'); }; // 测试助手连接 const testConnection = async (assistant: Assistant) => { setTestingMap((prev) => ({ ...prev, [assistant.id]: true })); try { const result = await testAssistantConnection(assistant); return result; } finally { setTestingMap((prev) => ({ ...prev, [assistant.id]: false })); } }; // 调用助手API const callAssistant = async ( messages: Array<{ role: string; content: string }>, options?: { stream?: boolean; temperature?: number; max_tokens?: number; }, ) => { if (!assistant) { message.error('请先选择助手'); return null; } const data = list.find((a) => a.id === Number(assistant)); if (!data) { message.error('助手不存在'); return null; } return callAssistantAPI(data, messages, options); }; return { list, assistant, setAssistant, loading, testingMap, saveAssistant, delAssistantData, setDefaultAssistant, testConnection, callAssistant, }; } ================================================ FILE: src/hooks/useAuthRedirect.tsx ================================================ import { useEffect } from 'react'; import { useNavigate, useLocation } from 'react-router-dom'; import { useUserStore } from '@/stores'; // 如果即将去往的是 /login 页面并且有 token 情况就自动重定向到 /,否则就跳转 const useAuthRedirect = () => { const store = useUserStore(); const navigate = useNavigate(); const location = useLocation(); useEffect(() => { const token = store.token; const isGoingToLogin = location.pathname === '/login'; if (isGoingToLogin && token) navigate('/'); }, [location, navigate, store.token]); }; export default useAuthRedirect; ================================================ FILE: src/hooks/useLocalStorage.tsx ================================================ import { useEffect, useState } from 'react'; type SetValue = T | ((val: T) => T); function useLocalStorage(key: string, initialValue: T): [T, (value: SetValue) => void] { // 存储值的状态 // 将初始状态函数传递给useState,因此逻辑只执行一次 const [storedValue, setStoredValue] = useState(() => { try { // 通过键从本地存储中获取 const item = window.localStorage.getItem(key); // 解析存储的json,如果没有则返回initialValue return item ? JSON.parse(item) : initialValue; } catch (error) { // 如果出错也返回initialValue console.log(error); return initialValue; } }); // 当状态改变时,useEffect更新本地存储 useEffect(() => { try { // 允许值为函数,因此我们有与useState相同的API const valueToStore = typeof storedValue === 'function' ? storedValue(storedValue) : storedValue; // 保存状态 window.localStorage.setItem(key, JSON.stringify(valueToStore)); } catch (error) { // 更高级的实现会处理错误情况 console.log(error); } }, [key, storedValue]); return [storedValue, setStoredValue]; } export default useLocalStorage; ================================================ FILE: src/hooks/useVersionData.tsx ================================================ import { useState, useEffect } from 'react'; import axios from 'axios'; interface Version { name: string; tag_name: string; html_url: string; } const useVersionData = () => { const [version, setVersion] = useState({} as Version); useEffect(() => { const getVersionData = async () => { try { // 先检查 sessionStorage 中是否有缓存的版本数据 const cachedVersion = sessionStorage.getItem('project_version'); if (cachedVersion) { const parsedVersion = JSON.parse(cachedVersion); // 检查缓存的数据是否有效(包含必要字段) if (parsedVersion.tag_name && parsedVersion.html_url) { setVersion(parsedVersion); return; // 使用缓存数据,不调用接口 } } // 如果没有缓存或缓存无效,则调用接口获取数据 // https://api.github.com/repos/LiuYuYang01/ThriveX-Blog/releases const { data } = await axios.get('https://api.github.com/repos/LiuYuYang01/ThriveX-Admin/releases/latest'); setVersion(data); // 将新数据存储到 sessionStorage sessionStorage.setItem('project_version', JSON.stringify(data)); } catch (error) { console.error('获取版本信息失败:', error); } }; getVersionData(); }, []); return version; }; export default useVersionData; ================================================ FILE: src/layout/DefaultLayout.tsx ================================================ import { useState, useEffect } from 'react'; import Header from '../components/Header/index'; import Sidebar from '../components/Sidebar/index'; import { useConfigStore } from '@/stores'; export default ({ children }: { children: React.ReactNode }) => { const [sidebarOpen, setSidebarOpen] = useState(false); const colorMode = useConfigStore((state) => state.colorMode); useEffect(() => { const className = 'dark'; const bodyClass = window.document.body.classList; if (colorMode === 'dark') { bodyClass.add(className); } else { bodyClass.remove(className); } }, [colorMode]); return (
    {children}
    ); }; ================================================ FILE: src/main.tsx ================================================ import ReactDOM from 'react-dom/client'; import { BrowserRouter as Router } from 'react-router-dom'; import App from './App'; import '@/styles/index.css'; const app = ReactDOM.createRoot(document.getElementById('root') as HTMLElement); app.render( , ); ================================================ FILE: src/pages/article/components/ArticleExport.tsx ================================================ import React, { useCallback } from 'react'; import { Button, Dropdown, Popconfirm, Tooltip, message } from 'antd'; import { DownloadOutlined } from '@ant-design/icons'; import JSZip from 'jszip'; import { saveAs } from 'file-saver'; import type { Article } from '@/types/app/article'; // 文章 → Markdown function articleToMarkdown(article: Article): string { const { title, description, content, cover, createTime, cateList, tagList } = article; const formatDate = (timestamp: string) => { const date = new Date(Number(timestamp)); const pad = (n: number) => String(n).padStart(2, '0'); return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`; }; const tags = (tagList || []).map((t) => t.name); const categories = (cateList || []).map((c) => c.name); const keywords = [...tags, ...categories].join(' '); return `---\ntitle: ${title}\ntags: ${tags.join(' ')}\ncategories: ${categories.join(' ')}\ncover: ${cover}\ndate: ${formatDate(createTime || String(Date.now()))}\nkeywords: ${keywords}\ndescription: ${description}\n---\n\n${(content || '').trim()}`; } function safeFileName(title: string): string { return title.replace(/[\\/:*?"<>|]/g, '_'); } function downloadBlob(content: string, fileName: string, mimeType = 'text/plain;charset=utf-8') { const blob = new Blob([content], { type: mimeType }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = fileName; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); } async function downloadArticlesZip(articles: Article[]) { const zip = new JSZip(); const folder = zip.folder('data'); for (const article of articles) { const markdown = articleToMarkdown(article); folder?.file(`${safeFileName(article.title)}.md`, markdown); } zip.file('articles.json', JSON.stringify(articles, null, 2)); const blob = await zip.generateAsync({ type: 'blob' }); saveAs(blob, `导出文章_${Date.now()}.zip`); } // 单篇导出 export interface ArticleExportSingleProps { article: Article; } export const ArticleExportSingle = ({ article }: ArticleExportSingleProps) => { const handleExport = useCallback(() => { const markdown = articleToMarkdown(article); downloadBlob(markdown, `${safeFileName(article.title)}.md`, 'text/markdown;charset=utf-8'); }, [article]); return ( , , ]} >
    fileInputRef.current?.click()} onKeyDown={(e) => e.key === 'Enter' && fileInputRef.current?.click()} onDragOver={handleDragOver} onDragEnter={handleDragEnter} onDragLeave={handleDragLeave} onDrop={handleDrop} className={`w-full h-40 p-4 border border-dashed rounded-lg transition-all duration-300 ${ isDragging ? 'border-primary bg-primary/5' : 'border-[#D7D7D7] hover:border-primary bg-[#FAFAFA]' } space-y-2 cursor-pointer`} >

    {isDragging ? '文件放在此处即上传' : '点击或拖动文件到此区域'}

    仅支持 Markdown 或 JSON 格式

    {fileList.length > 0 && (

    已选择的文件:

      {fileList.map((file) => (
    • {file.name}
    • ))}
    )} {fileList.length === 0 && (
    你可以下载模板后填写再导入:
    )}
    ); }; export default ArticleImportModal; ================================================ FILE: src/pages/article/index.tsx ================================================ import { useState, useEffect, useRef } from 'react'; import { Link } from 'react-router-dom'; import { Table, Button, Tag, notification, Popconfirm, Form, Input, Select, DatePicker, message, Tooltip, Space, Divider, Popover } from 'antd'; import type { ColumnsType } from 'antd/es/table'; import type { TableRowSelection } from 'antd/es/table/interface'; import { DeleteOutlined, FormOutlined, InboxOutlined, SearchOutlined, ClearOutlined, EyeOutlined, CommentOutlined } from '@ant-design/icons'; import { HiOutlineChevronDown, HiOutlineChevronUp } from 'react-icons/hi'; import dayjs from 'dayjs'; import Title from '@/components/Title'; import ArticleImportModal from './components/ArticleImportModal'; import ArticleExport from './components/ArticleExport'; import { getCateListAPI } from '@/api/cate'; import { getTagListAPI } from '@/api/tag'; import { delArticleDataAPI, getArticlePagingAPI, addArticleDataAPI, delBatchArticleDataAPI } from '@/api/article'; import type { Tag as ArticleTag } from '@/types/app/tag'; import type { Cate as ArticleCate } from '@/types/app/cate'; import type { Article, Config, ArticleFilterQueryParams, ArticleFilterDataForm } from '@/types/app/article'; import { useWebStore } from '@/stores'; const { RangePicker } = DatePicker; export default () => { const [loading, setLoading] = useState(false); const [initialLoading, setInitialLoading] = useState(true); const [btnLoading, setBtnLoading] = useState(null); const [isModalOpen, setIsModalOpen] = useState(false); const isFirstLoadRef = useRef(true); const filterDebounceRef = useRef | null>(null); const [form] = Form.useForm(); const web = useWebStore((state) => state.web); const [articleList, setArticleList] = useState([]); const [total, setTotal] = useState(0); const [filter, setFilter] = useState({ key: undefined, cateId: undefined, tagId: undefined, isDraft: 0, isDel: 0, startDate: undefined, endDate: undefined, page: 1, size: 8, }); const [showBatchActions, setShowBatchActions] = useState(false); // 分页获取文章 const getArticleList = async () => { try { if (isFirstLoadRef.current) { setInitialLoading(true); } else { setLoading(true); } const { data } = await getArticlePagingAPI(filter); setTotal(data.total); setArticleList(data.result); isFirstLoadRef.current = false; } catch (error) { console.error(error); } finally { setInitialLoading(false); setLoading(false); } }; const delArticleData = async (id: number) => { try { setBtnLoading(id); await delArticleDataAPI(id, true); await getArticleList(); notification.success({ message: '删除成功' }); } catch (error) { console.error(error); } finally { setBtnLoading(null); } }; // 分类/标签:柔和色系,收纳展示(默认显示前 2 个,其余 +N,悬停展示全部) const tagColors = [ 'default', 'processing', 'success', 'warning', 'cyan', ] as const; const VISIBLE_TAG_COUNT = 1; const renderCollapsibleTags = ( list: T[], keyPrefix: string, ) => { if (list.length === 0) return null; const visible = list.slice(0, VISIBLE_TAG_COUNT); const restCount = list.length - VISIBLE_TAG_COUNT; const items = (
    {list.map((item, index) => ( {item.name} ))}
    ); return (
    {visible.map((item, index) => ( {item.name} ))} {restCount > 0 && ( +{restCount} )}
    ); }; const columns: ColumnsType
    = [ { title: 'ID', dataIndex: 'id', key: 'id', width: 80, align: 'center', render: (text) => #{text}, }, { title: '标题', dataIndex: 'title', key: 'title', width: 280, render: (text: string, record: Article) => ( <> {text ? ( {text} ) : ( 暂无标题 ) } ), }, { title: '摘要', dataIndex: 'description', key: 'description', width: 320, render: (text: string) => ( <> {text ? (
    {text}
    ) : ( 暂无摘要 )} ), }, { title: '分类', dataIndex: 'cateList', key: 'cateList', width: 140, render: (cates: ArticleCate[]) => renderCollapsibleTags(cates || [], 'cate'), }, { title: '标签', dataIndex: 'tagList', key: 'tagList', width: 160, render: (tags: ArticleTag[]) => renderCollapsibleTags(tags || [], 'tag'), }, { title: '浏览量', dataIndex: 'view', key: 'view', width: 100, align: 'center', render: (v) => ( {v ?? 0} ), sorter: (a: Article, b: Article) => (a.view ?? 0) - (b.view ?? 0), showSorterTooltip: false, }, { title: '评论', dataIndex: 'comment', key: 'comment', width: 90, align: 'center', render: (v) => ( {v ?? 0} ), sorter: (a: Article, b: Article) => (a.comment ?? 0) - (b.comment ?? 0), showSorterTooltip: false, }, { title: '状态', dataIndex: 'config', key: 'config', width: 130, align: 'center', render: (config: Config) => { const statusMap: Record = { default: '正常', no_home: '不在首页显示', hide: '隐藏', }; const label = config.password?.trim() ? '文章加密' : statusMap[config.status]; const statusColorMap: Record = { default: 'success', no_home: 'warning', hide: 'default', }; const color = config.password?.trim() ? 'processing' : statusColorMap[config.status] ?? 'default'; return ( {label} ); }, }, { title: '发布时间', dataIndex: 'createTime', key: 'createTime', width: 140, render: (text: string) => (
    {dayjs(+text).format('YYYY-MM-DD')} {dayjs(+text).format('HH:mm:ss')}
    ), }, { title: '操作', key: 'action', fixed: 'right', width: 165, align: 'center', render: (_, record: Article) => ( }>
    {/* 卡片内容:URL显示 */}
    API Endpoint
    {item.url}
    {/* 卡片底部:主要操作 */}
    ); })} {/* 空状态下的添加按钮(如果没有数据或者作为最后一个Card) */}
    { setIsModalOpen(false); form.resetFields(); setInputModelValue(''); setAssistant({} as Assistant); }} >
    {isCateShow && ( )}
    } placeholder="搜索文章标题..." className="w-[220px]!" allowClear /> } placeholder="搜索评论内容..." className="w-[220px]!" allowClear /> current && current > dayjs().endOf('day')} />
    (
    共 {totalCount} 条数据
    ), className: 'px-6! py-4!', }} className="[&_.ant-table-thead>tr>th]:bg-gray-50! dark:[&_.ant-table-thead>tr>th]:bg-boxdark-2! [&_.ant-table-thead>tr>th]:font-medium! [&_.ant-table-thead>tr>th]:text-gray-500! dark:[&_.ant-table-thead>tr>th]:text-gray-400!" /> setIsReplyModalOpen(false)}>