Merge branch 'worktree-desktop-main-e750a46a'
4
.gitignore
vendored
@@ -169,8 +169,12 @@ cython_debug/
|
||||
*/.DS_Store
|
||||
.vscode
|
||||
/node_modules
|
||||
webui/node_modules
|
||||
docs/.vitepress/cache
|
||||
|
||||
# WebUI build output (generated by `cd webui && npm run build`)
|
||||
api/webui/
|
||||
|
||||
# other gitignore
|
||||
.venv
|
||||
.refer
|
||||
|
||||
12
README.md
@@ -175,6 +175,18 @@ uv run main.py --help
|
||||
|
||||
MediaCrawler 提供了基于 Web 的可视化操作界面,无需命令行也能轻松使用爬虫功能。
|
||||
|
||||
#### 构建前端资源(首次使用需要)
|
||||
|
||||
WebUI 前端源码位于 `webui/` 目录,需要先构建静态资源后才能通过 API 服务器访问。
|
||||
|
||||
```shell
|
||||
cd webui
|
||||
npm install
|
||||
npm run build # 产物输出到 api/webui/
|
||||
```
|
||||
|
||||
> 开发调试可改用 `npm run dev`,会在 5173 端口启动 Vite 开发服务器并自动代理 `/api` 到 8080。
|
||||
|
||||
#### 启动 WebUI 服务
|
||||
|
||||
```shell
|
||||
|
||||
12
README_en.md
@@ -157,6 +157,18 @@ uv run main.py --help
|
||||
|
||||
MediaCrawler provides a web-based visual operation interface, allowing you to easily use crawler features without command line.
|
||||
|
||||
#### Build Frontend Assets (required for first-time use)
|
||||
|
||||
The WebUI frontend source lives in the `webui/` directory. You need to build the static assets before the API server can serve them.
|
||||
|
||||
```shell
|
||||
cd webui
|
||||
npm install
|
||||
npm run build # outputs to api/webui/
|
||||
```
|
||||
|
||||
> For development, run `npm run dev` instead — it starts the Vite dev server on port 5173 and proxies `/api` to 8080.
|
||||
|
||||
#### Start WebUI Service
|
||||
|
||||
```shell
|
||||
|
||||
36
webui/.gitignore
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# Dependencies
|
||||
node_modules/
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# Build output
|
||||
dist/
|
||||
/build
|
||||
|
||||
# IDE
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Local env files
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Debug logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Misc
|
||||
*.pem
|
||||
/coverage
|
||||
.playwright-mcp/
|
||||
674
webui/LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is 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. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
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.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
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 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. Use with the GNU Affero General Public License.
|
||||
|
||||
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 Affero 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 special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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 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 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 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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
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 GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -8,10 +8,9 @@
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||||
<script type="module" crossorigin src="/assets/index-DvClRayq.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-OiBmsgXF.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
4221
webui/package-lock.json
generated
Normal file
45
webui/package.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "mediacrawler-webui",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@radix-ui/react-accordion": "^1.2.2",
|
||||
"@radix-ui/react-dialog": "^1.1.4",
|
||||
"@radix-ui/react-label": "^2.1.1",
|
||||
"@radix-ui/react-scroll-area": "^1.2.2",
|
||||
"@radix-ui/react-select": "^2.1.4",
|
||||
"@radix-ui/react-slot": "^1.1.1",
|
||||
"@radix-ui/react-tabs": "^1.1.2",
|
||||
"@tanstack/react-query": "^5.62.7",
|
||||
"axios": "^1.7.9",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"i18next": "^25.7.3",
|
||||
"i18next-browser-languagedetector": "^8.2.0",
|
||||
"lucide-react": "^0.468.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-i18next": "^16.5.0",
|
||||
"sonner": "^1.7.1",
|
||||
"tailwind-merge": "^2.6.0",
|
||||
"zustand": "^5.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.3.16",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"postcss": "^8.4.49",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"typescript": "~5.6.2",
|
||||
"vite": "^6.0.3"
|
||||
}
|
||||
}
|
||||
6
webui/postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 312 KiB After Width: | Height: | Size: 312 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |
74
webui/src/App.tsx
Normal file
@@ -0,0 +1,74 @@
|
||||
import { useState } from 'react'
|
||||
import { Toaster } from 'sonner'
|
||||
import { Sidebar } from '@/components/layout/Sidebar'
|
||||
import { MainContent } from '@/components/layout/MainContent'
|
||||
import { AuthorFooter } from '@/components/layout/AuthorFooter'
|
||||
import { CrawlerConfigPanel } from '@/components/config/CrawlerConfigPanel'
|
||||
import { EnvironmentCheck, isEnvChecked } from '@/components/env/EnvironmentCheck'
|
||||
import { LicenseDisclaimer, isLicenseAccepted } from '@/components/license/LicenseDisclaimer'
|
||||
|
||||
function App() {
|
||||
// Initialize by checking localStorage if license has been accepted
|
||||
const [licenseAccepted, setLicenseAccepted] = useState(() => isLicenseAccepted())
|
||||
// Initialize by checking localStorage if env check has passed
|
||||
const [envChecked, setEnvChecked] = useState(() => isEnvChecked())
|
||||
// State for showing disclaimer manually
|
||||
const [showDisclaimer, setShowDisclaimer] = useState(false)
|
||||
|
||||
const handleEnvCheckComplete = () => {
|
||||
setEnvChecked(true)
|
||||
}
|
||||
|
||||
const handleLicenseAccept = () => {
|
||||
setLicenseAccepted(true)
|
||||
setShowDisclaimer(false)
|
||||
}
|
||||
|
||||
const handleShowDisclaimer = () => {
|
||||
setShowDisclaimer(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-screen cyber-grid overflow-hidden relative">
|
||||
{/* License Disclaimer Modal - Shows first or when triggered */}
|
||||
{(!licenseAccepted || showDisclaimer) && (
|
||||
<LicenseDisclaimer onAccept={handleLicenseAccept} />
|
||||
)}
|
||||
|
||||
{/* Environment Check Modal - Shows after license accepted */}
|
||||
{licenseAccepted && !showDisclaimer && !envChecked && (
|
||||
<EnvironmentCheck onCheckComplete={handleEnvCheckComplete} />
|
||||
)}
|
||||
|
||||
{/* Header Bar */}
|
||||
<Sidebar onShowDisclaimer={handleShowDisclaimer} />
|
||||
|
||||
{/* Main Area */}
|
||||
<div className="flex-1 flex flex-col gap-4 p-4 overflow-hidden min-h-0">
|
||||
{/* Config Panel - Primary Action Area (Always Expanded) */}
|
||||
<div className="flex-shrink-0">
|
||||
<CrawlerConfigPanel />
|
||||
</div>
|
||||
|
||||
{/* Console - Collapsible Terminal */}
|
||||
<MainContent />
|
||||
</div>
|
||||
|
||||
{/* Author Footer */}
|
||||
<AuthorFooter />
|
||||
|
||||
{/* Toast notifications - Theme-aware style */}
|
||||
<Toaster
|
||||
position="top-right"
|
||||
toastOptions={{
|
||||
className: 'glass-panel font-mono text-cyber-text-primary',
|
||||
style: {
|
||||
fontFamily: 'JetBrains Mono, monospace',
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
415
webui/src/components/config/CrawlerConfigPanel.tsx
Normal file
@@ -0,0 +1,415 @@
|
||||
import type { ComponentType, ReactNode, KeyboardEvent } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Database, Globe, KeyRound, MessageSquare, Play, Square, X } from 'lucide-react'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useCrawlerStore } from '@/store/crawlerStore'
|
||||
import { usePlatforms, useConfigOptions, useStartCrawler, useStopCrawler } from '@/hooks/useCrawler'
|
||||
import { ParsedIdList } from './ParsedIdList'
|
||||
|
||||
type SectionProps = {
|
||||
title: string
|
||||
description: string
|
||||
icon: ComponentType<{ className?: string }>
|
||||
children: ReactNode
|
||||
className?: string
|
||||
}
|
||||
|
||||
function Section({ title, description, icon: Icon, children, className = '' }: SectionProps) {
|
||||
return (
|
||||
<section className={`rounded-lg glass-panel float-panel overflow-hidden ${className}`}>
|
||||
<header className="px-4 py-3 border-b border-cyber-border-subtle/50 flex items-center gap-3 bg-cyber-bg-tertiary/30">
|
||||
<div className="h-8 w-8 rounded-md bg-cyber-bg-tertiary border border-cyber-border-subtle flex items-center justify-center flex-shrink-0">
|
||||
<Icon className="h-4 w-4 text-cyber-neon-cyan" />
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<div className="text-xs font-mono font-semibold text-cyber-text-primary tracking-wide">
|
||||
{title}
|
||||
</div>
|
||||
<div className="text-[10px] text-cyber-text-muted leading-snug truncate">
|
||||
{description}
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div className="p-4 space-y-4">
|
||||
{children}
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
type FieldProps = {
|
||||
label: string
|
||||
hint?: string
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
function Field({ label, hint, children }: FieldProps) {
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div className="space-y-0.5">
|
||||
<Label className="text-xs text-cyber-text-secondary font-mono">
|
||||
{label}
|
||||
</Label>
|
||||
{hint ? (
|
||||
<p className="text-[10px] text-cyber-text-muted leading-snug">
|
||||
{hint}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
type KeywordInputProps = {
|
||||
value: string
|
||||
onChange: (value: string) => void
|
||||
placeholder?: string
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
function KeywordInput({ value, onChange, placeholder, disabled }: KeywordInputProps) {
|
||||
const [inputValue, setInputValue] = useState('')
|
||||
|
||||
// 将逗号分隔的字符串转换为数组
|
||||
const keywords = value ? value.split(',').map((k) => k.trim()).filter(Boolean) : []
|
||||
|
||||
const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault()
|
||||
const trimmed = inputValue.trim()
|
||||
if (trimmed && !keywords.includes(trimmed)) {
|
||||
const newKeywords = [...keywords, trimmed]
|
||||
onChange(newKeywords.join(','))
|
||||
setInputValue('')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const removeKeyword = (keywordToRemove: string) => {
|
||||
const newKeywords = keywords.filter((k) => k !== keywordToRemove)
|
||||
onChange(newKeywords.join(','))
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<Input
|
||||
value={inputValue}
|
||||
onChange={(e) => setInputValue(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
className="h-9 text-xs"
|
||||
/>
|
||||
{keywords.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{keywords.map((keyword) => (
|
||||
<span
|
||||
key={keyword}
|
||||
className="inline-flex items-center gap-1 px-2 py-1 rounded-md bg-cyber-neon-cyan/10 border border-cyber-neon-cyan/30 text-cyber-neon-cyan text-xs font-mono"
|
||||
>
|
||||
{keyword}
|
||||
{!disabled && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => removeKeyword(keyword)}
|
||||
className="hover:text-cyber-neon-pink transition-colors"
|
||||
>
|
||||
<X className="w-3 h-3" />
|
||||
</button>
|
||||
)}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function CrawlerConfigPanel() {
|
||||
const { t } = useTranslation('config')
|
||||
const config = useCrawlerStore((state) => state.config)
|
||||
const updateConfig = useCrawlerStore((state) => state.updateConfig)
|
||||
const status = useCrawlerStore((state) => state.status)
|
||||
|
||||
const { data: platforms } = usePlatforms()
|
||||
const { data: options } = useConfigOptions()
|
||||
const { mutate: startCrawler, isPending: isStarting } = useStartCrawler()
|
||||
const { mutate: stopCrawler, isPending: isStopping } = useStopCrawler()
|
||||
|
||||
const isDisabled = status === 'running' || status === 'stopping'
|
||||
const isRunning = status === 'running'
|
||||
const isBusy = isStarting || isStopping || status === 'stopping'
|
||||
|
||||
const handleStart = () => {
|
||||
startCrawler(config)
|
||||
}
|
||||
|
||||
const handleStop = () => {
|
||||
stopCrawler()
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4 animate-slide-up">
|
||||
{/* Row 1: Three Config Columns */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
{/* Column 1: Target & Mode Section */}
|
||||
<Section
|
||||
title={t('section.targetMatrix.title')}
|
||||
description={t('section.targetMatrix.description')}
|
||||
icon={Globe}
|
||||
>
|
||||
<Field label={t('field.platform')}>
|
||||
<Select
|
||||
value={config.platform}
|
||||
onValueChange={(value) => updateConfig({ platform: value })}
|
||||
disabled={isDisabled}
|
||||
>
|
||||
<SelectTrigger className="h-9 text-xs">
|
||||
<SelectValue placeholder={t('field.platformPlaceholder')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{platforms?.map((platform) => (
|
||||
<SelectItem key={platform.value} value={platform.value}>
|
||||
{platform.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<Field label={t('field.crawlType')}>
|
||||
<Select
|
||||
value={config.crawler_type}
|
||||
onValueChange={(value) => updateConfig({ crawler_type: value })}
|
||||
disabled={isDisabled}
|
||||
>
|
||||
<SelectTrigger className="h-9 text-xs">
|
||||
<SelectValue placeholder={t('field.crawlTypePlaceholder')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{options?.crawler_types.map((type) => (
|
||||
<SelectItem key={type.value} value={type.value}>
|
||||
{type.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
<Field label={t('field.startPage')}>
|
||||
<Input
|
||||
type="number"
|
||||
min={1}
|
||||
value={config.start_page}
|
||||
onChange={(e) => updateConfig({ start_page: parseInt(e.target.value) || 1 })}
|
||||
disabled={isDisabled}
|
||||
className="h-9 text-xs"
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
{/* 根据爬虫类型显示不同的输入框 */}
|
||||
{config.crawler_type === 'search' && (
|
||||
<Field label={t('field.keywords')} hint={t('field.keywordsHint')}>
|
||||
<KeywordInput
|
||||
placeholder={t('field.keywordsPlaceholder')}
|
||||
value={config.keywords}
|
||||
onChange={(keywords) => updateConfig({ keywords })}
|
||||
disabled={isDisabled}
|
||||
/>
|
||||
</Field>
|
||||
)}
|
||||
|
||||
{config.crawler_type === 'detail' && (
|
||||
<Field label={t('field.specifiedIds')} hint={t('field.specifiedIdsHint')}>
|
||||
<textarea
|
||||
value={config.specified_ids}
|
||||
onChange={(e) => updateConfig({ specified_ids: e.target.value })}
|
||||
disabled={isDisabled}
|
||||
placeholder={t(`field.specifiedIdsPlaceholder.${config.platform}`, t('field.specifiedIdsPlaceholder.default'))}
|
||||
className="min-h-[60px] w-full rounded-md border border-cyber-border-DEFAULT bg-cyber-bg-tertiary px-3 py-2 text-xs font-mono text-cyber-text-primary placeholder:text-cyber-text-muted focus-visible:outline-none focus-visible:border-cyber-neon-cyan/50 focus-visible:shadow-cyber-soft disabled:cursor-not-allowed disabled:opacity-50 transition-all resize-none"
|
||||
/>
|
||||
<ParsedIdList
|
||||
value={config.specified_ids}
|
||||
platform={config.platform}
|
||||
type="detail"
|
||||
disabled={isDisabled}
|
||||
/>
|
||||
{config.platform === 'xhs' && (
|
||||
<div className="mt-2 rounded-lg border border-cyber-neon-orange/30 bg-cyber-neon-orange/5 p-2 text-[10px] leading-snug text-cyber-neon-orange font-mono">
|
||||
{t('warning.xhsToken')}
|
||||
</div>
|
||||
)}
|
||||
</Field>
|
||||
)}
|
||||
|
||||
{config.crawler_type === 'creator' && (
|
||||
<Field label={t('field.creatorIds')} hint={t('field.creatorIdsHint')}>
|
||||
<textarea
|
||||
value={config.creator_ids}
|
||||
onChange={(e) => updateConfig({ creator_ids: e.target.value })}
|
||||
disabled={isDisabled}
|
||||
placeholder={t(`field.creatorIdsPlaceholder.${config.platform}`, t('field.creatorIdsPlaceholder.default'))}
|
||||
className="min-h-[60px] w-full rounded-md border border-cyber-border-DEFAULT bg-cyber-bg-tertiary px-3 py-2 text-xs font-mono text-cyber-text-primary placeholder:text-cyber-text-muted focus-visible:outline-none focus-visible:border-cyber-neon-cyan/50 focus-visible:shadow-cyber-soft disabled:cursor-not-allowed disabled:opacity-50 transition-all resize-none"
|
||||
/>
|
||||
<ParsedIdList
|
||||
value={config.creator_ids}
|
||||
platform={config.platform}
|
||||
type="creator"
|
||||
disabled={isDisabled}
|
||||
/>
|
||||
{config.platform === 'xhs' && (
|
||||
<div className="mt-2 rounded-lg border border-cyber-neon-orange/30 bg-cyber-neon-orange/5 p-2 text-[10px] leading-snug text-cyber-neon-orange font-mono">
|
||||
{t('warning.xhsToken')}
|
||||
</div>
|
||||
)}
|
||||
</Field>
|
||||
)}
|
||||
</Section>
|
||||
|
||||
{/* Column 2: Authentication Section */}
|
||||
<Section
|
||||
title={t('section.authMatrix.title')}
|
||||
description={t('section.authMatrix.description')}
|
||||
icon={KeyRound}
|
||||
>
|
||||
<Field label={t('field.loginMethod')}>
|
||||
<Select
|
||||
value={config.login_type}
|
||||
onValueChange={(value) => updateConfig({ login_type: value })}
|
||||
disabled={isDisabled}
|
||||
>
|
||||
<SelectTrigger className="h-9 text-xs">
|
||||
<SelectValue placeholder={t('field.loginMethodPlaceholder')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{options?.login_types.map((type) => (
|
||||
<SelectItem key={type.value} value={type.value}>
|
||||
{type.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
{config.login_type === 'cookie' ? (
|
||||
<Field label={t('field.cookies')} hint={t('field.cookiesHint')}>
|
||||
<textarea
|
||||
value={config.cookies}
|
||||
onChange={(e) => updateConfig({ cookies: e.target.value })}
|
||||
disabled={isDisabled}
|
||||
placeholder={t('field.cookiesPlaceholder')}
|
||||
className="min-h-[80px] w-full rounded-md border border-cyber-border-DEFAULT bg-cyber-bg-tertiary px-3 py-2 text-xs font-mono text-cyber-text-primary placeholder:text-cyber-text-muted focus-visible:outline-none focus-visible:border-cyber-neon-cyan/50 focus-visible:shadow-cyber-soft disabled:cursor-not-allowed disabled:opacity-50 transition-all resize-none"
|
||||
/>
|
||||
</Field>
|
||||
) : null}
|
||||
|
||||
{config.login_type === 'cookie' && (config.platform === 'xhs' || config.platform === 'dy') ? (
|
||||
<div className="rounded-lg border border-cyber-neon-orange/30 bg-cyber-neon-orange/5 p-3 text-[11px] leading-snug text-cyber-neon-orange font-mono">
|
||||
{t('warning.cookieSlider')}
|
||||
</div>
|
||||
) : null}
|
||||
</Section>
|
||||
|
||||
{/* Column 3: Output & Runtime Section */}
|
||||
<Section
|
||||
title={t('section.outputConfig.title')}
|
||||
description={t('section.outputConfig.description')}
|
||||
icon={Database}
|
||||
>
|
||||
<Field label={t('field.saveFormat')}>
|
||||
<Select
|
||||
value={config.save_option}
|
||||
onValueChange={(value) => updateConfig({ save_option: value })}
|
||||
disabled={isDisabled}
|
||||
>
|
||||
<SelectTrigger className="h-9 text-xs">
|
||||
<SelectValue placeholder={t('field.saveFormatPlaceholder')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{options?.save_options.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center gap-3 rounded-lg border border-cyber-border-subtle bg-cyber-bg-tertiary/30 p-2.5 hover:border-cyber-border-DEFAULT transition-colors">
|
||||
<Checkbox
|
||||
checked={config.enable_comments}
|
||||
onCheckedChange={(checked) => {
|
||||
const isChecked = checked === true
|
||||
updateConfig({
|
||||
enable_comments: isChecked,
|
||||
enable_sub_comments: isChecked ? config.enable_sub_comments : false,
|
||||
})
|
||||
}}
|
||||
disabled={isDisabled}
|
||||
/>
|
||||
<div className="flex items-center gap-2">
|
||||
<MessageSquare className="h-3.5 w-3.5 text-cyber-text-secondary" />
|
||||
<p className="text-xs font-mono text-cyber-text-primary">{t('field.commentExtraction')}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 rounded-lg border border-cyber-border-subtle bg-cyber-bg-tertiary/30 p-2.5 hover:border-cyber-border-DEFAULT transition-colors">
|
||||
<Checkbox
|
||||
checked={config.enable_sub_comments}
|
||||
onCheckedChange={(checked) => updateConfig({ enable_sub_comments: checked === true })}
|
||||
disabled={isDisabled || !config.enable_comments}
|
||||
/>
|
||||
<p className="text-xs font-mono text-cyber-text-primary">{t('field.subComments')}</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 rounded-lg border border-cyber-border-subtle bg-cyber-bg-tertiary/30 p-2.5 hover:border-cyber-border-DEFAULT transition-colors">
|
||||
<Checkbox
|
||||
checked={config.headless}
|
||||
onCheckedChange={(checked) => updateConfig({ headless: checked === true })}
|
||||
disabled={isDisabled}
|
||||
/>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-xs font-mono text-cyber-text-primary">{t('field.headlessMode')}</p>
|
||||
<p className="text-[10px] text-cyber-text-muted leading-snug">
|
||||
{t('field.headlessModeHint')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Section>
|
||||
</div>
|
||||
|
||||
{/* Row 2: Start/Stop Button - Full Width */}
|
||||
<div className="w-full">
|
||||
{isRunning ? (
|
||||
<Button
|
||||
onClick={handleStop}
|
||||
disabled={isBusy}
|
||||
className="w-full h-12 bg-cyber-neon-pink text-white font-mono font-bold text-sm tracking-wider hover:bg-cyber-neon-pink/90 hover:shadow-glow-pink-sm transition-all"
|
||||
>
|
||||
<Square className="w-4 h-4" />
|
||||
{isStopping ? t('button.stopping') : t('button.terminate')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
onClick={handleStart}
|
||||
disabled={isBusy}
|
||||
className="w-full h-12 bg-cyber-neon-cyan text-cyber-bg-primary font-mono font-bold text-sm tracking-wider hover:bg-cyber-neon-cyan/90 hover:shadow-glow-cyan-sm transition-all"
|
||||
>
|
||||
<Play className="w-4 h-4" />
|
||||
{isStarting ? t('button.initiating') : t('button.initiateScan')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
96
webui/src/components/config/ParsedIdList.tsx
Normal file
@@ -0,0 +1,96 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Check, AlertTriangle, X } from 'lucide-react'
|
||||
import { parseMultipleUrls, type ParsedId } from '@/lib/urlParser'
|
||||
|
||||
interface ParsedIdListProps {
|
||||
value: string
|
||||
platform: string
|
||||
type: 'detail' | 'creator'
|
||||
onRemove?: (index: number) => void
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
export function ParsedIdList({ value, platform, type, onRemove, disabled }: ParsedIdListProps) {
|
||||
const parsed = useMemo(() => {
|
||||
return parseMultipleUrls(value, platform)
|
||||
}, [value, platform])
|
||||
|
||||
if (parsed.length === 0) return null
|
||||
|
||||
const handleRemove = (index: number) => {
|
||||
if (disabled || !onRemove) return
|
||||
|
||||
const items = value
|
||||
.split(/[,\n]+/)
|
||||
.map(s => s.trim())
|
||||
.filter(Boolean)
|
||||
|
||||
items.splice(index, 1)
|
||||
onRemove(index)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-1.5 mt-2">
|
||||
<div className="text-[10px] text-cyber-text-muted font-mono">
|
||||
已识别 {parsed.length} 个{type === 'detail' ? '帖子/视频' : '创作者'}:
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{parsed.map((item, index) => (
|
||||
<ParsedIdTag
|
||||
key={`${item.id}-${index}`}
|
||||
item={item}
|
||||
expectedType={type}
|
||||
onRemove={!disabled ? () => handleRemove(index) : undefined}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
interface ParsedIdTagProps {
|
||||
item: ParsedId
|
||||
expectedType: 'detail' | 'creator'
|
||||
onRemove?: () => void
|
||||
}
|
||||
|
||||
function ParsedIdTag({ item, expectedType, onRemove }: ParsedIdTagProps) {
|
||||
// 检查类型是否匹配
|
||||
const typeMatch = item.type === 'unknown' ||
|
||||
(expectedType === 'detail' && item.type === 'video') ||
|
||||
(expectedType === 'creator' && item.type === 'creator')
|
||||
|
||||
// 警告状态:小红书需要xsec_token
|
||||
const needsWarning = !item.isValid || !typeMatch
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`
|
||||
inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-mono
|
||||
${needsWarning
|
||||
? 'bg-cyber-neon-orange/10 border border-cyber-neon-orange/30 text-cyber-neon-orange'
|
||||
: 'bg-cyber-neon-cyan/10 border border-cyber-neon-cyan/30 text-cyber-neon-cyan'
|
||||
}
|
||||
`}
|
||||
title={item.original}
|
||||
>
|
||||
{needsWarning ? (
|
||||
<AlertTriangle className="w-3 h-3 flex-shrink-0" />
|
||||
) : (
|
||||
<Check className="w-3 h-3 flex-shrink-0" />
|
||||
)}
|
||||
<span className="max-w-[120px] truncate">
|
||||
{item.id.length > 20 ? item.id.slice(0, 8) + '...' + item.id.slice(-8) : item.id}
|
||||
</span>
|
||||
{onRemove && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onRemove}
|
||||
className="hover:text-cyber-neon-pink transition-colors ml-0.5"
|
||||
>
|
||||
<X className="w-3 h-3" />
|
||||
</button>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
151
webui/src/components/console/Terminal.tsx
Normal file
@@ -0,0 +1,151 @@
|
||||
import { useState, useEffect, useRef } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { ChevronDown, ChevronUp, Trash2, RefreshCw } from 'lucide-react'
|
||||
import { TerminalLine } from './TerminalLine'
|
||||
import { useCrawlerStore } from '@/store/crawlerStore'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { DataExplorerDialog } from '@/components/data/DataExplorerDialog'
|
||||
|
||||
export function Terminal() {
|
||||
const { t } = useTranslation('terminal')
|
||||
const [isCollapsed, setIsCollapsed] = useState(false)
|
||||
const logs = useCrawlerStore((state) => state.logs)
|
||||
const clearLogs = useCrawlerStore((state) => state.clearLogs)
|
||||
const restoreLogs = useCrawlerStore((state) => state.restoreLogs)
|
||||
const clearedAfterLogId = useCrawlerStore((state) => state.clearedAfterLogId)
|
||||
const status = useCrawlerStore((state) => state.status)
|
||||
const scrollRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
// Auto scroll to bottom
|
||||
useEffect(() => {
|
||||
if (scrollRef.current && !isCollapsed) {
|
||||
scrollRef.current.scrollTop = scrollRef.current.scrollHeight
|
||||
}
|
||||
}, [logs, isCollapsed])
|
||||
|
||||
return (
|
||||
<div className={`flex flex-col rounded-lg overflow-hidden transition-all duration-300 border border-cyber-border-subtle bg-[#0d1117] ${isCollapsed ? 'h-12' : 'h-full'}`}>
|
||||
{/* Terminal Header */}
|
||||
<div className="flex items-center justify-between px-4 py-2.5 bg-[#161b22] border-b border-[#30363d] flex-shrink-0">
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Window buttons */}
|
||||
<div className="flex gap-1.5">
|
||||
<span className="w-2.5 h-2.5 rounded-full bg-cyber-neon-pink/80" />
|
||||
<span className="w-2.5 h-2.5 rounded-full bg-cyber-neon-orange/80" />
|
||||
<span className="w-2.5 h-2.5 rounded-full bg-cyber-neon-green/80" />
|
||||
</div>
|
||||
<span className="text-xs text-[#8b949e] font-mono tracking-wider">
|
||||
{t('header.title')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Log count & status */}
|
||||
<div className="flex items-center gap-3 text-xs font-mono">
|
||||
<span className="text-[#8b949e]">{t('header.entries', { count: logs.length })}</span>
|
||||
{status === 'running' && (
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="w-1.5 h-1.5 bg-cyber-neon-green rounded-full shadow-glow-green-sm animate-pulse-fast" />
|
||||
<span className="text-cyber-neon-green">{t('header.active')}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Data Explorer */}
|
||||
<DataExplorerDialog />
|
||||
|
||||
{/* Restore logs - 只在有清除标记时显示 */}
|
||||
{clearedAfterLogId !== null && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={restoreLogs}
|
||||
className="h-7 px-2 text-[#8b949e] hover:text-[#00ffff] hover:bg-[#00ffff]/10"
|
||||
title={t('header.restore')}
|
||||
>
|
||||
<RefreshCw className="w-4 h-4" />
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* Clear logs */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={clearLogs}
|
||||
disabled={logs.length === 0}
|
||||
className="h-7 px-2 text-[#8b949e] hover:text-[#ff0080] hover:bg-[#ff0080]/10 disabled:opacity-30"
|
||||
title={t('header.clear')}
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
|
||||
{/* Collapse toggle */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setIsCollapsed(!isCollapsed)}
|
||||
className="h-7 px-2 text-[#8b949e] hover:text-[#00ffff] hover:bg-[#00ffff]/10"
|
||||
>
|
||||
{isCollapsed ? (
|
||||
<ChevronDown className="w-4 h-4" />
|
||||
) : (
|
||||
<ChevronUp className="w-4 h-4" />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Terminal Content - only show when not collapsed */}
|
||||
{!isCollapsed && (
|
||||
<>
|
||||
<div
|
||||
ref={scrollRef}
|
||||
className="flex-1 overflow-auto p-4 font-mono text-sm terminal-scroll bg-[#0d1117] min-h-0"
|
||||
>
|
||||
{/* ASCII Art Banner when empty */}
|
||||
{logs.length === 0 ? (
|
||||
<div className="space-y-4">
|
||||
<pre className="text-cyber-neon-cyan/70 text-xs leading-tight">
|
||||
{` ╔══════════════════════════════════════════════════════╗
|
||||
║ __ __ _ _ ____ ║
|
||||
║ | \\/ | ___ __| (_) __ _/ ___|_ __ __ ___ __ ║
|
||||
║ | |\\/| |/ _ \\/ _\` | |/ _\` | | | '__/ _\` \\ \\ /\\ / / ║
|
||||
║ | | | | __/ (_| | | (_| | |___| | | (_| |\\ V V / ║
|
||||
║ |_| |_|\\___|\\__,_|_|\\__,_|\\____|_| \\__,_| \\_/\\_/ ║
|
||||
║ ║
|
||||
║ [ NEURAL EXTRACTION UNIT v1.0 ] ║
|
||||
╚══════════════════════════════════════════════════════╝`}
|
||||
</pre>
|
||||
<div className="text-[#c9d1d9] text-xs space-y-1">
|
||||
<p className="text-cyber-neon-green/70">{t('banner.systemInit')}</p>
|
||||
<p className="text-[#8b949e]">{t('banner.configHint')}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-0.5">
|
||||
{logs.map((log) => (
|
||||
<TerminalLine key={log.id} log={log} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Active Cursor */}
|
||||
{status === 'running' && (
|
||||
<div className="flex items-center gap-1 mt-3">
|
||||
<span className="text-cyber-neon-green/80">root@crawler:~$</span>
|
||||
<span className="w-2 h-4 bg-cyber-neon-green/80 cursor-blink" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Terminal Footer */}
|
||||
<div className="px-4 py-2 border-t border-[#30363d] bg-[#161b22] flex items-center justify-end flex-shrink-0">
|
||||
<div className="text-xs font-mono text-[#8b949e]">
|
||||
{status.toUpperCase()}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
70
webui/src/components/console/TerminalLine.tsx
Normal file
@@ -0,0 +1,70 @@
|
||||
import { cn } from '@/lib/utils'
|
||||
import type { LogEntry } from '@/types/crawler'
|
||||
|
||||
interface TerminalLineProps {
|
||||
log: LogEntry
|
||||
}
|
||||
|
||||
const levelConfig: Record<string, { text: string; bg: string; glow: string }> = {
|
||||
info: {
|
||||
text: 'text-cyber-neon-cyan',
|
||||
bg: 'bg-cyber-neon-cyan/10',
|
||||
glow: 'shadow-[0_0_3px_rgba(0,255,255,0.3)]'
|
||||
},
|
||||
success: {
|
||||
text: 'text-cyber-neon-green',
|
||||
bg: 'bg-cyber-neon-green/10',
|
||||
glow: 'shadow-[0_0_3px_rgba(0,255,65,0.3)]'
|
||||
},
|
||||
warning: {
|
||||
text: 'text-cyber-neon-orange',
|
||||
bg: 'bg-cyber-neon-orange/10',
|
||||
glow: 'shadow-[0_0_3px_rgba(255,152,0,0.3)]'
|
||||
},
|
||||
error: {
|
||||
text: 'text-cyber-neon-pink',
|
||||
bg: 'bg-cyber-neon-pink/10',
|
||||
glow: 'shadow-[0_0_3px_rgba(255,0,128,0.3)]'
|
||||
},
|
||||
debug: {
|
||||
text: 'text-[#8b949e]',
|
||||
bg: 'bg-[#21262d]',
|
||||
glow: ''
|
||||
},
|
||||
}
|
||||
|
||||
const levelIcons: Record<string, string> = {
|
||||
info: 'DATA',
|
||||
success: 'OK',
|
||||
warning: 'WARN',
|
||||
error: 'ERR',
|
||||
debug: 'DBG',
|
||||
}
|
||||
|
||||
export function TerminalLine({ log }: TerminalLineProps) {
|
||||
const config = levelConfig[log.level] || levelConfig.info
|
||||
|
||||
return (
|
||||
<div className="flex gap-2 text-xs leading-relaxed font-mono group hover:bg-[#21262d]/50 px-1 -mx-1 rounded transition-colors">
|
||||
{/* Timestamp */}
|
||||
<span className="text-[#8b949e] flex-shrink-0 opacity-60 group-hover:opacity-100 transition-opacity">
|
||||
[{log.timestamp}]
|
||||
</span>
|
||||
|
||||
{/* Level badge */}
|
||||
<span className={cn(
|
||||
'flex-shrink-0 w-14 px-1 rounded text-center',
|
||||
config.bg,
|
||||
config.text,
|
||||
config.glow
|
||||
)}>
|
||||
[{levelIcons[log.level]}]
|
||||
</span>
|
||||
|
||||
{/* Message */}
|
||||
<span className={cn('break-all', config.text)}>
|
||||
{log.message}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
157
webui/src/components/data/DataExplorer.tsx
Normal file
@@ -0,0 +1,157 @@
|
||||
import { useState, useMemo } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { FolderOpen, RefreshCw } from 'lucide-react'
|
||||
import { dataApi } from '@/lib/api'
|
||||
import { FileCard } from './FileCard'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
|
||||
// 从文件名提取类别
|
||||
function extractCategory(filename: string): string {
|
||||
// 文件名格式: search_comments_xxx, search_creators_xxx, search_videos_xxx 等
|
||||
const match = filename.match(/^(search_\w+?)_/)
|
||||
if (match) {
|
||||
return match[1]
|
||||
}
|
||||
// 其他格式尝试提取前缀
|
||||
const parts = filename.split('_')
|
||||
if (parts.length >= 2) {
|
||||
return `${parts[0]}_${parts[1]}`
|
||||
}
|
||||
return 'other'
|
||||
}
|
||||
|
||||
// 类别显示名称
|
||||
function getCategoryLabel(category: string): string {
|
||||
const labels: Record<string, string> = {
|
||||
'search_comments': 'Comments',
|
||||
'search_creators': 'Creators',
|
||||
'search_videos': 'Videos',
|
||||
'search_contents': 'Contents',
|
||||
'search_notes': 'Notes',
|
||||
'other': 'Other',
|
||||
}
|
||||
return labels[category] || category.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase())
|
||||
}
|
||||
|
||||
export function DataExplorer() {
|
||||
const { t } = useTranslation('data')
|
||||
const [activeTab, setActiveTab] = useState<string>('all')
|
||||
|
||||
const { data, isLoading, refetch, isRefetching } = useQuery({
|
||||
queryKey: ['dataFiles'],
|
||||
queryFn: async () => {
|
||||
const { data } = await dataApi.getFiles()
|
||||
return data.files
|
||||
},
|
||||
})
|
||||
|
||||
const files = data || []
|
||||
|
||||
// 按类别分组文件
|
||||
const { categories, groupedFiles } = useMemo(() => {
|
||||
const grouped: Record<string, typeof files> = {}
|
||||
|
||||
files.forEach(file => {
|
||||
const category = extractCategory(file.name)
|
||||
if (!grouped[category]) {
|
||||
grouped[category] = []
|
||||
}
|
||||
grouped[category].push(file)
|
||||
})
|
||||
|
||||
// 按文件数量排序类别
|
||||
const sortedCategories = Object.keys(grouped).sort((a, b) =>
|
||||
grouped[b].length - grouped[a].length
|
||||
)
|
||||
|
||||
return { categories: sortedCategories, groupedFiles: grouped }
|
||||
}, [files])
|
||||
|
||||
// 当前显示的文件
|
||||
const displayFiles = activeTab === 'all' ? files : (groupedFiles[activeTab] || [])
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<h2 className="text-lg font-mono font-bold text-cyber-neon-cyan glow-text-cyan tracking-wider">
|
||||
{t('explorer.title')}
|
||||
</h2>
|
||||
<Badge variant="default" className="font-mono">
|
||||
{t('explorer.records', { count: files.length })}
|
||||
</Badge>
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => refetch()}
|
||||
disabled={isRefetching}
|
||||
className="font-mono"
|
||||
>
|
||||
<RefreshCw className={`w-4 h-4 ${isRefetching ? 'animate-spin' : ''}`} />
|
||||
{t('explorer.rescan')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Category Tabs */}
|
||||
{files.length > 0 && categories.length > 1 && (
|
||||
<div className="flex items-center gap-2 mb-4 flex-wrap">
|
||||
<button
|
||||
onClick={() => setActiveTab('all')}
|
||||
className={`px-3 py-1.5 rounded-md text-xs font-mono transition-all ${
|
||||
activeTab === 'all'
|
||||
? 'bg-cyber-neon-cyan text-black font-bold'
|
||||
: 'bg-cyber-bg-tertiary text-cyber-text-secondary hover:text-cyber-text-primary border border-cyber-border-subtle hover:border-cyber-neon-cyan/50'
|
||||
}`}
|
||||
>
|
||||
{t('explorer.allCategories')} ({files.length})
|
||||
</button>
|
||||
{categories.map(category => (
|
||||
<button
|
||||
key={category}
|
||||
onClick={() => setActiveTab(category)}
|
||||
className={`px-3 py-1.5 rounded-md text-xs font-mono transition-all ${
|
||||
activeTab === category
|
||||
? 'bg-cyber-neon-cyan text-black font-bold'
|
||||
: 'bg-cyber-bg-tertiary text-cyber-text-secondary hover:text-cyber-text-primary border border-cyber-border-subtle hover:border-cyber-neon-cyan/50'
|
||||
}`}
|
||||
>
|
||||
{getCategoryLabel(category)} ({groupedFiles[category].length})
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Content */}
|
||||
{isLoading ? (
|
||||
<div className="flex-1 flex items-center justify-center">
|
||||
<div className="text-cyber-text-muted font-mono animate-pulse">
|
||||
{t('explorer.loading')}
|
||||
</div>
|
||||
</div>
|
||||
) : files.length === 0 ? (
|
||||
<div className="flex-1 flex flex-col items-center justify-center text-center">
|
||||
<div className="relative">
|
||||
<FolderOpen className="w-16 h-16 text-cyber-neon-cyan/30 mb-4" />
|
||||
<div className="absolute inset-0 blur-xl bg-cyber-neon-cyan/10" />
|
||||
</div>
|
||||
<h3 className="text-lg font-mono font-medium text-cyber-neon-cyan mb-2">
|
||||
{t('explorer.noData')}
|
||||
</h3>
|
||||
<p className="text-sm text-cyber-text-muted max-w-md font-mono">
|
||||
{t('explorer.noDataHint')}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
|
||||
{displayFiles.map((file) => (
|
||||
<FileCard key={file.path} file={file} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
38
webui/src/components/data/DataExplorerDialog.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Database } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '@/components/ui/dialog'
|
||||
import { DataExplorer } from './DataExplorer'
|
||||
|
||||
export function DataExplorerDialog() {
|
||||
const { t } = useTranslation('data')
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="font-mono text-xs text-[#c9d1d9] border-[#30363d] bg-transparent hover:bg-[#21262d] hover:text-[#00ffff] hover:border-[#00ffff]/50"
|
||||
>
|
||||
<Database className="w-3.5 h-3.5" />
|
||||
{t('dialog.button')}
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-5xl max-h-[85vh] overflow-hidden">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{t('dialog.title')}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="overflow-auto max-h-[calc(85vh-100px)] pr-2">
|
||||
<DataExplorer />
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
132
webui/src/components/data/FileCard.tsx
Normal file
@@ -0,0 +1,132 @@
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { FileJson, FileSpreadsheet, FileText, Download, Eye } from 'lucide-react'
|
||||
import { Card, CardContent } from '@/components/ui/card'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { dataApi } from '@/lib/api'
|
||||
import { formatFileSize, formatDateTime } from '@/lib/utils'
|
||||
import { DataPreviewDialog } from './preview/DataPreviewDialog'
|
||||
import type { DataFile } from '@/types/crawler'
|
||||
|
||||
interface FileCardProps {
|
||||
file: DataFile
|
||||
}
|
||||
|
||||
const fileIcons: Record<string, typeof FileJson> = {
|
||||
json: FileJson,
|
||||
csv: FileSpreadsheet,
|
||||
xlsx: FileSpreadsheet,
|
||||
xls: FileSpreadsheet,
|
||||
}
|
||||
|
||||
const fileStyles: Record<string, { icon: string; border: string; badge: string }> = {
|
||||
json: {
|
||||
icon: 'text-cyber-neon-yellow',
|
||||
border: 'hover:border-cyber-neon-yellow/50',
|
||||
badge: 'border-cyber-neon-yellow/30 bg-cyber-neon-yellow/10 text-cyber-neon-yellow'
|
||||
},
|
||||
csv: {
|
||||
icon: 'text-cyber-neon-green',
|
||||
border: 'hover:border-cyber-neon-green/50',
|
||||
badge: 'border-cyber-neon-green/30 bg-cyber-neon-green/10 text-cyber-neon-green'
|
||||
},
|
||||
xlsx: {
|
||||
icon: 'text-cyber-neon-cyan',
|
||||
border: 'hover:border-cyber-neon-cyan/50',
|
||||
badge: 'border-cyber-neon-cyan/30 bg-cyber-neon-cyan/10 text-cyber-neon-cyan'
|
||||
},
|
||||
xls: {
|
||||
icon: 'text-cyber-neon-cyan',
|
||||
border: 'hover:border-cyber-neon-cyan/50',
|
||||
badge: 'border-cyber-neon-cyan/30 bg-cyber-neon-cyan/10 text-cyber-neon-cyan'
|
||||
},
|
||||
}
|
||||
|
||||
export function FileCard({ file }: FileCardProps) {
|
||||
const { t } = useTranslation('data')
|
||||
const [previewOpen, setPreviewOpen] = useState(false)
|
||||
|
||||
const Icon = fileIcons[file.type] || FileText
|
||||
const styles = fileStyles[file.type] || {
|
||||
icon: 'text-cyber-text-muted',
|
||||
border: 'hover:border-cyber-neon-cyan/50',
|
||||
badge: 'border-cyber-border-DEFAULT bg-cyber-bg-tertiary text-cyber-text-secondary'
|
||||
}
|
||||
|
||||
// 检查是否支持预览
|
||||
const isPreviewable = ['json', 'csv', 'xlsx', 'xls'].includes(file.type.toLowerCase())
|
||||
|
||||
const handleDownload = () => {
|
||||
const url = dataApi.getDownloadUrl(file.path)
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card className={`relative overflow-hidden card-scan group transition-all ${styles.border} hover:shadow-[0_0_15px_rgb(var(--cyber-neon-cyan)/0.15)]`}>
|
||||
{/* Scan effect overlay */}
|
||||
<div className="absolute inset-0 bg-gradient-to-r from-transparent via-cyber-neon-cyan/5 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-700 pointer-events-none" />
|
||||
|
||||
<CardContent className="p-4 relative">
|
||||
<div className="flex items-start gap-3">
|
||||
<div className={`p-2 rounded bg-cyber-bg-panel border border-cyber-border-DEFAULT ${styles.icon}`}>
|
||||
<Icon className="w-6 h-6" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<h3 className="font-mono font-medium text-sm text-cyber-text-primary truncate" title={file.name}>
|
||||
{file.name}
|
||||
</h3>
|
||||
<p className="text-xs text-cyber-text-muted mt-1 font-mono">
|
||||
{formatFileSize(file.size)}
|
||||
{file.record_count !== null && (
|
||||
<span className="text-cyber-neon-green"> | {t('file.entries', { count: file.record_count })}</span>
|
||||
)}
|
||||
</p>
|
||||
<p className="text-xs text-cyber-text-muted mt-1 font-mono">
|
||||
{formatDateTime(file.modified_at)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between mt-3 pt-3 border-t border-cyber-border-subtle">
|
||||
<Badge variant="outline" className={`text-[10px] font-mono ${styles.badge}`}>
|
||||
.{file.type.toUpperCase()}
|
||||
</Badge>
|
||||
<div className="flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
{isPreviewable && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 px-2 font-mono text-cyber-neon-cyan hover:text-cyber-neon-cyan hover:bg-cyber-neon-cyan/10"
|
||||
onClick={() => setPreviewOpen(true)}
|
||||
>
|
||||
<Eye className="w-3 h-3 mr-1" />
|
||||
{t('file.preview')}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 px-2 font-mono text-cyber-neon-cyan hover:text-cyber-neon-cyan hover:bg-cyber-neon-cyan/10"
|
||||
onClick={handleDownload}
|
||||
>
|
||||
<Download className="w-3 h-3 mr-1" />
|
||||
{t('file.extract')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* 预览对话框 */}
|
||||
{isPreviewable && (
|
||||
<DataPreviewDialog
|
||||
file={file}
|
||||
open={previewOpen}
|
||||
onOpenChange={setPreviewOpen}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
93
webui/src/components/data/preview/DataPreviewDialog.tsx
Normal file
@@ -0,0 +1,93 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Download } from 'lucide-react'
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { dataApi } from '@/lib/api'
|
||||
import { DataPreviewTable } from './DataPreviewTable'
|
||||
import type { DataFile } from '@/types/crawler'
|
||||
|
||||
interface DataPreviewDialogProps {
|
||||
file: DataFile
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
}
|
||||
|
||||
export function DataPreviewDialog({ file, open, onOpenChange }: DataPreviewDialogProps) {
|
||||
const { t } = useTranslation('data')
|
||||
|
||||
const { data, isLoading, error } = useQuery({
|
||||
queryKey: ['filePreview', file.path],
|
||||
queryFn: async () => {
|
||||
const { data } = await dataApi.getFileContent(file.path, 100)
|
||||
return data
|
||||
},
|
||||
enabled: open,
|
||||
})
|
||||
|
||||
const handleDownload = () => {
|
||||
const url = dataApi.getDownloadUrl(file.path)
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-6xl max-h-[85vh] flex flex-col">
|
||||
<DialogHeader className="flex-shrink-0">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<DialogTitle className="font-mono text-cyber-neon-cyan">
|
||||
{file.name}
|
||||
</DialogTitle>
|
||||
<Badge variant="outline" className="font-mono text-[10px]">
|
||||
.{file.type.toUpperCase()}
|
||||
</Badge>
|
||||
{data && (
|
||||
<Badge variant="default" className="font-mono text-[10px]">
|
||||
{t('preview.records', { count: data.total })}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleDownload}
|
||||
className="font-mono text-xs"
|
||||
>
|
||||
<Download className="w-3 h-3 mr-1" />
|
||||
{t('preview.download')}
|
||||
</Button>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
|
||||
{/* 内容区域 */}
|
||||
<div className="flex-1 overflow-hidden min-h-0 mt-4">
|
||||
{isLoading ? (
|
||||
<div className="flex items-center justify-center h-full">
|
||||
<div className="text-cyber-text-muted font-mono animate-pulse">
|
||||
{t('preview.loading')}
|
||||
</div>
|
||||
</div>
|
||||
) : error ? (
|
||||
<div className="flex items-center justify-center h-full">
|
||||
<div className="text-cyber-neon-pink font-mono">
|
||||
{t('preview.error')}
|
||||
</div>
|
||||
</div>
|
||||
) : data ? (
|
||||
<DataPreviewTable
|
||||
data={data.data}
|
||||
columns={data.columns}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
104
webui/src/components/data/preview/DataPreviewTable.tsx
Normal file
@@ -0,0 +1,104 @@
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Search } from 'lucide-react'
|
||||
import { ScrollArea } from '@/components/ui/scroll-area'
|
||||
import { Input } from '@/components/ui/input'
|
||||
|
||||
interface DataPreviewTableProps {
|
||||
data: Record<string, unknown>[]
|
||||
columns?: string[]
|
||||
}
|
||||
|
||||
export function DataPreviewTable({ data, columns: propColumns }: DataPreviewTableProps) {
|
||||
const { t } = useTranslation('data')
|
||||
const [searchTerm, setSearchTerm] = useState('')
|
||||
|
||||
// 自动获取列名(JSON 可能没有 columns)
|
||||
const columns = useMemo(() => {
|
||||
if (propColumns && propColumns.length > 0) return propColumns
|
||||
if (data.length === 0) return []
|
||||
return Object.keys(data[0])
|
||||
}, [data, propColumns])
|
||||
|
||||
// 过滤数据
|
||||
const filteredData = useMemo(() => {
|
||||
if (!searchTerm) return data
|
||||
const term = searchTerm.toLowerCase()
|
||||
return data.filter(row =>
|
||||
Object.values(row).some(value =>
|
||||
String(value ?? '').toLowerCase().includes(term)
|
||||
)
|
||||
)
|
||||
}, [data, searchTerm])
|
||||
|
||||
// 格式化单元格值
|
||||
const formatCellValue = (value: unknown): string => {
|
||||
if (value === null || value === undefined) return '-'
|
||||
if (typeof value === 'object') return JSON.stringify(value)
|
||||
return String(value)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col">
|
||||
{/* 搜索栏 */}
|
||||
<div className="flex-shrink-0 mb-3">
|
||||
<div className="relative">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-cyber-text-muted" />
|
||||
<Input
|
||||
placeholder={t('preview.searchPlaceholder')}
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
className="pl-9 h-9 text-xs font-mono"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 表格 */}
|
||||
<ScrollArea className="flex-1 border border-cyber-border-DEFAULT rounded-lg">
|
||||
<div className="min-w-full">
|
||||
<table className="w-full text-xs font-mono">
|
||||
<thead className="sticky top-0 bg-cyber-bg-tertiary border-b border-cyber-border-DEFAULT">
|
||||
<tr>
|
||||
<th className="px-3 py-2 text-left text-cyber-text-muted w-12">#</th>
|
||||
{columns.map((col) => (
|
||||
<th
|
||||
key={col}
|
||||
className="px-3 py-2 text-left text-cyber-neon-cyan whitespace-nowrap"
|
||||
>
|
||||
{col}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{filteredData.map((row, idx) => (
|
||||
<tr
|
||||
key={idx}
|
||||
className="border-b border-cyber-border-subtle hover:bg-cyber-bg-elevated/50 transition-colors"
|
||||
>
|
||||
<td className="px-3 py-2 text-cyber-text-muted">{idx + 1}</td>
|
||||
{columns.map((col) => (
|
||||
<td
|
||||
key={col}
|
||||
className="px-3 py-2 text-cyber-text-primary max-w-xs truncate"
|
||||
title={formatCellValue(row[col])}
|
||||
>
|
||||
{formatCellValue(row[col])}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
|
||||
{/* 过滤结果提示 */}
|
||||
{searchTerm && (
|
||||
<div className="flex-shrink-0 mt-2 text-xs text-cyber-text-muted font-mono">
|
||||
{t('preview.showing', { filtered: filteredData.length, total: data.length })}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
80
webui/src/components/layout/AuthorFooter.tsx
Normal file
@@ -0,0 +1,80 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Sparkles, Heart } from 'lucide-react'
|
||||
|
||||
export function AuthorFooter() {
|
||||
const { t } = useTranslation('license')
|
||||
|
||||
return (
|
||||
<footer className="h-24 flex-shrink-0 glass-panel border-t border-cyber-border-subtle">
|
||||
<div className="h-full px-6 flex items-center justify-center gap-6">
|
||||
{/* Author Avatar */}
|
||||
<div className="w-14 h-14 rounded-lg overflow-hidden border-2 border-cyber-neon-cyan/60 flex-shrink-0 shadow-glow-cyan-sm">
|
||||
<img
|
||||
src="/logos/my_logo.png"
|
||||
alt="程序员阿江-Relakkes"
|
||||
className="w-full h-full object-cover"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Author Info */}
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-lg font-bold text-cyber-text-primary">
|
||||
{t('author.name')}
|
||||
</span>
|
||||
<Sparkles className="w-5 h-5 text-cyber-neon-cyan animate-pulse" />
|
||||
</div>
|
||||
<span className="text-sm text-cyber-text-muted hidden sm:inline">
|
||||
{t('author.description')}
|
||||
</span>
|
||||
<div className="flex items-center gap-2 text-cyber-neon-cyan">
|
||||
<Heart className="w-4 h-4 fill-current animate-pulse" />
|
||||
<span className="text-sm font-medium">
|
||||
{t('author.slogan')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Social Links */}
|
||||
<div className="flex items-center gap-3">
|
||||
<a
|
||||
href="https://github.com/NanmiCoder"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="w-11 h-11 rounded-lg flex items-center justify-center border border-cyber-border-subtle hover:border-cyber-neon-cyan hover:shadow-glow-cyan-sm transition-all bg-cyber-bg-tertiary hover:scale-110"
|
||||
title="GitHub"
|
||||
>
|
||||
<img src="/logos/github.png" alt="GitHub" className="w-6 h-6 object-contain" />
|
||||
</a>
|
||||
<a
|
||||
href="https://space.bilibili.com/434377496"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="w-11 h-11 rounded-lg flex items-center justify-center border border-cyber-border-subtle hover:border-pink-400 hover:shadow-[0_0_10px_rgba(251,113,133,0.4)] transition-all bg-cyber-bg-tertiary hover:scale-110"
|
||||
title="哔哩哔哩"
|
||||
>
|
||||
<img src="/logos/bilibili_logo.png" alt="Bilibili" className="w-6 h-6 object-contain" />
|
||||
</a>
|
||||
<a
|
||||
href="https://www.xiaohongshu.com/user/profile/5f58bd990000000001003753"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="w-11 h-11 rounded-lg flex items-center justify-center border border-cyber-border-subtle hover:border-red-400 hover:shadow-[0_0_10px_rgba(248,113,113,0.4)] transition-all bg-cyber-bg-tertiary hover:scale-110"
|
||||
title="小红书"
|
||||
>
|
||||
<img src="/logos/xiaohongshu_logo.png" alt="小红书" className="w-6 h-6 object-contain" />
|
||||
</a>
|
||||
<a
|
||||
href="https://www.douyin.com/user/MS4wLjABAAAATJPY7LAlaa5X-c8uNdWkvz0jUGgpw4eeXIwu_8BhvqE"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="w-11 h-11 rounded-lg flex items-center justify-center border border-cyber-border-subtle hover:border-cyber-text-primary hover:shadow-[0_0_10px_rgba(255,255,255,0.3)] transition-all bg-cyber-bg-tertiary hover:scale-110"
|
||||
title="抖音"
|
||||
>
|
||||
<img src="/logos/douyin.png" alt="抖音" className="w-6 h-6 object-contain" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
)
|
||||
}
|
||||
36
webui/src/components/layout/LanguageSwitch.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Globe } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select'
|
||||
|
||||
const languages = [
|
||||
{ code: 'zh-CN', label: '中文' },
|
||||
{ code: 'en-US', label: 'EN' },
|
||||
]
|
||||
|
||||
export function LanguageSwitch() {
|
||||
const { i18n } = useTranslation()
|
||||
|
||||
const currentLang = languages.find(l => l.code === i18n.language) || languages[0]
|
||||
|
||||
return (
|
||||
<Select value={i18n.language} onValueChange={(lang) => i18n.changeLanguage(lang)}>
|
||||
<SelectTrigger className="w-20 h-7 text-xs font-mono border-cyber-border-subtle bg-cyber-bg-tertiary/50 hover:border-cyber-neon-cyan/50 transition-colors">
|
||||
<Globe className="w-3 h-3 mr-1 text-cyber-text-secondary" />
|
||||
<SelectValue>{currentLang.label}</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{languages.map((lang) => (
|
||||
<SelectItem key={lang.code} value={lang.code} className="text-xs font-mono">
|
||||
{lang.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)
|
||||
}
|
||||
13
webui/src/components/layout/MainContent.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Terminal } from '@/components/console/Terminal'
|
||||
import { useLogWebSocket } from '@/hooks/useWebSocket'
|
||||
|
||||
export function MainContent() {
|
||||
// Connect to WebSocket for logs
|
||||
useLogWebSocket()
|
||||
|
||||
return (
|
||||
<main className="flex-1 flex flex-col overflow-hidden min-h-0 relative z-10">
|
||||
<Terminal />
|
||||
</main>
|
||||
)
|
||||
}
|
||||
88
webui/src/components/layout/Sidebar.tsx
Normal file
@@ -0,0 +1,88 @@
|
||||
import { Bug, Wifi, AlertTriangle, Github } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { useCrawlerStore } from '@/store/crawlerStore'
|
||||
import { useCrawlerStatus } from '@/hooks/useCrawler'
|
||||
import { LanguageSwitch } from './LanguageSwitch'
|
||||
import { ThemeToggle } from './ThemeToggle'
|
||||
|
||||
interface SidebarProps {
|
||||
onShowDisclaimer?: () => void
|
||||
}
|
||||
|
||||
export function Sidebar({ onShowDisclaimer }: SidebarProps) {
|
||||
const { t } = useTranslation()
|
||||
const { t: tLicense } = useTranslation('license')
|
||||
const status = useCrawlerStore((state) => state.status)
|
||||
|
||||
// Poll status
|
||||
useCrawlerStatus()
|
||||
|
||||
const isRunning = status === 'running'
|
||||
|
||||
return (
|
||||
<header className="h-14 flex-shrink-0 glass-panel border-b border-cyber-border-subtle relative z-10">
|
||||
<div className="h-full px-4 flex items-center justify-between">
|
||||
{/* Left: Logo and GitHub Star */}
|
||||
<div className="flex items-center gap-3">
|
||||
<Bug className="w-5 h-5 text-cyber-neon-cyan" />
|
||||
<span className="font-mono font-bold text-cyber-text-primary tracking-wider text-sm">
|
||||
MediaCrawler
|
||||
</span>
|
||||
<a
|
||||
href="https://github.com/NanmiCoder/MediaCrawler"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-1.5 px-2 py-1 rounded-md border border-cyber-border-subtle hover:border-cyber-neon-cyan hover:shadow-glow-cyan-sm transition-all bg-cyber-bg-tertiary"
|
||||
>
|
||||
<Github className="w-4 h-4 text-cyber-text-secondary" />
|
||||
<span className="text-xs font-mono text-cyber-text-secondary">Star</span>
|
||||
</a>
|
||||
{isRunning && (
|
||||
<Badge variant="running" className="text-[10px]">
|
||||
{t('status.active')}
|
||||
</Badge>
|
||||
)}
|
||||
{isRunning && (
|
||||
<span className="w-2 h-2 bg-cyber-neon-green rounded-full shadow-glow-green-sm animate-pulse-fast" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Center: Warning Text */}
|
||||
<button
|
||||
onClick={onShowDisclaimer}
|
||||
className="flex items-center gap-3 px-4 py-1.5 rounded-lg border border-cyber-neon-orange/50 bg-cyber-neon-orange/10 hover:bg-cyber-neon-orange/20 transition-all cursor-pointer"
|
||||
>
|
||||
<AlertTriangle className="w-4 h-4 text-cyber-neon-orange flex-shrink-0" />
|
||||
<div className="flex items-center gap-4 text-xs font-mono">
|
||||
<span className="text-cyber-neon-orange">
|
||||
<span className="text-cyber-neon-pink font-bold">1.</span> {tLicense('content.line1')}
|
||||
</span>
|
||||
<span className="text-cyber-neon-orange">
|
||||
<span className="text-cyber-neon-pink font-bold">2.</span> {tLicense('content.line2')}
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
{/* Right: Actions and Status */}
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Theme Toggle */}
|
||||
<ThemeToggle />
|
||||
{/* Language Switch */}
|
||||
<LanguageSwitch />
|
||||
|
||||
{/* Status Info */}
|
||||
<div className="hidden lg:flex items-center gap-2 text-xs font-mono">
|
||||
<span className="text-cyber-text-muted">{t('sidebar.api')}:</span>
|
||||
<span className="text-cyber-neon-green">v1.0.0</span>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Wifi className="w-3 h-3 text-cyber-text-secondary" />
|
||||
<span className="text-cyber-text-secondary">{t('sidebar.local')}</span>
|
||||
<span className="status-dot status-dot-online" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
)
|
||||
}
|
||||
43
webui/src/components/layout/ThemeToggle.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import { Sun, Moon, Monitor } from 'lucide-react'
|
||||
import { useThemeStore } from '@/store/themeStore'
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select'
|
||||
|
||||
type Theme = 'light' | 'dark' | 'system'
|
||||
|
||||
const themes: { value: Theme; label: string; icon: typeof Sun }[] = [
|
||||
{ value: 'light', label: 'Light', icon: Sun },
|
||||
{ value: 'dark', label: 'Dark', icon: Moon },
|
||||
{ value: 'system', label: 'Auto', icon: Monitor },
|
||||
]
|
||||
|
||||
export function ThemeToggle() {
|
||||
const { theme, setTheme } = useThemeStore()
|
||||
|
||||
const currentTheme = themes.find(t => t.value === theme) || themes[0]
|
||||
const Icon = currentTheme.icon
|
||||
|
||||
return (
|
||||
<Select value={theme} onValueChange={(value: Theme) => setTheme(value)}>
|
||||
<SelectTrigger className="w-20 h-7 text-xs font-mono border-cyber-border-subtle bg-cyber-bg-tertiary/50 hover:border-cyber-neon-cyan/50 transition-colors">
|
||||
<Icon className="w-3 h-3 mr-1 text-cyber-text-secondary" />
|
||||
<SelectValue>{currentTheme.label}</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{themes.map(({ value, label, icon: ItemIcon }) => (
|
||||
<SelectItem key={value} value={value} className="text-xs font-mono">
|
||||
<div className="flex items-center gap-2">
|
||||
<ItemIcon className="w-3 h-3" />
|
||||
{label}
|
||||
</div>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)
|
||||
}
|
||||
144
webui/src/components/license/LicenseDisclaimer.tsx
Normal file
@@ -0,0 +1,144 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { ShieldAlert, ExternalLink } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
|
||||
const LICENSE_KEY = 'mediacrawler_license_accepted'
|
||||
|
||||
// 检查是否已经接受协议
|
||||
export function isLicenseAccepted(): boolean {
|
||||
return localStorage.getItem(LICENSE_KEY) === 'true'
|
||||
}
|
||||
|
||||
// 清除协议接受状态
|
||||
export function clearLicenseAccepted(): void {
|
||||
localStorage.removeItem(LICENSE_KEY)
|
||||
}
|
||||
|
||||
interface LicenseDisclaimerProps {
|
||||
onAccept: () => void
|
||||
}
|
||||
|
||||
export function LicenseDisclaimer({ onAccept }: LicenseDisclaimerProps) {
|
||||
const { t } = useTranslation('license')
|
||||
|
||||
const handleConfirm = () => {
|
||||
localStorage.setItem(LICENSE_KEY, 'true')
|
||||
onAccept()
|
||||
}
|
||||
|
||||
const handleDecline = () => {
|
||||
// 尝试关闭当前标签页(不会关闭整个浏览器,只关闭当前tab)
|
||||
try {
|
||||
// 方式1: 直接关闭当前标签页
|
||||
window.close()
|
||||
|
||||
// 方式2: 将当前标签页导航到空白页
|
||||
setTimeout(() => {
|
||||
window.location.href = 'about:blank'
|
||||
}, 100)
|
||||
} catch {
|
||||
// 忽略错误
|
||||
}
|
||||
|
||||
// 如果无法关闭(浏览器安全限制),显示拒绝访问页面
|
||||
setTimeout(() => {
|
||||
document.body.innerHTML = `
|
||||
<div style="
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
background: #0d1117;
|
||||
color: #f85149;
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
">
|
||||
<div style="font-size: 48px; margin-bottom: 20px;">⛔</div>
|
||||
<div style="font-size: 24px; font-weight: bold; margin-bottom: 10px;">访问已拒绝</div>
|
||||
<div style="font-size: 14px; color: #8b949e;">您未同意使用条款,请关闭此标签页</div>
|
||||
</div>
|
||||
`
|
||||
}, 200)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 bg-black/95 backdrop-blur-sm flex items-center justify-center z-[100] overflow-y-auto py-8">
|
||||
<div className="bg-cyber-bg-panel border-2 border-cyber-neon-pink rounded-lg shadow-cyber-card p-6 max-w-2xl w-full mx-4 relative">
|
||||
{/* Corner decorations - Pink/Red theme for seriousness */}
|
||||
<div className="absolute top-0 left-0 w-6 h-6 border-t-2 border-l-2 border-cyber-neon-pink" />
|
||||
<div className="absolute top-0 right-0 w-6 h-6 border-t-2 border-r-2 border-cyber-neon-pink" />
|
||||
<div className="absolute bottom-0 left-0 w-6 h-6 border-b-2 border-l-2 border-cyber-neon-pink" />
|
||||
<div className="absolute bottom-0 right-0 w-6 h-6 border-b-2 border-r-2 border-cyber-neon-pink" />
|
||||
|
||||
{/* Header with warning icon */}
|
||||
<div className="flex items-center justify-center gap-3 mb-4">
|
||||
<ShieldAlert className="w-8 h-8 text-cyber-neon-pink animate-pulse" />
|
||||
<h2 className="text-xl font-mono font-bold text-cyber-neon-pink">
|
||||
{t('title')}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
{/* Warning subtitle */}
|
||||
<div className="text-center mb-4">
|
||||
<span className="text-base font-mono text-cyber-neon-orange">
|
||||
{t('warning')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Content box */}
|
||||
<div className="bg-black/50 border border-cyber-neon-pink/30 rounded-lg p-4 mb-4">
|
||||
<ul className="space-y-2 text-sm font-mono">
|
||||
<li className="flex items-start gap-2">
|
||||
<span className="text-cyber-neon-pink font-bold">1.</span>
|
||||
<span className="text-cyber-text-primary">{t('content.line1')}</span>
|
||||
</li>
|
||||
<li className="flex items-start gap-2">
|
||||
<span className="text-cyber-neon-pink font-bold">2.</span>
|
||||
<span className="text-cyber-text-primary">{t('content.line2')}</span>
|
||||
</li>
|
||||
<li className="flex items-start gap-2">
|
||||
<span className="text-cyber-neon-pink font-bold">3.</span>
|
||||
<span className="text-cyber-text-primary">{t('content.line3')}</span>
|
||||
</li>
|
||||
<li className="flex items-start gap-2">
|
||||
<span className="text-cyber-neon-pink font-bold">4.</span>
|
||||
<span className="text-cyber-text-primary">{t('content.line4')}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* License Link */}
|
||||
<div className="flex justify-center mb-6">
|
||||
<a
|
||||
href="https://github.com/NanmiCoder/MediaCrawler/blob/main/LICENSE"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-1.5 text-cyber-neon-cyan hover:underline text-sm font-mono"
|
||||
>
|
||||
<ExternalLink className="w-4 h-4" />
|
||||
{t('license')}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{/* Action buttons */}
|
||||
<div className="flex gap-4">
|
||||
<Button
|
||||
onClick={handleDecline}
|
||||
variant="outline"
|
||||
className="flex-1 font-mono border-cyber-neon-pink/50 text-cyber-neon-pink hover:bg-cyber-neon-pink/10"
|
||||
>
|
||||
{t('decline')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleConfirm}
|
||||
className="flex-1 font-mono bg-cyber-neon-green text-black font-bold hover:bg-cyber-neon-green/90"
|
||||
>
|
||||
{t('confirm')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
55
webui/src/components/ui/accordion.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
import * as React from 'react'
|
||||
import * as AccordionPrimitive from '@radix-ui/react-accordion'
|
||||
import { ChevronDown } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const Accordion = AccordionPrimitive.Root
|
||||
|
||||
const AccordionItem = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AccordionPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn('border-b', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AccordionItem.displayName = 'AccordionItem'
|
||||
|
||||
const AccordionTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<AccordionPrimitive.Header className="flex">
|
||||
<AccordionPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
|
||||
</AccordionPrimitive.Trigger>
|
||||
</AccordionPrimitive.Header>
|
||||
))
|
||||
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName
|
||||
|
||||
const AccordionContent = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<AccordionPrimitive.Content
|
||||
ref={ref}
|
||||
className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
|
||||
{...props}
|
||||
>
|
||||
<div className={cn('pb-4 pt-0', className)}>{children}</div>
|
||||
</AccordionPrimitive.Content>
|
||||
))
|
||||
|
||||
AccordionContent.displayName = AccordionPrimitive.Content.displayName
|
||||
|
||||
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
|
||||
44
webui/src/components/ui/badge.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
import * as React from 'react'
|
||||
import { cva, type VariantProps } from 'class-variance-authority'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const badgeVariants = cva(
|
||||
'inline-flex items-center rounded-sm border px-2 py-0.5 text-xs font-mono transition-colors focus:outline-none',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
'border-cyber-neon-cyan/30 bg-cyber-neon-cyan/10 text-cyber-neon-cyan',
|
||||
secondary:
|
||||
'border-cyber-border-DEFAULT bg-cyber-bg-tertiary text-cyber-text-secondary',
|
||||
destructive:
|
||||
'border-cyber-neon-pink/30 bg-cyber-neon-pink/10 text-cyber-neon-pink',
|
||||
outline:
|
||||
'border-cyber-border-DEFAULT text-cyber-text-primary',
|
||||
success:
|
||||
'border-cyber-neon-green/30 bg-cyber-neon-green/10 text-cyber-neon-green shadow-glow-green-sm',
|
||||
warning:
|
||||
'border-cyber-neon-orange/30 bg-cyber-neon-orange/10 text-cyber-neon-orange',
|
||||
idle:
|
||||
'border-cyber-border-DEFAULT bg-cyber-bg-tertiary text-cyber-text-muted',
|
||||
running:
|
||||
'border-cyber-neon-green/50 bg-cyber-neon-green/20 text-cyber-neon-green shadow-glow-green-sm animate-pulse-fast',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
export interface BadgeProps
|
||||
extends React.HTMLAttributes<HTMLDivElement>,
|
||||
VariantProps<typeof badgeVariants> {}
|
||||
|
||||
function Badge({ className, variant, ...props }: BadgeProps) {
|
||||
return (
|
||||
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
||||
)
|
||||
}
|
||||
|
||||
export { Badge, badgeVariants }
|
||||
60
webui/src/components/ui/button.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
import * as React from 'react'
|
||||
import { Slot } from '@radix-ui/react-slot'
|
||||
import { cva, type VariantProps } from 'class-variance-authority'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const buttonVariants = cva(
|
||||
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-cyber-neon-cyan disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
'bg-cyber-neon-cyan/20 text-cyber-neon-cyan border border-cyber-neon-cyan/50 hover:bg-cyber-neon-cyan/30 hover:shadow-glow-cyan-sm active:scale-95',
|
||||
destructive:
|
||||
'bg-cyber-neon-pink/20 text-cyber-neon-pink border border-cyber-neon-pink/50 hover:bg-cyber-neon-pink/30 hover:shadow-glow-pink-sm active:scale-95',
|
||||
outline:
|
||||
'border border-cyber-border-DEFAULT bg-transparent hover:bg-cyber-bg-tertiary hover:border-cyber-neon-cyan/50 hover:text-cyber-neon-cyan',
|
||||
secondary:
|
||||
'bg-cyber-neon-green/20 text-cyber-neon-green border border-cyber-neon-green/50 hover:bg-cyber-neon-green/30 hover:shadow-glow-green-sm active:scale-95',
|
||||
ghost:
|
||||
'hover:bg-cyber-bg-tertiary hover:text-cyber-neon-cyan',
|
||||
link:
|
||||
'text-cyber-neon-cyan underline-offset-4 hover:underline',
|
||||
glow:
|
||||
'bg-cyber-neon-cyan/20 text-cyber-neon-cyan border border-cyber-neon-cyan/50 shadow-glow-cyan-sm hover:shadow-glow-cyan hover:bg-cyber-neon-cyan/30 active:scale-95',
|
||||
},
|
||||
size: {
|
||||
default: 'h-10 px-4 py-2',
|
||||
sm: 'h-9 rounded-md px-3',
|
||||
lg: 'h-12 rounded-md px-8 text-base',
|
||||
icon: 'h-10 w-10',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
size: 'default',
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
export interface ButtonProps
|
||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
VariantProps<typeof buttonVariants> {
|
||||
asChild?: boolean
|
||||
}
|
||||
|
||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
({ className, variant, size, asChild = false, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : 'button'
|
||||
return (
|
||||
<Comp
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
)
|
||||
Button.displayName = 'Button'
|
||||
|
||||
export { Button, buttonVariants }
|
||||
78
webui/src/components/ui/card.tsx
Normal file
@@ -0,0 +1,78 @@
|
||||
import * as React from 'react'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const Card = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'rounded-lg border border-cyber-border-DEFAULT bg-cyber-bg-tertiary text-cyber-text-primary shadow-cyber-card transition-all hover:border-cyber-neon-cyan/30',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
Card.displayName = 'Card'
|
||||
|
||||
const CardHeader = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn('flex flex-col space-y-1.5 p-6', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
CardHeader.displayName = 'CardHeader'
|
||||
|
||||
const CardTitle = React.forwardRef<
|
||||
HTMLParagraphElement,
|
||||
React.HTMLAttributes<HTMLHeadingElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<h3
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'text-2xl font-semibold leading-none tracking-tight text-cyber-neon-cyan',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
CardTitle.displayName = 'CardTitle'
|
||||
|
||||
const CardDescription = React.forwardRef<
|
||||
HTMLParagraphElement,
|
||||
React.HTMLAttributes<HTMLParagraphElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<p
|
||||
ref={ref}
|
||||
className={cn('text-sm text-cyber-text-muted', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
CardDescription.displayName = 'CardDescription'
|
||||
|
||||
const CardContent = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
|
||||
))
|
||||
CardContent.displayName = 'CardContent'
|
||||
|
||||
const CardFooter = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div
|
||||
ref={ref}
|
||||
className={cn('flex items-center p-6 pt-0', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
CardFooter.displayName = 'CardFooter'
|
||||
|
||||
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
|
||||
36
webui/src/components/ui/checkbox.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import * as React from 'react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Check } from 'lucide-react'
|
||||
|
||||
export interface CheckboxProps
|
||||
extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||
onCheckedChange?: (checked: boolean) => void
|
||||
}
|
||||
|
||||
const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
|
||||
({ className, checked, onCheckedChange, ...props }, ref) => {
|
||||
return (
|
||||
<label className="inline-flex items-center cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="sr-only peer"
|
||||
ref={ref}
|
||||
checked={checked}
|
||||
onChange={(e) => onCheckedChange?.(e.target.checked)}
|
||||
{...props}
|
||||
/>
|
||||
<div
|
||||
className={cn(
|
||||
'h-4 w-4 shrink-0 rounded-sm border border-cyber-border-DEFAULT bg-cyber-bg-tertiary ring-offset-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-cyber-neon-cyan disabled:cursor-not-allowed disabled:opacity-50 peer-checked:bg-cyber-neon-cyan/20 peer-checked:border-cyber-neon-cyan peer-checked:shadow-glow-cyan-sm flex items-center justify-center transition-all',
|
||||
className
|
||||
)}
|
||||
>
|
||||
<Check className={cn('h-3 w-3 text-cyber-neon-cyan transition-opacity', checked ? 'opacity-100' : 'opacity-0')} />
|
||||
</div>
|
||||
</label>
|
||||
)
|
||||
}
|
||||
)
|
||||
Checkbox.displayName = 'Checkbox'
|
||||
|
||||
export { Checkbox }
|
||||
119
webui/src/components/ui/dialog.tsx
Normal file
@@ -0,0 +1,119 @@
|
||||
import * as React from 'react'
|
||||
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
||||
import { X } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const Dialog = DialogPrimitive.Root
|
||||
|
||||
const DialogTrigger = DialogPrimitive.Trigger
|
||||
|
||||
const DialogPortal = DialogPrimitive.Portal
|
||||
|
||||
const DialogClose = DialogPrimitive.Close
|
||||
|
||||
const DialogOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Overlay
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'fixed inset-0 z-50 bg-black/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
|
||||
|
||||
const DialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 glass-panel-dark float-panel rounded-lg p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 hover:text-cyber-neon-cyan focus:outline-none focus:ring-2 focus:ring-cyber-neon-cyan focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</DialogPrimitive.Close>
|
||||
</DialogPrimitive.Content>
|
||||
</DialogPortal>
|
||||
))
|
||||
DialogContent.displayName = DialogPrimitive.Content.displayName
|
||||
|
||||
const DialogHeader = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
'flex flex-col space-y-1.5 text-center sm:text-left',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
DialogHeader.displayName = 'DialogHeader'
|
||||
|
||||
const DialogFooter = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
DialogFooter.displayName = 'DialogFooter'
|
||||
|
||||
const DialogTitle = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Title
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'text-lg font-semibold leading-none tracking-tight text-cyber-neon-cyan font-mono',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DialogTitle.displayName = DialogPrimitive.Title.displayName
|
||||
|
||||
const DialogDescription = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Description
|
||||
ref={ref}
|
||||
className={cn('text-sm text-cyber-text-secondary', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DialogDescription.displayName = DialogPrimitive.Description.displayName
|
||||
|
||||
export {
|
||||
Dialog,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogClose,
|
||||
DialogTrigger,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogFooter,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
}
|
||||
24
webui/src/components/ui/input.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as React from 'react'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
export interface InputProps
|
||||
extends React.InputHTMLAttributes<HTMLInputElement> {}
|
||||
|
||||
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
||||
({ className, type, ...props }, ref) => {
|
||||
return (
|
||||
<input
|
||||
type={type}
|
||||
className={cn(
|
||||
'flex h-9 w-full rounded-md border border-cyber-border-DEFAULT bg-cyber-bg-tertiary px-3 py-2 text-sm font-mono text-cyber-text-primary ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-cyber-text-muted focus-visible:outline-none focus-visible:border-cyber-neon-cyan focus-visible:shadow-[0_0_10px_rgb(var(--cyber-neon-cyan)/0.2)] disabled:cursor-not-allowed disabled:opacity-50 transition-all',
|
||||
className
|
||||
)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
)
|
||||
Input.displayName = 'Input'
|
||||
|
||||
export { Input }
|
||||
23
webui/src/components/ui/label.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import * as React from 'react'
|
||||
import * as LabelPrimitive from '@radix-ui/react-label'
|
||||
import { cva, type VariantProps } from 'class-variance-authority'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const labelVariants = cva(
|
||||
'text-sm font-mono leading-none text-cyber-text-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-70'
|
||||
)
|
||||
|
||||
const Label = React.forwardRef<
|
||||
React.ElementRef<typeof LabelPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
||||
VariantProps<typeof labelVariants>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<LabelPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(labelVariants(), className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
Label.displayName = LabelPrimitive.Root.displayName
|
||||
|
||||
export { Label }
|
||||
45
webui/src/components/ui/scroll-area.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import * as React from 'react'
|
||||
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const ScrollArea = React.forwardRef<
|
||||
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<ScrollAreaPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn('relative overflow-hidden', className)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
||||
{children}
|
||||
</ScrollAreaPrimitive.Viewport>
|
||||
<ScrollBar />
|
||||
<ScrollAreaPrimitive.Corner />
|
||||
</ScrollAreaPrimitive.Root>
|
||||
))
|
||||
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
|
||||
|
||||
const ScrollBar = React.forwardRef<
|
||||
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
||||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||
>(({ className, orientation = 'vertical', ...props }, ref) => (
|
||||
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||
ref={ref}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
'flex touch-none select-none transition-colors',
|
||||
orientation === 'vertical' &&
|
||||
'h-full w-2.5 border-l border-l-transparent p-[1px]',
|
||||
orientation === 'horizontal' &&
|
||||
'h-2.5 flex-col border-t border-t-transparent p-[1px]',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
||||
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||
))
|
||||
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
|
||||
|
||||
export { ScrollArea, ScrollBar }
|
||||
157
webui/src/components/ui/select.tsx
Normal file
@@ -0,0 +1,157 @@
|
||||
import * as React from 'react'
|
||||
import * as SelectPrimitive from '@radix-ui/react-select'
|
||||
import { Check, ChevronDown, ChevronUp } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const Select = SelectPrimitive.Root
|
||||
|
||||
const SelectGroup = SelectPrimitive.Group
|
||||
|
||||
const SelectValue = SelectPrimitive.Value
|
||||
|
||||
const SelectTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<SelectPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'flex h-9 w-full items-center justify-between rounded-md border border-cyber-border-DEFAULT bg-cyber-bg-tertiary px-3 py-2 text-sm font-mono text-cyber-text-primary ring-offset-background placeholder:text-cyber-text-muted focus:outline-none focus:border-cyber-neon-cyan focus:shadow-[0_0_10px_rgb(var(--cyber-neon-cyan)/0.2)] disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 transition-all',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<SelectPrimitive.Icon asChild>
|
||||
<ChevronDown className="h-4 w-4 text-cyber-text-muted" />
|
||||
</SelectPrimitive.Icon>
|
||||
</SelectPrimitive.Trigger>
|
||||
))
|
||||
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
|
||||
|
||||
const SelectScrollUpButton = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.ScrollUpButton
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'flex cursor-default items-center justify-center py-1 text-cyber-text-muted',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronUp className="h-4 w-4" />
|
||||
</SelectPrimitive.ScrollUpButton>
|
||||
))
|
||||
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
|
||||
|
||||
const SelectScrollDownButton = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.ScrollDownButton
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'flex cursor-default items-center justify-center py-1 text-cyber-text-muted',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronDown className="h-4 w-4" />
|
||||
</SelectPrimitive.ScrollDownButton>
|
||||
))
|
||||
SelectScrollDownButton.displayName =
|
||||
SelectPrimitive.ScrollDownButton.displayName
|
||||
|
||||
const SelectContent = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
||||
>(({ className, children, position = 'popper', ...props }, ref) => (
|
||||
<SelectPrimitive.Portal>
|
||||
<SelectPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-cyber-border-DEFAULT bg-cyber-bg-panel text-cyber-text-primary shadow-[0_0_20px_rgba(0,0,0,0.5)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
|
||||
position === 'popper' &&
|
||||
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
||||
className
|
||||
)}
|
||||
position={position}
|
||||
{...props}
|
||||
>
|
||||
<SelectScrollUpButton />
|
||||
<SelectPrimitive.Viewport
|
||||
className={cn(
|
||||
'p-1',
|
||||
position === 'popper' &&
|
||||
'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</SelectPrimitive.Viewport>
|
||||
<SelectScrollDownButton />
|
||||
</SelectPrimitive.Content>
|
||||
</SelectPrimitive.Portal>
|
||||
))
|
||||
SelectContent.displayName = SelectPrimitive.Content.displayName
|
||||
|
||||
const SelectLabel = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn('py-1.5 pl-8 pr-2 text-sm font-semibold text-cyber-neon-cyan', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
SelectLabel.displayName = SelectPrimitive.Label.displayName
|
||||
|
||||
const SelectItem = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<SelectPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm font-mono outline-none focus:bg-cyber-neon-cyan/20 focus:text-cyber-neon-cyan data-[disabled]:pointer-events-none data-[disabled]:opacity-50 transition-colors',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||
<SelectPrimitive.ItemIndicator>
|
||||
<Check className="h-4 w-4 text-cyber-neon-cyan" />
|
||||
</SelectPrimitive.ItemIndicator>
|
||||
</span>
|
||||
|
||||
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
||||
</SelectPrimitive.Item>
|
||||
))
|
||||
SelectItem.displayName = SelectPrimitive.Item.displayName
|
||||
|
||||
const SelectSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Separator>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.Separator
|
||||
ref={ref}
|
||||
className={cn('-mx-1 my-1 h-px bg-cyber-border-DEFAULT', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
SelectSeparator.displayName = SelectPrimitive.Separator.displayName
|
||||
|
||||
export {
|
||||
Select,
|
||||
SelectGroup,
|
||||
SelectValue,
|
||||
SelectTrigger,
|
||||
SelectContent,
|
||||
SelectLabel,
|
||||
SelectItem,
|
||||
SelectSeparator,
|
||||
SelectScrollUpButton,
|
||||
SelectScrollDownButton,
|
||||
}
|
||||
52
webui/src/components/ui/tabs.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import * as React from 'react'
|
||||
import * as TabsPrimitive from '@radix-ui/react-tabs'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const Tabs = TabsPrimitive.Root
|
||||
|
||||
const TabsList = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.List>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<TabsPrimitive.List
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'inline-flex h-9 items-center justify-center rounded-md bg-cyber-bg-tertiary border border-cyber-border-DEFAULT p-1 text-cyber-text-muted',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TabsList.displayName = TabsPrimitive.List.displayName
|
||||
|
||||
const TabsTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<TabsPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1 text-sm font-mono ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-cyber-neon-cyan disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-cyber-neon-cyan/20 data-[state=active]:text-cyber-neon-cyan data-[state=active]:shadow-glow-cyan-sm',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
|
||||
|
||||
const TabsContent = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<TabsPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-cyber-neon-cyan',
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TabsContent.displayName = TabsPrimitive.Content.displayName
|
||||
|
||||
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
||||
99
webui/src/hooks/useCrawler.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { toast } from 'sonner'
|
||||
import { crawlerApi, configApi } from '@/lib/api'
|
||||
import { useCrawlerStore } from '@/store/crawlerStore'
|
||||
import type { CrawlerConfig } from '@/types/crawler'
|
||||
|
||||
export function useCrawlerStatus() {
|
||||
const setStatus = useCrawlerStore((state) => state.setStatus)
|
||||
const setRunningInfo = useCrawlerStore((state) => state.setRunningInfo)
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['crawlerStatus'],
|
||||
queryFn: async () => {
|
||||
const { data } = await crawlerApi.getStatus()
|
||||
setStatus(data.status)
|
||||
setRunningInfo(data.platform, data.crawler_type, data.started_at)
|
||||
return data
|
||||
},
|
||||
refetchInterval: 2000,
|
||||
})
|
||||
}
|
||||
|
||||
export function useStartCrawler() {
|
||||
const queryClient = useQueryClient()
|
||||
const setStatus = useCrawlerStore((state) => state.setStatus)
|
||||
const clearLogs = useCrawlerStore((state) => state.clearLogs)
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (config: CrawlerConfig) => crawlerApi.start(config),
|
||||
onMutate: () => {
|
||||
clearLogs()
|
||||
setStatus('running')
|
||||
},
|
||||
onSuccess: () => {
|
||||
toast.success('Crawler started successfully')
|
||||
queryClient.invalidateQueries({ queryKey: ['crawlerStatus'] })
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
setStatus('idle')
|
||||
toast.error(`Failed to start crawler: ${error.message}`)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function useStopCrawler() {
|
||||
const queryClient = useQueryClient()
|
||||
const setStatus = useCrawlerStore((state) => state.setStatus)
|
||||
|
||||
return useMutation({
|
||||
mutationFn: () => crawlerApi.stop(),
|
||||
onMutate: () => {
|
||||
setStatus('stopping')
|
||||
},
|
||||
onSuccess: () => {
|
||||
toast.success('Crawler stopped')
|
||||
setStatus('idle')
|
||||
queryClient.invalidateQueries({ queryKey: ['crawlerStatus'] })
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
toast.error(`Failed to stop crawler: ${error.message}`)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function useCrawlerLogs() {
|
||||
const setLogs = useCrawlerStore((state) => state.setLogs)
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['crawlerLogs'],
|
||||
queryFn: async () => {
|
||||
const { data } = await crawlerApi.getLogs(500)
|
||||
setLogs(data.logs)
|
||||
return data.logs
|
||||
},
|
||||
refetchInterval: false, // Use WebSocket instead
|
||||
})
|
||||
}
|
||||
|
||||
export function usePlatforms() {
|
||||
return useQuery({
|
||||
queryKey: ['platforms'],
|
||||
queryFn: async () => {
|
||||
const { data } = await configApi.getPlatforms()
|
||||
return data.platforms
|
||||
},
|
||||
staleTime: Infinity,
|
||||
})
|
||||
}
|
||||
|
||||
export function useConfigOptions() {
|
||||
return useQuery({
|
||||
queryKey: ['configOptions'],
|
||||
queryFn: async () => {
|
||||
const { data } = await configApi.getOptions()
|
||||
return data
|
||||
},
|
||||
staleTime: Infinity,
|
||||
})
|
||||
}
|
||||
111
webui/src/hooks/useWebSocket.ts
Normal file
@@ -0,0 +1,111 @@
|
||||
import { useEffect, useRef } from 'react'
|
||||
import { useCrawlerStore } from '@/store/crawlerStore'
|
||||
import type { LogEntry } from '@/types/crawler'
|
||||
|
||||
// 模块级单例,确保全局只有一个 WebSocket 连接
|
||||
let globalWs: WebSocket | null = null
|
||||
let globalReconnectTimer: ReturnType<typeof setTimeout> | null = null
|
||||
let connectionCount = 0 // 跟踪连接使用者数量
|
||||
|
||||
export function useLogWebSocket() {
|
||||
const addLog = useCrawlerStore((state) => state.addLog)
|
||||
const addLogRef = useRef(addLog)
|
||||
|
||||
// 保持 addLog 引用最新
|
||||
useEffect(() => {
|
||||
addLogRef.current = addLog
|
||||
}, [addLog])
|
||||
|
||||
useEffect(() => {
|
||||
connectionCount++
|
||||
|
||||
const connect = () => {
|
||||
if (globalReconnectTimer) {
|
||||
clearTimeout(globalReconnectTimer)
|
||||
globalReconnectTimer = null
|
||||
}
|
||||
|
||||
// 如果已经连接或正在连接,不重复创建
|
||||
if (globalWs && (globalWs.readyState === WebSocket.OPEN || globalWs.readyState === WebSocket.CONNECTING)) {
|
||||
return
|
||||
}
|
||||
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
|
||||
const host = window.location.host
|
||||
const wsUrl = `${protocol}//${host}/api/ws/logs`
|
||||
|
||||
const ws = new WebSocket(wsUrl)
|
||||
globalWs = ws
|
||||
|
||||
ws.onopen = () => {
|
||||
if (globalWs !== ws) return
|
||||
console.log('WebSocket connected')
|
||||
}
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
if (globalWs !== ws) return
|
||||
if (event.data === 'ping') {
|
||||
ws.send('pong')
|
||||
return
|
||||
}
|
||||
if (event.data === 'pong') {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const log: LogEntry = JSON.parse(event.data)
|
||||
if (log.id && log.message) {
|
||||
addLogRef.current(log)
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Failed to parse WebSocket message:', event.data)
|
||||
}
|
||||
}
|
||||
|
||||
ws.onclose = () => {
|
||||
if (globalWs !== ws) return
|
||||
console.log('WebSocket disconnected')
|
||||
globalWs = null
|
||||
// 只在还有使用者时才重连
|
||||
if (connectionCount > 0) {
|
||||
globalReconnectTimer = setTimeout(connect, 2000)
|
||||
}
|
||||
}
|
||||
|
||||
ws.onerror = (error) => {
|
||||
if (globalWs !== ws) return
|
||||
console.error('WebSocket error:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 首次连接
|
||||
connect()
|
||||
|
||||
// Heartbeat
|
||||
const heartbeat = setInterval(() => {
|
||||
if (globalWs && globalWs.readyState === WebSocket.OPEN) {
|
||||
globalWs.send('ping')
|
||||
}
|
||||
}, 30000)
|
||||
|
||||
return () => {
|
||||
connectionCount--
|
||||
clearInterval(heartbeat)
|
||||
|
||||
// 只在没有使用者时才断开连接
|
||||
if (connectionCount === 0) {
|
||||
if (globalReconnectTimer) {
|
||||
clearTimeout(globalReconnectTimer)
|
||||
globalReconnectTimer = null
|
||||
}
|
||||
if (globalWs) {
|
||||
const ws = globalWs
|
||||
globalWs = null
|
||||
ws.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}, []) // 空依赖数组
|
||||
|
||||
return { ws: globalWs }
|
||||
}
|
||||
57
webui/src/i18n/index.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import i18n from 'i18next'
|
||||
import { initReactI18next } from 'react-i18next'
|
||||
import LanguageDetector from 'i18next-browser-languagedetector'
|
||||
|
||||
// 中文翻译
|
||||
import zhCommon from './locales/zh-CN/common.json'
|
||||
import zhConfig from './locales/zh-CN/config.json'
|
||||
import zhTerminal from './locales/zh-CN/terminal.json'
|
||||
import zhData from './locales/zh-CN/data.json'
|
||||
import zhEnv from './locales/zh-CN/env.json'
|
||||
import zhLicense from './locales/zh-CN/license.json'
|
||||
|
||||
// 英文翻译
|
||||
import enCommon from './locales/en-US/common.json'
|
||||
import enConfig from './locales/en-US/config.json'
|
||||
import enTerminal from './locales/en-US/terminal.json'
|
||||
import enData from './locales/en-US/data.json'
|
||||
import enEnv from './locales/en-US/env.json'
|
||||
import enLicense from './locales/en-US/license.json'
|
||||
|
||||
const resources = {
|
||||
'zh-CN': {
|
||||
common: zhCommon,
|
||||
config: zhConfig,
|
||||
terminal: zhTerminal,
|
||||
data: zhData,
|
||||
env: zhEnv,
|
||||
license: zhLicense,
|
||||
},
|
||||
'en-US': {
|
||||
common: enCommon,
|
||||
config: enConfig,
|
||||
terminal: enTerminal,
|
||||
data: enData,
|
||||
env: enEnv,
|
||||
license: enLicense,
|
||||
},
|
||||
}
|
||||
|
||||
i18n
|
||||
.use(LanguageDetector)
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
resources,
|
||||
fallbackLng: 'zh-CN',
|
||||
defaultNS: 'common',
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
detection: {
|
||||
order: ['localStorage', 'navigator'],
|
||||
caches: ['localStorage'],
|
||||
lookupLocalStorage: 'mediacrawler_language',
|
||||
},
|
||||
})
|
||||
|
||||
export default i18n
|
||||
26
webui/src/i18n/locales/en-US/common.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"status": {
|
||||
"active": "ACTIVE",
|
||||
"standby": "STANDBY",
|
||||
"idle": "IDLE",
|
||||
"running": "RUNNING",
|
||||
"stopping": "STOPPING",
|
||||
"error": "ERROR"
|
||||
},
|
||||
"sidebar": {
|
||||
"title": "MediaCrawler",
|
||||
"api": "API",
|
||||
"local": "LOCAL",
|
||||
"disclaimer": "For personal learning only, commercial use prohibited",
|
||||
"license": "License"
|
||||
},
|
||||
"action": {
|
||||
"loading": "Loading...",
|
||||
"skip": "SKIP_CHECK",
|
||||
"retry": "RETRY_SCAN"
|
||||
},
|
||||
"unit": {
|
||||
"entries": "entries",
|
||||
"records": "records"
|
||||
}
|
||||
}
|
||||
71
webui/src/i18n/locales/en-US/config.json
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"section": {
|
||||
"targetMatrix": {
|
||||
"title": "TARGET_MATRIX",
|
||||
"description": "Platform, mode & search parameters"
|
||||
},
|
||||
"authMatrix": {
|
||||
"title": "AUTH_MATRIX",
|
||||
"description": "Login method configuration"
|
||||
},
|
||||
"outputConfig": {
|
||||
"title": "OUTPUT_CONFIG",
|
||||
"description": "Save format & comment options"
|
||||
},
|
||||
"runtime": {
|
||||
"title": "RUNTIME",
|
||||
"description": "Runtime parameters"
|
||||
}
|
||||
},
|
||||
"field": {
|
||||
"platform": "PLATFORM",
|
||||
"platformPlaceholder": "Select platform",
|
||||
"crawlType": "CRAWL_TYPE",
|
||||
"crawlTypePlaceholder": "Select type",
|
||||
"startPage": "START_PAGE",
|
||||
"keywords": "KEYWORDS",
|
||||
"keywordsHint": "Press Enter to add keyword",
|
||||
"keywordsPlaceholder": "Type keyword, press Enter to add...",
|
||||
"specifiedIds": "POST/VIDEO_ID",
|
||||
"specifiedIdsHint": "Enter post or video ID/URL, one per line or comma-separated",
|
||||
"specifiedIdsPlaceholder": {
|
||||
"bili": "Examples:\nBV1xxxx\nhttps://www.bilibili.com/video/BV1xxxx",
|
||||
"xhs": "Examples:\nhttps://www.xiaohongshu.com/explore/xxx?xsec_token=xxx\n(must include xsec_token)",
|
||||
"dy": "Examples:\n7525538910311632128\nhttps://www.douyin.com/video/xxx\nhttps://v.douyin.com/xxx (short link)",
|
||||
"wb": "Examples:\n4982041758140155\nhttps://weibo.com/xxx/xxx",
|
||||
"ks": "Examples:\n3xf8enb8dbj6uig\nhttps://www.kuaishou.com/short-video/xxx",
|
||||
"default": "Enter post/video ID or URL..."
|
||||
},
|
||||
"creatorIds": "CREATOR_ID",
|
||||
"creatorIdsHint": "Enter creator ID/URL, one per line or comma-separated",
|
||||
"creatorIdsPlaceholder": {
|
||||
"bili": "Examples:\n434377496\nhttps://space.bilibili.com/434377496",
|
||||
"xhs": "Examples:\nhttps://www.xiaohongshu.com/user/profile/xxx?xsec_token=xxx\n(must include xsec_token)",
|
||||
"dy": "Examples:\nMS4wLjABAAAAxxx\nhttps://www.douyin.com/user/MS4wLjABAAAAxxx",
|
||||
"wb": "Examples:\n5533390220\nhttps://weibo.com/u/5533390220",
|
||||
"ks": "Examples:\n3x84qugg4ch9zhs\nhttps://www.kuaishou.com/profile/xxx",
|
||||
"default": "Enter creator ID or URL..."
|
||||
},
|
||||
"loginMethod": "LOGIN_METHOD",
|
||||
"loginMethodPlaceholder": "Select login method",
|
||||
"cookies": "COOKIES",
|
||||
"cookiesHint": "Paste cookie string",
|
||||
"cookiesPlaceholder": "Paste cookies here...",
|
||||
"saveFormat": "SAVE_FORMAT",
|
||||
"saveFormatPlaceholder": "Select format",
|
||||
"commentExtraction": "Comment Extraction",
|
||||
"subComments": "Sub-comments",
|
||||
"headlessMode": "HEADLESS_MODE",
|
||||
"headlessModeHint": "Run browser without GUI"
|
||||
},
|
||||
"button": {
|
||||
"initiateScan": "INITIATE SCAN",
|
||||
"initiating": "INITIATING...",
|
||||
"terminate": "TERMINATE",
|
||||
"stopping": "STOPPING..."
|
||||
},
|
||||
"warning": {
|
||||
"cookieSlider": "[Note] Cookie login is not recommended for Xiaohongshu and Douyin due to slider captcha",
|
||||
"xhsToken": "[Important] Xiaohongshu URLs must contain xsec_token parameter, please copy the full URL from browser"
|
||||
}
|
||||
}
|
||||
29
webui/src/i18n/locales/en-US/data.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"dialog": {
|
||||
"button": "PAYLOAD_MATRIX",
|
||||
"title": "DATA_EXPLORER"
|
||||
},
|
||||
"explorer": {
|
||||
"title": "CAPTURED_PAYLOAD_MATRIX",
|
||||
"records": "{{count}} RECORDS",
|
||||
"rescan": "RESCAN",
|
||||
"loading": "[LOADING] Scanning payload directory...",
|
||||
"noData": "NO_DATA_CAPTURED",
|
||||
"noDataHint": "Initialize crawler to begin data extraction sequence. Results will appear here upon completion.",
|
||||
"allCategories": "ALL"
|
||||
},
|
||||
"file": {
|
||||
"entries": "{{count}} entries",
|
||||
"extract": "EXTRACT",
|
||||
"preview": "PREVIEW"
|
||||
},
|
||||
"preview": {
|
||||
"title": "Data Preview",
|
||||
"records": "{{count}} RECORDS",
|
||||
"download": "DOWNLOAD",
|
||||
"loading": "[LOADING] Decoding payload...",
|
||||
"error": "[ERROR] Failed to decode payload",
|
||||
"searchPlaceholder": "Search in data...",
|
||||
"showing": "Showing {{filtered}} of {{total}} records"
|
||||
}
|
||||
}
|
||||
18
webui/src/i18n/locales/en-US/env.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"title": "ENV_DIAGNOSTICS",
|
||||
"scanning": "[SCAN] Analyzing MediaCrawler environment...",
|
||||
"success": "[OK] {{message}}",
|
||||
"error": "[ERR] {{message}}",
|
||||
"defaultError": "Cannot connect to API server",
|
||||
"defaultErrorHint": "Please ensure backend service is running (uvicorn api.main:app --port 8080)",
|
||||
"showDetails": "[+] SHOW_DETAILS",
|
||||
"hideDetails": "[-] HIDE_DETAILS",
|
||||
"requirements": "[REQUIREMENTS]",
|
||||
"requirementsList": {
|
||||
"1": "Install uv package manager",
|
||||
"2": "Execute uv sync in project root",
|
||||
"3": "Verify all dependencies installed"
|
||||
},
|
||||
"skipCheck": "SKIP_CHECK",
|
||||
"retryCheck": "RETRY_SCAN"
|
||||
}
|
||||
21
webui/src/i18n/locales/en-US/license.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"title": "Usage Notice",
|
||||
"warning": "Please read the following terms carefully",
|
||||
"content": {
|
||||
"line1": "This project is for personal learning and research purposes only",
|
||||
"line2": "Commercial use or profit-making activities are strictly prohibited",
|
||||
"line3": "By using this project, you agree to comply with all applicable laws",
|
||||
"line4": "Users bear full responsibility for any consequences of misuse"
|
||||
},
|
||||
"license": "View Full License",
|
||||
"github": "Visit GitHub Repository",
|
||||
"confirm": "I understand and agree to the above terms",
|
||||
"decline": "Disagree, Exit",
|
||||
"author": {
|
||||
"name": "Relakkes (阿江)",
|
||||
"tagline": "40K+ Star Open Source Author",
|
||||
"description": "Author of MediaCrawler (40K stars), focused on crawler tech and AI Agent knowledge sharing",
|
||||
"support": "If you find this project helpful, please follow the author on social media",
|
||||
"slogan": "Open source is hard, please star ⭐"
|
||||
}
|
||||
}
|
||||
16
webui/src/i18n/locales/en-US/terminal.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"header": {
|
||||
"title": "SYSTEM_CONSOLE",
|
||||
"entries": "{{count}} entries",
|
||||
"active": "ACTIVE",
|
||||
"clear": "CLEAR",
|
||||
"restore": "RESTORE ALL LOGS"
|
||||
},
|
||||
"banner": {
|
||||
"systemInit": "[SYS] System initialized successfully",
|
||||
"configHint": "[INFO] Configure parameters and initiate scan sequence..."
|
||||
},
|
||||
"footer": {
|
||||
"awaiting": "awaiting_command..."
|
||||
}
|
||||
}
|
||||
26
webui/src/i18n/locales/zh-CN/common.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"status": {
|
||||
"active": "运行中",
|
||||
"standby": "待机",
|
||||
"idle": "空闲",
|
||||
"running": "运行中",
|
||||
"stopping": "停止中",
|
||||
"error": "错误"
|
||||
},
|
||||
"sidebar": {
|
||||
"title": "MediaCrawler",
|
||||
"api": "API",
|
||||
"local": "本地",
|
||||
"disclaimer": "仅供个人学习研究使用,禁止商业用途",
|
||||
"license": "查看协议"
|
||||
},
|
||||
"action": {
|
||||
"loading": "加载中...",
|
||||
"skip": "跳过检测",
|
||||
"retry": "重新扫描"
|
||||
},
|
||||
"unit": {
|
||||
"entries": "条记录",
|
||||
"records": "条"
|
||||
}
|
||||
}
|
||||
71
webui/src/i18n/locales/zh-CN/config.json
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"section": {
|
||||
"targetMatrix": {
|
||||
"title": "目标配置",
|
||||
"description": "平台、模式与搜索参数"
|
||||
},
|
||||
"authMatrix": {
|
||||
"title": "登录配置",
|
||||
"description": "登录方式配置"
|
||||
},
|
||||
"outputConfig": {
|
||||
"title": "输出配置",
|
||||
"description": "保存格式与评论选项"
|
||||
},
|
||||
"runtime": {
|
||||
"title": "运行参数",
|
||||
"description": "运行时参数"
|
||||
}
|
||||
},
|
||||
"field": {
|
||||
"platform": "平台",
|
||||
"platformPlaceholder": "选择平台",
|
||||
"crawlType": "爬取类型",
|
||||
"crawlTypePlaceholder": "选择类型",
|
||||
"startPage": "起始页",
|
||||
"keywords": "关键词",
|
||||
"keywordsHint": "输入关键词后按回车添加",
|
||||
"keywordsPlaceholder": "输入关键词,按回车添加...",
|
||||
"specifiedIds": "帖子/视频 ID",
|
||||
"specifiedIdsHint": "输入帖子或视频的ID/URL,每行一个或用逗号分隔",
|
||||
"specifiedIdsPlaceholder": {
|
||||
"bili": "示例:\nBV1xxxx\nhttps://www.bilibili.com/video/BV1xxxx",
|
||||
"xhs": "示例:\nhttps://www.xiaohongshu.com/explore/xxx?xsec_token=xxx\n(必须包含xsec_token参数)",
|
||||
"dy": "示例:\n7525538910311632128\nhttps://www.douyin.com/video/xxx\nhttps://v.douyin.com/xxx (短链接)",
|
||||
"wb": "示例:\n4982041758140155\nhttps://weibo.com/xxx/xxx",
|
||||
"ks": "示例:\n3xf8enb8dbj6uig\nhttps://www.kuaishou.com/short-video/xxx",
|
||||
"default": "输入帖子/视频 ID 或 URL..."
|
||||
},
|
||||
"creatorIds": "创作者 ID",
|
||||
"creatorIdsHint": "输入创作者的ID/URL,每行一个或用逗号分隔",
|
||||
"creatorIdsPlaceholder": {
|
||||
"bili": "示例:\n434377496\nhttps://space.bilibili.com/434377496",
|
||||
"xhs": "示例:\nhttps://www.xiaohongshu.com/user/profile/xxx?xsec_token=xxx\n(必须包含xsec_token参数)",
|
||||
"dy": "示例:\nMS4wLjABAAAAxxx\nhttps://www.douyin.com/user/MS4wLjABAAAAxxx",
|
||||
"wb": "示例:\n5533390220\nhttps://weibo.com/u/5533390220",
|
||||
"ks": "示例:\n3x84qugg4ch9zhs\nhttps://www.kuaishou.com/profile/xxx",
|
||||
"default": "输入创作者 ID 或 URL..."
|
||||
},
|
||||
"loginMethod": "登录方式",
|
||||
"loginMethodPlaceholder": "选择登录方式",
|
||||
"cookies": "Cookies",
|
||||
"cookiesHint": "粘贴 Cookie 字符串",
|
||||
"cookiesPlaceholder": "在此粘贴 Cookies...",
|
||||
"saveFormat": "保存格式",
|
||||
"saveFormatPlaceholder": "选择格式",
|
||||
"commentExtraction": "评论抓取",
|
||||
"subComments": "子评论",
|
||||
"headlessMode": "无头模式",
|
||||
"headlessModeHint": "无 GUI 运行浏览器"
|
||||
},
|
||||
"button": {
|
||||
"initiateScan": "开始爬虫",
|
||||
"initiating": "启动中...",
|
||||
"terminate": "终止",
|
||||
"stopping": "停止中..."
|
||||
},
|
||||
"warning": {
|
||||
"cookieSlider": "[提示] 小红书和抖音平台不建议使用 Cookie 登录,因为可能会触发滑块验证",
|
||||
"xhsToken": "[重要] 小红书 URL 必须包含 xsec_token 参数,请从浏览器复制完整 URL"
|
||||
}
|
||||
}
|
||||
29
webui/src/i18n/locales/zh-CN/data.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"dialog": {
|
||||
"button": "数据管理",
|
||||
"title": "数据浏览器"
|
||||
},
|
||||
"explorer": {
|
||||
"title": "数据文件管理",
|
||||
"records": "{{count}} 条",
|
||||
"rescan": "重新扫描",
|
||||
"loading": "[加载中] 正在扫描数据目录...",
|
||||
"noData": "暂无数据",
|
||||
"noDataHint": "启动爬虫开始数据采集,完成后结果将显示在此处。",
|
||||
"allCategories": "全部"
|
||||
},
|
||||
"file": {
|
||||
"entries": "{{count}} 条",
|
||||
"extract": "下载",
|
||||
"preview": "预览"
|
||||
},
|
||||
"preview": {
|
||||
"title": "数据预览",
|
||||
"records": "{{count}} 条记录",
|
||||
"download": "下载",
|
||||
"loading": "[加载中] 正在解析数据...",
|
||||
"error": "[错误] 数据解析失败",
|
||||
"searchPlaceholder": "搜索数据...",
|
||||
"showing": "显示 {{filtered}} / {{total}} 条记录"
|
||||
}
|
||||
}
|
||||
18
webui/src/i18n/locales/zh-CN/env.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"title": "环境检测",
|
||||
"scanning": "[扫描] 正在分析 MediaCrawler 环境...",
|
||||
"success": "[成功] {{message}}",
|
||||
"error": "[错误] {{message}}",
|
||||
"defaultError": "无法连接到 API 服务器",
|
||||
"defaultErrorHint": "请确保后端服务已启动 (uvicorn api.main:app --port 8080)",
|
||||
"showDetails": "[+] 显示详情",
|
||||
"hideDetails": "[-] 隐藏详情",
|
||||
"requirements": "[环境要求]",
|
||||
"requirementsList": {
|
||||
"1": "安装 uv 包管理器",
|
||||
"2": "在项目根目录执行 uv sync",
|
||||
"3": "确认所有依赖已安装"
|
||||
},
|
||||
"skipCheck": "跳过检测",
|
||||
"retryCheck": "重新检测"
|
||||
}
|
||||
21
webui/src/i18n/locales/zh-CN/license.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"title": "使用须知",
|
||||
"warning": "请仔细阅读以下条款",
|
||||
"content": {
|
||||
"line1": "本项目仅供个人学习和研究爬虫技术使用",
|
||||
"line2": "严禁将本项目用于任何商业用途或盈利活动",
|
||||
"line3": "使用本项目即表示您同意遵守相关法律法规",
|
||||
"line4": "任何因违规使用造成的后果由使用者自行承担"
|
||||
},
|
||||
"license": "查看完整协议",
|
||||
"github": "访问 GitHub 仓库",
|
||||
"confirm": "我已知晓并同意上述条款",
|
||||
"decline": "不同意,退出",
|
||||
"author": {
|
||||
"name": "程序员阿江-Relakkes",
|
||||
"tagline": "40K+ Star 开源项目作者",
|
||||
"description": "40K开源项目MediaCrawler作者,专注爬虫技术和AI Agent知识分享",
|
||||
"support": "如果觉得项目有帮助,欢迎关注作者的社交媒体账号",
|
||||
"slogan": "开源不易,求个关注 ⭐"
|
||||
}
|
||||
}
|
||||
16
webui/src/i18n/locales/zh-CN/terminal.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"header": {
|
||||
"title": "系统控制台",
|
||||
"entries": "{{count}} 条记录",
|
||||
"active": "活跃",
|
||||
"clear": "清除",
|
||||
"restore": "恢复所有日志"
|
||||
},
|
||||
"banner": {
|
||||
"systemInit": "[系统] 系统初始化成功",
|
||||
"configHint": "[信息] 配置参数并启动扫描序列..."
|
||||
},
|
||||
"footer": {
|
||||
"awaiting": "等待命令..."
|
||||
}
|
||||
}
|
||||
490
webui/src/index.css
Normal file
@@ -0,0 +1,490 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@layer base {
|
||||
/* Light theme (default) - Clean Cyber */
|
||||
:root {
|
||||
/* Semantic colors for shadcn compatibility */
|
||||
--background: 210 20% 98%;
|
||||
--foreground: 220 20% 15%;
|
||||
--card: 0 0% 100%;
|
||||
--card-foreground: 220 20% 15%;
|
||||
--popover: 0 0% 100%;
|
||||
--popover-foreground: 220 20% 15%;
|
||||
--primary: 187 80% 42%;
|
||||
--primary-foreground: 0 0% 100%;
|
||||
--secondary: 330 75% 55%;
|
||||
--secondary-foreground: 0 0% 100%;
|
||||
--muted: 210 20% 95%;
|
||||
--muted-foreground: 215 15% 45%;
|
||||
--accent: 187 80% 42%;
|
||||
--accent-foreground: 0 0% 100%;
|
||||
--destructive: 330 75% 55%;
|
||||
--destructive-foreground: 0 0% 100%;
|
||||
--border: 214 20% 88%;
|
||||
--input: 214 20% 88%;
|
||||
--ring: 187 80% 42%;
|
||||
--radius: 0.375rem;
|
||||
|
||||
/* Cyberpunk color system - Clean Light with Cyan accent */
|
||||
--cyber-bg-primary: 248 250 252;
|
||||
--cyber-bg-secondary: 241 245 249;
|
||||
--cyber-bg-tertiary: 226 232 240;
|
||||
--cyber-bg-panel: 255 255 255;
|
||||
--cyber-bg-elevated: 248 250 252;
|
||||
|
||||
--cyber-neon-cyan: 6 182 212;
|
||||
--cyber-neon-cyan-dim: 8 145 178;
|
||||
--cyber-neon-pink: 236 72 153;
|
||||
--cyber-neon-pink-dim: 219 39 119;
|
||||
--cyber-neon-green: 34 197 94;
|
||||
--cyber-neon-green-dim: 22 163 74;
|
||||
--cyber-neon-orange: 249 115 22;
|
||||
--cyber-neon-yellow: 234 179 8;
|
||||
--cyber-neon-purple: 168 85 247;
|
||||
|
||||
--cyber-text-primary: 15 23 42;
|
||||
--cyber-text-secondary: 71 85 105;
|
||||
--cyber-text-muted: 148 163 184;
|
||||
|
||||
--cyber-border-default: 203 213 225;
|
||||
--cyber-border-subtle: 226 232 240;
|
||||
--cyber-border-glow: 6 182 212;
|
||||
|
||||
/* Glass effect */
|
||||
--glass-bg: 255 255 255 / 0.85;
|
||||
--glass-border: 203 213 225 / 0.5;
|
||||
--glass-dark-bg: 241 245 249 / 0.9;
|
||||
--glass-dark-border: 203 213 225 / 0.6;
|
||||
|
||||
/* Shadows - subtle for light mode */
|
||||
--shadow-glow-opacity: 0.2;
|
||||
--shadow-glow-spread: 6px;
|
||||
}
|
||||
|
||||
/* Dark theme - Full Cyberpunk */
|
||||
.dark {
|
||||
/* Semantic colors */
|
||||
--background: 233 67% 4%;
|
||||
--foreground: 210 20% 93%;
|
||||
--card: 215 21% 11%;
|
||||
--card-foreground: 210 20% 93%;
|
||||
--popover: 213 18% 13%;
|
||||
--popover-foreground: 210 20% 93%;
|
||||
--primary: 180 100% 50%;
|
||||
--primary-foreground: 233 67% 4%;
|
||||
--secondary: 330 100% 50%;
|
||||
--secondary-foreground: 0 0% 100%;
|
||||
--muted: 215 14% 17%;
|
||||
--muted-foreground: 215 16% 57%;
|
||||
--accent: 180 100% 50%;
|
||||
--accent-foreground: 233 67% 4%;
|
||||
--destructive: 330 100% 50%;
|
||||
--destructive-foreground: 0 0% 100%;
|
||||
--border: 215 14% 25%;
|
||||
--input: 215 14% 25%;
|
||||
--ring: 180 100% 50%;
|
||||
|
||||
/* Cyberpunk color system - Dark variants (original neon) */
|
||||
--cyber-bg-primary: 10 10 15;
|
||||
--cyber-bg-secondary: 13 17 23;
|
||||
--cyber-bg-tertiary: 22 27 34;
|
||||
--cyber-bg-panel: 28 33 40;
|
||||
--cyber-bg-elevated: 33 38 45;
|
||||
|
||||
--cyber-neon-cyan: 0 255 255;
|
||||
--cyber-neon-cyan-dim: 37 177 191;
|
||||
--cyber-neon-pink: 255 0 128;
|
||||
--cyber-neon-pink-dim: 222 40 59;
|
||||
--cyber-neon-green: 0 255 65;
|
||||
--cyber-neon-green-dim: 57 255 20;
|
||||
--cyber-neon-orange: 255 152 0;
|
||||
--cyber-neon-yellow: 255 234 0;
|
||||
--cyber-neon-purple: 191 0 255;
|
||||
|
||||
--cyber-text-primary: 230 237 243;
|
||||
--cyber-text-secondary: 139 148 158;
|
||||
--cyber-text-muted: 72 79 88;
|
||||
|
||||
--cyber-border-default: 48 54 61;
|
||||
--cyber-border-subtle: 33 38 45;
|
||||
--cyber-border-glow: 0 255 255;
|
||||
|
||||
/* Glass effect */
|
||||
--glass-bg: 22 27 34 / 0.7;
|
||||
--glass-border: 48 54 61 / 0.5;
|
||||
--glass-dark-bg: 13 17 23 / 0.85;
|
||||
--glass-dark-border: 48 54 61 / 0.4;
|
||||
|
||||
/* Shadows - vibrant for dark mode */
|
||||
--shadow-glow-opacity: 0.5;
|
||||
--shadow-glow-spread: 10px;
|
||||
}
|
||||
|
||||
* {
|
||||
border-color: rgb(var(--cyber-border-default));
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: rgb(var(--cyber-bg-primary));
|
||||
color: rgb(var(--cyber-text-primary));
|
||||
font-family: Inter, system-ui, sans-serif;
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================
|
||||
Cyberpunk Scrollbar Styles
|
||||
============================ */
|
||||
|
||||
/* Default scrollbar - Light */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: rgb(var(--cyber-bg-secondary));
|
||||
border-left: 1px solid rgb(var(--cyber-neon-cyan) / 0.1);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: linear-gradient(180deg, rgb(var(--cyber-neon-cyan) / 0.4), rgb(var(--cyber-neon-pink) / 0.3));
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: linear-gradient(180deg, rgb(var(--cyber-neon-cyan) / 0.6), rgb(var(--cyber-neon-pink) / 0.5));
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-corner {
|
||||
background: rgb(var(--cyber-bg-secondary));
|
||||
}
|
||||
|
||||
/* Terminal scrollbar - always dark */
|
||||
.terminal-scroll::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.terminal-scroll::-webkit-scrollbar-track {
|
||||
background: #000000;
|
||||
}
|
||||
|
||||
.terminal-scroll::-webkit-scrollbar-thumb {
|
||||
background: rgba(0, 255, 65, 0.4);
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.terminal-scroll::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(0, 255, 65, 0.6);
|
||||
}
|
||||
|
||||
/* ============================
|
||||
Cyberpunk Grid Background
|
||||
============================ */
|
||||
|
||||
.cyber-grid {
|
||||
background-color: rgb(var(--cyber-bg-primary));
|
||||
background-image:
|
||||
linear-gradient(rgb(var(--cyber-neon-cyan) / 0.03) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgb(var(--cyber-neon-cyan) / 0.03) 1px, transparent 1px),
|
||||
radial-gradient(ellipse at 50% 0%, rgb(var(--cyber-neon-cyan) / 0.06) 0%, transparent 60%);
|
||||
background-size: 50px 50px, 50px 50px, 100% 100%;
|
||||
background-position: -1px -1px, -1px -1px, center top;
|
||||
}
|
||||
|
||||
.dark .cyber-grid {
|
||||
background-image:
|
||||
linear-gradient(rgba(0, 255, 255, 0.02) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgba(0, 255, 255, 0.02) 1px, transparent 1px),
|
||||
radial-gradient(ellipse at 50% 0%, rgba(0, 255, 255, 0.08) 0%, transparent 60%);
|
||||
}
|
||||
|
||||
/* ============================
|
||||
Glassmorphism Effects
|
||||
============================ */
|
||||
|
||||
.glass-panel {
|
||||
background: rgb(var(--glass-bg));
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid rgb(var(--glass-border));
|
||||
}
|
||||
|
||||
.glass-panel-dark {
|
||||
background: rgb(var(--glass-dark-bg));
|
||||
backdrop-filter: blur(16px);
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
border: 1px solid rgb(var(--glass-dark-border));
|
||||
}
|
||||
|
||||
.float-panel {
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 0 1px rgb(var(--cyber-neon-cyan) / 0.1);
|
||||
}
|
||||
|
||||
.dark .float-panel {
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 1px rgba(0, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
.elevated-panel {
|
||||
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.dark .elevated-panel {
|
||||
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
/* ============================
|
||||
Neon Glow Effects
|
||||
============================ */
|
||||
|
||||
/* Text glow - Light mode: subtle shadow, Dark mode: neon glow */
|
||||
.glow-text-cyan {
|
||||
text-shadow: 0 1px 3px rgb(var(--cyber-neon-cyan) / 0.3);
|
||||
}
|
||||
|
||||
.dark .glow-text-cyan {
|
||||
text-shadow:
|
||||
0 0 5px rgba(0, 255, 255, 0.8),
|
||||
0 0 10px rgba(0, 255, 255, 0.5),
|
||||
0 0 20px rgba(0, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
.glow-text-pink {
|
||||
text-shadow: 0 1px 3px rgb(var(--cyber-neon-pink) / 0.3);
|
||||
}
|
||||
|
||||
.dark .glow-text-pink {
|
||||
text-shadow:
|
||||
0 0 5px rgba(255, 0, 128, 0.8),
|
||||
0 0 10px rgba(255, 0, 128, 0.5),
|
||||
0 0 20px rgba(255, 0, 128, 0.3);
|
||||
}
|
||||
|
||||
.glow-text-green {
|
||||
text-shadow: 0 1px 3px rgb(var(--cyber-neon-green) / 0.3);
|
||||
}
|
||||
|
||||
.dark .glow-text-green {
|
||||
text-shadow:
|
||||
0 0 5px rgba(0, 255, 65, 0.8),
|
||||
0 0 10px rgba(0, 255, 65, 0.5),
|
||||
0 0 20px rgba(0, 255, 65, 0.3);
|
||||
}
|
||||
|
||||
/* Box glow - Light mode: subtle shadow, Dark mode: neon glow */
|
||||
.glow-cyan {
|
||||
box-shadow: 0 4px 12px rgb(var(--cyber-neon-cyan) / var(--shadow-glow-opacity));
|
||||
}
|
||||
|
||||
.dark .glow-cyan {
|
||||
box-shadow:
|
||||
0 0 5px rgba(0, 255, 255, 0.5),
|
||||
0 0 10px rgba(0, 255, 255, 0.3),
|
||||
0 0 20px rgba(0, 255, 255, 0.2),
|
||||
inset 0 0 5px rgba(0, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.glow-pink {
|
||||
box-shadow: 0 4px 12px rgb(var(--cyber-neon-pink) / var(--shadow-glow-opacity));
|
||||
}
|
||||
|
||||
.dark .glow-pink {
|
||||
box-shadow:
|
||||
0 0 5px rgba(255, 0, 128, 0.5),
|
||||
0 0 10px rgba(255, 0, 128, 0.3),
|
||||
0 0 20px rgba(255, 0, 128, 0.2);
|
||||
}
|
||||
|
||||
.glow-green {
|
||||
box-shadow: 0 4px 12px rgb(var(--cyber-neon-green) / var(--shadow-glow-opacity));
|
||||
}
|
||||
|
||||
.dark .glow-green {
|
||||
box-shadow:
|
||||
0 0 5px rgba(0, 255, 65, 0.5),
|
||||
0 0 10px rgba(0, 255, 65, 0.3),
|
||||
0 0 20px rgba(0, 255, 65, 0.2);
|
||||
}
|
||||
|
||||
/* ============================
|
||||
Corner Decorations
|
||||
============================ */
|
||||
|
||||
.cyber-corner {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.cyber-corner::before,
|
||||
.cyber-corner::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.cyber-corner::before {
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
border-top: 2px solid rgb(var(--cyber-neon-cyan) / 0.5);
|
||||
border-left: 2px solid rgb(var(--cyber-neon-cyan) / 0.5);
|
||||
}
|
||||
|
||||
.cyber-corner::after {
|
||||
bottom: -1px;
|
||||
right: -1px;
|
||||
border-bottom: 2px solid rgb(var(--cyber-neon-cyan) / 0.5);
|
||||
border-right: 2px solid rgb(var(--cyber-neon-cyan) / 0.5);
|
||||
}
|
||||
|
||||
/* Four corners variant */
|
||||
.cyber-corners {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.cyber-corners::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background:
|
||||
linear-gradient(to right, rgb(var(--cyber-neon-cyan) / 0.5) 12px, transparent 12px) 0 0,
|
||||
linear-gradient(to right, rgb(var(--cyber-neon-cyan) / 0.5) 12px, transparent 12px) 0 100%,
|
||||
linear-gradient(to left, rgb(var(--cyber-neon-cyan) / 0.5) 12px, transparent 12px) 100% 0,
|
||||
linear-gradient(to left, rgb(var(--cyber-neon-cyan) / 0.5) 12px, transparent 12px) 100% 100%,
|
||||
linear-gradient(to bottom, rgb(var(--cyber-neon-cyan) / 0.5) 12px, transparent 12px) 0 0,
|
||||
linear-gradient(to bottom, rgb(var(--cyber-neon-cyan) / 0.5) 12px, transparent 12px) 100% 0,
|
||||
linear-gradient(to top, rgb(var(--cyber-neon-cyan) / 0.5) 12px, transparent 12px) 0 100%,
|
||||
linear-gradient(to top, rgb(var(--cyber-neon-cyan) / 0.5) 12px, transparent 12px) 100% 100%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 2px 12px, 2px 12px, 2px 12px, 2px 12px, 12px 2px, 12px 2px, 12px 2px, 12px 2px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* ============================
|
||||
Card Hover Effects
|
||||
============================ */
|
||||
|
||||
/* Scan effect on hover */
|
||||
.card-scan {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card-scan::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
rgb(var(--cyber-neon-cyan) / 0.1),
|
||||
transparent
|
||||
);
|
||||
transition: left 0.6s ease-in-out;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.card-scan:hover::after {
|
||||
left: 100%;
|
||||
}
|
||||
|
||||
/* ============================
|
||||
Cursor Blink
|
||||
============================ */
|
||||
|
||||
.cursor-blink {
|
||||
animation: cursorBlink 1s step-end infinite;
|
||||
}
|
||||
|
||||
@keyframes cursorBlink {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0; }
|
||||
}
|
||||
|
||||
/* ============================
|
||||
Status Indicators
|
||||
============================ */
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.status-dot-online {
|
||||
background: rgb(var(--cyber-neon-green));
|
||||
box-shadow: 0 0 8px rgb(var(--cyber-neon-green) / 0.6);
|
||||
animation: pulseGlow 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.status-dot-offline {
|
||||
background: rgb(var(--cyber-text-muted));
|
||||
}
|
||||
|
||||
.status-dot-warning {
|
||||
background: rgb(var(--cyber-neon-orange));
|
||||
box-shadow: 0 0 8px rgb(var(--cyber-neon-orange) / 0.6);
|
||||
}
|
||||
|
||||
.status-dot-error {
|
||||
background: rgb(var(--cyber-neon-pink));
|
||||
box-shadow: 0 0 8px rgb(var(--cyber-neon-pink) / 0.6);
|
||||
}
|
||||
|
||||
@keyframes pulseGlow {
|
||||
0%, 100% {
|
||||
box-shadow: 0 0 5px currentColor;
|
||||
}
|
||||
50% {
|
||||
box-shadow: 0 0 15px currentColor, 0 0 25px currentColor;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================
|
||||
Input Focus Ring
|
||||
============================ */
|
||||
|
||||
.cyber-focus {
|
||||
transition: box-shadow 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.cyber-focus:focus {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 1px rgb(var(--cyber-neon-cyan)), 0 0 10px rgb(var(--cyber-neon-cyan) / 0.3);
|
||||
border-color: rgb(var(--cyber-neon-cyan));
|
||||
}
|
||||
|
||||
/* ============================
|
||||
Selection
|
||||
============================ */
|
||||
|
||||
::selection {
|
||||
background: rgb(var(--cyber-neon-cyan) / 0.3);
|
||||
color: rgb(var(--cyber-text-primary));
|
||||
}
|
||||
|
||||
::-moz-selection {
|
||||
background: rgb(var(--cyber-neon-cyan) / 0.3);
|
||||
color: rgb(var(--cyber-text-primary));
|
||||
}
|
||||
|
||||
/* ============================
|
||||
Performance Optimizations
|
||||
============================ */
|
||||
|
||||
.will-change-transform {
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.gpu-accelerate {
|
||||
transform: translateZ(0);
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
25
webui/src/main.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import App from './App'
|
||||
import './index.css'
|
||||
import './i18n'
|
||||
// Initialize theme store early to prevent flash of wrong theme
|
||||
import './store/themeStore'
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
refetchOnWindowFocus: false,
|
||||
retry: 1,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<App />
|
||||
</QueryClientProvider>
|
||||
</React.StrictMode>,
|
||||
)
|
||||
153
webui/src/store/crawlerStore.ts
Normal file
@@ -0,0 +1,153 @@
|
||||
import { create } from 'zustand'
|
||||
import type { LogEntry, CrawlerConfig } from '@/types/crawler'
|
||||
|
||||
interface CrawlerState {
|
||||
// Status
|
||||
status: 'idle' | 'running' | 'stopping' | 'error'
|
||||
platform: string | null
|
||||
crawlerType: string | null
|
||||
startedAt: string | null
|
||||
|
||||
// Logs
|
||||
logs: LogEntry[]
|
||||
clearedAfterLogId: number | null // 清除日志后,只显示 id 大于此值的日志
|
||||
|
||||
// Config
|
||||
config: CrawlerConfig
|
||||
|
||||
// Actions
|
||||
setStatus: (status: CrawlerState['status']) => void
|
||||
setRunningInfo: (platform: string | null, crawlerType: string | null, startedAt: string | null) => void
|
||||
addLog: (log: LogEntry) => void
|
||||
setLogs: (logs: LogEntry[]) => void
|
||||
clearLogs: () => void
|
||||
restoreLogs: () => void
|
||||
updateConfig: (config: Partial<CrawlerConfig>) => void
|
||||
reset: () => void
|
||||
}
|
||||
|
||||
// 持久化相关的 localStorage key
|
||||
const CLEARED_LOG_ID_KEY = 'mediacrawler_cleared_log_id'
|
||||
|
||||
// 从 localStorage 读取清除标记
|
||||
function getClearedLogIdFromStorage(): number | null {
|
||||
const stored = localStorage.getItem(CLEARED_LOG_ID_KEY)
|
||||
if (stored === null) return null
|
||||
const value = parseInt(stored, 10)
|
||||
return isNaN(value) ? null : value
|
||||
}
|
||||
|
||||
// 保存清除标记到 localStorage
|
||||
function saveClearedLogIdToStorage(id: number | null): void {
|
||||
if (id === null) {
|
||||
localStorage.removeItem(CLEARED_LOG_ID_KEY)
|
||||
} else {
|
||||
localStorage.setItem(CLEARED_LOG_ID_KEY, id.toString())
|
||||
}
|
||||
}
|
||||
|
||||
const defaultConfig: CrawlerConfig = {
|
||||
platform: 'bili',
|
||||
login_type: 'qrcode',
|
||||
crawler_type: 'search',
|
||||
keywords: '',
|
||||
specified_ids: '',
|
||||
creator_ids: '',
|
||||
start_page: 1,
|
||||
enable_comments: true,
|
||||
enable_sub_comments: false,
|
||||
save_option: 'json',
|
||||
cookies: '',
|
||||
headless: false,
|
||||
}
|
||||
|
||||
export const useCrawlerStore = create<CrawlerState>((set, get) => ({
|
||||
status: 'idle',
|
||||
platform: null,
|
||||
crawlerType: null,
|
||||
startedAt: null,
|
||||
logs: [],
|
||||
clearedAfterLogId: getClearedLogIdFromStorage(), // 从 localStorage 初始化
|
||||
config: defaultConfig,
|
||||
|
||||
setStatus: (status) => {
|
||||
set({ status })
|
||||
// 当开始新的爬虫任务时,清除之前的清除标记
|
||||
if (status === 'running') {
|
||||
const currentClearedId = get().clearedAfterLogId
|
||||
if (currentClearedId !== null) {
|
||||
set({ clearedAfterLogId: null })
|
||||
saveClearedLogIdToStorage(null)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setRunningInfo: (platform, crawlerType, startedAt) => {
|
||||
set({ platform, crawlerType, startedAt })
|
||||
// 当设置新的运行信息时,也清除之前的清除标记
|
||||
if (startedAt !== null) {
|
||||
const currentClearedId = get().clearedAfterLogId
|
||||
if (currentClearedId !== null) {
|
||||
set({ clearedAfterLogId: null })
|
||||
saveClearedLogIdToStorage(null)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addLog: (log) => {
|
||||
const { clearedAfterLogId, logs } = get()
|
||||
// 如果有清除标记,过滤掉 id 小于等于该标记的日志
|
||||
if (clearedAfterLogId !== null && log.id <= clearedAfterLogId) {
|
||||
return
|
||||
}
|
||||
// 防止 WebSocket 重连/重复连接导致的重复日志
|
||||
if (logs.length > 0 && logs[logs.length - 1].id === log.id) {
|
||||
return
|
||||
}
|
||||
if (logs.some((existing) => existing.id === log.id)) {
|
||||
return
|
||||
}
|
||||
set((state) => ({
|
||||
logs: [...state.logs.slice(-499), log], // Keep last 500 logs
|
||||
}))
|
||||
},
|
||||
|
||||
setLogs: (logs) => {
|
||||
const { clearedAfterLogId } = get()
|
||||
// 如果有清除标记,过滤掉 id 小于等于该标记的日志
|
||||
const filteredLogs = clearedAfterLogId !== null
|
||||
? logs.filter((log) => log.id > clearedAfterLogId)
|
||||
: logs
|
||||
set({ logs: filteredLogs })
|
||||
},
|
||||
|
||||
clearLogs: () => {
|
||||
const { logs } = get()
|
||||
// 记录当前最大的 log id,清除后只显示比这个 id 大的日志
|
||||
const maxLogId = logs.length > 0 ? Math.max(...logs.map(l => l.id)) : 0
|
||||
set({ logs: [], clearedAfterLogId: maxLogId })
|
||||
// 持久化到 localStorage
|
||||
saveClearedLogIdToStorage(maxLogId)
|
||||
},
|
||||
|
||||
restoreLogs: () => {
|
||||
// 清除清除标记,这样下次重新加载日志时就会显示所有日志
|
||||
set({ clearedAfterLogId: null })
|
||||
saveClearedLogIdToStorage(null)
|
||||
// 触发日志重新加载(通过刷新页面或重新连接 WebSocket)
|
||||
window.location.reload()
|
||||
},
|
||||
|
||||
updateConfig: (config) =>
|
||||
set((state) => ({
|
||||
config: { ...state.config, ...config },
|
||||
})),
|
||||
|
||||
reset: () =>
|
||||
set({
|
||||
status: 'idle',
|
||||
platform: null,
|
||||
crawlerType: null,
|
||||
startedAt: null,
|
||||
}),
|
||||
}))
|
||||
69
webui/src/store/themeStore.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { create } from 'zustand'
|
||||
|
||||
type Theme = 'light' | 'dark' | 'system'
|
||||
|
||||
interface ThemeState {
|
||||
theme: Theme
|
||||
resolvedTheme: 'light' | 'dark'
|
||||
setTheme: (theme: Theme) => void
|
||||
}
|
||||
|
||||
const THEME_KEY = 'mediacrawler_theme'
|
||||
|
||||
function getSystemTheme(): 'light' | 'dark' {
|
||||
if (typeof window === 'undefined') return 'light'
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
||||
}
|
||||
|
||||
function getStoredTheme(): Theme {
|
||||
if (typeof window === 'undefined') return 'light'
|
||||
const stored = localStorage.getItem(THEME_KEY) as Theme | null
|
||||
if (stored && ['light', 'dark', 'system'].includes(stored)) {
|
||||
return stored
|
||||
}
|
||||
return 'light' // Default to light
|
||||
}
|
||||
|
||||
function applyTheme(resolved: 'light' | 'dark') {
|
||||
const root = document.documentElement
|
||||
if (resolved === 'dark') {
|
||||
root.classList.add('dark')
|
||||
} else {
|
||||
root.classList.remove('dark')
|
||||
}
|
||||
}
|
||||
|
||||
function resolveTheme(theme: Theme): 'light' | 'dark' {
|
||||
return theme === 'system' ? getSystemTheme() : theme
|
||||
}
|
||||
|
||||
// Initialize theme immediately to prevent flash
|
||||
const initialTheme = getStoredTheme()
|
||||
const initialResolved = resolveTheme(initialTheme)
|
||||
if (typeof window !== 'undefined') {
|
||||
applyTheme(initialResolved)
|
||||
}
|
||||
|
||||
export const useThemeStore = create<ThemeState>((set) => ({
|
||||
theme: initialTheme,
|
||||
resolvedTheme: initialResolved,
|
||||
|
||||
setTheme: (theme) => {
|
||||
const resolved = resolveTheme(theme)
|
||||
localStorage.setItem(THEME_KEY, theme)
|
||||
applyTheme(resolved)
|
||||
set({ theme, resolvedTheme: resolved })
|
||||
},
|
||||
}))
|
||||
|
||||
// Listen for system theme changes
|
||||
if (typeof window !== 'undefined') {
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
|
||||
const state = useThemeStore.getState()
|
||||
if (state.theme === 'system') {
|
||||
const resolved = e.matches ? 'dark' : 'light'
|
||||
applyTheme(resolved)
|
||||
useThemeStore.setState({ resolvedTheme: resolved })
|
||||
}
|
||||
})
|
||||
}
|
||||
49
webui/src/types/crawler.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
export interface CrawlerConfig {
|
||||
platform: string
|
||||
login_type: string
|
||||
crawler_type: string
|
||||
keywords: string
|
||||
specified_ids: string // 详情模式下的帖子/视频ID
|
||||
creator_ids: string // 创作者模式下的创作者ID
|
||||
start_page: number
|
||||
enable_comments: boolean
|
||||
enable_sub_comments: boolean
|
||||
save_option: string
|
||||
cookies: string
|
||||
headless: boolean
|
||||
}
|
||||
|
||||
export interface CrawlerStatus {
|
||||
status: 'idle' | 'running' | 'stopping' | 'error'
|
||||
platform: string | null
|
||||
crawler_type: string | null
|
||||
started_at: string | null
|
||||
error_message: string | null
|
||||
}
|
||||
|
||||
export interface LogEntry {
|
||||
id: number
|
||||
timestamp: string
|
||||
level: 'info' | 'warning' | 'error' | 'success' | 'debug'
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface DataFile {
|
||||
name: string
|
||||
path: string
|
||||
size: number
|
||||
modified_at: number
|
||||
record_count: number | null
|
||||
type: string
|
||||
}
|
||||
|
||||
export interface Platform {
|
||||
value: string
|
||||
label: string
|
||||
icon: string
|
||||
}
|
||||
|
||||
export interface ConfigOption {
|
||||
value: string
|
||||
label: string
|
||||
}
|
||||
1
webui/src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
158
webui/tailwind.config.ts
Normal file
@@ -0,0 +1,158 @@
|
||||
import type { Config } from 'tailwindcss'
|
||||
|
||||
const config: Config = {
|
||||
darkMode: ['class'],
|
||||
content: [
|
||||
'./index.html',
|
||||
'./src/**/*.{js,ts,jsx,tsx}',
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
// Cyberpunk color scheme using CSS variables
|
||||
cyber: {
|
||||
// Background colors
|
||||
bg: {
|
||||
primary: 'rgb(var(--cyber-bg-primary) / <alpha-value>)',
|
||||
secondary: 'rgb(var(--cyber-bg-secondary) / <alpha-value>)',
|
||||
tertiary: 'rgb(var(--cyber-bg-tertiary) / <alpha-value>)',
|
||||
panel: 'rgb(var(--cyber-bg-panel) / <alpha-value>)',
|
||||
elevated: 'rgb(var(--cyber-bg-elevated) / <alpha-value>)',
|
||||
glass: 'rgb(var(--glass-bg))',
|
||||
glassDark: 'rgb(var(--glass-dark-bg))',
|
||||
},
|
||||
// Neon colors
|
||||
neon: {
|
||||
cyan: 'rgb(var(--cyber-neon-cyan) / <alpha-value>)',
|
||||
cyanDim: 'rgb(var(--cyber-neon-cyan-dim) / <alpha-value>)',
|
||||
pink: 'rgb(var(--cyber-neon-pink) / <alpha-value>)',
|
||||
pinkDim: 'rgb(var(--cyber-neon-pink-dim) / <alpha-value>)',
|
||||
green: 'rgb(var(--cyber-neon-green) / <alpha-value>)',
|
||||
greenDim: 'rgb(var(--cyber-neon-green-dim) / <alpha-value>)',
|
||||
orange: 'rgb(var(--cyber-neon-orange) / <alpha-value>)',
|
||||
yellow: 'rgb(var(--cyber-neon-yellow) / <alpha-value>)',
|
||||
purple: 'rgb(var(--cyber-neon-purple) / <alpha-value>)',
|
||||
},
|
||||
// Text colors
|
||||
text: {
|
||||
primary: 'rgb(var(--cyber-text-primary) / <alpha-value>)',
|
||||
secondary: 'rgb(var(--cyber-text-secondary) / <alpha-value>)',
|
||||
muted: 'rgb(var(--cyber-text-muted) / <alpha-value>)',
|
||||
},
|
||||
// Border colors
|
||||
border: {
|
||||
DEFAULT: 'rgb(var(--cyber-border-default) / <alpha-value>)',
|
||||
glow: 'rgb(var(--cyber-border-glow) / <alpha-value>)',
|
||||
subtle: 'rgb(var(--cyber-border-subtle) / <alpha-value>)',
|
||||
},
|
||||
},
|
||||
// Keep semantic colors for compatibility
|
||||
border: 'hsl(var(--border))',
|
||||
input: 'hsl(var(--input))',
|
||||
ring: 'hsl(var(--ring))',
|
||||
background: 'hsl(var(--background))',
|
||||
foreground: 'hsl(var(--foreground))',
|
||||
primary: {
|
||||
DEFAULT: 'hsl(var(--primary))',
|
||||
foreground: 'hsl(var(--primary-foreground))',
|
||||
},
|
||||
secondary: {
|
||||
DEFAULT: 'hsl(var(--secondary))',
|
||||
foreground: 'hsl(var(--secondary-foreground))',
|
||||
},
|
||||
destructive: {
|
||||
DEFAULT: 'hsl(var(--destructive))',
|
||||
foreground: 'hsl(var(--destructive-foreground))',
|
||||
},
|
||||
muted: {
|
||||
DEFAULT: 'hsl(var(--muted))',
|
||||
foreground: 'hsl(var(--muted-foreground))',
|
||||
},
|
||||
accent: {
|
||||
DEFAULT: 'hsl(var(--accent))',
|
||||
foreground: 'hsl(var(--accent-foreground))',
|
||||
},
|
||||
popover: {
|
||||
DEFAULT: 'hsl(var(--popover))',
|
||||
foreground: 'hsl(var(--popover-foreground))',
|
||||
},
|
||||
card: {
|
||||
DEFAULT: 'hsl(var(--card))',
|
||||
foreground: 'hsl(var(--card-foreground))',
|
||||
},
|
||||
},
|
||||
fontFamily: {
|
||||
sans: ['Inter', 'system-ui', 'sans-serif'],
|
||||
mono: ['JetBrains Mono', 'Fira Code', 'Consolas', 'monospace'],
|
||||
},
|
||||
boxShadow: {
|
||||
// Neon glow shadows - these use CSS variables for theme support
|
||||
'glow-cyan': '0 0 var(--shadow-glow-spread, 10px) rgb(var(--cyber-neon-cyan) / var(--shadow-glow-opacity, 0.5)), 0 0 calc(var(--shadow-glow-spread, 10px) * 2) rgb(var(--cyber-neon-cyan) / calc(var(--shadow-glow-opacity, 0.5) * 0.6)), 0 0 calc(var(--shadow-glow-spread, 10px) * 3) rgb(var(--cyber-neon-cyan) / calc(var(--shadow-glow-opacity, 0.5) * 0.2))',
|
||||
'glow-cyan-sm': '0 0 5px rgb(var(--cyber-neon-cyan) / 0.4), 0 0 10px rgb(var(--cyber-neon-cyan) / 0.2)',
|
||||
'glow-pink': '0 0 var(--shadow-glow-spread, 10px) rgb(var(--cyber-neon-pink) / var(--shadow-glow-opacity, 0.5)), 0 0 calc(var(--shadow-glow-spread, 10px) * 2) rgb(var(--cyber-neon-pink) / calc(var(--shadow-glow-opacity, 0.5) * 0.6))',
|
||||
'glow-pink-sm': '0 0 5px rgb(var(--cyber-neon-pink) / 0.4), 0 0 10px rgb(var(--cyber-neon-pink) / 0.2)',
|
||||
'glow-green': '0 0 var(--shadow-glow-spread, 10px) rgb(var(--cyber-neon-green) / var(--shadow-glow-opacity, 0.5)), 0 0 calc(var(--shadow-glow-spread, 10px) * 2) rgb(var(--cyber-neon-green) / calc(var(--shadow-glow-opacity, 0.5) * 0.6))',
|
||||
'glow-green-sm': '0 0 5px rgb(var(--cyber-neon-green) / 0.4), 0 0 10px rgb(var(--cyber-neon-green) / 0.2)',
|
||||
'glow-orange': '0 0 var(--shadow-glow-spread, 10px) rgb(var(--cyber-neon-orange) / var(--shadow-glow-opacity, 0.5)), 0 0 calc(var(--shadow-glow-spread, 10px) * 2) rgb(var(--cyber-neon-orange) / calc(var(--shadow-glow-opacity, 0.5) * 0.6))',
|
||||
'cyber-card': '0 0 1px rgb(var(--cyber-neon-cyan) / 0.5), 0 4px 20px rgba(0, 0, 0, 0.3)',
|
||||
'cyber-inset': 'inset 0 0 20px rgba(0, 0, 0, 0.5)',
|
||||
// Soft shadows for glassmorphism
|
||||
'cyber-soft': '0 4px 24px rgba(0, 0, 0, 0.2), 0 0 1px rgb(var(--cyber-neon-cyan) / 0.1)',
|
||||
'cyber-float': '0 8px 32px rgba(0, 0, 0, 0.25), 0 0 1px rgb(var(--cyber-neon-cyan) / 0.15)',
|
||||
'cyber-elevated': '0 12px 40px rgba(0, 0, 0, 0.3)',
|
||||
},
|
||||
animation: {
|
||||
'slide-up': 'slideUp 0.3s ease-out forwards',
|
||||
'pulse-fast': 'pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
||||
'pulse-glow': 'pulseGlow 2s ease-in-out infinite',
|
||||
'scanline': 'scanline 8s linear infinite',
|
||||
'cursor-blink': 'cursorBlink 1s step-end infinite',
|
||||
'border-glow': 'borderGlow 3s linear infinite',
|
||||
'accordion-down': 'accordion-down 0.2s ease-out',
|
||||
'accordion-up': 'accordion-up 0.2s ease-out',
|
||||
},
|
||||
keyframes: {
|
||||
slideUp: {
|
||||
from: { opacity: '0', transform: 'translateY(10px)' },
|
||||
to: { opacity: '1', transform: 'translateY(0)' },
|
||||
},
|
||||
pulseGlow: {
|
||||
'0%, 100%': {
|
||||
boxShadow: '0 0 5px rgb(var(--cyber-neon-cyan) / 0.5), 0 0 10px rgb(var(--cyber-neon-cyan) / 0.3)'
|
||||
},
|
||||
'50%': {
|
||||
boxShadow: '0 0 15px rgb(var(--cyber-neon-cyan) / 0.8), 0 0 25px rgb(var(--cyber-neon-cyan) / 0.5), 0 0 35px rgb(var(--cyber-neon-cyan) / 0.3)'
|
||||
},
|
||||
},
|
||||
scanline: {
|
||||
'0%': { transform: 'translateY(-100%)' },
|
||||
'100%': { transform: 'translateY(100vh)' },
|
||||
},
|
||||
cursorBlink: {
|
||||
'0%, 100%': { opacity: '1' },
|
||||
'50%': { opacity: '0' },
|
||||
},
|
||||
borderGlow: {
|
||||
'0%, 100%': { borderColor: 'rgb(var(--cyber-neon-cyan) / 0.3)' },
|
||||
'50%': { borderColor: 'rgb(var(--cyber-neon-cyan) / 0.6)' },
|
||||
},
|
||||
'accordion-down': {
|
||||
from: { height: '0' },
|
||||
to: { height: 'var(--radix-accordion-content-height)' },
|
||||
},
|
||||
'accordion-up': {
|
||||
from: { height: 'var(--radix-accordion-content-height)' },
|
||||
to: { height: '0' },
|
||||
},
|
||||
},
|
||||
borderRadius: {
|
||||
lg: 'var(--radius)',
|
||||
md: 'calc(var(--radius) - 2px)',
|
||||
sm: 'calc(var(--radius) - 4px)',
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [require('tailwindcss-animate')],
|
||||
}
|
||||
|
||||
export default config
|
||||
26
webui/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
26
webui/vite.config.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import path from 'path'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: '../api/webui',
|
||||
emptyOutDir: true,
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8080',
|
||||
changeOrigin: true,
|
||||
ws: true, // 启用 WebSocket 代理
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||