Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1425f1d1
authored
Jul 06, 2024
by
vben
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: Preferences support clearing the cache and logging out
1 parent
37a4f971
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
5 deletions
apps/web-antd/src/layouts/basic.vue
internal/node-utils/package.json
package.json
packages/@core/forward/preferences/src/index.ts
packages/business/layouts/src/basic/layout.vue
packages/business/widgets/src/preferences/preferences.vue
packages/locales/src/langs/en-US.yaml
packages/locales/src/langs/zh-CN.yaml
pnpm-lock.yaml
apps/web-antd/src/layouts/basic.vue
View file @
1425f1d
...
@@ -95,7 +95,7 @@ function handleNoticeClear() {
...
@@ -95,7 +95,7 @@ function handleNoticeClear() {
</
script
>
</
script
>
<
template
>
<
template
>
<BasicLayout>
<BasicLayout
@
clear-preferences-and-logout=
"handleLogout"
>
<template
#
user-dropdown
>
<template
#
user-dropdown
>
<UserDropdown
<UserDropdown
:avatar=
"preferences.app.defaultAvatar"
:avatar=
"preferences.app.defaultAvatar"
...
...
internal/node-utils/package.json
View file @
1425f1d
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
"nanoid"
:
"^5.0.7"
,
"nanoid"
:
"^5.0.7"
,
"pkg-types"
:
"^1.1.3"
,
"pkg-types"
:
"^1.1.3"
,
"prettier"
:
"^3.3.2"
,
"prettier"
:
"^3.3.2"
,
"rimraf"
:
"^5.0.
7
"
,
"rimraf"
:
"^5.0.
8
"
,
"zx"
:
"^7.2.3"
"zx"
:
"^7.2.3"
}
}
}
}
package.json
View file @
1425f1d
...
@@ -67,7 +67,7 @@
...
@@ -67,7 +67,7 @@
"husky"
:
"^9.0.11"
,
"husky"
:
"^9.0.11"
,
"is-ci"
:
"^3.0.1"
,
"is-ci"
:
"^3.0.1"
,
"jsdom"
:
"^24.1.0"
,
"jsdom"
:
"^24.1.0"
,
"rimraf"
:
"^5.0.
7
"
,
"rimraf"
:
"^5.0.
8
"
,
"taze"
:
"^0.14.2"
,
"taze"
:
"^0.14.2"
,
"turbo"
:
"^2.0.6"
,
"turbo"
:
"^2.0.6"
,
"typescript"
:
"^5.5.3"
,
"typescript"
:
"^5.5.3"
,
...
...
packages/@core/forward/preferences/src/index.ts
View file @
1425f1d
...
@@ -17,7 +17,11 @@ const updatePreferences =
...
@@ -17,7 +17,11 @@ const updatePreferences =
const
resetPreferences
=
const
resetPreferences
=
preferencesManager
.
resetPreferences
.
bind
(
preferencesManager
);
preferencesManager
.
resetPreferences
.
bind
(
preferencesManager
);
const
clearPreferencesCache
=
preferencesManager
.
clearCache
.
bind
(
preferencesManager
);
export
{
export
{
clearPreferencesCache
,
// flatPreferences,
// flatPreferences,
preferences
,
preferences
,
preferencesManager
,
preferencesManager
,
...
...
packages/business/layouts/src/basic/layout.vue
View file @
1425f1d
...
@@ -28,6 +28,8 @@ import { Breadcrumb } from './widgets';
...
@@ -28,6 +28,8 @@ import { Breadcrumb } from './widgets';
defineOptions
({
name
:
'BasicLayout'
});
defineOptions
({
name
:
'BasicLayout'
});
const
emit
=
defineEmits
<
{
clearPreferencesAndLogout
:
[]
}
>
();
const
{
isDark
,
isHeaderNav
,
isMixedNav
,
isSideMixedNav
,
layout
}
=
const
{
isDark
,
isHeaderNav
,
isMixedNav
,
isSideMixedNav
,
layout
}
=
usePreferences
();
usePreferences
();
...
@@ -106,6 +108,10 @@ function toggleSidebar() {
...
@@ -106,6 +108,10 @@ function toggleSidebar() {
},
},
});
});
}
}
function
clearPreferencesAndLogout
()
{
emit
(
'clearPreferencesAndLogout'
);
}
</
script
>
</
script
>
<
template
>
<
template
>
...
@@ -147,7 +153,9 @@ function toggleSidebar() {
...
@@ -147,7 +153,9 @@ function toggleSidebar() {
"
"
>
>
<template
v-if=
"preferences.app.showPreference"
#
preferences
>
<template
v-if=
"preferences.app.showPreference"
#
preferences
>
<PreferencesWidget
/>
<PreferencesWidget
@
clear-preferences-and-logout=
"clearPreferencesAndLogout"
/>
</
template
>
</
template
>
<
template
#
floating-groups
>
<
template
#
floating-groups
>
...
...
packages/business/widgets/src/preferences/preferences.vue
View file @
1425f1d
...
@@ -18,6 +18,7 @@ import { computed, ref } from 'vue';
...
@@ -18,6 +18,7 @@ import { computed, ref } from 'vue';
import
{
$t
,
loadLocaleMessages
}
from
'@vben/locales'
;
import
{
$t
,
loadLocaleMessages
}
from
'@vben/locales'
;
import
{
IcRoundFolderCopy
,
IcRoundRestartAlt
}
from
'@vben-core/iconify'
;
import
{
IcRoundFolderCopy
,
IcRoundRestartAlt
}
from
'@vben-core/iconify'
;
import
{
import
{
clearPreferencesCache
,
preferences
,
preferences
,
resetPreferences
,
resetPreferences
,
usePreferences
,
usePreferences
,
...
@@ -53,6 +54,8 @@ import {
...
@@ -53,6 +54,8 @@ import {
import
Trigger
from
'./trigger.vue'
;
import
Trigger
from
'./trigger.vue'
;
import
{
useOpenPreferences
}
from
'./use-open-preferences'
;
import
{
useOpenPreferences
}
from
'./use-open-preferences'
;
const
emit
=
defineEmits
<
{
clearPreferencesAndLogout
:
[]
}
>
();
const
appLocale
=
defineModel
<
SupportedLanguagesType
>
(
'appLocale'
);
const
appLocale
=
defineModel
<
SupportedLanguagesType
>
(
'appLocale'
);
const
appDynamicTitle
=
defineModel
<
boolean
>
(
'appDynamicTitle'
);
const
appDynamicTitle
=
defineModel
<
boolean
>
(
'appDynamicTitle'
);
const
appAiAssistant
=
defineModel
<
boolean
>
(
'appAiAssistant'
);
const
appAiAssistant
=
defineModel
<
boolean
>
(
'appAiAssistant'
);
...
@@ -166,6 +169,12 @@ async function handleCopy() {
...
@@ -166,6 +169,12 @@ async function handleCopy() {
toast
(
$t
(
'preferences.copy-success'
));
toast
(
$t
(
'preferences.copy-success'
));
}
}
async
function
handleClearCache
()
{
resetPreferences
();
clearPreferencesCache
();
emit
(
'clearPreferencesAndLogout'
);
}
async
function
handleReset
()
{
async
function
handleReset
()
{
if
(
!
diffPreference
.
value
)
{
if
(
!
diffPreference
.
value
)
{
return
;
return
;
...
@@ -187,6 +196,7 @@ async function handleReset() {
...
@@ -187,6 +196,7 @@ async function handleReset() {
<Trigger
/>
<Trigger
/>
</
template
>
</
template
>
<
template
#
extra
>
<
template
#
extra
>
<div
class=
"flex items-center"
>
<VbenIconButton
<VbenIconButton
:disabled=
"!diffPreference"
:disabled=
"!diffPreference"
:tooltip=
"$t('preferences.reset-tip')"
:tooltip=
"$t('preferences.reset-tip')"
...
@@ -198,6 +208,7 @@ async function handleReset() {
...
@@ -198,6 +208,7 @@ async function handleReset() {
></span>
></span>
<IcRoundRestartAlt
class=
"size-5"
@
click=
"handleReset"
/>
<IcRoundRestartAlt
class=
"size-5"
@
click=
"handleReset"
/>
</VbenIconButton>
</VbenIconButton>
</div>
</
template
>
</
template
>
<div
class=
"p-4 pt-4"
>
<div
class=
"p-4 pt-4"
>
...
@@ -329,8 +340,17 @@ async function handleReset() {
...
@@ -329,8 +340,17 @@ async function handleReset() {
<
template
#
footer
>
<
template
#
footer
>
<VbenButton
<VbenButton
class=
"mx-4 w-full"
size=
"sm"
variant=
"outline"
@
click=
"handleClearCache"
>
<IcRoundRestartAlt
class=
"mr-2 size-4"
/>
{{
$t
(
'preferences.clear-and-logout'
)
}}
</VbenButton>
<VbenButton
:disabled=
"!diffPreference"
:disabled=
"!diffPreference"
class=
"m
x-6
w-full"
class=
"m
r-4
w-full"
size=
"sm"
size=
"sm"
variant=
"default"
variant=
"default"
@
click=
"handleCopy"
@
click=
"handleCopy"
...
...
packages/locales/src/langs/en-US.yaml
View file @
1425f1d
...
@@ -165,6 +165,7 @@ preferences:
...
@@ -165,6 +165,7 @@ preferences:
interface-control
:
Interface Layout Control
interface-control
:
Interface Layout Control
copy
:
Copy Preferences
copy
:
Copy Preferences
copy-success
:
Copy successful. Please replace in `src/preferences.ts` of the app
copy-success
:
Copy successful. Please replace in `src/preferences.ts` of the app
clear-and-logout
:
Clear Cache & Logout
reset-success
:
Preferences reset successfully
reset-success
:
Preferences reset successfully
sidebar
:
Sidebar
sidebar
:
Sidebar
side-visible
:
Display Sidebar
side-visible
:
Display Sidebar
...
...
packages/locales/src/langs/zh-CN.yaml
View file @
1425f1d
...
@@ -164,6 +164,7 @@ preferences:
...
@@ -164,6 +164,7 @@ preferences:
rounded
:
圆润
rounded
:
圆润
copy
:
复制偏好设置
copy
:
复制偏好设置
copy-success
:
拷贝成功,请在 app 下的 `src/preferences.ts`内进行覆盖
copy-success
:
拷贝成功,请在 app 下的 `src/preferences.ts`内进行覆盖
clear-and-logout
:
清空缓存 & 退出登录
reset-success
:
重置偏好设置成功
reset-success
:
重置偏好设置成功
sidebar
:
侧边栏
sidebar
:
侧边栏
side-visible
:
显示侧边栏
side-visible
:
显示侧边栏
...
...
pnpm-lock.yaml
View file @
1425f1d
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment