Skip to content

Commit 5142893

Browse files
committed
Refactor content-ui for enhanced diagnostic mode functionality
- Updated content-ui components to support a new diagnostic mode with persistent state management and real-time updates across multiple pages. - Improved error handling and logging in storage operations for better debugging. - Enhanced the DiagnoseModeWidget to visually indicate the state of the diagnostic mode. - Expanded README documentation to include details on diagnostic mode features and testing procedures.
1 parent 0a97069 commit 5142893

File tree

6 files changed

+176
-350
lines changed

6 files changed

+176
-350
lines changed

README.md

Lines changed: 3 additions & 274 deletions
Original file line numberDiff line numberDiff line change
@@ -1,275 +1,4 @@
1-
<div align="center">
1+
# RWKV 离线翻译
22

3-
<picture>
4-
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/99cb6303-64e4-4bed-bf3f-35735353e6de" />
5-
<source media="(prefers-color-scheme: light)" srcset="https://github.com/user-attachments/assets/a5dbf71c-c509-4c4f-80f4-be88a1943b0a" />
6-
<img alt="Logo" src="https://github.com/user-attachments/assets/99cb6303-64e4-4bed-bf3f-35735353e6de" />
7-
</picture>
8-
9-
![](https://img.shields.io/badge/React-61DAFB?style=flat-square&logo=react&logoColor=black)
10-
![](https://img.shields.io/badge/Typescript-3178C6?style=flat-square&logo=typescript&logoColor=white)
11-
![](https://badges.aleen42.com/src/vitejs.svg)
12-
13-
![GitHub action badge](https://github.com/Jonghakseo/chrome-extension-boilerplate-react-vite/actions/workflows/build-zip.yml/badge.svg)
14-
![GitHub action badge](https://github.com/Jonghakseo/chrome-extension-boilerplate-react-vite/actions/workflows/lint.yml/badge.svg)
15-
16-
<a href="https://discord.gg/4ERQ6jgV9a" target="_blank"><img src="https://discord.com/api/guilds/1263404974830915637/widget.png"/></a>
17-
18-
> This boilerplate
19-
> has [Legacy version](https://github.com/Jonghakseo/chrome-extension-boilerplate-react-vite/tree/legacy)
20-
21-
</div>
22-
23-
> [!NOTE]
24-
> This project is listed in the [Awesome Vite](https://github.com/vitejs/awesome-vite)
25-
26-
> [!TIP]
27-
> Share storage state between all pages
28-
>
29-
> https://github.com/user-attachments/assets/3b8e189f-6443-490e-a455-4f9570267f8c
30-
31-
## Table of Contents
32-
33-
- [Intro](#intro)
34-
- [Features](#features)
35-
- [Structure](#structure)
36-
- [ChromeExtension](#structure-chrome-extension)
37-
- [Packages](#structure-packages)
38-
- [Pages](#structure-pages)
39-
- [Installation](#installation)
40-
- [Chrome](#installation-chrome)
41-
- [Firefox](#installation-firefox)
42-
- [Install dependency](#install-dependency)
43-
- [For root](#install-dependency-for-root)
44-
- [For module](#install-dependency-for-module)
45-
- [Environment variables](#env-variables)
46-
- [Add new](#env-variables-new)
47-
- [Set via CLI](#env-variables-cli-set)
48-
- [Troubleshooting](#troubleshooting)
49-
- [Hot module reload seems to have frozen](#hot-module-reload-seems-to-have-frozen)
50-
- [Imports not resolving correctly](#imports-not-resolving-correctly)
51-
- [Community](#community)
52-
- [Debugging](#debugging)
53-
- [Reference](#reference)
54-
- [Star History](#star-history)
55-
- [Contributors](#contributors)
56-
57-
## Intro
58-
59-
This boilerplate helps you create Chrome/Firefox extensions using React and Typescript. It improves
60-
the build speed and development experience by using Vite and Turborepo.
61-
62-
## Features
63-
64-
- [React](https://reactjs.org/)
65-
- [TypeScript](https://www.typescriptlang.org/)
66-
- [Tailwindcss](https://tailwindcss.com/)
67-
- [Vite](https://vitejs.dev/) with [Rollup](https://rollupjs.org/)
68-
- [Turborepo](https://turbo.build/repo)
69-
- [Prettier](https://prettier.io/)
70-
- [ESLint](https://eslint.org/)
71-
- [Chrome Extensions Manifest Version 3](https://developer.chrome.com/docs/extensions/mv3/intro/)
72-
- [Custom i18n package](/packages/i18n/)
73-
- [Custom HMR (Hot Module Rebuild) plugin](/packages/hmr)
74-
- [End-to-end testing with WebdriverIO](https://webdriver.io/)
75-
76-
## Installation
77-
78-
1. Clone this repository.( ```git clone https://github.com/Jonghakseo/chrome-extension-boilerplate-react-vite``` )
79-
2. Ensure your node version is >= than in `.nvmrc` file, recommend to use [nvm](https://github.com/nvm-sh/nvm?tab=readme-ov-file#intro)
80-
3. Edit `/packages/i18n/locales/`{your locale(s)}/`messages.json`
81-
4. In the objects `extensionDescription` and `extensionName`, change the `message` fields (leave `description` alone)
82-
5. Install pnpm globally: `npm install -g pnpm`
83-
6. Run `pnpm install`
84-
7. Check if you have that configuration in your IDE/Editor:
85-
- <b>VS Code</b>:
86-
- Installed [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
87-
- Installed [Prettier extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
88-
- Enabled `Typescript Workbench version` in settings:
89-
- CTRL + SHIFT + P -> Search: `Typescript: Select Typescript version...` -> `Use Workbench version`
90-
- [Read more](https://code.visualstudio.com/docs/languages/typescript#_using-newer-typescript-versions)
91-
- Optional, for imports to work correctly in WSL, you might need to install the [Remote - WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) extension and connect to WSL remotely from VS Code. See overview section in the extension page for more information.
92-
- <b>WebStorm</b>:
93-
- Configured [ESLint](https://www.jetbrains.com/help/webstorm/eslint.html#ws_eslint_configure_run_eslint_on_save)
94-
- Configured [Prettier](https://prettier.io/docs/en/webstorm.html)
95-
- Optional, but useful `File | Settings | Tools | Actions on Save`\
96-
-> `Optimize imports` and `Reformat code`
97-
8. Run `pnpm update-version <version>` for change the `version` to the desired version of your extension.
98-
99-
> [!IMPORTANT]
100-
> On Windows, make sure you have WSL enabled and Linux distribution (e.g. Ubuntu) installed on WSL.
101-
>
102-
> [Installation Guide](https://learn.microsoft.com/en-us/windows/wsl/install)
103-
104-
<b>Then, depending on the target browser:</b>
105-
106-
### For Chrome: <a name="installation-chrome"></a>
107-
108-
1. Run:
109-
- Dev: `pnpm dev` (on Windows, you should run as administrator;
110-
see [issue#456](https://github.com/Jonghakseo/chrome-extension-boilerplate-react-vite/issues/456))
111-
- Prod: `pnpm build`
112-
2. Open in browser - `chrome://extensions`
113-
3. Check - <kbd>Developer mode</kbd>
114-
4. Click - <kbd>Load unpacked</kbd> in the upper left corner
115-
5. Select the `dist` directory from the boilerplate project
116-
117-
### For Firefox: <a name="installation-firefox"></a>
118-
119-
1. Run:
120-
- Dev: `pnpm dev:firefox`
121-
- Prod: `pnpm build:firefox`
122-
2. Open in browser - `about:debugging#/runtime/this-firefox`
123-
3. Click - <kbd>Load Temporary Add-on...</kbd> in the upper right corner
124-
4. Select the `./dist/manifest.json` file from the boilerplate project
125-
126-
> [!NOTE]
127-
> In Firefox, you load add-ons in temporary mode. That means they'll disappear after each browser close. You have to
128-
> load the add-on on every browser launch.
129-
130-
## Install dependency for turborepo: <a name="install-dependency"></a>
131-
132-
### For root: <a name="install-dependency-for-root"></a>
133-
134-
1. Run `pnpm i <package> -w`
135-
136-
### For module: <a name="install-dependency-for-module"></a>
137-
138-
1. Run `pnpm i <package> -F <module name>`
139-
140-
`package` - Name of the package you want to install e.g. `nodemon` \
141-
`module-name` - You can find it inside each `package.json` under the key `name`, e.g. `@extension/content-script`, you
142-
can use only `content-script` without `@extension/` prefix
143-
144-
## How do I disable modules I'm not using?
145-
146-
[Read here](packages/module-manager/README.md)
147-
148-
## Environment variables
149-
150-
Read: [Env Documentation](packages/env/README.md)
151-
152-
## Boilerplate structure <a name="structure"></a>
153-
154-
### Chrome extension <a name="structure-chrome-extension"></a>
155-
156-
The extension lives in the `chrome-extension` directory and includes the following files:
157-
158-
- [`manifest.ts`](chrome-extension/manifest.ts) - script that outputs the `manifest.json`
159-
- [`src/background`](chrome-extension/src/background) - [background script](https://developer.chrome.com/docs/extensions/mv3/background_pages/)
160-
(`background.service_worker` in manifest.json)
161-
- [`public`](chrome-extension/public/) - icons referenced in the manifest; content CSS for user's page injection
162-
163-
> [!IMPORTANT]
164-
> To facilitate development, the boilerplate is configured to "Read and change all your data on all websites".
165-
> In production, it's best practice to limit the premissions to only the strictly necessary websites. See
166-
> [Declaring permissions](https://developer.chrome.com/docs/extensions/develop/concepts/declare-permissions)
167-
> and edit `manifest.js` accordingly.
168-
169-
### Pages <a name="structure-pages"></a>
170-
171-
Code that is transpiled to be part of the extension lives in the [pages](pages) directory.
172-
173-
- [`content`](pages/content) - Scripts injected into specified pages (You can see it in console)
174-
- [`content-ui`](pages/content-ui) - React Components injected into specified pages (You can see it at the very bottom of pages)
175-
- [`content-runtime`](pages/content-runtime/src/) - [injected content scripts](https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#functionality)
176-
This can be injected from e.g. `popup` like standard `content`
177-
- [`devtools`](pages/devtools/) - [extend the browser DevTools](https://developer.chrome.com/docs/extensions/how-to/devtools/extend-devtools#creating)
178-
(`devtools_page` in manifest.json)
179-
- [`devtools-panel`](pages/devtools-panel/) - [DevTools panel](https://developer.chrome.com/docs/extensions/reference/api/devtools/panels)
180-
for [devtools](pages/devtools/src/index.ts)
181-
- [`new-tab`](pages/new-tab/) - [override the default New Tab page](https://developer.chrome.com/docs/extensions/develop/ui/override-chrome-pages)
182-
(`chrome_url_overrides.newtab` in manifest.json)
183-
- [`options`](pages/options/) - [options page](https://developer.chrome.com/docs/extensions/develop/ui/options-page)
184-
(`options_page` in manifest.json)
185-
- [`popup`](pages/popup/) - [popup](https://developer.chrome.com/docs/extensions/reference/api/action#popup) shown when
186-
clicking the extension in the toolbar
187-
(`action.default_popup` in manifest.json)
188-
- [`side-panel`](pages/side-panel/) - [sidepanel (Chrome 114+)](https://developer.chrome.com/docs/extensions/reference/api/sidePanel)
189-
(`side_panel.default_path` in manifest.json)
190-
191-
### Packages <a name="structure-packages"></a>
192-
193-
Some shared packages:
194-
195-
- `dev-utils` - utilities for Chrome extension development (manifest-parser, logger)
196-
- `env` - exports object which contain all environment variables from `.env` and dynamically declared
197-
- `hmr` - custom HMR plugin for Vite, injection script for reload/refresh, HMR dev-server
198-
- `i18n` - custom internationalization package; provides i18n function with type safety and other validation
199-
- `shared` - shared code for the entire project (types, constants, custom hooks, components etc.)
200-
- `storage` - helpers for easier integration with [storage](https://developer.chrome.com/docs/extensions/reference/api/storage), e.g. local/session storages
201-
- `tailwind-config` - shared Tailwind config for entire project
202-
- `tsconfig` - shared tsconfig for the entire project
203-
- `ui` - function to merge your Tailwind config with the global one; you can save components here
204-
- `vite-config` - shared Vite config for the entire project
205-
206-
Other useful packages:
207-
208-
- `zipper` - run `pnpm zip` to pack the `dist` folder into `extension-YYYYMMDD-HHmmss.zip` inside the newly created
209-
`dist-zip`
210-
- `module-manager` - run `pnpm module-manager` to enable/disable modules
211-
- `e2e` - run `pnpm e2e` for end-to-end tests of your zipped extension on different browsers
212-
213-
## Troubleshooting
214-
215-
### Hot module reload seems to have frozen
216-
217-
If saving source files doesn't cause the extension HMR code to trigger a reload of the browser page, try this:
218-
219-
1. Ctrl+C the development server and restart it (`pnpm run dev`)
220-
2. If you get a [`grpc` error](https://github.com/Jonghakseo/chrome-extension-boilerplate-react-vite/issues/612),
221-
[kill the
222-
`turbo` process](https://github.com/Jonghakseo/chrome-extension-boilerplate-react-vite/issues/612#issuecomment-2518982339)
223-
and run `pnpm dev` again.
224-
225-
### Imports not resolving correctly
226-
227-
If you are using WSL and imports are not resolving correctly, ensure that you have connected VS Code to WSL remotely using the [Remote - WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) extension.
228-
229-
## Community
230-
231-
To chat with other community members, you can join the [Discord](https://discord.gg/4ERQ6jgV9a) server.
232-
You can ask questions on that server, and you can also help others.
233-
234-
Also, suggest new features or share any challenges you've faced while developing Chrome extensions!
235-
236-
## Debugging
237-
238-
If you're debugging one, you can use [Brie](https://go.briehq.com/github?utm_source=CEB) lets you capture screenshots, errors, and network activity, making it easier for us to help.
239-
240-
## Reference
241-
242-
- [Chrome Extensions](https://developer.chrome.com/docs/extensions)
243-
- [Vite Plugin](https://vitejs.dev/guide/api-plugin.html)
244-
- [Rollup](https://rollupjs.org/guide/en/)
245-
- [Turborepo](https://turbo.build/repo/docs)
246-
- [Rollup-plugin-chrome-extension](https://www.extend-chrome.dev/rollup-plugin)
247-
248-
## Star History <a name="star-history"></a>
249-
250-
<a href="https://star-history.com/#Jonghakseo/chrome-extension-boilerplate-react-vite&Date">
251-
<picture>
252-
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Jonghakseo/chrome-extension-boilerplate-react-vite&type=Date&theme=dark" />
253-
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Jonghakseo/chrome-extension-boilerplate-react-vite&type=Date" />
254-
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Jonghakseo/chrome-extension-boilerplate-react-vite&type=Date" />
255-
</picture>
256-
</a>
257-
258-
## Contributors <a name="contributors"></a>
259-
260-
This Boilerplate is made possible thanks to all of its contributors.
261-
262-
<a href="https://github.com/Jonghakseo/chrome-extension-boilerplate-react-vite/graphs/contributors">
263-
<img width="500px" src="https://contrib.rocks/image?repo=Jonghakseo/chrome-extension-boilerplate-react-vite" alt="All Contributors"/>
264-
</a>
265-
266-
---
267-
268-
## Special Thanks To
269-
270-
| <a href="https://jb.gg/OpenSourceSupport"><img width="40" src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png" alt="JetBrains Logo (Main) logo."></a> | <a href="https://www.linkedin.com/in/j-acks0n"><img width="40" style="border-radius:50%" src='https://avatars.githubusercontent.com/u/23139754' alt='Jackson Hong'/></a> |
271-
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
272-
273-
---
274-
275-
Made by [Jonghakseo](https://jonghakseo.github.io/)
3+
前端: Chrome 插件
4+
后端: RWKV Chat App

0 commit comments

Comments
 (0)