Skip to content

Commit

Permalink
feat: cfg for two cols
Browse files Browse the repository at this point in the history
  • Loading branch information
Zephyruso committed Nov 25, 2024
1 parent f611400 commit 23ffa48
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 12 deletions.
9 changes: 7 additions & 2 deletions src/components/ProxyGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
/>
<div class="collapse-content flex flex-col gap-2">
<div
class="grid grid-cols-1 gap-2 md:grid-cols-2"
:class="
twMerge(
'grid grid-cols-1 gap-2 sm:grid-cols-2',
!twoColumns && 'lg:grid-cols-3 2xl:grid-cols-4 3xl:grid-cols-5',
)
"
v-if="showContent"
>
<ProxyNodeCard
Expand All @@ -57,7 +62,7 @@
<script setup lang="ts">
import LatencyTag from '@/components/LatencyTag.vue'
import ProxyNodeCard from '@/components/ProxyNodeCard.vue'
import { collapseGroupMap } from '@/store/config'
import { collapseGroupMap, twoColumns } from '@/store/config'
import { activeConnections } from '@/store/connections'
import { getLatencyByName, proxyGroupLatencyTest, proxyMap, selectProxy } from '@/store/proxies'
import prettyBytes from 'pretty-bytes'
Expand Down
22 changes: 15 additions & 7 deletions src/components/sidebar/ProxiesCtrl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
class="flex flex-col gap-2 p-2"
v-if="configs"
>
<button
class="btn btn-sm w-full"
@click="flushFakeIPAPI"
>
{{ $t('flushFakeIP') }}
</button>
<div class="flex items-center gap-2">
{{ $t('twoColumns') }}:
<input
class="toggle"
type="checkbox"
v-model="twoColumns"
/>
</div>
<select
class="select select-bordered select-sm w-full"
:value="configs.mode"
Expand All @@ -26,12 +28,18 @@
class="input input-sm input-bordered w-full"
v-model="speedtestUrl"
/>
<button
class="btn btn-sm w-full"
@click="flushFakeIPAPI"
>
{{ $t('flushFakeIP') }}
</button>
</div>
</template>

<script setup lang="ts">
import { flushFakeIPAPI } from '@/api'
import { configs, speedtestUrl, updateConfigs } from '@/store/config'
import { configs, speedtestUrl, twoColumns, updateConfigs } from '@/store/config'
import { computed } from 'vue'
const modeList = computed(() => {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ export default {
activeConnections: 'Active Connections',
closedConnections: 'Closed Connections',
logLevel: 'Log Level',
twoColumns: 'Two Columns',
}
1 change: 1 addition & 0 deletions src/i18n/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ export default {
activeConnections: '活跃连接',
closedConnections: '已关闭连接',
logLevel: '日志等级',
twoColumns: '双列显示',
}
1 change: 1 addition & 0 deletions src/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const speedtestTimeout = useStorage<number>('config/speedtest-timeout', 5
export const compactConnectionCard = useStorage<boolean>('config/compact-connection-card', true)
export const hostLabelMap = useStorage<Record<string, string>>('config/host-label-map', {})
export const collapseGroupMap = useStorage<Record<string, boolean>>('config/collapse-group-map', {})
export const twoColumns = useStorage('config/twoColumns', true)

export const configs = ref<Config>()
export const fetchConfigs = async () => {
Expand Down
7 changes: 4 additions & 3 deletions src/views/ProxiesPage.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="h-full overflow-y-auto overflow-x-hidden p-2">
<template v-if="isLargeScreen">
<div class="flex flex-1 gap-1">
<template v-if="isLargeScreen && twoColumns">
<div class="grid grid-cols-2 gap-1">
<div
v-for="idx in [0, 1]"
:key="idx"
Expand All @@ -16,7 +16,7 @@
</div>
</template>
<div
class="flex flex-1 flex-col gap-1"
class="grid grid-cols-1 gap-1"
v-else
>
<ProxyGroup
Expand All @@ -31,6 +31,7 @@
<script setup lang="ts">
import ProxyGroup from '@/components/ProxyGroup.vue'
import { isLargeScreen } from '@/helper'
import { twoColumns } from '@/store/config'
import { proxyGroups } from '@/store/proxies'
const filterContent: <T>(all: T[], target: number) => T[] = (all, target) => {
Expand Down

0 comments on commit 23ffa48

Please sign in to comment.