Skip to content

Commit

Permalink
Settings: add bit unit
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Jul 8, 2021
1 parent a565a53 commit dc38705
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 128 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flashmaster",
"version": "1.1.0",
"version": "1.2.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
1 change: 1 addition & 0 deletions src/lang/chs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
customization: {
title: '个性化',
autoHideSoftKeyboard: '自动隐藏软键盘',
bitUnit: '使用 bit 作为容量单位',
theme: '主题',
theme_0: '深色',
theme_1: '浅色',
Expand Down
3 changes: 2 additions & 1 deletion src/lang/eng.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ module.exports = {
statistic: {
title: 'Statistic',
reset: 'Reset',
resetInfo: 'Statistic data have reseted.',
resetInfo: 'Statistic data have been reset.',
content: '{0} Part Numbers have been decoded.<br/>{1} Part Numbers have been searched.<br/>{2} Flash Ids have been decoded.<br/>{3} Flash Ids have been searched.'
},
customization: {
title: 'Customization',
autoHideSoftKeyboard: 'Auto hide soft keyboard',
bitUnit: 'Use bit as density unit',
theme: 'Theme',
theme_0: 'Dark',
theme_1: 'Light',
Expand Down
14 changes: 14 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const getServerAddress = () => {
const setServerAddress = (addr) => {
localStorage.server = addr
};

const statDecodeIdInc = () => {
if (isNaN(Number(localStorage.statDecodeId))) {
localStorage.statDecodeId = "0";
Expand Down Expand Up @@ -84,6 +85,17 @@ const isAutoHideSoftKeyboard = () => {
return localStorage.autoHideSoftKeyboard === "1"
}

const setBitUnit = (b) => {
localStorage.bitUnit = b ? "1" : "0"
}

const isBitUnit = () => {
if (isNaN(Number(localStorage.bitUnit))) {
setAutoHideSoftKeyboard(false);
}
return localStorage.bitUnit === "1"
}

const partNumberFormat = str => {
return str.toUpperCase()
.replace(/,/g, "")
Expand Down Expand Up @@ -130,6 +142,8 @@ export default {
getLang,
setAutoHideSoftKeyboard,
isAutoHideSoftKeyboard,
setBitUnit,
isBitUnit,
partNumberFormat,
setTheme,
getTheme,
Expand Down
2 changes: 1 addition & 1 deletion src/views/Decode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export default {
data = data.data;
this.vendor = data.vendor;
this.type = data.type;
this.density = data.density;
this.density = store.formatNumber(data.rawDensity, 2, true, store.isBitUnit());
this.deviceWidth = data.deviceWidth;
this.cellLevel = data.cellLevel;
this.processNode = data.processNode;
Expand Down
2 changes: 1 addition & 1 deletion src/views/DecodeId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export default {
.then(data => {
data = data.data;
this.vendor = data.vendor;
this.density = data.density;
this.density = store.formatNumber(data.density, 2, true, store.isBitUnit());
this.cellLevel = data.cellLevel;
this.processNode = data.processNode;
this.pageSize = store.formatNumber(data.pageSize);
Expand Down
Loading

0 comments on commit dc38705

Please sign in to comment.