紫微斗数结果页分享功能样式优化

- 参考八字结果页的分享功能样式
- 分享按钮固定在页面底部
- 添加渐变背景和阴影效果
- 优化页面底部padding,避免内容被遮挡
This commit is contained in:
H1d3rOne committed 2026-03-08 19:23:08 +08:00
1 parent 24eab9cb67
commit 869ffb58c6
17 files changed
+1086 -29

No files matched your search

@@ -0,0 +1,76 @@
package xuan.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xuan.entity.ShareRecord;
import xuan.repository.ShareRecordRepository;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@RestController
@RequestMapping("/api/share")
public class ShareController {
@Autowired
private ShareRecordRepository shareRecordRepository;
@PostMapping("/create")
public Map<String, Object> createShare(@RequestBody Map<String, Object> params) {
Map<String, Object> result = new HashMap<>();
try {
String type = (String) params.get("type");
String resultData = (String) params.get("resultData");
String name = (String) params.get("name");
ShareRecord shareRecord = new ShareRecord();
shareRecord.setShareId(UUID.randomUUID().toString().replace("-", "").substring(0, 16));
shareRecord.setType(type);
shareRecord.setResultData(resultData);
shareRecord.setName(name);
shareRecordRepository.save(shareRecord);
result.put("success", true);
result.put("shareId", shareRecord.getShareId());
result.put("message", "分享链接创建成功");
} catch (Exception e) {
result.put("success", false);
result.put("error", "创建分享链接失败:" + e.getMessage());
}
return result;
}
@GetMapping("/view/{shareId}")
public Map<String, Object> viewShare(@PathVariable String shareId) {
Map<String, Object> result = new HashMap<>();
try {
ShareRecord shareRecord = shareRecordRepository.findByShareId(shareId)
.orElse(null);
if (shareRecord == null) {
result.put("success", false);
result.put("error", "分享链接不存在或已过期");
return result;
}
if (shareRecord.getExpireTime() != null && shareRecord.getExpireTime().before(new java.util.Date())) {
result.put("success", false);
result.put("error", "分享链接已过期");
return result;
}
result.put("success", true);
result.put("data", shareRecord);
} catch (Exception e) {
result.put("success", false);
result.put("error", "获取分享数据失败:" + e.getMessage());
}
return result;
}
}
@@ -0,0 +1,94 @@
package xuan.entity;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "share_record")
public class ShareRecord {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(unique = true, nullable = false, length = 32)
private String shareId;
@Column(nullable = false, length = 20)
private String type;
@Column(columnDefinition = "TEXT")
private String resultData;
@Column(length = 50)
private String name;
@Column(updatable = false)
private Date createTime;
private Date expireTime;
@PrePersist
protected void onCreate() {
createTime = new Date();
if (expireTime == null) {
expireTime = new Date(System.currentTimeMillis() + 30L * 24 * 60 * 60 * 1000);
}
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getShareId() {
return shareId;
}
public void setShareId(String shareId) {
this.shareId = shareId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getResultData() {
return resultData;
}
public void setResultData(String resultData) {
this.resultData = resultData;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getExpireTime() {
return expireTime;
}
public void setExpireTime(Date expireTime) {
this.expireTime = expireTime;
}
}
@@ -0,0 +1,12 @@
package xuan.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import xuan.entity.ShareRecord;
import java.util.Optional;
@Repository
public interface ShareRecordRepository extends JpaRepository<ShareRecord, Long> {
Optional<ShareRecord> findByShareId(String shareId);
}