[
  {
    "path": ".eslintignore",
    "content": "dist\npublic\nsrc-tauri\n.vscode\n.github\n"
  },
  {
    "path": ".eslintrc",
    "content": "{\n  \"extends\": \"@antfu\"\n}\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "# 可选，将显示在 GitHub 存储库的“操作”选项卡中的工作流名称\nname: Release CI\n\n# 指定此工作流的触发器\non:\n  push:\n    # 匹配特定标签 (refs/tags)\n    tags:\n      - 'v*' # 推送事件匹配 v*, 例如 v1.0，v20.15.10 等来触发工作流\n\n# 需要运行的作业组合\njobs:\n  # 任务：创建 release 版本\n  create-release:\n    runs-on: ubuntu-latest\n    outputs:\n      RELEASE_UPLOAD_ID: ${{ steps.create_release.outputs.id }}\n\n    steps:\n      - uses: actions/checkout@v2\n      # 查询版本号（tag）\n      - name: Query version number\n        id: get_version\n        shell: bash\n        run: |\n          echo \"using version tag ${GITHUB_REF:10}\"\n          echo ::set-output name=version::\"${GITHUB_REF:10}\"\n      # 根据查询到的版本号创建 release\n      - name: Create Release\n        id: create_release\n        uses: actions/create-release@v1\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          tag_name: '${{ steps.get_version.outputs.VERSION }}'\n          release_name: 'app ${{ steps.get_version.outputs.VERSION }}'\n          body: 'See the assets to download this version and install.'\n\n  # 编译 Tauri\n  build-tauri:\n    needs: create-release\n    strategy:\n      fail-fast: false\n      matrix:\n        platform: [macos-latest, ubuntu-latest, windows-latest]\n\n    runs-on: ${{ matrix.platform }}\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n\n      - name: Install Node.js\n        uses: actions/setup-node@v3\n        with:\n          node-version: 16\n\n      - name: install dependencies (ubuntu only)\n        if: matrix.platform == 'ubuntu-latest'\n        run: |\n          sudo apt-get update\n          sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf\n\n      - uses: pnpm/action-setup@v2.0.1\n        name: Install pnpm\n        id: pnpm-install\n        with:\n          version: 7\n          run_install: false\n\n      - name: Get pnpm store directory\n        id: pnpm-cache\n        run: |\n          echo \"::set-output name=pnpm_cache_dir::$(pnpm store path)\"\n\n      - uses: actions/cache@v3\n        name: Setup pnpm cache\n        with:\n          path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}\n          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}\n          restore-keys: |\n            ${{ runner.os }}-pnpm-store-\n\n      - name: install Rust stable\n        uses: actions-rs/toolchain@v1\n        with:\n          toolchain: stable\n\n      - name: Install dependencies and build\n        run: pnpm install && pnpm build\n      - uses: tauri-apps/tauri-action@v0\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          tagName: v__VERSION__ # the action automatically replaces \\_\\_VERSION\\_\\_ with the app version\n          releaseName: \"App v__VERSION__\"\n          releaseBody: \"See the assets to download this version and install.\"\n          releaseDraft: true\n          prerelease: false\n"
  },
  {
    "path": ".gitignore",
    "content": "# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\npnpm-debug.log*\nlerna-debug.log*\n\nnode_modules\ndist\ndist-ssr\n*.local\n\n# Editor directories and files\n.vscode/*\n!.vscode/extensions.json\n!.vscode/settings.json\n.idea\n.DS_Store\n*.suo\n*.ntvs*\n*.njsproj\n*.sln\n*.sw?\n*.sublime-workspace\n\n# auto import\nsrc/auto-imports.d.ts\nsrc/components.d.ts\n"
  },
  {
    "path": ".vscode/extensions.json",
    "content": "{\n  \"recommendations\": [\"Vue.volar\"]\n}\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "{\n    \"editor.codeActionsOnSave\": {\n        \"source.fixAll.eslint\": true\n    },\n    \"files.associations\": {\n        \"*.css\": \"postcss\"\n    },\n    \"editor.formatOnSave\": false\n}"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU AFFERO GENERAL PUBLIC LICENSE\n                       Version 3, 19 November 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU Affero General Public License is a free, copyleft license for\nsoftware and other kinds of works, specifically designed to ensure\ncooperation with the community in the case of network server software.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nour General Public Licenses are intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  Developers that use our General Public Licenses protect your rights\nwith two steps: (1) assert copyright on the software, and (2) offer\nyou this License which gives you legal permission to copy, distribute\nand/or modify the software.\n\n  A secondary benefit of defending all users' freedom is that\nimprovements made in alternate versions of the program, if they\nreceive widespread use, become available for other developers to\nincorporate.  Many developers of free software are heartened and\nencouraged by the resulting cooperation.  However, in the case of\nsoftware used on network servers, this result may fail to come about.\nThe GNU General Public License permits making a modified version and\nletting the public access it on a server without ever releasing its\nsource code to the public.\n\n  The GNU Affero General Public License is designed specifically to\nensure that, in such cases, the modified source code becomes available\nto the community.  It requires the operator of a network server to\nprovide the source code of the modified version running there to the\nusers of that server.  Therefore, public use of a modified version, on\na publicly accessible server, gives the public access to the source\ncode of the modified version.\n\n  An older license, called the Affero General Public License and\npublished by Affero, was designed to accomplish similar goals.  This is\na different license, not a version of the Affero GPL, but Affero has\nreleased a new version of the Affero GPL which permits relicensing under\nthis license.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU Affero General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Remote Network Interaction; Use with the GNU General Public License.\n\n  Notwithstanding any other provision of this License, if you modify the\nProgram, your modified version must prominently offer all users\ninteracting with it remotely through a computer network (if your version\nsupports such interaction) an opportunity to receive the Corresponding\nSource of your version by providing access to the Corresponding Source\nfrom a network server at no charge, through some standard or customary\nmeans of facilitating copying of software.  This Corresponding Source\nshall include the Corresponding Source for any work covered by version 3\nof the GNU General Public License that is incorporated pursuant to the\nfollowing paragraph.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the work with which it is combined will remain governed by version\n3 of the GNU General Public License.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU Affero General Public License from time to time.  Such new versions\nwill be similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU Affero General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU Affero General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU Affero General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Affero General Public License as published\n    by the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Affero General Public License for more details.\n\n    You should have received a copy of the GNU Affero General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If your software can interact with users remotely through a computer\nnetwork, you should also make sure that it provides a way for users to\nget its source.  For example, if your program is a web application, its\ninterface could display a \"Source\" link that leads users to an archive\nof the code.  There are many ways you could offer source, and different\nsolutions will be better for different programs; see section 13 for the\nspecific requirements.\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU AGPL, see\n<https://www.gnu.org/licenses/>.\n"
  },
  {
    "path": "README.md",
    "content": "# D4nm4ku\n\n![](https://img.shields.io/github/workflow/status/widcardw/D4nm4ku/Release%20CI) ![](https://img.shields.io/github/downloads/widcardw/D4nm4ku/total)\n\n使用 Tauri 和 Vue 实现一个弹幕姬。\n\n> 后续会考虑使用 rust 作为后端来接收弹幕，而前端仅做数据的显示。目前时间和精力不是很足，因此暂时先搁置。\n\n## 下载 APP\n\n至 [release](https://github.com/widcardw/D4nm4ku/releases) 页面下载\n\n| Platform | Installer |\n|:--------:|:-------:|\n| Windows | D4nm4ku_version_x64_en-US.msi |\n| macOS Apple Silicon | D4nm4ku_version_aarch64.dmg |\n| macOS Intel x64 | D4nm4ku_version_x64.dmg |\n| Linux | d4nm4ku_version_amd64.deb <br> d4nm4ku_version_amd64.AppImage |\n\n## 构建\n\n```sh\npnpm install\npnpm tauri dev      # dev\npnpm tauri build    # build\n```\n\n## 功能预想\n\n### 弹幕部分\n\n#### 弹幕\n\n- [x] 主要：用户头像，用户名，弹幕内容，礼物，人气\n- [ ] 可选：\n    - [x] 用户等级\n    - [x] 谁的舰长\n    - [ ] 是否为粉丝\n    - [x] 入场\n    - [x] 关注主播\n\n#### 主播回复\n\n- [x] 主动输入回复\n- [x] 关键字触发回复\n    - [x] 使用队列存储\n        - 好像用不着了？\n    - [x] 通过关键字 Hash ，不再回复一段时间内已经重复的内容（设置回复内容的 TTL ）\n    - [x] 过长的弹幕需要分段延迟回复\n\n#### 扩展功能\n\n- [x] 醒目留言\n- [x] 可选：是否只显示付费礼物，礼物金额，礼物连击（可能稍微有一点问题，或许还是在队列里面写）\n- [ ] 可选：语音播报（感谢 xxx 的礼物，关注主播，等等）\n- [ ] 弹幕投票\n\n### 其他\n\n- [x] 优化登录界面\n- [ ] 不知道有没有自动验证的 API ，这样登录一次就不用再次登录了\n    - 好像是定时失效的吧，这就不管了，能用就行\n- [x] 将弹幕窗口化\n- [x] 添加配置\n    - [x] 窗口背景色\n    - [x] 窗口透明度\n    - [x] 弹幕文字颜色\n    - [x] 舰长加背景色（或者文字颜色）\n    - [x] 可隐藏头像\n    - [x] 可隐藏时间\n    - [ ] 粉丝加背景色\n    - [ ] 考虑要不要加原生 API 的毛玻璃效果\n        - 来自 tauri 的 API [`run_on_main_thread`](https://docs.rs/tauri/1.1.1/tauri/struct.AppHandle.html#method.run_on_main_thread) 和插件 [window-vibrancy](https://docs.rs/window-vibrancy/0.3.0/window_vibrancy/) 可以实现原生的毛玻璃效果\n- [ ] 优化界面\n    - [x] 考虑是否将启动小窗的界面合并到主界面\n        - 但是之前测试根目录组件使用带有 store 的组件会报错，说 pinia 未定义\n    - [ ] 设置界面\n        - 或许还要加一些功能\n- [x] 开播\n    - [x] 更改直播间标题\n    - [x] 开播\n- [ ] 窗口\n    - [x] 置顶\n    - [x] 保存和加载窗口的位置和大小\n    - [ ] 点击穿透（在 [tao](https://docs.rs/tao/0.14.0/tao/) 的 [API](https://docs.rs/tao/0.14.0/tao/window/struct.Window.html#method.set_ignore_cursor_events) 中已经有了，但是没有开放到 tauri 中）\n        - [ ] tauri 的 [issue](https://github.com/tauri-apps/tao/issues/184#issuecomment-1097109451) 中说要到 v2 时候才会正式公开这个 api\n        - [x] [#184-comment1](https://github.com/tauri-apps/tao/issues/184#issuecomment-1134823892) 给出了 macOS 的解决方案\n        - [ ] [#184-comment2](https://github.com/tauri-apps/tao/issues/184#issuecomment-1118176176) 给出了 Windows 的解决方案\n    - [ ] 将弹幕浏览器显示到所有桌面 (macOS) 详见 [#1](https://github.com/widcardw/D4nm4ku/issues/1)\n\n## 部分效果呈现\n\n### 基本功能\n\n![basic](./imgs/basic.png)\n\n### 自动回复\n\n![auto-reply](./imgs/auto-reply.png)\n\n### 开启直播\n\n![start-live](./imgs/start-live.png)\n"
  },
  {
    "path": "index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <link rel=\"icon\" type=\"image/svg+xml\" href=\"/vite.svg\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <meta name=\"referrer\" content=\"no-referrer\" />\n    <title>Vite + Vue + TS</title>\n  </head>\n  <body>\n    <script>\n      window.global = window\n    </script>\n    <div id=\"app\"></div>\n    <script type=\"module\" src=\"/src/main.ts\"></script>\n  </body>\n</html>\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"D4nm4ku\",\n  \"type\": \"module\",\n  \"version\": \"0.0.0\",\n  \"private\": true,\n  \"scripts\": {\n    \"dev\": \"vite\",\n    \"build\": \"vue-tsc --noEmit && vite build\",\n    \"preview\": \"vite preview\",\n    \"tauri\": \"tauri\",\n    \"lint\": \"eslint .\"\n  },\n  \"dependencies\": {\n    \"@tauri-apps/api\": \"^1.0.2\",\n    \"@vueuse/core\": \"^8.9.4\",\n    \"@vueuse/integrations\": \"^9.0.2\",\n    \"pinia\": \"^2.0.16\",\n    \"vue\": \"^3.2.37\",\n    \"vue-router\": \"^4.1.2\"\n  },\n  \"devDependencies\": {\n    \"@antfu/eslint-config\": \"^0.25.2\",\n    \"@iconify-json/ri\": \"^1.1.3\",\n    \"@tauri-apps/cli\": \"^1.0.4\",\n    \"@types/node\": \"^18.0.6\",\n    \"@types/qrcode\": \"^1.4.2\",\n    \"@unocss/preset-icons\": \"^0.44.5\",\n    \"@unocss/reset\": \"^0.44.5\",\n    \"@vitejs/plugin-vue\": \"^3.0.0\",\n    \"bilibili-live-ws\": \"^6.2.1\",\n    \"buffer\": \"^6.0.3\",\n    \"eslint\": \"^8.20.0\",\n    \"events\": \"^3.3.0\",\n    \"pako\": \"^2.0.4\",\n    \"qrcode\": \"^1.5.1\",\n    \"typescript\": \"^4.6.4\",\n    \"unocss\": \"^0.44.5\",\n    \"vite\": \"^3.0.0\",\n    \"vite-plugin-pages\": \"^0.25.0\",\n    \"vite-plugin-vue-layouts\": \"^0.6.0\",\n    \"vue-tsc\": \"^0.38.4\"\n  }\n}\n"
  },
  {
    "path": "src/App.vue",
    "content": "<script setup lang=\"ts\">\nimport { provide, ref } from 'vue'\nimport UMessageProvider from './components/ui/UMessageProvider.vue'\nimport { msgKey } from '~/composables/injectionKeys'\n// This starter template is using Vue 3 <script setup> SFCs\n// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup\nconst msgRef = ref<typeof UMessageProvider>()\nprovide(msgKey, msgRef)\n</script>\n\n<template>\n  <RouterView />\n  <UMessageProvider ref=\"msgRef\" />\n</template>\n"
  },
  {
    "path": "src/components/DarkMode.vue",
    "content": "<script setup lang=\"ts\">\nimport { isDark, toggleDark } from '~/composables/dark'\n</script>\n\n<template>\n  <div icon-btn @click=\"toggleDark()\">\n    <div v-if=\"!isDark\" i-ri-sun-line />\n    <div v-else i-ri-moon-line />\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/SideBar.vue",
    "content": "<script setup lang=\"ts\">\nimport { ref } from 'vue'\nimport { useRouter } from 'vue-router'\nimport DarkMode from './DarkMode.vue'\n\nconst router = useRouter()\n\nconst curPage = ref(1)\nconst routerSwitch = (target: string, page: number) => {\n  curPage.value = page\n  router.push(target)\n}\n</script>\n\n<template>\n  <div h-100vh flex flex-col fixed class=\"bg-#7f7f7f10\">\n    <div\n      m-2 icon-btn i-ri-home-line\n      :class=\"{ 'text-#646cff': curPage === 1 }\"\n      @click=\"routerSwitch('/', 1)\"\n    />\n    <div\n      m-2 icon-btn i-ri-settings-5-line\n      :class=\"{ 'text-#646cff': curPage === 2 }\"\n      @click=\"routerSwitch('/settings', 2)\"\n    />\n    <div\n      m-2 icon-btn i-ri-live-line\n      :class=\"{ 'text-#646cff': curPage === 3 }\"\n      @click=\"routerSwitch('/live', 3)\"\n    />\n    <div flex-1 />\n    <a href=\"https://github.com/widcardw/D4nm4ku\" target=\"_blank\" m-2 icon-btn>\n      <div i-ri-github-fill />\n    </a>\n    <DarkMode m-2 />\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/UWidget.vue",
    "content": "<script setup lang=\"ts\">\nimport { listen } from '@tauri-apps/api/event'\nimport { tryOnBeforeUnmount, useStorage } from '@vueuse/core'\nimport { inject } from 'vue'\nimport UMessageSender from './send/UMessageSender.vue'\nimport UInteraction from './danmaku/UInteraction.vue'\nimport USuperChatPool from '~/components/superchat/USuperChatPool.vue'\nimport { hex2rgb } from '~/composables/randomColor'\nimport {\n  chatPool,\n  connectRoom,\n  danmakuPool,\n  disconnectRoom,\n  enterQueue,\n  fans,\n  population,\n  selectedSc,\n} from '~/composables/server'\nimport { isGiftProps } from '~/composables/components'\nimport UWatch from '~/components/danmaku/UWatch.vue'\nimport URenderer from '~/components/danmaku/URenderer.vue'\nimport { useStore } from '~/stores/store'\nimport { getLiverInfo } from '~/composables/getLiverInfo'\nimport parseFanNumbers from '~/composables/parseFanNumbers'\nimport { msgKey } from '~/composables/injectionKeys'\n\nconst store = useStore()\nconst unlistens: Function[] = []\nconst msgRef = inject(msgKey)\n\nfunction parseBoolean(obj: string) {\n  return obj === 'true'\n}\n\nasync function initListens() {\n  unlistens.push(await listen('show-avatar', (event) => {\n    store.config.showAvatar = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('show-guard-tag', (event) => {\n    store.config.showGuardTag = parseInt(event.payload as string)\n  }))\n  unlistens.push(await listen('show-time', (event) => {\n    store.config.showTime = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('show-silver-gift', (event) => {\n    store.config.showSilverGift = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('show-gold-gift', (event) => {\n    store.config.showGoldGift = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('can-send-message', (event) => {\n    store.config.canSendMessage = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('text-color-changed', (event) => {\n    store.config.textColor = event.payload as string\n  }))\n  unlistens.push(await listen('text-shadow-color-changed', (event) => {\n    store.config.textShadowColor = event.payload as string\n  }))\n  unlistens.push(await listen('enable-text-shadow', (event) => {\n    store.config.enableTextShadow = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('bg-color-changed', (event) => {\n    store.config.bgColor = event.payload as string\n  }))\n  unlistens.push(await listen('bg-opacity-changed', (event) => {\n    store.config.bgOpacity = event.payload as string\n  }))\n  unlistens.push(await listen('show-population', (event) => {\n    store.config.showPopulation = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('blur', (event) => {\n    store.config.blur = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('layout', (event) => {\n    store.config.layout = event.payload as 'loose' | 'tight'\n  }))\n  unlistens.push(await listen('auto-reply', (event) => {\n    store.config.autoReply = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('show-highlight', (event) => {\n    store.config.showHighlight = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('show-enter', (event) => {\n    store.config.showEnter = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('show-subscribe', (event) => {\n    store.config.showSubscribe = parseBoolean(event.payload as string)\n  }))\n  unlistens.push(await listen('font-changed', (event) => {\n    store.config.fontFamily = event.payload as string\n  }))\n  unlistens.push(await listen('blacklist', (event) => {\n    store.config.blackList = JSON.parse(event.payload as string) as number[]\n  }))\n  unlistens.push(await listen('reset-config', (event) => {\n    store.config = JSON.parse(event.payload as string)\n  }))\n  unlistens.push(await listen('new-faq', (event) => {\n    store.faqs = JSON.parse(event.payload as string)\n  }))\n}\n\ninitListens()\nconnectRoom()\n\nconst roomId = useStorage('roomId', '')\n\ngetLiverInfo(Number.parseInt(roomId.value))\n  .then((res) => {\n    // console.log(res)\n    fans.value = parseFanNumbers(res)\n  })\n  .catch((err) => {\n    msgRef?.value.pushMsg(err.message, { type: 'error' })\n  })\n\ntryOnBeforeUnmount(() => {\n  unlistens.map(fn => fn())\n  disconnectRoom()\n})\n</script>\n\n<template>\n  <div\n    flex flex-col h-100vh\n    :class=\"{\n      'backdrop-blur-sm': store.getConfig.blur,\n    }\"\n    :style=\"{\n      background: hex2rgb(store.getConfig.bgColor, store.getConfig.bgOpacity),\n      color: store.getConfig.textColor,\n      textShadow: store.getConfig.enableTextShadow ? `1px 1px 1px ${store.getConfig.textShadowColor}` : 'none',\n      fontFamily: store.getConfig.fontFamily,\n    }\"\n  >\n    <UWatch\n      v-if=\"store.getConfig.showPopulation\"\n      data-tauri-drag-region shadow\n      :population=\"population\" :fans=\"fans\"\n    />\n    <USuperChatPool\n      v-if=\"store.getConfig.showHighlight\"\n      v-show=\"chatPool.length > 0\"\n      v-model=\"selectedSc\"\n      data-tauri-drag-region\n      :chat-pool=\"chatPool\" z-999 shadow\n    />\n    <TransitionGroup\n      tag=\"div\"\n      name=\"list\"\n      class=\"scroller\"\n      flex-1 of-y-auto\n      data-tauri-drag-region\n    >\n      <URenderer\n        v-for=\"it in danmakuPool\"\n        :key=\"`${it.ts}${it.uname}${it.type}${isGiftProps(it) ? it.giftId : ''}`\"\n        :obj=\"it\"\n      />\n    </TransitionGroup>\n    <TransitionGroup\n      v-if=\"enterQueue.length > 0 && store.getConfig.showEnter\"\n      tag=\"div\"\n      name=\"enter\"\n      class=\"h-2rem of-y-hidden\"\n    >\n      <UInteraction\n        :key=\"enterQueue[0].ts\"\n        type=\"interact\"\n        :action=\"enterQueue[0].action\"\n        :ts=\"enterQueue[0].ts\"\n        :uid=\"enterQueue[0].uid\"\n        :uname=\"enterQueue[0].uname\"\n        :uname-color=\"enterQueue[0].unameColor\"\n      />\n    </TransitionGroup>\n    <UMessageSender v-if=\"store.getConfig.canSendMessage\" :no-border=\"true\" />\n  </div>\n</template>\n\n<style scoped>\n::-webkit-scrollbar {\n  width: 0;\n  height: 0;\n}\n\n/* ::-webkit-scrollbar-thumb {\n  background: rgba(127, 127, 127, 0.5);\n  border-radius: 5px;\n} */\n.scroller {\n  overscroll-behavior-y: contain;\n  scroll-snap-type: y proximity;\n}\n.scroller > div:last-child {\n  scroll-snap-align: end;\n}\n/** {\n  pointer-events: v-bind(ct);\n}*/\n\n.list-move,\n.list-enter-active,\n.list-leave-active {\n  transition: all 0.25s ease;\n}\n.list-enter-from {\n  opacity: 0;\n  transform: translateX(30px);\n}\n.list-leave-to {\n  opacity: 0;\n}\n\n.enter-enter-active {\n  transition: all 0.125s ease;\n}\n.enter-enter-from {\n  opacity: 0;\n  transform: translateY(10px);\n}\n</style>\n\n"
  },
  {
    "path": "src/components/danmaku/UDanmaku.vue",
    "content": "<script setup lang=\"ts\">\nimport { confirm } from '@tauri-apps/api/dialog'\nimport { WebviewWindow } from '@tauri-apps/api/window'\nimport { inject, ref } from 'vue'\nimport MyImg from '../img/MyImg.vue'\nimport { guardType } from '~/composables/data'\nimport UGuardTag from '~/components/danmaku/UGuardTag.vue'\nimport Avatar from '~/components/img/Avatar.vue'\nimport { getAvatar2 } from '~/composables/getAvatar'\nimport { useStore } from '~/stores/store'\nimport { msgKey } from '~/composables/injectionKeys'\n\nconst props = withDefaults(defineProps<{\n  content: string\n  uname: string\n  color: string\n  level: number\n  label: string\n  tagColor: number\n  fang: number\n  perhapsGuard: 0 | 1 | 2 | 3\n  ts: number\n  uid: number\n  showAvatar?: boolean\n  showGuardTag?: boolean\n  showTime?: boolean\n  layout?: 'loose' | 'tight'\n}>(), {\n  showAvatar: true,\n  showGuardTag: true,\n  showTime: true,\n  layout: 'loose',\n})\n\nconst store = useStore()\n\nconst faceUrl = ref('')\n\nconst msgRef = inject(msgKey)\nconst urlIsBlob = ref(false)\n\nif (props.showAvatar) {\n// 异步获取头像的链接，默认为 noface，当加载出来后替换为真实头像\n  getAvatar2(props.uid)\n    .then(({ url, isBlob }) => {\n      faceUrl.value = url\n      urlIsBlob.value = isBlob\n    })\n    .catch((err: Error) => {\n      msgRef?.value.pushMsg(err.message, { type: 'error' })\n    })\n}\n\nasync function confirmAddingToBlacklist(e: Event) {\n  e.preventDefault()\n  const confirmed = await confirm(`确定将用户 \"${props.uname}\" (uid: ${props.uid}) 加入黑名单吗？`, {\n    title: '加入黑名单', type: 'warning',\n  })\n\n  if (confirmed) {\n    store.config.blackList.push(props.uid)\n    const mainWindow = WebviewWindow.getByLabel('main')\n    if (mainWindow)\n      mainWindow.emit('add-black', props.uid)\n  }\n}\n</script>\n\n<template>\n  <div @contextmenu=\"confirmAddingToBlacklist\">\n    <div v-if=\"layout === 'loose'\" flex space-x-2 w-full p=\"x-2 y-1\" my-2>\n      <!-- 头像 -->\n      <Avatar v-if=\"showAvatar\" w-3rem h-3rem :is-blob=\"urlIsBlob\" :src=\"faceUrl\" :uid=\"uid\" />\n      <div flex-1>\n        <div flex justify-between text-sm>\n          <div flex space-x-2>\n            <!-- 用户名 -->\n            <div leading-normal font-bold of-x-hidden wsn :style=\"{ color }\">\n              {{ uname }}\n            </div>\n            <span\n              v-if=\"store.liverId === uid\"\n              text=\"0.75rem amber\"\n              border=\"~ rounded amber\"\n              bg=\"amber/20\"\n              px-1\n            >主播</span>\n            <span\n              v-if=\"fang === 1\"\n              text=\"0.75rem amber\"\n              border=\"~ rounded amber\"\n              bg=\"amber/20\"\n              px=\"0.5\"\n            >房</span>\n            <!-- 等级标签 -->\n            <UGuardTag\n              v-if=\"level && showGuardTag && tagColor !== 12632256\"\n              :level=\"level\"\n              :label=\"label\"\n              :perhaps-guard=\"perhapsGuard\"\n              :tag-color=\"tagColor\"\n              shadow\n            />\n            <MyImg v-if=\"perhapsGuard !== 0 && level >= 20\" self-center :src=\"guardType[perhapsGuard].badge\" class=\"w-1.25rem h-1.25rem\" mx-1 rounded-full />\n          </div>\n          <!-- 弹幕发送时间 -->\n          <div v-if=\"showTime\" wsn ml-2>\n            {{ new Date(ts).toLocaleTimeString('en-US', {\n              hour: '2-digit',\n              minute: '2-digit',\n            }) }}\n          </div>\n        </div>\n        <!-- 弹幕内容，初步断定为以 http 开头的是链接，采用 img 渲染 -->\n        <div text-lg>\n          <MyImg v-if=\"content.startsWith('http://')\" class=\"h-2rem\" :src=\"content\" />\n          <span v-else break-words>{{ content }}</span>\n        </div>\n      </div>\n    </div>\n    <div v-else flex space-x-2 w-full p=\"x-2 y-1\">\n      <Avatar v-if=\"showAvatar\" :src=\"faceUrl\" :uid=\"uid\" :is-blob=\"urlIsBlob\" class=\"w-1.5rem h-1.5rem\" />\n      <div space-x-1 overflow-ellipsis>\n        <span v-if=\"showTime\" wsn text-sm op-50>\n          {{ new Date(ts).toLocaleTimeString('en-US', {\n            hour: '2-digit',\n            minute: '2-digit',\n          }) }}\n        </span>\n        <span leading-normal font-bold wsn text-sm op-70 :style=\"{ color }\">\n          {{ uname }}\n        </span>\n        <span\n          v-if=\"store.liverId === uid\"\n          text=\"0.75rem amber\"\n          border=\"~ rounded amber\"\n          bg=\"amber/20\"\n          px-1\n        >主播</span>\n        <span\n          v-if=\"fang === 1\"\n          text=\"0.75rem amber\"\n          border=\"~ rounded amber\"\n          bg=\"amber/20\"\n          px=\"0.5\"\n        >房</span>\n        <UGuardTag\n          v-if=\"level && showGuardTag && tagColor !== 12632256\"\n          inline-flex leading-normal shadow\n          :level=\"level\"\n          :label=\"label\"\n          :perhaps-guard=\"perhapsGuard\"\n          :tag-color=\"tagColor\"\n        />\n        <MyImg v-if=\"perhapsGuard !== 0 && level >= 20\" inline-flex w-1rem h-1rem :src=\"guardType[perhapsGuard].badge\" err-src=\"/loading.gif\" rounded-full />\n        <MyImg v-if=\"content.startsWith('http://')\" class=\"h-2rem\" :src=\"content\" inline-flex err-src=\"/loading.gif\" />\n        <span v-else break-words>{{ content }}</span>\n      </div>\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/danmaku/UGift.vue",
    "content": "<script setup lang=\"ts\">\nimport Avatar from '~/components/img/Avatar.vue'\nimport MyImg from '~/components/img/MyImg.vue'\nimport { useStore } from '~/stores/store'\ndefineProps<{\n  uname: string\n  action: string\n  num: number\n  face: string\n  coinType: 'gold' | 'silver'\n  giftId: number\n  giftName: string\n  price: number\n  ts: number\n  uid: number\n  blindGift: null | {\n    blind_gift_config_id: number\n    from: number\n    gift_action: string\n    original_gift_id: string\n    original_gift_name: string\n  }\n  bgColor: string\n}>()\n\nconst store = useStore()\n\n// // eslint-disable-next-line no-console\n// console.log('gift', props.ts, new Date(props.ts))\n</script>\n\n<template>\n  <div flex w-full space-x-2 :style=\"{ backgroundColor: bgColor }\" text-white p-2 rounded my-2>\n    <Avatar w-3rem h-3rem :src=\"face\" :uid=\"uid\" :is-blob=\"false\" />\n    <div flex-1>\n      <div flex justify-between text-sm>\n        <div font-bold>\n          {{ uname }}\n        </div>\n        <div v-if=\"coinType === 'gold'\" text-amber text-sm>\n          ￥{{ price * num / 1000 }}\n        </div>\n      </div>\n      <div font-bold text-lg flex justify-between items-center>\n        <div>{{ action }} <span :class=\"{ 'text-amber': coinType === 'gold' }\">{{ blindGift?.original_gift_name }}</span> <span>{{ blindGift?.gift_action }}</span> <span :class=\"{ 'text-amber': coinType === 'gold' }\">{{ giftName }}</span> × {{ num }}</div>\n      </div>\n    </div>\n    <div grid grid-rows-2 />\n    <MyImg\n      :src=\"(store.giftInfoList.find(x => x.id === giftId) || { webp: '' }).webp\"\n      err-src=\"/loading.gif\"\n      class=\"w-3rem h-3rem\"\n    />\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/danmaku/UGuardTag.vue",
    "content": "<script setup lang=\"ts\">\nconst props = defineProps<{\n  level: number\n  label: string\n  perhapsGuard: 0 | 1 | 2 | 3\n  tagColor: number\n}>()\n</script>\n\n<template>\n  <div\n    flex class=\"text-0.75rem\"\n  >\n    <div\n      rounded-l\n      px-1\n      wsn\n      :style=\"{\n        backgroundColor: `#${props.tagColor.toString(16).padStart(6, '0')}`,\n      }\"\n    >\n      {{ label }}\n    </div>\n    <div px-1 wsn bg-white text-black rounded-r text-shadow-none>\n      {{ level }}\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/danmaku/UInteraction.vue",
    "content": "<script setup lang=\"ts\">\nimport { inject, ref } from 'vue'\nimport { getAvatar2 } from '../../composables/getAvatar'\nimport { useStore } from '../../stores/store'\nimport Avatar from '../img/Avatar.vue'\nimport { msgKey } from '~/composables/injectionKeys'\n\nconst props = defineProps<{\n  type: 'interact'\n  uname: string\n  uid: number\n  unameColor: string\n  ts: number\n  action: 1 | 2\n}>()\n\nconst store = useStore()\nconst faceUrl = ref('')\nconst urlIsBlob = ref(false)\nconst msgRef = inject(msgKey)\n\nif (store.getConfig.showAvatar) {\n  getAvatar2(props.uid)\n    .then(({ url, isBlob }) => {\n      faceUrl.value = url\n      urlIsBlob.value = isBlob\n    })\n    .catch((err: Error) => {\n      msgRef?.value.pushMsg(err.message, { type: 'error' })\n    })\n}\n</script>\n\n<template>\n  <div w-full flex space-x-2 p=\"x-2 y-1\">\n    <Avatar v-if=\"store.getConfig.showAvatar\" class=\"w-1.5rem h-1.5rem\" :src=\"faceUrl\" :is-blob=\"urlIsBlob\" :uid=\"uid\" />\n    <div space-x-1>\n      <span leading-normal text-sm op-70 font-bold :style=\"{ color: unameColor }\">\n        {{ uname }}\n      </span>\n      <span leading-normal :style=\"{ color: action === 1 ? '' : 'gold' }\">{{ action === 1 ? '进入了直播间' : '关注了直播间' }}</span>\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/danmaku/URenderer.vue",
    "content": "<script setup lang=\"ts\">\nimport UInteraction from './UInteraction.vue'\nimport UDanmaku from '~/components/danmaku/UDanmaku.vue'\nimport UGift from '~/components/danmaku/UGift.vue'\nimport UScDanmaku from '~/components/superchat/UScDanmaku.vue'\nimport type { DanmakuProps, GiftProps, InteractProps, SuperChatProps } from '~/composables/components'\nimport { isDanmakuProps, isGiftProps, isInteractProps, isSuperChatProps } from '~/composables/components'\nimport { useStore } from '~/stores/store'\n\ndefineProps<{\n  obj?: DanmakuProps | GiftProps | SuperChatProps | InteractProps\n}>()\n\nconst store = useStore()\n</script>\n\n<template>\n  <UDanmaku\n    v-if=\"isDanmakuProps(obj)\"\n    :content=\"obj.content\"\n    :uname=\"obj.uname\"\n    :level=\"obj.level\"\n    :label=\"obj.label\"\n    :color=\"obj.color\"\n    :tag-color=\"obj.tagColor\"\n    :fang=\"obj.fang\"\n    :perhaps-guard=\"obj.perhapsGuard\"\n    :ts=\"obj.ts\"\n    :uid=\"obj.uid\"\n    :show-avatar=\"store.getConfig.showAvatar\"\n    :show-guard-tag=\"store.getConfig.showGuardTag > 0\"\n    :show-time=\"store.getConfig.showTime\"\n    :layout=\"store.getConfig.layout\"\n  />\n  <UGift\n    v-else-if=\"isGiftProps(obj)\"\n    :uname=\"obj.uname\"\n    :action=\"obj.action\"\n    :num=\"obj.num\"\n    :face=\"obj.face\"\n    :coin-type=\"obj.coinType\"\n    :gift-id=\"obj.giftId\"\n    :gift-name=\"obj.giftName\"\n    :price=\"obj.price\"\n    :ts=\"obj.ts\"\n    :uid=\"obj.uid\"\n    :blind-gift=\"obj.blindGift\"\n    :bg-color=\"obj.bgColor\"\n  />\n  <UScDanmaku\n    v-else-if=\"isSuperChatProps(obj)\"\n    :uname=\"obj.uname\"\n    :uid=\"obj.uid\"\n    :ts=\"obj.ts\"\n    :second=\"obj.second\"\n    :face=\"obj.face\"\n    :bg-bottom-color=\"obj.bgBottomColor\"\n    :bg-color=\"obj.bgColor\"\n    :content=\"obj.content\"\n    :content-jpn=\"obj.contentJpn\"\n    :price=\"obj.price\"\n  />\n  <UInteraction\n    v-else-if=\"isInteractProps(obj)\"\n    :type=\"obj.type\"\n    :action=\"obj.action\"\n    :ts=\"obj.ts\"\n    :uid=\"obj.uid\"\n    :uname=\"obj.uname\"\n    :uname-color=\"obj.unameColor\"\n  />\n</template>\n"
  },
  {
    "path": "src/components/danmaku/UWatch.vue",
    "content": "<script setup lang=\"ts\">\ndefineProps<{\n  population: string\n  fans: string\n}>()\n</script>\n\n<template>\n  <div\n    flex\n    p-2\n    space-x-1\n    items-center\n  >\n    <div>人气 {{ population }}</div>\n    <div flex-1 />\n    <div>粉丝数 {{ fans }}</div>\n  </div>\n</template>\n\n"
  },
  {
    "path": "src/components/img/Avatar.vue",
    "content": "<script setup lang=\"ts\">\nimport MyImg from './MyImg.vue'\ndefineProps<{\n  src: string\n  uid?: number\n  isBlob?: boolean\n}>()\n</script>\n\n<template>\n  <MyImg :src=\"src\" :uid=\"uid\" :is-blob=\"isBlob\" rounded-full shadow-md err-src=\"/noface.gif\" />\n</template>\n\n"
  },
  {
    "path": "src/components/img/MyImg.vue",
    "content": "<script setup lang=\"ts\">\n// import { readBinaryFile } from '@tauri-apps/api/fs'\nimport { ref, watch } from 'vue'\nimport { processImgUrl2 } from '~/composables/fetchImgFromBackend'\n\nconst props = withDefaults(defineProps<{\n  src: string\n  errSrc?: string\n  uid?: number\n  isBlob?: boolean\n}>(), {\n  errSrc: '/noface.gif',\n  isBlob: false,\n})\n\nconst realSrc = ref(props.errSrc)\n\nfunction loadImage() {\n  if (props.src.trim() === '')\n    return\n  if (props.isBlob) {\n    realSrc.value = props.src\n    return\n  }\n  processImgUrl2(props.src, props.uid)\n    .then(({ blob }) => {\n      realSrc.value = blob\n    })\n}\n\nloadImage()\n\nwatch(\n  () => props.src,\n  loadImage,\n)\n\nconst onError = () => {\n  realSrc.value = props.errSrc\n}\n</script>\n\n<template>\n  <img :loading=\"errSrc\" :src=\"realSrc\" @error=\"onError\">\n</template>\n"
  },
  {
    "path": "src/components/img/MyQrCode.vue",
    "content": "<script setup lang=\"ts\">\nimport { useQRCode } from '@vueuse/integrations/useQRCode'\n\nconst props = defineProps<{\n  url: string\n}>()\n\nconst emits = defineEmits(['close'])\n\nconst qrcode = useQRCode(props.url)\n</script>\n\n<template>\n  <div shadow-lg p-4 bg=\"white dark:#121212\" rounded space-y-2>\n    <div absolute right-1 top-1 i-ri-close-line icon-btn text-lg @click=\"emits('close')\" />\n    <img :src=\"qrcode\" ma>\n    <div>请使用 bilibili 手机客户端扫码</div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/send/UMessageSender.vue",
    "content": "<script setup lang=\"ts\">\nimport { inject, ref } from 'vue'\nimport { sendMsg } from '~/composables/msgSend'\nimport UInputBtn from '~/components/ui/UInputBtn.vue'\nimport { useStore } from '~/stores/store'\nimport { msgKey } from '~/composables/injectionKeys'\n\nwithDefaults(defineProps<{\n  noBorder?: boolean\n}>(), {\n  noBorder: false,\n})\n\nconst msg = ref('')\nconst btnDisabled = ref(false)\nconst msgRef = inject(msgKey)\nconst store = useStore()\n\nconst sendMessage = () => {\n  if (msg.value.trim() === '') {\n    msgRef?.value.pushMsg('发送的消息不能为空！', {\n      type: 'warning',\n    })\n    return\n  }\n  try {\n    btnDisabled.value = true\n    sendMsg(msg.value)\n    btnDisabled.value = false\n    msg.value = ''\n  }\n  catch (e) {\n    msgRef?.value.pushMsg('消息发送失败！请重新登录！', {\n      type: 'error',\n    })\n  }\n}\n</script>\n\n<template>\n  <UInputBtn\n    v-model=\"msg\"\n    placeholder=\"Ctrl + Enter 发送\"\n    :btn-disabled=\"btnDisabled || !store.getUserInfo.mid || msg.trim() === ''\"\n    :no-border=\"noBorder\"\n    @click-btn=\"sendMessage\"\n  >\n    发送\n  </UInputBtn>\n</template>\n"
  },
  {
    "path": "src/components/settings/Login.vue",
    "content": "<script setup lang=\"ts\">\nimport { fetch } from '@tauri-apps/api/http'\nimport { confirm } from '@tauri-apps/api/dialog'\nimport { inject, ref } from 'vue'\nimport MyQrCode from '~/components/img/MyQrCode.vue'\nimport Avatar from '~/components/img/Avatar.vue'\nimport { clearLoop, createLoginLoop, interval } from '~/composables/loginLoop'\nimport logoutAccount from '~/composables/logout'\nimport { qrcodeGet } from '~/composables/api'\nimport { useStore } from '~/stores/store'\nimport { msgKey } from '~/composables/injectionKeys'\n\nconst store = useStore()\nconst msgRef = inject(msgKey)\n\ninterface QrProps {\n  url: string\n  oauthKey: string\n}\n\nconst getQrcodeEnabled = ref(true)\nconst qrurl = ref('')\n\n// const interval = computed(() => interval.value !== undefined)\n\nconst login = async () => {\n  getQrcodeEnabled.value = false\n  const { data: { data } }: { data: { data: QrProps } } = await fetch(qrcodeGet, { method: 'GET', timeout: 5000 })\n  // // eslint-disable-next-line no-console\n  // console.log(data)\n  getQrcodeEnabled.value = true\n\n  qrurl.value = data.url\n  store.userInfo.oauthKey = data.oauthKey\n\n  const success = await createLoginLoop(data.oauthKey)\n  if (success)\n    msgRef?.value.pushMsg('登录成功！', { type: 'success' })\n  msgRef?.value.pushMsg('若头像信息未更新，可点击按钮刷新', { type: 'info' })\n}\n\nconst cancelLogin = () => {\n  clearLoop()\n}\n\nconst logout = async () => {\n  const confirmed = await confirm('确定要退出登录吗？', { title: '退出登录', type: 'warning' })\n  if (confirmed) {\n    const resData = await logoutAccount() as any\n    if (resData.code === 0) {\n      store.removeUserInfo()\n      msgRef?.value.pushMsg('退出成功', { type: 'success' })\n      store.config.autoReply = false\n      store.config.canSendMessage = false\n    }\n    else {\n      msgRef?.value.pushMsg('退出失败', { type: 'error' })\n    }\n  }\n}\n\nconst refreshLogin = (event: Event) => {\n  location.reload();\n  (event.target as HTMLElement).classList.toggle('animate-spin')\n  setTimeout(() => {\n    (event.target as HTMLElement).classList.toggle('animate-spin')\n  }, 1000)\n}\n</script>\n\n<template>\n  <div flex space-x-2 items-center>\n    <Avatar w-3rem h-3rem :src=\"store.getUserInfo.avatarUrl || ''\" :uid=\"store.getUserInfo.mid\" />\n    <div flex-1>\n      <div v-if=\"!store.getUserInfo.mid\" flex>\n        <div space-x-2 flex items-center>\n          <button btn rounded :disabled=\"!getQrcodeEnabled\" @click=\"login\">\n            {{ interval ? '刷新' : '登录' }}\n          </button>\n          <div i-ri-refresh-line icon-btn @click=\"refreshLogin\" />\n        </div>\n        <div\n          v-if=\"interval\" absolute z-998 fixed\n          left-0 top-0 bottom-0 right-0\n          flex items-center justify-center\n          bg=\"white/80 dark:black/60\"\n        >\n          <MyQrCode absolute :url=\"qrurl\" @close=\"cancelLogin\" />\n        </div>\n      </div>\n      <div v-else>\n        <div>\n          {{ store.getUserInfo.mname }}\n        </div>\n        <div>已登录</div>\n      </div>\n    </div>\n    <button v-if=\"store.getUserInfo.mid\" btn rounded @click=\"logout\">\n      退出登录\n    </button>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/superchat/UScDanmaku.vue",
    "content": "<script setup lang=\"ts\">\nimport { computed, inject, ref } from 'vue'\nimport Avatar from '~/components/img/Avatar.vue'\nimport { getAvatar2 } from '~/composables/getAvatar'\nimport { msgKey } from '~/composables/injectionKeys'\nimport { useStore } from '~/stores/store'\n\nimport { LIGHTNESS_LIMIT, getLightnessFromHex } from '~/composables/randomColor'\n\nconst props = defineProps<{\n  uname: string\n  content: string\n  contentJpn: string\n  face: string\n  price: number\n  ts: number\n  uid: number\n  bgBottomColor: string\n  bgColor: string\n  second: number\n}>()\n\nconst store = useStore()\nconst faceUrl = ref(props.face)\nconst msgRef = inject(msgKey)\nconst urlIsBlob = ref(false)\nconst lang = ref(store.config.scLang)\nconst showToggleLang = computed(() => props.contentJpn.trim() !== '')\n\nfunction toggleLang() {\n  if (lang.value === 'zh-cn')\n    lang.value = 'ja-jp'\n  else\n    lang.value = 'zh-cn'\n}\n\nif (props.face === '') {\n  getAvatar2(props.uid)\n    .then(({ url, isBlob }) => {\n      faceUrl.value = url\n      urlIsBlob.value = isBlob\n    })\n    .catch(() => {\n      msgRef?.value.pushMsg('头像获取失败', { type: 'error' })\n    })\n}\n</script>\n\n<template>\n  <div w-full rounded>\n    <div\n      :style=\"{\n        backgroundColor: bgColor,\n        color: getLightnessFromHex(bgColor) > LIGHTNESS_LIMIT ? '#000' : '#fff',\n      }\"\n      flex space-x-2 p-2 rounded-t\n    >\n      <Avatar w-3rem h-3rem :src=\"faceUrl\" :uid=\"uid\" :is-blob=\"urlIsBlob\" />\n      <div flex-1>\n        <div font-bold text-lg text-shadow-none>\n          {{ uname }}\n        </div>\n        <div text=\"sm\" text-shadow-none>\n          ￥{{ price / 1000 }}\n        </div>\n      </div>\n      <div v-if=\"showToggleLang\" icon-btn i-ri-translate-2 @click=\"toggleLang\" />\n    </div>\n    <div\n      :style=\"{\n        backgroundColor: bgBottomColor,\n        color: getLightnessFromHex(bgBottomColor) > LIGHTNESS_LIMIT ? '#000' : '#fff',\n      }\"\n      p-2 rounded-b break-words\n    >\n      {{ lang === 'zh-cn' ? content : (contentJpn.trim() !== '' ? contentJpn : content) }}\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/superchat/USuperChatFloat.vue",
    "content": "<script setup lang=\"ts\">\nimport { computed, inject, ref } from 'vue'\nimport Avatar from '~/components/img/Avatar.vue'\nimport { getAvatar2 } from '~/composables/getAvatar'\nimport { msgKey } from '~/composables/injectionKeys'\nimport { LIGHTNESS_LIMIT, getLightnessFromHex } from '~/composables/randomColor'\nimport { useStore } from '~/stores/store'\n\nconst props = defineProps<{\n  uname: string\n  content: string\n  contentJpn: string\n  face: string\n  price: number\n  ts: number\n  uid: number\n  bgBottomColor: string\n  bgColor: string\n}>()\n\nconst store = useStore()\nconst lang = ref(store.config.scLang)\nconst showToggleLang = computed(() => props.contentJpn.trim() !== '')\n\nfunction toggleLang() {\n  if (lang.value === 'zh-cn')\n    lang.value = 'ja-jp'\n  else\n    lang.value = 'zh-cn'\n}\n\nconst faceUrl = ref(props.face)\nconst msgRef = inject(msgKey)\nconst urlIsBlob = ref(false)\n\nif (props.face === '') {\n  getAvatar2(props.uid)\n    .then(({ url, isBlob }) => {\n      faceUrl.value = url\n      urlIsBlob.value = isBlob\n    })\n    .catch(() => {\n      msgRef?.value.pushMsg('头像获取失败', { type: 'error' })\n    })\n}\n// console.log(getLightnessFromRgb(props.bgBottomColor), getLightnessFromRgb(props.bgColor))\n</script>\n\n<template>\n  <div w-full rounded text-white>\n    <div\n      flex items-center shadow space-x-2 p-2 rounded-t\n      :style=\"{\n        backgroundColor: bgColor,\n        color: getLightnessFromHex(bgColor) > LIGHTNESS_LIMIT ? '#000' : '#fff',\n      }\"\n    >\n      <Avatar :src=\"faceUrl\" :uid=\"uid\" class=\"w-1.5rem h-1.5rem\" />\n      <div flex-1 text-shadow-none>\n        {{ uname }}\n      </div>\n      <div text-shadow-none>\n        ￥{{ price / 1000 }}\n      </div>\n      <div v-if=\"showToggleLang\" icon-btn i-ri-translate-2 @click=\"toggleLang\" />\n    </div>\n    <div\n      p-2 rounded-b break-words\n      :style=\"{\n        backgroundColor: bgBottomColor,\n        color: getLightnessFromHex(bgBottomColor) > LIGHTNESS_LIMIT ? '#000' : '#fff',\n      }\"\n    >\n      {{ lang === 'zh-cn' ? content : (contentJpn.trim() !== '' ? contentJpn : content) }}\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/superchat/USuperChatPool.vue",
    "content": "<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\nimport USuperChat from './USuperChatFloat.vue'\nimport USuperChatTag from './USuperChatTag.vue'\nimport type { SuperChatProps } from '~/composables/components'\nimport { chatPool } from '~/composables/server'\n\nconst props = defineProps<{\n  chatPool: Array<SuperChatProps>\n  modelValue: SuperChatProps | null\n}>()\n\nconst emits = defineEmits(['update:modelValue'])\n\nconst sc = useVModel(props, 'modelValue', emits)\n\nconst clickSuperChat = (currentSc: SuperChatProps) => {\n  if (sc.value?.ts === currentSc.ts)\n    sc.value = null\n\n  else\n    sc.value = currentSc\n}\n</script>\n\n<template>\n  <div space-y-1 p-1>\n    <div\n      flex of-x-auto\n      space-x-2\n    >\n      <USuperChatTag\n        v-for=\"it in chatPool\" :key=\"it.ts\"\n        :face=\"it.face\"\n        :uid=\"it.uid\"\n        :price=\"it.price\"\n        :color=\"it.bgBottomColor\"\n        :second=\"it.second\"\n        :ts=\"it.ts\"\n        cursor-pointer\n        @click=\"clickSuperChat(it)\"\n      />\n    </div>\n    <USuperChat\n      v-if=\"sc\"\n      :ts=\"sc.ts\"\n      :uname=\"sc.uname\"\n      :content=\"sc.content\"\n      :content-jpn=\"sc.contentJpn\"\n      :face=\"sc.face\"\n      :price=\"sc.price\"\n      :uid=\"sc.uid\"\n      :bg-bottom-color=\"sc.bgBottomColor\"\n      :bg-color=\"sc.bgColor\"\n    />\n  </div>\n</template>\n\n<style scoped>\n::-webkit-scrollbar {\n  width: 0px;\n  height: 0px;\n}\n</style>\n"
  },
  {
    "path": "src/components/superchat/USuperChatTag.vue",
    "content": "<script setup lang=\"ts\">\nimport { useIntervalFn } from '@vueuse/core'\nimport { inject, ref, watchEffect } from 'vue'\nimport Avatar from '~/components/img/Avatar.vue'\nimport { getAvatar2 } from '~/composables/getAvatar'\nimport { msgKey } from '~/composables/injectionKeys'\nimport { LIGHTNESS_LIMIT, getLightnessFromHex } from '~/composables/randomColor'\n\nconst props = defineProps<{\n  face: string\n  price: number\n  color: string\n  second: number\n  uid: number\n  ts: number\n}>()\n\nconst timestamp = ref(Date.now())\nconst color2 = `${props.color}7f` // rgbAppendAlpha(props.color)\n\nconst { pause } = useIntervalFn(() => {\n  timestamp.value = Date.now()\n}, 1000)\n\nwatchEffect(() => {\n  if (timestamp.value - props.ts > props.second * 1000)\n    pause()\n})\n\nconst faceUrl = ref(props.face)\nconst msgRef = inject(msgKey)\nconst urlIsBlob = ref(false)\n\nif (props.face === '') {\n  getAvatar2(props.uid)\n    .then(({ url, isBlob }) => {\n      faceUrl.value = url\n      urlIsBlob.value = isBlob\n    })\n    .catch(() => {\n      msgRef?.value.pushMsg('头像获取失败', { type: 'error' })\n    })\n}\n</script>\n\n<template>\n  <div\n    rounded-full\n    inline-flex flex-shrink-0 items-center\n    :style=\"{\n      background: `linear-gradient(to right, ${color}, ${color} ${100 - (timestamp - ts) / 10 / second}%, ${color2}  ${100 - (timestamp - ts) / 10 / second + 5}%, ${color2})`,\n      color: getLightnessFromHex(color) > LIGHTNESS_LIMIT ? '#000' : '#fff',\n    }\"\n    p=\"0.75\" pr-2 text-white space-x=\"0.5\"\n  >\n    <Avatar :src=\"faceUrl\" :uid=\"uid\" class=\"w-1.25rem h-1.25rem\" />\n    <div text=\"sm amber\">\n      ￥{{ price / 1000 }}\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/ui/UBlackList.vue",
    "content": "<script setup lang=\"ts\">\nimport { inject } from 'vue'\nimport UTag from './UTag.vue'\nimport { useStore } from '~/stores/store'\nimport { msgKey } from '~/composables/injectionKeys'\nconst emits = defineEmits(['settingsChanged'])\nconst store = useStore()\nconst msgRef = inject(msgKey)\n\nfunction pushItem(event: Event) {\n  const uid = Number((event.target as HTMLInputElement).value.trim())\n  if (!isNaN(uid) && !store.getConfig.blackList.includes(uid)) {\n    store.config.blackList.push(uid)\n    emits('settingsChanged')\n  }\n  else {\n    msgRef?.value.pushMsg('该用户的 uid 已存在或不合法！', {\n      type: 'warning',\n    })\n  }\n  (event.target as HTMLInputElement).value = ''\n}\n\nfunction deleteItem(i: number) {\n  store.config.blackList.splice(i, 1)\n  emits('settingsChanged')\n}\n</script>\n\n<template>\n  <div>\n    <span font-bold>\n      黑名单\n    </span>\n    <span text-sm op-50>以下 uid 用户发送的弹幕将被屏蔽，右键弹幕也可将用户加入黑名单</span>\n    <hr border=\"zinc/20\" py-1>\n    <div\n      rounded\n      flex-1\n      text-sm\n      border=\"~ zinc-300 dark:zinc-700\"\n      p=\"t-1 l-1 r\"\n    >\n      <UTag\n        v-for=\"(el, i) in store.getConfig.blackList\" :key=\"el\"\n        :content=\"el.toString()\"\n        m=\"r-1 b-1\"\n        @close=\"deleteItem(i)\"\n      />\n      <input\n        leading-normal\n        border=\"~ rounded zinc-300 dark:zinc-700\"\n        content-border\n        class=\"!outline-none\"\n        px-2 m=\"r-1 b-1\"\n        w-8rem\n        bg-transparent\n        placeholder=\"按下回车以添加\"\n        @keydown.enter=\"pushItem\"\n      >\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/ui/UCheckBox.vue",
    "content": "<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\n\nconst props = withDefaults(defineProps<{\n  modelValue?: boolean\n  disabled?: boolean\n}>(), {\n  modelValue: false,\n  disabled: false,\n})\n\nconst emits = defineEmits(['update:modelValue'])\n\nconst checked = useVModel(props, 'modelValue', emits)\n</script>\n\n<template>\n  <label\n    class=\"inline-flex items-center leading-relaxed select-none space-x-1\"\n    :class=\"{ 'op-50 cursor-not-allowed': disabled, 'cursor-pointer': !disabled }\"\n    :checked=\"checked || null\"\n    :disabled=\"disabled || null\"\n  >\n    <input\n      v-model=\"checked\"\n      type=\"checkbox\"\n      :disabled=\"disabled\"\n      display-none\n      @keypress.enter=\"checked = !checked\"\n    >\n    <div flex items-center text-lg>\n      <div i-ri-checkbox-blank-line icon-btn />\n      <div\n        i-ri-checkbox-fill text-active icon-btn absolute\n        :class=\"{ 'scale-0': !checked }\"\n      />\n    </div>\n\n    <span><slot /></span>\n  </label>\n</template>\n"
  },
  {
    "path": "src/components/ui/UColorPicker.vue",
    "content": "<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\n\nconst props = withDefaults(defineProps<{\n  modelValue: string\n  disabled?: boolean\n}>(), {\n  disabled: false,\n})\n\nconst emits = defineEmits(['update:modelValue'])\n\nconst value = useVModel(props, 'modelValue', emits)\n</script>\n\n<template>\n  <label\n    class=\"inline-flex items-center leading-relaxed select-none space-x-1 cursor-pointer\"\n    :class=\"{ 'op-50': disabled }\"\n  >\n    <input v-model=\"value\" type=\"color\" :disabled=\"disabled\" absolute w-1px op-0>\n    <div text-lg flex items-center>\n      <div i-ri-checkbox-blank-fill :style=\"{ color: value }\" op-100 icon-btn />\n      <div absolute i-ri-checkbox-blank-line icon-btn />\n    </div>\n    <span>\n      <slot />\n    </span>\n  </label>\n</template>\n"
  },
  {
    "path": "src/components/ui/UInputBtn.vue",
    "content": "<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\n\nconst props = withDefaults(defineProps<{\n  modelValue: string\n  inputDisabled?: boolean\n  btnDisabled?: boolean\n  noBorder?: boolean\n  placeholder?: string\n}>(), {\n  inputDisabled: false,\n  btnDisabled: false,\n  noBorder: false,\n})\n\nconst emits = defineEmits(['update:modelValue', 'clickBtn'])\n\nconst emitEvent = () => {\n  emits('clickBtn')\n  // (event.target as HTMLInputElement).blur()\n}\n\nconst value = useVModel(props, 'modelValue', emits)\n</script>\n\n<template>\n  <div rounded flex :class=\"{ flex: noBorder }\">\n    <div flex-1>\n      <input\n        v-model=\"value\"\n        m-input rounded-l\n        py-1 px-2 w-full\n        border-r-none\n        :disabled=\"inputDisabled\"\n        :placeholder=\"placeholder\"\n        :class=\"{ 'border-none': noBorder }\"\n        @keydown.ctrl.enter.exact=\"emitEvent\"\n      >\n    </div>\n    <button\n      btn\n      :class=\"{ 'border-~ border-#646cff disabled:border-zinc-300/20': !noBorder }\"\n      rounded-r\n      :disabled=\"btnDisabled\"\n      @click=\"emitEvent\"\n    >\n      <slot />\n    </button>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/ui/UMdInput.vue",
    "content": "<script setup lang=\"ts\">\nimport { useFocus, useVModel } from '@vueuse/core'\nimport { computed, ref } from 'vue'\n\nconst props = withDefaults(defineProps<{\n  modelValue: string\n  disabled?: boolean\n  title?: string\n}>(), {\n  disabled: false,\n  title: '请输入',\n})\n\nconst emits = defineEmits(['update:modelValue', 'blur'])\nconst value = useVModel(props, 'modelValue', emits)\n\nconst inputRef = ref<HTMLInputElement>()\nconst { focused } = useFocus(inputRef)\nconst shouldFloat = computed(() => focused.value || value.value !== '')\n</script>\n\n<template>\n  <div inline-flex m=\"x-2 y-2\">\n    <input\n      ref=\"inputRef\"\n      v-model=\"value\"\n      class=\"bg-transparent !outline-none leading-loose\"\n      border=\"2px rounded zinc-300 dark:zinc-700 focus:#646cff\"\n      p=\"x-2 y-1\"\n      w-15rem transition-all\n      :disabled=\"disabled\"\n      @blur=\"emits('blur')\"\n    >\n    <div\n      absolute transition-all m=\"x-3 y-10px\" op-50\n      :class=\"{\n        'scale-80 translate-y--20px bg-white dark:bg-#242424 leading-tight !op-100': shouldFloat,\n      }\"\n      style=\"transform-origin: left\"\n      @click=\"focused = !focused\"\n    >\n      {{ title }}\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/ui/UMessageProvider.vue",
    "content": "<script setup lang=\"ts\">\nimport { ref } from 'vue'\nimport type { MessageProviderOptions } from '~/types'\n\ninterface PopMessage {\n  ts: number\n  content: string\n  type: 'success' | 'error' | 'warning' | 'info'\n}\n\nconst iconsDict = {\n  success: 'i-ri-checkbox-circle-line text-green-6',\n  error: 'i-ri-close-circle-line text-red-6',\n  warning: 'i-ri-error-warning-line text-amber',\n  info: 'i-ri-information-line text-blue',\n}\n\nconst messageQueue = ref<PopMessage[]>([])\n\nconst pushMsg = (msg: string, config?: MessageProviderOptions) => {\n  const ts = Date.now()\n  messageQueue.value.push({\n    type: config?.type || 'info',\n    content: msg,\n    ts,\n  })\n\n  setTimeout(() => {\n    messageQueue.value.splice(messageQueue.value.findIndex(it => it.ts === ts), 1)\n  }, config?.ttl || 3000)\n}\n\ndefineExpose({ pushMsg })\n</script>\n\n<template>\n  <TransitionGroup\n    tag=\"div\"\n    name=\"msggroup\"\n    fixed left-0 right-0\n    top-2rem\n    flex flex-col\n    pointer-events-none\n    z-999\n  >\n    <div\n      v-for=\"it in messageQueue\" :key=\"it.ts\"\n      p=\"x-4 y-2\" my-2 shadow-lg rounded\n      ma\n      bg=\"white !dark:zinc-900\"\n      flex items-center space-x-2\n      class=\"use-dark-msg\"\n    >\n      <div icon-btn :class=\"iconsDict[it.type]\" /><span>{{ it.content }}</span>\n    </div>\n  </TransitionGroup>\n</template>\n\n<style scoped>\n.msggroup-move, /* 对移动中的元素应用的过渡 */\n.msggroup-enter-active,\n.msggroup-leave-active {\n  transition: all 0.375s ease;\n}\n\n.msggroup-enter-from,\n.msggroup-leave-to {\n  opacity: 0;\n  transform: translateY(-30px) scale(0.01);\n}\n\n.msggroup-leave-active {\n  position: absolute;\n}\n</style>\n"
  },
  {
    "path": "src/components/ui/UMultiList.vue",
    "content": "<script setup lang=\"ts\">\nimport { confirm } from '@tauri-apps/api/dialog'\nimport { inject } from 'vue'\nimport type { Answer } from '../../composables/autoSendMsg'\nimport UTag from './UTag.vue'\nimport { useStore } from '~/stores/store'\nimport { msgKey } from '~/composables/injectionKeys'\n\nconst emits = defineEmits(['settingsChanged'])\nconst store = useStore()\nconst msgRef = inject(msgKey)\n\nfunction pushFaq() {\n  store.faqs.push({\n    ts: Date.now(),\n    keywords: [],\n    answer: '',\n  })\n  emits('settingsChanged')\n}\n\nfunction pushKeyWord(event: Event, faq: Answer) {\n  const val = (event.target as HTMLInputElement).value.trim()\n  if (val === '' || faq.keywords.includes(val)) {\n    msgRef?.value.pushMsg('关键词重复！', {\n      type: 'warning',\n    })\n    return\n  }\n\n  faq.keywords.push(val);\n  (event.target as HTMLInputElement).value = ''\n  emits('settingsChanged')\n}\n\nasync function deleteFaq(index: number) {\n  const confirmed = await confirm('确定要删除这个问题吗？', {\n    title: '提示', type: 'warning',\n  })\n  if (confirmed) {\n    store.faqs.splice(index, 1)\n    emits('settingsChanged')\n  }\n}\n\nfunction answerChanged() {\n  emits('settingsChanged')\n}\n</script>\n\n<template>\n  <div space-y-2>\n    <div\n      v-for=\"(it, index) in store.getFaqs\" :key=\"it.ts\"\n      py-2 space-y-2\n    >\n      <div flex items-center space-x-2>\n        <div font-bold>\n          问题 {{ index + 1 }}\n        </div>\n        <div flex-1>\n          <span v-if=\"it.answer.trim() === '' || it.keywords.length === 0\" text=\"sm red\">*问题不完整，保存时将自动删除</span>\n        </div>\n        <div i-ri-delete-bin-line icon-btn @click=\"deleteFaq(index)\" />\n      </div>\n      <div flex space-x-2 items-center>\n        <div>关键词语</div>\n        <div\n          rounded\n          flex-1\n          text-sm\n          border=\"~ zinc-300 dark:zinc-700\"\n          p=\"t-1 l-1 r\"\n        >\n          <UTag\n            v-for=\"(kw, jndex) in it.keywords\"\n            :key=\"kw\"\n            m=\"r-1 b-1\"\n            :content=\"kw\"\n            @close=\"it.keywords.splice(jndex, 1)\"\n          />\n          <input\n            leading-normal\n            border=\"~ rounded zinc-300 dark:zinc-700\"\n            content-border\n            class=\"!outline-none\"\n            px-2 m=\"r-1 b-1\"\n            w-8rem\n            bg-transparent\n            placeholder=\"按下回车以添加\"\n            @keydown.enter=\"pushKeyWord($event, it)\"\n          >\n        </div>\n      </div>\n      <div flex space-x-2 items-center>\n        <div>自动回复</div>\n        <input\n          v-model=\"it.answer\"\n          m-input rounded flex-1 text-sm\n          @input=\"answerChanged\"\n        >\n        <span text=\"sm zinc\" absolute right-6>\n          {{ it.answer.length <= 20 ? `${it.answer.length}/20` : '过长的消息将会分条发送' }}\n        </span>\n      </div>\n    </div>\n    <button\n      flex space-x-2 items-center justify-center\n      py-1\n      border=\"~ rounded dashed zinc-300 dark:zinc-600 hover:#646cff\"\n      block w-full\n      class=\"hover:text-#646cff\"\n      transition\n      @click=\"pushFaq\"\n    >\n      <div i-ri-add-line /> 添加\n    </button>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/ui/URadio.vue",
    "content": "<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\n\nconst props = withDefaults(defineProps<{\n  modelValue?: string\n  disabled?: boolean\n  name?: string\n  value?: string\n}>(), {\n  disabled: false,\n  modelValue: '',\n})\n\nconst emits = defineEmits(['update:modelValue'])\n\nconst model = useVModel(props, 'modelValue', emits)\n</script>\n\n<template>\n  <label\n    class=\"inline-flex items-center leading-relaxed select-none space-x-1 cursor-pointer\"\n    :class=\"{ 'op-50': disabled }\"\n    :checked=\"model === value || null\"\n    :disabled=\"disabled || null\"\n  >\n    <input\n      v-model=\"model\"\n      type=\"radio\"\n      :value=\"value\"\n      :name=\"name\"\n      :disabled=\"disabled\"\n      display-none\n    >\n    <div flex items-center text-lg>\n      <div i-ri-checkbox-blank-circle-line icon-btn />\n      <div\n        i-ri-radio-button-line text-active icon-btn absolute\n        :class=\"{ 'scale-0': model !== value }\"\n      />\n    </div>\n    <span><slot /></span>\n  </label>\n</template>\n"
  },
  {
    "path": "src/components/ui/USelector.vue",
    "content": "<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\nconst props = withDefaults(defineProps<{\n  options?: Array<{ label: string; value: number }>\n  modelValue?: number\n}>(), {\n  options: () => [],\n  modelValue: 0,\n})\n\nconst emits = defineEmits(['update:modelValue'])\n\nconst value = useVModel(props, 'modelValue', emits)\n</script>\n\n<template>\n  <div flex items-center>\n    <label\n      flex=\"~\" items-center absolute\n      border=\"~ zinc rounded\"\n    >\n      <select\n        v-model=\"value\"\n        bg=\"transparent\"\n        appearance=\"none\"\n        outline=\"!none\"\n        transition-all\n        flex-1\n        p=\"l-1 r-6\"\n      >\n        <option v-for=\"o in options\" :key=\"o.value\" :value=\"o.value\">\n          {{ o.label }}\n        </option>\n      </select>\n      <div i-ri-arrow-down-s-line absolute right-0 pointer-events=\"none\" />\n    </label>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/ui/USettingsBox.vue",
    "content": "<script setup lang=\"ts\">\ndefineProps<{ title: string }>()\n</script>\n\n<template>\n  <div>\n    <div font-bold>\n      {{ title }}\n    </div>\n    <hr border=\"zinc/20\" py-1>\n    <div grid grid-cols-3>\n      <slot />\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/ui/USlider.vue",
    "content": "<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\n\nconst props = withDefaults(defineProps<{\n  modelValue?: string\n  disabled?: boolean\n  minValue?: number\n  maxValue?: number\n}>(), {\n  modelValue: '0',\n  disabled: false,\n  minValue: 0,\n  maxValue: 100,\n})\n\nconst emits = defineEmits(['update:modelValue'])\n\nconst value = useVModel(props, 'modelValue', emits)\n</script>\n\n<template>\n  <input v-model=\"value\" inline-block type=\"range\" :min=\"minValue\" :max=\"maxValue\" class=\"disabled:grayscale\">\n</template>\n\n<style scoped>\n[type=\"range\"] {\n    -webkit-appearance: none;\n    appearance: none;\n    margin: 0;\n    outline: 0;\n    background-color: transparent;\n}\n[type=\"range\"]::-webkit-slider-runnable-track {\n    height: 4px;\n    background: #7f7f7f10;\n}\n[type=\"range\" i]::-webkit-slider-container {\n    height: 20px;\n    overflow: hidden;\n}\n[type=\"range\"]::-webkit-slider-thumb {\n    -webkit-appearance: none;\n    appearance: none;\n    width: 20px;\n    height: 20px;\n    border-radius: 50%;\n    background-color: #646cff;\n    border: 1px solid transparent;\n    margin-top: -8px;\n    border-image: linear-gradient(#646cff,#646cff) 0 fill / 8 20 8 0 / 0px 0px 0 2000px;\n}\n</style>\n"
  },
  {
    "path": "src/components/ui/USwitch.vue",
    "content": "<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\n\nconst props = withDefaults(defineProps<{\n  modelValue?: boolean\n  disabled?: boolean\n}>(), {\n  modelValue: false,\n  disabled: false,\n})\n\nconst emits = defineEmits(['update:modelValue'])\n\nconst checked = useVModel(props, 'modelValue', emits)\n\nconst toggleChecked = () => {\n  if (!props.disabled)\n    checked.value = !checked.value\n}\n</script>\n\n<template>\n  <div\n    flex items-center cursor-pointer leading-relaxed\n    :class=\"{ 'opacity-50': disabled }\"\n    @click=\"toggleChecked\"\n  >\n    <div\n      class=\"w-2rem h-1.2rem mx-1 bg-opacity-20\"\n      flex items-center\n      rounded-full transition-all\n      :class=\"{\n        'bg-#646cff': checked,\n        'bg-zinc': !checked,\n      }\"\n    >\n      <div\n        class=\"w-1rem h-1rem ml-0.1rem\"\n        rounded-full border-transparent transition-all\n        :class=\"{\n          'ml-0.9rem bg-#646cff shadow': checked,\n          'bg-white dark:bg-zinc-500': !checked,\n        }\"\n      />\n    </div>\n    <span><slot /></span>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/ui/UTabSelector.vue",
    "content": "<script setup lang=\"ts\">\nimport { onClickOutside, useVModels } from '@vueuse/core'\nimport { ref } from 'vue'\nimport { useStore } from '~/stores/store'\n\nconst props = defineProps<{\n  id: number\n  info: string\n}>()\n\nconst emits = defineEmits(['update:id', 'update:info', 'close'])\n\nconst { id, info } = useVModels(props, emits)\n\nconst store = useStore()\n\nconst currentTab = ref(0)\nconst currentPage = ref(0)\nconst dialog = ref<HTMLElement>()\n\nfunction tabChanged(i: number) {\n  currentTab.value = i\n  currentPage.value = 0\n}\n\nfunction select(id2: string, area2: string) {\n  id.value = parseInt(id2)\n  info.value = `${store.liveConfig.liveAreaList[currentTab.value].name} · ${area2}`\n}\n\nonClickOutside(dialog, () => {\n  emits('close')\n})\n</script>\n\n<template>\n  <div\n    fixed\n    left-0 top-0 bottom-0 right-0\n    flex items-center justify-center\n    bg=\"white/80 dark:black/60\"\n  >\n    <div\n      ref=\"dialog\" w-40rem\n      h-13rem\n      p-6\n      shadow absolute\n      bg=\"white dark:#242424\"\n    >\n      <div\n        icon-btn absolute top-2 right-2\n        i-ri-close-line\n        @click=\"emits('close')\"\n      />\n      <div flex justify-between>\n        <button\n          v-for=\"(it, i) in store.liveConfig.liveAreaList\"\n          :key=\"it.id\"\n          :class=\"{\n            'text-#646cff': currentTab === i,\n          }\"\n          icon-btn m=\"x-2 y-1\"\n          @click=\"tabChanged(i)\"\n        >\n          {{ it.name }}\n        </button>\n      </div>\n      <div grid grid-cols-5 text-center place-items-center>\n        <button\n          v-for=\"jt in store.liveConfig.liveAreaList[currentTab].list.slice(currentPage * 20, currentPage * 20 + 20)\"\n          :key=\"jt.id\"\n          :title=\"jt.name\"\n          icon-btn\n          truncate px-4\n          w-7rem mb-1\n          border=\"~ zinc-300 dark:zinc-700\"\n          rounded-full\n          @click=\"select(jt.id, jt.name)\"\n        >\n          {{ jt.name }}\n        </button>\n      </div>\n      <div v-if=\"store.liveConfig.liveAreaList[currentTab].list.length > 20\" flex justify-center>\n        <button\n          v-for=\"j in Math.ceil(store.liveConfig.liveAreaList[currentTab].list.length / 20)\" :key=\"j\"\n          icon-btn\n          :class=\"{ 'text-#646cff': currentPage === j - 1 }\"\n          m=\"x-2 y-1\"\n          @click=\"currentPage = j - 1\"\n        >\n          {{ j }}\n        </button>\n      </div>\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/components/ui/UTag.vue",
    "content": "<script setup lang=\"ts\">\ndefineProps<{\n  content: string\n}>()\n\nconst emits = defineEmits(['close'])\n</script>\n\n<template>\n  <div\n    inline-flex\n    items-center\n    border=\"~ rounded zinc-300 dark:zinc-700\"\n    leading-normal\n    p=\"x-2\"\n    space-x-1\n  >\n    <span pl-1>{{ content }}</span>\n    <div icon-btn text-sm i-ri-close-line @click=\"emits('close')\" />\n  </div>\n</template>\n"
  },
  {
    "path": "src/composables/api.ts",
    "content": "const spaceInfo = 'https://api.bilibili.com/x/space/app/index?mid='\nconst cardInfo = 'http://api.bilibili.com/x/web-interface/card?mid='\nconst giftInfo = 'https://api.live.bilibili.com/xlive/web-room/v1/giftPanel/giftConfig?platform=pc&room_id='\nconst roomInfo = 'https://api.live.bilibili.com/room/v1/Room/get_info?id='\nconst qrcodeGet = 'http://passport.bilibili.com/qrcode/getLoginUrl'\nconst qrcodeLogin = 'http://passport.bilibili.com/qrcode/getLoginInfo'\nconst danmakuSend = 'https://api.live.bilibili.com/msg/send'\nconst logOutApi = 'http://passport.bilibili.com/login/exit/v2'\nconst liveAreaInfoListApi = 'http://api.live.bilibili.com/room/v1/Area/getList'\nconst startLiveApi = 'http://api.live.bilibili.com/room/v1/Room/startLive'\nconst stopLiveApi = 'http://api.live.bilibili.com/room/v1/Room/stopLive'\nconst updateLiveTitleApi = 'http://api.live.bilibili.com/room/v1/Room/update'\nconst shortIdToLongApi = 'https://api.live.bilibili.com/room/v1/Room/mobileRoomInit?id='\nconst getRoomInfoOldApi = 'https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid='\n\nexport {\n  spaceInfo,\n  giftInfo,\n  roomInfo,\n  qrcodeGet,\n  qrcodeLogin,\n  cardInfo,\n  danmakuSend,\n  logOutApi,\n  liveAreaInfoListApi,\n  stopLiveApi,\n  startLiveApi,\n  updateLiveTitleApi,\n  shortIdToLongApi,\n  getRoomInfoOldApi,\n}\n"
  },
  {
    "path": "src/composables/autoSendMsg.ts",
    "content": "import { sendMsg } from './msgSend'\nimport { useStore } from '~/stores/store'\n\ninterface Answer {\n  ts: number\n  keywords: string[]\n  answer: string\n}\n\nconst store = useStore()\n\nfunction addFAQ(ans: Omit<Answer, 'ts'>) {\n  store.faqs.push({\n    ...ans,\n    ts: Date.now(),\n  })\n}\n\nfunction removeFAQ(index: number) {\n  store.faqs.splice(index, 1)\n}\n\nconst sentQueue: number[] = []\n\nfunction enqueueAnswerTs(ts: number) {\n  sentQueue.push(ts)\n\n  setTimeout(() => {\n    sentQueue.shift()\n  }, 30000)\n}\n\nfunction autoSendByIndex(index: number) {\n  // 已经发过的暂时不发\n  if (sentQueue.find(it => it === store.getFaqs[index].ts))\n    return\n\n  enqueueAnswerTs(store.getFaqs[index].ts)\n\n  try {\n    sendMsg(store.getFaqs[index].answer)\n    // // eslint-disable-next-line no-console\n    // console.log(store.getFaqs[index].answer)\n  }\n  catch (e: any) {\n    throw new Error(e.toString())\n  }\n}\n\nfunction autoSendByWord(word: string) {\n  for (const [index, faq] of store.getFaqs.entries()) {\n    for (const kw of faq.keywords) {\n      if (word.includes(kw)) {\n        autoSendByIndex(index)\n        return\n      }\n    }\n  }\n}\n\nexport {\n  addFAQ,\n  removeFAQ,\n  autoSendByWord,\n}\n\nexport type {\n  Answer,\n}\n"
  },
  {
    "path": "src/composables/components.ts",
    "content": "interface DanmakuProps {\n  type: 'text'\n  content: string\n  uname: string\n  color: string\n  tagColor: number\n  fang: number\n  level: number\n  label: string\n  perhapsGuard: 0 | 1 | 2 | 3\n  ts: number\n  uid: number\n}\n\nfunction isDanmakuProps(obj: any): obj is DanmakuProps {\n  return obj !== undefined && obj.type === 'text'\n}\n\ninterface GiftProps {\n  type: 'gift'\n  uname: string\n  action: string\n  num: number\n  face: string\n  coinType: 'gold' | 'silver'\n  giftId: number\n  giftName: string\n  price: number\n  ts: number\n  uid: number\n  blindGift: null | {\n    blind_gift_config_id: number\n    from: number\n    gift_action: string\n    original_gift_id: string\n    original_gift_name: string\n  }\n  bgColor: string\n}\n\nfunction isGiftProps(obj: any): obj is GiftProps {\n  return obj !== undefined && obj.type === 'gift'\n}\n\ntype PropsType = 'text' | 'gift'\n\ninterface SuperChatProps {\n  type: 'superchat'\n  uname: string\n  content: string\n  contentJpn: string\n  face: string\n  price: number\n  ts: number\n  uid: number\n  bgBottomColor: string\n  bgColor: string\n  second: number\n}\n\nfunction isSuperChatProps(obj: any): obj is SuperChatProps {\n  return obj !== undefined && obj.type === 'superchat'\n}\n\ninterface GuardBuyProps {\n  type: 'guard_buy'\n  uname: string\n  face: string\n  uid: number\n  guardLevel: number\n  num: number\n  price: number\n  ts: number\n}\n\nfunction isGuardBuyProps(obj: any): obj is GuardBuyProps {\n  return obj !== undefined && obj.type === 'guard_buy'\n}\n\ninterface InteractProps {\n  type: 'interact'\n  uname: string\n  uid: number\n  unameColor: string\n  ts: number\n  action: 1 | 2\n}\n\nfunction isInteractProps(obj: any): obj is InteractProps {\n  return obj !== undefined && obj.type === 'interact'\n}\n\nexport type {\n  DanmakuProps,\n  GiftProps,\n  PropsType,\n  GuardBuyProps,\n  SuperChatProps,\n  InteractProps,\n}\n\nexport {\n  isDanmakuProps,\n  isGiftProps,\n  isSuperChatProps,\n  isGuardBuyProps,\n  isInteractProps,\n}\n"
  },
  {
    "path": "src/composables/dark.ts",
    "content": "import { useDark, usePreferredDark, useToggle } from '@vueuse/core'\n\n// these APIs are auto-imported from @vueuse/core\nexport const isDark = useDark()\nexport const toggleDark = useToggle(isDark)\nexport const preferredDark = usePreferredDark()\n"
  },
  {
    "path": "src/composables/data.ts",
    "content": "const guardType = {\n  1: {\n    type: 'member',\n    bgColor: '#fae4ab',\n    bgBottomColor: '#e3704d',\n    second: 60,\n    badge: 'https://i0.hdslb.com/bfs/activity-plat/static/20200716/1d0c5a1b042efb59f46d4ba1286c6727/icon-guard1.png@44w_44h.webp',\n  },\n  2: {\n    type: 'member',\n    bgColor: '#d5ccef',\n    bgBottomColor: '#633382',\n    second: 300,\n    badge: 'https://i0.hdslb.com/bfs/activity-plat/static/20200716/1d0c5a1b042efb59f46d4ba1286c6727/icon-guard2.png@44w_44h.webp',\n  },\n  3: {\n    type: 'member',\n    bgColor: '#e5faff',\n    bgBottomColor: '#657eaa',\n    second: 1800,\n    badge: 'https://i0.hdslb.com/bfs/activity-plat/static/20200716/1d0c5a1b042efb59f46d4ba1286c6727/icon-guard3.png@44w_44h.webp',\n  },\n}\n\nexport {\n  guardType,\n}\n"
  },
  {
    "path": "src/composables/eventEmitter.ts",
    "content": "import { WebviewWindow } from '@tauri-apps/api/window'\n\nexport function eventEmitter(event: string, payload: any) {\n  const showWindow = WebviewWindow.getByLabel('danmakuWidget')\n  if (showWindow)\n    showWindow.emit(event, payload)\n\n  const senderWindow = WebviewWindow.getByLabel('senderWindow')\n  if (senderWindow)\n    senderWindow.emit(event, payload)\n}\n"
  },
  {
    "path": "src/composables/fetchImgFromBackend.ts",
    "content": "import { appDir, join } from '@tauri-apps/api/path'\nimport { invoke } from '@tauri-apps/api/tauri'\nimport { readBinaryFile } from '@tauri-apps/api/fs'\nimport { useStore } from '~/stores/store'\n\nconst store = useStore()\n\nasync function getAbsolutePathFromUrl(url: string, fileName: string) {\n  const dir = await appDir()\n  const absolutePath = await join(dir, 'imgs', fileName)\n  const realPath = await invoke('fetch_image', {\n    imgUrl: url,\n    filePath: absolutePath,\n  }) as string\n  return realPath\n}\n\nasync function abPath2Blob(path: string) {\n  const imgContent = await readBinaryFile(path)\n  const blob = URL.createObjectURL(new Blob([imgContent.buffer]))\n  return blob\n}\n\nasync function processImgUrl2(imgUrl: string, uid?: number) {\n  let fileName: string\n  // 如果是头像\n  if (uid) {\n    // 文件名\n    fileName = `avatar_${uid}`\n  }\n  else {\n    // 从 url 截取图片名和路径\n    const splits = imgUrl.split('/')\n    fileName = splits[splits.length - 1]\n  }\n\n  // 在 store 中查找是否存在该图片\n  const found = store.mediaList.find(it => it.fileName === fileName)\n\n  // 找到了直接返回 blob 链接\n  if (found) {\n    // // eslint-disable-next-line no-console\n    // console.log('fetch: store', fileName)\n    return { name: fileName, blob: found.blob }\n  }\n\n  // // eslint-disable-next-line no-console\n  // console.log('fetch: through backend', fileName)\n\n  // 调用后端，获取头像绝对路径\n  const absolutePath = await getAbsolutePathFromUrl(imgUrl, fileName)\n\n  // 读取头像并转为 blob 链接\n  const blob = await abPath2Blob(absolutePath)\n\n  // const blob = convertFileSrc(absolutePath)\n\n  // 存入 cache\n  if (!store.mediaList.find(it => it.fileName === fileName))\n    store.mediaList.push({ fileName, blob })\n\n  return { name: fileName, blob }\n}\n\nexport {\n  processImgUrl2,\n  abPath2Blob,\n}\n"
  },
  {
    "path": "src/composables/getAvatar.ts",
    "content": "import { invoke } from '@tauri-apps/api/tauri'\nimport { appDir, join } from '@tauri-apps/api/path'\nimport { getCardInfo, getSpaceInfo } from './getInfoFromUid'\nimport type { CardInfoResponse, SpaceApiResponse } from './types'\nimport { abPath2Blob } from './fetchImgFromBackend'\nimport { useStore } from '~/stores/store'\n\nconst store = useStore()\n\nconst MAX_REQUEST_BLOCK_TIMES = 10\n\n// https://api.bilibili.com/x/space/app/index?mid=${uid}\n// https://api.bilibili.com/x/space/acc/info?mid=${uid}\n\nasync function getAvatar2(uid: number): Promise<{ url: string; isBlob: boolean }> {\n  const found = store.mediaList.find(it => it.fileName === `avatar_${uid}`)\n\n  if (found) {\n    // // eslint-disable-next-line no-console\n    // console.log('getAvatar: store', uid)\n    return { isBlob: true, url: found.blob }\n  }\n\n  const dir = await appDir()\n  const localPath = await join(dir, 'imgs', `avatar_${uid}`)\n\n  const res = await invoke('load_local_image', { uidPath: localPath }) as string\n\n  if (res.trim() !== '') {\n    // // eslint-disable-next-line no-console\n    // console.log('getAvatar: local', uid)\n    const blob = await abPath2Blob(res)\n    store.mediaList.push({ fileName: `avatar_${uid}`, blob })\n    return { url: blob, isBlob: true }\n  }\n\n  if (store.requestBlockedTimes >= MAX_REQUEST_BLOCK_TIMES)\n    return { isBlob: false, url: '' }\n\n  // // eslint-disable-next-line no-console\n  // console.log('getAvatar: request img url', uid)\n\n  const responseData = await getCardInfo(uid) as CardInfoResponse\n  if (responseData.code === 0) {\n    const url = `${responseData.data.card.face}@96w_96h`\n    return { url, isBlob: false }\n  }\n\n  const responseData2 = await getSpaceInfo(uid) as SpaceApiResponse\n  if (responseData2.code === 0) {\n    const url = `${responseData2.data.info.face}@96w_96h`\n    return { url, isBlob: false }\n  }\n\n  store.requestBlockedTimes++\n\n  // // eslint-disable-next-line no-console\n  // console.log(store.requestBlockedTimes)\n  if (store.requestBlockedTimes === MAX_REQUEST_BLOCK_TIMES)\n    throw new Error('头像获取失败！请考虑关闭头像！')\n\n  return { isBlob: false, url: '' }\n}\n\nexport { getAvatar2 }\n"
  },
  {
    "path": "src/composables/getCookies.ts",
    "content": "import { useStore } from '~/stores/store'\n\nconst store = useStore()\n\nexport default function getCookies() {\n  if (!store.getUserInfo.mid)\n    return ''\n  let cookies = ''\n  cookies += `sid=${store.getUserInfo.sid}; `\n  cookies += `DedeUserID=${store.getUserInfo.mid}; `\n  cookies += `DedeUserID__ckMd5=${store.getUserInfo.midmd5}; `\n  cookies += `SESSDATA=${store.getUserInfo.sessdata}; `\n  cookies += `bili_jct=${store.getUserInfo.bili_jct}`\n  return cookies\n}\n\n"
  },
  {
    "path": "src/composables/getInfoFromUid.ts",
    "content": "import { fetch } from '@tauri-apps/api/http'\nimport { cardInfo, spaceInfo } from './api'\nimport type { CardInfoResponse, SpaceApiResponse } from './types'\n\nasync function getSpaceInfo(uid: number) {\n  const response = await fetch(`${spaceInfo}${uid}`, {\n    method: 'GET',\n    timeout: 5000,\n  })\n\n  return response.data as SpaceApiResponse\n}\n\nasync function getCardInfo(uid: number) {\n  const response = await fetch(`${cardInfo}${uid}`, {\n    method: 'GET',\n    timeout: 5000,\n  })\n\n  return response.data as CardInfoResponse\n}\n\nexport {\n  getSpaceInfo,\n  getCardInfo,\n}\n"
  },
  {
    "path": "src/composables/getLastMatchedGift.ts",
    "content": "import type { GiftProps } from '~/composables/components'\n\nconst getLastMatchedGift = (\n  danmakuPool: Array<any>,\n  uname: string,\n  giftId: number,\n  ts: number,\n  num: number,\n): boolean => {\n  for (let i = danmakuPool.length - 1; i >= 0; i--) {\n    if (danmakuPool[i].type !== 'gift')\n      continue\n    const item = danmakuPool[i] as GiftProps\n    if (item.uname === uname && item.giftId === giftId) {\n      const item = danmakuPool.splice(i, 1) as GiftProps[]\n      item[0].num += num\n      // item[0].ts = ts\n      danmakuPool.push(item[0])\n      return true\n    }\n  }\n  return false\n}\n\nexport default getLastMatchedGift\n"
  },
  {
    "path": "src/composables/getLiverInfo.ts",
    "content": "import { fetch } from '@tauri-apps/api/http'\nimport { getRoomInfoOldApi, roomInfo } from './api'\nimport { getCardInfo, getSpaceInfo } from './getInfoFromUid'\nimport { useStore } from '~/stores/store'\n\nconst store = useStore()\n\nasync function getLiveRoomInfoFromRoomId(roomId: number) {\n  const data = (await fetch(`${roomInfo}${roomId}`, {\n    method: 'GET',\n    timeout: 5000,\n  })).data as {\n    data: {\n      uid: number\n      live_status: 0 | 1 | 2\n      room_id: number\n      area_id: number\n    }\n  }\n  return data\n}\n\nasync function getLiverInfo(roomId: number) {\n  const data = await getLiveRoomInfoFromRoomId(roomId)\n\n  //   console.log(data, data.data.uid)\n  store.liverId = data.data.uid\n  const data2 = await getCardInfo(data.data.uid) as any\n\n  if (data2.code !== 0)\n    throw new Error('主播信息获取失败！')\n\n  const fansNumber = data2.data.follower\n\n  //   console.log(fansNumber)\n  return fansNumber as number\n}\n\nasync function getLiveRoomInfoFromUid(uid: number) {\n  const spaceData = await getSpaceInfo(uid)\n  return {\n    roomid: spaceData.data.info.live.roomid,\n    title: spaceData.data.info.live.title,\n  }\n}\n\nasync function getLiveStatusFromUid(uid: number) {\n  const data = (await fetch(`${getRoomInfoOldApi}${uid}`, {\n    method: 'GET',\n    timeout: 5000,\n  })).data as any\n\n  const liveStatus = data.data.liveStatus as number\n  return liveStatus\n}\n\nexport {\n  getLiverInfo,\n  getLiveRoomInfoFromUid,\n  getLiveRoomInfoFromRoomId,\n  getLiveStatusFromUid,\n}\n"
  },
  {
    "path": "src/composables/injectionKeys.ts",
    "content": "import type { InjectionKey, Ref } from 'vue'\nimport type UMessageProvider from '~/components/ui/UMessageProvider.vue'\n\nexport const msgKey: InjectionKey<Ref<typeof UMessageProvider>> = Symbol('')\n"
  },
  {
    "path": "src/composables/load_pos.ts",
    "content": "import { invoke } from '@tauri-apps/api/tauri'\nimport type { PositionConfig } from '~/stores/position'\n\nasync function loadPos(conf: PositionConfig) {\n  const res = await invoke('set_viewer_pos_and_size', { conf })\n  return res\n}\n\nexport {\n  loadPos,\n}\n"
  },
  {
    "path": "src/composables/loginLoop.ts",
    "content": "import { Body, fetch } from '@tauri-apps/api/http'\nimport { ref } from 'vue'\nimport { qrcodeLogin } from './api'\nimport { getCardInfo } from './getInfoFromUid'\nimport { useStore } from '~/stores/store'\n\nconst store = useStore()\n\nconst getUrlParams = (url: string) => {\n  const purl = new URL(url)\n  const paramsStr = purl.search.slice(1)\n  const params = new URLSearchParams(paramsStr)\n  return {\n    DedeUserID: Number.parseInt(params.get('DedeUserID') || ''),\n    DedeUserID__ckMd5: params.get('DedeUserID__ckMd5') || '',\n    SESSDATA: params.get('SESSDATA') || '',\n    bili_jct: params.get('bili_jct') || '',\n    Expires: Number.parseInt(params.get('Expires') || ''),\n    sid: params.get('sid') || '',\n  }\n}\n\nconst interval = ref<NodeJS.Timer>()\n\nconst clearLoop = () => {\n  if (interval.value) {\n    clearInterval(interval.value)\n    interval.value = undefined\n  }\n}\n\nasync function createLoginLoop(oauthKey: string): Promise<boolean> {\n  return new Promise((resolve) => {\n    interval.value = setInterval(async () => {\n      const response = await fetch(qrcodeLogin, {\n        method: 'POST',\n        headers: {\n          'Content-Type': 'application/x-www-form-urlencoded',\n        },\n        body: Body.form({ oauthKey }),\n      })\n\n      const { data: loginResponse, rawHeaders }: {\n        data: {\n          data: -1 | -2 | -4 | -5 | { url: string }\n          message: string\n        }\n        headers: any\n        rawHeaders: {\n          'set-cookie': string[]\n        }\n      } = response as any\n\n      if (typeof loginResponse.data === 'object') {\n        clearLoop()\n        const params = getUrlParams(loginResponse.data.url)\n        const fullUserInfo = await getCardInfo(params.DedeUserID) as any\n        store.userInfo = {\n          oauthKey,\n          mid: params.DedeUserID,\n          midmd5: params.DedeUserID__ckMd5,\n          bili_jct: params.bili_jct,\n          expires: params.Expires,\n          sessdata: params.SESSDATA,\n          sid: params.sid === '' ? rawHeaders['set-cookie'][0].split(';')[0].split('=')[1] : params.sid,\n          mname: fullUserInfo.data.card.name,\n          avatarUrl: fullUserInfo.data.card.face,\n          lastLogin: new Date().getTime(),\n        }\n        store.storeUserInfo()\n        // console.log(headers, rawHeaders)\n        resolve(true)\n      }\n\n      // eslint-disable-next-line no-console\n      console.log('待确认', loginResponse)\n    }, 3000)\n  })\n}\n\nexport {\n  interval,\n  createLoginLoop,\n  clearLoop,\n}\n"
  },
  {
    "path": "src/composables/logout.ts",
    "content": "import { Body, fetch } from '@tauri-apps/api/http'\nimport getCookies from './getCookies'\nimport { logOutApi } from './api'\nimport { useStore } from '~/stores/store'\n\nconst store = useStore()\n\nconst cookies = getCookies()\n\nconst form = Body.form({\n  biliCSRF: store.getUserInfo.bili_jct,\n})\n\nexport default async function logout() {\n  if (cookies === '')\n    throw new Error('尚未登录')\n  const response = await fetch(logOutApi, {\n    method: 'POST',\n    headers: {\n      'Content-Type': 'application/x-www-form-urlencoded',\n      'cookie': cookies,\n    },\n    body: form,\n  })\n\n  // eslint-disable-next-line no-console\n  console.log(response.data)\n\n  return response.data\n}\n"
  },
  {
    "path": "src/composables/msgSend.ts",
    "content": "import { invoke } from '@tauri-apps/api/tauri'\nimport getCookies from './getCookies'\nimport { useStore } from '~/stores/store'\n\nconst store = useStore()\nconst roomId = store.getRoomId\n\nconst cookie = getCookies()\n\nfunction sendSingleMsg(msg: string) {\n  const payload = {\n    msg,\n    cookie,\n    roomid: roomId,\n    csrf: store.getUserInfo.bili_jct,\n  }\n  invoke('send_message', payload)\n    .then(() => {\n      // eslint-disable-next-line no-console\n      console.log('发送成功')\n    })\n    .catch((err: string) => {\n      throw new Error(err)\n    })\n}\n\nfunction sendMsg(msg: string) {\n  if (cookie === '')\n    throw new Error('尚未登录')\n\n  for (let i = 0; i * 20 < msg.length; i++) {\n    const partial = msg.substring(i * 20, i * 20 + 20)\n    setTimeout(() => {\n      sendSingleMsg(partial)\n    }, i * 1500)\n  }\n}\n\nexport {\n  sendMsg,\n}\n"
  },
  {
    "path": "src/composables/openLive.ts",
    "content": "import { Body, fetch } from '@tauri-apps/api/http'\nimport { useStorage } from '@vueuse/core'\nimport { liveAreaInfoListApi, startLiveApi, stopLiveApi, updateLiveTitleApi } from './api'\nimport type { LiveAreaInfo, StartLiveResponse } from './types'\nimport getCookies from './getCookies'\nimport { useStore } from '~/stores/store'\n\nconst store = useStore()\nconst selectedArea = useStorage('selectedArea', '')\nconst cookie = getCookies()\n\nasync function getAreaInfoList() {\n  if (store.liveConfig.liveAreaList.length > 0)\n    return\n\n  const { data } = await fetch(liveAreaInfoListApi)\n  store.liveConfig.liveAreaList = (data as any).data as LiveAreaInfo[]\n}\n\nasync function updateLiveTitle(roomId: string, title: string) {\n  if (cookie === '')\n    throw new Error('尚未登录')\n\n  const { data } = await fetch(updateLiveTitleApi, {\n    method: 'POST',\n    headers: {\n      cookie,\n      'content-type': 'application/x-www-form-urlencoded',\n    },\n    body: Body.form({\n      room_id: roomId,\n      title,\n      csrf: store.getUserInfo.bili_jct,\n    }),\n  }) as any\n  if (data.code !== 0)\n    throw new Error('标题更新失败')\n}\n\nasync function startLive(roomId: string, area_v2: number, platform: string) {\n  const { data }: { data: StartLiveResponse } = await fetch(startLiveApi, {\n    method: 'POST',\n    headers: {\n      cookie,\n      'content-type': 'application/x-www-form-urlencoded',\n    },\n    body: Body.form({\n      room_id: roomId,\n      area_v2: area_v2.toString(),\n      platform,\n      csrf: store.getUserInfo.bili_jct,\n    }),\n  })\n\n  // // eslint-disable-next-line no-console\n  // console.log(data)\n\n  if (data.code === 0) {\n    // eslint-disable-next-line no-console\n    console.log('直播开启成功')\n    return data.data.rtmp\n  }\n  else {\n    throw new Error(data.msg)\n  }\n}\n\nasync function stopLive(roomId: string) {\n  const { data }: { data: { code: number; msg: string } } = await fetch(stopLiveApi, {\n    method: 'POST',\n    headers: {\n      cookie,\n      'content-type': 'application/x-www-form-urlencoded',\n    },\n    body: Body.form({\n      room_id: roomId,\n      csrf: store.getUserInfo.bili_jct,\n    }),\n  })\n\n  // // eslint-disable-next-line no-console\n  // console.log(data)\n\n  if (data.code === 0) {\n    // eslint-disable-next-line no-console\n    console.log('直播关闭成功')\n  }\n  else {\n    throw new Error(data.msg)\n  }\n}\n\nexport {\n  getAreaInfoList,\n  updateLiveTitle,\n  selectedArea,\n  startLive,\n  stopLive,\n}\n"
  },
  {
    "path": "src/composables/parseFanNumbers.ts",
    "content": "export default function (num: number) {\n  if (num >= 1e8)\n    return `${(num / 1e8).toFixed(1)} 亿`\n\n  if (num >= 10000)\n    return `${(num / 10000).toFixed(1)} 万`\n\n  return `${num}`\n}\n"
  },
  {
    "path": "src/composables/priceToSeconds.ts",
    "content": "function priceToSeconds(price: number) {\n  if (price <= 2000)\n    return 5\n  if (price <= 10000)\n    return 10\n  if (price <= 30000)\n    return 30\n  if (price <= 100000)\n    return 60\n  if (price <= 300000)\n    return 180\n  return 300\n}\n\nexport {\n  priceToSeconds,\n}\n"
  },
  {
    "path": "src/composables/randomColor.ts",
    "content": "function hslToRgb(h: number, s: number, l: number) {\n  s /= 100\n  l /= 100\n  const k = (n: number) => (n + h / 30) % 12\n  const a = s * Math.min(l, 1 - l)\n  const f = (n: number) =>\n    l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)))\n  return [255 * f(0), 255 * f(8), 255 * f(4)].map(Math.round)\n}\n\nfunction randomColor() {\n  const colorAngle = Math.floor(Math.random() * 360)\n\n  const [r, g, b] = hslToRgb(colorAngle, 60, 50)\n\n  return `rgb(${r}, ${g}, ${b})`\n}\n\nfunction rgbToHex(r: number, g: number, b: number) {\n  let res = '#'\n  res += (r < 16 ? '0' : '') + r.toString(16)\n  res += (g < 16 ? '0' : '') + g.toString(16)\n  res += (b < 16 ? '0' : '') + b.toString(16)\n  return res\n}\n\nfunction randomColorPair() {\n  const colorAngle = Math.floor(Math.random() * 280 + 80)\n\n  const [r1, g1, b1] = hslToRgb(colorAngle, 60, 90)\n  const topColor = rgbToHex(r1, g1, b1)\n  const [r2, g2, b2] = hslToRgb(colorAngle, 70, 30)\n  const bottomColor = rgbToHex(r2, g2, b2)\n  return [topColor, bottomColor]\n}\n\nfunction rgbAppendAlpha(color: string) {\n  return color.replace(/^(rgb)\\((\\d+, \\d+, \\d+)\\)$/, (match, p1, p2) => `${p1}a(${p2}, 0.5)`)\n}\n\nfunction getLightnessFromHex(hex: string) {\n  const [r, g, b] = hex.replace(/^#/, '').match(/../g)!.map(n => parseInt(n, 16))\n  return (r * 299 + g * 587 + b * 114) / 1000\n}\n\nfunction getLightnessFromRgb(rgb: string) {\n  const [r, g, b] = rgb.match(/\\d+/g)!.map(n => parseInt(n, 10))\n  return (r * 299 + g * 587 + b * 114) / 1000\n}\n\nfunction hex2rgb(hex: string, opacity: string) {\n  const matches = hex.match(/^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i) as [string, string, string, string]\n  return `rgba(${parseInt(matches[1], 16)}, ${parseInt(matches[2], 16)}, ${parseInt(matches[3], 16)}, ${parseInt(opacity) / 255})`\n}\n\nconst LIGHTNESS_LIMIT = 120\n\nexport default randomColor\n\nexport {\n  rgbAppendAlpha,\n  getLightnessFromHex,\n  getLightnessFromRgb,\n  randomColorPair,\n  LIGHTNESS_LIMIT,\n  hex2rgb,\n}\n"
  },
  {
    "path": "src/composables/server.ts",
    "content": "import { KeepLiveWS } from 'bilibili-live-ws'\nimport { fetch } from '@tauri-apps/api/http'\nimport { useStorage } from '@vueuse/core'\nimport { ref } from 'vue'\nimport type {\n  DanmakuProps,\n  GiftProps,\n  InteractProps,\n  SuperChatProps,\n} from './components'\nimport type {\n  DanmakuMessage,\n  GiftInfo,\n  GuardBuyMessage,\n  InteractiveWordMessage,\n  SendGiftMessage,\n  SuperChatMessage,\n} from './types'\nimport { giftInfo } from './api'\nimport { autoSendByWord } from './autoSendMsg'\nimport { guardType } from './data'\nimport getLastMatchedGift from './getLastMatchedGift'\nimport parseFanNumbers from './parseFanNumbers'\nimport { randomColorPair } from './randomColor'\nimport { priceToSeconds } from './priceToSeconds'\nimport { processTooLongSymbols } from './tooLongSymbols'\nimport { useStore } from '~/stores/store'\n\nconst roomId = useStorage('roomId', '')\nconst linked = ref(true)\nconst store = useStore()\nconst fans = ref('')\nconst population = ref('')\nconst danmakuPool = ref<Array<DanmakuProps | GiftProps | SuperChatProps | InteractProps>>([])\nconst selectedSc = ref<SuperChatProps | null>(null)\nconst chatPool = ref<Array<SuperChatProps>>([])\nconst enterQueue = ref<InteractProps[]>([])\n\nsetInterval(() => {\n  if (enterQueue.value.length >= 2)\n    enterQueue.value.shift()\n}, 500)\n\nlet live: KeepLiveWS | null = null\n\nconst pushObject = (obj: DanmakuProps | GiftProps | SuperChatProps | InteractProps) => {\n  danmakuPool.value.push(obj)\n  if (danmakuPool.value.length > 100)\n    danmakuPool.value.shift()\n}\n\nconst pushChat = (chat: SuperChatProps) => {\n  chatPool.value.push(chat)\n  setTimeout(() => {\n    chatPool.value = chatPool.value.filter(x => x.ts !== chat.ts)\n    if (selectedSc.value?.ts === chat.ts)\n      selectedSc.value = null\n  }, chat.second * 1000)\n}\n\nconst connectRoom = () => {\n  try {\n    live = new KeepLiveWS(Number.parseInt(roomId.value))\n    linked.value = true\n\n    live.on('open', () => {\n      // eslint-disable-next-line no-console\n      console.log('WebSocket Open')\n\n      fetch(`${giftInfo}${roomId.value}`)\n        .then((response) => {\n          store.giftInfoList = (response.data as any).data.list.map((it: any) => {\n            return {\n              id: it.id,\n              webp: it.webp,\n            } as GiftInfo\n          })\n        })\n    })\n\n    // 结束连接\n    live.on('close', () => {\n      // eslint-disable-next-line no-console\n      console.log('WebSocket Close')\n    })\n\n    live.on('heartbeat', (online: number) => {\n      population.value = parseFanNumbers(online)\n    })\n\n    // 好像这个 api 没用，或许是 bilibili-live-ws 没写进去\n    // 欢迎用户进入直播间的 api 好像也没用\n    // live.on('ROOM_REAL_TIME_MESSAGE_UPDATA', (data) => {\n    //   // eslint-disable-next-line no-console\n    //   console.log(data)\n    //   const { data: { fans_num } } = data\n    //   fans.value = parseFanNumbers(fans_num)\n    // })\n\n    live.on('INTERACT_WORD', (data: InteractiveWordMessage) => {\n      const { data: { msg_type, uname, uid, uname_color, trigger_time } } = data\n      const interact: InteractProps = {\n        type: 'interact',\n        ts: trigger_time / 1000,\n        uid,\n        uname,\n        unameColor: uname_color,\n        action: msg_type,\n      }\n      if (store.getConfig.showEnter && msg_type === 1) {\n        // 用户进入直播间\n        // pushObject(interact)\n        enterQueue.value.push(interact)\n        if (enterQueue.value.length > 20)\n          enterQueue.value.splice(0, 15)\n      }\n      else if (store.getConfig.showSubscribe && msg_type === 2) {\n        // 用户关注主播\n        pushObject(interact)\n      }\n    })\n\n    live.on('SEND_GIFT', (data: SendGiftMessage) => {\n      const { data: { face, timestamp, coin_type, uname, giftName, num, giftId, action, total_coin, uid, blind_gift } } = data\n\n      if (coin_type === 'silver' && !store.getConfig.showSilverGift)\n        return\n\n      if (!store.getConfig.showGoldGift)\n        return\n      const [bgColor, bgBottomColor] = randomColorPair()\n\n      if (danmakuPool.value.length > 0) {\n        if (getLastMatchedGift(danmakuPool.value, uname, giftId, timestamp, num))\n          return\n      }\n\n      const gift: GiftProps = {\n        type: 'gift',\n        uname,\n        action,\n        num,\n        coinType: coin_type,\n        face: `${face}@96w_96h`,\n        giftId,\n        giftName,\n        price: total_coin, // 实际价格 * 1000\n        ts: timestamp,\n        uid,\n        blindGift: blind_gift,\n        bgColor: bgBottomColor,\n      }\n      pushObject(gift)\n\n      if (store.getConfig.showHighlight && coin_type === 'gold' && store.getConfig.pushGiftIntoHighlight) {\n        const chat: SuperChatProps = {\n          type: 'superchat',\n          uid,\n          uname,\n          face,\n          price: total_coin, // 实际价格 * 1000\n          content: `${action}${giftName}`,\n          contentJpn: '',\n          ts: timestamp * 1000,\n          second: priceToSeconds(total_coin),\n          bgColor,\n          bgBottomColor,\n        }\n        pushChat(chat)\n      }\n    })\n\n    live.on('DANMU_MSG', (data: DanmakuMessage) => {\n      // // eslint-disable-next-line no-console\n      // console.log(data)\n      const { info } = data\n      const perhapsLottery = info[0][9]\n      if (perhapsLottery !== 0)\n        return\n      const [, content, [uid, uname, fang, , , , ,color = ''], [level = 0, label = ''],,,,perhapsGuard] = info\n      const ts = info[0][4]\n      let tagColor = info[3][9] || 0\n      if (store.getConfig.showGuardTag === 2)\n        tagColor = info[3][4] || 0\n\n      if (store.getConfig.blackList.includes(uid))\n        return\n\n      if (store.getConfig.autoReply) {\n        setTimeout(() => {\n          autoSendByWord(content)\n        }, 1000)\n      }\n\n      const danmaku: DanmakuProps = {\n        type: 'text',\n        uid,\n        uname,\n        content: processTooLongSymbols(content),\n        color,\n        tagColor,\n        fang,\n        level,\n        label,\n        perhapsGuard,\n        ts,\n      }\n\n      if (typeof info[0][13] === 'object')\n        danmaku.content = info[0][13].url\n\n      pushObject(danmaku)\n    })\n\n    live.on('SUPER_CHAT_MESSAGE_JPN', (data: SuperChatMessage) => {\n      // // eslint-disable-next-line no-console\n      // console.log(data)\n      const { data: { uid, user_info: { uname, face }, price, message_jpn, message, ts, time, background_color, background_bottom_color } } = data\n      const chat: SuperChatProps = {\n        type: 'superchat',\n        uid: Number.parseInt(uid),\n        uname,\n        face,\n        price: price * 1000, // 实际价格 * 1000\n        content: message,\n        contentJpn: message_jpn.trim() !== '' ? message_jpn : message,\n        ts: ts * 1000,\n        second: time,\n        bgColor: background_color,\n        bgBottomColor: background_bottom_color,\n      }\n\n      // // eslint-disable-next-line no-console\n      // console.log(chat)\n\n      pushObject(chat)\n      if (store.getConfig.showHighlight)\n        pushChat(chat)\n    })\n\n    // live.on('SUPER_CHAT_MESSAGE', (data) => {\n    //   // eslint-disable-next-line no-console\n    //   console.log(data)\n    // })\n\n    live.on('GUARD_BUY', (data: GuardBuyMessage) => {\n      // // eslint-disable-next-line no-console\n      // console.log(data)\n\n      const { data: { uid, username, num, price, guard_level, ts } } = data\n      const guard: SuperChatProps = {\n        type: 'superchat',\n        uname: username,\n        face: '',\n        uid,\n        price: price * num, // 实际价格 * 1000\n        content: '欢迎加入大航海',\n        contentJpn: '',\n        second: guardType[guard_level].second,\n        ts: ts * 1000,\n        bgColor: guardType[guard_level].bgColor,\n        bgBottomColor: guardType[guard_level].bgBottomColor,\n      }\n\n      pushObject(guard)\n      if (store.getConfig.showHighlight)\n        pushChat(guard)\n    })\n  }\n  catch (e) {\n    // eslint-disable-next-line no-console\n    console.log(e)\n  }\n}\n\nconst disconnectRoom = () => {\n  if (live) {\n    live.close()\n    live = null\n    linked.value = false\n  }\n}\n\nexport {\n  connectRoom,\n  disconnectRoom,\n  population,\n  fans,\n  danmakuPool,\n  linked,\n  chatPool,\n  selectedSc,\n  pushChat,\n  enterQueue,\n}\n"
  },
  {
    "path": "src/composables/shortIdToLong.ts",
    "content": "import { fetch } from '@tauri-apps/api/http'\nimport { shortIdToLongApi } from './api'\n\nasync function shortToLongResponse(id: number) {\n  const response = (await fetch(`${shortIdToLongApi}${id}`)).data as any\n  return response\n}\n\nasync function shortToLong(id: number) {\n  const response = await shortToLongResponse(id)\n  return response.data.room_id as number | undefined\n}\n\nexport {\n  shortToLong,\n}\n"
  },
  {
    "path": "src/composables/tooLongSymbols.ts",
    "content": "function processTooLongSymbols(content: string) {\n  const match = content.match(/^(.)\\1{6,20}$/)\n  if (match)\n    return `${content.slice(0, 6)}...`\n  return content\n}\n\nexport {\n  processTooLongSymbols,\n}\n"
  },
  {
    "path": "src/composables/types.ts",
    "content": "type MsgCommand = 'INTERACT_WORD'\n| 'DANMU_MSG' // 弹幕信息\n| 'ROOM_REAL_TIME_MESSAGE_UPDATA' // 有关注人数\n| 'WATCHED_CHANGE' // 观看人数\n| 'ENTRY_EFFECT' // 欢迎舰长进入直播间\n| 'WELCOME' // 欢迎xxx进入直播间\n| 'WELCOME_GUARD' // 欢迎xxx进入直播间\n| 'SEND_GIFT' // 礼物\n| 'COMBO_SEND' // 连击\n| 'SUPER_CHAT_MESSAGE' // sc\n| 'SUPER_CHAT_MESSAGE_JPN'\n| 'GUARD_BUY' // 上舰长\n| 'USER_TOAST_MSG' // 续费舰长\n| '__CONNECTED__' // 连接成功\n| '__ERROR__' // 报错\n\ninterface MessageType {\n  cmd: MsgCommand\n}\n\ninterface DanmakuMessage extends MessageType {\n  cmd: 'DANMU_MSG'\n  info: [\n    config: [\n      n0: number,\n      n1: number,\n      n2: number,\n      n3: number,\n      timestamp: number,\n      n5: number,\n      n6: number,\n      n7: string,\n      n8: number,\n      perhapsLottery: number, // 如果是抽奖弹幕，这个值不是 0\n      n10: number,\n      n11: any,\n      n12: any,\n      n13: string | {\n        bulge_display: number\n        emoticon_unique: string\n        height: number\n        in_player_area: number\n        is_dynamic: number\n        url: string\n        width: number\n      },\n      n14: any,\n    ],\n    content: string,\n    userInfo: [uid: number, uname: string, n2: number, n3: number, n4: number, n5: number, n6: number, color: string],\n    label: [level: number, label: string, extLabel: string, roomId: number, colorInt: number, n5: string, n6: number, n7: number, n8: number, n9: number],\n    rank: Array<any>,\n    title: [string, string],\n    n6: number,\n    perhapsGuard: 0 | 1 | 2 | 3, // 不为 0 是舰长\n    n8: any,\n  ]\n}\n\ninterface WatchedMessage extends MessageType {\n  cmd: 'WATCHED_CHANGE'\n  data: {\n    num: number\n  }\n}\n\ninterface SubscriberMessage extends MessageType {\n  cmd: 'ROOM_REAL_TIME_MESSAGE_UPDATA'\n  data: {\n    fans: number\n    fans_club: number\n    roomid: number\n    red_notice: number\n  }\n}\n\ninterface SendGiftMessage extends MessageType {\n  cmd: 'SEND_GIFT'\n  data: {\n    face: string // 头像地址\n    giftType: number\n    timestamp: number\n    coin_type: 'gold' | 'silver'\n    uid: number\n    uname: string\n    giftName: string\n    num: number\n    total_coin: number\n    giftId: number\n    action: string\n    blind_gift: {\n      blind_gift_config_id: number\n      from: number\n      gift_action: string\n      original_gift_id: string\n      original_gift_name: string\n    } | null\n  }\n}\n\ninterface GuardBuyMessage extends MessageType {\n  cmd: 'GUARD_BUY'\n  data: {\n    uid: number\n    username: string\n    gift_name: string\n    num: number\n    price: number\n    guard_level: 1 | 2 | 3\n    ts: number\n  }\n}\n\ninterface SuperChatMessage extends MessageType {\n  cmd: 'SUPER_CHAT_MESSAGE_JPN'\n  data: {\n    uid: string\n    user_info: {\n      uname: string\n      face: string\n    }\n    price: number\n    message_jpn: string\n    message: string\n    background_bottom_color: string\n    background_color: string\n    ts: number\n    time: number\n  }\n}\n\ninterface WelcomeGuardMessage extends MessageType {\n  cmd: 'WELCOME_GUARD'\n  data: {\n    uid: number\n    username: string\n    guard_level: number\n  }\n}\n\ninterface InteractiveWordMessage extends MessageType {\n  cmd: 'INTERACT_WORD'\n  data: {\n    contribution: {\n      grade: number\n    }\n    identities: [number]\n    is_spread: number\n    msg_type: 1 | 2\n    roomid: number\n    uid: number\n    uname: string\n    uname_color: string\n    trigger_time: number // 除以 1000 后就可以是一个合法的时间\n    timestamp: number // 时间戳 / 1000\n  }\n}\n\ninterface ComboSendMessage extends MessageType {\n  cmd: 'COMBO_SEND'\n  data: {\n    gift_id: number\n    gift_name: string\n    gift_nun: string\n    is_show: number\n    uid: number\n    uname: string\n    action: string\n    batch_combo_id: string\n    batch_combo_num: number\n    combi_id: string\n    combo: number\n    combo_total_coin: number\n  }\n}\n\ninterface SendMessageProps {\n  bubble: number // 0\n  msg: string // 发出的消息\n  color: number // 颜色\n  mode: number // 1\n  fontsize: number // 25\n  rnd: number // 时间戳 / 1000\n  roomid: number // 直播间房间号\n  csrf: string\n  csrf_token: string\n}\n\ninterface GiftInfo {\n  id: number\n  webp: string\n}\n\ninterface LiveAreaInfo {\n  id: number\n  name: string\n  list: Array<{\n    id: string\n    name: string\n  }>\n}\n\ninterface StartLiveResponse {\n  code: number\n  msg: string\n  data: {\n    change: 0 | 1\n    status: string\n    rtmp: {\n      addr: string\n      code: string\n    }\n  }\n}\n\ninterface SpaceApiResponse {\n  code: number\n  data: {\n    info: {\n      face: string\n      live: {\n        roomid: number\n        title: string\n      }\n    }\n  }\n}\n\ninterface CardInfoResponse {\n  code: number\n  data: {\n    card: {\n      face: string\n    }\n  }\n}\n\nexport type {\n  MsgCommand,\n  DanmakuMessage,\n  WatchedMessage,\n  SubscriberMessage,\n  SendGiftMessage,\n  GuardBuyMessage,\n  SuperChatMessage,\n  WelcomeGuardMessage,\n  InteractiveWordMessage,\n  ComboSendMessage,\n  GiftInfo,\n  SendMessageProps,\n  LiveAreaInfo,\n  StartLiveResponse,\n  SpaceApiResponse,\n  CardInfoResponse,\n}\n\n"
  },
  {
    "path": "src/layouts/default.vue",
    "content": "<script setup lang=\"ts\">\nimport { listen } from '@tauri-apps/api/event'\nimport { tryOnBeforeUnmount } from '@vueuse/core'\nimport SideBar from '~/components/SideBar.vue'\nimport { useStore } from '~/stores/store'\n\nconst store = useStore()\nconst unlistens: Function[] = []\n\nasync function unlistenAdd() {\n  unlistens.push(await listen('add-black', (event) => {\n    const uid = parseInt(event.payload as string)\n    if (!store.config.blackList.includes(uid)) {\n      store.config.blackList.push(uid)\n      store.settingsSaved = false\n    }\n  }))\n}\n\nunlistenAdd()\n\ntryOnBeforeUnmount(() => {\n  unlistens.map(fn => fn())\n})\n</script>\n\n<template>\n  <div class=\"use-dark\">\n    <SideBar />\n    <div ml-2rem flex-1>\n      <RouterView />\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/layouts/none.vue",
    "content": "<script setup lang=\"ts\">\n\n</script>\n\n<template>\n  <RouterView />\n</template>\n"
  },
  {
    "path": "src/main.ts",
    "content": "import { createApp } from 'vue'\nimport { createRouter, createWebHistory } from 'vue-router'\nimport generatedRoutes from 'virtual:generated-pages'\nimport { setupLayouts } from 'virtual:generated-layouts'\nimport { Buffer } from 'buffer/'\nimport { WebviewWindow } from '@tauri-apps/api/window'\nimport { tryOnUnmounted } from '@vueuse/core'\nimport App from './App.vue'\nimport { pinia } from '~/stores'\n\nimport '@unocss/reset/tailwind.css'\nimport './styles/main.css'\nimport 'uno.css'\n\n(window as any).Buffer = Buffer\nconst app = createApp(App)\n// const pinia = createPinia()\n\nconst routes = setupLayouts(generatedRoutes)\n\nconst router = createRouter({\n  history: createWebHistory(import.meta.env.BASE_URL),\n  routes,\n})\n\napp.use(pinia)\n\napp.use(router)\napp.mount('#app')\n\nconst mainWindow = WebviewWindow.getByLabel('main');\n(async () => {\n  const unlisten = await mainWindow?.onCloseRequested((_event) => {\n    const danmakuWindow = WebviewWindow.getByLabel('danmakuWidget')\n    if (danmakuWindow)\n      danmakuWindow.close()\n\n    const senderWindow = WebviewWindow.getByLabel('senderWindow')\n    if (senderWindow)\n      senderWindow.close()\n  })\n\n  tryOnUnmounted(() => {\n    unlisten?.()\n  })\n})()\n\n"
  },
  {
    "path": "src/pages/index.vue",
    "content": "<script setup lang=\"ts\">\nimport { WebviewWindow } from '@tauri-apps/api/window'\nimport { invoke } from '@tauri-apps/api/tauri'\nimport { useStorage, useThrottleFn } from '@vueuse/core'\nimport type { Ref } from 'vue'\nimport { inject, ref } from 'vue'\nimport UMdInput from '~/components/ui/UMdInput.vue'\nimport UCheckBox from '~/components/ui/UCheckBox.vue'\nimport { shortToLong } from '~/composables/shortIdToLong'\nimport { useStore } from '~/stores/store'\nimport { eventEmitter } from '~/composables/eventEmitter'\nimport { usePosition } from '~/stores/position'\nimport { loadPos } from '~/composables/load_pos'\nimport { msgKey } from '~/composables/injectionKeys'\nimport type { MessageProvider } from '~/types'\n\nconst roomId = useStorage('roomId', '')\n\nlet webview: WebviewWindow | null = null\nconst msgRef = inject<Ref<MessageProvider>>(msgKey)\nconst store = useStore()\nconst isLoadingRoomId = ref(false)\nconst pos = usePosition()\n\nasync function createWebview() {\n  if (roomId.value.trim() === '') {\n    msgRef?.value.pushMsg('房间号不能为空！', {\n      type: 'warning',\n    })\n    return\n  }\n  webview = WebviewWindow.getByLabel('danmakuWidget')\n  if (webview) {\n    webview.close()\n    webview = null\n    store.linked = false\n    // eslint-disable-next-line no-console\n    console.log('关闭窗口')\n    const senderWindow = WebviewWindow.getByLabel('senderWindow')\n    if (senderWindow)\n      senderWindow.close()\n\n    store.clickThrough = false\n\n    return\n  }\n\n  await invoke('create_new_danmaku_view')\n\n  store.linked = true\n  msgRef?.value.pushMsg('窗口已开启')\n}\n\nfunction tryToCloseDanmaku() {\n  webview = WebviewWindow.getByLabel('danmakuWidget')\n  if (!webview) {\n    webview = new WebviewWindow('danmakuWidget', {\n      url: '/show',\n      decorations: false,\n      width: 400,\n      height: 600,\n      transparent: true,\n      alwaysOnTop: true,\n      title: 'D4nm4ku',\n      minWidth: 320,\n      minHeight: 150,\n    })\n  }\n  if (webview) {\n    webview.close()\n    webview = null\n    store.linked = false\n    // eslint-disable-next-line no-console\n    console.log('关闭窗口')\n  }\n}\n\nfunction roomIdBlured() {\n  if (roomId.value.trim() === '')\n    return\n  const fakeId = Number(roomId.value)\n  if (fakeId <= 1000 && fakeId > 0) {\n    isLoadingRoomId.value = true\n    shortToLong(fakeId)\n      .then((id) => {\n        roomId.value = String(id)\n      })\n      .catch((err) => {\n        msgRef?.value.pushMsg(err.message, {\n          type: 'error',\n        })\n      })\n      .finally(() => {\n        isLoadingRoomId.value = false\n      })\n  }\n}\n\nasync function setClickThrough() {\n  if (store.clickThrough) {\n    store.previousCanSend = store.config.canSendMessage\n    if (store.config.canSendMessage) {\n      eventEmitter('can-send-message', false)\n      openSenderWindow()\n    }\n  }\n  else {\n    store.config.canSendMessage = store.previousCanSend\n    if (store.previousCanSend) {\n      eventEmitter('can-send-message', store.config.canSendMessage)\n      openSenderWindow()\n    }\n  }\n\n  // eventEmitter('set-click-through', store.clickThrough)\n  const res: boolean = await invoke('set_click_through', { enable: store.clickThrough })\n  msgRef?.value.pushMsg(`点击穿透功能已${res ? '开启' : '关闭'}`)\n}\n\nasync function openSenderWindow() {\n  if (!store.getUserInfo.mid) {\n    msgRef?.value.pushMsg('发送弹幕需要登录')\n    return\n  }\n  let senderWindow = WebviewWindow.getByLabel('senderWindow')\n  if (senderWindow) {\n    store.senderEnabled = false\n    senderWindow.close()\n    senderWindow = null\n    return\n  }\n\n  await invoke('create_sender_window')\n  store.senderEnabled = true\n  msgRef?.value.pushMsg('弹幕发送浮窗已开启')\n}\n\nconst pinned = ref(true)\nconst pinWidget = () => {\n  const danmakuWidget = WebviewWindow.getByLabel('danmakuWidget')\n  if (danmakuWidget)\n    danmakuWidget.setAlwaysOnTop(pinned.value)\n}\n\nconst storePosition = useThrottleFn(() => {\n  pos.storeConfig()\n    .then(() => {\n      msgRef?.value.pushMsg('保存成功', { type: 'success' })\n    })\n    .catch((err) => {\n      msgRef?.value.pushMsg(`保存失败, ${err.message}`, { type: 'error' })\n    })\n})\n\nconst loadPosition = useThrottleFn(() => {\n  const conf = pos.getConfig()\n  loadPos(conf)\n    .then(() => {\n      msgRef?.value.pushMsg('加载成功', { type: 'success' })\n    })\n    .catch((err) => {\n      msgRef?.value.pushMsg(`加载失败, ${err.message}`, { type: 'error' })\n    })\n})\n</script>\n\n<template>\n  <div h-100vh flex flex-col>\n    <div flex-1 flex justify-center>\n      <div self-end text-2xl>\n        D4nm4ku\n      </div>\n    </div>\n    <div flex items-center>\n      <div flex-1 />\n      <UMdInput\n        v-model=\"roomId\"\n        title=\"直播间号\"\n        :disabled=\"store.linked\"\n        @blur=\"roomIdBlured\"\n      />\n      <div flex-1>\n        <button\n          p-2 m-2\n          bg=\"#646cff\"\n          rounded-full\n          shadow hover:shadow-lg\n          op=\"90 hover:100\"\n          text-white\n          cursor-pointer\n          class=\"disabled:bg-zinc disabled:dark:bg-zinc-600 disabled:dark:text-zinc-800 disabled:cursor-not-allowed\"\n          :disabled=\"!roomId.trim().match(/^\\d+$/) || isLoadingRoomId\"\n          @click=\"createWebview\"\n        >\n          <div v-if=\"isLoadingRoomId\" i-ri-refresh-line animate-spin />\n          <div v-else-if=\"!store.linked\" i-ri-arrow-right-line />\n          <div v-else i-ri-stop-fill />\n        </button>\n      </div>\n    </div>\n    <div flex-1 flex flex-col>\n      <div flex>\n        <div flex-1 />\n        <div flex flex-col>\n          <UCheckBox\n            v-model=\"pinned\"\n            @update:model-value=\"pinWidget\"\n          >\n            窗口置顶\n          </UCheckBox>\n          <UCheckBox\n            v-model=\"store.clickThrough\"\n            title=\"开启点击穿透后 弹幕窗口将不接受任何鼠标消息\"\n            :disabled=\"!store.linked\"\n            @update:model-value=\"setClickThrough\"\n          >\n            点击穿透（仅 macOS）\n          </UCheckBox>\n          <div\n            inline-flex items-center leading-relaxed select-none space-x-1 cursor-pointer\n            title=\"开启额外浮动窗口发送弹幕\"\n            @click=\"openSenderWindow\"\n          >\n            <div text-lg flex items-center>\n              <div icon-btn i-ri-window-line ml-1 />\n            </div>\n            <span>打开/关闭弹幕发送浮窗</span>\n          </div>\n          <div inline-flex items-center leading-relaxed select-none space-x-1>\n            <div text-lg flex items-center>\n              <div icon-btn i-ri-save-line ml-1 />\n            </div>\n            <div>\n              <button text-btn :disabled=\"!store.linked\" @click=\"storePosition\">\n                保存\n              </button>/<button :disabled=\"!store.linked\" text-btn @click=\"loadPosition\">\n                加载\n              </button>窗口大小和位置\n            </div>\n          </div>\n        </div>\n        <div flex-1 />\n      </div>\n      <div flex-1 />\n      <div mx-a my-2 i-ri-stop-circle-line icon-btn op=\"10 hover:100\" title=\"应急关闭\" @click=\"tryToCloseDanmaku\" />\n    </div>\n  </div>\n</template>\n"
  },
  {
    "path": "src/pages/live.vue",
    "content": "<script setup lang=\"ts\">\nimport { useClipboard, useStorage } from '@vueuse/core'\nimport type { Ref } from 'vue'\nimport { inject, ref } from 'vue'\nimport { getAreaInfoList, startLive, stopLive, updateLiveTitle } from '~/composables/openLive'\nimport { getLiveRoomInfoFromRoomId, getLiveRoomInfoFromUid } from '~/composables/getLiverInfo'\nimport { useStore } from '~/stores/store'\nimport UMdInput from '~/components/ui/UMdInput.vue'\nimport UTabSelector from '~/components/ui/UTabSelector.vue'\nimport { shortToLong } from '~/composables/shortIdToLong'\nimport type { MessageProvider } from '~/types'\nimport { msgKey } from '~/composables/injectionKeys'\n\nconst store = useStore()\nconst roomId2 = useStorage('roomId2', '')\nconst selectedAreaId = useStorage('selectedAreaId', 0)\nconst selectedAreaInfo = useStorage('selectedAreaInfo', '')\nconst liveTitle = useStorage('liveTitle', '')\nconst msgRef = inject<Ref<MessageProvider>>(msgKey)\nconst isShowAreaSelection = ref(false)\nconst btnEnabled = ref(true)\nconst firstLoad = ref(0)\nconst btnUpdateTitleEnabled = ref(true)\nconst btnShowAreaEnabled = ref(true)\n\nconst { copy } = useClipboard()\n\nif (!store.getUserInfo.mid)\n  msgRef?.value.pushMsg('需要登录才能开启直播哦')\n\nfunction updateLiveRoomInfo() {\n  if (roomId2.value.trim() === '' || liveTitle.value.trim() === '') {\n    getLiveRoomInfoFromUid(store.getUserInfo.mid)\n      .then(({ roomid, title }) => {\n        roomId2.value = roomid.toString()\n        liveTitle.value = title\n        return roomid\n      })\n      .catch((err) => {\n        msgRef?.value.pushMsg(`直播间信息获取失败！${err.message}`, {\n          type: 'error',\n        })\n      })\n  }\n  // 当前如果是开播的状态，但是主播可能手动关闭了弹幕姬，导致弹幕姬只有开播按钮\n  // 因此自动检测当前是否在开播状态，如果是，则自动变更按钮\n  if (!store.liveConfig.isLive && roomId2.value.trim() !== '' && liveTitle.value.trim() !== '' && selectedAreaId.value) {\n    getLiveRoomInfoFromRoomId(parseInt(roomId2.value))\n      .then(({ data }) => {\n        store.liveConfig.isLive = data.live_status === 1\n      })\n      .catch((err) => {\n        msgRef?.value.pushMsg(err.message, {\n          type: 'error',\n        })\n      })\n  }\n}\n\nif (store.getUserInfo.mid)\n  updateLiveRoomInfo()\n\nfunction updateLiveTitle2() {\n  btnUpdateTitleEnabled.value = false\n  updateLiveTitle(roomId2.value, liveTitle.value)\n    .then(() => {\n      msgRef?.value.pushMsg('标题修改成功', {\n        type: 'success',\n      })\n    })\n    .catch((e: Error) => {\n      msgRef?.value.pushMsg(\n        e.message,\n        { type: 'error' },\n      )\n    })\n    .finally(() => {\n      btnUpdateTitleEnabled.value = true\n    })\n}\n\nfunction showAreaSelection() {\n  btnShowAreaEnabled.value = false\n  if (firstLoad.value === 0) {\n    msgRef?.value.pushMsg('首次加载可能需要一段时间')\n    firstLoad.value++\n  }\n  getAreaInfoList()\n    .then(() => {\n      isShowAreaSelection.value = !isShowAreaSelection.value\n      btnShowAreaEnabled.value = true\n    })\n}\n\nfunction startLive2() {\n  btnEnabled.value = false\n  startLive(roomId2.value, selectedAreaId.value, 'pc')\n    .then((rtmp) => {\n      store.liveConfig.addr = rtmp.addr\n      store.liveConfig.code = rtmp.code\n      msgRef?.value.pushMsg('直播开启成功', {\n        type: 'success',\n      })\n      msgRef?.value.pushMsg('请将串流地址和密钥复制到直播软件（如 OBS）后开启推流', {\n        ttl: 6000,\n      })\n      store.liveConfig.isLive = true\n    })\n    .catch((e: Error) => {\n      msgRef?.value.pushMsg(\n        e.message,\n        { type: 'error' },\n      )\n    })\n    .finally(() => {\n      btnEnabled.value = true\n    })\n}\n\nfunction stopLive2() {\n  btnEnabled.value = false\n  stopLive(roomId2.value)\n    .then(() => {\n      msgRef?.value.pushMsg('直播关闭成功', {\n        type: 'success',\n      })\n      store.liveConfig.addr = ''\n      store.liveConfig.code = ''\n      store.liveConfig.isLive = false\n    })\n    .catch((e: Error) => {\n      msgRef?.value.pushMsg(\n        e.message,\n        { type: 'error' },\n      )\n    }).finally(() => {\n      btnEnabled.value = true\n    })\n}\n\nfunction copy2(source: string) {\n  copy(source)\n  msgRef?.value.pushMsg('复制成功', {\n    type: 'success',\n  })\n}\n\nconst loadingRoomId = ref(false)\n\nfunction roomIdBlur() {\n  if (roomId2.value.trim() === '')\n    return\n\n  const fakeId = Number(roomId2.value)\n  if (fakeId <= 1000 && fakeId > 0) {\n    loadingRoomId.value = true\n    shortToLong(fakeId)\n      .then((id) => {\n        roomId2.value = String(id)\n      })\n      .catch((err) => {\n        msgRef?.value.pushMsg(err.message, {\n          type: 'error',\n        })\n      })\n      .finally(() => {\n        loadingRoomId.value = false\n      })\n  }\n}\n</script>\n\n<template>\n  <div h-100vh flex flex-col>\n    <div flex-1 text-2xl flex justify-center>\n      <div self-end>\n        {{ store.liveConfig.isLive ? '正在直播' : 'Live!' }}\n      </div>\n    </div>\n    <div text-center>\n      <div flex items-center>\n        <div flex-1 />\n        <UMdInput\n          v-model=\"roomId2\"\n          title=\"房间号\"\n          :disabled=\"store.liveConfig.isLive\"\n          @blur=\"roomIdBlur\"\n        />\n        <div flex-1 flex items-center>\n          <div v-if=\"loadingRoomId\" i-ri-refresh-line icon-btn animate-spin />\n        </div>\n      </div>\n      <div flex items-center>\n        <div flex-1 />\n        <UMdInput v-model=\"liveTitle\" title=\"直播标题\" />\n        <div flex-1 flex items-center>\n          <div\n            v-if=\"btnUpdateTitleEnabled\"\n            i-ri-save-line\n            icon-btn\n            :disabled=\"liveTitle.trim() === '' || !store.getUserInfo.mid\"\n            @click=\"updateLiveTitle2\"\n          />\n          <div v-else i-ri-refresh-line animate-spin icon-btn />\n        </div>\n      </div>\n      <div flex items-center>\n        <div flex-1 />\n        <UMdInput\n          v-model=\"selectedAreaInfo\" title=\"选择分区\"\n          :disabled=\"!btnShowAreaEnabled\"\n          cursor-pointer\n          class=\"disabled:cursor-wait\"\n          @click=\"showAreaSelection\"\n        />\n        <div flex-1 flex items-center>\n          <div v-if=\"!btnShowAreaEnabled\" i-ri-refresh-line icon-btn animate-spin />\n        </div>\n      </div>\n      <div v-if=\"store.liveConfig.isLive\" flex items-center>\n        <div flex-1 />\n        <UMdInput v-model=\"store.liveConfig.addr\" title=\"RTMP 串流地址\" />\n        <div flex-1 flex items-center>\n          <div i-ri-file-copy-2-line icon-btn title=\"点击复制\" @click=\"copy2(store.liveConfig.addr)\" />\n        </div>\n      </div>\n      <div v-if=\"store.liveConfig.isLive\" flex items-center>\n        <div flex-1 />\n        <UMdInput v-model=\"store.liveConfig.code\" title=\"RTMP 串流密钥\" />\n        <div flex-1 flex items-center>\n          <div i-ri-file-copy-2-line icon-btn title=\"点击复制\" @click=\"copy2(store.liveConfig.code)\" />\n        </div>\n      </div>\n      <div m-2 space-x-2>\n        <button\n          v-if=\"!store.liveConfig.isLive\"\n          btn rounded\n          :disabled=\"!btnEnabled || !roomId2.trim().match(/^\\d+$/) || !store.getUserInfo.mid || !selectedAreaId || liveTitle.trim() === ''\"\n          @click=\"startLive2\"\n        >\n          开启直播\n        </button>\n        <button\n          v-else\n          :disabled=\"!btnEnabled\"\n          btn rounded\n          @click=\"stopLive2\"\n        >\n          关闭直播\n        </button>\n      </div>\n    </div>\n    <div flex-1 flex items-end>\n      <div mx-a my-2 i-ri-stop-circle-line icon-btn op=\"10 hover:100\" title=\"应急关闭\" @click=\"stopLive2\" />\n    </div>\n  </div>\n  <Transition name=\"selector\">\n    <UTabSelector\n      v-if=\"isShowAreaSelection\"\n      v-model:id=\"selectedAreaId\"\n      v-model:info=\"selectedAreaInfo\"\n      @update:id=\"showAreaSelection\"\n      @close=\"showAreaSelection\"\n    />\n  </Transition>\n</template>\n\n<style scoped>\n.selector-enter-active,\n.selector-leave-active {\n  transition: all 0.200s ease;\n}\n\n.selector-enter-from,\n.selector-leave-to {\n  opacity: 0;\n}\n</style>\n"
  },
  {
    "path": "src/pages/sender.vue",
    "content": "<script setup lang=\"ts\">\nimport { listen } from '@tauri-apps/api/event'\nimport { tryOnBeforeUnmount } from '@vueuse/core'\nimport UMessageSender from '../components/send/UMessageSender.vue'\nimport { useStore } from '../stores/store'\nimport { hex2rgb } from '~/composables/randomColor'\n\nconst store = useStore()\n\nconst unlistens: Function[] = []\nasync function initListens() {\n  unlistens.push(await listen('bg-color-changed', (event) => {\n    store.config.bgColor = event.payload as string\n  }))\n  unlistens.push(await listen('bg-opacity-changed', (event) => {\n    store.config.bgOpacity = event.payload as string\n  }))\n  unlistens.push(await listen('text-color-changed', (event) => {\n    store.config.textColor = event.payload as string\n  }))\n  unlistens.push(await listen('text-shadow-color-changed', (event) => {\n    store.config.textShadowColor = event.payload as string\n  }))\n  unlistens.push(await listen('enable-text-shadow', (event) => {\n    store.config.enableTextShadow = (event.payload as string) === 'true'\n  }))\n  unlistens.push(await listen('blur', (event) => {\n    store.config.blur = (event.payload as string) === 'true'\n  }))\n  unlistens.push(await listen('font-changed', (event) => {\n    store.config.fontFamily = event.payload as string\n  }))\n}\n\ninitListens()\n\ntryOnBeforeUnmount(() => {\n  unlistens.map(fn => fn())\n})\n</script>\n\n<template>\n  <div\n    flex items-center\n    :class=\"{\n      'backdrop-blur-sm': store.getConfig.blur,\n    }\"\n    :style=\"{\n      background: hex2rgb(store.getConfig.bgColor, store.getConfig.bgOpacity),\n      color: store.getConfig.textColor,\n      textShadow: store.getConfig.enableTextShadow ? `1px 1px 1px ${store.getConfig.textShadowColor}` : 'none',\n      fontFamily: store.getConfig.fontFamily,\n    }\"\n  >\n    <div cursor-move i-ri-drag-move-line icon-btn data-tauri-drag-region text-gray ml-2 />\n    <UMessageSender :no-border=\"true\" flex-1 />\n  </div>\n</template>\n\n<route lang=\"yaml\">\nmeta:\n  layout: none\n</route>\n\n"
  },
  {
    "path": "src/pages/settings.vue",
    "content": "<script setup lang=\"ts\">\nimport { inject } from 'vue'\nimport { confirm } from '@tauri-apps/api/dialog'\nimport { invoke } from '@tauri-apps/api/tauri'\nimport { appDir } from '@tauri-apps/api/path'\nimport { useThrottleFn } from '@vueuse/core'\nimport USettingsBox from '~/components/ui/USettingsBox.vue'\nimport UCheckBox from '~/components/ui/UCheckBox.vue'\nimport UColorPicker from '~/components/ui/UColorPicker.vue'\nimport { useStore } from '~/stores/store'\nimport Login from '~/components/settings/Login.vue'\nimport URadio from '~/components/ui/URadio.vue'\nimport USlider from '~/components/ui/USlider.vue'\nimport UMultiList from '~/components/ui/UMultiList.vue'\nimport UBlackList from '~/components/ui/UBlackList.vue'\nimport { eventEmitter } from '~/composables/eventEmitter'\nimport USelector from '~/components/ui/USelector.vue'\nimport { msgKey } from '~/composables/injectionKeys'\n\nconst msgRef = inject(msgKey)\nconst store = useStore()\n\nconst saveSettings = useThrottleFn(() => {\n  store.settingsSaved = true\n  store.storeConfig()\n  msgRef?.value.pushMsg('保存成功', { type: 'success' })\n}, 1000)\n\nconst settingChanged = (event: string, payload: any) => {\n  store.settingsSaved = false\n  eventEmitter(event, payload)\n}\n\nfunction openAppDir() {\n  appDir()\n    .then(async (dir) => {\n      return await invoke('open_app_img_dir', { dir })\n    })\n    .catch((err) => {\n      msgRef?.value.pushMsg(err.message, { type: 'error' })\n    })\n}\n\nasync function clearConfig() {\n  const confirmed = await confirm('确定要清空当前设置吗？', {\n    title: '还原默认设置', type: 'warning',\n  })\n  if (confirmed) {\n    store.removeConfig()\n    msgRef?.value.pushMsg('设置已还原！')\n  }\n}\n\nfunction setCanSend() {\n  settingChanged('can-send-message', store.config.canSendMessage)\n  if (store.getConfig.canSendMessage)\n    msgRef?.value.pushMsg('在点击穿透模式下，窗口将自动分裂为弹幕窗格和发送浮窗', { ttl: 8000 })\n}\n\nfunction setAutoReply() {\n  settingChanged('auto-reply', store.config.autoReply)\n  if (store.getConfig.autoReply)\n    msgRef?.value.pushMsg('保存设置后生效')\n}\n</script>\n\n<template>\n  <div p-4 space-y-4>\n    <Login />\n    <div flex space-x-2>\n      <div font-bold text-xl>\n        设置项\n      </div>\n      <div flex-1 />\n      <button\n        btn rounded\n        :disabled=\"store.settingsSaved\"\n        @click=\"saveSettings\"\n      >\n        保存设置\n      </button>\n      <button\n        border=\"~ zinc hover:#646cff\"\n        p=\"x-4 y-1\" op=\"80 hover:100\"\n        transition-all\n        rounded\n        title=\"如果有些新加的设置项无法修改，请尝试重置设置\"\n        @click=\"clearConfig\"\n      >\n        还原默认\n      </button>\n    </div>\n    <USettingsBox title=\"界面布局\">\n      <div space-x-2>\n        <URadio\n          v-model=\"store.config.layout\"\n          value=\"loose\" name=\"layout\"\n          @update:model-value=\"settingChanged('layout', store.config.layout)\"\n        >\n          松散\n        </URadio>\n        <URadio\n          v-model=\"store.config.layout\"\n          value=\"tight\" name=\"layout\"\n          @update:model-value=\"settingChanged('layout', store.config.layout)\"\n        >\n          紧凑\n        </URadio>\n      </div>\n      <UCheckBox\n        v-model=\"store.config.showPopulation\"\n        @update:model-value=\"settingChanged('show-population', store.config.showPopulation)\"\n      >\n        显示顶部栏\n      </UCheckBox>\n      <UCheckBox\n        v-model=\"store.config.showHighlight\"\n        @update:model-value=\"settingChanged('show-highlight', store.config.showHighlight)\"\n      >\n        显示高能榜\n      </UCheckBox>\n    </USettingsBox>\n    <USettingsBox title=\"常规\">\n      <UCheckBox\n        v-model=\"store.config.showAvatar\"\n        title=\"若弹幕数量过多，建议关闭，以免请求超时\"\n        @update:model-value=\"settingChanged('show-avatar', store.config.showAvatar)\"\n      >\n        显示用户头像\n      </UCheckBox>\n      <UCheckBox\n        v-model=\"store.config.showTime\"\n        @update:model-value=\"settingChanged('show-time', store.config.showTime)\"\n      >\n        显示弹幕发送时间\n      </UCheckBox>\n      <div flex space-x-1 items-center>\n        <div text-lg flex items-center>\n          <div i-ri-bank-card-line icon-btn ml-1 />\n        </div>\n        <span>\n          标签和等级\n        </span>\n        <USelector\n          v-model=\"store.config.showGuardTag\"\n          :options=\"[{ label: '不显示', value: 0 }, { label: '官方配置', value: 1 }, { label: '全部显示', value: 2 }]\"\n          @update:model-value=\"settingChanged('show-guard-tag', store.config.showGuardTag)\"\n        />\n      </div>\n      <UCheckBox\n        v-model=\"store.config.showEnter\"\n        @update:model-value=\"settingChanged('show-enter', store.config.showEnter)\"\n      >\n        显示进场信息\n      </UCheckBox>\n      <UCheckBox\n        v-model=\"store.config.showSubscribe\"\n        @update:model-value=\"settingChanged('show-subscribe', store.config.showSubscribe)\"\n      >\n        显示关注信息\n      </UCheckBox>\n      <div\n        inline-flex items-center leading-relaxed select-none space-x-1 cursor-pointer\n        @click=\"openAppDir\"\n      >\n        <div text-lg flex items-center>\n          <div icon-btn i-ri-folder-open-fill ml-1 />\n        </div>\n        <span>打开图片缓存目录</span>\n      </div>\n    </USettingsBox>\n    <USettingsBox title=\"礼物\">\n      <UCheckBox\n        v-model=\"store.config.showSilverGift\"\n        @update:model-value=\"settingChanged('show-silver-gift', store.config.showSilverGift)\"\n      >\n        显示免费礼物\n      </UCheckBox>\n      <UCheckBox\n        v-model=\"store.config.showGoldGift\"\n        @update:model-value=\"settingChanged('show-gold-gift', store.config.showGoldGift)\"\n      >\n        显示付费礼物\n      </UCheckBox>\n      <UCheckBox\n        v-model=\"store.config.pushGiftIntoHighlight\"\n        @update:model-value=\"settingChanged('push-gift-into-highlight', store.config.pushGiftIntoHighlight)\"\n      >\n        付费礼物加入高能榜\n      </UCheckBox>\n    </USettingsBox>\n\n    <USettingsBox title=\"样式\">\n      <UColorPicker\n        v-model=\"store.config.textColor\"\n        @update:model-value=\"settingChanged('text-color-changed', store.config.textColor)\"\n      >\n        文字颜色\n      </UColorPicker>\n      <div flex space-x-2>\n        <UCheckBox\n          v-model=\"store.config.enableTextShadow\"\n          @update:model-value=\"settingChanged('enable-text-shadow', store.config.enableTextShadow)\"\n        >\n          文字阴影\n        </UCheckBox>\n        <UColorPicker\n          v-model=\"store.config.textShadowColor\"\n          :disabled=\"!store.config.enableTextShadow\"\n          @update:model-value=\"settingChanged('text-shadow-color-changed', store.config.textShadowColor)\"\n        >\n          颜色\n        </UColorPicker>\n      </div>\n      <div flex space-x-1 items-center>\n        <div>\n          字体\n        </div>\n        <div flex-1>\n          <input\n            v-model=\"store.config.fontFamily\"\n            w-full\n            m-input rounded text-sm\n            autocorrect=\"off\"\n            autocapitalize=\"off\"\n            autocomplete=\"off\"\n            spellcheck=\"false\"\n            :style=\"{ fontFamily: store.config.fontFamily }\"\n            @input=\"settingChanged('font-changed', store.config.fontFamily)\"\n          >\n        </div>\n      </div>\n      <UColorPicker\n        v-model=\"store.config.bgColor\"\n        @update:model-value=\"settingChanged('bg-color-changed', store.config.bgColor)\"\n      >\n        背景颜色\n      </UColorPicker>\n      <div flex space-x-2 leading-relaxed>\n        <USlider\n          v-model=\"store.config.bgOpacity\" :min-value=\"0\" :max-value=\"255\" w-100px\n          @update:model-value=\"settingChanged('bg-opacity-changed', store.config.bgOpacity)\"\n        />\n        <span>背景不透明度</span>\n      </div>\n      <UCheckBox\n        v-model=\"store.config.blur\"\n        @update:model-value=\"settingChanged('blur', store.config.blur)\"\n      >\n        毛玻璃效果（不稳定）\n      </UCheckBox>\n    </USettingsBox>\n    <UBlackList @settings-changed=\"settingChanged('blacklist', store.getConfig.blackList)\" />\n    <USettingsBox :title=\"store.getUserInfo.mid ? '弹幕扩展' : '弹幕扩展（需要登录）'\">\n      <UCheckBox\n        v-model=\"store.config.canSendMessage\"\n        :disabled=\"!store.getUserInfo.mid || store.clickThrough\"\n        @update:model-value=\"setCanSend\"\n      >\n        通过弹幕窗格发送弹幕\n      </UCheckBox>\n      <UCheckBox\n        v-model=\"store.config.autoReply\"\n        :disabled=\"!store.getUserInfo.mid\"\n        @update:model-value=\"setAutoReply\"\n      >\n        自动回复\n      </UCheckBox>\n    </USettingsBox>\n    <UMultiList\n      v-if=\"store.config.autoReply\"\n      ml-2\n      @settings-changed=\"store.settingsSaved = false\"\n    />\n  </div>\n</template>\n"
  },
  {
    "path": "src/pages/show.vue",
    "content": "<script setup lang=\"ts\">\nimport UWidget from '~/components/UWidget.vue'\n</script>\n\n<template>\n  <UWidget />\n</template>\n\n<route lang=\"yaml\">\nmeta:\n  layout: none\n</route>\n"
  },
  {
    "path": "src/stores/index.ts",
    "content": "import { createPinia } from 'pinia'\n\nexport const pinia = createPinia()\n"
  },
  {
    "path": "src/stores/position.ts",
    "content": "import { defineStore } from 'pinia'\nimport { invoke } from '@tauri-apps/api/tauri'\n\nexport interface PositionConfig {\n  width: number\n  height: number\n  x: number\n  y: number\n}\n\nexport const usePosition = defineStore('position', {\n  state: () => ({\n    width: 400,\n    height: 600,\n    x: 0,\n    y: 0,\n  }),\n  getters: {\n    getConfig() {\n      return () => {\n        const localConfigString = localStorage.getItem('position')\n        if (!localConfigString)\n          return { width: 400, height: 600, x: 0, y: 0 }\n        const localConfig = JSON.parse(localConfigString) as PositionConfig\n        return localConfig\n      }\n    },\n  },\n  actions: {\n    async storeConfig() {\n      const conf = await invoke('get_viewer_pos_and_size') as PositionConfig\n      this.width = conf.width\n      this.height = conf.height\n      this.x = conf.x\n      this.y = conf.y\n      localStorage.setItem('position', JSON.stringify(conf))\n    },\n  },\n})\n"
  },
  {
    "path": "src/stores/store.ts",
    "content": "import { defineStore } from 'pinia'\nimport type { GiftInfo, LiveAreaInfo } from '../composables/types'\nimport type { Answer } from '~/composables/autoSendMsg'\nimport { eventEmitter } from '~/composables/eventEmitter'\n\ninterface UserInfo {\n  oauthKey: string\n  mid: number\n  midmd5: string\n  mname: string\n  expires: number\n  bili_jct: string\n  sessdata: string\n  avatarUrl: string\n  lastLogin: number\n  sid: string\n}\n\ninterface ConfigProps {\n  showGuardTag: number\n  showAvatar: boolean\n  showTime: boolean\n  showSilverGift: boolean\n  showGoldGift: boolean\n  showPopulation: boolean\n  showHighlight: boolean\n  showEnter: boolean\n  showSubscribe: boolean\n  canSendMessage: boolean\n  textColor: string\n  enableTextShadow: boolean\n  textShadowColor: string\n  bgColor: string\n  bgOpacity: string\n  blur: boolean\n  layout: 'loose' | 'tight'\n  autoReply: boolean\n  readSc: boolean\n  readGift: boolean\n  pushGiftIntoHighlight: boolean\n  fontFamily: string\n  blackList: number[]\n  scLang: 'zh-cn' | 'ja-jp'\n}\n\nconst defaultConfig: ConfigProps = {\n  blackList: [],\n  showGuardTag: 0,\n  showAvatar: true,\n  showTime: false,\n  showSilverGift: false,\n  showPopulation: true,\n  showGoldGift: true,\n  showHighlight: true,\n  showEnter: false,\n  showSubscribe: true,\n  pushGiftIntoHighlight: true,\n  canSendMessage: false,\n  textColor: '#ffffff',\n  enableTextShadow: false,\n  textShadowColor: '#000000',\n  bgColor: '#000000',\n  bgOpacity: '128',\n  blur: false,\n  layout: 'loose',\n  autoReply: false,\n  readSc: false,\n  readGift: false,\n  fontFamily: '',\n  scLang: 'zh-cn',\n}\n\nconst defaultUserInfo: UserInfo = {\n  oauthKey: '',\n  mid: 0,\n  midmd5: '',\n  mname: '',\n  expires: 0,\n  bili_jct: '',\n  sessdata: '',\n  avatarUrl: '',\n  lastLogin: 0,\n  sid: '',\n}\n\ninterface liveConfig {\n  isLive: boolean\n  liveAreaList: LiveAreaInfo[]\n  liveTitle: string\n  addr: string\n  code: string\n}\n\nexport const useStore = defineStore('stores', {\n  state: () => ({\n    roomId: '',\n    liverId: 0,\n    giftInfoList: [] as GiftInfo[],\n    userInfo: {} as UserInfo,\n    config: Object.assign({ ...defaultConfig }, JSON.parse(localStorage.getItem('config') || 'null')) as ConfigProps,\n    requestBlockedTimes: 0,\n    faqs: [] as Answer[],\n    blackList: [] as number[],\n    settingsSaved: true,\n    linked: false,\n    liveConfig: {\n      isLive: false,\n      liveAreaList: [],\n      liveTitle: '',\n      addr: '',\n      code: '',\n    } as liveConfig,\n    mediaList: [] as { fileName: string; blob: string }[],\n    configLoaded: false,\n    clickThrough: false,\n    senderEnabled: false,\n    previousCanSend: false,\n  }),\n  getters: {\n    getUserInfo(): UserInfo {\n      if (!localStorage.getItem('userInfo')) {\n        localStorage.setItem('userInfo', JSON.stringify(defaultUserInfo))\n        return defaultUserInfo\n      }\n      // 登录过期\n      if (this.userInfo.lastLogin + this.userInfo.expires * 1000 < new Date().getTime()) {\n        localStorage.removeItem('userInfo')\n        this.userInfo = {} as UserInfo\n        throw new Error('需要重新登录')\n      }\n      if (!this.userInfo.mid)\n        this.userInfo = JSON.parse(localStorage.getItem('userInfo') || '{}')\n\n      // // eslint-disable-next-line no-console\n      // console.log(this.userInfo)\n      return this.userInfo\n    },\n    getConfig(): ConfigProps {\n      if (!localStorage.getItem('config')) {\n        localStorage.setItem('config', JSON.stringify(defaultConfig))\n        this.config = { ...defaultConfig }\n        return this.config\n      }\n      if (!this.configLoaded) {\n        this.config = Object.assign({ ...defaultConfig }, JSON.parse(localStorage.getItem('config') || 'null'))\n        this.configLoaded = true\n      }\n      // this.config = JSON.parse(localStorage.getItem('config') || 'null')\n\n      // if (!this.config) {\n      //   this.config = Object.assign({ ...defaultConfig }, this.config)\n      //   localStorage.setItem('config', JSON.stringify(this.config))\n      // }\n\n      return this.config\n    },\n    getRoomId(): string {\n      this.roomId = localStorage.getItem('roomId') || ''\n      return this.roomId\n    },\n    getFaqs(): Answer[] {\n      this.faqs = JSON.parse(localStorage.getItem('faqs') || '[]')\n      return this.faqs\n    },\n  },\n  actions: {\n    storeUserInfo() {\n      localStorage.setItem('userInfo', JSON.stringify(this.userInfo))\n    },\n    removeUserInfo() {\n      localStorage.removeItem('userInfo')\n      this.userInfo = { ...defaultUserInfo }\n    },\n    storeConfig() {\n      localStorage.setItem('config', JSON.stringify(this.config))\n      // trim faqs\n      this.faqs = this.faqs.filter(it => it.answer.trim() !== '' && it.keywords.length !== 0)\n      localStorage.setItem('faqs', JSON.stringify(this.faqs))\n      eventEmitter('new-faq', this.faqs)\n    },\n    removeConfig() {\n      localStorage.setItem('config', JSON.stringify(defaultConfig))\n      this.config = { ...defaultConfig }\n      eventEmitter('reset-config', this.config)\n    },\n    setRoomId(id: string) {\n      localStorage.setItem('roomId', id)\n    },\n  },\n})\n\nexport type {\n  ConfigProps,\n}\n"
  },
  {
    "path": "src/styles/main.css",
    "content": ":root {\n  font-family: Inter, Avenir, Helvetica, Arial, sans-serif;\n  font-size: 16px;\n  line-height: 24px;\n  font-weight: 400;\n\n  font-synthesis: none;\n  text-rendering: optimizeLegibility;\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n  -webkit-text-size-adjust: 100%;\n}\n\nbody {\n  margin: 0;\n  min-height: 100vh;\n}\n\n#app {\n  margin: 0 auto;\n}\n\nhtml {\n  transition: background 0.25s;\n}\n\n.use-dark {\n  min-height: 100vh;\n}\n\n\n.dark>body>#app>div>.use-dark-msg {\n  background: #242424;\n  color: #ddd;\n}\n\n\n.dark:has(.use-dark) {\n  background: #242424;\n  color: #ddd;\n}\n"
  },
  {
    "path": "src/types.ts",
    "content": "export interface MessageProvider {\n  pushMsg(msg: string, config?: MessageProviderOptions): void\n}\n\nexport interface MessageProviderOptions {\n  type?: 'success' | 'error' | 'warning' | 'info'\n  ttl?: number\n}\n"
  },
  {
    "path": "src/vite-env.d.ts",
    "content": "/// <reference types=\"vite/client\" />\n\ndeclare module '*.vue' {\n  import type { DefineComponent } from 'vue'\n  const component: DefineComponent<{}, {}, any>\n  export default component\n}\n"
  },
  {
    "path": "src-tauri/.gitignore",
    "content": "# Generated by Cargo\n# will have compiled files and executables\n/target/\n"
  },
  {
    "path": "src-tauri/Cargo.toml",
    "content": "[package]\nname = \"app\"\nversion = \"0.1.0\"\ndescription = \"A Tauri App\"\nauthors = [\"you\"]\nlicense = \"\"\nrepository = \"\"\ndefault-run = \"app\"\nedition = \"2021\"\nrust-version = \"1.57\"\n\n# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html\n\n[build-dependencies]\ntauri-build = { version = \"1.0.4\", features = [] }\n\n[dependencies]\nserde_json = \"1.0\"\nserde = { version = \"1.0\", features = [\"derive\"] }\n# tao = { version = \"0.14.0\"}\ntauri = { version = \"1.0.4\", features = [\"api-all\", \"macos-private-api\"] }\nreqwest = { version = \"0.11.11\", features = [\"json\", \"multipart\"] }\nobjc = \"0.2.7\"\nwindow-shadows = \"0.2.0\"\n\n[features]\n# by default Tauri runs in production mode\n# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL\ndefault = [ \"custom-protocol\" ]\n# this feature is used used for production builds where `devPath` points to the filesystem\n# DO NOT remove this\ncustom-protocol = [ \"tauri/custom-protocol\" ]\nhttp-multipart = [ \"tauri/http-multipart\" ]\n"
  },
  {
    "path": "src-tauri/build.rs",
    "content": "fn main() {\n  tauri_build::build()\n}\n"
  },
  {
    "path": "src-tauri/src/fetch_img.rs",
    "content": "use std::io::Write;\n\n#[tauri::command]\npub async fn fetch_image(img_url: String, file_path: String) -> Result<String, String> {\n  \n  // println!(\"{}\", img_url);\n  // println!(\"{}\", file_path);\n\n  if std::path::Path::new(file_path.as_str()).metadata().is_ok() {\n    // println!(\"File exists!\");\n    return Ok(file_path);\n  }\n\n  let client = reqwest::Client::new();\n  let response = client.get(img_url)\n    .send()\n    .await\n    .unwrap();\n\n  // println!(\"Fetched image!\");\n\n  let dir = std::path::Path::new(file_path.as_str()).parent().unwrap();\n  if dir.metadata().is_err() {\n    std::fs::create_dir_all(dir).unwrap();\n  }\n\n  let mut file = std::fs::File::create(file_path.as_str()).unwrap();\n  file.write_all(response.bytes().await.unwrap().as_ref()).unwrap();\n\n  Ok(file_path)\n}\n"
  },
  {
    "path": "src-tauri/src/load_local_img.rs",
    "content": "#[tauri::command]\npub async fn load_local_image(uid_path: String) -> Result<String, String> {\n    if std::path::Path::new(uid_path.as_str()).metadata().is_ok() {\n        return Ok(uid_path);\n    }\n\n    Ok(\"\".into())\n}\n"
  },
  {
    "path": "src-tauri/src/main.rs",
    "content": "#![cfg_attr(\n  all(not(debug_assertions), target_os = \"windows\"),\n  windows_subsystem = \"windows\"\n)]\n\nmod send_msg;\nmod fetch_img;\nmod open_app_dir;\nmod load_local_img;\nmod new_view;\nmod new_sender;\n\nuse send_msg::send_message;\nuse fetch_img::fetch_image;\nuse open_app_dir::open_app_img_dir;\nuse load_local_img::load_local_image;\n\n// use tauri::Manager;\n\n#[cfg(target_os = \"macos\")]\n#[macro_use]\nextern crate objc;\n\nfn main() {\n  tauri::Builder::default()\n    .invoke_handler(tauri::generate_handler![\n                      send_message,\n                      fetch_image,\n                      open_app_img_dir,\n                      load_local_image,\n                      new_sender::create_sender_window,\n                      new_view::create_new_danmaku_view,\n                      new_view::set_click_through,\n                      new_view::get_viewer_pos_and_size,\n                      new_view::set_viewer_pos_and_size\n                    ])\n    .run(tauri::generate_context!())\n    .expect(\"error while running tauri application\");\n}\n"
  },
  {
    "path": "src-tauri/src/new_sender.rs",
    "content": "use tauri::Wry;\n\n#[tauri::command]\npub async fn create_sender_window(app_handle: tauri::AppHandle<Wry>) {\n    let viewer = tauri::WindowBuilder::new(\n        &app_handle,\n        \"senderWindow\",\n        tauri::WindowUrl::App(\"/sender\".into())\n    )\n      .transparent(true)\n      .decorations(false)\n      .inner_size(400., 40.)\n      .build()\n      .unwrap();\n\n    viewer\n      .set_min_size(std::option::Option::Some(tauri::LogicalSize::new(200, 40)))\n      .expect(\"Failed to set min size!\");\n\n    viewer\n      .set_max_size(std::option::Option::Some(tauri::LogicalSize::new(800, 40)))\n      .expect(\"Failed to set min size!\");\n\n    viewer\n      .set_always_on_top(true)\n      .expect(\"Failed to set always on top\");\n\n    window_shadows::set_shadow(&viewer, false)\n      .expect(\"Failed to set window shadows to false!\");\n}\n"
  },
  {
    "path": "src-tauri/src/new_view.rs",
    "content": "use tauri::{Manager, Wry};\n\n#[tauri::command]\npub async fn create_new_danmaku_view(app_handle: tauri::AppHandle<Wry>) {\n    let viewer = tauri::WindowBuilder::new(\n        &app_handle,\n        \"danmakuWidget\",\n        tauri::WindowUrl::App(\"/show\".into())\n    )\n      .transparent(true)\n      .decorations(false)\n      .inner_size(400., 600.)\n      .build()\n      .unwrap();\n\n    viewer\n      .set_min_size(std::option::Option::Some(tauri::LogicalSize::new(200, 200)))\n      .expect(\"Failed to set min size!\");\n\n    viewer\n      .set_always_on_top(true)\n      .expect(\"Failed to set always on top\");\n\n    window_shadows::set_shadow(&viewer, false)\n      .expect(\"Failed to set window shadows to false!\");\n\n}\n\n#[tauri::command]\npub fn set_click_through(app_handle: tauri::AppHandle<Wry>, enable: bool) -> Result<bool, String> {\n  let option_window = app_handle.get_window(\"danmakuWidget\");\n  if let Some(window) = option_window {\n    window.with_webview(move |webview| {\n      #[cfg(target_os = \"macos\")]\n      unsafe {\n        let () = msg_send![webview.ns_window(), setIgnoresMouseEvents: enable];\n      }\n    })\n    .expect(\"Failed to set click through\");\n    // tao::window::Window::set_ignore_cursor_events(&window, enable);  // 怎么把 tauri::Window cast 到 tao::window::Window 呢？\n  }\n\n  Ok(enable)\n}\n\n#[derive(Copy, Clone, serde::Serialize, serde::Deserialize)]\npub struct PosProps {\n  width: u32,\n  height: u32,\n  x: i32,\n  y: i32\n}\n\n#[tauri::command]\npub fn get_viewer_pos_and_size(app_handle: tauri::AppHandle<Wry>) -> Result<PosProps, String> {\n  let option_window = app_handle.get_window(\"danmakuWidget\");\n  if let Some(viewer) = option_window {\n    let size = viewer.inner_size().unwrap();\n    let pos = viewer.inner_position().unwrap();\n    let ret = PosProps { width: size.width, height: size.height, x: pos.x, y: pos.y };\n\n    return Ok(ret);\n  }\n\n  Err(\"Failed to get danmaku window!\".into())\n}\n\n#[tauri::command]\npub fn set_viewer_pos_and_size(app_handle: tauri::AppHandle<Wry>, conf: PosProps) -> Result<bool, String> {\n  let option_window = app_handle.get_window(\"danmakuWidget\");\n  let PosProps {width, height, x, y} = conf;\n  if let Some(viewer) = option_window {\n    viewer.set_size(tauri::PhysicalSize { width, height }).unwrap();\n    viewer.set_position(tauri::PhysicalPosition { x, y }).unwrap();\n\n    return Ok(true);\n  }\n\n  Err(\"Failed to get danmaku window!\".into())\n}\n"
  },
  {
    "path": "src-tauri/src/open_app_dir.rs",
    "content": "use std::process::Command;\n\n#[tauri::command]\npub async fn open_app_img_dir(dir: String) -> Result<(), String> {\n    // println!(\"{}\", dir);\n    if cfg!(target_os = \"windows\") {\n        Command::new(\"explorer\")\n            .arg(&dir)\n            .spawn()\n            .unwrap();\n    } else if cfg!(target_os = \"macos\") {\n        Command::new(\"open\")\n            .arg(&dir)\n            .spawn()\n            .unwrap();\n    } else {\n        Command::new(\"xdg-open\")\n            .arg(&dir)\n            .spawn()\n            .unwrap();\n    }\n\n    Ok(())\n}\n"
  },
  {
    "path": "src-tauri/src/send_msg.rs",
    "content": "#[derive(Clone, serde::Serialize, serde::Deserialize, Debug)]\nstruct Payload {\n  msg: String,\n  cookie: String,\n  csrf: String,\n  roomid: String\n}\n\nstatic API: &str = \"https://api.live.bilibili.com/msg/send\";\n\n#[tauri::command]\npub async fn send_message(msg: String, cookie: String, csrf: String, roomid: String) -> Result<(), String> {\n\n  let client = reqwest::Client::new();\n  let csrf2 = csrf.clone();\n\n  let form = reqwest::multipart::Form::new()\n    .text(\"bubblue\", \"0\")\n    .text(\"msg\", msg)\n    .text(\"color\", \"16777215\")\n    .text(\"mode\", \"1\")\n    .text(\"fontsize\", \"25\")\n    .text(\"roomid\", roomid)\n    .text(\"csrf\", csrf)\n    .text(\"csrf_token\", csrf2)\n    .text(\"rnd\", std::time::SystemTime::now()\n      .duration_since(std::time::UNIX_EPOCH)\n      .unwrap()\n      .as_secs().to_string());\n\n\n    let response = client\n      .post(API)\n      .header(\"cookie\", cookie)\n      .multipart(form)\n      .send()\n      .await\n      .unwrap();\n\n    if response.status().is_success() {\n      return Ok(());\n    }\n\n    Err(response.status().to_string().into())\n}\n"
  },
  {
    "path": "src-tauri/tauri.conf.json",
    "content": "{\n  \"$schema\": \"../node_modules/@tauri-apps/cli/schema.json\",\n  \"build\": {\n    \"beforeBuildCommand\": \"pnpm build\",\n    \"beforeDevCommand\": \"pnpm dev\",\n    \"devPath\": \"http://localhost:5173\",\n    \"distDir\": \"../dist\"\n  },\n  \"package\": {\n    \"productName\": \"D4nm4ku\",\n    \"version\": \"0.1.13\"\n  },\n  \"tauri\": {\n    \"allowlist\": {\n      \"all\": true,\n      \"http\":{\n        \"scope\":[\n          \"http://**\",\n          \"https://**\"\n        ],\n        \"all\": true,\n        \"request\": true\n      },\n      \"fs\": {\n        \"all\": true,\n        \"scope\": [\"$APP/imgs/*\"]\n      }\n    },\n    \"macOSPrivateApi\": true,\n    \"bundle\": {\n      \"active\": true,\n      \"category\": \"DeveloperTool\",\n      \"copyright\": \"\",\n      \"deb\": {\n        \"depends\": []\n      },\n      \"externalBin\": [],\n      \"icon\": [\n        \"icons/32x32.png\",\n        \"icons/128x128.png\",\n        \"icons/128x128@2x.png\",\n        \"icons/icon.icns\",\n        \"icons/icon.ico\"\n      ],\n      \"identifier\": \"win.widcard.d4nm4ku\",\n      \"longDescription\": \"\",\n      \"macOS\": {\n        \"entitlements\": null,\n        \"exceptionDomain\": \"\",\n        \"frameworks\": [],\n        \"providerShortName\": null,\n        \"signingIdentity\": null\n      },\n      \"resources\": [],\n      \"shortDescription\": \"\",\n      \"targets\": \"all\",\n      \"windows\": {\n        \"certificateThumbprint\": null,\n        \"digestAlgorithm\": \"sha256\",\n        \"timestampUrl\": \"\"\n      }\n    },\n    \"security\": {\n      \"csp\": null\n    },\n    \"updater\": {\n      \"active\": false\n    },\n    \"windows\": [\n      {\n        \"fullscreen\": false,\n        \"height\": 600,\n        \"resizable\": true,\n        \"title\": \"D4nm4ku\",\n        \"width\": 800,\n        \"label\": \"main\",\n        \"minWidth\": 800,\n        \"minHeight\": 600\n      }\n    ]\n  }\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"baseUrl\": \".\",\n    \"target\": \"ESNext\",\n    \"useDefineForClassFields\": true,\n    \"module\": \"ESNext\",\n    \"moduleResolution\": \"Node\",\n    \"strict\": true,\n    \"jsx\": \"preserve\",\n    \"sourceMap\": true,\n    \"resolveJsonModule\": true,\n    \"isolatedModules\": true,\n    \"esModuleInterop\": true,\n    \"lib\": [\"ESNext\", \"DOM\"],\n    \"skipLibCheck\": true,\n    \"noUnusedLocals\": true,\n    \"strictNullChecks\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"types\": [\n      \"vite/client\",\n      \"vite-plugin-pages/client\",\n      \"vite-plugin-vue-layouts/client\"\n    ],\n    \"paths\": {\n      \"~/*\": [\"src/*\"]\n    }\n  },\n  \"include\": [\"src/**/*.ts\", \"src/**/*.d.ts\", \"src/**/*.tsx\", \"src/**/*.vue\"],\n  \"references\": [{ \"path\": \"./tsconfig.node.json\" }]\n}\n"
  },
  {
    "path": "tsconfig.node.json",
    "content": "{\n  \"compilerOptions\": {\n    \"composite\": true,\n    \"module\": \"ESNext\",\n    \"moduleResolution\": \"Node\",\n    \"allowSyntheticDefaultImports\": true\n  },\n  \"include\": [\"vite.config.ts\"]\n}\n"
  },
  {
    "path": "unocss.config.ts",
    "content": "import {\n  defineConfig,\n  presetAttributify,\n  presetIcons,\n  presetUno,\n  presetWebFonts,\n  // transformerDirectives,\n  // transformerVariantGroup,\n} from 'unocss'\n\n// @unocss-include\n\nexport default defineConfig({\n  shortcuts: [\n    ['btn', 'inline-block px-4 py-1 bg-#646cff bg-opacity-80 disabled:opacity-20 disabled:bg-zinc-500 hover:bg-opacity-100 font-500 transition-all text-white'],\n    ['icon-btn', 'text-[0.9em] inline-block cursor-pointer select-none opacity-75 transition duration-200 ease-in-out hover:opacity-100 hover:text-#646cff !outline-none disabled:(cursor-not-allowed op-50 hover:text-zinc)'],\n    ['text-active', 'text-#646cff dark:text-#646cff opacity-100'],\n    ['text-btn', 'cursor-pointer select-none opacity-75 transition duration-200 hover:op-100 hover:text-#646cff !outline-none disabled:(cursor-not-allowed op-50 hover:text-zinc)'],\n    ['m-input', 'border border-zinc-300 dark:border-zinc-600 !outline-none px-2 py-1 bg-transparent leading-normal'],\n    ['wsn', 'whitespace-nowrap'],\n  ],\n  presets: [\n    presetUno(),\n    presetAttributify(),\n    presetIcons({\n      scale: 1.2,\n      warn: true,\n    }),\n    presetWebFonts({\n      fonts: {\n        sans: 'DM Sans',\n        serif: 'DM Serif Display',\n        mono: 'DM Mono',\n      },\n    }),\n  ],\n  // transformers: [\n  //   transformerDirectives(),\n  //   transformerVariantGroup(),\n  // ],\n})\n"
  },
  {
    "path": "vite.config.ts",
    "content": "import path from 'path'\nimport { defineConfig } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport Unocss from 'unocss/vite'\nimport Pages from 'vite-plugin-pages'\nimport Layouts from 'vite-plugin-vue-layouts'\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  resolve: {\n    alias: {\n      '~/': `${path.resolve(__dirname, 'src')}/`,\n    },\n  },\n  plugins: [\n    vue(),\n    Unocss(),\n\n    Pages(),\n\n    Layouts(),\n  ],\n})\n"
  }
]