use for-of statements to replace for and for-in
This commit is contained in:
@@ -338,18 +338,20 @@ watch(currentValue, (newValue) => {
|
||||
const decimalSeparator = getCurrentDecimalSeparator();
|
||||
|
||||
if (newValue[0] === '-' || newValue[0] === decimalSeparator) {
|
||||
actualNumeralSystem = NumeralSystem.detect(newValue[1]);
|
||||
actualNumeralSystem = NumeralSystem.detect(newValue.charAt(1));
|
||||
} else {
|
||||
actualNumeralSystem = NumeralSystem.detect(newValue[0]);
|
||||
actualNumeralSystem = NumeralSystem.detect(newValue.charAt(0));
|
||||
}
|
||||
|
||||
if (actualNumeralSystem && (actualNumeralSystem.type === NumeralSystem.WesternArabicNumerals.type || actualNumeralSystem.type === numeralSystem.value.type)) {
|
||||
for (let i = 0; i < newValue.length; i++) {
|
||||
if (!NumeralSystem.WesternArabicNumerals.isDigit(newValue[i]) && !numeralSystem.value.isDigit(newValue[i]) && newValue[i] !== '-' && newValue[i] !== decimalSeparator) {
|
||||
const ch = newValue.charAt(i);
|
||||
|
||||
if (!NumeralSystem.WesternArabicNumerals.isDigit(ch) && !numeralSystem.value.isDigit(ch) && ch !== '-' && ch !== decimalSeparator) {
|
||||
break;
|
||||
}
|
||||
|
||||
finalValue += newValue[i];
|
||||
finalValue += ch;
|
||||
}
|
||||
|
||||
finalValue = numeralSystem.value.replaceWesternArabicDigitsToLocalizedDigits(finalValue);
|
||||
|
||||
@@ -52,7 +52,7 @@ import { ref, computed } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
import type { NameNumeralValue } from '@/core/base.ts';
|
||||
import { type NameNumeralValue, keys } from '@/core/base.ts';
|
||||
import type { NumeralSystem } from '@/core/numeral.ts';
|
||||
import type { ComponentDensity } from '@/lib/ui/desktop.ts';
|
||||
|
||||
@@ -94,11 +94,7 @@ const currentPage = computed<number>({
|
||||
if (value && value >= 1 && value <= props.totalPageCount) {
|
||||
emit('update:modelValue', value);
|
||||
|
||||
for (const key in showMenus.value) {
|
||||
if (!Object.prototype.hasOwnProperty.call(showMenus.value, key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const key of keys(showMenus.value)) {
|
||||
showMenus.value[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import type { CallbackDataParams } from 'echarts/types/dist/shared';
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
import { type CommonPieChartDataItem, type CommonPieChartProps, usePieChartBase } from '@/components/base/PieChartBase.ts'
|
||||
|
||||
import { itemAndIndex } from '@/core/base.ts';
|
||||
import type { ColorStyleValue } from '@/core/color.ts';
|
||||
import { ThemeType } from '@/core/theme.ts';
|
||||
|
||||
@@ -41,8 +42,7 @@ const isDarkMode = computed<boolean>(() => theme.global.name.value === ThemeType
|
||||
const itemsMap = computed<Record<string, Record<string, unknown>>>(() => {
|
||||
const map: Record<string, Record<string, unknown>> = {};
|
||||
|
||||
for (let i = 0; i < props.items.length; i++) {
|
||||
const item = props.items[i];
|
||||
for (const item of props.items) {
|
||||
let id = '';
|
||||
|
||||
if (props.idField && item[props.idField]) {
|
||||
@@ -60,8 +60,7 @@ const itemsMap = computed<Record<string, Record<string, unknown>>>(() => {
|
||||
const seriesData = computed<DesktopPieChartDataItem[]>(() => {
|
||||
const ret: DesktopPieChartDataItem[] = [];
|
||||
|
||||
for (let i = 0; i < validItems.value.length; i++) {
|
||||
const item = validItems.value[i];
|
||||
for (const item of validItems.value) {
|
||||
ret.push({
|
||||
...item,
|
||||
itemStyle: {
|
||||
@@ -75,9 +74,7 @@ const seriesData = computed<DesktopPieChartDataItem[]>(() => {
|
||||
});
|
||||
|
||||
const hasUnselectedItem = computed<boolean>(() => {
|
||||
for (let i = 0; i < validItems.value.length; i++) {
|
||||
const item = validItems.value[i];
|
||||
|
||||
for (const item of validItems.value) {
|
||||
if (selectedLegends.value && !selectedLegends.value[item.id]) {
|
||||
return true;
|
||||
}
|
||||
@@ -91,9 +88,7 @@ const firstItemAndHalfCurrentItemTotalPercent = computed<number>(() => {
|
||||
let firstValue = null;
|
||||
let firstToCurrentTotalValue = 0;
|
||||
|
||||
for (let i = 0; i < validItems.value.length; i++) {
|
||||
const item = validItems.value[i];
|
||||
|
||||
for (const [item, index] of itemAndIndex(validItems.value)) {
|
||||
if (selectedLegends.value && !selectedLegends.value[item.id]) {
|
||||
continue;
|
||||
}
|
||||
@@ -103,9 +98,9 @@ const firstItemAndHalfCurrentItemTotalPercent = computed<number>(() => {
|
||||
}
|
||||
|
||||
if (firstValue !== null) {
|
||||
if (i < selectedIndex.value) {
|
||||
if (index < selectedIndex.value) {
|
||||
firstToCurrentTotalValue += item.value;
|
||||
} else if (i === selectedIndex.value) {
|
||||
} else if (index === selectedIndex.value) {
|
||||
firstToCurrentTotalValue += item.value / 2;
|
||||
}
|
||||
}
|
||||
@@ -241,11 +236,9 @@ function onLegendSelectChanged(e: { selected: Record<string, boolean> }): void {
|
||||
if (!selectedItem || !selectedLegends.value[selectedItem.id]) {
|
||||
let newSelectedIndex = 0;
|
||||
|
||||
for (let i = 0; i < validItems.value.length; i++) {
|
||||
const item = validItems.value[i];
|
||||
|
||||
for (const [item, index] of itemAndIndex(validItems.value)) {
|
||||
if (selectedLegends.value[item.id]) {
|
||||
newSelectedIndex = i;
|
||||
newSelectedIndex = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,9 +138,9 @@ function updateFrequencyValue(value: number, selected: boolean | null): void {
|
||||
const currentFrequencyValues = frequencyValue.value;
|
||||
const newFrequencyValues: number[] = [];
|
||||
|
||||
for (let i = 0; i < currentFrequencyValues.length; i++) {
|
||||
if (currentFrequencyValues[i] !== value || selected) {
|
||||
newFrequencyValues.push(currentFrequencyValues[i]);
|
||||
for (const currentFrequencyValue of currentFrequencyValues) {
|
||||
if (currentFrequencyValue !== value || selected) {
|
||||
newFrequencyValues.push(currentFrequencyValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ import { computed } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
import { itemAndIndex } from '@/core/base.ts';
|
||||
import { NumeralSystem } from '@/core/numeral.ts';
|
||||
|
||||
export interface StepBarItem {
|
||||
@@ -87,9 +88,9 @@ function isStepActive(step: StepBarItem): boolean {
|
||||
}
|
||||
|
||||
function isStepCompleted(stepIndex: number): boolean {
|
||||
for (let i = 0; i < props.steps.length; i++) {
|
||||
if (props.steps[i].name === props.currentStep) {
|
||||
return stepIndex < i;
|
||||
for (const [step, index] of itemAndIndex(props.steps)) {
|
||||
if (step.name === props.currentStep) {
|
||||
return stepIndex < index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user