Skip to content

Commit

Permalink
改用html2canvas截图,修复截图相关的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoZuohong committed Nov 18, 2023
1 parent c7ef1f5 commit 48512b3
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 119 deletions.
7 changes: 4 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,15 @@ def save_file_dialog():
if not img:
return "图片未上传"
window = webview.active_window()
folder_path = window.create_file_dialog(
img_path = window.create_file_dialog(
dialog_type=webview.SAVE_DIALOG,
save_filename="plan.png",
file_types=("PNG图片 (*.png)",),
)
if not folder_path:
if not img_path:
return "保存已取消"
img_path = folder_path[0]
if not isinstance(img_path, str):
img_path = img_path[0]
if os.path.exists(img_path):
root = tkinter.Tk()
root.withdraw()
Expand Down
1 change: 1 addition & 0 deletions ui/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ declare module '@vue/runtime-core' {
NLayoutContent: typeof import('naive-ui')['NLayoutContent']
NLayoutFooter: typeof import('naive-ui')['NLayoutFooter']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NLoadingBarProvider: typeof import('naive-ui')['NLoadingBarProvider']
NLog: typeof import('naive-ui')['NLog']
NMenu: typeof import('naive-ui')['NMenu']
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
Expand Down
90 changes: 81 additions & 9 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"echarts": "^5.4.3",
"file-saver": "^2.0.5",
"highlight.js": "^11.8.0",
"html-to-image": "^1.11.11",
"html2canvas": "^1.4.1",
"katex": "^0.16.8",
"luxon": "^3.4.0",
"moment": "^2.29.4",
Expand Down
172 changes: 87 additions & 85 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,91 +9,93 @@
<n-global-style />
<n-dialog-provider>
<n-message-provider>
<n-layout :has-sider="!mobile" class="outer-layout">
<n-layout-sider
v-if="!mobile"
bordered
collapse-mode="width"
:collapsed-width="50"
:width="210"
show-trigger
>
<n-menu
:indent="24"
:collapsed-width="64"
:collapsed-icon-size="22"
:options="menuOptions"
/>
</n-layout-sider>
<n-layout-content class="layout-content-container">
<router-view v-if="loaded" />
</n-layout-content>
<n-layout-footer v-if="mobile">
<n-tabs type="line" justify-content="space-evenly" size="small">
<n-tab name="主页" @click="$router.push('/')">
<div style="display: flex; flex-direction: column; align-items: center">
<n-icon size="20" style="margin-bottom: -1px" :component="BookOutline" />
日志
</div>
</n-tab>
<n-tab name="设置" @click="$router.push('/settings')">
<div style="display: flex; flex-direction: column; align-items: center">
<n-icon size="20" style="margin-bottom: -1px" :component="Settings" />
设置
</div>
</n-tab>
<n-tab name="排班" @click="$router.push('/plan-editor')">
<div style="display: flex; flex-direction: column; align-items: center">
<n-icon size="20" style="margin-bottom: -1px" :component="Home" />
排班
</div>
</n-tab>
<n-tab name="报表" @click="showModal = true">
<div style="display: flex; flex-direction: column; align-items: center">
<n-icon size="20" style="margin-bottom: -1px" :component="StatsChart" />
报表
</div>
<n-modal v-model:show="showModal">
<n-card
style="width: 300px"
title="基建报表"
:bordered="false"
size="huge"
role="dialog"
aria-modal="true"
>
<div>
<n-button @click=";(showModal = false), $router.push('/record/line')">
心情曲线
</n-button>
</div>
<div>
<n-button @click=";(showModal = false), $router.push('/record/pie')">
心情饼图
</n-button>
</div>
<div>
<n-button @click=";(showModal = false), $router.push('/record/depot')">
仓库
</n-button>
</div>
<div>
<n-button @click=";(showModal = false), $router.push('/record/report')">
基建报告
</n-button>
</div>
</n-card>
</n-modal>
</n-tab>
<n-tab name="帮助" @click="$router.push('/doc')">
<div style="display: flex; flex-direction: column; align-items: center">
<n-icon size="20" style="margin-bottom: -1px" :component="HelpCircle" />
帮助
</div>
</n-tab>
</n-tabs>
</n-layout-footer>
</n-layout>
<n-loading-bar-provider>
<n-layout :has-sider="!mobile" class="outer-layout">
<n-layout-sider
v-if="!mobile"
bordered
collapse-mode="width"
:collapsed-width="50"
:width="210"
show-trigger
>
<n-menu
:indent="24"
:collapsed-width="64"
:collapsed-icon-size="22"
:options="menuOptions"
/>
</n-layout-sider>
<n-layout-content class="layout-content-container">
<router-view v-if="loaded" />
</n-layout-content>
<n-layout-footer v-if="mobile">
<n-tabs type="line" justify-content="space-evenly" size="small">
<n-tab name="主页" @click="$router.push('/')">
<div style="display: flex; flex-direction: column; align-items: center">
<n-icon size="20" style="margin-bottom: -1px" :component="BookOutline" />
日志
</div>
</n-tab>
<n-tab name="设置" @click="$router.push('/settings')">
<div style="display: flex; flex-direction: column; align-items: center">
<n-icon size="20" style="margin-bottom: -1px" :component="Settings" />
设置
</div>
</n-tab>
<n-tab name="排班" @click="$router.push('/plan-editor')">
<div style="display: flex; flex-direction: column; align-items: center">
<n-icon size="20" style="margin-bottom: -1px" :component="Home" />
排班
</div>
</n-tab>
<n-tab name="报表" @click="showModal = true">
<div style="display: flex; flex-direction: column; align-items: center">
<n-icon size="20" style="margin-bottom: -1px" :component="StatsChart" />
报表
</div>
<n-modal v-model:show="showModal">
<n-card
style="width: 300px"
title="基建报表"
:bordered="false"
size="huge"
role="dialog"
aria-modal="true"
>
<div>
<n-button @click=";(showModal = false), $router.push('/record/line')">
心情曲线
</n-button>
</div>
<div>
<n-button @click=";(showModal = false), $router.push('/record/pie')">
心情饼图
</n-button>
</div>
<div>
<n-button @click=";(showModal = false), $router.push('/record/depot')">
仓库
</n-button>
</div>
<div>
<n-button @click=";(showModal = false), $router.push('/record/report')">
基建报告
</n-button>
</div>
</n-card>
</n-modal>
</n-tab>
<n-tab name="帮助" @click="$router.push('/doc')">
<div style="display: flex; flex-direction: column; align-items: center">
<n-icon size="20" style="margin-bottom: -1px" :component="HelpCircle" />
帮助
</div>
</n-tab>
</n-tabs>
</n-layout-footer>
</n-layout>
</n-loading-bar-provider>
</n-message-provider>
</n-dialog-provider>
</n-config-provider>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/PlanEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { storeToRefs } from 'pinia'
import { useConfigStore } from '@/stores/config'
import { usePlanStore } from '@/stores/plan'
import { ref, computed, nextTick, watch, h } from 'vue'
import { ref, computed, nextTick, watch, h, inject } from 'vue'
import pinyinMatch from 'pinyin-match/es/traditional'
import { NAvatar, NTag } from 'naive-ui'
const config_store = useConfigStore()
Expand All @@ -19,7 +19,7 @@ const facility_types = [
{ label: '发电站', value: '发电站' }
]
const facility = ref('')
const facility = inject('facility')
const button_type = {
贸易站: 'info',
Expand Down
Loading

0 comments on commit 48512b3

Please sign in to comment.