Skip to content

Commit 2a6e451

Browse files
committed
fix review
1 parent bb7bab3 commit 2a6e451

File tree

3 files changed

+78
-55
lines changed

3 files changed

+78
-55
lines changed

src/components/commentBanner.vue

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,86 @@
11
<template>
22
<v-alert
3-
v-if="isNewVisit"
4-
type="success"
3+
v-if="isBannerVisible"
4+
:type="alertType"
55
border="start"
66
variant="tonal"
77
closable
88
close-label="Close Alert"
9-
:title="title"
9+
:title="alertTitle"
1010
style="min-height: 90px;"
1111
>
12-
{{ subtitle }}
12+
{{ alertSubtitle }}
1313
<template v-slot:append>
1414
<v-btn
1515
variant="tonal"
1616
style="position: absolute; bottom: 10px; right: 10px;"
17-
@click="handleClick(url)"
17+
@click="handleClick(alertUrl)"
1818
>
19-
Open
19+
{{ buttonText }}
2020
</v-btn>
2121
</template>
2222
</v-alert>
2323
</template>
24-
<script>
2524

25+
<script>
2626
import browser from "webextension-polyfill";
2727
import { useSettingStore } from "/src/stores/setting.js";
2828
import { mapState } from "pinia";
29+
import {getReviewUrl} from "/src/util/review_util.js";
30+
2931
3032
export default {
3133
name: "CommentBanner",
3234
emits: ["click"],
33-
// props: ["title"],
3435
data() {
3536
return {
36-
title: browser.i18n.getMessage("Support_this_extension"),
37-
subtitle: browser.i18n.getMessage("Feed_a_coffee_to_the_extension_devs"),
38-
url: "https://buymeacoffee.com/ttop324",
37+
messages: {
38+
title: browser.i18n.getMessage("Support_this_extension"),
39+
subtitle: browser.i18n.getMessage("Feed_a_coffee_to_the_extension_devs"),
40+
url: "https://buymeacoffee.com/ttop324",
41+
reviewTitle: browser.i18n.getMessage("Review_this"),
42+
reviewSubtitle: browser.i18n.getMessage("Developer_love_criticism"),
43+
reviewUrl: getReviewUrl(),
44+
},
45+
coffeeCount: 0,
46+
isBannerVisible: false,
47+
alertType: "",
48+
alertTitle: "",
49+
alertSubtitle: "",
50+
alertUrl: "",
51+
buttonText: "",
3952
};
4053
},
4154
async mounted() {
4255
await this.waitSettingLoad();
43-
this.increasePopupCount();
56+
this.updateCoffeeCount();
57+
this.updateBannerProperties();
4458
},
4559
computed: {
4660
...mapState(useSettingStore, ["setting", "waitSettingLoad"]),
47-
isNewVisit() {
48-
var count = Number(this.setting?.["coffeeCount"]);
49-
return 1 < count && count < 15;
61+
coffeeCount() {
62+
return Number(this.setting?.["coffeeCount"]);
5063
},
5164
},
5265
methods: {
53-
openUrl(newURL) {
54-
window.open(newURL);
55-
},
56-
handleClick(newURL) {
57-
this.openUrl(newURL);
58-
this.finishPopupCount();
66+
handleClick(url) {
67+
window.open(url);
68+
this.updateCoffeeCount(10);
69+
this.updateBannerProperties();
5970
this.$emit("click");
6071
},
61-
increasePopupCount(inc = 1) {
62-
var count = Number(this.setting["coffeeCount"]);
63-
if (count < 17) {
64-
this.setting["coffeeCount"] = count + inc;
65-
}
72+
updateCoffeeCount(increment = 1) {
73+
const count = Number(this.setting["coffeeCount"]);
74+
this.setting["coffeeCount"] = Math.min(count + increment, 17);
75+
this.coffeeCount = this.setting["coffeeCount"];
6676
},
67-
finishPopupCount() {
68-
this.increasePopupCount(100);
77+
updateBannerProperties() {
78+
this.isBannerVisible = this.coffeeCount < 15;
79+
this.alertType = this.coffeeCount < 5 ? "info" : "success";
80+
this.alertTitle = this.coffeeCount < 5 ? this.messages.reviewTitle : this.messages.title;
81+
this.alertSubtitle = this.coffeeCount < 5 ? this.messages.reviewSubtitle : this.messages.subtitle;
82+
this.alertUrl = this.coffeeCount < 5 ? this.messages.reviewUrl : this.messages.url;
83+
this.buttonText = this.coffeeCount < 5 ? "Review" : "Open";
6984
},
7085
},
7186
};

src/pages/about.vue

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,7 @@
4242
</template>
4343
<script>
4444
import browser from "webextension-polyfill";
45-
// import * as util from "/src/util";
46-
47-
var reviewUrlJson = {
48-
nnodgmifnfgkolmakhcfkkbbjjcobhbl:
49-
"https://microsoftedge.microsoft.com/addons/detail/mouse-tooltip-translator/nnodgmifnfgkolmakhcfkkbbjjcobhbl", //edge web store id
50-
hmigninkgibhdckiaphhmbgcghochdjc:
51-
"https://chromewebstore.google.com/detail/hmigninkgibhdckiaphhmbgcghochdjc/reviews", //chrome web store id
52-
firefox:
53-
"https://addons.mozilla.org/en-US/firefox/addon/mouse-tooltip-translator-pdf/reviews/",
54-
default:
55-
"https://chromewebstore.google.com/detail/hmigninkgibhdckiaphhmbgcghochdjc/reviews",
56-
};
45+
import { getReviewUrl } from "/src/util/review_util.js";
5746
5847
export default {
5948
name: "AboutView",
@@ -93,8 +82,8 @@ export default {
9382
},
9483
reviewPage: {
9584
name: browser.i18n.getMessage("Review_Page"),
96-
sub_name: browser.i18n.getMessage("Comment_on_this_extension"),
97-
url: this.getReviewUrl(),
85+
sub_name: browser.i18n.getMessage("Comment_on_this extension"),
86+
url: getReviewUrl(),
9887
icon: "mdi-message-draw",
9988
color: "primary",
10089
},
@@ -132,19 +121,6 @@ export default {
132121
this.openUrlAsPanel(url);
133122
}
134123
},
135-
getReviewUrl() {
136-
const extId = browser.runtime.id;
137-
if (extId in reviewUrlJson) {
138-
return reviewUrlJson[extId];
139-
}
140-
if (this.isFirefox()) {
141-
return reviewUrlJson["firefox"];
142-
}
143-
return reviewUrlJson["default"];
144-
},
145-
isFirefox() {
146-
return typeof InstallTrigger !== "undefined";
147-
},
148124
async openUrlAsPanel(url) {
149125
var url = browser.runtime.getURL(url);
150126
await this.removePreviousTab(url);

src/util/review_util.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var browser;
2+
try {
3+
browser = require("webextension-polyfill");
4+
} catch (error) {}
5+
6+
var reviewUrlJson = {
7+
nnodgmifnfgkolmakhcfkkbbjjcobhbl:
8+
"https://microsoftedge.microsoft.com/addons/detail/mouse-tooltip-translator/nnodgmifnfgkolmakhcfkkbbjjcobhbl", //edge web store id
9+
hmigninkgibhdckiaphhmbgcghochdjc:
10+
"https://chromewebstore.google.com/detail/hmigninkgibhdckiaphhmbgcghochdjc/reviews", //chrome web store id
11+
firefox:
12+
"https://addons.mozilla.org/en-US/firefox/addon/mouse-tooltip-translator-pdf/reviews/",
13+
default:
14+
"https://chromewebstore.google.com/detail/hmigninkgibhdckiaphhmbgcghochdjc/reviews",
15+
};
16+
17+
function getReviewUrl() {
18+
const extId = browser.runtime.id;
19+
if (extId in reviewUrlJson) {
20+
return reviewUrlJson[extId];
21+
}
22+
if (isFirefox()) {
23+
return reviewUrlJson["firefox"];
24+
}
25+
return reviewUrlJson["default"];
26+
}
27+
28+
function isFirefox() {
29+
return typeof InstallTrigger !== "undefined";
30+
}
31+
32+
export { getReviewUrl };

0 commit comments

Comments
 (0)