Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
refactor: setting operation via useAppConfig (#100)
Browse files Browse the repository at this point in the history
* refactor: setting operation via useAppConfig

* chore: format the value of JSON.stringify
  • Loading branch information
likui628 authored Sep 12, 2023
1 parent 1e65c78 commit 7092779
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 49 deletions.
2 changes: 1 addition & 1 deletion packages/hooks/src/config/useAppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const useAppConfig = () => {
if (!isSupported)
return console.error('Your browser does not support Clipboard API')
const source = reactive(_omit(appConfigOptions, ['openSettingDrawer']))
await copy(JSON.stringify(source))
await copy(JSON.stringify(source, null, 2))
} catch (e) {
console.error(e)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,70 +1,27 @@
<script lang="ts" setup>
import { context } from '../../../../bridge'
import { useI18n } from '@vben/locale'
import { writeTextToClipboard } from '@vben/hooks'
import { unref } from 'vue'
import { resetRouter } from '@vben/router'
const { t } = useI18n()
const { useAppConfig, useConfigStore, useMultipleTabStore, useUserStore } =
context
const appConfig = useAppConfig()
const tabStore = useMultipleTabStore()
const userStore = useUserStore()
const configStore = useConfigStore()
const handleCopy = () => {
writeTextToClipboard(
JSON.stringify(unref(configStore.getProjectConfig), null, 2),
)
// const { isSuccessRef } = useCopyToClipboard(
// JSON.stringify(unref(configStore.getProjectConfig), null, 2),
// );
// unref(isSuccessRef) &&
// createSuccessModal({
// title: t('layout.setting.operatingTitle'),
// content: t('layout.setting.operatingContent'),
// });
}
const handleReset = () => {
try {
appConfig.resetAllConfig()
// configStore.resetAllConfig()
// const { colorWeak, grayMode } = defaultSetting;
// updateTheme(themeColor);
// updateColorWeak(colorWeak);
// updateGrayMode(grayMode);
// createMessage.success(t('layout.setting.resetSuccess'))
} catch (error: any) {
// createMessage.error(error);
}
}
const handleClearAndRedo = () => {
localStorage.clear()
resetRouter()
// permissionStore.resetState()
tabStore.resetState()
userStore.resetState()
location.reload()
}
const { useAppConfig } = context
const { copyConfigs, resetAllConfig, clearAndRedo } = useAppConfig()
</script>
<template>
<VbenSpace vertical>
<VbenButton type="info" block @click="handleCopy">
<VbenButton type="info" block @click="copyConfigs">
<template #icon>
<VbenIconify icon="ant-design:snippets-twotone" />
</template>
{{ t('layout.setting.copyBtn') }}
</VbenButton>
<VbenButton type="warning" @click="handleReset" block>
<VbenButton type="warning" @click="resetAllConfig" block>
<template #icon>
<VbenIconify icon="ant-design:reload-outlined" />
</template>
{{ t('common.resetText') }}
</VbenButton>
<VbenButton type="error" block @click="handleClearAndRedo">
<VbenButton type="error" block @click="clearAndRedo">
<template #icon>
<VbenIconify icon="ant-design:redo-outlined" />
</template>
Expand Down

0 comments on commit 7092779

Please sign in to comment.