This commit is contained in:
xiangheng
2024-11-19 00:06:05 +08:00
parent 1b7ccf6468
commit 7b27141d1f
8 changed files with 59 additions and 59 deletions

View File

@@ -207,6 +207,10 @@ export default {
captchaType: captchaType.value captchaType: captchaType.value
} }
reqGet(data).then((res) => { reqGet(data).then((res) => {
if (!res) {
text.value = '网络错误'
return
}
if (res.repCode == '0000') { if (res.repCode == '0000') {
pointBackImgBase.value = pointBackImgBase.value =
'data:image/png;base64,' + res.repData.originalImageBase64 'data:image/png;base64,' + res.repData.originalImageBase64

View File

@@ -1,14 +1,14 @@
<script setup lang="ts"> <script setup lang="ts">
// import { onUnmounted } from 'vue' // import { onUnmounted } from 'vue'
// import { XErr, XErrWeb } from '../../../../x_err_sdk/web/index' // import { Base, Web } from '../../../../x_err_sdk/web/index'
// // { XErr, XErrWeb } // // { XErr, Web }
// const xErr = new XErr( // const xErr = new Base(
// { // {
// Dns: 'http://localhost:5174/api', // Dns: 'http://localhost:5174/api',
// Pid: 'e19e3be20de94f49b68fafb4c30668bc', // Pid: 'e19e3be20de94f49b68fafb4c30668bc',
// Uid: '10' // Uid: '10'
// }, // },
// new XErrWeb() // new Web()
// ) // )
// onUnmounted(() => { // onUnmounted(() => {
// xErr.unListen() // xErr.unListen()

View File

@@ -93,15 +93,15 @@ const formData = reactive({
Status: null Status: null
}) })
const code = computed(() => { const code = computed(() => {
return `import { XErr, XErrWeb } from '../../x_err_sdk/web/index' return `import { Base, Web } from '../../x_err_sdk/web/index'
new XErr( new Base(
{ {
Dns: '${location.origin}/api', Dns: '${location.origin}/api',
Pid: '${formData.ProjectKey}', Pid: '${formData.ProjectKey}',
Uid: '' Uid: ''
}, },
new XErrWeb({ new Web({
onloadTimeOut: 3000 onloadTimeOut: 8000
}) })
)` )`
}) })

View File

@@ -1,58 +1,56 @@
package user_protocol package user_protocol
import ( import (
"x_admin/core" "x_admin/core"
) )
//UserProtocolListReq 用户协议列表参数 // UserProtocolListReq 用户协议列表参数
type UserProtocolListReq struct { type UserProtocolListReq struct {
Title *string // 标题 Title *string // 标题
Content *string // 协议内容 Content *string // 协议内容
Sort *float64 // 排序 Sort *float64 // 排序
CreateTimeStart *string // 开始创建时间 CreateTimeStart *string // 开始创建时间
CreateTimeEnd *string // 结束创建时间 CreateTimeEnd *string // 结束创建时间
UpdateTimeStart *string // 开始更新时间 UpdateTimeStart *string // 开始更新时间
UpdateTimeEnd *string // 结束更新时间 UpdateTimeEnd *string // 结束更新时间
} }
// UserProtocolAddReq 用户协议新增参数
//UserProtocolAddReq 用户协议新增参数
type UserProtocolAddReq struct { type UserProtocolAddReq struct {
Title *string // 标题 Title *string // 标题
Content *string // 协议内容 Content *string // 协议内容
Sort core.NullFloat // 排序 Sort core.NullFloat // 排序
} }
//UserProtocolEditReq 用户协议编辑参数 // UserProtocolEditReq 用户协议编辑参数
type UserProtocolEditReq struct { type UserProtocolEditReq struct {
Id int // Id int //
Title *string // 标题 Title *string // 标题
Content *string // 协议内容 Content *string // 协议内容
Sort core.NullFloat // 排序 Sort core.NullFloat // 排序
} }
//UserProtocolDetailReq 用户协议详情参数 // UserProtocolDetailReq 用户协议详情参数
type UserProtocolDetailReq struct { type UserProtocolDetailReq struct {
Id int // Id int //
} }
//UserProtocolDelReq 用户协议删除参数 // UserProtocolDelReq 用户协议删除参数
type UserProtocolDelReq struct { type UserProtocolDelReq struct {
Id int // Id int //
} }
//UserProtocolDelReq 用户协议批量删除参数 // UserProtocolDelReq 用户协议批量删除参数
type UserProtocolDelBatchReq struct { type UserProtocolDelBatchReq struct {
Ids string Ids string
} }
//UserProtocolResp 用户协议返回信息 // UserProtocolResp 用户协议返回信息
type UserProtocolResp struct { type UserProtocolResp struct {
Id int // Id int //
Title string // 标题 Title string // 标题
Content string // 协议内容 Content string // 协议内容
Sort core.NullFloat // 排序 Sort core.NullFloat // 排序
CreateTime core.NullTime // 创建时间 CreateTime core.NullTime // 创建时间
UpdateTime core.NullTime // 更新时间 UpdateTime core.NullTime // 更新时间
} }

View File

@@ -196,7 +196,7 @@ func (service userProtocolService) GetExcelCol() []excel2.Col {
var cols = []excel2.Col{ var cols = []excel2.Col{
{Name: "标题", Key: "Title", Width: 15}, {Name: "标题", Key: "Title", Width: 15},
{Name: "协议内容", Key: "Content", Width: 15}, {Name: "协议内容", Key: "Content", Width: 15},
{Name: "排序", Key: "Sort", Width: 15}, {Name: "排序", Key: "Sort", Width: 15, Decode: core.DecodeFloat},
{Name: "创建时间", Key: "CreateTime", Width: 15, Decode: util.NullTimeUtil.DecodeTime}, {Name: "创建时间", Key: "CreateTime", Width: 15, Decode: util.NullTimeUtil.DecodeTime},
{Name: "更新时间", Key: "UpdateTime", Width: 15, Decode: util.NullTimeUtil.DecodeTime}, {Name: "更新时间", Key: "UpdateTime", Width: 15, Decode: util.NullTimeUtil.DecodeTime},
} }

View File

@@ -15,9 +15,9 @@ const TimeFormat = "2006-01-02 15:04:05"
// NullTime 自定义时间格式 // NullTime 自定义时间格式
type NullTime struct { type NullTime struct {
Time *time.Time Time *time.Time
Valid bool Valid bool
Format string // Format string
} }
// func (t *NullTime) IsZero() bool { // func (t *NullTime) IsZero() bool {
@@ -70,25 +70,23 @@ func (t NullTime) Value() (driver.Value, error) {
// 读取数据gorm调用 // 读取数据gorm调用
func (t *NullTime) Scan(v any) error { func (t *NullTime) Scan(v any) error {
// pt, err := time.ParseInLocation("2006-01-02 15:04:05", v.(time.Time).String(), time.Local) switch val := v.(type) {
if pt, ok := v.(time.Time); ok { case time.Time:
tt := pt.Format(TimeFormat) tt := val.Format(TimeFormat)
if tt == "0001-01-01 00:00:00" { if tt == "0001-01-01 00:00:00" {
*t = NullTime{ *t = NullTime{
Time: &pt, Time: nil,
Valid: false, Valid: false,
} }
return nil
} else { } else {
*t = NullTime{ *t = NullTime{
Time: &pt, Time: &val,
Valid: true, Valid: true,
} }
} }
return nil return nil
} }
return fmt.Errorf("cant convert %s to time", v) return fmt.Errorf("NullTime cant convert %s", v)
} }
func (t NullTime) String() string { func (t NullTime) String() string {

View File

@@ -78,22 +78,22 @@ func importData(f *excelize.File, dst interface{}, sheetName string, startRow in
key := col.Key key := col.Key
replace := col.Replace replace := col.Replace
val := rows[i][j] rowVal := rows[i][j]
// 先替换将val替换为key // 先替换将val替换为key
for replaceKey, v := range replace { for replaceKey, replaceVal := range replace {
if fmt.Sprintf("%v", v) == fmt.Sprintf("%v", val) { if fmt.Sprintf("%v", replaceVal) == rowVal {
val = fmt.Sprintf("%v", replaceKey) rowVal = replaceKey
break break
} }
} }
// 再解码 // 再解码
if col.Decode != nil { if col.Decode != nil {
v, e := col.Decode(val) v, e := col.Decode(rowVal)
if e == nil { if e == nil {
rowMap[key] = v rowMap[key] = v
} }
} else { } else {
rowMap[key] = val rowMap[key] = rowVal
} }
} }
data = append(data, rowMap) data = append(data, rowMap)

View File

@@ -149,7 +149,7 @@ class Web implements IErrorEvent {
this.callback({ this.callback({
Type: "onloadTime", Type: "onloadTime",
Path: window.location.href, Path: window.location.href,
Time:onloadTime Time:Math.floor(onloadTime)
}); });
} }
} }