Compare commits
2 Commits
d6d2a4ad96
...
201ee8c0f9
| Author | SHA1 | Date | |
|---|---|---|---|
| 201ee8c0f9 | |||
| 58a29f2b9d |
@@ -3,6 +3,7 @@ package controller
|
||||
import (
|
||||
"dypid/internal/db"
|
||||
"dypid/internal/global"
|
||||
"dypid/internal/model"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -11,7 +12,11 @@ import (
|
||||
)
|
||||
|
||||
func ListTokenHandler(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"result": db.ListToken()})
|
||||
c.JSON(http.StatusOK, model.APIResponse{
|
||||
Code: 200,
|
||||
Message: "获取所有token成功",
|
||||
Data: db.ListToken(),
|
||||
})
|
||||
}
|
||||
|
||||
func CreateTokenHandler(c *gin.Context) {
|
||||
@@ -23,24 +28,37 @@ func CreateTokenHandler(c *gin.Context) {
|
||||
Notes string `form:"notes"`
|
||||
}{}
|
||||
if err := c.ShouldBindQuery(&input); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "参数不能为空 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//检查Token是否存在
|
||||
if db.CheckToken(input.Token) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "创建Token失败,Token已经存在"})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "创建Token失败,Token已经存在,请勿重复创建",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//创建Token
|
||||
err := db.CreateToken(input.Token, input.DedupObject, input.DataFormat, input.Notes)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusInternalServerError, model.APIResponse{
|
||||
Code: 500,
|
||||
Message: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//返回
|
||||
c.JSON(http.StatusOK, gin.H{"result": "ok"})
|
||||
c.JSON(http.StatusOK, model.APIResponse{
|
||||
Code: 200,
|
||||
Message: "创建Token成功",
|
||||
})
|
||||
}
|
||||
|
||||
func UpdateTokenHandler(c *gin.Context) {
|
||||
@@ -51,22 +69,35 @@ func UpdateTokenHandler(c *gin.Context) {
|
||||
Notes string `form:"notes"`
|
||||
}{}
|
||||
if err := c.ShouldBindQuery(&input); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "参数不能为空 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//检查Token是否存在
|
||||
if !db.CheckToken(input.Token) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "更改失败,Token不存在"})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "更改失败,Token不存在",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
err := db.UpdateToken(input.Token, input.DedupObject, input.DataFormat, input.Notes)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusInternalServerError, model.APIResponse{
|
||||
Code: 500,
|
||||
Message: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"result": "ok"})
|
||||
c.JSON(http.StatusOK, model.APIResponse{
|
||||
Code: 200,
|
||||
Message: "更改Token成功",
|
||||
})
|
||||
}
|
||||
|
||||
func DeleteTokenHandler(c *gin.Context) {
|
||||
@@ -74,22 +105,35 @@ func DeleteTokenHandler(c *gin.Context) {
|
||||
Token string `form:"token" binding:"required"`
|
||||
}{}
|
||||
if err := c.ShouldBindQuery(&input); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数不能为空 " + err.Error()})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "参数不能为空 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//检查Token是否存在
|
||||
if !db.CheckToken(input.Token) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "删除Token失败,Token不存在"})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "删除Token失败,Token不存在",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
err := db.DeleteToken(input.Token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusInternalServerError, model.APIResponse{
|
||||
Code: 500,
|
||||
Message: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"result": "ok"})
|
||||
c.JSON(http.StatusOK, model.APIResponse{
|
||||
Code: 200,
|
||||
Message: "删除Token成功",
|
||||
})
|
||||
}
|
||||
|
||||
func GetTokenInfoHandler(c *gin.Context) {
|
||||
@@ -97,23 +141,36 @@ func GetTokenInfoHandler(c *gin.Context) {
|
||||
Token string `form:"token" binding:"required"`
|
||||
}{}
|
||||
if err := c.ShouldBindQuery(&input); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Token不能为空"})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "参数不能为空 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//检查Token是否存在
|
||||
if !db.CheckToken(input.Token) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "获取信息失败,Token不存在"})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "获取信息失败,Token不存在",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
dedupObject, err := db.GetDedupObject(input.Token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "获取去重对象失败 " + err.Error()})
|
||||
c.JSON(http.StatusInternalServerError, model.APIResponse{
|
||||
Code: 500,
|
||||
Message: "获取去重对象失败 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
dataFormat, err := db.GetDataFormat(input.Token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "获取数据格式失败 " + err.Error()})
|
||||
c.JSON(http.StatusInternalServerError, model.APIResponse{
|
||||
Code: 500,
|
||||
Message: "获取数据格式失败 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -130,7 +187,11 @@ func GetTokenInfoHandler(c *gin.Context) {
|
||||
output.DedupItemsNumber = global.RDB.CFInfo(global.RCtx, "dedup:"+input.Token+":"+dedupObject).Val().NumItemsInserted
|
||||
output.CacheListNumber = global.RDB.LLen(global.RCtx, "list:"+input.Token).Val()
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"result": output})
|
||||
c.JSON(http.StatusOK, model.APIResponse{
|
||||
Code: 200,
|
||||
Message: "获取Token信息成功",
|
||||
Data: output,
|
||||
})
|
||||
}
|
||||
|
||||
func DeleteTokenInfoHandler(c *gin.Context) {
|
||||
@@ -142,24 +203,29 @@ func DeleteTokenInfoHandler(c *gin.Context) {
|
||||
BothNumber string `form:"both_number"`
|
||||
}{}
|
||||
if err := c.ShouldBindQuery(&input); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Token不能为空"})
|
||||
return
|
||||
}
|
||||
//检查Token是否存在
|
||||
if !db.CheckToken(input.Token) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "删除Token失败,Token不存在"})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "参数不能为空 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//检查token是否存在
|
||||
_, err := db.GetDedupObject(input.Token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Token不存在" + err.Error()})
|
||||
//检查Token是否存在
|
||||
if !db.CheckToken(input.Token) {
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "删除Token信息失败,Token不存在",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//获取去重对象
|
||||
dedupObject, err := db.GetDedupObject(input.Token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "获取去重对象失败 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -173,7 +239,10 @@ func DeleteTokenInfoHandler(c *gin.Context) {
|
||||
default:
|
||||
num, err := strconv.Atoi(input.DedupBF)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "dedup_bf数量设置错误 " + err.Error()})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "dedup_bf数量设置错误 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -196,7 +265,10 @@ func DeleteTokenInfoHandler(c *gin.Context) {
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusInternalServerError, model.APIResponse{
|
||||
Code: 500,
|
||||
Message: "删除去重对象失败 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -213,7 +285,10 @@ func DeleteTokenInfoHandler(c *gin.Context) {
|
||||
default:
|
||||
num, err := strconv.Atoi(input.CacheList)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "cache_list数量设置错误 " + err.Error()})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 400,
|
||||
Message: "cache_list数量设置错误 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -226,7 +301,10 @@ func DeleteTokenInfoHandler(c *gin.Context) {
|
||||
default:
|
||||
num, err := strconv.Atoi(input.BothNumber)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "both_number数量设置错误 " + err.Error()})
|
||||
c.JSON(http.StatusBadRequest, model.APIResponse{
|
||||
Code: 500,
|
||||
Message: "both_number数量设置错误 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -248,12 +326,18 @@ func DeleteTokenInfoHandler(c *gin.Context) {
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusInternalServerError, model.APIResponse{
|
||||
Code: 500,
|
||||
Message: "删除Token信息失败 " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//输出信息
|
||||
c.JSON(http.StatusOK, gin.H{"result": "ok"})
|
||||
c.JSON(http.StatusOK, model.APIResponse{
|
||||
Code: 200,
|
||||
Message: "删除Token信息成功",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package model
|
||||
|
||||
type APIResponse struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data any `json:"data"`
|
||||
}
|
||||
@@ -22,7 +22,10 @@ func main() {
|
||||
//初始化一个http服务对象
|
||||
gin.SetMode(config.APPConfig.RunMode)
|
||||
r := gin.New()
|
||||
r.Use(gin.Recovery())
|
||||
if config.APPConfig.RunMode == "debug" {
|
||||
r.Use(gin.Logger()) //日志处理
|
||||
}
|
||||
r.Use(gin.Recovery()) //错误处理
|
||||
r.Use(cors.Default()) //跨域设置
|
||||
|
||||
//注册网页服务(Vue)
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import axios from "axios";
|
||||
|
||||
const axiosInstance = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL,
|
||||
})
|
||||
|
||||
export default {
|
||||
getTokenList: () =>
|
||||
axiosInstance.get('/api/token'),
|
||||
|
||||
createToken: (params: {
|
||||
token: string
|
||||
dedup_object: string
|
||||
data_format: string
|
||||
notes: string
|
||||
}) =>
|
||||
axiosInstance.post('/api/token', {}, {params}),
|
||||
|
||||
updateToken: (params: {
|
||||
token: string
|
||||
dedup_object?: string
|
||||
data_format?: string
|
||||
notes?: string
|
||||
}) =>
|
||||
axiosInstance.put('/api/token', {}, {params}),
|
||||
|
||||
deleteToken: (params: {
|
||||
token: string
|
||||
}) =>
|
||||
axiosInstance.delete('/api/token', {params}),
|
||||
|
||||
getTokenInfo: (params: {
|
||||
token: string
|
||||
}) =>
|
||||
axiosInstance.get('/api/token/info', {params}),
|
||||
|
||||
deleteTokenInfo: (params: {
|
||||
token: string
|
||||
dedup_bf?: string
|
||||
cache_list?: string
|
||||
both_number?: string
|
||||
}) =>
|
||||
axiosInstance.delete('/api/token/info', {params}),
|
||||
|
||||
uploadData: (params: {
|
||||
data: string
|
||||
token: string
|
||||
}) =>
|
||||
axiosInstance.post('/api/data', {}, {params}),
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const instance = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL,
|
||||
});
|
||||
|
||||
export default instance;
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import {computed, ref} from "vue"
|
||||
import axios from "@/axios.ts"
|
||||
import api from "@/api"
|
||||
import {ElMessage} from 'element-plus'
|
||||
import {Upload} from '@element-plus/icons-vue'
|
||||
|
||||
@@ -42,12 +42,7 @@ const handleUpload = async () => {
|
||||
|
||||
for (const line of lines) {
|
||||
try {
|
||||
await axios.post('/api/data', {}, {
|
||||
params: {
|
||||
data: line,
|
||||
token: props.token || ''
|
||||
}
|
||||
})
|
||||
await api.uploadData({data: line, token: props.token || ''})
|
||||
uploadedCount.value++
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.response?.data?.error || '上传失败')
|
||||
|
||||
+21
-15
@@ -1,14 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import {onMounted, onUnmounted, ref} from 'vue'
|
||||
import axios from "@/axios.ts"
|
||||
import api from "@/api"
|
||||
import {useRoute} from "vue-router"
|
||||
import {ElMessage} from "element-plus"
|
||||
import {DataAnalysis, Document, Key, Search, Upload, Warning} from '@element-plus/icons-vue'
|
||||
import AddDataDialog from "@/components/AddDataDialog.vue";
|
||||
|
||||
const route = useRoute()
|
||||
const token = ref(route.query.token as string || '')
|
||||
const input = ref(route.query.token as string || '')
|
||||
const inputToken = ref(route.query.token as string || '')
|
||||
const result = ref<any>(null)
|
||||
const loading = ref(false)
|
||||
const lastUpdate = ref('')
|
||||
@@ -20,34 +19,41 @@ const updateTime = () => {
|
||||
}
|
||||
|
||||
const fetchInfo = async () => {
|
||||
if (!input.value) return
|
||||
if (!inputToken.value) return
|
||||
|
||||
try {
|
||||
const res = await axios.get('/api/token/info', {
|
||||
params: {token: input.value}
|
||||
})
|
||||
result.value = res.data.result
|
||||
token.value = input.value
|
||||
const res = await api.getTokenInfo({token: inputToken.value})
|
||||
result.value = res.data.data
|
||||
updateTime()
|
||||
} catch {
|
||||
result.value = null
|
||||
ElMessage({message: 'Token输入错误', type: 'error', duration: 2000})
|
||||
}
|
||||
}
|
||||
|
||||
const refresh = async () => {
|
||||
loading.value = true
|
||||
await fetchInfo()
|
||||
|
||||
try {
|
||||
const res = await api.getTokenInfo({token: inputToken.value})
|
||||
result.value = res.data.data
|
||||
updateTime()
|
||||
ElMessage({message: '查询成功', type: 'success', duration: 1500})
|
||||
} catch {
|
||||
result.value = null
|
||||
ElMessage({message: 'Token输入错误', type: 'error', duration: 2000})
|
||||
}
|
||||
|
||||
loading.value = false
|
||||
ElMessage({message: '查询成功', type: 'success', duration: 1500})
|
||||
}
|
||||
|
||||
const inputChange = () => {
|
||||
if (input.value) fetchInfo()
|
||||
if (inputToken.value) fetchInfo()
|
||||
}
|
||||
|
||||
let timer: number
|
||||
onMounted(() => {
|
||||
if (token.value) fetchInfo()
|
||||
fetchInfo()
|
||||
timer = window.setInterval(fetchInfo, 5000)
|
||||
})
|
||||
|
||||
@@ -73,7 +79,7 @@ const statCards = [
|
||||
|
||||
<div class="search-box">
|
||||
<el-input
|
||||
v-model="input"
|
||||
v-model="inputToken"
|
||||
placeholder="输入 Token"
|
||||
clearable
|
||||
size="large"
|
||||
@@ -99,7 +105,7 @@ const statCards = [
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<AddDataDialog v-model="showAddDataDialog" :token="token"/>
|
||||
<AddDataDialog v-model="showAddDataDialog" :token="inputToken"/>
|
||||
|
||||
<div v-if="result" class="result-section">
|
||||
<div class="result-header">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import {onMounted, onUnmounted, ref, watch} from 'vue'
|
||||
import {useCounterStore} from "@/stores/counter.ts"
|
||||
import axios from "@/axios.ts"
|
||||
import api from "@/api"
|
||||
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||
import {DataAnalysis, Delete, Document, InfoFilled, Key, Refresh, Search, Warning} from '@element-plus/icons-vue'
|
||||
|
||||
@@ -23,22 +23,18 @@ const isLoading = ref(false)
|
||||
const fetchInfo = async () => {
|
||||
if (!value.value) return
|
||||
|
||||
const res = await axios.get('/api/token/info', {
|
||||
params: {
|
||||
token: value.value
|
||||
}
|
||||
})
|
||||
const res = await api.getTokenInfo({token: value.value})
|
||||
if (res.status === 200) {
|
||||
result.value = res.data.result
|
||||
result.value = res.data.data
|
||||
lastUpdate.value = new Date().toLocaleTimeString()
|
||||
}
|
||||
}
|
||||
|
||||
const fetchTokens = async () => {
|
||||
try {
|
||||
const res = await axios.get('/api/token')
|
||||
const res = await api.getTokenList()
|
||||
if (res.status === 200) {
|
||||
options.value = res.data.result?.map((item: any) => item.token) || []
|
||||
options.value = res.data.data?.map((item: any) => item.token) || []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch tokens:', error)
|
||||
@@ -58,12 +54,7 @@ const deleteDedup = () => {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(async () => {
|
||||
await axios.delete('/api/token/info', {
|
||||
params: {
|
||||
token: value.value,
|
||||
dedup_bf: "all"
|
||||
}
|
||||
})
|
||||
await api.deleteTokenInfo({token: value.value, dedup_bf: "all"})
|
||||
ElMessage({message: '删除成功', type: 'success'})
|
||||
await fetchInfo()
|
||||
}).catch(() => {
|
||||
@@ -76,12 +67,7 @@ const deleteRedis = () => {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(async () => {
|
||||
await axios.delete('/api/token/info', {
|
||||
params: {
|
||||
token: value.value,
|
||||
cache_list: "all"
|
||||
}
|
||||
})
|
||||
await api.deleteTokenInfo({token: value.value, cache_list: "all"})
|
||||
ElMessage({message: '删除成功', type: 'success'})
|
||||
await fetchInfo()
|
||||
}).catch(() => {
|
||||
@@ -91,12 +77,7 @@ const deleteRedis = () => {
|
||||
const deleteSpecifyDedup = async () => {
|
||||
isLoading.value = true
|
||||
|
||||
await axios.delete('/api/token/info', {
|
||||
params: {
|
||||
token: value.value,
|
||||
dedup_bf: inputSpecifyDedup.value
|
||||
}
|
||||
})
|
||||
await api.deleteTokenInfo({token: value.value, dedup_bf: inputSpecifyDedup.value})
|
||||
|
||||
isLoading.value = false
|
||||
ElMessage({message: '删除成功', type: 'success'})
|
||||
@@ -109,12 +90,7 @@ const deleteSpecifyDedup = async () => {
|
||||
const deleteSpecifyRaw = async () => {
|
||||
isLoading.value = true
|
||||
|
||||
await axios.delete('/api/token/info', {
|
||||
params: {
|
||||
token: value.value,
|
||||
cache_list: inputSpecifyRaw.value
|
||||
}
|
||||
})
|
||||
await api.deleteTokenInfo({token: value.value, cache_list: inputSpecifyRaw.value})
|
||||
|
||||
isLoading.value = false
|
||||
ElMessage({message: '删除成功', type: 'success'})
|
||||
@@ -127,12 +103,7 @@ const deleteSpecifyRaw = async () => {
|
||||
const deleteSpecifyData = async () => {
|
||||
isLoading.value = true
|
||||
|
||||
await axios.delete('/api/token/info', {
|
||||
params: {
|
||||
token: value.value,
|
||||
both_number: inputSpecifyData.value
|
||||
}
|
||||
})
|
||||
await api.deleteTokenInfo({token: value.value, both_number: inputSpecifyData.value})
|
||||
|
||||
isLoading.value = false
|
||||
ElMessage({message: '删除成功', type: 'success'})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import {onMounted, ref} from "vue"
|
||||
import axios from "@/axios.ts"
|
||||
import api from "@/api"
|
||||
import {ElMessage} from 'element-plus'
|
||||
import {useCounterStore} from "@/stores/counter.ts"
|
||||
import {useRouter} from "vue-router"
|
||||
@@ -42,8 +42,8 @@ const dataFormatOptions = [
|
||||
const fetchTokens = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await axios.get("/api/token")
|
||||
tableData.value = res.data.result || []
|
||||
const res = await api.getTokenList()
|
||||
tableData.value = res.data.data || []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -74,13 +74,11 @@ const addToken = async () => {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await axios.post('/api/token', {}, {
|
||||
params: {
|
||||
token: input.value,
|
||||
dedup_object: value.value,
|
||||
data_format: dataFormat.value,
|
||||
notes: inputNotes.value,
|
||||
}
|
||||
await api.createToken({
|
||||
token: input.value,
|
||||
dedup_object: value.value,
|
||||
data_format: dataFormat.value,
|
||||
notes: inputNotes.value,
|
||||
})
|
||||
ElMessage({message: '添加成功', type: 'success'})
|
||||
input.value = ''
|
||||
@@ -123,13 +121,11 @@ const dialogDataADDVisible = (row: any) => {
|
||||
|
||||
const updateDedupObject = async () => {
|
||||
try {
|
||||
await axios.put('/api/token', {}, {
|
||||
params: {
|
||||
token: rowOut.value.token,
|
||||
dedup_object: value.value,
|
||||
data_format: rowOut.value.data_format,
|
||||
notes: rowOut.value.notes,
|
||||
}
|
||||
await api.updateToken({
|
||||
token: rowOut.value.token,
|
||||
dedup_object: value.value,
|
||||
data_format: rowOut.value.data_format,
|
||||
notes: rowOut.value.notes,
|
||||
})
|
||||
ElMessage({message: '更新成功', type: 'success'})
|
||||
dedupObjectVisible.value = false
|
||||
@@ -141,13 +137,11 @@ const updateDedupObject = async () => {
|
||||
|
||||
const updateDataFormat = async () => {
|
||||
try {
|
||||
await axios.put('/api/token', {}, {
|
||||
params: {
|
||||
token: rowOut.value.token,
|
||||
dedup_object: rowOut.value.dedup_object,
|
||||
data_format: dataFormat.value,
|
||||
notes: rowOut.value.notes,
|
||||
}
|
||||
await api.updateToken({
|
||||
token: rowOut.value.token,
|
||||
dedup_object: rowOut.value.dedup_object,
|
||||
data_format: dataFormat.value,
|
||||
notes: rowOut.value.notes,
|
||||
})
|
||||
ElMessage({message: '更新成功', type: 'success'})
|
||||
dataFormatVisible.value = false
|
||||
@@ -159,13 +153,11 @@ const updateDataFormat = async () => {
|
||||
|
||||
const updateNotes = async () => {
|
||||
try {
|
||||
await axios.put('/api/token', {}, {
|
||||
params: {
|
||||
token: rowOut.value.token,
|
||||
dedup_object: rowOut.value.dedup_object,
|
||||
data_format: rowOut.value.data_format,
|
||||
notes: inputNotes.value
|
||||
}
|
||||
await api.updateToken({
|
||||
token: rowOut.value.token,
|
||||
dedup_object: rowOut.value.dedup_object,
|
||||
data_format: rowOut.value.data_format,
|
||||
notes: inputNotes.value,
|
||||
})
|
||||
ElMessage({message: '更新成功', type: 'success'})
|
||||
inputNotesVisible.value = false
|
||||
@@ -177,9 +169,7 @@ const updateNotes = async () => {
|
||||
|
||||
const deleteToken = async (row: any) => {
|
||||
try {
|
||||
await axios.delete('/api/token', {
|
||||
params: {token: row.token}
|
||||
})
|
||||
await api.deleteToken({token: row.token})
|
||||
ElMessage({message: '删除成功', type: 'success'})
|
||||
fetchTokens()
|
||||
} catch (error: any) {
|
||||
|
||||
Reference in New Issue
Block a user