diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fbcdaf7..0b182dcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,37 @@ # CHANGE LOG -## 4.6.2-beta +## 4.6.2-beta1.1 + +## Feats + +- `cache` 工具包相关 + - 优化 `removeStorage` 方法类型推导,当 `key` 为预留字关键字时,强制绑定 `storageType` 为对应的类型值 + +```ts +import { removeStorage } from '@/utils' + +// 正确 +removeStorage('__all__', 'all') +removeStorage('__all_sessionStorage__', 'sessionStorage') +removeStorage('__all_localStorage__', 'localStorage') +remove('your key', 'sessionStorage' || 'localStorage') + +// 错误 +removeStorage('__all__', 'sessionStorage') +removeStorage('__all_sessionStorage__', 'localStorage') +removeStorage('__all_localStorage__', 'all') +removeStorage('__all_localStorage__', 'sessionStorage') +remove('your key', 'all') +``` + +- 优化 `Layout` 布局样式,移除 `border` 边框,添加 `box-shadow` 阴影 + +## Fixes + +- 修复 `copy` 指令复制的时候不能正确的提示的问题 +- 修复 `AppVersionProvider` 组件不能正确的注入 `appVersion` 的问题 + +## 4.6.2-beta1.0 为了支持同域名下同时部署多套系统,重构了 `cache` 工具包支持前缀配置。并且暴露重构所有的缓存 `key` 配置项,为了便捷的进行私有数据缓存。 diff --git a/README-ZH.md b/README-ZH.md index 6ba8887c..135e68ee 100644 --- a/README-ZH.md +++ b/README-ZH.md @@ -4,7 +4,7 @@ alt="Ray Template" width="200" height="200" - src="https://r2chevereto.yka.moe/longmao.navigator.th.png" + src="https://avatars.githubusercontent.com/u/51957438?v=4" />
diff --git a/README.md b/README.md index f79e3e2c..8a50e817 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ alt="Ray Template" width="200" height="200" - src="https://r2chevereto.yka.moe/longmao.navigator.th.png" + src="https://avatars.githubusercontent.com/u/51957438?v=4" />
diff --git a/package.json b/package.json index 960898f6..1c1f0724 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ray-template", "private": false, - "version": "4.6.2-beta", + "version": "4.6.2-beta1.1", "type": "module", "engines": { "node": "^18.0.0 || >=20.0.0", diff --git a/src/app-components/app/AppAvatar/index.tsx b/src/app-components/app/AppAvatar/index.tsx index b977b47f..6d018b3c 100644 --- a/src/app-components/app/AppAvatar/index.tsx +++ b/src/app-components/app/AppAvatar/index.tsx @@ -63,22 +63,24 @@ const AppAvatar = defineComponent({ } }, render() { + const { signing, cssVars, spaceSize, avatarSize, $props } = this + return ( -
{this.signing?.name}
+
{signing?.name}
) }, diff --git a/src/app-components/app/RayLink/index.tsx b/src/app-components/app/RayLink/index.tsx index 908e38ec..06969a26 100644 --- a/src/app-components/app/RayLink/index.tsx +++ b/src/app-components/app/RayLink/index.tsx @@ -16,41 +16,41 @@ export default defineComponent({ name: 'RayLink', setup() { const avatarOptions: AvatarOptions[] = [ - { - key: 'yunhome', - src: 'https://yunkuangao.me/', - tooltip: '云之家', - icon: 'https://r2chevereto.yka.moe/avatar.jpeg', - }, - { - key: 'yun-cloud-images', - src: 'https://yunkuangao.com/', - tooltip: '云图床', - icon: 'https://r2chevereto.yka.moe/avatar.jpeg', - }, + // { + // key: 'yunhome', + // src: 'https://yunkuangao.me/', + // tooltip: '云之家', + // icon: 'https://r2chevereto.yka.moe/avatar.jpeg', + // }, + // { + // key: 'yun-cloud-images', + // src: 'https://yunkuangao.com/', + // tooltip: '云图床', + // icon: 'https://r2chevereto.yka.moe/avatar.jpeg', + // }, { key: 'ray-js-note', src: 'https://note.youdao.com/s/ObWEe2BB', tooltip: 'Ray的前端学习笔记', - icon: 'https://r2chevereto.yka.moe/longmao.navigator.png', + icon: 'https://avatars.githubusercontent.com/u/51957438?v=4', }, { key: 'ray-js-cover', src: 'https://note.youdao.com/s/IC8xKPdB', tooltip: 'Ray的面试题总结', - icon: 'https://r2chevereto.yka.moe/longmao.navigator.png', + icon: 'https://avatars.githubusercontent.com/u/51957438?v=4', }, { key: 'ray-template-doc', src: 'https://xiaodaigua-ray.github.io/ray-template-doc/', tooltip: 'Ray Template Doc', - icon: 'https://r2chevereto.yka.moe/longmao.navigator.png', + icon: 'https://avatars.githubusercontent.com/u/51957438?v=4', }, { key: 'ray-template-doc-out', src: 'https://ray-template.yunkuangao.com/', tooltip: 'Ray Template Doc (国内地址)', - icon: 'https://r2chevereto.yka.moe/longmao.navigator.png', + icon: 'https://avatars.githubusercontent.com/u/51957438?v=4', }, ] diff --git a/src/app-components/provider/AppVersionProvider/index.tsx b/src/app-components/provider/AppVersionProvider/index.tsx index 4af69274..2dcef8b7 100644 --- a/src/app-components/provider/AppVersionProvider/index.tsx +++ b/src/app-components/provider/AppVersionProvider/index.tsx @@ -45,6 +45,12 @@ export default defineComponent({ 'localStorage', ) } + } else { + setStorage( + APP_CATCH_KEY.appVersionProvider, + version, + 'localStorage', + ) } return { diff --git a/src/directives/modules/copy/index.ts b/src/directives/modules/copy/index.ts index ce2e52b0..2c95b21f 100644 --- a/src/directives/modules/copy/index.ts +++ b/src/directives/modules/copy/index.ts @@ -19,29 +19,31 @@ import ClipboardJS from 'clipboard' import type { CopyElement } from './type' import type { CustomDirectiveFC } from '@/directives/type' +const createClipboard = (el: CopyElement, value: string) => { + const clipboard = new ClipboardJS(el, { + text: () => value, + }) + + el.$$clipboard = clipboard + + el.$$clipboard.on('success', () => { + window.$message.success('复制成功') + }) + el.$$clipboard.on('error', () => { + window.$message.error('复制失败') + }) +} + const copyDirective: CustomDirectiveFC = () => { return { mounted: (el, { value }) => { - const clipboard = new ClipboardJS(el, { - text: () => String(value), - }) - - clipboard.on('success', () => { - window.$message.success('复制成功') - }) - clipboard.on('error', () => { - window.$message.error('复制失败') - }) - - el.$$clipboard = clipboard + createClipboard(el, value) }, updated: (el, { value, oldValue }) => { if (value !== oldValue) { el.$$clipboard?.destroy() - el.$$clipboard = new ClipboardJS(el, { - text: () => String(value), - }) + createClipboard(el, value) } }, beforeUnmount: (el: CopyElement) => { diff --git a/src/layout/components/Menu/components/SiderBarLogo/index.scss b/src/layout/components/Menu/components/SiderBarLogo/index.scss index 7f1faa3a..8a5fd57d 100644 --- a/src/layout/components/Menu/components/SiderBarLogo/index.scss +++ b/src/layout/components/Menu/components/SiderBarLogo/index.scss @@ -19,7 +19,6 @@ gap: 8px 12px; font-weight: 600; overflow: hidden; - border-right: solid 1px var(--n-border-color); &.ray-menu__logo-url { position: sticky; diff --git a/src/layout/components/Menu/index.scss b/src/layout/components/Menu/index.scss index abd0df87..fdbc484a 100644 --- a/src/layout/components/Menu/index.scss +++ b/src/layout/components/Menu/index.scss @@ -5,3 +5,11 @@ height: 100%; } } + +.ray-template--light .app-menu__sider { + box-shadow: 2px 0 8px $layoutShadowColorLight; +} + +.ray-template--dark .app-menu__sider { + box-shadow: 2px 0 8px $layoutShadowColorDark; +} diff --git a/src/layout/components/Menu/index.tsx b/src/layout/components/Menu/index.tsx index 644d7bab..cf0fc89a 100644 --- a/src/layout/components/Menu/index.tsx +++ b/src/layout/components/Menu/index.tsx @@ -67,7 +67,7 @@ export default defineComponent({ const BasicMenu = () => ( + { window.$message.info('账号退出中...') - removeStorage('__all_sessionStorage__') + removeStorage('__all_sessionStorage__', 'sessionStorage') setTimeout(() => window.location.reload()) } diff --git a/src/styles/setting.scss b/src/styles/setting.scss index 5a9b58e5..0ec99897 100644 --- a/src/styles/setting.scss +++ b/src/styles/setting.scss @@ -9,3 +9,6 @@ $layoutContentBackgroundColorLight: #f7f9f8; $layoutFooterBackgroundColorDark: rgba(24, 24, 28, 1); // 底部区域背景色(light) $layoutFooterBackgroundColorLight: rgba(255, 255, 255, 1); +// 区域阴影 +$layoutShadowColorLight: #0000001f; +$layoutShadowColorDark: #000000b8; diff --git a/src/types/modules/utils.ts b/src/types/modules/utils.ts index b22e8533..4566c72d 100644 --- a/src/types/modules/utils.ts +++ b/src/types/modules/utils.ts @@ -9,7 +9,17 @@ export type RemoveStorageKey = | '__all_sessionStorage__' | '__all_localStorage__' -export type RemoveStorageType = StorageLike +export type RemoveStorageFC = ( + key: T, + storageType: T extends '__all__' + ? 'all' + : T extends '__all_sessionStorage__' + ? 'sessionStorage' + : T extends '__all_localStorage__' + ? 'localStorage' + : StorageLike, + options?: StorageOptions, +) => void export type ValidateValueType = | 'BigUint64Array' diff --git a/src/utils/cache.ts b/src/utils/cache.ts index 6363cbe6..09fd4a4c 100644 --- a/src/utils/cache.ts +++ b/src/utils/cache.ts @@ -11,12 +11,7 @@ import { APP_CATCH_KEY_PREFIX } from '@/app-config' -import type { - StorageLike, - RemoveStorageKey, - StorageOptions, - RemoveStorageType, -} from '@/types' +import type { StorageLike, StorageOptions, RemoveStorageFC } from '@/types' /** * @@ -24,6 +19,7 @@ import type { * @param storageType 需要删除的缓存类型 * @param options 配置项 * + * @description * 查找当前缓存中是否含有某个 key * 默认查找 sessionStorage */ @@ -46,6 +42,7 @@ function hasStorage( * @param type 需要删除的缓存类型 * @param options 配置项 * + * @description * 设置缓存值,默认设置 sessionStorage */ function setStorage( @@ -97,6 +94,7 @@ function getStorage( * @param type 需要删除的缓存类型 * @param options 配置项 * + * @description * 获取缓存值,默认获取 sessionStorage */ function getStorage( @@ -134,27 +132,23 @@ function getStorage( * @param type 需要删除的缓存类型 * @param options 配置项 * + * @description * 删除缓存值,默认删除 sessionStorage * * 预保留了 __all__、__all_sessionStorage__、__all_localStorage__ 三个 key * 分别代表清空所有缓存、清空 sessionStorage 缓存、清空 localStorage 缓存 * * @example - * removeStorage('__all__') // 清空所有缓存 - * removeStorage('__all_sessionStorage__') // 清空 sessionStorage 缓存 - * removeStorage('__all_localStorage__') // 清空 localStorage 缓存 - * removeStorage('signing') // 清空 session 中 signing 缓存字段 + * removeStorage('__all__', 'all') // 清空所有缓存 + * removeStorage('__all_sessionStorage__', 'sessionStorage') // 清空 sessionStorage 缓存 + * removeStorage('__all_localStorage__', 'localStorage') // 清空 localStorage 缓存 + * removeStorage('signing', 'sessionStorage' || 'localStorage') // 清空 session 中 signing 缓存字段 */ -function removeStorage( - key: RemoveStorageKey, - storageType: RemoveStorageType = 'sessionStorage', - options?: StorageOptions, -) { +const removeStorage: RemoveStorageFC = (key, storageType, options) => { if (!key) { console.error( `[removeStorage]: Failed to remove stored data: key ${key} is empty or undefined`, ) - return } @@ -169,7 +163,6 @@ function removeStorage( : removeType === 'localStorage' ? localStorageKeys : sessionStorageKeys - keys.forEach((curr) => { if (key === '__all__') { window.sessionStorage.removeItem(_prefix + curr)