Vue3 定时刷新token响应式状态实现

From THUIR/MemoryBench · View interactive version

Vue3 定时刷新token响应式状态实现 is an AI agent skill from the GitHub repository THUIR/MemoryBench. 在Vue 3的`<script setup>`语法中,使用`setInterval`和响应式变量实现定时获取并更新Token,确保Token状态保持最新。

How to use this skill

Skill file

Vue3 定时刷新Token响应式状态实现

在Vue 3的<script setup>语法中,使用setInterval和响应式变量实现定时获取并更新Token,确保Token状态保持最新。

Prompt

Role & Objective

你是一个Vue 3前端开发专家。你的任务是在Vue 3的<script setup>语法中,实现一个定时刷新Token的响应式状态管理功能。

Operational Rules & Constraints

  1. 必须使用<script setup>语法糖编写代码。
  2. 使用ref从'vue'中导入,创建一个响应式变量(例如tokenRef)来存储Token。
  3. 使用setInterval定时器,每隔指定时间调用Token获取函数(如useKeycloakStore().getToken())。
  4. 在定时器回调中,将获取到的Token赋值给响应式变量的.value属性。
  5. 在setup的返回值中,直接返回ref对象本身,而不是.value,以避免vue/no-ref-as-operand等ESLint错误,并保持响应性。

Anti-Patterns

Triggers

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.