Browse Source

✨ feat: 优化ai助手相关页面

Pchen. 19 hours ago
parent
commit
064e90b2aa
2 changed files with 782 additions and 144 deletions
  1. 680 140
      src/pages/ai/assistant/WeixinBindingModal.vue
  2. 102 4
      src/pages/ai/assistant/index.vue

+ 680 - 140
src/pages/ai/assistant/WeixinBindingModal.vue

@@ -14,100 +14,196 @@
       </div>
       </div>
     </template>
     </template>
 
 
-    <div class="bind-dialog">
-      <div class="bind-dialog__main">
-        <div class="bind-dialog__status">
-          <span class="pulse" :class="`pulse--${stateType}`" />
-          <div>
-            <strong>{{ stateTitle }}</strong>
-            <p>{{ stateDescription }}</p>
-          </div>
+    <section class="bind-shell" :class="`bind-shell--${stateType}`">
+      <div class="bind-hero">
+        <div class="bind-hero__copy">
+          <span class="eyebrow">{{ stateEyebrow }}</span>
+          <h2>{{ stateTitle }}</h2>
+          <p>{{ stateDescription }}</p>
         </div>
         </div>
-
-        <div v-if="bindingQrSource && binding?.state === 0" class="qr-stage">
-          <div class="qr-frame">
-            <canvas v-if="!bindingQrIsImage" ref="qrcodeCanvas" class="qr-canvas" aria-label="wechat qrcode"></canvas>
-            <img v-else :src="bindingQrSource" alt="微信绑定二维码" />
-          </div>
-          <div class="qr-tip">请使用微信扫码确认绑定</div>
-        </div>
-
-        <div v-else class="empty-stage">
-          <div class="empty-stage__icon"><icon-scan /></div>
-          <div>{{ emptyText }}</div>
+        <div class="signal" :class="`signal--${stateType}`">
+          <span></span>
+          <i></i>
         </div>
         </div>
       </div>
       </div>
 
 
-      <div class="bind-dialog__side">
-        <div class="side-card">
-          <span>状态</span>
-          <a-tag :color="bindingColor">{{ bindingLabel }}</a-tag>
-        </div>
-        <div class="side-card">
-          <span>最近微信消息</span>
-          <strong>{{ lastActiveText }}</strong>
+      <div class="bind-grid">
+        <div class="scan-panel">
+          <template v-if="showQr">
+            <div
+              class="qr-frame qr-frame--clickable"
+              :class="{ 'qr-frame--loading': bindingLoading }"
+              role="button"
+              tabindex="0"
+              title="点击重新生成二维码"
+              @click="refreshQrCode"
+              @keydown.enter.prevent="refreshQrCode"
+              @keydown.space.prevent="refreshQrCode"
+            >
+              <canvas v-if="!bindingQrIsImage" ref="qrcodeCanvas" class="qr-canvas" aria-label="wechat qrcode"></canvas>
+              <img v-else :src="bindingQrSource" alt="微信绑定二维码" />
+              <span class="qr-frame__action">
+                {{ bindingLoading ? '正在生成' : '点击刷新' }}
+              </span>
+            </div>
+            <div class="qr-meta">
+              <span>二维码有效期</span>
+              <strong>{{ qrRemainText }}</strong>
+            </div>
+          </template>
+
+          <template v-else>
+            <div class="state-visual">
+              <icon-check-circle v-if="isActive" />
+              <icon-exclamation-circle v-else-if="isExpired" />
+              <icon-scan v-else />
+            </div>
+            <strong>{{ emptyTitle }}</strong>
+            <p>{{ emptyText }}</p>
+          </template>
         </div>
         </div>
-        <div class="side-card">
-          <span>到期提醒</span>
-          <strong>24 小时内需保持一次对话</strong>
+
+        <div class="info-panel">
+          <div class="metric">
+            <span>绑定状态</span>
+            <a-tag :color="bindingColor">{{ bindingLabel }}</a-tag>
+          </div>
+          <div class="metric">
+            <span>最近微信消息</span>
+            <strong>{{ lastActiveText }}</strong>
+          </div>
+          <div class="metric">
+            <span>登录保持</span>
+            <strong>{{ keepAliveText }}</strong>
+          </div>
+          <div class="capabilities">
+            <span>已启用能力</span>
+            <ul>
+              <li>微信接收消息通知</li>
+              <li>微信内与小妍助理对话</li>
+            </ul>
+          </div>
         </div>
         </div>
       </div>
       </div>
-    </div>
+    </section>
 
 
     <div class="modal-actions">
     <div class="modal-actions">
-      <a-button type="primary" size="large" :loading="bindingLoading" @click="createBinding">
+      <a-button
+        v-if="showCreateButton"
+        type="primary"
+        size="large"
+        :loading="bindingLoading"
+        @click="createBinding"
+      >
         <template #icon><icon-scan /></template>
         <template #icon><icon-scan /></template>
-        {{ binding?.state === 1 ? '重新绑定微信' : '生成绑定二维码' }}
+        {{ createButtonText }}
       </a-button>
       </a-button>
-      <a-button v-if="binding" size="large" status="danger" :loading="bindingLoading" @click="unbind">
+      <a-button
+        v-if="showUnbindButton"
+        size="large"
+        status="danger"
+        :loading="bindingLoading"
+        @click="confirmUnbind"
+      >
         <template #icon><icon-delete /></template>
         <template #icon><icon-delete /></template>
         解除绑定
         解除绑定
       </a-button>
       </a-button>
-      <!-- <a-button size="large" :loading="loading" @click="refreshBinding">
+      <a-button size="large" :loading="loading" @click="refreshBinding">
         <template #icon><icon-refresh /></template>
         <template #icon><icon-refresh /></template>
         刷新状态
         刷新状态
-      </a-button> -->
+      </a-button>
     </div>
     </div>
   </a-modal>
   </a-modal>
 </template>
 </template>
 
 
 <script setup>
 <script setup>
 import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
 import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
-import { Message } from '@arco-design/web-vue'
+import { Message, Modal } from '@arco-design/web-vue'
 import QRCode from 'qrcode'
 import QRCode from 'qrcode'
 import { createWeixinBinding, deleteWeixinBinding, getWeixinBinding } from '@/api/aiChat'
 import { createWeixinBinding, deleteWeixinBinding, getWeixinBinding } from '@/api/aiChat'
 
 
 const emit = defineEmits(['updated'])
 const emit = defineEmits(['updated'])
 
 
+const QR_EXPIRE_MS = 5 * 60 * 1000
+
 const visible = ref(false)
 const visible = ref(false)
 const loading = ref(false)
 const loading = ref(false)
 const bindingLoading = ref(false)
 const bindingLoading = ref(false)
 const binding = ref(null)
 const binding = ref(null)
 const qrcodeCanvas = ref(null)
 const qrcodeCanvas = ref(null)
-let timer = null
+const now = ref(Date.now())
+let pollTimer = null
+let clockTimer = null
 
 
-const modalWidth = computed(() => (window.innerWidth < 720 ? '94vw' : '720px'))
+const modalWidth = computed(() => (window.innerWidth < 760 ? '94vw' : '780px'))
 const bindingQrSource = computed(() => binding.value?.qrcode_url || binding.value?.qrcode || '')
 const bindingQrSource = computed(() => binding.value?.qrcode_url || binding.value?.qrcode || '')
 const bindingQrIsImage = computed(() => /^data:image\//i.test(bindingQrSource.value))
 const bindingQrIsImage = computed(() => /^data:image\//i.test(bindingQrSource.value))
-const bindingLabel = computed(() => ({ 0: '待扫码', 1: '已绑定', 2: '已解绑', 3: '已过期' }[binding.value?.state] || '未绑定'))
-const bindingColor = computed(() => ({ 0: 'orange', 1: 'green', 2: 'gray', 3: 'red' }[binding.value?.state] || 'gray'))
-const stateType = computed(() => ({ 0: 'pending', 1: 'active', 2: 'muted', 3: 'danger' }[binding.value?.state] || 'muted'))
+const qrExpireTime = computed(() => Number(binding.value?.qrcode_expire_time || 0))
+const isPending = computed(() => binding.value?.state === 0)
+const isActive = computed(() => binding.value?.state === 1)
+const isDisabled = computed(() => binding.value?.state === 2)
+const isQrExpired = computed(() => {
+  if (binding.value?.expire_type === 'qrcode' || binding.value?.qrcode_expired) return true
+  if (!isPending.value || !qrExpireTime.value) return false
+  return now.value >= qrExpireTime.value
+})
+const isSessionExpired = computed(() => binding.value?.state === 3 && !isQrExpired.value)
+const isExpired = computed(() => isQrExpired.value || isSessionExpired.value)
+const showQr = computed(() => isPending.value && !isExpired.value && bindingQrSource.value)
+const stateType = computed(() => {
+  if (isActive.value) return 'active'
+  if (showQr.value) return 'pending'
+  if (isExpired.value) return 'expired'
+  return 'idle'
+})
+const bindingLabel = computed(() => {
+  if (isActive.value) return '已绑定'
+  if (showQr.value) return '待扫码'
+  if (isExpired.value) return '已过期'
+  if (isDisabled.value) return '已解绑'
+  return '未绑定'
+})
+const bindingColor = computed(() => ({ active: 'green', pending: 'orange', expired: 'red', idle: 'gray' }[stateType.value]))
+const stateEyebrow = computed(() => {
+  if (isActive.value) return 'CONNECTED'
+  if (showQr.value) return 'WAITING FOR SCAN'
+  if (isExpired.value) return 'EXPIRED'
+  return 'NOT CONNECTED'
+})
 const stateTitle = computed(() => {
 const stateTitle = computed(() => {
-  if (binding.value?.state === 1) return '微信已连接'
-  if (binding.value?.state === 0) return '等待扫码确认'
-  if (binding.value?.state === 3) return '登录已过期'
+  if (isActive.value) return '微信已连接'
+  if (showQr.value) return '等待扫码确认'
+  if (isQrExpired.value) return '二维码已过期'
+  if (isSessionExpired.value) return '微信登录已过期'
   return '尚未绑定微信'
   return '尚未绑定微信'
 })
 })
 const stateDescription = computed(() => {
 const stateDescription = computed(() => {
-  if (binding.value?.state === 1) return '你可以在微信中随时随地与小妍助理对话'
-  if (binding.value?.state === 0) return '扫码后请在微信中确认授权,绑定完成后二维码会自动收起'
-  if (binding.value?.state === 3) return '超过 24 小时未向小妍助理发送消息,需要重新扫码登录'
-  return '绑定后可在微信中接收乐跑通知,并与小妍助理对话'
+  if (isActive.value) return '小妍助理可通过微信接收消息,乐跑通知也可投递到当前微信会话'
+  if (showQr.value) return '使用微信扫码并确认授权'
+  if (isQrExpired.value) return '当前二维码不可继续使用,请重新生成后完成绑定'
+  if (isSessionExpired.value) return '超过 24 小时未向小妍助理发送消息,请重新生成二维码完成绑定'
+  return '绑定后可在微信中接收乐跑通知,并继续使用小妍助理对话'
+})
+const emptyTitle = computed(() => {
+  if (isActive.value) return '连接运行中'
+  if (isExpired.value) return '当前二维码不可用'
+  return '准备生成绑定二维码'
 })
 })
 const emptyText = computed(() => {
 const emptyText = computed(() => {
-  if (binding.value?.state === 1) return '当前微信已绑定,无需扫码'
-  if (binding.value?.state === 3) return '登录已过期,请重新生成二维码。'
-  return '点击下方按钮生成二维码。'
+  if (isActive.value) return '保持 24 小时内至少发送一条微信消息,可维持登录状态'
+  if (isExpired.value) return '重新生成后请在 5 分钟内扫码确认'
+  return '点击下方按钮生成新的微信绑定二维码'
+})
+const showCreateButton = computed(() => !isActive.value && (!isPending.value || isQrExpired.value || isSessionExpired.value))
+const showUnbindButton = computed(() => isActive.value || isSessionExpired.value)
+const createButtonText = computed(() => (isExpired.value ? '重新生成二维码' : '生成绑定二维码'))
+const keepAliveText = computed(() => (isActive.value ? '24 小时内发送消息' : '绑定后生效'))
+const qrRemainText = computed(() => {
+  if (!showQr.value || !qrExpireTime.value) return '-'
+  const remain = Math.max(0, Math.ceil((qrExpireTime.value - now.value) / 1000))
+  const min = Math.floor(remain / 60)
+  const sec = String(remain % 60).padStart(2, '0')
+  return `${min}:${sec}`
 })
 })
 const lastActiveText = computed(() => {
 const lastActiveText = computed(() => {
   const time = Number(binding.value?.last_user_message_time || 0)
   const time = Number(binding.value?.last_user_message_time || 0)
@@ -122,21 +218,30 @@ const drawQrLogo = () => {
   const logo = new Image()
   const logo = new Image()
   logo.src = '/logo.svg'
   logo.src = '/logo.svg'
   logo.onload = () => {
   logo.onload = () => {
-    const canvasSize = canvas.width
-    const logoSize = canvasSize * 0.15
-    const x = (canvasSize - logoSize) / 2
-    const y = (canvasSize - logoSize) / 2
+    const logoSize = canvas.width * 0.15
+    const x = (canvas.width - logoSize) / 2
+    const y = (canvas.height - logoSize) / 2
+    ctx.save()
+    ctx.fillStyle = '#fff'
+    if (ctx.roundRect) {
+      ctx.beginPath()
+      ctx.roundRect(x - 6, y - 6, logoSize + 12, logoSize + 12, 8)
+      ctx.fill()
+    } else {
+      ctx.fillRect(x - 6, y - 6, logoSize + 12, logoSize + 12)
+    }
     ctx.drawImage(logo, x, y, logoSize, logoSize)
     ctx.drawImage(logo, x, y, logoSize, logoSize)
+    ctx.restore()
   }
   }
 }
 }
 
 
 const renderQrCode = async () => {
 const renderQrCode = async () => {
   await nextTick()
   await nextTick()
-  if (!qrcodeCanvas.value || bindingQrIsImage.value || !bindingQrSource.value || binding.value?.state !== 0) return
+  if (!qrcodeCanvas.value || bindingQrIsImage.value || !showQr.value) return
   await QRCode.toCanvas(qrcodeCanvas.value, bindingQrSource.value, {
   await QRCode.toCanvas(qrcodeCanvas.value, bindingQrSource.value, {
-    width: 220,
+    width: 236,
     margin: 1,
     margin: 1,
-    color: { dark: '#111827', light: '#ffffff' }
+    color: { dark: '#0f172a', light: '#ffffff' }
   })
   })
   drawQrLogo()
   drawQrLogo()
 }
 }
@@ -164,14 +269,23 @@ const createBinding = async () => {
   try {
   try {
     const res = await createWeixinBinding()
     const res = await createWeixinBinding()
     if (!res || res.code !== 0) return Message.warning(res?.msg || '创建绑定失败')
     if (!res || res.code !== 0) return Message.warning(res?.msg || '创建绑定失败')
-    syncBinding(res.data)
+    now.value = Date.now()
+    syncBinding({
+      ...res.data,
+      qrcode_expire_time: res.data?.qrcode_expire_time || Date.now() + QR_EXPIRE_MS
+    })
     await renderQrCode()
     await renderQrCode()
-    Message.success('请扫码确认绑定')
+    Message.success('二维码已生成')
   } finally {
   } finally {
     bindingLoading.value = false
     bindingLoading.value = false
   }
   }
 }
 }
 
 
+const refreshQrCode = async () => {
+  if (!showQr.value || bindingLoading.value) return
+  await createBinding()
+}
+
 const unbind = async () => {
 const unbind = async () => {
   bindingLoading.value = true
   bindingLoading.value = true
   try {
   try {
@@ -184,20 +298,44 @@ const unbind = async () => {
   }
   }
 }
 }
 
 
+const confirmUnbind = () => {
+  Modal.warning({
+    title: '确认解除微信绑定?',
+    content: '解除后将无法通过微信接收乐跑通知,也不能在微信中继续使用小妍助理。',
+    hideCancel: false,
+    okText: '解除绑定',
+    cancelText: '取消',
+    onOk: unbind
+  })
+}
+
+const startTimers = () => {
+  handleClose()
+  pollTimer = setInterval(() => {
+    if (visible.value && (isPending.value || isActive.value)) refreshBinding()
+  }, 5000)
+  clockTimer = setInterval(() => {
+    now.value = Date.now()
+  }, 1000)
+}
+
 const open = async (initialBinding = null) => {
 const open = async (initialBinding = null) => {
   visible.value = true
   visible.value = true
+  now.value = Date.now()
   if (initialBinding) syncBinding(initialBinding)
   if (initialBinding) syncBinding(initialBinding)
   await refreshBinding()
   await refreshBinding()
-  timer = setInterval(refreshBinding, 5000)
+  startTimers()
 }
 }
 
 
 const handleClose = () => {
 const handleClose = () => {
-  if (timer) clearInterval(timer)
-  timer = null
+  if (pollTimer) clearInterval(pollTimer)
+  if (clockTimer) clearInterval(clockTimer)
+  pollTimer = null
+  clockTimer = null
 }
 }
 
 
 onUnmounted(handleClose)
 onUnmounted(handleClose)
-watch(bindingQrSource, renderQrCode)
+watch([bindingQrSource, showQr], renderQrCode)
 
 
 defineExpose({ open })
 defineExpose({ open })
 </script>
 </script>
@@ -216,153 +354,555 @@ defineExpose({ open })
   width: 34px;
   width: 34px;
   height: 34px;
   height: 34px;
   border-radius: 8px;
   border-radius: 8px;
-  background: #ecfdf3;
-  color: #039855;
+  color: #00c16a;
+  background: rgba(0, 193, 106, 0.12);
 }
 }
 
 
-.bind-dialog {
-  display: grid;
-  grid-template-columns: minmax(0, 1fr) 220px;
-  gap: 16px;
+.bind-shell {
+  position: relative;
+  overflow: hidden;
+  padding: 18px;
+  border: 1px solid rgba(15, 23, 42, 0.08);
+  border-radius: 8px;
+  background:
+    linear-gradient(135deg, rgba(2, 6, 23, 0.96), rgba(15, 23, 42, 0.92)),
+    radial-gradient(circle at 80% 0%, rgba(0, 193, 106, 0.28), transparent 34%);
+  color: #f8fafc;
 }
 }
 
 
-.bind-dialog__main,
-.bind-dialog__side {
-  min-width: 0;
+.bind-shell::before {
+  position: absolute;
+  inset: 0;
+  pointer-events: none;
+  content: '';
+  background-image:
+    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
+    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
+  background-size: 26px 26px;
+  mask-image: linear-gradient(180deg, #000, transparent 88%);
+}
+
+.bind-shell--pending {
+  background:
+    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(2, 6, 23, 0.92)),
+    radial-gradient(circle at 80% 0%, rgba(247, 144, 9, 0.24), transparent 34%);
+}
+
+.bind-shell--expired {
+  background:
+    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(2, 6, 23, 0.94)),
+    radial-gradient(circle at 80% 0%, rgba(240, 68, 56, 0.24), transparent 34%);
+}
+
+.bind-hero,
+.bind-grid,
+.modal-actions {
+  position: relative;
+  z-index: 1;
 }
 }
 
 
-.bind-dialog__status {
+.bind-hero {
   display: flex;
   display: flex;
-  gap: 12px;
-  align-items: flex-start;
-  padding: 16px;
-  border-radius: 8px;
-  background: #f8fafc;
+  align-items: center;
+  justify-content: space-between;
+  gap: 16px;
+  margin-bottom: 18px;
 }
 }
 
 
-.bind-dialog__status strong {
-  display: block;
-  color: #101828;
-  font-size: 17px;
+.eyebrow {
+  color: #7dd3fc;
+  font-size: 12px;
+  font-weight: 800;
+  letter-spacing: 0;
 }
 }
 
 
-.bind-dialog__status p {
-  margin: 5px 0 0;
-  color: #667085;
-  line-height: 1.6;
+.bind-hero h2 {
+  margin: 6px 0;
+  color: #fff;
+  font-size: 24px;
+  line-height: 1.2;
+}
+
+.bind-hero p {
+  max-width: 520px;
+  margin: 0;
+  color: #cbd5e1;
+  line-height: 1.65;
 }
 }
 
 
-.pulse {
-  width: 12px;
-  height: 12px;
-  margin-top: 5px;
+.signal {
+  position: relative;
+  flex: 0 0 auto;
+  width: 62px;
+  height: 62px;
+  border: 1px solid rgba(148, 163, 184, 0.24);
   border-radius: 50%;
   border-radius: 50%;
-  background: #98a2b3;
-  box-shadow: 0 0 0 6px rgba(152, 162, 179, 0.14);
 }
 }
 
 
-.pulse--active {
-  background: #12b76a;
-  box-shadow: 0 0 0 6px rgba(18, 183, 106, 0.14);
+.signal span,
+.signal i {
+  position: absolute;
+  inset: 14px;
+  border-radius: 50%;
 }
 }
 
 
-.pulse--pending {
+.signal span {
+  background: #94a3b8;
+  box-shadow: 0 0 28px rgba(148, 163, 184, 0.55);
+}
+
+.signal i {
+  border: 1px solid rgba(255, 255, 255, 0.45);
+  animation: signal-ring 1.8s ease-out infinite;
+}
+
+.signal--active span {
+  background: #00c16a;
+  box-shadow: 0 0 32px rgba(0, 193, 106, 0.75);
+}
+
+.signal--pending span {
   background: #f79009;
   background: #f79009;
-  box-shadow: 0 0 0 6px rgba(247, 144, 9, 0.14);
+  box-shadow: 0 0 32px rgba(247, 144, 9, 0.75);
 }
 }
 
 
-.pulse--danger {
+.signal--expired span {
   background: #f04438;
   background: #f04438;
-  box-shadow: 0 0 0 6px rgba(240, 68, 56, 0.14);
+  box-shadow: 0 0 32px rgba(240, 68, 56, 0.75);
 }
 }
 
 
-.qr-stage,
-.empty-stage {
+.bind-grid {
   display: grid;
   display: grid;
-  place-items: center;
-  min-height: 310px;
-  margin-top: 14px;
-  border: 1px solid #eaecf0;
+  grid-template-columns: minmax(0, 1fr) 250px;
+  gap: 14px;
+}
+
+.scan-panel,
+.info-panel {
+  min-width: 0;
+  border: 1px solid rgba(226, 232, 240, 0.14);
   border-radius: 8px;
   border-radius: 8px;
-  background: linear-gradient(180deg, #ffffff, #f8fafc);
+  background: rgba(15, 23, 42, 0.64);
+  backdrop-filter: blur(14px);
+}
+
+.scan-panel {
+  display: grid;
+  place-items: center;
+  min-height: 330px;
+  padding: 20px;
+  text-align: center;
 }
 }
 
 
 .qr-frame {
 .qr-frame {
   display: grid;
   display: grid;
   place-items: center;
   place-items: center;
-  width: 244px;
-  height: 244px;
+  width: 270px;
+  height: 270px;
+  border: 1px solid rgba(255, 255, 255, 0.18);
   border-radius: 8px;
   border-radius: 8px;
   background: #fff;
   background: #fff;
-  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
+  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
 }
 }
 
 
 .qr-frame img,
 .qr-frame img,
 .qr-canvas {
 .qr-canvas {
-  width: 220px;
-  height: 220px;
+  width: 236px;
+  height: 236px;
 }
 }
 
 
-.qr-tip,
-.empty-stage {
-  color: #667085;
+.qr-meta {
+  display: inline-flex;
+  align-items: center;
+  gap: 10px;
+  margin-top: 16px;
+  color: #cbd5e1;
+}
+
+.qr-meta strong {
+  color: #facc15;
+  font-size: 18px;
 }
 }
 
 
-.empty-stage__icon {
+.state-visual {
   display: grid;
   display: grid;
   place-items: center;
   place-items: center;
-  width: 58px;
-  height: 58px;
-  margin-bottom: 10px;
+  width: 82px;
+  height: 82px;
+  margin-bottom: 18px;
+  border: 1px solid rgba(125, 211, 252, 0.26);
   border-radius: 8px;
   border-radius: 8px;
-  background: #eef4ff;
-  color: #2970ff;
-  font-size: 24px;
+  color: #7dd3fc;
+  background: rgba(14, 165, 233, 0.12);
+  font-size: 34px;
+}
+
+.scan-panel > strong {
+  color: #fff;
+  font-size: 18px;
+}
+
+.scan-panel > p {
+  max-width: 360px;
+  margin: 8px 0 0;
+  color: #cbd5e1;
+  line-height: 1.6;
 }
 }
 
 
-.bind-dialog__side {
+.info-panel {
   display: grid;
   display: grid;
-  gap: 10px;
   align-content: start;
   align-content: start;
+  gap: 10px;
+  padding: 14px;
 }
 }
 
 
-.side-card {
+.metric,
+.capabilities {
   display: grid;
   display: grid;
   gap: 8px;
   gap: 8px;
-  padding: 14px;
-  border: 1px solid #eaecf0;
+  padding: 12px;
+  border: 1px solid rgba(226, 232, 240, 0.12);
   border-radius: 8px;
   border-radius: 8px;
-  background: #fff;
+  background: rgba(255, 255, 255, 0.05);
 }
 }
 
 
-.side-card span {
-  color: #667085;
+.metric span,
+.capabilities span {
+  color: #94a3b8;
   font-size: 12px;
   font-size: 12px;
 }
 }
 
 
-.side-card strong {
-  color: #101828;
+.metric strong {
+  color: #f8fafc;
+}
+
+.capabilities ul {
+  display: grid;
+  gap: 7px;
+  margin: 0;
+  padding: 0;
+  color: #e2e8f0;
+  list-style: none;
+}
+
+.capabilities li::before {
+  margin-right: 7px;
+  color: #00c16a;
+  content: '•';
 }
 }
 
 
 .modal-actions {
 .modal-actions {
   display: flex;
   display: flex;
   flex-wrap: wrap;
   flex-wrap: wrap;
   gap: 10px;
   gap: 10px;
-  margin-top: 18px;
+  margin-top: 16px;
 }
 }
 
 
-@media (max-width: 720px) {
-  .bind-dialog {
+@keyframes signal-ring {
+  from {
+    opacity: 0.8;
+    transform: scale(0.7);
+  }
+
+  to {
+    opacity: 0;
+    transform: scale(1.7);
+  }
+}
+
+@media (max-width: 760px) {
+  .bind-shell {
+    padding: 14px;
+  }
+
+  .bind-hero {
+    align-items: flex-start;
+  }
+
+  .signal {
+    width: 46px;
+    height: 46px;
+  }
+
+  .signal span,
+  .signal i {
+    inset: 11px;
+  }
+
+  .bind-grid {
     grid-template-columns: 1fr;
     grid-template-columns: 1fr;
   }
   }
 
 
-  .qr-stage,
-  .empty-stage {
-    min-height: 280px;
+  .scan-panel {
+    min-height: 286px;
+  }
+
+  .qr-frame {
+    width: 236px;
+    height: 236px;
+  }
+
+  .qr-frame img,
+  .qr-canvas {
+    width: 208px;
+    height: 208px;
   }
   }
 
 
   .modal-actions .arco-btn {
   .modal-actions .arco-btn {
     flex: 1 1 100%;
     flex: 1 1 100%;
   }
   }
 }
 }
+
+/* Visual refresh: keep the existing state logic, align the card with the AI assistant light theme. */
+.modal-title {
+  color: #1d2129;
+}
+
+.modal-title__icon {
+  color: #0f9f7a;
+  background: linear-gradient(135deg, rgba(236, 253, 243, 0.96), rgba(239, 246, 255, 0.96));
+  box-shadow: 0 8px 20px rgba(43, 179, 169, 0.12);
+}
+
+.bind-shell,
+.bind-shell--pending,
+.bind-shell--expired {
+  padding: 20px;
+  border-color: rgba(43, 179, 169, 0.16);
+  background:
+    radial-gradient(circle at 12% 8%, rgba(43, 179, 169, 0.12), transparent 32%),
+    radial-gradient(circle at 92% 6%, rgba(103, 87, 245, 0.1), transparent 30%),
+    linear-gradient(135deg, #f7f9ff 0%, #ffffff 50%, #f3fbf8 100%);
+  color: #1d2129;
+  box-shadow: 0 20px 48px rgba(35, 48, 86, 0.08);
+}
+
+.bind-shell--pending {
+  background:
+    radial-gradient(circle at 12% 8%, rgba(247, 144, 9, 0.1), transparent 32%),
+    radial-gradient(circle at 92% 6%, rgba(103, 87, 245, 0.1), transparent 30%),
+    linear-gradient(135deg, #fffaf3 0%, #ffffff 48%, #f5fbff 100%);
+}
+
+.bind-shell--expired {
+  background:
+    radial-gradient(circle at 12% 8%, rgba(240, 68, 56, 0.09), transparent 32%),
+    radial-gradient(circle at 92% 6%, rgba(103, 87, 245, 0.08), transparent 30%),
+    linear-gradient(135deg, #fff7f7 0%, #ffffff 48%, #f7f9ff 100%);
+}
+
+.bind-shell::before {
+  background-image:
+    linear-gradient(rgba(116, 89, 255, 0.055) 1px, transparent 1px),
+    linear-gradient(90deg, rgba(43, 179, 169, 0.055) 1px, transparent 1px);
+  background-size: 24px 24px;
+  mask-image: linear-gradient(180deg, #000, transparent 86%);
+}
+
+.eyebrow {
+  color: #0f9f7a;
+}
+
+.bind-shell--pending .eyebrow {
+  color: #d97706;
+}
+
+.bind-shell--expired .eyebrow {
+  color: #d92d20;
+}
+
+.bind-hero h2 {
+  color: #1d2129;
+}
+
+.bind-hero p {
+  color: #667085;
+}
+
+.signal {
+  width: 58px;
+  height: 58px;
+  border-color: rgba(43, 179, 169, 0.18);
+  background: rgba(255, 255, 255, 0.72);
+  box-shadow: 0 14px 34px rgba(35, 48, 86, 0.08);
+}
+
+.signal span {
+  background: #98a2b3;
+  box-shadow: 0 0 24px rgba(152, 162, 179, 0.28);
+}
+
+.signal i {
+  border-color: rgba(43, 179, 169, 0.3);
+}
+
+.signal--active span {
+  background: #12b76a;
+  box-shadow: 0 0 28px rgba(18, 183, 106, 0.38);
+}
+
+.signal--pending span {
+  background: #f79009;
+  box-shadow: 0 0 28px rgba(247, 144, 9, 0.34);
+}
+
+.signal--expired span {
+  background: #f04438;
+  box-shadow: 0 0 28px rgba(240, 68, 56, 0.34);
+}
+
+.scan-panel,
+.info-panel {
+  border-color: rgba(17, 24, 39, 0.075);
+  background: rgba(255, 255, 255, 0.76);
+  box-shadow:
+    0 14px 32px rgba(35, 48, 86, 0.07),
+    inset 0 1px 0 rgba(255, 255, 255, 0.82);
+}
+
+.qr-frame {
+  position: relative;
+  border-color: rgba(43, 179, 169, 0.16);
+  border-radius: 14px;
+  box-shadow:
+    0 22px 48px rgba(35, 48, 86, 0.12),
+    0 0 0 8px rgba(43, 179, 169, 0.055);
+}
+
+.qr-frame--clickable {
+  cursor: pointer;
+  outline: none;
+  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
+}
+
+.qr-frame--clickable:hover,
+.qr-frame--clickable:focus-visible {
+  border-color: rgba(43, 179, 169, 0.34);
+  box-shadow:
+    0 24px 52px rgba(35, 48, 86, 0.14),
+    0 0 0 8px rgba(43, 179, 169, 0.08);
+  transform: translateY(-1px);
+}
+
+.qr-frame--loading {
+  cursor: wait;
+}
+
+.qr-frame--loading .qr-canvas,
+.qr-frame--loading img {
+  opacity: 0.56;
+}
+
+.qr-frame__action {
+  position: absolute;
+  right: 12px;
+  bottom: 12px;
+  display: inline-flex;
+  align-items: center;
+  min-height: 24px;
+  padding: 0 9px;
+  border: 1px solid rgba(43, 179, 169, 0.18);
+  border-radius: 999px;
+  color: #0f766e;
+  background: rgba(255, 255, 255, 0.9);
+  box-shadow: 0 8px 18px rgba(35, 48, 86, 0.1);
+  font-size: 12px;
+  font-weight: 700;
+  line-height: 1;
+  opacity: 0;
+  transform: translateY(4px);
+  transition: opacity 0.18s ease, transform 0.18s ease;
+}
+
+.qr-frame--clickable:hover .qr-frame__action,
+.qr-frame--clickable:focus-visible .qr-frame__action,
+.qr-frame--loading .qr-frame__action {
+  opacity: 1;
+  transform: translateY(0);
+}
+
+.qr-frame::before,
+.qr-frame::after {
+  content: none;
+}
+
+.qr-frame img,
+.qr-canvas {
+  border-radius: 8px;
+}
+
+.qr-meta {
+  padding: 8px 12px;
+  border: 1px solid rgba(247, 144, 9, 0.16);
+  border-radius: 999px;
+  color: #667085;
+  background: rgba(255, 250, 235, 0.86);
+}
+
+.qr-meta strong {
+  color: #b54708;
+}
+
+.state-visual {
+  border-color: rgba(43, 179, 169, 0.18);
+  color: #0f9f7a;
+  background: linear-gradient(135deg, rgba(236, 253, 243, 0.96), rgba(239, 246, 255, 0.96));
+  box-shadow: 0 14px 34px rgba(43, 179, 169, 0.12);
+}
+
+.scan-panel > strong {
+  color: #1d2129;
+}
+
+.scan-panel > p {
+  color: #667085;
+}
+
+.metric,
+.capabilities {
+  padding: 13px;
+  border-color: rgba(17, 24, 39, 0.065);
+  background: rgba(255, 255, 255, 0.68);
+  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
+}
+
+.metric:hover,
+.capabilities:hover {
+  border-color: rgba(43, 179, 169, 0.2);
+  box-shadow: 0 12px 26px rgba(35, 48, 86, 0.07);
+  transform: translateY(-1px);
+}
+
+.metric span,
+.capabilities span {
+  color: #667085;
+}
+
+.metric strong,
+.capabilities ul {
+  color: #1d2129;
+}
+
+.capabilities li::before {
+  color: #12b76a;
+}
+
+.modal-actions :deep(.arco-btn-primary) {
+  border: 0;
+  background: linear-gradient(135deg, #6757f5, #20b7a7);
+  box-shadow: 0 10px 22px rgba(43, 179, 169, 0.24);
+}
+
+@media (max-width: 760px) {
+  .bind-shell,
+  .bind-shell--pending,
+  .bind-shell--expired {
+    padding: 14px;
+  }
+
+  .signal {
+    width: 46px;
+    height: 46px;
+  }
+}
 </style>
 </style>

+ 102 - 4
src/pages/ai/assistant/index.vue

@@ -85,6 +85,11 @@
             <p>{{ item.hint }}</p>
             <p>{{ item.hint }}</p>
           </div>
           </div>
         </div>
         </div>
+        <div class="quota-summary">
+          <span>额度策略</span>
+          <strong>{{ isVip ? 'VIP 专属额度' : '基础网页额度' }}</strong>
+          <p>{{ quotaSummaryText }}</p>
+        </div>
       </article>
       </article>
 
 
       <article class="panel weixin-panel">
       <article class="panel weixin-panel">
@@ -103,6 +108,16 @@
             <span>{{ weixinDescription }}</span>
             <span>{{ weixinDescription }}</span>
           </div>
           </div>
         </div>
         </div>
+        <div class="weixin-detail-grid">
+          <div class="weixin-detail">
+            <span>最近消息</span>
+            <strong>{{ lastActiveText }}</strong>
+          </div>
+          <div class="weixin-detail">
+            <span>登录保持</span>
+            <strong>{{ keepAliveText }}</strong>
+          </div>
+        </div>
         <a-button class="weixin-action" type="primary" :disabled="!isVip" @click="openBindingModal">
         <a-button class="weixin-action" type="primary" :disabled="!isVip" @click="openBindingModal">
           <template #icon><icon-scan /></template>
           <template #icon><icon-scan /></template>
           {{ weixin?.bound ? '查看绑定' : '绑定微信' }}
           {{ weixin?.bound ? '查看绑定' : '绑定微信' }}
@@ -261,6 +276,10 @@ const quotaItems = computed(() => {
     build('微信对话', quota.value.wechat, theme.value.secondary)
     build('微信对话', quota.value.wechat, theme.value.secondary)
   ]
   ]
 })
 })
+const quotaSummaryText = computed(() => {
+  if (isVip.value) return '网页与微信额度独立统计,VIP可享受更多额度'
+  return '当前可使用网页对话额度,开通 VIP 后可启用微信专属额度'
+})
 
 
 const weixinTagText = computed(() => ({ 0: '待扫码', 1: '已绑定', 2: '已解绑', 3: '已过期' }[weixin.value?.state] || '未绑定'))
 const weixinTagText = computed(() => ({ 0: '待扫码', 1: '已绑定', 2: '已解绑', 3: '已过期' }[weixin.value?.state] || '未绑定'))
 const weixinTagColor = computed(() => ({ 0: 'orange', 1: 'green', 2: 'gray', 3: 'red' }[weixin.value?.state] || 'gray'))
 const weixinTagColor = computed(() => ({ 0: 'orange', 1: 'green', 2: 'gray', 3: 'red' }[weixin.value?.state] || 'gray'))
@@ -281,6 +300,12 @@ const weixinDescription = computed(() => {
   if (weixin.value?.bound) return '可在微信中随时随地处理事务'
   if (weixin.value?.bound) return '可在微信中随时随地处理事务'
   return '在弹窗中扫码完成授权。'
   return '在弹窗中扫码完成授权。'
 })
 })
+const keepAliveText = computed(() => (weixin.value?.bound ? '24 小时内消息' : '绑定后生效'))
+const lastActiveText = computed(() => {
+  const time = Number(weixin.value?.last_user_message_time || 0)
+  if (!time) return '暂无记录'
+  return new Date(time).toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false })
+})
 
 
 const accountChartOptions = computed(() => ({
 const accountChartOptions = computed(() => ({
   color: ['#10b981', '#f59e0b'],
   color: ['#10b981', '#f59e0b'],
@@ -661,12 +686,14 @@ onUnmounted(() => {
 .content-grid {
 .content-grid {
   display: grid;
   display: grid;
   grid-template-columns: repeat(3, minmax(0, 1fr));
   grid-template-columns: repeat(3, minmax(0, 1fr));
-  align-items: start;
+  align-items: stretch;
   gap: 12px;
   gap: 12px;
   margin-top: 12px;
   margin-top: 12px;
 }
 }
 
 
 .panel {
 .panel {
+  display: flex;
+  flex-direction: column;
   min-width: 0;
   min-width: 0;
   padding: 18px;
   padding: 18px;
 }
 }
@@ -726,9 +753,14 @@ onUnmounted(() => {
 }
 }
 
 
 .chart-shell {
 .chart-shell {
+  flex: 1;
   min-height: 220px;
   min-height: 220px;
 }
 }
 
 
+.quota-panel {
+  gap: 0;
+}
+
 .quota-list {
 .quota-list {
   display: grid;
   display: grid;
   gap: 18px;
   gap: 18px;
@@ -757,11 +789,43 @@ onUnmounted(() => {
   font-size: 12px;
   font-size: 12px;
 }
 }
 
 
+.quota-summary {
+  display: grid;
+  gap: 6px;
+  margin-top: auto;
+  padding: 14px;
+  border: 1px solid color-mix(in srgb, var(--assistant-primary) 14%, transparent);
+  border-radius: 8px;
+  background:
+    linear-gradient(135deg, color-mix(in srgb, var(--assistant-primary) 7%, white), rgba(255, 255, 255, 0.82));
+}
+
+.quota-summary span {
+  color: var(--assistant-muted);
+  font-size: 12px;
+}
+
+.quota-summary strong {
+  color: var(--assistant-text);
+  font-size: 15px;
+}
+
+.quota-summary p {
+  margin: 0;
+  color: var(--assistant-muted);
+  font-size: 12px;
+  line-height: 1.6;
+}
+
+.weixin-panel {
+  justify-content: flex-start;
+}
+
 .weixin-status-card {
 .weixin-status-card {
   display: flex;
   display: flex;
-  align-items: flex-start;
+  align-items: center;
   gap: 13px;
   gap: 13px;
-  padding: 15px;
+  padding: 16px;
   border: 1px solid color-mix(in srgb, var(--assistant-secondary) 18%, transparent);
   border: 1px solid color-mix(in srgb, var(--assistant-secondary) 18%, transparent);
   border-radius: 8px;
   border-radius: 8px;
   background: color-mix(in srgb, var(--assistant-secondary) 8%, white);
   background: color-mix(in srgb, var(--assistant-secondary) 8%, white);
@@ -791,9 +855,39 @@ onUnmounted(() => {
   line-height: 1.6;
   line-height: 1.6;
 }
 }
 
 
+.weixin-detail-grid {
+  display: grid;
+  grid-template-columns: repeat(2, minmax(0, 1fr));
+  gap: 10px;
+  margin-top: 14px;
+}
+
+.weixin-detail {
+  display: grid;
+  gap: 7px;
+  min-width: 0;
+  padding: 14px;
+  border: 1px solid rgba(17, 24, 39, 0.07);
+  border-radius: 8px;
+  background: rgba(255, 255, 255, 0.68);
+}
+
+.weixin-detail span {
+  color: var(--assistant-muted);
+  font-size: 12px;
+}
+
+.weixin-detail strong {
+  overflow: hidden;
+  color: var(--assistant-text);
+  font-size: 13px;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+
 .weixin-action {
 .weixin-action {
   width: 100%;
   width: 100%;
-  margin-top: 16px;
+  margin-top: 18px;
 }
 }
 
 
 .ability-grid {
 .ability-grid {
@@ -912,6 +1006,10 @@ onUnmounted(() => {
     font-size: 24px;
     font-size: 24px;
   }
   }
 
 
+    .weixin-detail-grid {
+      grid-template-columns: 1fr;
+    }
+
   .ability-button {
   .ability-button {
     min-height: 72px;
     min-height: 72px;
   }
   }