跳至主要內容

CMS模块

holic-x...大约 4 分钟

CMS模块

内容管理系统

1.动态公告

数据表设计

create table notification
(
    id         bigint  							comment 'id' primary key,
    title      varchar(255)                       not null comment '公告标题',
    content    varchar(2048)                      not null comment '公告内容',
    startTime  datetime                           null comment '开始时间',
    endTime    datetime                           null comment '结束时间',
    status     tinyint  default 0                 not null comment '0: 关闭,1: 启用',
    domain     varchar(255)                       null comment '域名',
    createTime datetime default CURRENT_TIMESTAMP null comment '创建时间',
    updateTime datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP,
    creater     bigint                            null comment '创建者',
    updater     bigint                            null comment '修改者',
    isDelete   tinyint  default 0                 not null comment '是否删除'
);

实现说明

后台:通知信息管理

前台:前端SDK构建,调用后台接口获取通知弹窗

创建vite项目进行构建:npm create vite@latest 根据提示初始化项目,然后选择一个第三方弹窗库实现效果,参考网站BootCDNopen in new window

选择一个体积比较小、样式精美的组件库,此处选用swaeetalert2open in new window

image-20240501154506034

npm create vite@latest,创建一个react项目,配置细节参考Vite官方文档open in new window

​ 创建完成更新依赖并启动项目npm install、npm run dev

image-20240501155848426




import Swal from "sweetalert2";

document.addEventListener("DOMContentLoaded", function () {
  /**
   * 后端地址(本地)
   */
  const BACKEND_HOST_LOCAL = "http://localhost:8101";

  /**
   * 后端地址(线上)
   */
  const BACKEND_HOST_PROD = "http://xxx.xxx";

  function getNotificationVoUsingGet(params) {
    const url = `http://localhost:8101/api/notification/get/vo`;
    // const url = `${BACKEND_HOST_PROD}/api/notification/get/vo`;

    return fetch(url + "?" + new URLSearchParams(params))
      .then((response) => {
        if (!response.ok) {
          throw new Error("Network response was not ok");
        }
        return response.json();
      })
      .then((data) => data)
      .catch((error) => {
        // 处理错误
        console.error("Fetch request error:", error);
        throw error;
      });
  }

  const fetchNotification = function (domain) {
    // 发起请求获取通知信息的逻辑
    getNotificationVoUsingGet({ domain })
      .then((response) => {
        const data = response.data;
        const id = data.id;
        const updateTime = data.updateTime;
        if (
          !localStorage.getItem(id + updateTime) &&
          data.title &&
          data.content
        ) {
          // 使用 SweetAlert2 显示弹窗
          Swal.fire({
            title: data.title,
            text: data.content,
            icon: "info",
            confirmButtonText: "知道了",
          });

          // 存储到 localStorage
          localStorage.setItem(id + updateTime, "id");
        }
      })
      .catch((error) => {
        console.error("Fetch request error:", error);
      });
  };

  const url = new URL(location.href);
  const domain = url.hostname;
  fetchNotification(domain);
});

2.主页轮播管理

字段名称字段类型字段默认值是否允许为空字段描述索引字段数据示例
platformchar(30)pc所属平台(pc PC网站, h5 H5手机网站, ios 苹果APP, android 安卓APP, alipay 支付宝小程序, weixin 微信小程序, baidu 百度小程序)普通索引pc
event_typetinyint(2)-1事件类型(0 WEB页面, 1 内部页面(小程序或APP内部地址), 2 外部小程序(同一个主体下的小程序appid), 3 打开地图, 4 拨打电话)无索引-1
event_valuechar(255)事件值无索引
images_urlchar(255)图片地址无索引
yesapi_shopxo_s_slide_namechar(60)别名无索引
bg_colorchar(30)css背景色值无索引
is_enabletinyint(1)1是否启用(0否,1是)普通索引1
sorttinyint(3)0排序普通索引0
upd_timeint(11)0更新时间无索引0
CREATE TABLE `yesapi_shopxo_s_slide` (
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `platform` char(30) NOT NULL DEFAULT 'pc' COMMENT '所属平台(pc PC网站, h5 H5手机网站, ios 苹果APP, android 安卓APP, alipay 支付宝小程序, weixin 微信小程序, baidu 百度小程序)',
    `event_type` tinyint(2) NOT NULL DEFAULT '-1' COMMENT '事件类型(0 WEB页面, 1 内部页面(小程序或APP内部地址), 2 外部小程序(同一个主体下的小程序appid), 3 打开地图, 4 拨打电话)',
    `event_value` char(255) NOT NULL COMMENT '事件值',
    `images_url` char(255) NOT NULL COMMENT '图片地址',
    `yesapi_shopxo_s_slide_name` char(60) NOT NULL COMMENT '别名',
    `bg_color` char(30) NOT NULL COMMENT 'css背景色值',
    `is_enable` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用(0否,1是)',
    `sort` tinyint(3) NOT NULL DEFAULT '0' COMMENT '排序',
    `upd_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
    KEY `platform` (`platform`),
    KEY `is_enable` (`is_enable`),
    KEY `sort` (`sort`),
    PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT 'ShopXO商城-轮播图片';

2.日志管理

3.友链表

字段名称字段类型字段默认值是否允许为空字段描述索引字段数据示例
namevarchar(60)名称无索引
urlvarchar(150)url链接无索引
targetsmallint(2)0跳转方式,0_blank,1_self,2_parent,3_top,4framename无索引0
groupint(5)0分组无索引0
listorderint(11)50排序无索引50
statustinyint友链状态
isDeletetinyint是否删除
createTime创建时间
updateTime修改时间
CREATE TABLE `yesapi_fl_friendlink` (
    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `name` varchar(60) NOT NULL COMMENT '名称',
    `url` varchar(150) NOT NULL COMMENT 'url链接',
    `target` smallint(2) NOT NULL DEFAULT '0' COMMENT '跳转方式,0_blank,1_self,2_parent,3_top,4framename',
    `group_id` int(5) NOT NULL DEFAULT '0' COMMENT '分组ID',
    `listorder` int(11) NOT NULL DEFAULT '50' COMMENT '排序',
    PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT 'CMS建站系统-友情链接表';
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.1.3