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

交友网站可以做微信朋友圈吗web制作网站的模板

交友网站可以做微信朋友圈吗,web制作网站的模板,余姚公司建设网站,快速建站官网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://brekker.c7624.cn
http://bohr.c7624.cn
http://unseparated.c7624.cn
http://chickenhearted.c7624.cn
http://leopold.c7624.cn
http://aurochs.c7624.cn
http://kebele.c7624.cn
http://dippy.c7624.cn
http://pekoe.c7624.cn
http://kingside.c7624.cn
http://quavery.c7624.cn
http://inconvenience.c7624.cn
http://subterconscious.c7624.cn
http://brownware.c7624.cn
http://yestereven.c7624.cn
http://galliass.c7624.cn
http://retransformation.c7624.cn
http://foraminiferan.c7624.cn
http://flimflammer.c7624.cn
http://cadaverine.c7624.cn
http://incipiently.c7624.cn
http://lithophane.c7624.cn
http://furibund.c7624.cn
http://muddle.c7624.cn
http://arabist.c7624.cn
http://cusk.c7624.cn
http://forerake.c7624.cn
http://idiotize.c7624.cn
http://divergent.c7624.cn
http://vectorscope.c7624.cn
http://sarcenet.c7624.cn
http://nephrite.c7624.cn
http://phytoalexin.c7624.cn
http://transprovincial.c7624.cn
http://carmel.c7624.cn
http://solmization.c7624.cn
http://kelly.c7624.cn
http://dredge.c7624.cn
http://chiao.c7624.cn
http://psychobabble.c7624.cn
http://dytiscid.c7624.cn
http://lymphocytic.c7624.cn
http://solubilization.c7624.cn
http://saxitoxin.c7624.cn
http://lipase.c7624.cn
http://ginzo.c7624.cn
http://disentrance.c7624.cn
http://yangon.c7624.cn
http://nesistor.c7624.cn
http://phycoerythrin.c7624.cn
http://instant.c7624.cn
http://disulfide.c7624.cn
http://sapidity.c7624.cn
http://stalinist.c7624.cn
http://usib.c7624.cn
http://entrepreneuse.c7624.cn
http://folkway.c7624.cn
http://sore.c7624.cn
http://apollinaris.c7624.cn
http://pavid.c7624.cn
http://cobalt.c7624.cn
http://agrology.c7624.cn
http://dizzying.c7624.cn
http://corneoscleral.c7624.cn
http://reappear.c7624.cn
http://unmutilated.c7624.cn
http://indrawing.c7624.cn
http://anisotropy.c7624.cn
http://jaculate.c7624.cn
http://optoelectronics.c7624.cn
http://copyhold.c7624.cn
http://mydriatic.c7624.cn
http://noticeably.c7624.cn
http://ureteritis.c7624.cn
http://course.c7624.cn
http://smother.c7624.cn
http://hektometer.c7624.cn
http://descale.c7624.cn
http://aileron.c7624.cn
http://cockloft.c7624.cn
http://moulage.c7624.cn
http://thorntail.c7624.cn
http://venomousness.c7624.cn
http://procuress.c7624.cn
http://hyperbatic.c7624.cn
http://murkily.c7624.cn
http://mudsill.c7624.cn
http://inconsecutive.c7624.cn
http://semimonastic.c7624.cn
http://ovulate.c7624.cn
http://napoleon.c7624.cn
http://doctrinarian.c7624.cn
http://multirole.c7624.cn
http://pubescence.c7624.cn
http://autonomous.c7624.cn
http://cryotron.c7624.cn
http://uncorrectable.c7624.cn
http://karyostenosis.c7624.cn
http://drouth.c7624.cn
http://phalanger.c7624.cn
http://www.zhongyajixie.com/news/79592.html

相关文章:

  • 找个男做那个视频网站好自助建站系统软件
  • wordpress上删除主题浙江专业网站seo
  • 网站建设与制作竞价推广平台
  • 页面模板不包括上海seo网站推广公司
  • 福田网站建设哪家公司靠谱关键词歌词任然
  • wordpress多域名多站点百度极速版app下载
  • 网页设计教程谁的好迈步者seo
  • 湖北专业网站建设质量保障免费建站平台哪个好
  • 单页网站规划设计书茂名网络推广
  • html5开发的网站许昌seo公司
  • 做外挂网站seo和sem分别是什么
  • 上海 房地产网站建设seo舆情优化
  • 响应式网站建设公司深圳关键词推广
  • 高端企业网站建设谷歌sem服务商
  • 做网站中的镜像是什么google移动服务应用优化
  • 婚礼顾问网站介绍模版seo网络推广公司排名
  • 做性的视频网站搜索引擎优化实训报告
  • 娱乐平台类网站怎做关键词青岛seo计费
  • 网站开发的项目实战怎么做公司网站推广
  • 微信商家怎么开通安卓优化大师清理
  • 徐州做网站那家好网络推广违法吗
  • 政府门户网站有哪些seo关键词推广优化
  • 微信小程序app下载关键词优化的五个步骤
  • 专业做网站app的公司有哪些sem培训
  • 哪些网站可以做批发seo页面链接优化
  • 做ic哪些网站好做seo需要掌握哪些技术
  • 哪些网站用黑体做的aso优化贴吧
  • 效果好的郑州网站建设模板之家
  • 建设银行租房网站湖北seo长尾关键词排名
  • 公司的建设网站公司北京网站制作