Skip to content

Commit

Permalink
Merge pull request #13 from AGIUI/dev0.2.1
Browse files Browse the repository at this point in the history
bugfix
  • Loading branch information
shadowcz007 authored May 19, 2023
2 parents 564d1e4 + e433d56 commit 1a6a482
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
7 changes: 6 additions & 1 deletion src/components/background/ChatBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ class ChatBotBackground {
return
}
clearAvailables() {
Array.from(this.items, item => item.clearAvailable());
Array.from(this.items, item => {
item.clearAvailable();
item.token = null;
item.model = null;
item.baseUrl = null;
});
chrome.storage.sync.set({
chatBotAvailables: null
})
Expand Down
4 changes: 2 additions & 2 deletions src/components/background/ChatGPT.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ export default class ChatGPT {


baseUrl = baseUrl ? createAPIUrl(baseUrl) : this.baseUrl
// token = token || this.token
// model = model || this.model
token = token || this.token
model = model || this.model

this.token = token
this.baseUrl = baseUrl
Expand Down
39 changes: 18 additions & 21 deletions src/pages/content/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Main extends React.Component<{
loading: boolean,
// 是否全屏
fullscreen: boolean,

// 全局的禁止操作
disabledAll: boolean,
// 加载机器人,初始化
Expand All @@ -178,7 +178,7 @@ class Main extends React.Component<{
showEdit: boolean,

activeIndex: any,

talks: Array<{}>,
mixedCards: Array<{}>,

Expand Down Expand Up @@ -227,11 +227,11 @@ class Main extends React.Component<{
loading: this.props.initIsOpen ? false : true,
fullscreen: this.props.fullscreen,
activeIndex: undefined,

talks: [],

mixedCards: [],

// 禁止点击
disabledAll: true,

Expand Down Expand Up @@ -389,7 +389,7 @@ class Main extends React.Component<{
} else if (cmd == 'toggle-insight') {
this.setState({ initIsOpen: true });
this.show(false);
}else if (cmd == 'chat-bot-init-result') {
} else if (cmd == 'chat-bot-init-result') {
that.initChatBot(false);
}

Expand Down Expand Up @@ -539,20 +539,17 @@ class Main extends React.Component<{
return prompt
}

async _getPromptsData() {
//['user']
async _getPromptsData(keys = ['user']) {
let prompts: any[] = [];
const res: any = await chromeStorageGet(['user', 'official']);

if (res && res.user) for (const userPrompt of res.user) {
prompts.push(userPrompt);
}

if (res && res.official) for (const officialPrompt of res.official) {
prompts.push(officialPrompt);
const res: any = await chromeStorageGet(keys);
for (const k of keys) {
if (res && res[k]) {
for (const combo of res[k]) {
prompts.push(combo);
}
}
}

// console.log(prompts)

return prompts;
}

Expand Down Expand Up @@ -1130,7 +1127,7 @@ class Main extends React.Component<{


_doChatBotData() {

let subjects = [{
type: 'chatbot', text: '聊天', index: -1
}];
Expand All @@ -1148,22 +1145,22 @@ class Main extends React.Component<{
}

const datas = [talks]

const tabList = Array.from(subjects, subject => {
return {
key: subject.text,
tab: subject.text,
index: subject.index
}
});

return {
tabList, datas, activeIndex
}
}

render() {
const { tabList, datas, activeIndex } = this._doChatBotData();
const { tabList, datas, activeIndex } = this._doChatBotData();
return (<>
<FlexColumn
translate="no"
Expand Down

0 comments on commit 1a6a482

Please sign in to comment.