Skip to content

Commit 445111e

Browse files
committed
refactoring
1 parent 946ad65 commit 445111e

33 files changed

Lines changed: 700 additions & 753 deletions

.devcontainer/Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,3 @@ RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhisto
1818

1919
# [Optional] Uncomment this line to install global node packages.
2020
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm update -g" 2>&1
21-
22-
# https://heyapi.dev/openapi-ts/configuration#input
23-
RUN 'export NODE_TLS_REJECT_UNAUTHORIZED=0'

src/WebUI/app/components/app/Login.vue

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
<script setup lang="ts">
22
import type { ButtonProps, DropdownMenuItem } from '@nuxt/ui'
33
4+
import { useStorage } from '@vueuse/core'
5+
6+
import type { Platform } from '~/models/platform'
7+
48
import { useAsyncCallback } from '~/composables/utils/use-async-callback'
5-
import { PLATFORM } from '~/models/platform'
9+
import { AVAILABLE_PLATFORM, PLATFORM } from '~/models/platform'
610
import { login } from '~/services/auth-service'
711
import { platformToIcon } from '~/services/platform-service'
812
import { useUserStore } from '~/stores/user'
913
1014
const { size = 'xl' } = defineProps<{ size?: ButtonProps['size'] }>()
1115
const userStore = useUserStore()
1216
const { user } = toRefs(userStore)
13-
const { platform, changePlatform } = usePlatform()
17+
18+
const platform = useStorage<Platform>('user-platform', PLATFORM.Steam) // Steam by default
19+
1420
const { t } = useI18n()
1521
1622
const {
1723
execute: loginUser,
1824
isLoading: logging,
1925
} = useAsyncCallback(() => login(platform.value))
2026
21-
const items = computed(() =>
22-
Object.values(PLATFORM).map(p => ({
23-
label: t(`platform.${p}`),
24-
icon: `crpg:${platformToIcon[p]}`,
25-
type: 'checkbox' as const,
26-
checked: p === platform.value,
27-
onUpdateChecked() {
28-
changePlatform(p)
29-
},
30-
})) satisfies DropdownMenuItem[],
31-
)
27+
const items = AVAILABLE_PLATFORM.map(p => ({
28+
label: t(`platform.${p}`),
29+
icon: `crpg:${platformToIcon[p]}`,
30+
type: 'checkbox' as const,
31+
checked: p === platform.value,
32+
onUpdateChecked() {
33+
platform.value = p
34+
},
35+
})) satisfies DropdownMenuItem[]
3236
</script>
3337

3438
<template>

src/WebUI/app/components/character/action/respec/CharacterActionRespecConfirmDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defineEmits<{
1818
:confirm="character.name"
1919
@close="(res) => $emit('close', res)"
2020
>
21-
<template #title>
21+
<template #description>
2222
<i18n-t
2323
scope="global"
2424
keypath="character.settings.respecialize.dialog.desc"

src/WebUI/app/components/character/action/retire/CharacterActionRetireConfirmDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const experienceMultiplierBonus = computed(() => getExperienceMultiplierBonus(us
2626
:confirm-label="$t('action.confirm')"
2727
@close="(res) => $emit('close', res)"
2828
>
29-
<template #title>
29+
<template #description>
3030
<div class="space-y-2">
3131
<i18n-t
3232
scope="global"

src/WebUI/app/components/character/inventory/item/CharacterInventoryItemUpgradesModal.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ async function reforge() {
184184

185185
<template #body>
186186
<ItemTableUpgrades
187-
with-header
188-
:with-filler="false"
189187
:current-rank="userItem.item.rank"
190188
:loading="isLoadingitemUpgrades"
191189
:items="itemUpgrades"

src/WebUI/app/components/item/ItemParam.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ const formattedBuckets = computed(() => {
6363
return [humanizeBucket(field, rawBuckets, item)]
6464
})
6565
66-
// TODO: to tailwind cfg
6766
const colorPositive = '#34d399'
6867
const colorNegative = '#ef4444'
6968

src/WebUI/app/components/item/grid/ItemGrid.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import type { SortingConfig } from '~/services/item-search-service'
1010
import { useMainHeader } from '~/composables/app/use-main-header'
1111
import { useStickySidebar } from '~/composables/use-sticky-sidebar'
1212
import { ITEM_TYPE } from '~/models/item'
13-
import { getFacetsByItemType } from '~/services/item-search-service'
14-
import { aggregationsConfig, getFilterFn } from '~/services/item-search-service/aggregations'
13+
import { getFacetsByItemType, getFilterFn } from '~/services/item-search-service'
14+
import { aggregationsConfig } from '~/services/item-search-service/aggregations'
1515
1616
const { sortingConfig, items, withPagination = true, loading = false } = defineProps<{
1717
items: T[]

src/WebUI/app/components/item/table/ItemTableUpgrades.vue

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,49 @@
11
<script setup lang="ts">
22
import type { TableColumn } from '@nuxt/ui'
3-
import type { RowSelectionState, VisibilityState } from '@tanstack/vue-table'
3+
import type { RowSelectionState } from '@tanstack/vue-table'
44
5-
import { ItemParam, ItemTableMedia } from '#components'
5+
import { AppCoin, ItemParam, ItemTableMedia } from '#components'
66
77
import type { CompareItemsResult, ItemFlat } from '~/models/item'
8-
import type { AggregationConfig, AggregationOptions } from '~/services/item-search-service/aggregations'
8+
import type { AggregationConfig } from '~/services/item-search-service/aggregations'
99
1010
import { ITEM_COMPARE_MODE } from '~/models/item'
11+
import { getColumnVisibility } from '~/services/item-search-service'
1112
1213
const {
1314
items,
1415
aggregationConfig,
15-
withHeader = false,
1616
compareItemsResult,
1717
loading = false,
1818
currentRank,
19-
withFiller = true,
2019
} = defineProps<{
2120
items: ItemFlat[]
2221
aggregationConfig: AggregationConfig
2322
compareItemsResult: CompareItemsResult
2423
loading?: boolean
25-
withHeader?: boolean
26-
withFiller?: boolean // offset
2724
currentRank?: number
2825
}>()
2926
30-
const { t } = useI18n()
27+
const { t, n } = useI18n()
3128
32-
function createTableColumn(key: keyof ItemFlat, options: AggregationOptions): TableColumn<ItemFlat> {
33-
const widthPx = options.width || 160
29+
function createTableColumn(key: keyof ItemFlat): TableColumn<ItemFlat> {
3430
return {
3531
accessorKey: key,
36-
meta: {
37-
style: {
38-
th: {
39-
width: `${widthPx}px`,
40-
},
41-
td: {
42-
width: `${widthPx}px`,
43-
},
44-
},
45-
},
4632
header: ({ header }) => t(`item.aggregations.${header.id}.title`),
4733
cell: ({ row }) => h(ItemParam, {
4834
field: key,
4935
item: row.original,
5036
isCompare: true,
5137
compareMode: ITEM_COMPARE_MODE.Relative,
5238
relativeValue: compareItemsResult[key]!,
39+
}, {
40+
...(key === 'upkeep' && { default: ({ rawBuckets }: { rawBuckets: number }) => h(AppCoin, { value: t('item.format.upkeep', { upkeep: n(rawBuckets) }) }) }),
41+
...(key === 'price' && { default: ({ rawBuckets }: { rawBuckets: number }) => h(AppCoin, { value: rawBuckets }) }),
5342
}),
5443
}
5544
}
5645
5746
const columns = computed<TableColumn<ItemFlat>[]>(() => [
58-
...(withFiller
59-
? [
60-
{
61-
id: 'fill',
62-
meta: {
63-
class: {
64-
td: 'px-0 w-[32px]',
65-
th: 'px-0 w-[32px]',
66-
},
67-
},
68-
},
69-
{
70-
id: 'fill2',
71-
meta: {
72-
class: {
73-
td: 'px-0 w-[32px]',
74-
th: 'px-0 w-[32px]',
75-
},
76-
},
77-
},
78-
]
79-
: []),
8047
{
8148
accessorKey: 'name',
8249
header: '',
@@ -85,19 +52,10 @@ const columns = computed<TableColumn<ItemFlat>[]>(() => [
8552
showTier: true,
8653
}),
8754
},
88-
...Object.entries(aggregationConfig).map(([key, config]) => createTableColumn(key as keyof ItemFlat, config)),
55+
...objectKeys(aggregationConfig).map(createTableColumn),
8956
])
9057
91-
const columnVisibility = computed<VisibilityState>(() => {
92-
return {
93-
...Object.entries(aggregationConfig)
94-
.filter(([_, value]) => value.hidden)
95-
.reduce((out, [key]) => {
96-
out[key] = false
97-
return out
98-
}, {} as VisibilityState),
99-
}
100-
})
58+
const columnVisibility = computed(() => getColumnVisibility(aggregationConfig))
10159
10260
const rowSelection = ref<RowSelectionState>({
10361
...(currentRank !== undefined && {
@@ -115,9 +73,6 @@ const rowSelection = ref<RowSelectionState>({
11573
:columns
11674
:ui="{
11775
root: 'overflow-visible',
118-
...(!withHeader && {
119-
thead: 'hidden',
120-
}),
12176
}"
12277
>
12378
<template #empty>

src/WebUI/app/components/moderator/RestrictionsTable.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { SortingState, VisibilityState } from '@tanstack/vue-table'
44
55
import { getPaginationRowModel } from '@tanstack/vue-table'
66
import { navigateTo } from '#app'
7-
import { NuxtLink, UBadge, UiCollapsibleText, UInput, UiTableColumnHeader, UiTableColumnHeaderLabel, USelect, UserMedia, UTooltip } from '#components'
7+
import { NuxtLink, UBadge, UiCollapsibleText, UiGridColumnHeader, UiGridColumnHeaderLabel, UInput, USelect, UserMedia, UTooltip } from '#components'
88
99
import type { UserRestriction } from '~/models/user'
1010
@@ -37,7 +37,7 @@ const columns: TableColumn<UserRestriction>[] = [
3737
{
3838
accessorKey: 'status',
3939
header: ({ column }) => {
40-
return h(UiTableColumnHeader, {
40+
return h(UiGridColumnHeader, {
4141
label: t('restriction.table.column.status'),
4242
withFilter: true,
4343
filtered: column.getIsFiltered(),
@@ -61,7 +61,7 @@ const columns: TableColumn<UserRestriction>[] = [
6161
'modelValue': column.getFilterValue(),
6262
'onUpdate:modelValue': column.setFilterValue,
6363
}, {
64-
default: () => h(UiTableColumnHeaderLabel, {
64+
default: () => h(UiGridColumnHeaderLabel, {
6565
label: t('restriction.table.column.status'),
6666
withFilter: true,
6767
}),
@@ -78,7 +78,7 @@ const columns: TableColumn<UserRestriction>[] = [
7878
{
7979
accessorKey: 'type',
8080
header: ({ column }) => {
81-
return h(UiTableColumnHeader, {
81+
return h(UiGridColumnHeader, {
8282
label: t('restriction.table.column.type'),
8383
withFilter: true,
8484
filtered: column.getIsFiltered(),
@@ -102,7 +102,7 @@ const columns: TableColumn<UserRestriction>[] = [
102102
'modelValue': column.getFilterValue(),
103103
'onUpdate:modelValue': column.setFilterValue,
104104
}, {
105-
default: () => h(UiTableColumnHeaderLabel, {
105+
default: () => h(UiGridColumnHeaderLabel, {
106106
label: t('restriction.table.column.type'),
107107
withFilter: true,
108108
}),

src/WebUI/app/components/moderator/UserFinder.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ValueOf } from 'type-fest'
44
55
import type { Platform } from '~/models/platform'
66
7-
import { PLATFORM } from '~/models/platform'
7+
import { AVAILABLE_PLATFORM, PLATFORM } from '~/models/platform'
88
import { platformToIcon } from '~/services/platform-service'
99
import { getUserById, searchUser } from '~/services/restriction-service'
1010
@@ -61,7 +61,7 @@ const searchModeItems = Object.keys(SEARCH_MODE).map<TabsItem>(mode => ({
6161
slot: `${mode}` as const,
6262
}))
6363
64-
const platformItems = computed(() => Object.values(PLATFORM).map<SelectItem>(p => ({
64+
const platformItems = computed(() => AVAILABLE_PLATFORM.map<SelectItem>(p => ({
6565
value: p,
6666
label: t(`platform.${p}`),
6767
icon: `crpg:${platformToIcon[p]}`,

0 commit comments

Comments
 (0)