Skip to content

Commit

Permalink
Merge branch 'userXinos:master' into cn
Browse files Browse the repository at this point in the history
  • Loading branch information
233dada authored Nov 14, 2023
2 parents 80e6522 + 2a8311c commit d512745
Show file tree
Hide file tree
Showing 34 changed files with 235 additions and 302 deletions.
7 changes: 4 additions & 3 deletions src/components/Calculator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
</div>
</template>

<!--suppress TypeScriptCheckImport -->
<script setup lang="ts">
import { computed, ref, nextTick } from 'vue';
import { useI18n } from 'vue-i18n';
Expand All @@ -175,7 +176,7 @@ import statsStyleName from '@Handlers/statsStyleName';
import calculator from '@/composables/calculator';
import CalculatorConfig from '@/composables/calculatorConfig';
import type { Input, SetupComponent, SetupGetElementsCB } from '@/typings/calculator';
import type { Input, Output, SetupComponent, SetupGetElementsCB } from '@/typings/calculator';
type calculatorArgs = Parameters<typeof calculator>
type configArgs = ConstructorParameters<typeof CalculatorConfig>
Expand All @@ -193,7 +194,7 @@ const props = defineProps<Props>();
const emit = defineEmits(['update:input', 'setup']);
const format = {
key: (k: string) => key(k, router.currentRoute.name as string),
key: (k: string) => key(k, router.currentRoute.value.name as string),
value: (k: string, v: unknown) => value(k, v, router.currentRoute.value.name as string),
};
Expand Down Expand Up @@ -248,7 +249,7 @@ function fullUpdate() {
updateOutput();
}
async function onReset(event: Event): Promise<void> {
if ((event.target).name == 'all') {
if ((event.target as HTMLInputElement).name == 'all') {
await resetConfirm('Reset all ? Are you serious ?')
.then(() => {
for (const key in props.input) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/Changelog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Modal
:open="isOpen"
:size="SIZES.LARGE"
:title="titleKey ? $t(titleKey) : null"
:title="titleKey ? $t(titleKey) : undefined"
@update:open="$emit('close')"
>
<template #body>
Expand All @@ -15,6 +15,7 @@
</Modal>
</template>

<!--suppress TypeScriptCheckImport -->
<script setup lang="ts">
import { ref, onMounted } from 'vue';
Expand Down
4 changes: 2 additions & 2 deletions src/components/CompendiumPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
>
<div class="avatar">
<img
:src="getDiscordIconUrl(guild.id, guild.icon)"
:alt="`${guild.name} icon`"
:src="getDiscordIconUrl(guild!.id, guild!.icon)"
:alt="`${guild!.name} icon`"
@error="(e) => e.target.src = memberImage"
>
<img
Expand Down
3 changes: 2 additions & 1 deletion src/components/Content.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!--suppress TypeScriptUnresolvedReference -->
<template>
<div class="container">

Expand Down Expand Up @@ -65,7 +66,7 @@ export interface Props {
args: {
data: Record<string, object>,
tableOpts?: object,
iconDir?: string
iconDir: string
}
}
defineProps<Props>();
Expand Down
18 changes: 9 additions & 9 deletions src/components/Data.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<v-table
v-if="Object.keys(table.head).length > 0"
v-bind="Object.assign(tableOpts, {data: table, format})"
v-bind="Object.assign(tableOpts, {data: table, format, isHide: (k) => isHide(k, data.Name)})"
>
<!-- eslint-disable vue/max-attributes-per-line -->
<template v-if="$slots['table-head']" #head="p"><slot name="table-head" v-bind="p" /></template>
Expand All @@ -24,7 +24,7 @@
</template>

<script setup lang="ts">
import { computed, ref, Ref, watch } from 'vue';
import { computed, ref, watch } from 'vue';
import router from '@Utils/Vue/router';
import VTable from './DataTable.vue';
Expand All @@ -40,7 +40,7 @@ export interface Props {
data: object
tableOpts?: object
sort?: boolean
iconDir?: string
iconDir: string
}
interface DataTable {
head: Record<string, unknown[]>
Expand All @@ -55,15 +55,15 @@ const props = withDefaults(defineProps<Props>(), {
sort: true,
iconDir: '',
});
const table: Ref<DataTable> = ref({ head: {}, body: {} });
const title: Ref<DataTitle> = ref({ });
const table = ref<DataTable>({ head: {}, body: {} });
const title = ref<DataTitle>({ });
const dataName = computed(() => {
const { value: t } = title;
return (t && 'default' in t) ? (t.default as Record<string, string>).Name : undefined;
});
const format = {
key: (k: string) => key(k, router.currentRoute.name as string),
key: (k: string) => key(k, router.currentRoute.value.name as string),
value: (k: string, v: unknown) => value(k, v, dataName.value),
};
Expand Down Expand Up @@ -103,13 +103,13 @@ function packagingData(obj: Record<string, unknown>, category = 'default') {
buildTable(category, preTable);
}
function buildTitle(category: string, pre:[string, unknown][]) {
// TODO перенести фильтры из Head сюда
const { value } = title;
pre.forEach(([k, v]) => {
if (!value[category]) {
value[category] = {};
}
(value[category] as Record<string, unknown>)[k] = v;
value[category][k] = v;
});
}
function buildTable(category: string, pre: [string, unknown][]) {
Expand All @@ -118,7 +118,7 @@ function buildTable(category: string, pre: [string, unknown][]) {
const keys = pre.map(([k]: [string, unknown]) => k);
pre
.filter(([k]: [string, unknown]) => (keys.includes(`_${k}`)) ? true : !isHide(k, Name))
// .filter(([k]: [string, unknown]) => (keys.includes(`_${k}`)) ? true : !isHide(k, Name))
.sort(([a]: [string, unknown], [b]: [string, unknown]) => props.sort ? headersOrder.indexOf(a) - headersOrder.indexOf(b) : 0)
.forEach(([key, value]) => {
if (Array.isArray(head[category])) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/DataHead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { computed } from 'vue';
import Stats from '@/components/DataHeadStats.vue';
export interface Props {
data: object,
data: {[k: string]: unknown, default: unknown},
format: {value: (k: string, v: unknown) => unknown, key: (k: string) => string}
iconDir: string
}
Expand Down
31 changes: 14 additions & 17 deletions src/components/DataHeadStats.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<!--suppress TypeScriptValidateTypes -->
<template>
<div>
<template v-if="isObject(items) || (Array.isArray(items) && items.every(isObject))">
<div class="wrapper">

<div
v-for="(item, name) of itemsToArray"
v-for="(item, name) of (itemsToArray as {[k: string]: unknown, TID: string, TID_Description: string}[])"
:key="name"
class="item"
>
Expand All @@ -17,11 +18,11 @@
class="title"
>
<a :href="parentId ? `#${parentId}-${name}` : `#${item.Name}`">
{{ formatTitle(name, item.TID) }}
{{ format.key(item.TID) }}
</a>
</div>
<p
v-if="item.TID_Description && (parent.TID_Description ? parent.TID_Description !== item.TID_Description : true) && $te(item.TID_Description)"
v-if="item.TID_Description && (parent?.TID_Description ? parent.TID_Description !== item.TID_Description : true) && $te(item.TID_Description)"
class="description"
>
{{ formatDescr(item.TID_Description) }}
Expand Down Expand Up @@ -75,19 +76,22 @@
<template v-else>
<b>
<DataStatTooltip :k="itemKey">
<DataStatTooltip
v-if="itemKey"
:k="itemKey"
>
{{ format.key(itemKey) }}
</DataStatTooltip>
</b>
<template v-if="$store.state.userSettings.showKeys"> ({{ itemKey }})</template>:
<v-node
v-if="typeof format.value(itemKey, items) === 'function'"
:render="format.value(itemKey, items)"
v-if="typeof format.value(itemKey as string, items) === 'function'"
:render="format.value(itemKey as string, items)"
/>
<span
v-else
:class="statsStyleName(itemKey)"
:class="statsStyleName(itemKey as string)"
class="value stats-style"
>
{{ format.value(itemKey, items) }}
Expand All @@ -112,7 +116,6 @@ const starKeys = formatValueRulesTime
.map(([keys]) => (keys as string[]).filter((k) => !EXCLUDE_KEYS_FROM_TIME.includes(k)))
.flat();
interface GetCharacteristicsOut {
[k: string]: [unknown, boolean],
_statsByStar: [{[k: string]: unknown}, boolean]
Expand Down Expand Up @@ -172,14 +175,13 @@ import DataStatByStar from '@/components/DataStatByStar.vue';
import { useI18n } from 'vue-i18n';
import statsStyleName from '@Handlers/statsStyleName';
import locKeys from '@Regulation/locKeys.mjs';
export interface Props {
items: unknown[] | unknown | { [k:string]: object|unknown[] },
format: { key: (k: string) => string, value: (k: string, v: unknown) => string }
itemKey?: string|null
parentId?: string|null
parent?: object
parent?: {[k: string]: unknown, TID?: string, TID_Description?: string}
iconDir?: string
}
Expand All @@ -200,7 +202,7 @@ const itemsToArray = computed(() => {
if (Array.isArray(props.items)) {
return props.items;
}
if (isObject(props.items) && Object.values(props.items).every((e) => isObject(e) || Array.isArray(e))) {
if (isObject(props.items) && Object.values(props.items as unknown[]).every((e) => isObject(e) || Array.isArray(e))) {
return props.items;
}
return [props.items];
Expand All @@ -210,17 +212,12 @@ function isObject(o: unknown): boolean {
return (typeof o === 'object' && !Array.isArray(o) && o !== null);
}
function formatDescr(descrKey: string): string {
const customDescrKey = descrKey.endsWith('_DESCR') ? descrKey.replace('_DESCR', '_CUSTOM_DESCR') : null;
const customDescrKey = descrKey.endsWith('_DESCR') ? descrKey.replace('_DESCR', '_CUSTOM_DESCR') : undefined;
const descr = t(descrKey, ['X', 'Y', 'Z']).replace(/<[^>]*>/g, '');
const customDescr = (customDescrKey && te(customDescrKey)) ? t(customDescrKey) : null;
return (customDescr) ? `${descr}\n\n${customDescr}` : descr;
}
function formatTitle(keyName: string, TID: string) {
const finalKey = (TID) ? ((keyName in locKeys) ? keyName : TID) : keyName;
return props.format.key(finalKey);
}
function VNode({ render }) {
return render(h);
Expand Down
2 changes: 1 addition & 1 deletion src/components/DataStatByStar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const LABEL_KEYS = Object.keys(LABEL_BY_ORDER);
const TO_SPOILER_KEYS = ['TID_Description'];
export interface Props {
items: { [k:string]: object|unknown[] },
items: { [k:string]: unknown },
format: { key: (k: string) => string, value: (k: string, v: unknown) => string }
}
Expand Down
Loading

0 comments on commit d512745

Please sign in to comment.