Skip to content

Commit 0a412dc

Browse files
authored
feat: 使用瀑布流布局展示模型列表 (#502)
1 parent d15376e commit 0a412dc

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"tauri-plugin-macos-permissions-api": "^2.3.0",
4747
"vue": "^3.5.16",
4848
"vue-markdown-render": "^2.2.1",
49-
"vue-router": "^4.5.1"
49+
"vue-router": "^4.5.1",
50+
"vue3-masonry-css": "^1.0.7"
5051
},
5152
"devDependencies": {
5253
"@antfu/eslint-config": "^4.13.3",

pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/pages/preference/components/model/components/upload/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ watch(selectPaths, async (paths) => {
8686
<template>
8787
<div
8888
ref="drop"
89-
class="size-full flex flex-col cursor-pointer items-center justify-center gap-4 b b-color-1 rounded-lg b-dashed bg-color-8 transition hover:border-primary"
89+
class="h-40 w-full flex flex-col cursor-pointer items-center justify-center gap-4 b b-color-1 rounded-lg b-dashed bg-color-8 transition hover:border-primary"
9090
:class="{ 'border-primary': dragenter }"
9191
@click="handleUpload"
9292
>

src/pages/preference/components/model/index.vue

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script setup lang="ts">
22
import type { Model } from '@/stores/model'
3-
import type { ColProps } from 'ant-design-vue'
43
54
import { convertFileSrc } from '@tauri-apps/api/core'
65
import { remove } from '@tauri-apps/plugin-fs'
76
import { revealItemInDir } from '@tauri-apps/plugin-opener'
8-
import { Card, Col, message, Popconfirm, Row } from 'ant-design-vue'
7+
import { Card, message } from 'ant-design-vue'
8+
import { MasonryGrid, MasonryGridItem } from 'vue3-masonry-css'
99
1010
import FloatMenu from './components/float-menu/index.vue'
1111
import Upload from './components/upload/index.vue'
@@ -15,13 +15,6 @@ import { join } from '@/utils/path'
1515
1616
const modelStore = useModelStore()
1717
18-
const colProps: ColProps = {
19-
xs: 12,
20-
md: 8,
21-
lg: 6,
22-
xl: 4,
23-
}
24-
2518
async function handleDelete(item: Model) {
2619
const { id, path } = item
2720
@@ -42,15 +35,17 @@ async function handleDelete(item: Model) {
4235
</script>
4336

4437
<template>
45-
<Row :gutter="[16, 16]">
46-
<Col v-bind="colProps">
38+
<MasonryGrid
39+
:columns="{ 992: 3, 1200: 4, 1600: 6, default: 8 }"
40+
:gutter="16"
41+
>
42+
<MasonryGridItem>
4743
<Upload />
48-
</Col>
44+
</MasonryGridItem>
4945

50-
<Col
46+
<MasonryGridItem
5147
v-for="item in modelStore.models"
5248
:key="item.id"
53-
v-bind="colProps"
5449
>
5550
<Card
5651
hoverable
@@ -90,8 +85,8 @@ async function handleDelete(item: Model) {
9085
</template>
9186
</template>
9287
</Card>
93-
</Col>
94-
</Row>
88+
</MasonryGridItem>
89+
</MasonryGrid>
9590

9691
<FloatMenu />
9792
</template>

src/pages/preference/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const menus = [
6161
<div class="b b-color-2 rounded-2xl b-solid">
6262
<img
6363
class="size-15"
64+
data-tauri-drag-region
6465
src="/logo.png"
6566
>
6667
</div>

0 commit comments

Comments
 (0)