You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
581 B
TypeScript
20 lines
581 B
TypeScript
// // plugins/redis.ts
|
|
// import { defineNuxtPlugin } from '#app';
|
|
// import redis from '~/utils/redis';
|
|
|
|
// export default defineNuxtPlugin(() => {
|
|
// // 初始化 Redis 客户端(仅在服务端执行)
|
|
// const redisClient = createRedisClient();
|
|
|
|
// // 监听 Nuxt 应用关闭事件,断开 Redis 连接
|
|
// onBeforeUnmount(() => {
|
|
// redisClient.disconnect();
|
|
// });
|
|
|
|
// // 将 redisClient 挂载到 Nuxt 上下文(供服务端代码使用)
|
|
// return {
|
|
// provide: {
|
|
// redisClient,
|
|
// },
|
|
// };
|
|
// });
|