Files
张成 8309808835 1
2025-11-21 16:53:49 +08:00

150 lines
4.5 KiB
JavaScript

const dayjs = require("dayjs");
const fs = require('fs')
const path = require('path')
const { plu_api_linkjs, plu_ga, plu_func, plu_func_type, plu_version, querySql, op } = require("../../middleware/baseModel");
module.exports = {
"GET /config/v3_test": async (ctx, next) => {
let data = [
{
create_time: "2021-11-23 16:27:06",
last_modify_time: "2021-11-23 16:27:06",
id: 1,
name: "数据银行",
platformUrl: "databank.tmall.com",
linkUrl: "https://yunzhuan.light120.com/platform/databank/index.js",
inline: true,
},
{
create_time: "2021-11-23 16:26:38",
last_modify_time: "2021-11-23 16:26:38",
id: 2,
name: "生意参谋",
platformUrl: "sycm.taobao.com",
linkUrl: "https://yunzhuan.light120.com/platform/businessStaff/index.js",
inline: false,
},
{
create_time: "2021-11-23 16:26:03",
last_modify_time: "2021-11-23 16:26:03",
id: 3,
name: "策略中心",
platformUrl: "strategy.tmall.com",
linkUrl: "https://yunzhuan.light120.com/platform/strategy/index.js",
inline: false,
},
{
create_time: "2021-11-24 19:13:00",
last_modify_time: "2021-11-24 19:13:00",
id: 4,
name: "淘宝直播",
platformUrl: "market.m.taobao.com",
linkUrl: "https://yunzhuan.light120.com/platform/tbLive/index.js",
inline: true,
},
{
create_time: "2021-11-24 19:13:00",
last_modify_time: "2021-11-24 19:13:00",
id: 5,
name: "达摩盘",
platformUrl: "dmp.taobao.com",
linkUrl: "https://yunzhuan.light120.com/platform/dmp/index.js",
inline: true,
},
{
create_time: "2021-11-24 19:13:00",
last_modify_time: "2021-11-24 19:13:00",
id: 5,
name: "淘宝光合",
platformUrl: "creator.guanghe.taobao.com",
linkUrl: "https://yunzhuan.light120.com/platform/guanghe/index.js",
inline: true,
},
{
create_time: "2021-11-24 19:13:00",
last_modify_time: "2021-11-24 19:13:00",
id: 5,
name: "抖音电商",
platformUrl: "compass.jinritemai.com",
linkUrl: "https://yunzhuan.light120.com/platform/tikTok/index.js",
inline: true,
},
{
create_time: "2021-11-24 19:13:00",
last_modify_time: "2021-11-24 19:13:00",
id: 6,
name: "天猫详情",
platformUrl: "detail.tmall.com",
linkUrl: "https://yunzhuan.light120.com/platform/tmall/index.js",
inline: true,
},
];
return ctx.success(data);
},
"GET /config/v3": async (ctx, next) => {
const res = await plu_api_linkjs.findAll({ where: {} });
return ctx.success(res);
},
"GET /config/ga": async (ctx, next) => {
let ip = ctx.getIp();
let { title, brand, type, postion, parentSelector: parent_selector, className: class_name, icon, path, browser } = ctx.getQuery();
let res = await plu_ga.create({ title, type, brand, postion, parent_selector, class_name, icon, path, ip, browser });
return ctx.success(res);
},
"GET /config/funType": async (ctx, next) => {
const res = await plu_func_type.findAll({ where: { is_enable: 1 } });
let rows = res.map(p => {
return { key: p.id, value: p.value }
})
return ctx.success(rows);
},
"GET /config/funAll": async (ctx, next) => {
let rows = await plu_func.findAll({ where: { is_enable: 1 }, order: [["sort", "asc"]] });
return ctx.success(rows);
},
"GET /config/lastPlug": async (ctx, next) => {
const replaceUrl = (url) => {
url = url.replace('https:', '')
url = url.replace('http:', '')
return url
}
let defaultRow = {
plugVersion: '2.7.5',
plugUpdateDate: '2023-06-09',
officialUrl: "//shopant.baozun.com/plug/#/",
downUrl: '//bztic-shopant-files.oss-cn-shanghai.aliyuncs.com/front/plug/business-staff-extension_2.7.5.zip',
helpUrl: '//bztic-shopant-files.oss-cn-shanghai.aliyuncs.com/front/plug/helpDoc.pdf'
}
let row = await plu_version.findOne({ where: { is_enable: 1 }, order: [["id", "desc"]] })
if (row) {
let { plugVersion, plugUpdateDate, downUrl, helpUrl } = row
plugUpdateDate = dayjs(plugUpdateDate).format('YYYY-MM-DD')
downUrl = replaceUrl(downUrl)
helpUrl = replaceUrl(helpUrl)
defaultRow = Object.assign({}, defaultRow, { plugVersion, plugUpdateDate, downUrl, helpUrl })
}
return ctx.success(defaultRow);
},
};