|
1 | 1 | <template> |
2 | 2 | <a-drawer v-model:visible="visible" title="项目配置" width="300px" unmount-on-close :footer="false"> |
3 | 3 | <a-space :size="15" direction="vertical" fill> |
4 | | - <a-divider orientation="center">系统布局</a-divider> |
5 | | - <a-row justify="center"> |
| 4 | + <a-alert v-if="settingOpen" :show-icon="false" type="info"> |
| 5 | + 「复制配置」按钮,并将配置粘贴到 src/config/settings.ts 文件中。 |
| 6 | + </a-alert> |
| 7 | + <a-divider v-if="settingOpen" orientation="center">系统布局</a-divider> |
| 8 | + <a-row v-if="settingOpen" justify="center"> |
6 | 9 | <a-space> |
7 | 10 | <a-badge> |
8 | 11 | <template #content> |
|
35 | 38 | ></ColorPicker> |
36 | 39 | </a-row> |
37 | 40 |
|
38 | | - <a-divider orientation="center">界面显示</a-divider> |
| 41 | + <a-divider v-if="settingOpen" orientation="center">界面显示</a-divider> |
39 | 42 |
|
40 | | - <a-descriptions :column="1" :align="{ value: 'right' }" :value-style="{ paddingRight: 0 }"> |
| 43 | + <a-descriptions v-if="settingOpen" :column="1" :align="{ value: 'right' }" :value-style="{ paddingRight: 0 }"> |
41 | 44 | <a-descriptions-item label="页签显示"> |
42 | 45 | <a-switch v-model="appStore.tab" /> |
43 | 46 | </a-descriptions-item> |
|
70 | 73 | <a-descriptions-item label="水印"> |
71 | 74 | <a-switch v-model="appStore.isOpenWatermark" /> |
72 | 75 | </a-descriptions-item> |
73 | | - <a-descriptions-item v-if="appStore.isOpenWatermark" label="水印信息"> |
| 76 | + <a-descriptions-item label="水印信息"> |
74 | 77 | <a-input v-model="appStore.watermark" placeholder="留空则显示用户名" /> |
75 | 78 | </a-descriptions-item> |
76 | 79 | </a-descriptions> |
| 80 | + |
| 81 | + <a-divider orientation="center">其它</a-divider> |
| 82 | + <a-descriptions :column="1" :align="{ value: 'right' }" :value-style="{ paddingRight: 0 }"> |
| 83 | + <a-descriptions-item label="色弱模式"> |
| 84 | + <a-switch v-model="appStore.enableColorWeaknessMode" /> |
| 85 | + </a-descriptions-item> |
| 86 | + <a-descriptions-item v-if="settingOpen" label="哀悼模式"> |
| 87 | + <a-switch v-model="appStore.enableMourningMode" /> |
| 88 | + </a-descriptions-item> |
| 89 | + </a-descriptions> |
| 90 | + <a-space v-if="settingOpen" direction="vertical" fill> |
| 91 | + <a-button type="primary" long @click="copySettings"> |
| 92 | + <template #icon> |
| 93 | + <icon-copy /> |
| 94 | + </template> |
| 95 | + 复制配置 |
| 96 | + </a-button> |
| 97 | + </a-space> |
77 | 98 | </a-space> |
78 | 99 | </a-drawer> |
79 | 100 | </template> |
80 | 101 |
|
81 | 102 | <script setup lang="ts"> |
82 | 103 | import { ColorPicker } from 'vue-color-kit' |
83 | 104 | import 'vue-color-kit/dist/vue-color-kit.css' |
| 105 | +import { useClipboard } from '@vueuse/core' |
| 106 | +import { Message } from '@arco-design/web-vue' |
84 | 107 | import LayoutItem from './components/LayoutItem.vue' |
85 | 108 | import { useAppStore } from '@/stores' |
86 | 109 |
|
87 | 110 | defineOptions({ name: 'SettingDrawer' }) |
88 | 111 | const appStore = useAppStore() |
89 | 112 | const visible = ref(false) |
90 | | -
|
| 113 | +const settingOpen = JSON.parse(import.meta.env.VITE_APP_SETTING) |
91 | 114 | const tabModeList: App.TabItem[] = [ |
92 | 115 | { label: '卡片', value: 'card' }, |
93 | 116 | { label: '间隔卡片', value: 'card-gutter' }, |
@@ -138,6 +161,36 @@ const changeColor = (colorObj: ColorObj) => { |
138 | 161 | appStore.setThemeColor(colorObj.hex) |
139 | 162 | } |
140 | 163 |
|
| 164 | +// 复制配置 |
| 165 | +const copySettings = () => { |
| 166 | + const settings: App.AppSettings = { |
| 167 | + theme: 'light', |
| 168 | + themeColor: appStore.themeColor, |
| 169 | + tab: appStore.tab, |
| 170 | + tabMode: appStore.tabMode, |
| 171 | + animate: appStore.animate, |
| 172 | + animateMode: appStore.animateMode, |
| 173 | + menuCollapse: appStore.menuCollapse, |
| 174 | + menuAccordion: appStore.menuAccordion, |
| 175 | + menuDark: appStore.menuDark, |
| 176 | + copyrightDisplay: appStore.copyrightDisplay, |
| 177 | + layout: appStore.layout, |
| 178 | + isOpenWatermark: appStore.isOpenWatermark, |
| 179 | + watermark: appStore.watermark, |
| 180 | + enableColorWeaknessMode: appStore.enableColorWeaknessMode, |
| 181 | + enableMourningMode: appStore.enableMourningMode, |
| 182 | + } |
| 183 | +
|
| 184 | + const settingJson = JSON.stringify(settings, null, 2) |
| 185 | + const { isSupported, copy } = useClipboard({ source: settingJson }) |
| 186 | + if (isSupported) { |
| 187 | + copy(settingJson) |
| 188 | + Message.success({ content: '复制成功!' }) |
| 189 | + } else { |
| 190 | + Message.error({ content: '请检查浏览器权限是否开启' }) |
| 191 | + } |
| 192 | +} |
| 193 | +
|
141 | 194 | defineExpose({ open }) |
142 | 195 | </script> |
143 | 196 |
|
|
0 commit comments