diff --git a/api/v1/config.pb.go b/api/v1/config.pb.go index 1033086..8f0a6c2 100644 --- a/api/v1/config.pb.go +++ b/api/v1/config.pb.go @@ -333,6 +333,7 @@ type ConfigSystem struct { LoginBackground string `protobuf:"bytes,12,opt,name=login_background,json=loginBackground,proto3" json:"login_background,omitempty"` RecommendWords []string `protobuf:"bytes,13,rep,name=recommend_words,json=recommendWords,proto3" json:"recommend_words,omitempty"` Version string `protobuf:"bytes,14,opt,name=version,proto3" json:"version,omitempty"` + CreditName string `protobuf:"bytes,15,opt,name=credit_name,json=creditName,proto3" json:"credit_name,omitempty"` } func (m *ConfigSystem) Reset() { *m = ConfigSystem{} } @@ -466,6 +467,13 @@ func (m *ConfigSystem) GetVersion() string { return "" } +func (m *ConfigSystem) GetCreditName() string { + if m != nil { + return m.CreditName + } + return "" +} + // 底链配置项,为跳转的链接地址 type ConfigFooter struct { About string `protobuf:"bytes,1,opt,name=about,proto3" json:"about,omitempty"` @@ -1017,100 +1025,101 @@ func init() { func init() { proto.RegisterFile("api/v1/config.proto", fileDescriptor_321614cd6c9c1b8a) } var fileDescriptor_321614cd6c9c1b8a = []byte{ - // 1487 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x57, 0xcb, 0x6e, 0x1b, 0x37, - 0x17, 0xce, 0x48, 0xd6, 0x8d, 0xba, 0xd8, 0xa6, 0x2f, 0x91, 0x95, 0xfc, 0x8e, 0x33, 0x3f, 0xda, - 0x3a, 0x41, 0x61, 0xc5, 0xee, 0x65, 0xd1, 0x2e, 0x02, 0xc7, 0x71, 0xd2, 0x00, 0x59, 0xa4, 0xe3, - 0x04, 0xbd, 0x6c, 0x06, 0xd4, 0x0c, 0x25, 0x11, 0x1e, 0x91, 0x13, 0x92, 0x52, 0xac, 0x2c, 0xbb, - 0xea, 0x32, 0x40, 0x81, 0x16, 0xe8, 0xfb, 0x14, 0xe8, 0x32, 0x40, 0x37, 0xdd, 0xb5, 0x48, 0xda, - 0x07, 0x28, 0xd0, 0x07, 0x28, 0x78, 0xc8, 0x19, 0x4b, 0x32, 0x0c, 0x64, 0x37, 0xe7, 0x3b, 0x1f, - 0x0f, 0xc9, 0x73, 0xbe, 0x43, 0x72, 0xd0, 0x1a, 0x49, 0x59, 0x77, 0xb2, 0xdf, 0x8d, 0x04, 0xef, - 0xb3, 0xc1, 0x5e, 0x2a, 0x85, 0x16, 0xb8, 0x4c, 0x52, 0xb6, 0x37, 0xd9, 0xef, 0xdc, 0x18, 0x08, - 0x31, 0x48, 0x68, 0x17, 0xd0, 0xde, 0xb8, 0xdf, 0xd5, 0x6c, 0x44, 0x95, 0x26, 0xa3, 0xd4, 0x12, - 0x3b, 0xeb, 0x03, 0x31, 0x10, 0xf0, 0xd9, 0x35, 0x5f, 0x0e, 0xbd, 0xee, 0x86, 0x99, 0xd0, 0x84, - 0x73, 0xa1, 0x89, 0x66, 0x82, 0x2b, 0xe7, 0xbd, 0xb6, 0x18, 0x94, 0x8e, 0x52, 0x3d, 0xb5, 0x4e, - 0xff, 0xef, 0x02, 0x2a, 0x1f, 0xc1, 0x52, 0x70, 0x0b, 0x15, 0x58, 0xdc, 0xf6, 0x76, 0xbc, 0xdd, - 0x62, 0x50, 0x60, 0x31, 0x5e, 0x47, 0xa5, 0x84, 0xf4, 0x68, 0xd2, 0x2e, 0xec, 0x78, 0xbb, 0xb5, - 0xc0, 0x1a, 0x18, 0xa3, 0x25, 0x4e, 0x46, 0xb4, 0x5d, 0x04, 0x10, 0xbe, 0x0d, 0x73, 0x42, 0x92, - 0x31, 0x6d, 0x2f, 0x59, 0x26, 0x18, 0x78, 0x07, 0xd5, 0xd3, 0x84, 0x44, 0x74, 0x28, 0x92, 0x98, - 0xca, 0x76, 0x09, 0x7c, 0xb3, 0x10, 0xfe, 0x1f, 0x42, 0x8c, 0xa7, 0x63, 0x1d, 0xea, 0x69, 0x4a, - 0xdb, 0x65, 0x20, 0xd4, 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8, 0x8f, 0x2d, 0x2e, 0x7c, 0xfb, 0xbf, - 0x14, 0x51, 0xc3, 0xce, 0x75, 0x32, 0x55, 0x9a, 0x8e, 0xcc, 0xe0, 0x58, 0x8c, 0x08, 0xe3, 0x30, - 0x55, 0x2d, 0x70, 0x96, 0x99, 0x4a, 0x33, 0x9d, 0xd0, 0x4c, 0x44, 0x60, 0x98, 0x8d, 0x9f, 0xd2, - 0xe9, 0x0b, 0x21, 0x63, 0xe5, 0x84, 0x94, 0xdb, 0x46, 0x36, 0x31, 0x55, 0x91, 0x64, 0x50, 0x3b, - 0x37, 0xeb, 0x2c, 0x64, 0x16, 0x94, 0x88, 0x81, 0x70, 0x8a, 0x82, 0x6f, 0x53, 0xfb, 0x3e, 0x99, - 0xb0, 0x48, 0x70, 0xa7, 0xa3, 0xcc, 0xc4, 0x2b, 0xa8, 0xc8, 0xa2, 0xd4, 0x09, 0xc8, 0x7c, 0xe2, - 0xeb, 0xa8, 0x46, 0x38, 0x49, 0xa6, 0x9a, 0x45, 0x0a, 0x04, 0x54, 0x0b, 0xce, 0x01, 0xb3, 0x36, - 0xc5, 0x34, 0x05, 0x91, 0x5b, 0x19, 0xe5, 0x36, 0xbe, 0x83, 0xd6, 0x23, 0x91, 0x4e, 0xa5, 0xc9, - 0x4b, 0xa8, 0x34, 0x91, 0x3a, 0x9c, 0x52, 0x22, 0x41, 0x51, 0xb5, 0x00, 0xe7, 0xbe, 0x13, 0xe3, - 0xfa, 0x86, 0x12, 0x89, 0xbb, 0x68, 0x4d, 0xd2, 0x01, 0x53, 0x9a, 0xca, 0xb0, 0x47, 0xa2, 0xd3, - 0x81, 0x14, 0x63, 0x1e, 0x83, 0x82, 0x6a, 0x01, 0xce, 0x5c, 0xf7, 0x72, 0x0f, 0xbe, 0x85, 0x56, - 0x12, 0x31, 0x60, 0x7c, 0x96, 0xdd, 0x00, 0xf6, 0x32, 0xe0, 0x33, 0xd4, 0x0f, 0xd0, 0xb2, 0xa4, - 0x91, 0x18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3f, - 0x1e, 0x6a, 0x1c, 0xf3, 0xc9, 0x7d, 0x9a, 0x52, 0x1e, 0x9b, 0x3a, 0x65, 0xd7, 0xa5, 0x37, 0x73, - 0x5d, 0x2e, 0x9c, 0x70, 0x85, 0x8b, 0x27, 0xdc, 0x4d, 0xd4, 0x60, 0x2a, 0x64, 0x5c, 0x69, 0x92, - 0x24, 0x34, 0x76, 0x1a, 0xad, 0x33, 0xf5, 0x28, 0x83, 0x4c, 0xa3, 0x52, 0x29, 0x85, 0xcc, 0xee, - 0x5c, 0x30, 0xe0, 0xa2, 0x1b, 0xd2, 0xe8, 0xd4, 0xde, 0x53, 0xa5, 0x77, 0xbe, 0xe8, 0xec, 0x98, - 0x43, 0x6d, 0x4e, 0xcb, 0x68, 0x14, 0xbb, 0x33, 0xd4, 0x7c, 0xe2, 0x1b, 0xa8, 0xce, 0xd4, 0x79, - 0x4d, 0xac, 0xb0, 0x10, 0x53, 0x79, 0x41, 0xee, 0xa0, 0xa5, 0x63, 0x3e, 0x51, 0x78, 0x17, 0x2d, - 0x51, 0x3e, 0x51, 0xee, 0x92, 0xca, 0x73, 0x3b, 0x9b, 0x8e, 0x00, 0x18, 0xfe, 0xf7, 0x45, 0x54, - 0x32, 0x3d, 0xa9, 0xcc, 0x0b, 0x60, 0xac, 0xa8, 0x0c, 0x23, 0x31, 0xe6, 0xda, 0xbd, 0x3d, 0x6a, - 0x06, 0x39, 0x32, 0x80, 0x91, 0x44, 0x2e, 0x22, 0x4b, 0x29, 0x00, 0xa5, 0x99, 0xa1, 0x39, 0x2d, - 0xbb, 0x37, 0x1d, 0xad, 0x68, 0x69, 0x19, 0x6a, 0x69, 0xff, 0x47, 0x4d, 0x22, 0x35, 0x8b, 0x8c, - 0xe6, 0x81, 0xb5, 0x04, 0xac, 0x86, 0x03, 0x73, 0x92, 0xeb, 0x3f, 0x47, 0x2a, 0x59, 0x92, 0x03, - 0x2d, 0xe9, 0x26, 0x6a, 0xf4, 0x08, 0xe7, 0xf9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, 0xe6, 0x65, - 0x5b, 0x6f, 0xe6, 0x5b, 0x37, 0x34, 0x7f, 0x03, 0xe2, 0x2d, 0xe3, 0x66, 0xbe, 0x6f, 0x18, 0x7d, - 0x8c, 0x2a, 0x0f, 0xa9, 0x86, 0xae, 0xb8, 0x2c, 0x50, 0x63, 0xa6, 0x3f, 0x94, 0xbf, 0x0e, 0x71, - 0x5a, 0xb8, 0x91, 0xc5, 0x31, 0x7d, 0x82, 0xbf, 0x46, 0x4d, 0x9b, 0xbb, 0x13, 0xa6, 0xe9, 0x88, - 0xa4, 0x97, 0x06, 0xbb, 0x2c, 0x87, 0x57, 0x21, 0xec, 0x6a, 0x67, 0x39, 0x5f, 0x9e, 0x0d, 0x74, - 0xef, 0x93, 0x5f, 0xdf, 0x6c, 0x7b, 0xaf, 0xdf, 0x6c, 0x7b, 0x7f, 0xbe, 0xd9, 0xf6, 0x5e, 0xbd, - 0xdd, 0xbe, 0xf2, 0xfa, 0xed, 0xf6, 0x95, 0xdf, 0xdf, 0x6e, 0x5f, 0x41, 0xee, 0x57, 0xe4, 0x89, - 0xf7, 0xed, 0xea, 0x48, 0x48, 0x1a, 0x8b, 0xc8, 0x8d, 0xfd, 0x7c, 0xb2, 0xdf, 0x2b, 0x43, 0xfc, - 0x8f, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x7c, 0x60, 0x72, 0xc5, 0x0c, 0x00, 0x00, + // 1503 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x57, 0x4b, 0x6f, 0x1b, 0xb7, + 0x16, 0xce, 0xe8, 0x2d, 0xea, 0x65, 0xd3, 0x8f, 0xc8, 0x4a, 0xae, 0xe3, 0xcc, 0xc5, 0xbd, 0x75, + 0x82, 0xc2, 0x8a, 0xdd, 0xc7, 0xa2, 0x5d, 0x04, 0x8e, 0xe3, 0xa4, 0x01, 0x82, 0x22, 0x1d,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6a, 0xd9, 0xb3, 0x96, + 0xae, 0xd7, 0x0b, 0x16, 0xaa, 0x31, 0x54, 0xb6, 0xec, 0x19, 0x43, 0xb3, 0xc7, 0x94, 0x8d, 0xc6, + 0x0a, 0x6a, 0x5b, 0xf6, 0xac, 0xa5, 0x53, 0x0d, 0xf5, 0x31, 0xc5, 0x85, 0x6f, 0xf7, 0xaf, 0x22, + 0x6a, 0x9a, 0xb9, 0x4e, 0x66, 0x52, 0xd1, 0x58, 0x0f, 0x0e, 0x79, 0x4c, 0x58, 0x02, 0x53, 0xd5, + 0x3d, 0x6b, 0xe9, 0xa9, 0x14, 0x53, 0x11, 0xcd, 0x44, 0x04, 0x86, 0xde, 0xf8, 0x29, 0x9d, 0xbd, + 0xe0, 0x22, 0x94, 0x56, 0x48, 0xb9, 0xad, 0x65, 0x13, 0x52, 0x19, 0x08, 0x06, 0xb5, 0xb3, 0xb3, + 0xce, 0x43, 0x7a, 0x41, 0x11, 0x1f, 0x71, 0xab, 0x28, 0xf8, 0xd6, 0xb5, 0x1f, 0x92, 0x29, 0x0b, + 0x78, 0x62, 0x75, 0x94, 0x99, 0x78, 0x05, 0x15, 0x59, 0x90, 0x5a, 0x01, 0xe9, 0x4f, 0x7c, 0x1d, + 0xd5, 0x49, 0x42, 0xa2, 0x99, 0x62, 0x81, 0x04, 0x01, 0xd5, 0xbd, 0x73, 0x40, 0xaf, 0x4d, 0x32, + 0x45, 0x41, 0xe4, 0x46, 0x46, 0xb9, 0x8d, 0xef, 0xa0, 0xf5, 0x80, 0xa7, 0x33, 0xa1, 0xf3, 0xe2, + 0x4b, 0x45, 0x84, 0xf2, 0x67, 0x94, 0x08, 0x50, 0x54, 0xdd, 0xc3, 0xb9, 0xef, 0x44, 0xbb, 0xbe, + 0xa6, 0x44, 0xe0, 0x3e, 0x5a, 0x13, 0x74, 0xc4, 0xa4, 0xa2, 0xc2, 0x1f, 0x90, 0xe0, 0x74, 0x24, + 0xf8, 0x24, 0x09, 0x41, 0x41, 0x75, 0x0f, 0x67, 0xae, 0x7b, 0xb9, 0x07, 0xdf, 0x42, 0x2b, 0x11, + 0x1f, 0xb1, 0x64, 0x9e, 0xdd, 0x04, 0x76, 0x07, 0xf0, 0x39, 0xea, 0x7b, 0xa8, 0x23, 0x68, 0xc0, + 0xe3, 0x98, 0x26, 0xa1, 0x6f, 0x92, 0xd9, 0x02, 0x15, 0xb5, 0x73, 0xf8, 0x4b, 0x48, 0x69, 0x17, + 0x55, 0xa7, 0x54, 0x48, 0x9d, 0xce, 0xb6, 0x49, 0x8e, 0x35, 0xf1, 0x0d, 0xd4, 0x08, 0x04, 0x0d, + 0x99, 0xf2, 0x61, 0xbf, 0x1d, 0xf0, 0x22, 0x03, 0x7d, 0x4e, 0x62, 0xea, 0xfe, 0xe0, 0x64, 0x85, + 0x7e, 0xc0, 0xb9, 0xa2, 0x42, 0x17, 0x94, 0x0c, 0xf8, 0x44, 0xd9, 0x3a, 0x1b, 0x43, 0xcf, 0x10, + 0xf0, 0x44, 0x91, 0x40, 0xd9, 0x42, 0x67, 0x26, 0x24, 0x7b, 0x24, 0x28, 0x8d, 0x69, 0xa2, 0x6c, + 0xad, 0xcf, 0x01, 0xed, 0xcd, 0x93, 0x66, 0x4b, 0x7d, 0x0e, 0xe8, 0x52, 0x0c, 0x29, 0x0d, 0x75, + 0x26, 0x6c, 0xb1, 0x73, 0xdb, 0xfd, 0xb1, 0x84, 0xda, 0x56, 0x81, 0x34, 0x98, 0x08, 0xa6, 0x66, + 0x78, 0x0b, 0xd5, 0x98, 0xf4, 0x83, 0x88, 0x4b, 0x0a, 0xab, 0xab, 0x79, 0x55, 0x26, 0x8f, 0xb4, + 0xa9, 0x53, 0x05, 0xb8, 0x2e, 0x9a, 0x32, 0x6b, 0x31, 0xeb, 0x6c, 0x03, 0x7c, 0x92, 0xa1, 0x9a, + 0x48, 0x13, 0x32, 0x88, 0xa8, 0x9f, 0xd5, 0x06, 0x16, 0x5d, 0xf3, 0xda, 0x06, 0xf6,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x05, 0x8a, 0x68, 0x1c, 0xac, 0x2f, 0x9e, 0x9d, 0xe6, 0xf4, 0xf2, + 0x2c, 0x47, 0xb3, 0x87, 0x20, 0x73, 0x50, 0xc7, 0x05, 0xb6, 0x69, 0x01, 0xcf, 0x72, 0xf0, 0x01, + 0xaa, 0x49, 0xab, 0x3d, 0x10, 0x49, 0xe3, 0x60, 0x73, 0x29, 0xba, 0xf5, 0x7a, 0x39, 0xcf, 0xfd, + 0xdb, 0x41, 0xcd, 0xe3, 0x64, 0x7a, 0x9f, 0xa6, 0x34, 0x09, 0x75, 0x9d, 0xb2, 0xfb, 0xd4, 0x99, + 0xbb, 0x4f, 0x97, 0x8e, 0xc0, 0xc2, 0xc5, 0x23, 0xf0, 0x26, 0x6a, 0x32, 0xe9, 0xb3, 0x44, 0x2a, + 0x12, 0x45, 0x34, 0xb4, 0x1a, 0x6d, 0x30, 0xf9, 0x28, 0x83, 0x74, 0xa3, 0x52, 0x21, 0xb8, 0xc8, + 0x2e, 0x65, 0x30, 0xe0, 0x26, 0x1c, 0xd3, 0xe0, 0xd4, 0x5c, 0x64, 0xe5, 0x77, 0xbe, 0x09, 0xcd, + 0x98, 0x43, 0xa5, 0x8f, 0xd3, 0x20, 0x0e, 0xed, 0x21, 0xab, 0x3f, 0xf5, 0x19, 0xc2, 0xe4, 0x79, + 0x4d, 0x8c, 0xb0, 0x10, 0x93, 0x79, 0x41, 0xee, 0xa0, 0xd2, 0x71, 0x32, 0x95, 0x78, 0x17, 0x95, + 0x68, 0x32, 0x95, 0xf6, 0x16, 0xcb, 0x73, 0x3b, 0x9f, 0x0e, 0x0f, 0x18, 0xee, 0x77, 0x45, 0x54, + 0xd6, 0x3d, 0x29, 0xf5, 0x13, 0x61, 0x22, 0xa9, 0xf0, 0x03, 0x3e, 0x49, 0x94, 0x7d, 0x9c, 0xd4, + 0x35, 0x72, 0xa4, 0x01, 0x2d, 0x89, 0x5c, 0x44, 0x86, 0x52, 0x00, 0x4a, 0x2b, 0x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0x76, 0x7f, 0xe1, 0x49, 0xfd, 0x89, 0x73, 0x1b, 0x3f, 0x43, 0xe8, + 0xfc, 0xb5, 0x85, 0xb7, 0xb2, 0x88, 0x17, 0x5e, 0x60, 0xbd, 0xe5, 0xc9, 0xdc, 0x6b, 0x10, 0x74, + 0x03, 0xaf, 0x2d, 0x06, 0xed, 0x47, 0x4c, 0x2a, 0xfc, 0x19, 0xaa, 0xe9, 0xdd, 0x83, 0x30, 0x2f, + 0xdb, 0x7a, 0x2b, 0xdf, 0xba, 0xa6, 0xb9, 0x1b, 0x10, 0xaf, 0x83, 0x5b, 0xf9, 0xbe, 0x61, 0xf4, + 0x31, 0xaa, 0x3e, 0xa4, 0x0a, 0xba, 0xe2, 0xb2, 0x40, 0xcd, 0xb9, 0xfe, 0x90, 0xee, 0x3a, 0xc4, + 0x69, 0xe3, 0x66, 0x16, 0x47, 0xf7, 0x09, 0xfe, 0x0a, 0xb5, 0x4c, 0xee, 0x4e, 0x98, 0xa2, 0x31, + 0x49, 0x2f, 0x0d, 0x76, 0x59, 0x0e, 0xaf, 0x42, 0xd8, 0xd5, 0x5e, 0x27, 0x5f, 0x9e, 0x09, 0x74, + 0xef, 0xa3, 0x9f, 0xdf, 0x6c, 0x3b, 0xaf, 0xdf, 0x6c, 0x3b, 0xbf, 0xbf, 0xd9, 0x76, 0x5e, 0xbd, + 0xdd, 0xbe, 0xf2, 0xfa, 0xed, 0xf6, 0x95, 0x5f, 0xdf, 0x6e, 0x5f, 0x41, 0xf6, 0x5f, 0xe5, 0x89, + 0xf3, 0xcd, 0x6a, 0xcc, 0x05, 0x0d, 0x79, 0x60, 0xc7, 0x7e, 0x3a, 0xdd, 0x1f, 0x54, 0x20, 0xfe, + 0x07, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x2f, 0xb7, 0x6b, 0xe6, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1621,6 +1630,13 @@ func (m *ConfigSystem) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.CreditName) > 0 { + i -= len(m.CreditName) + copy(dAtA[i:], m.CreditName) + i = encodeVarintConfig(dAtA, i, uint64(len(m.CreditName))) + i-- + dAtA[i] = 0x7a + } if len(m.Version) > 0 { i -= len(m.Version) copy(dAtA[i:], m.Version) @@ -2352,6 +2368,10 @@ func (m *ConfigSystem) Size() (n int) { if l > 0 { n += 1 + l + sovConfig(uint64(l)) } + l = len(m.CreditName) + if l > 0 { + n += 1 + l + sovConfig(uint64(l)) + } return n } @@ -3722,6 +3742,38 @@ func (m *ConfigSystem) Unmarshal(dAtA []byte) error { } m.Version = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreditName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthConfig + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthConfig + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CreditName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipConfig(dAtA[iNdEx:]) diff --git a/api/v1/config.proto b/api/v1/config.proto index 3bd25ee..493b3e3 100644 --- a/api/v1/config.proto +++ b/api/v1/config.proto @@ -62,6 +62,7 @@ message ConfigSystem { string login_background = 12; // 登录页背景图 repeated string recommend_words = 13; // 推荐搜索词,首页展示 string version = 14; // 程序版本号 + string credit_name = 15; // 积分名称 } // 底链配置项,为跳转的链接地址 diff --git a/biz/config.go b/biz/config.go index 9f89b6f..7540a82 100644 --- a/biz/config.go +++ b/biz/config.go @@ -144,6 +144,7 @@ func (s *ConfigAPIService) GetSettings(ctx context.Context, req *emptypb.Empty) } } res.System.Version = util.Version + res.System.CreditName = s.dbModel.GetConfigOfScore(model.ConfigScoreCreditName).CreditName footer := s.dbModel.GetConfigOfFooter() if err := util.CopyStruct(&footer, res.Footer); err != nil { s.logger.Error("util.CopyStruct", zap.Any("footer", footer), zap.Any("res.Footer", res.Footer), zap.Error(err)) diff --git a/biz/document.go b/biz/document.go index c575c60..aeb81d6 100644 --- a/biz/document.go +++ b/biz/document.go @@ -657,7 +657,7 @@ func (s *DocumentAPIService) DownloadDocument(ctx context.Context, req *pb.Docum user, _ := s.dbModel.GetUser(userId) if doc.UserId != userId && user.CreditCount < doc.Price { - return res, status.Errorf(codes.PermissionDenied, "魔豆不足,无法下载") + return res, status.Errorf(codes.PermissionDenied, fmt.Sprintf("%s不足,无法下载", s.dbModel.GetCreditName())) } // 用户可以免费下载自己的文档 diff --git a/biz/user.go b/biz/user.go index 3b34022..b7646bd 100644 --- a/biz/user.go +++ b/biz/user.go @@ -104,7 +104,7 @@ func (s *UserAPIService) Register(ctx context.Context, req *pb.RegisterAndLoginR } // 用户积分 - cfgScore := s.dbModel.GetConfigOfScore(model.ConfigScoreRegister) + cfgScore := s.dbModel.GetConfigOfScore(model.ConfigScoreRegister, model.ConfigScoreCreditName) user.CreditCount = int(cfgScore.Register) if err = s.dbModel.CreateUser(user, group.Id); err != nil { s.logger.Error("CreateUser", zap.Error(err)) @@ -116,7 +116,7 @@ func (s *UserAPIService) Register(ctx context.Context, req *pb.RegisterAndLoginR s.dbModel.CreateDynamic(&model.Dynamic{ UserId: user.Id, Type: model.DynamicTypeRegister, - Content: fmt.Sprintf("成功注册成网站会员,获得 %d 魔豆奖励", cfgScore.Register), + Content: fmt.Sprintf("成功注册成网站会员,获得 %d %s奖励", cfgScore.Register, cfgScore.CreditName), }) } diff --git a/model/config.go b/model/config.go index 89f727e..7d18498 100644 --- a/model/config.go +++ b/model/config.go @@ -38,6 +38,17 @@ const ( ConfigCategoryScore = "score" ) +const ( + InputTypeNumber = "number" // 数字 + InputTypeSwitch = "switch" // switch + InputTypeSelect = "select" // 单选 + InputTypeSelectMulti = "select-multi" // 多选 + InputTypeText = "text" // 文本框 + InputTypeTextarea = "textarea" // 多行文本框 + InputTypePassword = "password" // 密码 + InputTypeImage = "image" // 图片 +) + type Config struct { Id int64 `form:"id" json:"id,omitempty" gorm:"primaryKey;autoIncrement;column:id;comment:;"` Label string `form:"label" json:"label,omitempty" gorm:"column:label;type:varchar(64);size:64;comment:标签名称;"` @@ -331,6 +342,8 @@ type ConfigFooter struct { } const ( + // 积分名称 + ConfigScoreCreditName = "credit_name" // 注册积分 ConfigScoreRegister = "register" // 签到积分 @@ -352,15 +365,16 @@ const ( ) type ConfigScore struct { - Register int32 `json:"register"` // 注册积分 - SignIn int32 `json:"sign_in"` // 签到积分 - UploadDocument int32 `json:"upload_document"` // 上传文档积分 - UploadDocumentLimit int32 `json:"upload_document_limit"` // 每日上传文档积分次数限制 - DeleteDocument int32 `json:"delete_document"` // 删除上传文档积分 - DocumentCollected int32 `json:"document_collected"` // 文档被收藏获得积分 - DocumentCollectedLimit int32 `json:"document_collected_limit"` // 文档被收藏获得积分次数限制 - DocumentCommented int32 `json:"document_commented"` // 文档被评论获得积分 - DocumentCommentedLimit int32 `json:"document_commented_limit"` // 文档被评论获得积分次数限制 + CreditName string `json:"credit_name"` // 积分名称 + Register int32 `json:"register"` // 注册积分 + SignIn int32 `json:"sign_in"` // 签到积分 + UploadDocument int32 `json:"upload_document"` // 上传文档积分 + UploadDocumentLimit int32 `json:"upload_document_limit"` // 每日上传文档积分次数限制 + DeleteDocument int32 `json:"delete_document"` // 删除上传文档积分 + DocumentCollected int32 `json:"document_collected"` // 文档被收藏获得积分 + DocumentCollectedLimit int32 `json:"document_collected_limit"` // 文档被收藏获得积分次数限制 + DocumentCommented int32 `json:"document_commented"` // 文档被评论获得积分 + DocumentCommentedLimit int32 `json:"document_commented_limit"` // 文档被评论获得积分次数限制 } func (m *DBModel) GetConfigOfFooter() (config ConfigFooter) { @@ -370,11 +384,7 @@ func (m *DBModel) GetConfigOfFooter() (config ConfigFooter) { m.logger.Error("GetConfigOfFooter", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range configs { - data[cfg.Name] = cfg.Value - } + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -394,19 +404,7 @@ func (m *DBModel) GetConfigOfDownload(name ...string) (config ConfigDownload) { m.logger.Error("GetConfigOfDownload", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range configs { - switch cfg.Name { - case ConfigDownloadEnableGuestDownload: - data[cfg.Name], _ = strconv.ParseBool(cfg.Value) - case ConfigDownloadTimesEveryDay, ConfigDownloadUrlDuration, ConfigDownloadFreeDownloadDuration, ConfigDownloadTimesEveryIP: - data[cfg.Name], _ = strconv.ParseInt(cfg.Value, 10, 32) - default: - data[cfg.Name] = cfg.Value - } - } - + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -420,28 +418,18 @@ func (m *DBModel) GetConfigOfCaptcha() (config ConfigCaptcha) { if err != nil && err != gorm.ErrRecordNotFound { m.logger.Error("GetConfigOfCaptcha", zap.Error(err)) } + data := m.convertConfig2Map(configs) + bytes, _ := json.Marshal(data) + json.Unmarshal(bytes, &config) - for _, cfg := range configs { - switch cfg.Name { - case ConfigCaptchaLength: - config.Length, _ = strconv.Atoi(cfg.Value) - if config.Length <= 0 { - config.Length = 6 - } - case ConfigCaptchaWidth: - config.Width, _ = strconv.Atoi(cfg.Value) - if config.Width <= 0 { - config.Width = 240 - } - case ConfigCaptchaHeight: - config.Height, _ = strconv.Atoi(cfg.Value) - if config.Height <= 0 { - config.Height = 60 - } - case ConfigCaptchaType: - // 验证码类型 - config.Type = cfg.Value - } + if config.Length <= 0 { + config.Length = 6 + } + if config.Width <= 0 { + config.Width = 240 + } + if config.Height <= 0 { + config.Height = 60 } return } @@ -458,24 +446,7 @@ func (m *DBModel) GetConfigOfSystem(name ...string) (config ConfigSystem) { m.logger.Error("GetConfigOfSystem", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range confgis { - if cfg.Name == ConfigSystemRecommendWords { - words := strings.Split(cfg.Value, ",") - iwords := make([]string, 0) - for _, word := range words { - word = strings.TrimSpace(word) - if word != "" { - iwords = append(iwords, word) - } - } - data[cfg.Name] = iwords - } else { - data[cfg.Name] = cfg.Value - } - } - + data := m.convertConfig2Map(confgis) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -494,34 +465,7 @@ func (m *DBModel) GetConfigOfSecurity(name ...string) (config ConfigSecurity) { m.logger.Error("GetConfigOfSecurity", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range configs { - switch cfg.Name { - case ConfigSecurityIsClose, - ConfigSecurityEnableRegister, - ConfigSecurityEnableCaptchaLogin, - ConfigSecurityEnableCaptchaRegister, - ConfigSecurityEnableCaptchaComment, - ConfigSecurityLoginRequired, - ConfigSecurityEnableCaptchaFindPassword: - value, _ := strconv.ParseBool(cfg.Value) - data[cfg.Name] = value - case ConfigSecurityMaxDocumentSize, - ConfigSecurityCommentInterval, - ConfigSecurityDocumentRelatedDuration: - data[cfg.Name], _ = strconv.Atoi(cfg.Value) - case ConfigSecurityDocumentAllowedExt: - arr := strings.Split(cfg.Value, ",") - if len(arr) == 1 && arr[0] == "" { - arr = []string{} - } - data[cfg.Name] = arr - default: - data[cfg.Name] = cfg.Value - } - } - + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -535,20 +479,7 @@ func (m *DBModel) GetConfigOfConverter() (config ConfigConverter) { m.logger.Error("GetConfigOfConverter", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range configs { - switch cfg.Name { - case ConfigConverterMaxPreview, ConfigConverterTimeout: - data[cfg.Name], _ = strconv.Atoi(cfg.Value) - case ConfigConverterEnableSVGO, ConfigConverterEnableGZIP, ConfigConverterEnableConvertRepeatedDocument: - value, _ := strconv.ParseBool(cfg.Value) - data[cfg.Name] = value - default: - data[cfg.Name] = cfg.Value - } - } - + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -566,17 +497,7 @@ func (m *DBModel) GetConfigOfEmail(name ...string) (config ConfigEmail) { m.logger.Error("GetConfigOfEmail", zap.Error(err)) } - var data = make(map[string]interface{}) - for _, cfg := range configs { - switch cfg.Name { - case ConfigEmailEnable, ConfigEmailIsTLS: - data[cfg.Name], _ = strconv.ParseBool(cfg.Value) - case ConfigEmailPort, ConfigEmailDuration: - data[cfg.Name], _ = strconv.Atoi(cfg.Value) - default: - data[cfg.Name] = cfg.Value - } - } + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) m.logger.Debug("GetConfigOfEmail", zap.Any("data", data), zap.Any("config", config)) @@ -595,12 +516,7 @@ func (m *DBModel) GetConfigOfScore(name ...string) (config ConfigScore) { m.logger.Error("GetConfigOfScore", zap.Error(err)) } - var data = make(map[string]interface{}) - - for _, cfg := range configs { - data[cfg.Name], _ = strconv.Atoi(cfg.Value) - } - + data := m.convertConfig2Map(configs) bytes, _ := json.Marshal(data) json.Unmarshal(bytes, &config) @@ -632,6 +548,38 @@ func (m *DBModel) SendMail(subject, email string, body string) error { } return mail.DialAndSend(message) } +func (m *DBModel) GetCreditName() string { + creditName := m.GetConfigOfScore(ConfigScoreCreditName).CreditName + if creditName == "" { + creditName = "魔豆" + } + return creditName +} + +func (m *DBModel) convertConfig2Map(cfgs []Config) (data map[string]interface{}) { + data = make(map[string]interface{}) + for _, cfg := range cfgs { + switch strings.TrimSpace(cfg.InputType) { + case InputTypeNumber: + data[cfg.Name], _ = strconv.Atoi(cfg.Value) + case InputTypeSwitch: + data[cfg.Name], _ = strconv.ParseBool(cfg.Value) + case InputTypeSelectMulti: + arr := strings.Split(cfg.Value, ",") + if len(arr) == 1 && arr[0] == "" { + arr = []string{} + } + data[cfg.Name] = arr + case InputTypeSelect, InputTypeText, InputTypeTextarea, InputTypePassword, InputTypeImage: + data[cfg.Name] = cfg.Value + default: + // 这里只是做一个兼容处理。报错是为了提醒开发者,如果有新的输入类型,需要增加 InptType 的枚举常量,并在相应的表单进行处理 + m.logger.Error("convertConfig2Map", zap.Error(errors.New("未知的输入类型,请在枚举常量InputType中进行定义")), zap.String("inputType", cfg.InputType), zap.String("name", cfg.Name), zap.String("value", cfg.Value)) + data[cfg.Name] = cfg.Value + } + } + return +} func (m *DBModel) initConfig() (err error) { closeStatement := `
尊敬的用户,您好:
@@ -641,84 +589,85 @@ func (m *DBModel) initConfig() (err error) { // 初始化配置项 cfgs := []Config{ // 系统配置项 - {Category: ConfigCategorySystem, Name: ConfigSystemSitename, Label: "网站名称", Value: "魔豆文库", Placeholder: "请输入您网站的名称,如:魔豆文库", InputType: "text", Sort: 10, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemTitle, Label: "首页标题", Value: "MOREDOC · 魔豆文库", Placeholder: "请输入您网站的首页标题,如:魔豆文库,强大、专业的文库系统", InputType: "text", Sort: 20, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemKeywords, Label: "网站关键字", Value: "MOREDOC · 魔豆文库", Placeholder: "请输入您网站的关键字", InputType: "text", Sort: 30, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemDescription, Label: "网站描述", Value: "MOREDOC · 魔豆文库", Placeholder: "请输入您网站的描述", InputType: "textarea", Sort: 40, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemRecommendWords, Label: "首页搜索推荐词", Value: "", Placeholder: "网站首页搜索推荐关键字,多个关键字用英文逗号分隔", InputType: "text", Sort: 50, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemLogo, Label: "网站Logo", Value: "", Placeholder: "请上传一张图片作为网站Logo", InputType: "image", Sort: 60, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemFavicon, Label: "网站Favicon", Value: "", Placeholder: "请上传一张方方正正的小图片作为网站favicon,建议为 .ico 的图片", InputType: "image", Sort: 61, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemRegistrerBackground, Label: "注册页背景图", Value: "", Placeholder: "请上传一张图片作为注册页背景图", InputType: "image", Sort: 62, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemLoginBackground, Label: "登录页背景图", Value: "", Placeholder: "请上传一张图片作为登录页背景图", InputType: "image", Sort: 63, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemIcp, Label: "网站备案号", Value: "", Placeholder: "请输入您网站的备案号", InputType: "text", Sort: 69, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemDomain, Label: "网站域名", Value: "https://moredoc.mnt.ltd", Placeholder: "请输入您网站的域名访问地址,带 https:// 或 http:// 如 https://moredoc.mnt.ltd,用以生成网站地图sitemap", InputType: "text", Sort: 70, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemCopyrightStartYear, Label: "版权起始年", Value: "2019", Placeholder: "请输入您网站版权起始年,如:2019,则前台会显示如 ©2019 - 20xx 的字样", InputType: "text", Sort: 80, Options: ""}, - {Category: ConfigCategorySystem, Name: ConfigSystemAnalytics, Label: "网站统计代码", Value: "", Placeholder: "请输入您网站的统计代码,当前只支持百度统计", InputType: "textarea", Sort: 90, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemSitename, Label: "网站名称", Value: "魔豆文库", Placeholder: "请输入您网站的名称,如:魔豆文库", InputType: InputTypeText, Sort: 10, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemTitle, Label: "首页标题", Value: "MOREDOC · 魔豆文库", Placeholder: "请输入您网站的首页标题,如:魔豆文库,强大、专业的文库系统", InputType: InputTypeText, Sort: 20, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemKeywords, Label: "网站关键字", Value: "MOREDOC · 魔豆文库", Placeholder: "请输入您网站的关键字", InputType: InputTypeText, Sort: 30, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemDescription, Label: "网站描述", Value: "MOREDOC · 魔豆文库", Placeholder: "请输入您网站的描述", InputType: InputTypeTextarea, Sort: 40, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemRecommendWords, Label: "首页搜索推荐词", Value: "", Placeholder: "网站首页搜索推荐关键字,多个关键字用英文逗号分隔", InputType: InputTypeText, Sort: 50, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemLogo, Label: "网站Logo", Value: "", Placeholder: "请上传一张图片作为网站Logo", InputType: InputTypeImage, Sort: 60, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemFavicon, Label: "网站Favicon", Value: "", Placeholder: "请上传一张方方正正的小图片作为网站favicon,建议为 .ico 的图片", InputType: InputTypeImage, Sort: 61, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemRegistrerBackground, Label: "注册页背景图", Value: "", Placeholder: "请上传一张图片作为注册页背景图", InputType: InputTypeImage, Sort: 62, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemLoginBackground, Label: "登录页背景图", Value: "", Placeholder: "请上传一张图片作为登录页背景图", InputType: InputTypeImage, Sort: 63, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemIcp, Label: "网站备案号", Value: "", Placeholder: "请输入您网站的备案号", InputType: InputTypeText, Sort: 69, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemDomain, Label: "网站域名", Value: "https://moredoc.mnt.ltd", Placeholder: "请输入您网站的域名访问地址,带 https:// 或 http:// 如 https://moredoc.mnt.ltd,用以生成网站地图sitemap", InputType: InputTypeText, Sort: 70, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemCopyrightStartYear, Label: "版权起始年", Value: "2019", Placeholder: "请输入您网站版权起始年,如:2019,则前台会显示如 ©2019 - 20xx 的字样", InputType: InputTypeText, Sort: 80, Options: ""}, + {Category: ConfigCategorySystem, Name: ConfigSystemAnalytics, Label: "网站统计代码", Value: "", Placeholder: "请输入您网站的统计代码,当前只支持百度统计", InputType: InputTypeTextarea, Sort: 90, Options: ""}, // 验证码配置项 - {Category: ConfigCategoryCaptcha, Name: ConfigCaptchaHeight, Label: "验证码高度", Value: "60", Placeholder: "请输入验证码高度,默认为60", InputType: "number", Sort: 13, Options: ""}, - {Category: ConfigCategoryCaptcha, Name: ConfigCaptchaWidth, Label: "验证码宽度", Value: "240", Placeholder: "请输入验证码宽度,默认为240", InputType: "number", Sort: 14, Options: ""}, - {Category: ConfigCategoryCaptcha, Name: ConfigCaptchaLength, Label: "验证码长度", Value: "5", Placeholder: "请输入验证码长度,默认为6", InputType: "number", Sort: 15, Options: ""}, - {Category: ConfigCategoryCaptcha, Name: ConfigCaptchaType, Label: "验证码类型", Value: "digit", Placeholder: "请选择验证码类型,默认为数字", InputType: "select", Sort: 16, Options: captcha.CaptchaTypeOptions}, + {Category: ConfigCategoryCaptcha, Name: ConfigCaptchaHeight, Label: "验证码高度", Value: "60", Placeholder: "请输入验证码高度,默认为60", InputType: InputTypeNumber, Sort: 13, Options: ""}, + {Category: ConfigCategoryCaptcha, Name: ConfigCaptchaWidth, Label: "验证码宽度", Value: "240", Placeholder: "请输入验证码宽度,默认为240", InputType: InputTypeNumber, Sort: 14, Options: ""}, + {Category: ConfigCategoryCaptcha, Name: ConfigCaptchaLength, Label: "验证码长度", Value: "5", Placeholder: "请输入验证码长度,默认为6", InputType: InputTypeNumber, Sort: 15, Options: ""}, + {Category: ConfigCategoryCaptcha, Name: ConfigCaptchaType, Label: "验证码类型", Value: "digit", Placeholder: "请选择验证码类型,默认为数字", InputType: InputTypeSelect, Sort: 16, Options: captcha.CaptchaTypeOptions}, // 安全配置项 - {Category: ConfigCategorySecurity, Name: ConfigSecurityMaxDocumentSize, Label: "最大文档大小(MB)", Value: "50", Placeholder: "允许用户上传的最大文档大小,默认为50,即50MB。配置时仍需注意NGINX等反向代理服务所允许传输的最大大小", InputType: "number", Sort: 1, Options: ""}, - {Category: ConfigCategorySecurity, Name: ConfigSecurityCommentInterval, Label: "评论时间间隔", Value: "10", Placeholder: "用户评论时间间隔,单位为秒。0表示不限制。", InputType: "number", Sort: 2, Options: ""}, - {Category: ConfigCategorySecurity, Name: ConfigSecurityDocumentRelatedDuration, Label: "文档的【相关文档】有效期", Value: "7", Placeholder: "文档的相关联文档的有效期,默认为7,即7天,0或小于0,表示不开启相关文档功能", InputType: "number", Sort: 15, Options: ""}, - {Category: ConfigCategorySecurity, Name: ConfigSecurityDocumentAllowedExt, Label: "允许上传的文档类型", Value: "", Placeholder: "留空表示允许程序所支持的全部文档类型", InputType: "select-multi", Sort: 3, Options: strings.Join(filetil.GetDocumentExts(), "\n")}, - {Category: ConfigCategorySecurity, Name: ConfigSecurityIsClose, Label: "是否关闭网站", Value: "false", Placeholder: "请选择是否关闭网站", InputType: "switch", Sort: 160, Options: ""}, - {Category: ConfigCategorySecurity, Name: ConfigSecurityCloseStatement, Label: "闭站说明", Value: closeStatement, Placeholder: "关闭网站后,页面提示内容(支持HTML)", InputType: "textarea", Sort: 170, Options: ""}, - {Category: ConfigCategorySecurity, Name: ConfigSecurityEnableRegister, Label: "是否允许注册", Value: "true", Placeholder: "请选择是否允许用户注册", InputType: "switch", Sort: 18, Options: ""}, - {Category: ConfigCategorySecurity, Name: ConfigSecurityLoginRequired, Label: "是否登录才能访问", Value: "false", Placeholder: "用户是否登录了才能访问", InputType: "switch", Sort: 18, Options: ""}, - {Category: ConfigCategorySecurity, Name: ConfigSecurityEnableCaptchaLogin, Label: "是否开启登录验证码", Value: "true", Placeholder: "请选择是否开启登录验证码", InputType: "switch", Sort: 19, Options: ""}, - {Category: ConfigCategorySecurity, Name: ConfigSecurityEnableCaptchaRegister, Label: "是否开启注册验证码", Value: "true", Placeholder: "请选择是否开启注册验证码", InputType: "switch", Sort: 20, Options: ""}, - {Category: ConfigCategorySecurity, Name: ConfigSecurityEnableCaptchaComment, Label: "是否开启评论验证码", Value: "true", Placeholder: "请选择是否开启评论验证码", InputType: "switch", Sort: 21, Options: ""}, - {Category: ConfigCategorySecurity, Name: ConfigSecurityEnableCaptchaFindPassword, Label: "是否开启找回密码验证码", Value: "true", Placeholder: "请选择是否开启找回密码验证码", InputType: "switch", Sort: 22, Options: ""}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityMaxDocumentSize, Label: "最大文档大小(MB)", Value: "50", Placeholder: "允许用户上传的最大文档大小,默认为50,即50MB。配置时仍需注意NGINX等反向代理服务所允许传输的最大大小", InputType: InputTypeNumber, Sort: 1, Options: ""}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityCommentInterval, Label: "评论时间间隔", Value: "10", Placeholder: "用户评论时间间隔,单位为秒。0表示不限制。", InputType: InputTypeNumber, Sort: 2, Options: ""}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityDocumentRelatedDuration, Label: "文档的【相关文档】有效期", Value: "7", Placeholder: "文档的相关联文档的有效期,默认为7,即7天,0或小于0,表示不开启相关文档功能", InputType: InputTypeNumber, Sort: 15, Options: ""}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityDocumentAllowedExt, Label: "允许上传的文档类型", Value: "", Placeholder: "留空表示允许程序所支持的全部文档类型", InputType: InputTypeSelectMulti, Sort: 3, Options: strings.Join(filetil.GetDocumentExts(), "\n")}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityIsClose, Label: "是否关闭网站", Value: "false", Placeholder: "请选择是否关闭网站", InputType: InputTypeSwitch, Sort: 160, Options: ""}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityCloseStatement, Label: "闭站说明", Value: closeStatement, Placeholder: "关闭网站后,页面提示内容(支持HTML)", InputType: InputTypeTextarea, Sort: 170, Options: ""}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityEnableRegister, Label: "是否允许注册", Value: "true", Placeholder: "请选择是否允许用户注册", InputType: InputTypeSwitch, Sort: 18, Options: ""}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityLoginRequired, Label: "是否登录才能访问", Value: "false", Placeholder: "用户是否登录了才能访问", InputType: InputTypeSwitch, Sort: 18, Options: ""}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityEnableCaptchaLogin, Label: "是否开启登录验证码", Value: "true", Placeholder: "请选择是否开启登录验证码", InputType: InputTypeSwitch, Sort: 19, Options: ""}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityEnableCaptchaRegister, Label: "是否开启注册验证码", Value: "true", Placeholder: "请选择是否开启注册验证码", InputType: InputTypeSwitch, Sort: 20, Options: ""}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityEnableCaptchaComment, Label: "是否开启评论验证码", Value: "true", Placeholder: "请选择是否开启评论验证码", InputType: InputTypeSwitch, Sort: 21, Options: ""}, + {Category: ConfigCategorySecurity, Name: ConfigSecurityEnableCaptchaFindPassword, Label: "是否开启找回密码验证码", Value: "true", Placeholder: "请选择是否开启找回密码验证码", InputType: InputTypeSwitch, Sort: 22, Options: ""}, // 底部链接 - {Category: ConfigCategoryFooter, Name: ConfigFooterAbout, Label: "关于我们", Value: "/article/about", Placeholder: "请输入关于我们的链接地址,留空表示不显示", InputType: "text", Sort: 24, Options: ""}, - {Category: ConfigCategoryFooter, Name: ConfigFooterContact, Label: "联系我们", Value: "/article/contact", Placeholder: "请输入联系我们的链接地址,留空表示不显示", InputType: "text", Sort: 25, Options: ""}, - {Category: ConfigCategoryFooter, Name: ConfigFooterAgreement, Label: "文库协议", Value: "/article/agreement", Placeholder: "请输入文库协议的链接地址,留空表示不显示", InputType: "text", Sort: 26, Options: ""}, - {Category: ConfigCategoryFooter, Name: ConfigFooterCopyright, Label: "免责声明", Value: "/article/copyright", Placeholder: "请输入免责声明的链接地址,留空表示不显示", InputType: "text", Sort: 27, Options: ""}, - {Category: ConfigCategoryFooter, Name: ConfigFooterFeedback, Label: "意见反馈", Value: "/article/feedback", Placeholder: "请输入意见反馈的链接地址,留空表示不显示", InputType: "text", Sort: 28, Options: ""}, + {Category: ConfigCategoryFooter, Name: ConfigFooterAbout, Label: "关于我们", Value: "/article/about", Placeholder: "请输入关于我们的链接地址,留空表示不显示", InputType: InputTypeText, Sort: 24, Options: ""}, + {Category: ConfigCategoryFooter, Name: ConfigFooterContact, Label: "联系我们", Value: "/article/contact", Placeholder: "请输入联系我们的链接地址,留空表示不显示", InputType: InputTypeText, Sort: 25, Options: ""}, + {Category: ConfigCategoryFooter, Name: ConfigFooterAgreement, Label: "文库协议", Value: "/article/agreement", Placeholder: "请输入文库协议的链接地址,留空表示不显示", InputType: InputTypeText, Sort: 26, Options: ""}, + {Category: ConfigCategoryFooter, Name: ConfigFooterCopyright, Label: "免责声明", Value: "/article/copyright", Placeholder: "请输入免责声明的链接地址,留空表示不显示", InputType: InputTypeText, Sort: 27, Options: ""}, + {Category: ConfigCategoryFooter, Name: ConfigFooterFeedback, Label: "意见反馈", Value: "/article/feedback", Placeholder: "请输入意见反馈的链接地址,留空表示不显示", InputType: InputTypeText, Sort: 28, Options: ""}, // 转换配置项 - {Category: ConfigCategoryConverter, Name: ConfigConverterMaxPreview, Label: "最大预览页数", Value: "0", Placeholder: "文档允许的最大预览页数,0表示不限制", InputType: "number", Sort: 15, Options: ""}, - {Category: ConfigCategoryConverter, Name: ConfigConverterTimeout, Label: "转换超时(分钟)", Value: "30", Placeholder: "文档转换超时时间,默认为30分钟", InputType: "number", Sort: 16, Options: ""}, - {Category: ConfigCategoryConverter, Name: ConfigConverterEnableGZIP, Label: "是否启用GZIP压缩", Value: "true", Placeholder: "是否对文档SVG预览文件启用GZIP压缩,启用后转换效率会【稍微】下降,但相对直接的SVG文件减少75%的存储空间", InputType: "switch", Sort: 17, Options: ""}, - {Category: ConfigCategoryConverter, Name: ConfigConverterEnableSVGO, Label: "是否启用SVGO", Value: "false", Placeholder: "是否对文档SVG预览文件启用SVGO压缩,启用后转换效率会【明显】下降,但相对直接的SVG文件减少50%左右的存储空间", InputType: "switch", Sort: 18, Options: ""}, - {Category: ConfigCategoryConverter, Name: ConfigConverterEnableConvertRepeatedDocument, Label: "是否转换重复文档", Value: "false", Placeholder: "对于已转换过的文档,再次被上传时是否再转换一次", InputType: "switch", Sort: 20, Options: ""}, + {Category: ConfigCategoryConverter, Name: ConfigConverterMaxPreview, Label: "最大预览页数", Value: "0", Placeholder: "文档允许的最大预览页数,0表示不限制", InputType: InputTypeNumber, Sort: 15, Options: ""}, + {Category: ConfigCategoryConverter, Name: ConfigConverterTimeout, Label: "转换超时(分钟)", Value: "30", Placeholder: "文档转换超时时间,默认为30分钟", InputType: InputTypeNumber, Sort: 16, Options: ""}, + {Category: ConfigCategoryConverter, Name: ConfigConverterEnableGZIP, Label: "是否启用GZIP压缩", Value: "true", Placeholder: "是否对文档SVG预览文件启用GZIP压缩,启用后转换效率会【稍微】下降,但相对直接的SVG文件减少75%的存储空间", InputType: InputTypeSwitch, Sort: 17, Options: ""}, + {Category: ConfigCategoryConverter, Name: ConfigConverterEnableSVGO, Label: "是否启用SVGO", Value: "false", Placeholder: "是否对文档SVG预览文件启用SVGO压缩,启用后转换效率会【明显】下降,但相对直接的SVG文件减少50%左右的存储空间", InputType: InputTypeSwitch, Sort: 18, Options: ""}, + {Category: ConfigCategoryConverter, Name: ConfigConverterEnableConvertRepeatedDocument, Label: "是否转换重复文档", Value: "false", Placeholder: "对于已转换过的文档,再次被上传时是否再转换一次", InputType: InputTypeSwitch, Sort: 20, Options: ""}, // 下载配置 - {Category: ConfigCategoryDownload, Name: ConfigDownloadEnableGuestDownload, Label: "是否允许游客下载", Value: "false", Placeholder: "启用之后,未登录用户可以下载免费文档", InputType: "switch", Sort: 10, Options: ""}, - {Category: ConfigCategoryDownload, Name: ConfigDownloadFreeDownloadDuration, Label: "购买文档后多少天内允许免费重复下载", Value: "0", Placeholder: "0表示再次下载仍需购买,大于0表示指定多少天内有效", InputType: "number", Sort: 20, Options: ""}, - {Category: ConfigCategoryDownload, Name: ConfigDownloadUrlDuration, Label: "下载链接有效时长(秒)", Value: "60", Placeholder: "生成文档下载链接后多少秒之后链接失效", InputType: "number", Sort: 30, Options: ""}, - {Category: ConfigCategoryDownload, Name: ConfigDownloadTimesEveryDay, Label: "允许登录用户每天下载次数", Value: "10", Placeholder: "允许登录用户每天下载次数,0表示不允许下载", InputType: "number", Sort: 40, Options: ""}, - {Category: ConfigCategoryDownload, Name: ConfigDownloadTimesEveryIP, Label: "允许每个IP每天下载次数", Value: "10", Placeholder: "允许每个IP每天下载的次数,0表示不允许下载(针对所有用户)", InputType: "number", Sort: 41, Options: ""}, - {Category: ConfigCategoryDownload, Name: ConfigDownloadSecretKey, Label: "链接签名密钥", Value: "moredoc", Placeholder: "链接签名密钥,用于加密下载链接", InputType: "text", Sort: 50, Options: ""}, + {Category: ConfigCategoryDownload, Name: ConfigDownloadEnableGuestDownload, Label: "是否允许游客下载", Value: "false", Placeholder: "启用之后,未登录用户可以下载免费文档", InputType: InputTypeSwitch, Sort: 10, Options: ""}, + {Category: ConfigCategoryDownload, Name: ConfigDownloadFreeDownloadDuration, Label: "购买文档后多少天内允许免费重复下载", Value: "0", Placeholder: "0表示再次下载仍需购买,大于0表示指定多少天内有效", InputType: InputTypeNumber, Sort: 20, Options: ""}, + {Category: ConfigCategoryDownload, Name: ConfigDownloadUrlDuration, Label: "下载链接有效时长(秒)", Value: "60", Placeholder: "生成文档下载链接后多少秒之后链接失效", InputType: InputTypeNumber, Sort: 30, Options: ""}, + {Category: ConfigCategoryDownload, Name: ConfigDownloadTimesEveryDay, Label: "允许登录用户每天下载次数", Value: "10", Placeholder: "允许登录用户每天下载次数,0表示不允许下载", InputType: InputTypeNumber, Sort: 40, Options: ""}, + {Category: ConfigCategoryDownload, Name: ConfigDownloadTimesEveryIP, Label: "允许每个IP每天下载次数", Value: "10", Placeholder: "允许每个IP每天下载的次数,0表示不允许下载(针对所有用户)", InputType: InputTypeNumber, Sort: 41, Options: ""}, + {Category: ConfigCategoryDownload, Name: ConfigDownloadSecretKey, Label: "链接签名密钥", Value: "moredoc", Placeholder: "链接签名密钥,用于加密下载链接", InputType: InputTypeText, Sort: 50, Options: ""}, // 积分规则配置 - {Category: ConfigCategoryScore, Name: ConfigScoreRegister, Label: "注册", Value: "10", Placeholder: "注册时获得的魔豆", InputType: "number", Sort: 10, Options: ""}, - {Category: ConfigCategoryScore, Name: ConfigScoreSignIn, Label: "签到", Value: "1", Placeholder: "每日签到获得的魔豆", InputType: "number", Sort: 20, Options: ""}, - {Category: ConfigCategoryScore, Name: ConfigScoreDeleteDocument, Label: "删除文档", Value: "1", Placeholder: "删除上传文档扣除的魔豆,0表示不扣除", InputType: "number", Sort: 25, Options: ""}, - {Category: ConfigCategoryScore, Name: ConfigScoreUploadDocument, Label: "上传文档", Value: "5", Placeholder: "上传一篇文档可获得的魔豆", InputType: "number", Sort: 30, Options: ""}, - {Category: ConfigCategoryScore, Name: ConfigScoreUploadDocumentLimit, Label: "每日上传文档奖励次数", Value: "1", Placeholder: "每天最多可以获得多少次文档上传奖励,0表示无奖励。", InputType: "number", Sort: 40, Options: ""}, - {Category: ConfigCategoryScore, Name: ConfigScoreDocumentCollected, Label: "文档被收藏", Value: "1", Placeholder: "上传的文档被收藏后获得的魔豆", InputType: "number", Sort: 50, Options: ""}, - {Category: ConfigCategoryScore, Name: ConfigScoreDocumentCollectedLimit, Label: "每日文档被收藏奖励次数", Value: "1", Placeholder: "每天最多可以获得多少次文档被收藏奖励,0表示无奖励。", InputType: "number", Sort: 60, Options: ""}, - {Category: ConfigCategoryScore, Name: ConfigScoreDocumentCommented, Label: "文档被评论", Value: "1", Placeholder: "上传的文档被评论后获得的魔豆", InputType: "number", Sort: 70, Options: ""}, - {Category: ConfigCategoryScore, Name: ConfigScoreDocumentCommentedLimit, Label: "每日文档被评论奖励次数", Value: "1", Placeholder: "每天最多可以获得多少次文档被评论奖励,0表示无奖励。", InputType: "number", Sort: 80, Options: ""}, + {Category: ConfigCategoryScore, Name: ConfigScoreCreditName, Label: "积分名称", Value: "魔豆", Placeholder: "请输入网站的积分名称,默认为魔豆", InputType: InputTypeText, Sort: 1, Options: ""}, + {Category: ConfigCategoryScore, Name: ConfigScoreRegister, Label: "注册", Value: "10", Placeholder: "注册时获得的积分", InputType: InputTypeNumber, Sort: 10, Options: ""}, + {Category: ConfigCategoryScore, Name: ConfigScoreSignIn, Label: "签到", Value: "1", Placeholder: "每日签到获得的积分", InputType: InputTypeNumber, Sort: 20, Options: ""}, + {Category: ConfigCategoryScore, Name: ConfigScoreDeleteDocument, Label: "删除文档", Value: "1", Placeholder: "删除上传文档扣除的积分,0表示不扣除", InputType: InputTypeNumber, Sort: 25, Options: ""}, + {Category: ConfigCategoryScore, Name: ConfigScoreUploadDocument, Label: "上传文档", Value: "5", Placeholder: "上传一篇文档可获得的积分", InputType: InputTypeNumber, Sort: 30, Options: ""}, + {Category: ConfigCategoryScore, Name: ConfigScoreUploadDocumentLimit, Label: "每日上传文档奖励次数", Value: "1", Placeholder: "每天最多可以获得多少次文档上传奖励,0表示无奖励。", InputType: InputTypeNumber, Sort: 40, Options: ""}, + {Category: ConfigCategoryScore, Name: ConfigScoreDocumentCollected, Label: "文档被收藏", Value: "1", Placeholder: "上传的文档被收藏后获得的积分", InputType: InputTypeNumber, Sort: 50, Options: ""}, + {Category: ConfigCategoryScore, Name: ConfigScoreDocumentCollectedLimit, Label: "每日文档被收藏奖励次数", Value: "1", Placeholder: "每天最多可以获得多少次文档被收藏奖励,0表示无奖励。", InputType: InputTypeNumber, Sort: 60, Options: ""}, + {Category: ConfigCategoryScore, Name: ConfigScoreDocumentCommented, Label: "文档被评论", Value: "1", Placeholder: "上传的文档被评论后获得的积分", InputType: InputTypeNumber, Sort: 70, Options: ""}, + {Category: ConfigCategoryScore, Name: ConfigScoreDocumentCommentedLimit, Label: "每日文档被评论奖励次数", Value: "1", Placeholder: "每天最多可以获得多少次文档被评论奖励,0表示无奖励。", InputType: InputTypeNumber, Sort: 80, Options: ""}, // 邮件配置 - {Category: ConfigCategoryEmail, Name: ConfigEmailEnable, Label: "是否启用邮件服务", Value: "false", Placeholder: "邮件服务,用于找回账户密码", InputType: "switch", Sort: 10, Options: ""}, - {Category: ConfigCategoryEmail, Name: ConfigEmailHost, Label: "SMTP 服务器地址", Value: "", Placeholder: "如:smtp.exmail.com", InputType: "text", Sort: 20, Options: ""}, - {Category: ConfigCategoryEmail, Name: ConfigEmailPort, Label: "SMTP 服务器端口", Value: "465", Placeholder: "如:465", InputType: "number", Sort: 30, Options: ""}, - {Category: ConfigCategoryEmail, Name: ConfigEmailIsTLS, Label: "是否启用TLS", Value: "true", Placeholder: "如果是TLS端口,请启用", InputType: "switch", Sort: 40, Options: ""}, - {Category: ConfigCategoryEmail, Name: ConfigEmailFromName, Label: "发件人名称", Value: "", Placeholder: "请输入您要展示的发件人名称", InputType: "text", Sort: 50, Options: ""}, - {Category: ConfigCategoryEmail, Name: ConfigEmailUsername, Label: "SMTP 账号", Value: "", Placeholder: "请输入您的邮箱账户", InputType: "text", Sort: 60, Options: ""}, - {Category: ConfigCategoryEmail, Name: ConfigEmailPassword, Label: "SMTP 密码", Value: "", Placeholder: "请输入您的邮箱密码", InputType: "password", Sort: 70, Options: ""}, - {Category: ConfigCategoryEmail, Name: ConfigEmailDuration, Label: "邮件有效期", Value: "30", Placeholder: "找回密码时链接有效期,默认为30,表示30分钟", InputType: "number", Sort: 80, Options: ""}, - {Category: ConfigCategoryEmail, Name: ConfigEmailSecret, Label: "签名密钥", Value: "moredoc", Placeholder: "找回密码链接签名密钥", InputType: "text", Sort: 80, Options: ""}, - {Category: ConfigCategoryEmail, Name: ConfigEmailTestEmail, Label: "测试邮箱", Value: "", Placeholder: "用于每次变更配置时保存发送测试邮件", InputType: "text", Sort: 90, Options: ""}, + {Category: ConfigCategoryEmail, Name: ConfigEmailEnable, Label: "是否启用邮件服务", Value: "false", Placeholder: "邮件服务,用于找回账户密码", InputType: InputTypeSwitch, Sort: 10, Options: ""}, + {Category: ConfigCategoryEmail, Name: ConfigEmailHost, Label: "SMTP 服务器地址", Value: "", Placeholder: "如:smtp.exmail.com", InputType: InputTypeText, Sort: 20, Options: ""}, + {Category: ConfigCategoryEmail, Name: ConfigEmailPort, Label: "SMTP 服务器端口", Value: "465", Placeholder: "如:465", InputType: InputTypeNumber, Sort: 30, Options: ""}, + {Category: ConfigCategoryEmail, Name: ConfigEmailIsTLS, Label: "是否启用TLS", Value: "true", Placeholder: "如果是TLS端口,请启用", InputType: InputTypeSwitch, Sort: 40, Options: ""}, + {Category: ConfigCategoryEmail, Name: ConfigEmailFromName, Label: "发件人名称", Value: "", Placeholder: "请输入您要展示的发件人名称", InputType: InputTypeText, Sort: 50, Options: ""}, + {Category: ConfigCategoryEmail, Name: ConfigEmailUsername, Label: "SMTP 账号", Value: "", Placeholder: "请输入您的邮箱账户", InputType: InputTypeText, Sort: 60, Options: ""}, + {Category: ConfigCategoryEmail, Name: ConfigEmailPassword, Label: "SMTP 密码", Value: "", Placeholder: "请输入您的邮箱密码", InputType: InputTypePassword, Sort: 70, Options: ""}, + {Category: ConfigCategoryEmail, Name: ConfigEmailDuration, Label: "邮件有效期", Value: "30", Placeholder: "找回密码时链接有效期,默认为30,表示30分钟", InputType: InputTypeNumber, Sort: 80, Options: ""}, + {Category: ConfigCategoryEmail, Name: ConfigEmailSecret, Label: "签名密钥", Value: "moredoc", Placeholder: "找回密码链接签名密钥", InputType: InputTypeText, Sort: 80, Options: ""}, + {Category: ConfigCategoryEmail, Name: ConfigEmailTestEmail, Label: "测试邮箱", Value: "", Placeholder: "用于每次变更配置时保存发送测试邮件", InputType: InputTypeText, Sort: 90, Options: ""}, } for _, cfg := range cfgs { diff --git a/model/document.go b/model/document.go index be54c26..3b1892b 100644 --- a/model/document.go +++ b/model/document.go @@ -274,7 +274,7 @@ func (m *DBModel) DeleteDocument(ids []int64, deletedUserId int64, deepDelete .. docCateMap[docCate.DocumentId] = append(docCateMap[docCate.DocumentId], docCate.CategoryId) } - cfgScore := m.GetConfigOfScore(ConfigScoreDeleteDocument) + cfgScore := m.GetConfigOfScore(ConfigScoreDeleteDocument, ConfigScoreCreditName) sess := m.db.Begin() defer func() { @@ -350,7 +350,7 @@ func (m *DBModel) DeleteDocument(ids []int64, deletedUserId int64, deepDelete .. if score < 0 { score = -score } - dynamic.Content += fmt.Sprintf(",扣除了 %d 魔豆", score) + dynamic.Content += fmt.Sprintf(",扣除了 %d %s", score, cfgScore.CreditName) err = sess.Model(modelUser).Where("id = ?", doc.UserId).Update("credit_count", gorm.Expr("credit_count - ?", score)).Error if err != nil { m.logger.Error("DeleteDocument", zap.Error(err)) @@ -536,7 +536,7 @@ func (m *DBModel) CreateDocuments(documents []Document, categoryIds []int64) (do } content := fmt.Sprintf(`上传了文档《%s》`, doc.Id, html.EscapeString(doc.Title)) if award > 0 { - content += fmt.Sprintf(`,获得了 %d 个魔豆奖励`, award) + content += fmt.Sprintf(`,获得了 %d %s奖励`, award, m.GetCreditName()) } dynamics = append(dynamics, Dynamic{ UserId: doc.UserId, diff --git a/model/favorite.go b/model/favorite.go index b267944..527ad30 100644 --- a/model/favorite.go +++ b/model/favorite.go @@ -68,7 +68,7 @@ func (m *DBModel) CreateFavorite(favorite *Favorite) (err error) { return } - cfgScore := m.GetConfigOfScore(ConfigScoreDocumentCollected, ConfigScoreDocumentCollectedLimit) + cfgScore := m.GetConfigOfScore(ConfigScoreDocumentCollected, ConfigScoreDocumentCollectedLimit, ConfigScoreCreditName) if cfgScore.DocumentCollected > 0 && cfgScore.DocumentCollectedLimit > 0 { var todayFavoriteCount int64 tx.Model(&Favorite{}).Where("user_id = ? and created_at >= ?", favorite.UserId, time.Now().Format("2006-01-02")).Count(&todayFavoriteCount) @@ -86,7 +86,7 @@ func (m *DBModel) CreateFavorite(favorite *Favorite) (err error) { err = tx.Create(&Dynamic{ UserId: doc.UserId, Type: DynamicTypeFavorite, - Content: fmt.Sprintf(`分享的文档《%s》被其他用户收藏,获得 %d 魔豆奖励`, doc.Id, doc.Title, cfgScore.DocumentCollected), + Content: fmt.Sprintf(`分享的文档《%s》被其他用户收藏,获得 %d %s奖励`, doc.Id, doc.Title, cfgScore.DocumentCollected, cfgScore.CreditName), }).Error if err != nil { m.logger.Error("CreateFavorite", zap.Error(err)) diff --git a/model/sign.go b/model/sign.go index b21fd92..782ecff 100644 --- a/model/sign.go +++ b/model/sign.go @@ -35,7 +35,7 @@ func (m *DBModel) CreateSign(userId int64, ip string) (sign *Sign, err error) { SignAt: signAt, } - cfg := m.GetConfigOfScore(ConfigScoreSignIn) + cfg := m.GetConfigOfScore(ConfigScoreSignIn, ConfigScoreCreditName) sign.Award = cfg.SignIn tx := m.db.Begin() @@ -61,7 +61,7 @@ func (m *DBModel) CreateSign(userId int64, ip string) (sign *Sign, err error) { m.logger.Error("CreateSign Update", zap.Error(err)) return } - content = fmt.Sprintf("签到成功,获得 %d 个魔豆奖励", cfg.SignIn) + content = fmt.Sprintf("签到成功,获得 %d %s奖励", cfg.SignIn, cfg.CreditName) } dynamic := Dynamic{ diff --git a/model/user.go b/model/user.go index 8a112ed..b3de606 100644 --- a/model/user.go +++ b/model/user.go @@ -41,7 +41,7 @@ type User struct { FansCount int `form:"fans_count" json:"fans_count,omitempty" gorm:"column:fans_count;type:int(10);default:0;comment:粉丝数;"` FavoriteCount int `form:"favorite_count" json:"favorite_count,omitempty" gorm:"column:favorite_count;type:int(10);default:0;comment:收藏数;"` CommentCount int `form:"comment_count" json:"comment_count,omitempty" gorm:"column:comment_count;type:int(11);size:11;default:0;comment:评论数;"` - CreditCount int `form:"credit_count" json:"credit_count,omitempty" gorm:"column:credit_count;type:int(11);size:11;default:0;comment:积分数,魔豆;"` + CreditCount int `form:"credit_count" json:"credit_count,omitempty" gorm:"column:credit_count;type:int(11);size:11;default:0;comment:积分数量;"` Status int8 `form:"status" json:"status,omitempty" gorm:"column:status;type:tinyint(4);size:4;default:0;index:status;comment:用户状态:0正常 1禁用 2审核中 3审核拒绝 4审核忽略;"` Avatar string `form:"avatar" json:"avatar,omitempty" gorm:"column:avatar;type:varchar(255);size:255;comment:头像;"` Identity string `form:"identity" json:"identity,omitempty" gorm:"column:identity;type:char(18);size:18;comment:身份证号码;"` diff --git a/web/components/DocumentList.vue b/web/components/DocumentList.vue index 95c8324..c99eb34 100644 --- a/web/components/DocumentList.vue +++ b/web/components/DocumentList.vue @@ -30,8 +30,10 @@ > - {{ doc.price || 0 }} 魔豆 | - {{ doc.pages || '-' }} 页 | + {{ doc.price || 0 }} + {{ settings.system.credit_name || '魔豆' }} + | {{ doc.pages || '-' }} 页 + | {{ formatBytes(doc.size) || '-' }} | @@ -51,6 +53,7 @@ diff --git a/web/layouts/admin.vue b/web/layouts/admin.vue index 02e7f8b..3dcbf0b 100644 --- a/web/layouts/admin.vue +++ b/web/layouts/admin.vue @@ -4,13 +4,9 @@ :class="isCollapse ? 'layout-aside-collapsed' : ''" :width="'240px'" > -