优化程序逻辑
This commit is contained in:
parent
be4bbe55df
commit
d1f8b403c4
@ -1,6 +1,3 @@
|
|||||||
// content.js
|
|
||||||
|
|
||||||
// 1. 注入 main.js
|
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
script.type = 'module';
|
script.type = 'module';
|
||||||
script.src = chrome.runtime.getURL('main.js');
|
script.src = chrome.runtime.getURL('main.js');
|
||||||
|
|||||||
8
main.js
8
main.js
@ -1,7 +1,7 @@
|
|||||||
import { createPanel } from './panel.js';
|
import { createPanel } from './scripts/panel.js';
|
||||||
import { handleCommand, COMMANDS } from './commands.js';
|
import { handleCommand, COMMANDS } from './scripts/commands.js';
|
||||||
import { initVoice } from './voice.js';
|
import { initVoice } from './scripts/voice.js';
|
||||||
import { translateToCommand } from './ai.js';
|
import { translateToCommand } from './scripts/ai.js';
|
||||||
|
|
||||||
// 等待页面加载完成
|
// 等待页面加载完成
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
|
|||||||
@ -4,10 +4,10 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"permissions": ["activeTab", "storage"],
|
"permissions": ["activeTab", "storage"],
|
||||||
"background": {
|
"background": {
|
||||||
"service_worker": "background.js"
|
"service_worker": "background/background.js"
|
||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
"default_popup": "popup.html",
|
"default_popup": "popup/popup.html",
|
||||||
"default_title": "AI 配置"
|
"default_title": "AI 配置"
|
||||||
},
|
},
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
@ -19,7 +19,7 @@
|
|||||||
],
|
],
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [
|
||||||
{
|
{
|
||||||
"resources": ["*.js", "*.css"],
|
"resources": ["main.js", "scripts/*.js"],
|
||||||
"matches": ["*://1718cloud.com/*"]
|
"matches": ["*://1718cloud.com/*"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,7 +1,3 @@
|
|||||||
// 设置默认值
|
|
||||||
const DEFAULT_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1";
|
|
||||||
const DEFAULT_MODEL = "qwen-plus";
|
|
||||||
|
|
||||||
// 页面加载时读取存储的配置
|
// 页面加载时读取存储的配置
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
chrome.storage.sync.get(['aiConfig'], (result) => {
|
chrome.storage.sync.get(['aiConfig'], (result) => {
|
||||||
Loading…
x
Reference in New Issue
Block a user