Skip to content

Commit

Permalink
[coc-card] 增加空白卡 pdf,修复 table 样式
Browse files Browse the repository at this point in the history
  • Loading branch information
masquevil committed Dec 20, 2023
1 parent e81fd2f commit e79426b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
Binary file added src/assets/coc-card-empty.pdf
Binary file not shown.
17 changes: 14 additions & 3 deletions src/components/coc-card/SkillTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,14 @@ function getTotal(points: SkillPoint, init: number) {
'td-color-1': (index + 1) % 2,
}"
>
<span
<div
v-if="!row.init && row.initPlaceholder"
class="init-placeholder"
>
{{ row.initPlaceholder }}
</span>
<span class="init-placeholder-content">
{{ row.initPlaceholder }}
</span>
</div>
<span v-else-if="row.groupName !== '其它'">
{{ row.init }}
</span>
Expand Down Expand Up @@ -427,5 +429,14 @@ function getTotal(points: SkillPoint, init: number) {
.init-placeholder {
color: var(--color-placeholder);
display: inline-flex;
width: 0;
justify-content: center;
}
.init-placeholder-content {
display: block;
transform: scale(0.88);
transform-origin: center center;
white-space: nowrap;
}
</style>
6 changes: 6 additions & 0 deletions src/utils/file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function downloadFile(url: string, title: string) {
const a = document.createElement('a');
a.href = url;
a.download = title;
a.click();
}
7 changes: 3 additions & 4 deletions src/utils/image.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { downloadFile } from './file';

export function getImageSize(url: string) {
return new Promise<{ width: number; height: number }>((resolve) => {
const img = document.createElement('img');
Expand All @@ -13,8 +15,5 @@ export function getImageSize(url: string) {
}

export function downloadImage(url: string, title: string = 'image') {
const a = document.createElement('a');
a.href = url;
a.download = title;
a.click();
downloadFile(url, title);
}
14 changes: 8 additions & 6 deletions src/views/COCCardSections/ControlSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
KnifeFork,
IceCream,
Guide,
Brush,
} from '@element-plus/icons-vue';
// components
Expand All @@ -35,10 +36,12 @@ import {
import { usePC, useViewData, usePageData } from '@/hooks/useCOCCardProviders';
import usePrintPaper from '@/hooks/usePrintPaper';
import { downloadFile } from '@/utils/file';
import type { COCCardViewData } from '@/types/coc-card/viewData';
import qrWechat from '@/assets/qr-wechat.jpg';
import qrAlipay from '@/assets/qr-alipay.jpg';
import cardPdf from '@/assets/coc-card-empty.pdf';
interface Props {
paperEls: {
Expand Down Expand Up @@ -221,37 +224,36 @@ const cleanPreloadFn = watch(morePanelVisible, (visible) => {
<ControlButton
label="快速年龄修正"
:icon="Scissor"
iconSize="1.4em"
@click="actAgeGrow"
/>
<ControlButton
label="重置人物卡"
:icon="Refresh"
iconSize="1.4em"
@click="$emit('reset-card')"
/>
<ControlButton
label="导入/导出数据"
:icon="DocumentCopy"
iconSize="1.4em"
@click="inOutModalVisible = true"
/>
<ControlButton
:label="`${cheating ? '关闭' : '开启'}灌铅模式`"
:icon="KnifeFork"
iconSize="1.4em"
@click="$emit('switch-cheating')"
/>
<ControlButton
label="查看使用指南"
:icon="Guide"
iconSize="1.4em"
@click="morePanelActiveTab = 'guide'"
/>
<ControlButton
label="下载空白卡"
:icon="Brush"
@click="downloadFile(cardPdf, '【TRPG 赛高】空白卡.pdf')"
/>
<ControlButton
label="投喂作者"
:icon="IceCream"
iconSize="1.4em"
@click="rewardModalVisible = true"
/>
</div>
Expand Down

0 comments on commit e79426b

Please sign in to comment.