Skip to content

Commit

Permalink
新增代码压缩工具;ChatGPT增加api-key自助配置入口;其他bug一并修复
Browse files Browse the repository at this point in the history
  • Loading branch information
xianliezhao@foxmail.com committed Jan 5, 2023
1 parent 9e2349b commit 4346a91
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/background/awesome.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ let Awesome = (() => {
}
});
Object.keys(toolMap).forEach(tool => {
toolMap[tool].installed = toolMap[tool].installed || toolMap[tool].offloadForbid;
toolMap[tool].installed = toolMap[tool].systemInstalled || toolMap[tool].installed;
});
return toolMap;
});
Expand Down
1 change: 0 additions & 1 deletion apps/background/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export default (function () {
};
break;


case 'qr-code':
toolMap[tool].menuConfig[0].onClick = function (info, tab) {
chrome.scripting.executeScript({
Expand Down
10 changes: 9 additions & 1 deletion apps/background/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let toolMap = {
tips: '页面自动检测并格式化、手动格式化、乱码解码、排序、BigInt、编辑、下载、皮肤定制等',
contentScriptJs: true,
contentScriptCss: true,
offloadForbid: true,
systemInstalled: true,
menuConfig: [{
icon: '⒥',
text: 'JSON格式化',
Expand Down Expand Up @@ -62,6 +62,14 @@ let toolMap = {
contexts: ['page', 'selection', 'editable']
}]
},
'code-compress': {
name: '代码压缩工具',
tips: 'Web开发用,提供简单的代码压缩功能,支持HTML、Javascript、CSS代码压缩',
menuConfig: [{
icon: '♯',
text: '代码压缩工具'
}]
},
'chatgpt': {
name: 'ChatGPT工具',
tips: '由OpenAI强力支撑的超智能对话工具,可以让它帮你写代码、查资料、做分析、甚至帮你画一幅画',
Expand Down
7 changes: 7 additions & 0 deletions apps/chatgpt/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ <h3 class="panel-title">
<input type="radio" name="rdoImgSize" value="1024x1024" v-model="imgSize" id="rdoImgSize_1024"><label for="rdoImgSize_1024">1024*1024</label>
</div>
</fieldset>

<fieldset>
<legend>设置API-KEY</legend>
<div>
<input type="text" id="elmApiKey" class="form-control" v-model="authKey">
</div>
</fieldset>
<div class="x-sure">
<input class="btn btn-sm btn-primary ui-mr-10" type="button" value="取消" @click="toggleSettingPanel()">
<input class="btn btn-sm btn-success" type="button" value="确定" @click="saveSettings()">
Expand Down
14 changes: 10 additions & 4 deletions apps/chatgpt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ new Vue({
mounted: function () {
this.$refs.prompt.focus();
this.authKey = this.decodeAuthKey(this.$refs.prompt.getAttribute('data-key'));
// 如果本地有存储过authKey,就优先用本地的
Awesome.StorageMgr.get('CHATGPT_AUTH_KEY').then(authKey => {
this.authKey = authKey || this.authKey;
});

Awesome.StorageMgr.get('CHATGPT_CONVERSATION').then(results => {
if(results && results.length) {
Expand Down Expand Up @@ -93,6 +97,10 @@ new Vue({
// 鉴权失败
if(resp.status == 401) {
json.errorMessage = '出错啦!ChatGPT鉴权失败!';
} else if(resp.status == 429) {
let url = 'https://beta.openai.com/account/api-keys';
json.errorMessage = '当前账号下OpenAI的免费限额用完了,你可以在右上角【机器人设置】中更换为你自己的OpenAI API Key!'
+ `如果你还没有OpenAI账号,<a class="resp-tips" target="_blank" href="${url}">你可以点击这里进入</a>,提前申请好API Key!`;
} else {
json.errorMessage = '发生未知错误,请稍后再试!';
}
Expand Down Expand Up @@ -190,7 +198,8 @@ new Vue({
this.showSettingPanel = false;
Awesome.StorageMgr.set('CHATGPT_IMAGE_SIZE',this.imgSize);
Awesome.StorageMgr.set('CHATGPT_CHAT_MODEL',this.chatModel);
toast('设置成功,已立即生效!');
Awesome.StorageMgr.set('CHATGPT_AUTH_KEY',this.authKey);
toast('设置成功,已立即生效,可以继续使用了!');
},
imageBase64(onlineSrc) {
let that = this;
Expand Down Expand Up @@ -220,9 +229,6 @@ new Vue({
},
decodeAuthKey(dataKey){
return EncodeUtils.utf8Decode(EncodeUtils.base64Decode(dataKey));
},
loadApiKey(){

}
}

Expand Down
2 changes: 1 addition & 1 deletion apps/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "FeHelper(前端助手)-Dev",
"short_name": "FeHelper",
"version": "2022.12.2716",
"version": "2023.01.0512",
"manifest_version": 3,
"description": "JSON自动格式化、手动格式化,支持排序、解码、下载等,更多功能可在配置页按需安装!",
"icons": {
Expand Down
4 changes: 2 additions & 2 deletions apps/options/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ <h4># FH应用市场 <span class="x-tips">(严格遵循Google官方要求的
<span class="x-tips">({{fhTools[tool].tips}})</span>

<span class="ui-fl-r x-btn-box">
<button class="btn btn-danger btn-xs" @click="offLoad(tool,$event)" v-if="!fhTools[tool].offloadForbid">卸载</button>
<button class="btn btn-disabled btn-xs" v-if="fhTools[tool].offloadForbid" title="系统预装,不可被卸载">卸载</button>
<button class="btn btn-danger btn-xs" @click="offLoad(tool,$event)" v-if="!fhTools[tool].systemInstalled">卸载</button>
<button class="btn btn-disabled btn-xs" v-if="fhTools[tool].systemInstalled" title="系统预装,不可被卸载">卸载</button>
<button class="btn btn-xs" :class="fhTools[tool].menu ? 'btn-warning' : 'btn-info'" @click="menuMgr(tool,$event)">{{fhTools[tool].menu ? '移出' : '加入'}}右键</button>
</span>

Expand Down
Binary file modified output/fehelper.zip
Binary file not shown.

0 comments on commit 4346a91

Please sign in to comment.