Skip to content

Commit

Permalink
feat: uniform modal style (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb committed Mar 31, 2023
1 parent 9330730 commit 6ef4682
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions .eslintrc-auto-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"useCssVars": true,
"useDisableShortcuts": true,
"useInit": true,
"useModalStyle": true,
"useObserverLink": true,
"useRoleStore": true,
"useSessionStore": true,
Expand Down
9 changes: 2 additions & 7 deletions src/components/Settings/index.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<script setup lang="ts">
import { listen } from '@tauri-apps/api/event'
import { type, OsType } from '@tauri-apps/api/os'
const platform = ref<OsType>('Darwin')
const { modalMaskStyle } = useModalStyle()
const visible = ref(false)
onMounted(async () => {
listen('open-settings', () => {
visible.value = true
})
platform.value = await type()
})
</script>

Expand All @@ -21,9 +18,7 @@ onMounted(async () => {
class="settings-modal"
:visible="visible"
width="70%"
:mask-style="{
borderRadius: platform === 'Darwin' ? '0.75rem' : '0'
}"
:mask-style="modalMaskStyle"
:footer="false"
@ok="visible = false"
@cancel="visible = false"
Expand Down
3 changes: 3 additions & 0 deletions src/components/Update/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { getVersion } from '@tauri-apps/api/app'
import { relaunch } from '@tauri-apps/api/process'
import { listen } from '@tauri-apps/api/event'
const { modalMaskStyle } = useModalStyle()
const visible = ref(false)
const isDownload = ref(false)
Expand Down Expand Up @@ -85,6 +87,7 @@ onMounted(() => {
:visible="visible"
simple
title="发现新版本可用 🥳"
:mask-style="modalMaskStyle"
:ok-text="isDownload ? '正在更新' : '立即更新'"
:cancel-text="isDownload ? '取消更新' : '稍后更新'"
:mask-closable="false"
Expand Down
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './useObserverLink'
export * from './useDisableShortcuts'
export * from './useInit'
export * from './useModalStyle'
18 changes: 18 additions & 0 deletions src/hooks/useModalStyle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { type, OsType } from '@tauri-apps/api/os'
import type { CSSProperties } from 'vue'

export const useModalStyle = () => {
const platform = ref<OsType>('Darwin')

const modalMaskStyle = computed<CSSProperties>(() => ({
borderRadius: platform.value === 'Darwin' ? '0.75rem' : 0
}))

onMounted(async () => {
platform.value = await type()
})

return {
modalMaskStyle
}
}

0 comments on commit 6ef4682

Please sign in to comment.