Skip to content

Commit

Permalink
Settings: add statistic
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Nov 20, 2019
1 parent 2964a66 commit a383c9f
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 24 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# iTXTech FlashMaster

[![Donate](https://img.shields.io/badge/alipay-donate-yellow.svg)](https://qr.alipay.com/FKX04751EZDP0SQ0BOT137)

Powerful NAND Flash Part Number and Id query toolbox.

## Introduction
Expand Down Expand Up @@ -50,4 +52,4 @@ Upload all files in `dist`.
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
18 changes: 3 additions & 15 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,11 @@
<v-content>
<router-view />
</v-content>
<v-dialog
v-model="loading"
hide-overlay
persistent
width="300"
>
<v-card
color="primary"
dark
>
<v-dialog v-model="loading" hide-overlay persistent width="300">
<v-card color="primary" dark>
<v-card-text>
{{$t('loading')}}
<v-progress-linear
indeterminate
color="white"
class="mb-0"
></v-progress-linear>
<v-progress-linear indeterminate color="white" class="mb-0"/>
</v-card-text>
</v-card>
</v-dialog>
Expand Down
Binary file modified src/assets/wechat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions src/lang/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ module.exports = {
st: 'STMicroelectronics',
spectek: 'SpecTek'
},
support: {
alipay: 'Support Us - Alipay',
wechat: 'Support Us - WeChat',
alipayUrl: 'Open Alipay',
saveQrCode: 'Save QR Code'
},
statistic: {
title: 'Statistic',
reset: 'Reset',
resetInfo: 'Statistic data have reseted.',
content: '{0} Part Numbers have been decoded.<br/>{1} Part Numbers have been searched.<br/>{2} Flash Ids have been searched.'
},
loading: 'Loading',
unknown: 'Unknown',
query: "Decode PN",
Expand Down Expand Up @@ -64,7 +76,5 @@ module.exports = {
flashIds: 'Flash Ids',
flashId: 'Flash Id',
action: 'Action',
supportUsAlipay: 'Support Us - Alipay',
supportUsWeChat: 'Support Us - WeChat',
about: '<a href="https://github.com/iTXTech/FlashMaster" target="_blank">iTXTech FlashMaster</a><br/>Built with <a href="https://vuejs.org" target="_blank">Vue.js</a> and <a href="https://vuetifyjs.com/" target="_blank">Vuetify</a><br/>This program is licensed under Apache License 2.0<br/><br/>Maintainers:<br/><a href="https://peratx.net" target="_blank">PeratX</a><br/><br/>Copyright (C) 2019 <a href="https://itxtech.org" target="_blank">iTX Technologies</a>'
}
14 changes: 12 additions & 2 deletions src/lang/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ module.exports = {
st: '意法半导体',
spectek: '美光白片'
},
support: {
alipay: '支持作者 - 支付宝(推荐)',
wechat: '支持作者 - 微信',
alipayUrl: '打开支付宝',
saveQrCode: '保存二维码'
},
statistic: {
title: '统计',
reset: '重置',
resetInfo: '统计数据已重置。',
content: '共查询料号 {0} 次。<br/>共搜索料号 {1} 个。<br/>共搜索闪存ID {2} 个。'
},
loading: '加载中',
unknown: '未知',
query: '查询料号',
Expand Down Expand Up @@ -64,7 +76,5 @@ module.exports = {
flashIds: '闪存ID',
flashId: '闪存ID',
action: '操作',
supportUsAlipay: '支持作者 - 支付宝',
supportUsWeChat: '支持作者 - 微信',
about: '<a href="https://github.com/iTXTech/FlashMaster" target="_blank">iTXTech FlashMaster</a><br/>使用 <a href="https://vuejs.org" target="_blank">Vue.js</a> 和 <a href="https://vuetifyjs.com/" target="_blank">Vuetify</a> 构建<br/>本程序遵循 Apache License 2.0 开源<br/><br/>主要维护者:<br/><a href="https://peratx.net" target="_blank">PeratX</a><br/><br/><a href="https://market.m.taobao.com/app/idleFish-F2e/IdleFishWeexPersonalPage/PersonalHome?ut_sk=1.WmC0tf46/fADAD7YJeN2DyOW_12431167_1573698250610.QRCode.mypage.894797966.894797966&userid=894797966&wh_weex=true&forceFlush=1" target="_blank">去作者的闲鱼主页看看</a><br/><br/>Copyright (C) 2019 <a href="https://itxtech.org" target="_blank">iTX Technologies</a>'
}
48 changes: 47 additions & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,55 @@ const setAutoTranslation = (auto) => {
localStorage.autoTranslation = auto ? "1" : "0";
}

const statDecodeIdInc = () => {
if (isNaN(Number(localStorage.statDecodeId))) {
localStorage.statDecodeId = "0";
}
localStorage.statDecodeId = String(Number(localStorage.statDecodeId) + 1);
}

const statDecodeId = () => {
return localStorage.statDecodeId || 0;
}

const statSearchPnInc = () => {
if (isNaN(Number(localStorage.statSearchPn))) {
localStorage.statSearchPn = "0";
}
localStorage.statSearchPn = String(Number(localStorage.statSearchPn) + 1);
}

const statSearchPn = () => {
return localStorage.statSearchPn || 0;
}

const statSearchIdInc = () => {
if (isNaN(Number(localStorage.statSearchId))) {
localStorage.statSearchId = "0";
}
localStorage.statSearchId = String(Number(localStorage.statSearchId) + 1);
}

const statSearchId = () => {
return localStorage.statSearchId || 0;
}

const resetStat = () => {
localStorage.statDecodeId = "0"
localStorage.statSearchId = "0"
localStorage.statSearchPn = "0"
}

export default {
getServerAddress,
setServerAddress,
autoTranslation,
setAutoTranslation
setAutoTranslation,
statDecodeIdInc,
statDecodeId,
statSearchPnInc,
statSearchPn,
statSearchIdInc,
statSearchId,
resetStat
}
11 changes: 9 additions & 2 deletions src/views/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,26 @@

<v-flex lg3 sm12 xs12>
<v-card>
<v-card-title>{{$t('supportUsAlipay')}}</v-card-title>
<v-card-title>{{$t('support.alipay')}}</v-card-title>
<v-card-text>
<v-img :src="require('@/assets/alipay.jpg')" />
</v-card-text>
<v-card-actions>
<v-btn href="https://qr.alipay.com/FKX04751EZDP0SQ0BOT137" target="_blank" text>{{$t('support.alipayUrl')}}</v-btn>
<v-btn text :href="require('@/assets/alipay.jpg')" download="alipay.jpg">{{$t('support.saveQrCode')}}</v-btn>
</v-card-actions>
</v-card>
</v-flex>

<v-flex lg3 sm12 xs12>
<v-card>
<v-card-title>{{$t('supportUsWeChat')}}</v-card-title>
<v-card-title>{{$t('support.wechat')}}</v-card-title>
<v-card-text>
<v-img :src="require('@/assets/wechat.jpg')" />
</v-card-text>
<v-card-actions>
<v-btn text :href="require('@/assets/wechat.jpg')" download="wechat.jpg">{{$t('support.saveQrCode')}}</v-btn>
</v-card-actions>
</v-card>
</v-flex>
</v-layout>
Expand Down
1 change: 1 addition & 0 deletions src/views/Decode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export default {
}
}
bus.$emit("loading", false);
store.statDecodeIdInc();
})
.catch(err => {
bus.$emit("snackbar", {
Expand Down
1 change: 1 addition & 0 deletions src/views/SearchId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export default {
}
this.ids = this.tids;
bus.$emit("loading", false);
store.statSearchIdInc();
});
})
.catch(err => {
Expand Down
1 change: 1 addition & 0 deletions src/views/SearchPn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default {
});
}
bus.$emit("loading", false);
store.statSearchPnInc();
})
.catch(err => {
bus.$emit("snackbar", {
Expand Down
38 changes: 37 additions & 1 deletion src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
</v-card-actions>
</v-card>
</v-flex>

<v-flex lg3 sm12 xs12>
<v-card>
<v-card-title>{{$t('statistic.title')}}</v-card-title>
<v-card-text v-html="statContent" />
<v-card-actions>
<v-btn text @click="resetStat">{{$t("statistic.reset")}}</v-btn>
</v-card-actions>
</v-card>
</v-flex>
</v-layout>
</v-container>

Expand Down Expand Up @@ -55,6 +65,9 @@ export default {
}
}
return s;
},
transStat() {
return this.updateStat();
}
},
data() {
Expand All @@ -65,10 +78,12 @@ export default {
dialog: {
show: false,
text: ""
}
},
statContent: ""
};
},
created: function() {
this.statContent = this.updateStat();
this.autoTrans = store.autoTranslation() == "1" ? true : false;
fetch(
"https://raw.githubusercontent.com/PeratX/FlashMaster/master/servers.json"
Expand Down Expand Up @@ -108,6 +123,27 @@ export default {
text: this.$t("alert.fetchFailed", [err])
});
});
},
resetStat() {
store.resetStat();
this.statContent = this.updateStat();
bus.$emit("snackbar", {
timeout: 3000,
show: true,
text: this.$t("statistic.resetInfo")
});
},
updateStat() {
return this.$t("statistic.content", [
store.statDecodeId(),
store.statSearchPn(),
store.statSearchId()
]);
}
},
watch: {
transStat(v) {
this.statContent = v;
}
}
};
Expand Down

0 comments on commit a383c9f

Please sign in to comment.