Skip to content

Commit

Permalink
feat: build sh
Browse files Browse the repository at this point in the history
  • Loading branch information
chengfengfengwang committed Jun 18, 2024
1 parent 6121487 commit a1c7e5c
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 266 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist/
dist-ssr
*.local

Expand Down
6 changes: 6 additions & 0 deletions buildExtension.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

cd dist;
rm -rf ./.vite;
cd ..;
zip -r dist.zip dist/;
Binary file added dist.zip
Binary file not shown.
19 changes: 14 additions & 5 deletions manifest.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { defineManifest } from "@crxjs/vite-plugin";
import packageJson from "./package.json";
import type { ManifestV3Export } from "@crxjs/vite-plugin";
const { version } = packageJson;

const target = process.env.BUILD_TARGET;

// Convert from Semver (example: 0.1.0-beta6)
const [major, minor, patch, label = "0"] = version
// can only contain digits, dots, or dash
.replace(/[^\d.-]+/g, "")
// split into version parts
.split(/[.-]/);

export default defineManifest(async () => ({
let json:ManifestV3Export = {
manifest_version: 3,
name: "lingo link",
// up to four numbers separated by dots
Expand Down Expand Up @@ -41,13 +43,20 @@ export default defineManifest(async () => ({
service_worker: "src/background.ts",
type:"module"
},
key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApXvVjpN4kxyWPCZuhsoHZYavMOI+U5w6FHXITdHUuF5UKzlAJr0Lqu5ZY5+b6U+Y19ZLh9SDfhFi4fk5PtF3I8cQbUI8p2eXxwUio7IgxWJQgruQLwILO08LvLTa55BinA/Sgstl6zbYTAeFLthd1JJyz5FDN26NwH6CcbqEY7AC2Vr9/VtwH4buz92qetjuR5MpfrzNUN0QtSlKnXPJ8wasCGeWDcerynYw/OEVXwbgiENfK8+K9hHKnsZLK+U4Y4yrNEZPOfMBSe+Q1o2+eof2DQFxsDxy9ohyk3P1/oyP3vmhD2xxuJOtsS9hp31lDm+2nlreCC3w5IKsUZABDQIDAQAB",
"host_permissions": [
"https://www.youdao.com/*",
"https://dict.youdao.com/*"
],
}
if (target === 'chrome') {
json = {...json, ...{key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApXvVjpN4kxyWPCZuhsoHZYavMOI+U5w6FHXITdHUuF5UKzlAJr0Lqu5ZY5+b6U+Y19ZLh9SDfhFi4fk5PtF3I8cQbUI8p2eXxwUio7IgxWJQgruQLwILO08LvLTa55BinA/Sgstl6zbYTAeFLthd1JJyz5FDN26NwH6CcbqEY7AC2Vr9/VtwH4buz92qetjuR5MpfrzNUN0QtSlKnXPJ8wasCGeWDcerynYw/OEVXwbgiENfK8+K9hHKnsZLK+U4Y4yrNEZPOfMBSe+Q1o2+eof2DQFxsDxy9ohyk3P1/oyP3vmhD2xxuJOtsS9hp31lDm+2nlreCC3w5IKsUZABDQIDAQAB",
oauth2: {
client_id:
"33611715893-c00c0ofv209ophmc2tf113t3t6luslkt.apps.googleusercontent.com",
scopes: [
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email",
],
},
}));
}}}
}
export default defineManifest(async () => (json));
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"version": "0.3.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"dev": "cross-env BUILD_TARGET=chrome vite",
"build:chrome": "tsc && cross-env BUILD_TARGET=chrome vite build",
"build:edge": "tsc && cross-env BUILD_TARGET=edge vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
Expand Down Expand Up @@ -45,6 +46,7 @@
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
Expand Down
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

188 changes: 0 additions & 188 deletions src/api/deepl.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/api/youdaoTranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default async function youdaoTranslate({
fetchSource = target
}
if (!youdaoSupportLang.includes(fetchSource)) {
throw new Error(`youdao don\'t support ${fetchSource} as the learn language`);
throw new Error(`youdao don't support ${fetchSource} as the learn language`);
}
const url = `https://www.youdao.com/result?word=${formateText(
text
Expand Down
67 changes: 0 additions & 67 deletions src/utils/qwertyUtil.ts

This file was deleted.

1 change: 0 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import react from '@vitejs/plugin-react'
import { crx } from "@crxjs/vite-plugin";
import manifestConfig from "./manifest.config";
import { resolve } from "path";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), crx({ manifest: manifestConfig })],
Expand Down

0 comments on commit a1c7e5c

Please sign in to comment.