Skip to content

Latest commit

ย 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

GLM-Image2COS

WXT Vue TypeScript Pinia Element Plus license

A Chrome extension that generates images via GLM Image API (Zhipu) and uploads them to Tencent Cloud COS โ€” get permanent links instantly, all from your browser's side panel.

ไธญๆ–‡ๆ–‡ๆกฃ


Screenshots

Click to expand/collapse screenshots
Popup Side Panel - AI Image Gen
Popup AI Gen
Side Panel - History Side Panel - History Detail
History History Detail
Side Panel - Cloud Storage Side Panel - Settings
Cloud Storage Settings

Features

  • GLM Image Generation โ€” AI-powered image generation using Zhipu's GLM Image model (glm-image), with user-configurable API Key.
  • Tencent Cloud COS Integration โ€” Auto-upload generated images to COS for permanent, shareable links.
  • Side Panel UI โ€” Clean, compact side panel interface with AI generation tools and settings management.
  • User Settings โ€” Configure your Zhipu API Key and theme preferences (light / dark / system) directly in the side panel.
  • Dark Mode โ€” system / light / dark theme switching with VueUse, synced across all extension contexts.
  • Built-in WXT i18n โ€” Native @wxt-dev/i18n module, follows the browser locale. Supports Chinese and English.
  • Shared State via WXT Storage โ€” Cross-context state synchronization through wxt/storage (API key, theme, app state).
  • Element Plus with Auto Import โ€” UI components and APIs are auto-imported on demand via unplugin-vue-components and unplugin-auto-import.
  • Multi-Entry SPA Architecture โ€” popup, options, and sidepanel each have their own Vue Router and Pinia instance, fully isolated.
  • Iconify Icons โ€” Uses @iconify/vue for a rich, customizable icon set.
  • Complete DX Toolchain โ€” ESLint (@antfu/eslint-config), TypeScript strict mode, SCSS, conventional commits (cz-git), semantic versioning (standard-version).

Tech Stack

Layer Technology
Framework WXT (Web Extension Tools)
UI Vue 3 + Element Plus
Icons Iconify (@iconify/vue)
State Pinia (per-entry instance)
Routing Vue Router 4 (Hash mode, per-entry)
i18n @wxt-dev/i18n (WXT native)
Storage wxt/storage (cross-context sync)
AI SDK OpenAI Node SDK (GLM Image API compatible)
Utilities VueUse + Lodash-es + Day.js
HTTP Axios
Styling SCSS + Element Plus theme customization
Linting @antfu/eslint-config
CI/CD GitHub Actions

Project Structure

GLM-Image2COS/
โ”œโ”€โ”€ .github/workflows/          # CI/CD: lint + build + release
โ”œโ”€โ”€ .vscode/                    # VSCode recommended extensions
โ”œโ”€โ”€ assets/styles/              # Global SCSS: variables, dark mode, reset
โ”œโ”€โ”€ components/                 # Shared Vue components
โ”‚   โ””โ”€โ”€ HelloWorld.vue
โ”œโ”€โ”€ composables/                # Vue composables
โ”‚   โ””โ”€โ”€ useDarkMode.ts          # Dark mode logic with Pinia + VueUse
โ”œโ”€โ”€ entrypoints/                # Extension entry points
โ”‚   โ”œโ”€โ”€ background.ts           # Service Worker: storage management & message routing
โ”‚   โ”œโ”€โ”€ popup/                  # Popup SPA (Product introduction)
โ”‚   โ”‚   โ”œโ”€โ”€ main.ts / App.vue
โ”‚   โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ”‚   โ””โ”€โ”€ style.css
โ”‚   โ””โ”€โ”€ sidepanel/              # Side Panel SPA (Core features)
โ”‚       โ”œโ”€โ”€ main.ts / App.vue / router.ts
โ”‚       โ”œโ”€โ”€ index.html
โ”‚       โ””โ”€โ”€ views/
โ”‚           โ”œโ”€โ”€ ToolsView.vue      # GLM Image generation tool
โ”‚           โ”œโ”€โ”€ HistoryView.vue    # Generation history
โ”‚           โ”œโ”€โ”€ CloudView.vue      # Cloud storage management
โ”‚           โ”œโ”€โ”€ SettingsView.vue   # API Key & theme configuration
โ”‚           โ””โ”€โ”€ OverviewView.vue   # Overview page
โ”œโ”€โ”€ lib/                        # Core libraries
โ”‚   โ”œโ”€โ”€ glm.ts                  # GLM Image API client (OpenAI-compatible)
โ”‚   โ”œโ”€โ”€ cos.ts                  # Tencent Cloud COS SDK
โ”‚   โ”œโ”€โ”€ create-extension-app.ts # Unified Vue app factory
โ”‚   โ”œโ”€โ”€ element-plus.ts         # Element Plus locale resolver
โ”‚   โ””โ”€โ”€ i18n.ts                 # WXT i18n wrapper
โ”œโ”€โ”€ locales/                    # i18n translation files
โ”‚   โ”œโ”€โ”€ en.json
โ”‚   โ””โ”€โ”€ zh-CN.json
โ”œโ”€โ”€ public/icon/                # Extension icons (16/32/48/96/128)
โ”œโ”€โ”€ screenshots/                # Preview screenshots
โ”œโ”€โ”€ stores/                     # Pinia stores (definitions shared, instances isolated)
โ”‚   โ”œโ”€โ”€ app.ts                  # App state: theme, global settings
โ”‚   โ”œโ”€โ”€ cloud.ts                # Cloud files state
โ”‚   โ”œโ”€โ”€ history.ts              # Generation history state
โ”‚   โ””โ”€โ”€ userSettings.ts         # User settings: API Key persistence
โ”œโ”€โ”€ utils/                      # Utilities
โ”‚   โ”œโ”€โ”€ messaging.ts            # Type-safe extension messaging
โ”‚   โ””โ”€โ”€ storage.ts              # WXT storage adapter & types
โ”œโ”€โ”€ wxt.config.ts               # WXT configuration
โ”œโ”€โ”€ tsconfig.json               # TypeScript configuration
โ”œโ”€โ”€ eslint.config.mjs           # ESLint flat config
โ””โ”€โ”€ package.json

Getting Started

Prerequisites

  • Node.js >= 18
  • Bun >= 1.0 (recommended)

Install

bun install

This will also run wxt prepare automatically via postinstall to generate i18n types and WXT type declarations.

Development

# Chrome (default)
bun run dev

# Firefox
bun run dev:firefox

After starting, load the extension in your browser:

Browser Steps
Chrome Open chrome://extensions โ†’ Enable "Developer mode" โ†’ "Load unpacked" โ†’ Select .output/chrome-mv3
Firefox Open about:debugging#/runtime/this-firefox โ†’ "Load Temporary Add-on" โ†’ Select .output/firefox-mv3/manifest.json

Build

# Chrome
bun run build

# Firefox
bun run build:firefox

# Build and zip both
bun run zip
bun run zip:firefox

Output is in the .output/ directory.

Configuration

After loading the extension, open the side panel and navigate to Settings to configure your Zhipu API Key. The key is persisted locally and used for all GLM Image API calls.


Architecture

Side Panel App

The primary user interface is the Side Panel, which provides the following main views:

Route View Description
/ OverviewView Overview page with basic info and entries
/tools ToolsView AI image generation โ€” enter prompts and generate images via GLM Image API
/history HistoryView Generation history โ€” view, delete, download, or upload to cloud
/cloud CloudView Cloud storage management โ€” manage objects uploaded to Tencent Cloud COS
/settings SettingsView Configure API Key, COS settings, and theme

GLM Image API Integration

The extension communicates with the Zhipu GLM Image API through an OpenAI-compatible client (lib/glm.ts). The API Key is user-configurable and stored in userSettingsStore, following the standard WXT storage pattern for cross-context sync.

Cross-Context State Sync

Shared application state (theme, API key, COS settings, etc.) is persisted through WXT Storage (wxt/storage). Each UI entry's Pinia store watches storage changes and stays in sync:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Popup   โ”‚   โ”‚Sidepanel โ”‚
โ”‚ (Pinia)  โ”‚   โ”‚ (Pinia)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
     โ”‚              โ”‚
     โ”‚  wxt/storage โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚  Background   โ”‚
    โ”‚ (Service Wkr) โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

i18n with WXT Native Module

Translations are defined in locales/*.json and follow the browser's UI language. No runtime language switching โ€” WXT i18n maps to chrome.i18n / browser.i18n natively.


Scripts

Command Description
bun run dev Start dev server (Chrome)
bun run dev:firefox Start dev server (Firefox)
bun run build Build for production (Chrome)
bun run build:firefox Build for production (Firefox)
bun run zip Build and create .zip for Chrome
bun run zip:firefox Build and create .zip for Firefox
bun run lint Run ESLint
bun run lint:fix Run ESLint with auto-fix
bun run format Run ESLint with auto-fix
bun run typecheck Run TypeScript type checking
bun run commit Interactive conventional commit (cz-git)
bun run release Bump version and generate CHANGELOG

ROADMAP

Planned features and improvements:

  • GLM Image ๅކๅฒ่ฎฐๅฝ•็ฎก็† โ€” ็ฎก็† GLM Image ็”Ÿๆˆ็š„ๅ›พ็‰‡ๅކๅฒ่ฎฐๅฝ•๏ผŒๆ”ฏๆŒๆŸฅ็œ‹ใ€ๅˆ ้™คๅ’Œ้‡ๆ–ฐ็”Ÿๆˆใ€‚
    Image generation history management โ€” view, delete, and regenerate past results.
  • ้›†ๆˆ Tencent Cloud COS โ€” ๅฐ†็”Ÿๆˆ็š„ๅ›พ็‰‡่‡ชๅŠจไธŠไผ ่‡ณ่…พ่ฎฏไบ‘ COS๏ผŒ่Žทๅ–ๆฐธไน…ๅฏๅˆ†ไบซ็š„้“พๆŽฅใ€‚
    Integrate Tencent Cloud COS for automatic image uploads and permanent shareable links.
  • ไผ˜ๅŒ– Side Panel UI ่ฎพ่ฎก โ€” ๆ”น่ฟ› sidepanel ็š„็•Œ้ข่ฎพ่ฎกๅ’Œไบคไบ’ไฝ“้ชŒใ€‚
    Optimize the side panel UI design and user experience, and optimize the popup.
  • Chrome ้€š็Ÿฅๅผน็ช—ไธญ็š„ๅคๅˆถ้“พๆŽฅ โ€” ๅœจ Chrome ้€š็Ÿฅไธญ็›ดๆŽฅๆไพ›ๅคๅˆถๅ›พ็‰‡้“พๆŽฅ็š„ๅŠŸ่ƒฝใ€‚
    Implement copy-link functionality in Chrome notification popups.

Contributing

This project uses conventional commits with cz-git for standardized commit messages.

bun run commit

Follow the prompts to select the type (feat, fix, docs, etc.) and scope. The commit message will be automatically formatted.

To release a new version:

bun run release        # Auto-detect version bump
bun run release:patch  # 0.0.x
bun run release:minor  # 0.x.0
bun run release:major  # x.0.0

This will:

  1. Bump the version in package.json
  2. Generate / update CHANGELOG.md
  3. Create a git tag (v*)
  4. Trigger the GitHub Actions release workflow

Recommended IDE Setup

  • VS Code + Volar (recommended extension auto-suggested in .vscode/extensions.json)

License

MIT

About

๐ŸŽจ A Chrome extension that generates images via GLM Image API and automatically uploads them to Tencent Cloud COS โ€” get permanent links instantly.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages