update at 2026-02-07 11:14:09
This commit is contained in:
74
frontend/src/components/ExportPanel.vue
Normal file
74
frontend/src/components/ExportPanel.vue
Normal file
@@ -0,0 +1,74 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { downloadSvg, downloadMultipleFiles, generateSvgFilename } from '../utils/download'
|
||||
import { useUiStore } from '../stores/uiStore'
|
||||
|
||||
const uiStore = useUiStore()
|
||||
|
||||
const selectedItems = computed(() => uiStore.selectedExportItems)
|
||||
|
||||
async function handleExport() {
|
||||
if (selectedItems.value.length === 0) {
|
||||
alert('请先选择要导出的预览项')
|
||||
return
|
||||
}
|
||||
|
||||
uiStore.isExporting = true
|
||||
|
||||
try {
|
||||
if (selectedItems.value.length === 1) {
|
||||
// 单个导出
|
||||
const item = selectedItems.value[0]
|
||||
if (!item) return
|
||||
const filename = generateSvgFilename(uiStore.inputText, item.fontInfo.name)
|
||||
downloadSvg(item.svgResult.svg, filename)
|
||||
} else {
|
||||
// 批量导出
|
||||
const files = selectedItems.value.map((item) => ({
|
||||
name: generateSvgFilename(uiStore.inputText, item.fontInfo.name),
|
||||
content: item.svgResult.svg,
|
||||
}))
|
||||
await downloadMultipleFiles(files)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Export failed:', error)
|
||||
alert('导出失败,请重试')
|
||||
} finally {
|
||||
uiStore.isExporting = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-full flex flex-col p-4">
|
||||
<h2 class="text-lg font-semibold text-gray-800 mb-4">导出</h2>
|
||||
|
||||
<div v-overflow-aware class="scrollbar-hover flex-1 overflow-auto mb-4">
|
||||
<div v-if="selectedItems.length === 0" class="text-sm text-gray-500 text-center py-8">
|
||||
未选择任何预览项
|
||||
</div>
|
||||
<div v-else class="space-y-2">
|
||||
<div
|
||||
v-for="(item, index) in selectedItems"
|
||||
:key="index"
|
||||
class="text-sm text-gray-700 p-2 bg-gray-50 rounded"
|
||||
>
|
||||
{{ item.fontInfo.name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="w-full py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors disabled:bg-gray-300 disabled:cursor-not-allowed"
|
||||
:disabled="selectedItems.length === 0 || uiStore.isExporting"
|
||||
@click="handleExport"
|
||||
>
|
||||
<span v-if="uiStore.isExporting">导出中...</span>
|
||||
<span v-else>导出 SVG ({{ selectedItems.length }})</span>
|
||||
</button>
|
||||
|
||||
<p class="mt-3 text-xs text-gray-500 text-center">
|
||||
点击预览项选中,然后点击导出按钮
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
83
frontend/src/components/FavoritesList.vue
Normal file
83
frontend/src/components/FavoritesList.vue
Normal file
@@ -0,0 +1,83 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useFontStore } from '../stores/fontStore'
|
||||
|
||||
const fontStore = useFontStore()
|
||||
|
||||
const favoriteFonts = computed(() => fontStore.favoriteFonts)
|
||||
|
||||
function handlePreviewClick(fontId: string, event: Event) {
|
||||
event.stopPropagation()
|
||||
fontStore.togglePreview(fontId)
|
||||
}
|
||||
|
||||
function handleFavoriteClick(fontId: string, event: Event) {
|
||||
event.stopPropagation()
|
||||
fontStore.toggleFavorite(fontId)
|
||||
}
|
||||
|
||||
function isFavorite(fontId: string): boolean {
|
||||
return fontStore.favoriteFontIds.has(fontId)
|
||||
}
|
||||
|
||||
function isInPreview(fontId: string): boolean {
|
||||
return fontStore.previewFontIds.has(fontId)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-2">
|
||||
<div v-if="favoriteFonts.length === 0" class="text-sm text-gray-500 text-center py-8">
|
||||
暂无收藏字体
|
||||
</div>
|
||||
<div v-else class="flex flex-col gap-3 favorite-indent">
|
||||
<div
|
||||
v-for="font in favoriteFonts"
|
||||
:key="font.id"
|
||||
class="flex items-center gap-2 border-b border-[#c9cdd4] pb-2"
|
||||
>
|
||||
<!-- 字体图标 -->
|
||||
<div class="w-4 h-4 shrink-0">
|
||||
<img src="/assets/icons/icons_idx%20_18.svg" alt="font" class="w-full h-full" />
|
||||
</div>
|
||||
|
||||
<!-- 字体名称 -->
|
||||
<div class="flex-1 text-xs text-[#86909c]">
|
||||
{{ font.name }}
|
||||
</div>
|
||||
|
||||
<!-- 预览复选框 -->
|
||||
<button
|
||||
@click="handlePreviewClick(font.id, $event)"
|
||||
class="w-[18px] h-[18px] shrink-0 border rounded-full flex items-center justify-center p-0 bg-transparent"
|
||||
:class="isInPreview(font.id) ? 'bg-[#9b6bc2] border-[#9b6bc2]' : 'border-[#c9cdd4]'"
|
||||
>
|
||||
<img v-if="isInPreview(font.id)" src="/assets/icons/checkbox.svg" alt="选中" class="w-[11px] h-[9px]" />
|
||||
</button>
|
||||
|
||||
<!-- 收藏按钮 -->
|
||||
<button
|
||||
@click="handleFavoriteClick(font.id, $event)"
|
||||
class="w-[18px] h-[17px] shrink-0 p-0 border-0 bg-transparent"
|
||||
>
|
||||
<img
|
||||
src="/assets/icons/icons_idx%20_19.svg"
|
||||
alt="收藏"
|
||||
class="w-full h-full"
|
||||
:class="isFavorite(font.id) ? 'favorite-active' : ''"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.favorite-indent {
|
||||
padding-left: 2ch;
|
||||
}
|
||||
|
||||
.favorite-active {
|
||||
filter: brightness(0) saturate(100%) invert(16%) sepia(96%) saturate(7491%) hue-rotate(356deg) brightness(99%) contrast(119%);
|
||||
}
|
||||
</style>
|
||||
18
frontend/src/components/FontSelector.vue
Normal file
18
frontend/src/components/FontSelector.vue
Normal file
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { useFontStore } from '../stores/fontStore'
|
||||
import FontTree from './FontTree.vue'
|
||||
|
||||
const fontStore = useFontStore()
|
||||
|
||||
const fontTree = computed(() => fontStore.fontTree)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-2">
|
||||
<div v-if="fontTree.length === 0" class="text-sm text-gray-500 text-center py-8">
|
||||
暂无字体
|
||||
</div>
|
||||
<FontTree v-else :nodes="fontTree" />
|
||||
</div>
|
||||
</template>
|
||||
51
frontend/src/components/FontSizeSlider.vue
Normal file
51
frontend/src/components/FontSizeSlider.vue
Normal file
@@ -0,0 +1,51 @@
|
||||
<script setup lang="ts">
|
||||
import { useUiStore } from '../stores/uiStore'
|
||||
|
||||
const uiStore = useUiStore()
|
||||
|
||||
function handleSizeChange(event: Event) {
|
||||
const target = event.target as HTMLInputElement
|
||||
uiStore.setFontSize(Number(target.value))
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-2">
|
||||
<div class="flex justify-between items-center">
|
||||
<label class="text-sm font-medium text-gray-700">字体大小</label>
|
||||
<span class="text-sm text-gray-600">{{ uiStore.fontSize }}px</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
min="10"
|
||||
max="500"
|
||||
:value="uiStore.fontSize"
|
||||
class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer accent-blue-600"
|
||||
@input="handleSizeChange"
|
||||
>
|
||||
<div class="flex justify-between text-xs text-gray-500">
|
||||
<span>10px</span>
|
||||
<span>500px</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
input[type="range"]::-webkit-slider-thumb {
|
||||
appearance: none;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background: #2563eb;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input[type="range"]::-moz-range-thumb {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background: #2563eb;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
172
frontend/src/components/FontTree.vue
Normal file
172
frontend/src/components/FontTree.vue
Normal file
@@ -0,0 +1,172 @@
|
||||
<script setup lang="ts">
|
||||
import type { FontTreeNode } from '../types/font'
|
||||
import { useFontStore } from '../stores/fontStore'
|
||||
|
||||
const props = defineProps<{
|
||||
nodes: FontTreeNode[]
|
||||
}>()
|
||||
|
||||
const fontStore = useFontStore()
|
||||
|
||||
function toggleExpand(node: FontTreeNode) {
|
||||
const next = !node.expanded
|
||||
node.expanded = next
|
||||
fontStore.setCategoryExpanded(node.name, next)
|
||||
}
|
||||
|
||||
function handlePreviewClick(node: FontTreeNode, event: Event) {
|
||||
event.stopPropagation()
|
||||
if (node.type === 'font' && node.fontInfo) {
|
||||
fontStore.togglePreview(node.fontInfo.id)
|
||||
}
|
||||
}
|
||||
|
||||
function handleFavoriteClick(node: FontTreeNode, event: Event) {
|
||||
event.stopPropagation()
|
||||
if (node.type === 'font' && node.fontInfo) {
|
||||
fontStore.toggleFavorite(node.fontInfo.id)
|
||||
}
|
||||
}
|
||||
|
||||
function isFavorite(node: FontTreeNode): boolean {
|
||||
return node.type === 'font' && node.fontInfo ? fontStore.favoriteFontIds.has(node.fontInfo.id) : false
|
||||
}
|
||||
|
||||
function isInPreview(node: FontTreeNode): boolean {
|
||||
return node.type === 'font' && node.fontInfo ? fontStore.previewFontIds.has(node.fontInfo.id) : false
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-0">
|
||||
<div v-for="node in nodes" :key="node.name">
|
||||
<!-- 分类节点 -->
|
||||
<div v-if="node.type === 'category'" class="relative mb-3">
|
||||
<div class="flex items-center">
|
||||
<!-- 左侧展开图标 -->
|
||||
<div class="tree-icon-wrapper">
|
||||
<button
|
||||
@click="toggleExpand(node)"
|
||||
class="tree-toggle"
|
||||
>
|
||||
<img
|
||||
v-if="node.expanded"
|
||||
src="/assets/icons/zhedie.svg"
|
||||
alt="收起"
|
||||
class="w-[15px] h-[15px]"
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
src="/assets/icons/icons_idx%20_12.svg"
|
||||
alt="展开"
|
||||
class="w-[15px] h-[15px]"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 分类标题 -->
|
||||
<div
|
||||
@click="toggleExpand(node)"
|
||||
class="text-base font-medium text-black cursor-pointer flex-1 ml-2"
|
||||
>
|
||||
{{ node.name }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 竖直连接线 -->
|
||||
<div v-if="node.expanded && node.children" class="tree-vertical-line"></div>
|
||||
|
||||
<!-- 字体列表 -->
|
||||
<div v-if="node.expanded && node.children" class="flex flex-col gap-3 mt-3">
|
||||
<div
|
||||
v-for="(child, index) in node.children"
|
||||
:key="child.name"
|
||||
class="flex items-center gap-2 border-b border-[#c9cdd4] pb-2 relative"
|
||||
>
|
||||
<!-- 水平连接线 -->
|
||||
<div class="tree-horizontal-line"></div>
|
||||
|
||||
<!-- 字体图标 -->
|
||||
<div class="w-4 h-4 shrink-0 ml-[17px]">
|
||||
<img src="/assets/icons/icons_idx%20_18.svg" alt="font" class="w-full h-full" />
|
||||
</div>
|
||||
|
||||
<!-- 字体名称 -->
|
||||
<div class="flex-1 text-xs text-[#86909c]">
|
||||
{{ child.name }}
|
||||
</div>
|
||||
|
||||
<!-- 预览复选框 -->
|
||||
<button
|
||||
@click="handlePreviewClick(child, $event)"
|
||||
class="w-[18px] h-[18px] shrink-0 border rounded-full flex items-center justify-center p-0 bg-transparent"
|
||||
:class="isInPreview(child) ? 'bg-[#9b6bc2] border-[#9b6bc2]' : 'border-[#c9cdd4]'"
|
||||
>
|
||||
<img v-if="isInPreview(child)" src="/assets/icons/checkbox.svg" alt="选中" class="w-[11px] h-[9px]" />
|
||||
</button>
|
||||
|
||||
<!-- 收藏按钮 -->
|
||||
<button
|
||||
@click="handleFavoriteClick(child, $event)"
|
||||
class="w-[18px] h-[17px] shrink-0 p-0 border-0 bg-transparent"
|
||||
>
|
||||
<img
|
||||
src="/assets/icons/icons_idx%20_19.svg"
|
||||
alt="收藏"
|
||||
class="w-full h-full"
|
||||
:class="isFavorite(child) ? 'favorite-active' : ''"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tree-icon-wrapper {
|
||||
position: relative;
|
||||
width: 17px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tree-toggle {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.tree-vertical-line {
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
top: 20px;
|
||||
bottom: 12px;
|
||||
width: 1px;
|
||||
background: #c9cdd4;
|
||||
}
|
||||
|
||||
.tree-horizontal-line {
|
||||
position: absolute;
|
||||
left: 8px;
|
||||
top: 12px;
|
||||
width: 10px;
|
||||
height: 1px;
|
||||
background: #c9cdd4;
|
||||
}
|
||||
|
||||
.favorite-active {
|
||||
filter: brightness(0) saturate(100%) invert(16%) sepia(96%) saturate(7491%) hue-rotate(356deg) brightness(99%) contrast(119%);
|
||||
}
|
||||
</style>
|
||||
41
frontend/src/components/HelloWorld.vue
Normal file
41
frontend/src/components/HelloWorld.vue
Normal file
@@ -0,0 +1,41 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
defineProps<{ msg: string }>()
|
||||
|
||||
const count = ref(0)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>{{ msg }}</h1>
|
||||
|
||||
<div class="card">
|
||||
<button type="button" @click="count++">count is {{ count }}</button>
|
||||
<p>
|
||||
Edit
|
||||
<code>components/HelloWorld.vue</code> to test HMR
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Check out
|
||||
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
|
||||
>create-vue</a
|
||||
>, the official Vue + Vite starter
|
||||
</p>
|
||||
<p>
|
||||
Learn more about IDE Support for Vue in the
|
||||
<a
|
||||
href="https://vuejs.org/guide/scaling-up/tooling.html#ide-support"
|
||||
target="_blank"
|
||||
>Vue Docs Scaling up Guide</a
|
||||
>.
|
||||
</p>
|
||||
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
</style>
|
||||
45
frontend/src/components/PreviewItem.vue
Normal file
45
frontend/src/components/PreviewItem.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<script setup lang="ts">
|
||||
import type { PreviewItem } from '../types/font'
|
||||
|
||||
const props = defineProps<{
|
||||
previewItem: PreviewItem
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
toggleSelect: []
|
||||
}>()
|
||||
|
||||
function handleClick() {
|
||||
emit('toggleSelect')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer"
|
||||
:class="previewItem.selected ? 'border-blue-500 bg-blue-50' : 'border-gray-200 bg-white'"
|
||||
@click="handleClick"
|
||||
>
|
||||
<!-- 字体名称 -->
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<h3 class="font-medium text-gray-800">{{ previewItem.fontInfo.name }}</h3>
|
||||
<div
|
||||
class="w-5 h-5 border-2 rounded flex items-center justify-center"
|
||||
:class="previewItem.selected ? 'border-blue-500 bg-blue-500' : 'border-gray-300'"
|
||||
>
|
||||
<span v-if="previewItem.selected" class="text-white text-xs">✓</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SVG 预览 -->
|
||||
<div class="bg-gray-50 rounded p-4 flex items-center justify-center min-h-32">
|
||||
<div v-html="previewItem.svgResult.svg" class="max-w-full" />
|
||||
</div>
|
||||
|
||||
<!-- 信息 -->
|
||||
<div class="mt-3 text-xs text-gray-500 flex justify-between">
|
||||
<span>{{ previewItem.svgResult.width.toFixed(0) }} × {{ previewItem.svgResult.height.toFixed(0) }}</span>
|
||||
<span>{{ previewItem.svgResult.fontName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
140
frontend/src/components/SvgPreview.vue
Normal file
140
frontend/src/components/SvgPreview.vue
Normal file
@@ -0,0 +1,140 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { useFontStore } from '../stores/fontStore'
|
||||
import { useUiStore } from '../stores/uiStore'
|
||||
import { generateSvg } from '../utils/svg-builder'
|
||||
import type { PreviewItem as PreviewItemType } from '../types/font'
|
||||
|
||||
const fontStore = useFontStore()
|
||||
const uiStore = useUiStore()
|
||||
|
||||
const previewItems = ref<PreviewItemType[]>([])
|
||||
const isGenerating = ref(false)
|
||||
|
||||
const previewFonts = computed(() => fontStore.previewFonts)
|
||||
const inputText = computed(() => uiStore.inputText)
|
||||
const fontSize = computed(() => uiStore.fontSize)
|
||||
const fillColor = computed(() => uiStore.textColor)
|
||||
|
||||
watch(
|
||||
[previewFonts, inputText, fontSize, fillColor],
|
||||
async () => {
|
||||
await generatePreviews()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
async function generatePreviews() {
|
||||
const validPreviewFontIds = new Set(previewFonts.value.map(font => font.id))
|
||||
uiStore.retainExportItemsByFontIds(validPreviewFontIds)
|
||||
|
||||
if (!inputText.value || inputText.value.trim() === '') {
|
||||
previewItems.value = []
|
||||
return
|
||||
}
|
||||
|
||||
const fonts = previewFonts.value
|
||||
if (fonts.length === 0) {
|
||||
previewItems.value = []
|
||||
return
|
||||
}
|
||||
|
||||
isGenerating.value = true
|
||||
|
||||
try {
|
||||
const items: PreviewItemType[] = []
|
||||
|
||||
for (const fontInfo of fonts) {
|
||||
if (!fontInfo.loaded) {
|
||||
await fontStore.loadFont(fontInfo)
|
||||
}
|
||||
|
||||
if (fontInfo.font) {
|
||||
try {
|
||||
const svgResult = await generateSvg({
|
||||
text: inputText.value,
|
||||
font: fontInfo.font,
|
||||
fontSize: fontSize.value,
|
||||
fillColor: fillColor.value,
|
||||
})
|
||||
|
||||
items.push({
|
||||
fontInfo,
|
||||
svgResult,
|
||||
selected: uiStore.selectedExportItems.some(item => item.fontInfo.id === fontInfo.id)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(`Failed to generate SVG for ${fontInfo.name}:`, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
previewItems.value = items
|
||||
} catch (error) {
|
||||
console.error('Failed to generate previews:', error)
|
||||
} finally {
|
||||
isGenerating.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSelectItem(item: PreviewItemType) {
|
||||
item.selected = !item.selected
|
||||
uiStore.toggleExportItem(item)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-2">
|
||||
<div v-if="previewItems.length === 0" class="text-[#86909c] text-center py-20">
|
||||
{{ isGenerating ? '生成预览中...' : '请选择字体并输入内容' }}
|
||||
</div>
|
||||
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="item in previewItems"
|
||||
:key="item.fontInfo.id"
|
||||
class="flex flex-col gap-2"
|
||||
>
|
||||
<div class="flex items-center gap-[8px] border-b border-[#c9cdd4] pb-[8px] pr-[8px]">
|
||||
<div class="w-[24px] h-[24px] shrink-0">
|
||||
<img src="/assets/icons/icons_idx%20_32.svg" alt="字体" class="w-full h-full" />
|
||||
</div>
|
||||
|
||||
<div class="flex-1 text-xs text-[#86909c]">
|
||||
{{ item.fontInfo.name }}
|
||||
</div>
|
||||
|
||||
<button
|
||||
@click="toggleSelectItem(item)"
|
||||
class="w-[18px] h-[18px] shrink-0 border rounded-full flex items-center justify-center p-0 bg-transparent"
|
||||
:class="item.selected ? 'bg-[#9b6bc2] border-[#9b6bc2]' : 'border-[#c9cdd4]'"
|
||||
>
|
||||
<img v-if="item.selected" src="/assets/icons/checkbox.svg" alt="选中" class="w-[11px] h-[9px]" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@click="toggleSelectItem(item)"
|
||||
class="bg-white px-[8px] py-[8px] cursor-pointer"
|
||||
>
|
||||
<div v-html="item.svgResult.svg" class="svg-preview-container"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.svg-preview-container {
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.svg-preview-container :deep(svg) {
|
||||
display: block;
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
max-height: none;
|
||||
}
|
||||
</style>
|
||||
38
frontend/src/components/TextInput.vue
Normal file
38
frontend/src/components/TextInput.vue
Normal file
@@ -0,0 +1,38 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useUiStore } from '../stores/uiStore'
|
||||
|
||||
const uiStore = useUiStore()
|
||||
const localText = ref(uiStore.inputText)
|
||||
|
||||
function handlePreview() {
|
||||
uiStore.setInputText(localText.value)
|
||||
}
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
if (event.key === 'Enter') {
|
||||
handlePreview()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-2">
|
||||
<label class="block text-sm font-medium text-gray-700">输入文本</label>
|
||||
<div class="flex gap-2">
|
||||
<input
|
||||
v-model="localText"
|
||||
type="text"
|
||||
placeholder="此处输入内容"
|
||||
class="flex-1 px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
@keydown="handleKeydown"
|
||||
>
|
||||
<button
|
||||
class="px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"
|
||||
@click="handlePreview"
|
||||
>
|
||||
预览
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user