当前位置: 首页 > news >正文

彩票网站建设策划书wordpress分页加载

彩票网站建设策划书,wordpress分页加载,自己做的网站图片挡住了导航栏,网站开发前端和后端用什么语言refer: http://ip-api.com/ 1.首先需要创建一个保存用户历史的登录的表,然后连接go 2.在用户登录的时候,获取用户的IP IP位置,在后端直接处理数据即可(不需要在前端传递数据) (1)增加路由&am…

refer: http://ip-api.com/

1.首先需要创建一个保存用户历史的登录的表,然后连接go

2.在用户登录的时候,获取用户的IP IP位置,在后端直接处理数据即可(不需要在前端传递数据)

(1)增加路由:

apiv1.POST("/history_login_logs", v1.AddHistoryLoginLog)

(2)在model里增加(例如:models/history_login_logs.go)
 

 func AddHistoryLoginLog(user_id int, ip_address string, ip_location string, login_at time.Time) bool {db.Create(&HistoryLoginLogs{UserId:    user_id,IpAddress: ip_address,IpLocation:   ip_location,LoginAt: login_at,})return true}


  (3) 在登录后的方法中增加(需要引入

import("time""io/ioutil""fmt""encoding/json"
)type Location struct {Status      string  `json:"status"`Country     string  `json:"country"`CountryCode string  `json:"countryCode"`Region      string  `json:"region"`RegionName  string  `json:"regionName"`City        string  `json:"city"`Zip         string  `json:"zip"`Lat         float64 `json:"lat"`Lon         float64 `json:"lon"`Timezone    string  `json:"timezone"`Isp         string  `json:"isp"`Org         string  `json:"org"`As          string  `json:"as"`Query       string  `json:"query"`
}...
ipAddress := c.ClientIP()
fmt.Println("== ip_address:", ipAddress)
resp, err := http.Get("http://ip-api.com/json/" + ipAddress + "?lang=zh-CN")
if err != nil {fmt.Println("Error:", err)return
}defer resp.Body.Close()body, err := ioutil.ReadAll(resp.Body)if err != nil {fmt.Println("Error:", err)return}var location Location
err = json.Unmarshal(body, &location)if err != nil {fmt.Println("Error:", err)return}fmt.Println("=== Location:", location)
City := location.CitycurrentTime := time.Now()
models.AddHistoryLoginLog(user.ID, ipAddress, City, currentTime)
...

  (4)增加action (例如:routers/api/v1/history_login_log.go)(需要引入import  "net/http"   "time"  "fmt")
 

type AddHistoryLoginLogRequest struct {UserID     int    `json:"user_id" binding:"required"`IPAddress  string `json:"ip_address" binding:"required"`City string `json:"ip_location" binding:"required"`CurrentTime time.Time `json:"login_at" binding:"required"`}func AddHistoryLoginLog(c *gin.Context) {var request AddHistoryLoginLogRequestif err := c.ShouldBindJSON(&request); err != nil {fmt.Println("== err: ", err)return}models.AddHistoryLoginLog(request.UserID, request.IPAddress, request.City, request.CurrentTime)}

3.在前端写一个展示的列表页面即可。(登录时间写现在的时间即可。)
例如:src/pages/HistoryLoginLog/index.jsx

import React, { Component } from 'react'
import { Table } from 'antd';
import axios from 'axios'
import Config from '@/settings'
import { getToken, removeToken } from '@/utils/auth'const columns = [{title: '登录名',dataIndex: 'user_id',key: 'user_id',render: text => <a>{text}</a>,},{title: '登陆时间',dataIndex: 'login_at',key: 'login_at',// 这里是进行时间的处理,转换为北京时间,格式为:2023/08/16 21:40render: text => {const dateObj = new Date(text);const localizedDate = dateObj.toLocaleString('zh-CN', {timeZone: 'Asia/Shanghai',year: 'numeric',month: '2-digit',day: '2-digit',hour: '2-digit',minute: '2-digit',});return <span>{localizedDate}</span>;},},{title: '登陆ip',dataIndex: 'ip_address',key: 'ip_address',},{title: '登陆位置',dataIndex: 'ip_location',key: 'ip_locatio',}
];export default class CalculationPlan extends Component {state = {data: [],loading: true,}async fetchData() {try {const response = await axios.get(`${Config.BASE_URL}/api/v1/history_login_logs?token=${getToken()}`)if (response.data.message == "ok") {const sortedData = response.data.data.sort((a, b) => new Date(b.id) - new Date(a.id));this.setState({data: sortedData,loading: false,})}} catch (error) {console.error(error)removeToken()window.location.href = '/'}}componentDidMount() {this.fetchData()}render() {const { data, loading } = this.statereturn (<Table columns={columns} dataSource={data} loading={loading} />)}
}

http://www.yayakq.cn/news/202604/

相关文章:

  • 阿里云多网站建设各引擎收录查询
  • 湖南对外建设集团网站惠州自适应网站建设
  • 做本地网站需要什么资质贵金属如何用网站开发客户
  • 如何做网站公众号推广cms管理手机网站
  • 备案网站出售百度云搜索资源入口
  • 360网站推广登录常德百竞seo
  • 大型集团网站建设公司网站建设 海口
  • 中山网站建设模板招商电厂cms系统是什么
  • 网站建设规划书结构网络广告电话
  • 什么行业最需要做网站建设引流推广公司
  • 几大门户网站广州 网站 设计
  • 手机主题如何自己制作网站个人网站只能用作博客
  • 防止网站流量被刷asp.net 网站开发实例教程
  • 网页设计网站搭建最好的网站代运营公司
  • 网站备案 历史东莞长安
  • 中小企业网站建设方案有特色的网站设计
  • 邢台网站网页设计公司小米公司网络营销工具
  • 手机网站模板 html5 下载工具设计制作小车一教学设计
  • 网站的弹窗怎么做想在微信公众号上做网站链接
  • 常宁市住房和城乡建设局网站什么是管理
  • 凡客诚品官网疑似关闭网站怎样做优化调整
  • 查询企业信息的网站北京泵网站建设
  • 企业建设网站需注意哪些事项自己搭建服务器违法吗
  • 自己做本地视频网站wordpress 微商城模板下载
  • 网站前台怎么套用织梦后台兰州装修公司位置
  • 肥城网站建设电话上海中高风险地区名单最新
  • 网站建设技术的实现wordpress查询分页插件
  • 了解网站开发流程网站服务器ip更换
  • 网站与后台奥利奥广告策划书
  • 科技因子网站建设方案先做网站后付款