Skip to content

Commit

Permalink
feat: 增加一键清除功能
Browse files Browse the repository at this point in the history
  • Loading branch information
limy committed Feb 14, 2023
1 parent 9199d4d commit 75d3c9a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "chat-gpt-prompts",
"description": "一个 chat-gpt 的 chrome 插件,用来帮助用户存储、收集一些调教 gpt 的语料",
"private": true,
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "chat-gpt-prompts",
"description": "一个 chat-gpt 的 chrome 插件,用来帮助用户存储、收集一些调教 gpt 的语料",
"version": "1.0.0",
"version": "1.0.1",
"action": {
"default_popup": "src/popup/index.html",
"default_icon": {
Expand Down
10 changes: 9 additions & 1 deletion src/popup/PopupComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
/></el-icon>
</div>

<HandleResource :visible="showAdd" @add-item="addItem" />
<HandleResource
:visible="showAdd"
@add-item="addItem"
@clear="clearStore"
/>
</section>
<div class="blank"></div>

Expand Down Expand Up @@ -86,6 +90,10 @@ function remove(item: string) {
store.remove(item);
}
function clearStore() {
store.clear();
}
function onClick(item: string) {
autoFill(item);
}
Expand Down
15 changes: 12 additions & 3 deletions src/popup/components/HandleResource.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="handle-resource" v-show="visible">
<div class="add-item">
<div class="operation-item add-item">
<el-input
v-model="textarea"
:rows="1"
Expand All @@ -10,14 +10,17 @@
/>
<el-button class="add" type="primary" @click="addItem">增加</el-button>
</div>
<el-button class="go-link">
<el-button class="operation-item go-link">
<OpenLink
link="https://github.com/PlexPt/awesome-chatgpt-prompts-zh#readme"
content="ChatGPT 中文调教指南"
/>
页面抓取
</el-button>
<el-button class="operation-item" type="danger" @click="$emit('clear')"
>清除全部数据</el-button
>
</div>
</template>

Expand All @@ -29,6 +32,7 @@ import OpenLink from './OpenLink.vue';
defineProps<{ visible: boolean }>();
const emits = defineEmits<{
(event: 'add-item', content: string): void;
(event: 'clear'): void;
}>();
const textarea = ref('');
Expand All @@ -42,7 +46,13 @@ function addItem() {
.handle-resource {
display: flex;
flex-direction: column;
margin: 0 10px;
}
.operation-item {
margin-top: 5px;
}
.add-item {
width: 100%;
display: flex;
Expand All @@ -53,7 +63,6 @@ function addItem() {
}
.go-link {
margin-top: 5px;
display: flex;
justify-content: center;
}
Expand Down
6 changes: 5 additions & 1 deletion src/popup/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,9 @@ export const useLocalStore = () => {
}
}

return { add, remove, arr };
function clear() {
arr.splice(0, arr.length);
}

return { add, remove, clear, arr };
};
4 changes: 4 additions & 0 deletions src/popup/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ body {
color: #000;
background-color: #f7f8fa;
}

.el-button + .el-button {
margin-left: 0;
}

0 comments on commit 75d3c9a

Please sign in to comment.