mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-22 08:47:06 +08:00
✨ Feature(custom): rewrite setting page, WIP
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { IRPCActionType } from 'root/src/universal/types/enum'
|
||||
import { onMounted, onUnmounted } from 'vue'
|
||||
|
||||
import { IRPCActionType } from '@/utils/enum'
|
||||
|
||||
export function useATagClick () {
|
||||
const handleATagClick = (e: MouseEvent) => {
|
||||
if (e.target instanceof HTMLAnchorElement) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
|
||||
import { IStringKeyMap } from '#/types/types'
|
||||
import type { IStringKeyMap } from '#/types/types'
|
||||
|
||||
export const useAppStore = defineStore('app', () => {
|
||||
const settings = ref<IStringKeyMap>({
|
||||
38
src/renderer/hooks/useConfirm.ts
Normal file
38
src/renderer/hooks/useConfirm.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
export interface ConfirmOptions {
|
||||
title?: string
|
||||
message: string
|
||||
type?: 'info' | 'success' | 'warning' | 'error'
|
||||
confirmButtonText?: string
|
||||
cancelButtonText?: string
|
||||
showClose?: boolean
|
||||
center?: boolean
|
||||
}
|
||||
|
||||
interface ConfirmService {
|
||||
confirm: (options: ConfirmOptions) => Promise<boolean>
|
||||
}
|
||||
|
||||
const confirmServiceRef = ref<ConfirmService | null>(null)
|
||||
|
||||
export function useConfirm () {
|
||||
const setConfirmService = (service: ConfirmService) => {
|
||||
confirmServiceRef.value = service
|
||||
}
|
||||
|
||||
const confirm = (options: ConfirmOptions): Promise<boolean> => {
|
||||
if (confirmServiceRef.value) {
|
||||
return confirmServiceRef.value.confirm(options)
|
||||
}
|
||||
console.warn('Confirm service not initialized')
|
||||
return Promise.resolve(false)
|
||||
}
|
||||
|
||||
return {
|
||||
setConfirmService,
|
||||
confirm
|
||||
}
|
||||
}
|
||||
|
||||
export default useConfirm
|
||||
60
src/renderer/hooks/useMessage.ts
Normal file
60
src/renderer/hooks/useMessage.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
import type { MessageOptions } from '@/components/ui/MessageToast.vue'
|
||||
|
||||
interface MessageService {
|
||||
success: (message: string, options?: Partial<MessageOptions>) => string
|
||||
error: (message: string, options?: Partial<MessageOptions>) => string
|
||||
warning: (message: string, options?: Partial<MessageOptions>) => string
|
||||
info: (message: string, options?: Partial<MessageOptions>) => string
|
||||
}
|
||||
|
||||
const messageServiceRef = ref<MessageService | null>(null)
|
||||
|
||||
export function useMessage () {
|
||||
const setMessageService = (service: MessageService) => {
|
||||
messageServiceRef.value = service
|
||||
}
|
||||
|
||||
const success = (message: string, options?: Partial<MessageOptions>) => {
|
||||
if (messageServiceRef.value) {
|
||||
return messageServiceRef.value.success(message, options)
|
||||
}
|
||||
console.warn('Message service not initialized')
|
||||
return ''
|
||||
}
|
||||
|
||||
const error = (message: string, options?: Partial<MessageOptions>) => {
|
||||
if (messageServiceRef.value) {
|
||||
return messageServiceRef.value.error(message, options)
|
||||
}
|
||||
console.warn('Message service not initialized')
|
||||
return ''
|
||||
}
|
||||
|
||||
const warning = (message: string, options?: Partial<MessageOptions>) => {
|
||||
if (messageServiceRef.value) {
|
||||
return messageServiceRef.value.warning(message, options)
|
||||
}
|
||||
console.warn('Message service not initialized')
|
||||
return ''
|
||||
}
|
||||
|
||||
const info = (message: string, options?: Partial<MessageOptions>) => {
|
||||
if (messageServiceRef.value) {
|
||||
return messageServiceRef.value.info(message, options)
|
||||
}
|
||||
console.warn('Message service not initialized')
|
||||
return ''
|
||||
}
|
||||
|
||||
return {
|
||||
setMessageService,
|
||||
success,
|
||||
error,
|
||||
warning,
|
||||
info
|
||||
}
|
||||
}
|
||||
|
||||
export default useMessage
|
||||
Reference in New Issue
Block a user