| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <template>
- <div class="token-page">
- <div class="top-bar">
- <el-button type="info" plain @click="goBack">返回首页</el-button>
- </div>
- <el-card class="token-card">
- <h2>更新 Token / Cookie</h2>
- <el-form :model="form" label-width="100px">
- <el-form-item label="gh_id">
- <el-input v-model="form.gzh_id" placeholder="请输入公众号 ID" clearable />
- </el-form-item>
- <el-form-item label="Token">
- <el-input v-model="form.token" placeholder="请输入 Token" clearable />
- </el-form-item>
- <el-form-item label="Cookie">
- <el-input
- v-model="form.cookie"
- placeholder="请输入 Cookie"
- type="textarea"
- rows="4"
- clearable
- />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="onSave" :loading="loading" style="width: 120px">
- 保存
- </el-button>
- <el-button @click="onReset" :disabled="loading" style="width: 120px">
- 重置
- </el-button>
- </el-form-item>
- </el-form>
- </el-card>
- </div>
- </template>
- <script setup lang="ts">
- import { ref } from 'vue'
- import { useRouter } from 'vue-router'
- import { ElMessage } from 'element-plus'
- import axios from 'axios'
- import { API_CONFIG, API_ENDPOINTS } from '../config/api'
- const router = useRouter()
- interface TokenForm {
- gzh_id: string
- token: string
- cookie: string
- }
- const form = ref<TokenForm>({
- gzh_id: '',
- token: '',
- cookie: '',
- })
- const loading = ref(false)
- const onSave = async () => {
- if (!form.value.gzh_id || !form.value.token || !form.value.cookie) {
- ElMessage.warning('请填写完整信息(gh_id / Token / Cookie)')
- return
- }
- loading.value = true
- try {
- const res = await axios.post(`${API_CONFIG.BASE_URL}${API_ENDPOINTS.SAVE_TOKEN}`, {
- gzh_id: form.value.gzh_id,
- token: form.value.token,
- cookie: form.value.cookie,
- })
- if (res.data?.success) {
- ElMessage.success('更新成功')
- form.value = { gzh_id: '', token: '', cookie: '' }
- } else {
- ElMessage.error(res.data?.error || '更新失败')
- }
- } catch (err) {
- console.error('保存请求出错:', err)
- ElMessage.error('请求异常,请稍后重试')
- } finally {
- loading.value = false
- }
- }
- const onReset = () => {
- form.value = { gzh_id: '', token: '', cookie: '' }
- }
- const goBack = () => {
- router.push('/welcome')
- }
- </script>
- <style scoped>
- .token-page {
- background: linear-gradient(180deg, #f6f8fb, #e8ecf3);
- min-height: 100vh;
- display: flex;
- flex-direction: column;
- }
- .top-bar {
- padding: 12px 16px;
- background: #fff;
- border-bottom: 1px solid #f0f2f5;
- display: flex;
- justify-content: flex-start;
- }
- .token-card {
- width: 520px;
- margin: 80px auto 0;
- padding: 40px 30px 30px;
- box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
- border-radius: 14px;
- background: #fff;
- }
- h2 {
- text-align: center;
- font-size: 22px;
- margin-bottom: 30px;
- color: #333;
- font-weight: 600;
- }
- </style>
|