feat: first commit

This commit is contained in:
2025-03-27 19:37:24 +08:00
commit 3e2aa46ea1
81 changed files with 106573 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
static/*
config.yml
+22
View File
@@ -0,0 +1,22 @@
db: # 数据库配置
db: &db E:\sourceCode\2025\funjia-admin-template-vue\server\db\db.json
resourceDB: &resourceDB E:\sourceCode\2025\funjia-admin-template-vue\server\db\resourceDB.json
backupDB: &backupDB E:\sourceCode\2025\funjia-admin-template-vue\server\db\backupDB.json
logDB: &logDB E:\sourceCode\2025\funjia-admin-template-vue\server\db\logDB.json
dbBak: # 数据库备份配置
- #
original: *db
dest: F:/sourceCode/2022/compute-cms/bak/db
category: db
- #
original: *resourceDB
dest: F:/sourceCode/2022/compute-cms/bak/resourceDB
category: resourceDB
- #
original: *backupDB
dest: F:/sourceCode/2022/compute-cms/bak/backupDB
category: backupDB
- #
original: *logDB
dest: F:/sourceCode/2022/compute-cms/bak/logDB
category: logDB
+346
View File
@@ -0,0 +1,346 @@
{
"backupHistory": [
{
"name": "db20220701112510.json",
"category": "db",
"id": "cl51w799y00003cny7rm01lx4",
"createTime": "2022-07-01T03:25:10.198Z",
"status": "1,2"
},
{
"name": "resourceDB20220701112510.json",
"category": "resourceDB",
"id": "cl51w79f900033cnyd44c044t",
"createTime": "2022-07-01T03:25:10.389Z",
"status": "1,2"
},
{
"name": "backupDB20220701112510.json",
"category": "backupDB",
"id": "cl51w79ia00063cny0hty82gs",
"createTime": "2022-07-01T03:25:10.499Z",
"status": "1,2"
},
{
"name": "logDB20220701112510.json",
"category": "logDB",
"id": "cl51w79lc00093cny9oiz4tlh",
"createTime": "2022-07-01T03:25:10.608Z",
"status": "1,2"
},
{
"name": "db20220701112520.json",
"category": "db",
"id": "cl51w7h1n000c3cnyhpfjbrpj",
"createTime": "2022-07-01T03:25:20.267Z",
"status": "1"
},
{
"name": "resourceDB20220701112520.json",
"category": "resourceDB",
"id": "cl51w7h4o000f3cnybldh5115",
"createTime": "2022-07-01T03:25:20.376Z",
"status": "1"
},
{
"name": "backupDB20220701112520.json",
"category": "backupDB",
"id": "cl51w7h7w000i3cnyafqk3p1o",
"createTime": "2022-07-01T03:25:20.492Z",
"status": "1"
},
{
"name": "logDB20220701112520.json",
"category": "logDB",
"id": "cl51w7haw000l3cny4nv48t44",
"createTime": "2022-07-01T03:25:20.600Z",
"status": "1"
},
{
"name": "db20220701112530.json",
"category": "db",
"id": "cl51w7oty000o3cny5v281zy3",
"createTime": "2022-07-01T03:25:30.358Z",
"status": "1"
},
{
"name": "resourceDB20220701112530.json",
"category": "resourceDB",
"id": "cl51w7owz000r3cnybuil0qm8",
"createTime": "2022-07-01T03:25:30.467Z",
"status": "1"
},
{
"name": "backupDB20220701112530.json",
"category": "backupDB",
"id": "cl51w7p0e000u3cnyg8r9by1q",
"createTime": "2022-07-01T03:25:30.590Z",
"status": "1"
},
{
"name": "logDB20220701112530.json",
"category": "logDB",
"id": "cl51w7p37000x3cny9be2eh4h",
"createTime": "2022-07-01T03:25:30.691Z",
"status": "1"
},
{
"name": "db20220701112540.json",
"category": "db",
"id": "cl51w7wlu00103cny65nw72bm",
"createTime": "2022-07-01T03:25:40.434Z",
"status": "1"
},
{
"name": "resourceDB20220701112540.json",
"category": "resourceDB",
"id": "cl51w7wom00133cnyg0nqc9w3",
"createTime": "2022-07-01T03:25:40.534Z",
"status": "1"
},
{
"name": "backupDB20220701112540.json",
"category": "backupDB",
"id": "cl51w7wrd00163cnydmnjcgw7",
"createTime": "2022-07-01T03:25:40.633Z",
"status": "1"
},
{
"name": "logDB20220701112540.json",
"category": "logDB",
"id": "cl51w7wuk00193cny8hwlcc89",
"createTime": "2022-07-01T03:25:40.748Z",
"status": "1"
},
{
"name": "db20220701112550.json",
"category": "db",
"id": "cl51w84dz001c3cnygo6oeal7",
"createTime": "2022-07-01T03:25:50.519Z",
"status": "1"
},
{
"name": "resourceDB20220701112550.json",
"category": "resourceDB",
"id": "cl51w84h0001f3cnyfahs5q4c",
"createTime": "2022-07-01T03:25:50.628Z",
"status": "1"
},
{
"name": "backupDB20220701112550.json",
"category": "backupDB",
"id": "cl51w84jm001i3cny2tpqcjjp",
"createTime": "2022-07-01T03:25:50.722Z",
"status": "1"
},
{
"name": "logDB20220701112550.json",
"category": "logDB",
"id": "cl51w84ml001l3cnygzl3hjod",
"createTime": "2022-07-01T03:25:50.829Z",
"status": "1"
},
{
"name": "db20220701112600.json",
"category": "db",
"id": "cl51w8c63001o3cnyfevk3kyp",
"createTime": "2022-07-01T03:26:00.603Z",
"status": "1"
},
{
"name": "resourceDB20220701112600.json",
"category": "resourceDB",
"id": "cl51w8c8m001r3cny9zryh2pe",
"createTime": "2022-07-01T03:26:00.694Z",
"status": "1"
},
{
"name": "backupDB20220701112600.json",
"category": "backupDB",
"id": "cl51w8cbo001u3cnya2bw2bsi",
"createTime": "2022-07-01T03:26:00.804Z",
"status": "1"
},
{
"name": "logDB20220701112600.json",
"category": "logDB",
"id": "cl51w8ce8001x3cny1cltcbdh",
"createTime": "2022-07-01T03:26:00.896Z",
"status": "1"
},
{
"name": "db20220701112610.json",
"category": "db",
"id": "cl51w8jxq00203cny392bhx57",
"createTime": "2022-07-01T03:26:10.670Z",
"status": "1"
},
{
"name": "resourceDB20220701112610.json",
"category": "resourceDB",
"id": "cl51w8k0n00233cny37f0cx5j",
"createTime": "2022-07-01T03:26:10.775Z",
"status": "1"
},
{
"name": "backupDB20220701112610.json",
"category": "backupDB",
"id": "cl51w8k3h00263cnydfiu8inf",
"createTime": "2022-07-01T03:26:10.877Z",
"status": "1"
},
{
"name": "logDB20220701112610.json",
"category": "logDB",
"id": "cl51w8k6n00293cny0j395r0p",
"createTime": "2022-07-01T03:26:10.991Z",
"status": "1"
},
{
"name": "db20220701112620.json",
"category": "db",
"id": "cl51w8rq0002c3cny2tih0ehp",
"createTime": "2022-07-01T03:26:20.760Z",
"status": "1"
},
{
"name": "resourceDB20220701112620.json",
"category": "resourceDB",
"id": "cl51w8rv2002f3cnyddcya1y9",
"createTime": "2022-07-01T03:26:20.942Z",
"status": "1"
},
{
"name": "backupDB20220701112621.json",
"category": "backupDB",
"id": "cl51w8rz2002i3cnyhsiihd6x",
"createTime": "2022-07-01T03:26:21.086Z",
"status": "1"
},
{
"name": "logDB20220701112621.json",
"category": "logDB",
"id": "cl51w8s5u002l3cny2o7m161c",
"createTime": "2022-07-01T03:26:21.330Z",
"status": "1"
},
{
"name": "F:\\sourceCode\\2022\\compute-cms\\db20220703182610.json",
"category": "db",
"id": "cl5564dxd0000sonyakfraso1",
"createTime": "2022-07-03T10:26:10.945Z"
},
{
"name": "db20220703182700.json",
"category": "db",
"id": "cl5565fxt0000s0ny94tvajvl",
"createTime": "2022-07-03T10:27:00.209Z",
"status": "1"
},
{
"name": "resourceDB20220703182700.json",
"category": "resourceDB",
"id": "cl5565g3o0003s0nyhl4m51nu",
"createTime": "2022-07-03T10:27:00.420Z",
"status": "1"
},
{
"name": "backupDB20220703182700.json",
"category": "backupDB",
"id": "cl5565g7t0006s0ny2juo1ve3",
"createTime": "2022-07-03T10:27:00.570Z",
"status": "1"
},
{
"name": "logDB20220703182700.json",
"category": "logDB",
"id": "cl5565gas0009s0nyfyi71i0a",
"createTime": "2022-07-03T10:27:00.676Z",
"status": "1"
},
{
"name": "db20220703182710.json",
"category": "db",
"id": "cl5565npe000cs0ny4jmk13uj",
"createTime": "2022-07-03T10:27:10.274Z",
"status": "1"
},
{
"name": "resourceDB20220703182710.json",
"category": "resourceDB",
"id": "cl5565num000fs0nyfuynhsvn",
"createTime": "2022-07-03T10:27:10.462Z",
"status": "1"
},
{
"name": "backupDB20220703182710.json",
"category": "backupDB",
"id": "cl5565nxt000is0nyfaw54i99",
"createTime": "2022-07-03T10:27:10.578Z",
"status": "1"
},
{
"name": "logDB20220703182710.json",
"category": "logDB",
"id": "cl5565o0q000ls0ny49na7htm",
"createTime": "2022-07-03T10:27:10.682Z",
"status": "1"
},
{
"name": "db20220703182720.json",
"category": "db",
"id": "cl5565vh5000os0ny8q5l2dhe",
"createTime": "2022-07-03T10:27:20.346Z",
"status": "1"
},
{
"name": "resourceDB20220703182720.json",
"category": "resourceDB",
"id": "cl5565vlh000rs0ny6nvm1t28",
"createTime": "2022-07-03T10:27:20.501Z",
"status": "1"
},
{
"name": "backupDB20220703182720.json",
"category": "backupDB",
"id": "cl5565vpg000us0nyhchjafdx",
"createTime": "2022-07-03T10:27:20.644Z",
"status": "1"
},
{
"name": "logDB20220703182720.json",
"category": "logDB",
"id": "cl5565vs9000xs0nybt568rnh",
"createTime": "2022-07-03T10:27:20.745Z",
"status": "1"
},
{
"name": "db20220703182730.json",
"category": "db",
"id": "cl556638l0010s0ny42h7beca",
"createTime": "2022-07-03T10:27:30.405Z",
"status": "1"
},
{
"name": "resourceDB20220703182730.json",
"category": "resourceDB",
"id": "cl55663c00013s0nyefkb8ozn",
"createTime": "2022-07-03T10:27:30.528Z",
"status": "1"
},
{
"name": "backupDB20220703182730.json",
"category": "backupDB",
"id": "cl55663f50016s0nyhmal0v7o",
"createTime": "2022-07-03T10:27:30.641Z",
"status": "1"
},
{
"name": "logDB20220703182730.json",
"category": "logDB",
"id": "cl55663i50019s0nydmqjhwqr",
"createTime": "2022-07-03T10:27:30.749Z",
"status": "1"
}
]
}
+21146
View File
File diff suppressed because one or more lines are too long
+72195
View File
File diff suppressed because one or more lines are too long
+190
View File
@@ -0,0 +1,190 @@
{
"img": [
{
"id": "cl4u5pghi0001wgny53o32aq4",
"filename": "cl4u5pgh40000wgnya0lp59uc.jpg",
"path": "static\\cl4u5pgh40000wgnya0lp59uc.jpg",
"createTime": "2022-06-25T17:29:06.486Z"
},
{
"id": "cl4u68rlb0001qcnygmv39izm",
"filename": "cl4u68rl60000qcny6npk19d3.jpg",
"path": "static\\cl4u68rl60000qcny6npk19d3.jpg",
"createTime": "2022-06-25T17:44:07.343Z"
},
{
"id": "cl4u692vx0003qcnyaiip9dnn",
"filename": "cl4u692vq0002qcny9bmj3q30.jpg",
"path": "static\\cl4u692vq0002qcny9bmj3q30.jpg",
"createTime": "2022-06-25T17:44:21.981Z"
},
{
"id": "cl4u6agif0005qcny0kd1659n",
"filename": "cl4u6agib0004qcnyexnb9xzz.jpg",
"path": "static\\cl4u6agib0004qcnyexnb9xzz.jpg",
"createTime": "2022-06-25T17:45:26.295Z"
},
{
"id": "cl4u6ls550001ucnyhy6ghpwy",
"filename": "cl4u6ls4r0000ucny86k414pr.jpg",
"path": "static\\cl4u6ls4r0000ucny86k414pr.jpg",
"createTime": "2022-06-25T17:54:14.585Z"
},
{
"id": "cl4u6mmog0003ucnyato6b8qd",
"filename": "cl4u6mmoc0002ucny0eaa8t7f.jpg",
"path": "static\\cl4u6mmoc0002ucny0eaa8t7f.jpg",
"createTime": "2022-06-25T17:54:54.160Z"
},
{
"id": "cl4u7huus0001x4nyalm386vp",
"filename": "cl4u7huui0000x4ny1rd095z4.jpg",
"path": "static\\cl4u7huui0000x4ny1rd095z4.jpg",
"createTime": "2022-06-25T18:19:11.092Z"
},
{
"id": "cl4u7jyqy0003x4nyaa2mhk1a",
"filename": "cl4u7jyqv0002x4ny27cb0zyt.jpg",
"path": "static\\cl4u7jyqv0002x4ny27cb0zyt.jpg",
"createTime": "2022-06-25T18:20:49.450Z"
},
{
"id": "cl4uycgv80005x4nycnn4ahui",
"filename": "cl4uycgv30004x4ny4k9a0987.jpg",
"path": "static\\cl4uycgv30004x4ny4k9a0987.jpg",
"createTime": "2022-06-26T06:50:49.316Z"
},
{
"id": "cl4v0kl5h000rx4nydmi0gnhl",
"filename": "cl4v0kl59000qx4ny0xsx9j2n.jpg",
"path": "static\\cl4v0kl59000qx4ny0xsx9j2n.jpg",
"createTime": "2022-06-26T07:53:07.349Z"
},
{
"id": "cl4v0lgm3000tx4ny7i4xdeq4",
"filename": "cl4v0lglz000sx4ny17in7q6a.jpg",
"path": "static\\cl4v0lglz000sx4ny17in7q6a.jpg",
"createTime": "2022-06-26T07:53:48.123Z"
},
{
"id": "cl4v0m2wm000vx4nye3kl2794",
"filename": "cl4v0m2wi000ux4nyhb7xaykl.jpg",
"path": "static\\cl4v0m2wi000ux4nyhb7xaykl.jpg",
"createTime": "2022-06-26T07:54:17.014Z"
},
{
"id": "cl4v0mdjv000xx4nycqqngyjr",
"filename": "cl4v0mdjl000wx4ny6d4acii7.jpg",
"path": "static\\cl4v0mdjl000wx4ny6d4acii7.jpg",
"createTime": "2022-06-26T07:54:30.811Z"
},
{
"id": "cl4v0mzlq000zx4ny37649xm3",
"filename": "cl4v0mzlm000yx4nyhjcwdmwb.jpg",
"path": "static\\cl4v0mzlm000yx4nyhjcwdmwb.jpg",
"createTime": "2022-06-26T07:54:59.390Z"
},
{
"id": "cl4v0nf8t0011x4ny3vgb0njg",
"filename": "cl4v0nf8p0010x4ny1q8o96bb.jpg",
"path": "static\\cl4v0nf8p0010x4ny1q8o96bb.jpg",
"createTime": "2022-06-26T07:55:19.661Z"
},
{
"id": "cl4v0q7mv0013x4nybkoy3z9b",
"filename": "cl4v0q7ms0012x4ny29i1hy0d.jpg",
"path": "static\\cl4v0q7ms0012x4ny29i1hy0d.jpg",
"createTime": "2022-06-26T07:57:29.767Z"
},
{
"id": "cl4v0qaxk0015x4nyc61xhnsk",
"filename": "cl4v0qaxi0014x4nyd02n1y0s.jpg",
"path": "static\\cl4v0qaxi0014x4nyd02n1y0s.jpg",
"createTime": "2022-06-26T07:57:34.040Z"
},
{
"id": "cl4v0qrtf0017x4ny1y0t0wam",
"filename": "cl4v0qrtc0016x4ny1bxh12e8.jpg",
"path": "static\\cl4v0qrtc0016x4ny1bxh12e8.jpg",
"createTime": "2022-06-26T07:57:55.923Z"
},
{
"id": "cl4v0s7m10019x4ny5zta50b4",
"filename": "cl4v0s7lv0018x4nybu4u9qrp.jpg",
"path": "static\\cl4v0s7lv0018x4nybu4u9qrp.jpg",
"createTime": "2022-06-26T07:59:03.049Z"
},
{
"id": "cl4v0uvxk001bx4ny2qe0c22r",
"filename": "cl4v0uvxi001ax4ny0itgd8j9.jpg",
"path": "static\\cl4v0uvxi001ax4ny0itgd8j9.jpg",
"createTime": "2022-06-26T08:01:07.880Z"
},
{
"id": "cl4v18kp9001dx4nya6yhb8yy",
"filename": "cl4v18kp6001cx4nyg3xoh7kn.jpg",
"path": "static\\cl4v18kp6001cx4nyg3xoh7kn.jpg",
"createTime": "2022-06-26T08:11:46.509Z"
},
{
"id": "cl4v18mxi001fx4nyc6h2fozb",
"filename": "cl4v18mxe001ex4ny8147ehkt.jpg",
"path": "static\\cl4v18mxe001ex4ny8147ehkt.jpg",
"createTime": "2022-06-26T08:11:49.398Z"
},
{
"id": "cl4v18pi9001hx4ny7idea4m5",
"filename": "cl4v18pi3001gx4nyazt40dus.jpg",
"path": "static\\cl4v18pi3001gx4nyazt40dus.jpg",
"createTime": "2022-06-26T08:11:52.737Z"
},
{
"id": "cl4wq1ywm0001a0ny38cmcwa2",
"filename": "cl4wq1ywc0000a0ny2y25e0fa.jpg",
"path": "static\\cl4wq1ywc0000a0ny2y25e0fa.jpg",
"createTime": "2022-06-27T12:34:14.902Z"
},
{
"id": "cl4wq21w30003a0ny9xpd62rv",
"filename": "cl4wq21vu0002a0ny07359nx6.jpg",
"path": "static\\cl4wq21vu0002a0ny07359nx6.jpg",
"createTime": "2022-06-27T12:34:18.771Z"
},
{
"id": "cl4wq28rv0005a0nycf7k2a34",
"filename": "cl4wq28rt0004a0ny5nj4gbe2.jpg",
"path": "static\\cl4wq28rt0004a0ny5nj4gbe2.jpg",
"createTime": "2022-06-27T12:34:27.691Z"
},
{
"id": "cl550ghgz0009lsnycaace5r1",
"filename": "cl550ghgt0008lsnyc7jl7rhw.jpg",
"path": "static\\cl550ghgt0008lsnyc7jl7rhw.jpg",
"createTime": "2022-07-03T07:47:37.715Z"
},
{
"id": "cl550gk3n000blsnybbxz3rru",
"filename": "cl550gk3e000alsnyafhcc8b2.jpg",
"path": "static\\cl550gk3e000alsnyafhcc8b2.jpg",
"createTime": "2022-07-03T07:47:41.123Z"
},
{
"id": "cl550gmhr000dlsny9oxxex2y",
"filename": "cl550gmhf000clsny2c4h5a33.jpg",
"path": "static\\cl550gmhf000clsny2c4h5a33.jpg",
"createTime": "2022-07-03T07:47:44.223Z"
},
{
"id": "clzwtwwmp00029grb63lr3hcq",
"filename": "clzwtwwml00019grbfbsf6r72.viminfo",
"path": "static\\clzwtwwml00019grbfbsf6r72.viminfo",
"createTime": "2024-08-16T14:53:09.553Z"
},
{
"id": "clzwuyxln00049grb4ng91xik",
"filename": "clzwuyxlf00039grb80upct14.yarnrc",
"path": "static\\clzwuyxlf00039grb80upct14.yarnrc",
"createTime": "2024-08-16T15:22:43.739Z"
}
]
}
+2
View File
@@ -0,0 +1,2 @@
import { CreateServer } from "funjia-server";
const app = await CreateServer(4873);
+230
View File
@@ -0,0 +1,230 @@
// const.ts
var accessTokenInfo = {
"expires_in": 31536e3,
"access_token": "24.e7f0cd92f73198efe99b8ccb4466f045.2592000.1744250279.282335-23610200",
"session_secret": "",
"session_key": "",
"scope": "basic netdisk"
};
var getUrlParams = (params) => {
const body = new URLSearchParams();
for (const [key, value] of Object.entries(params)) {
body.append(key, value);
}
return body;
};
var const_default = accessTokenInfo;
// cookieUtil.ts
var CookieUtil = class _CookieUtil {
// 静态属性,用于存储单例实例
static instance = null;
accessTokenInfo = {
"expires_in": 31536e3,
"access_token": "24.e7f0cd92f73198efe99b8ccb4466f045.2592000.1744250279.282335-23610200",
"session_secret": "",
"session_key": "",
"scope": "basic netdisk",
app_id: "250528",
cookie: `BIDUPSID=B6F89C8A6AD149BCDC6FF40289C98EEA; PSTM=1719579347; PANWEB=1; Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=1719583693,1719754941; BAIDUID=10DC30A9D8497854D8275A9855AA40A6:SL=0:NR=10:FG=1; H_WISE_SIDS_BFESS=60447_60575_60600; csrfToken=UG2bfMChS2_3SL_SPVH_hKvy; Hm_lvt_fa0277816200010a74ab7d2895df481b=1741096444; Hm_lpvt_fa0277816200010a74ab7d2895df481b=1741096444; HMACCOUNT=EDFC1163C2009122; H_PS_PSSID=61027_62277_62325_62336_62347_62372_62243_62390_62420_62423_62474_62484_62499_62493_62522_62457_62455_62453_62451_62568_62610; BDSFRCVID=EB-OJexroGWT0gjJdKLdMO_dgSNbUdrTDYrEjGc3VtzSGYLVd4SGEG0Pts1-dEub6j30ogKKLmOTHpKF_2uxOjjg8UtVJeC6EG0Ptf8g0M5; H_BDCLCKID_SF=tRAOoC_-tDvDqTrP-trf5DCShUFsXTblB2Q-XPoO3M3xSlv4y4b8j4-kyhOk2M5f5mkf3fbgy4op8P3y0bb2DUA1y4vp-Jo7bmTxoUJ2-KDVeh5Gqq-KXU4ebPRiWPr9Qgbj_43Jtq4KO4bGQq5lDIuTXqO30ptJ06nhVn0MBCK0hD89DjKKD6PVKgTa54cbb4o2WbCQQnC28pcN2b5oQp-734RHBtJqBC74aPbwahQbeq06-lOUWJDkXpJvQnJjt2JxaqRCbtj1fq5jDh3MKToDb-oteltHB2Oy0hvcBn6cShnxjJJjDx7XylOt0ljPt-jr24bS3U8MEtbIe-t2XjQhDNL8q6_qJbCsQnj8HJoHjJbGq4bohjPkLmc9BtQO-DOx-M-M5bckehvsbMccBP0s0PTaL43HQgnkQq5_3b85S4bu0UJZXhKOjbbx0x-jLTneo66e345DMRFRD-nJyUPThtnnBnOi3H8HL4nv2JcJbM5m3x6qLTKkQN3T-PKO5bRu_CcJ-J8XMK8mjTjP; newlogin=1; Hm_lvt_182d6d59474cf78db37e0b2248640ea5=1742211139; H_WISE_SIDS=61027_62277_62325_62336_62347_62372_62243_62390_62420_62423_62474_62484_62499_62493_62522_62457_62455_62453_62451_62568_62610; BDUSS=HB1TDFqeGVLTWZhcURSM015WmJrVi1XaWdqbkdSUWVmaH5mc2daSzJIeG5aUUJvSVFBQUFBJCQAAAAAAAAAAAEAAAAmJicXaG5qaWFuYW4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGfY2Gdn2NhnZ; BDUSS_BFESS=HB1TDFqeGVLTWZhcURSM015WmJrVi1XaWdqbkdSUWVmaH5mc2daSzJIeG5aUUJvSVFBQUFBJCQAAAAAAAAAAAEAAAAmJicXaG5qaWFuYW4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGfY2Gdn2NhnZ; STOKEN=4b412d30af62a38ce1b769718dbf216cbd0ed032e38e2ab282aea36707e93a20; Hm_lvt_bc5920843408306f8b6fc088319384ce=1742264429; Hm_lpvt_bc5920843408306f8b6fc088319384ce=1742264434; BAIDUID_BFESS=10DC30A9D8497854D8275A9855AA40A6:SL=0:NR=10:FG=1; BDSFRCVID_BFESS=EB-OJexroGWT0gjJdKLdMO_dgSNbUdrTDYrEjGc3VtzSGYLVd4SGEG0Pts1-dEub6j30ogKKLmOTHpKF_2uxOjjg8UtVJeC6EG0Ptf8g0M5; H_BDCLCKID_SF_BFESS=tRAOoC_-tDvDqTrP-trf5DCShUFsXTblB2Q-XPoO3M3xSlv4y4b8j4-kyhOk2M5f5mkf3fbgy4op8P3y0bb2DUA1y4vp-Jo7bmTxoUJ2-KDVeh5Gqq-KXU4ebPRiWPr9Qgbj_43Jtq4KO4bGQq5lDIuTXqO30ptJ06nhVn0MBCK0hD89DjKKD6PVKgTa54cbb4o2WbCQQnC28pcN2b5oQp-734RHBtJqBC74aPbwahQbeq06-lOUWJDkXpJvQnJjt2JxaqRCbtj1fq5jDh3MKToDb-oteltHB2Oy0hvcBn6cShnxjJJjDx7XylOt0ljPt-jr24bS3U8MEtbIe-t2XjQhDNL8q6_qJbCsQnj8HJoHjJbGq4bohjPkLmc9BtQO-DOx-M-M5bckehvsbMccBP0s0PTaL43HQgnkQq5_3b85S4bu0UJZXhKOjbbx0x-jLTneo66e345DMRFRD-nJyUPThtnnBnOi3H8HL4nv2JcJbM5m3x6qLTKkQN3T-PKO5bRu_CcJ-J8XMK8mjTjP; ndut_fmt=4AED84C3D5C763CC7467C0BD21B7059718FB121D7685531B0B05A7947CD6E542; ab_sr=1.0.1_MWQ5NTY4MTE4YTU1OTJiNmI0YmUxMDAzNWY1NTkyZjkzZGNkYzBjNDg2NWYxODdhNTM0Zjk4NDNlNzIwNmJhNWFjNTVmYzlhMjllZDQ1YzBhODZkMjFkZjNmODk1YWRkYjU4ZWI4OGQ5ZTY5Yzg1YjU0YTEyNzE4ZTZmZGYyOWYzZTYzZWYwYmFiODVhOWIwMWZjMjUyMDg1ZjExYWE0Y2QzNDU0MWY3MGRiOGQ0NDk2MjZlYWY3NDM2YmI4NmNlNzUxMmEzYjEyOWY5MDI5NDNkMmY4YWUxZDJkNDUwNGI=; PANPSC=12091468029218708382%3AAuI6D6iGxsvfqD2oGDJz%2FlcS2d9ns3O52KR9sgxqNvJDnBUTmlU39wjHRUw%2FZR6kz81ttRoL0tCAzpMjKfHvSrz7Cgwm46ULLjHyseP5LOc2jyb7JodIivKBB5%2BWSCTpbaC532AuNi3w0iRW66wpcaOpfVD7rGCOIND%2Ba86tsPJVcd75GMrlL3ggdH3Ht58%2BGZF3KerqQjL6l%2B17QGFqtw%3D%3D; Hm_lpvt_182d6d59474cf78db37e0b2248640ea5=1742385365`
};
constructor() {
if (_CookieUtil.instance) {
return _CookieUtil.instance;
}
_CookieUtil.instance = this;
}
// 静态方法,用于获取单例实例
static getInstance() {
if (!_CookieUtil.instance) {
_CookieUtil.instance = new _CookieUtil();
}
return _CookieUtil.instance;
}
getHeaders = () => {
return {
"Content-Type": "application/x-www-form-urlencoded",
Host: "pan.baidu.com",
Origin: "https://pan.baidu.com",
Referer: "https://pan.baidu.com/disk/main",
"User-Agent": " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"X-Requested-With": "XMLHttpRequest",
"sec-ch-ua": `"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"`,
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "Windows",
"Cookie": this.accessTokenInfo.cookie
};
};
setCookie = ({ cookie: cookie2, accessToken }) => {
this.accessTokenInfo.access_token = accessToken;
this.accessTokenInfo.cookie = cookie2;
};
};
// getBdstoken.ts
var url = `http://pan.baidu.com/api/gettemplatevariable?clienttype=0&app_id=250528&web=1&fields=[%22bdstoken%22]`;
async function getInfo() {
const cookieUtilInstance = CookieUtil.getInstance();
const headers = cookieUtilInstance.getHeaders();
const res = await fetch(url, { headers });
const data = await res.json();
return data?.result?.bdstoken;
}
// getDpLogId.ts
var DpLogIdUtil = class _DpLogIdUtil {
// 静态属性,用于存储单例实例
static instance = null;
// 实例属性
sessionId = 0;
// 会话ID,用于标识当前会话
userId = "";
// 用户ID,用于标识用户
_countId = 0;
// 计数器ID,用于生成唯一的日志ID
client = "";
// 客户端标识
// 私有化构造函数,防止外部直接实例化
constructor() {
if (_DpLogIdUtil.instance) {
return _DpLogIdUtil.instance;
}
this.sessionId = this.getRandomInt(6);
this.userId = "00" + this.getRandomInt(8);
this._countId = 0;
this.client = "";
_DpLogIdUtil.instance = this;
}
// 静态方法,用于获取单例实例
static getInstance() {
if (!_DpLogIdUtil.instance) {
_DpLogIdUtil.instance = new _DpLogIdUtil();
}
return _DpLogIdUtil.instance;
}
// 生成指定位数的随机整数
getRandomInt = function(t) {
return Math.floor((9 * Math.random() + 1) * Math.pow(10, t - 1));
};
// 将数字补足指定位数,不足部分用0填充
prefixInteger = function(t, e) {
t += "";
for (var n = new Array(e - t.length), i = n.length, r = 0; r < i; r++)
n[r] = "0";
return n.join("") + t;
};
// 获取并递增计数器ID,确保ID在0到9999之间循环
getCountId = function() {
return this._countId < 9999 ? this._countId += 1 : this._countId = 0, this.prefixInteger(this._countId, 4);
};
// 验证用户ID是否为10位
validateUk = function(t) {
return 10 === (t + "").length;
};
// 生成完整的日志ID
getDpLogId = function() {
var e = this.userId;
return "" + this.client + this.sessionId + e + this.getCountId();
};
// 从URL中提取日志ID,如果不存在则生成一个新的日志ID
getDpLogIdByUrl = function(t) {
var e = t.match(/dp-logid=(\d+)/);
return e && e[1] ? e[1] : this.getDpLogId();
};
// 向URL中添加日志ID参数
addDpLogId = function(t, e, n) {
if (/dp-logid=\d+/.test(t))
return t;
var i = n || this.getDpLogId(e);
return t += /\?/.test(t) ? "&" : "?", t + "dp-logid=" + i;
};
};
// queryMagnetinfo.ts
var { access_token } = const_default;
async function getMagnetInfo(link, savePath) {
let bdstoken2 = await getInfo();
let dpLogId2 = DpLogIdUtil.getInstance().getDpLogId();
const url2 = `https://pan.baidu.com/rest/2.0/services/cloud_dl?clienttype=0&app_id=250528&web=1&dp-logid=${dpLogId2}&bdstoken=${bdstoken2}`;
const cookieUtilInstance = CookieUtil.getInstance();
const headers = cookieUtilInstance.getHeaders();
const params = {
method: "query_magnetinfo",
app_id: 250528,
save_path: savePath,
type: 4,
source_url: link
};
const res = await fetch(url2, {
method: "POST",
headers,
body: getUrlParams(params)
});
const data = await res.json();
return data?.total || 0;
}
// offDown.ts
var bdstoken = "";
var dpLogId = "";
var dpLogIdUtil = DpLogIdUtil.getInstance();
function generateSelectedIdx(total) {
return [...Array(total).keys()].map((i) => i + 1);
}
function getRandomNumberBetween(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function randomDelay(min = 2e3, max = 4e3) {
const delay = getRandomNumberBetween(min, max);
console.log(`\u7B49\u5F85 ${delay} \u6BEB\u79D2...`);
return sleep(delay);
}
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function down(link, savePath = "/movie/2025") {
const cookieUtilInstance = CookieUtil.getInstance();
bdstoken = await getInfo();
dpLogId = dpLogIdUtil?.getDpLogId();
const url2 = `https://pan.baidu.com/rest/2.0/services/cloud_dl?clienttype=0&app_id=250528&web=1&dp-logid=${dpLogId}&bdstoken=${bdstoken}`;
const headers = cookieUtilInstance.getHeaders();
const fileTotal = await getMagnetInfo(link, savePath);
randomDelay(2e3, 4e3);
const params = {
method: "add_task",
app_id: 250528,
save_path: savePath,
selected_idx: generateSelectedIdx(fileTotal).join(","),
task_from: 0,
t: (/* @__PURE__ */ new Date()).getTime(),
type: 4,
source_url: link
};
console.log(params);
try {
const res = await fetch(url2, {
method: "POST",
headers,
body: getUrlParams(params)
});
if (!res.ok) {
throw new Error(`HTTP error! status: ${res.status}`);
}
const data = await res.json();
console.log(data);
return data;
} catch (error) {
console.error("Fetch error:", error);
}
}
var offDown_default = {
down,
CookieUtil,
randomDelay
};
export {
offDown_default as default
};
+32
View File
@@ -0,0 +1,32 @@
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@koa/multer": "^3.0.0",
"@types/yaml": "^1.9.7",
"cuid": "^2.1.8",
"dayjs": "^1.11.3",
"koa": "^2.13.4",
"koa-body": "^4.2.0",
"koa-mount": "^4.0.0",
"koa-router": "^10.1.1",
"koa-static": "^5.0.0",
"lodash": "^4.17.21",
"lowdb": "^3.0.0",
"multer": "^1.4.5-lts.1",
"node-cron": "^3.0.1",
"uuid": "^8.3.2",
"yaml": "^2.1.1",
"funjia-server":"git+http://git.funjia.top/funjia/funjia-server.git"
},
"devDependencies": {
"vite": "^6.0.7"
}
}
+15
View File
@@ -0,0 +1,15 @@
// import RouterFactor from "../RouterFactory.mjs";
// import DBHelper from "../DBHelper.mjs";
import {RouterFactor,DBHelper} from "funjia-server/lib/funjia-server.mjs";
const getDataLog = (router) => {
const rF = new RouterFactor({
router,
db: DBHelper.logDB,
name: "dataLog"
});
rF.creaetBaseRouter();
}
export default getDataLog;
+173
View File
@@ -0,0 +1,173 @@
import cuid from "cuid";
// import getDb from "../dbServer.mjs";
import _ from "lodash";
import { getDb } from "funjia-server/lib/funjia-server.mjs";
const getEmployee = (router) => {
router.post('/api/employee/list', async (ctx) => {
// 设置头类型, 如果不设置,会直接下载该页面
ctx.type = 'application/json';
const db = await getDb();
const body = ctx.request.body;
const data = db.data?.employee?.filter((item) => {
let isMatch = true;
for (let field in body) {
if (["page", "pageSize"].includes(field)) {
continue;
}
if (typeof (item[field]) == "string") {
isMatch = item[field]?.indexOf?.(body[field]) > -1;
} else if (typeof (item[field]) == "number") {
isMatch = item[field] == body[field];
}
if (!isMatch)
break;
}
return isMatch;
});
const {
page,
pageSize
} = body;
let batchData = data;
if (page && pageSize) {
batchData = data.slice((page - 1) * pageSize, page * pageSize);
}
ctx.body = {
code: 0,
data: batchData || [],
total: data.length
};
});
router.get('/api/employee', async (ctx) => {
// 设置头类型, 如果不设置,会直接下载该页面
ctx.type = 'application/json';
const db = await getDb();
const data = db.data.employee;
const query = ctx.request.query;
console.log("参数:", query, ctx.request.body, ctx.query);
let detail = {};
if (query.id && data) {
detail = data.find((item) => {
return item.id == query.id;
});
}
ctx.body = {
code: 0,
data: detail || {}
};
});
router.post('/api/employee/add', async (ctx) => {
ctx.type = 'application/json';
const db = await getDb();
// You can also use this syntax if you prefer
if (!db.data?.employee)
db.data.employee = [];
const {
employee
} = db.data;
const data = ctx.request.body;
console.log("add:", data);
data.id = cuid();
data.createTime = new Date();
employee.push(data)
// Write db.data content to db.json
await db.write()
ctx.body = {
code: 0,
};
});
router.post('/api/employee/upd', async (ctx) => {
ctx.type = 'application/json';
const db = await getDb();
// You can also use this syntax if you prefer
if (!db.data?.employee)
db.data = {
employee: []
}
const {
employee
} = db.data;
const data = ctx.request.body;
const id = data.id;
console.log("数据Id", id);
if (id && employee) {
const currentDetail = employee.find(item => item.id == id);
if (currentDetail) {
_.merge(currentDetail, data);
}
// Write db.data content to db.json
await db.write()
}
ctx.body = {
code: 0,
};
});
router.post('/api/employee/delete', async (ctx) => {
ctx.type = 'application/json';
const db = await getDb();
// You can also use this syntax if you prefer
if (!db.data?.employee)
db.data = {
employee: []
}
let {
employee
} = db.data;
const data = ctx.request.body;
const ids = data.ids;
if (ids?.length > 0 && employee) {
let id = null;
for (let i = 0; i < ids.length; i++) {
id = ids[i];
const idx = employee.findIndex(item => item.id == id);
if (idx != -1) {
employee.splice(idx, 1);
}
}
// Write db.data content to db.json
await db.write()
}
ctx.body = {
code: 0,
};
});
router.post('/api/employee/login', async (ctx) => {
// 设置头类型, 如果不设置,会直接下载该页面
ctx.type = 'application/json';
const db = await getDb();
const data = db.data.employee;
const params = ctx.request.body;
let detail = {};
if (data) {
detail = data.find((item) => {
return item.userName == params.userName && item.pwd == params.pwd;
});
}
const code = detail ? 0 : 1;
ctx.body = {
code,
data: detail || {}
};
});
}
export default getEmployee;
+154
View File
@@ -0,0 +1,154 @@
import cuid from "cuid";
// import getDb from "../dbServer.mjs";
import {getDb} from "funjia-server/lib/funjia-server.mjs";
import _ from "lodash";
const getNotice = (router) => {
router.post('/api/Notice/list', async (ctx) => {
// 设置头类型, 如果不设置,会直接下载该页面
ctx.type = 'application/json';
const db = await getDb();
const body = ctx.request.body;
const data = db.data?.Notice?.filter((item) => {
let isMatch = true;
for (let field in body) {
if (["page", "pageSize"].includes(field)) {
continue;
}
if (typeof (item[field]) == "string") {
isMatch = item[field]?.indexOf?.(body[field]) > -1;
} else if (typeof (item[field]) == "number") {
isMatch = item[field] == body[field];
}
if (!isMatch)
break;
}
return isMatch;
});
const {
page,
pageSize
} = body;
let batchData = data;
if (page && pageSize) {
batchData = data.slice((page - 1) * pageSize, page * pageSize);
}
ctx.body = {
code: 0,
data: batchData.sort((a, b) => {
return a.sort - b.sort;
}) || [],
total: data.length
};
});
router.get('/api/Notice', async (ctx) => {
// 设置头类型, 如果不设置,会直接下载该页面
ctx.type = 'application/json';
const db = await getDb();
const data = db.data.Notice;
const query = ctx.request.query;
console.log("参数:", query, ctx.request.body, ctx.query);
let detail = {};
if (query.id && data) {
detail = data.find((item) => {
return item.id == query.id;
});
}
ctx.body = {
code: 0,
data: detail || {}
};
});
router.post('/api/Notice/add', async (ctx) => {
ctx.type = 'application/json';
const db = await getDb();
// You can also use this syntax if you prefer
if (!db.data?.Notice)
db.data.Notice = [];
const {
Notice
} = db.data;
const data = ctx.request.body;
console.log("add:", data);
data.id = cuid();
data.createTime = new Date();
Notice.push(data)
// Write db.data content to db.json
await db.write()
ctx.body = {
code: 0,
};
});
router.post('/api/Notice/upd', async (ctx) => {
ctx.type = 'application/json';
const db = await getDb();
// You can also use this syntax if you prefer
if (!db.data?.Notice)
db.data = {
Notice: []
}
const {
Notice
} = db.data;
const data = ctx.request.body;
const id = data.id;
console.log("数据Id", id);
if (id && Notice) {
const currentDetail = Notice.find(item => item.id == id);
if (currentDetail) {
_.merge(currentDetail, data);
}
// Write db.data content to db.json
await db.write()
}
ctx.body = {
code: 0,
};
});
router.post('/api/Notice/delete', async (ctx) => {
ctx.type = 'application/json';
const db = await getDb();
// You can also use this syntax if you prefer
if (!db.data?.Notice)
db.data = {
Notice: []
}
let {
Notice
} = db.data;
const data = ctx.request.body;
const ids = data.ids;
if (ids?.length > 0 && Notice) {
let id = null;
for (let i = 0; i < ids.length; i++) {
id = ids[i];
const idx = Notice.findIndex(item => item.id == id);
if (idx != -1) {
Notice.splice(idx, 1);
}
}
// Write db.data content to db.json
await db.write()
}
ctx.body = {
code: 0,
};
});
}
export default getNotice;
+16
View File
@@ -0,0 +1,16 @@
// import RouterFactor from "../RouterFactory.mjs";
// import DBHelper from "../DBHelper.mjs";
import {RouterFactor,DBHelper} from "funjia-server/lib/funjia-server.mjs";
const getQA = (router) => {
const rF = new RouterFactor({
router,
db: DBHelper.baseDB,
name: "qa"
});
rF.creaetBaseRouter();
}
export default getQA;
+108
View File
@@ -0,0 +1,108 @@
import _ from "lodash";
// import RouterFactor from "../RouterFactory.mjs";
// import DBHelper from "../DBHelper.mjs";
import {RouterFactor,DBHelper} from "funjia-server/lib/funjia-server.mjs";
const getBackupHistory = (router) => {
const rF = new RouterFactor({
router,
db: DBHelper.backupDB,
name: "backupHistory"
});
rF.createGetList();
rF.createGetDetail();
rF.createAdd();
rF.createUpdate();
rF.createDelete();
// router.post('/api/backupHistory/add', async (ctx) => {
// ctx.type = 'application/json';
// const db = await getBackupDb();
// // You can also use this syntax if you prefer
// if (!db.data.backupHistory)
// db.data.backupHistory = [];
// const {
// backupHistory
// } = db.data;
// const data = ctx.request.body;
// console.log("add:", data);
// data.id = cuid();
// data.createTime = new Date();
// backupHistory.push(data)
// // Write db.data content to db.json
// await db.write()
// ctx.body = {
// code: 0,
// };
// });
// router.post('/api/backupHistory/upd', async (ctx) => {
// ctx.type = 'application/json';
// const db = await getBackupDb();
// // You can also use this syntax if you prefer
// if (!db.data.backupHistory)
// db.data = {
// backupHistory: []
// }
// const {
// backupHistory
// } = db.data;
// const data = ctx.request.body;
// const id = data.id;
// console.log("数据Id", id);
// if (id && backupHistory) {
// const currentDetail = backupHistory.find(item => item.id == id);
// if (currentDetail) {
// _.merge(currentDetail, data);
// }
// // Write db.data content to db.json
// await db.write()
// }
// ctx.body = {
// code: 0,
// };
// });
// router.post('/api/backupHistory/delete', async (ctx) => {
// ctx.type = 'application/json';
// const db = await getBackupDb();
// // You can also use this syntax if you prefer
// if (!db.data.backupHistory)
// db.data = {
// backupHistory: []
// }
// let {
// backupHistory
// } = db.data;
// const data = ctx.request.body;
// const ids = data.ids;
// if (ids.length > 0 && backupHistory) {
// let id = null;
// for (let i = 0; i < ids.length; i++) {
// id = ids[i];
// const idx = backupHistory.findIndex(item => item.id == id);
// if (idx != -1) {
// backupHistory.splice(idx, 1);
// }
// }
// // Write db.data content to db.json
// await db.write()
// }
// ctx.body = {
// code: 0,
// };
// });
}
export default getBackupHistory;
+22
View File
@@ -0,0 +1,22 @@
import cuid from "cuid";
// import getDb from "../dbServer.mjs";
import { getDb } from "funjia-server/lib/funjia-server.mjs";
import _ from "lodash";
import offDown from "../offDown.bundle.mjs";
const baiduCloudPan = async (router) => {
router.post('/api/baiduCloudPan/offDown', async (ctx) => {
const body = ctx.request.body;
// console.log(body);
// 延迟发送请求,避免频繁对百度云盘离线下载
// await offDown.randomDelay(20000, 40000);
const data = await offDown.down(body?.magnet, body?.savePath);
console.log("云盘返回参数:", data);
ctx.body = {
code: 0,
data
}
});
}
export default baiduCloudPan;
+157
View File
@@ -0,0 +1,157 @@
import cuid from "cuid";
// import getDb from "../dbServer.mjs";
import {getDb} from "funjia-server/lib/funjia-server.mjs";
import _ from "lodash";
const getDynamic = (router) => {
router.post('/api/dynamic/list/:tableName', async (ctx) => {
// 设置头类型, 如果不设置,会直接下载该页面
ctx.type = 'application/json';
const db = await getDb();
const body = ctx.request.body;
const data = db.data[ctx.params.tableName]?.filter((item) => {
let isMatch = true;
for (let field in body) {
if (["page", "pageSize"].includes(field)) {
continue;
}
if (typeof (item[field]) == "string") {
isMatch = item[field]?.indexOf?.(body[field]) > -1;
} else if (typeof (item[field]) == "number") {
isMatch = item[field] == body[field];
}
if (!isMatch)
break;
}
return isMatch;
});
const {
page,
pageSize
} = body;
let batchData = data;
if (page && pageSize) {
batchData = data.slice((page - 1) * pageSize, page * pageSize);
}
ctx.body = {
code: 0,
data: batchData || [],
total: data.length
};
});
router.get('/api/dynamic/:tableName', async (ctx) => {
// 设置头类型, 如果不设置,会直接下载该页面
ctx.type = 'application/json';
const db = await getDb();
const data = db.data[ctx.params.tableName];
const query = ctx.request.query;
console.log("参数:", query, ctx.request.body, ctx.query);
let detail = {};
if (query.id && data) {
detail = data.find((item) => {
return item.id == query.id;
});
}
ctx.body = {
code: 0,
data: detail || {}
};
});
router.post('/api/dynamic/add/:tableName', async (ctx) => {
ctx.type = 'application/json';
const tableName=ctx.params.tableName;
const db = await getDb();
// You can also use this syntax if you prefer
if (!db.data[tableName])
db.data[tableName] = [];
const dynamic = db.data[tableName];
const data = ctx.request.body;
console.log("add:", data);
data.id = cuid();
data.createTime = new Date();
dynamic.push(data)
// Write db.data content to db.json
await db.write()
ctx.body = {
code: 0,
};
});
router.post('/api/dynamic/upd/:tableName', async (ctx) => {
ctx.type = 'application/json';
const tableName=ctx.params.tableName;
const db = await getDb();
// You can also use this syntax if you prefer
if (!db.data[tableName])
db.data = {
dynamic: []
}
const dynamic = db.data[tableName];
const data = ctx.request.body;
const id = data.id;
console.log("数据Id", id);
if (id && dynamic) {
const currentDetail = dynamic.find(item => item.id == id);
if (currentDetail) {
_.merge(currentDetail, data);
}
// Write db.data content to db.json
await db.write()
}
ctx.body = {
code: 0,
};
});
router.post('/api/dynamic/delete/:tableName', async (ctx) => {
ctx.type = 'application/json';
const tableName=ctx.params.tableName;
const db = await getDb();
// You can also use this syntax if you prefer
if (!db.data[tableName])
db.data = {
[tableName]: []
}
const dynamic = db.data[tableName];
const data = ctx.request.body;
const ids = data.ids;
if (ids?.length > 0 && dynamic) {
let id = null;
for (let i = 0; i < ids.length; i++) {
id = ids[i];
const idx = dynamic.findIndex(item => item.id == id);
if (idx != -1) {
dynamic.splice(idx, 1);
}
}
// Write db.data content to db.json
await db.write()
}
ctx.body = {
code: 0,
};
});
}
export default getDynamic;
+167
View File
@@ -0,0 +1,167 @@
import cuid from "cuid";
// import getDb, {
// getResourceDb
// } from "../dbServer.mjs";
import {getDb,getResourceDb} from "funjia-server/lib/funjia-server.mjs";
import _ from "lodash";
import multer from '@koa/multer';
//配置
var storage = multer.diskStorage({
//文件保存路径
destination: function (req, file, cb) {
cb(null, 'static') //注意路径必须存最后面在不用加斜杠
},
//修改文件名称
filename: function (req, file, cb) {
var fileFormat = (file.originalname).split(".");
const filename = cuid() + "." + fileFormat[fileFormat.length - 1];
req.filename = filename;
cb(null, filename);
}
})
//加载配置
var upload = multer({
storage: storage
})
// const upload = multer({ dest: 'static/' })
const getUpload = (router) => {
router.post('/api/leaseRecords/list', async (ctx) => {
// 设置头类型, 如果不设置,会直接下载该页面
ctx.type = 'application/json';
const db = await getDb();
const body = ctx.request.body;
const data = db.data.leaseRecords.filter((item) => {
let isMatch = true;
for (let field in body) {
if (["page", "pageSize"].includes(field)) {
continue;
}
if (typeof (item[field]) == "string") {
isMatch = item[field].indexOf(body[field]) > -1;
} else if (typeof (item[field]) == "number") {
isMatch = item[field] == body[field];
}
if (!isMatch)
break;
}
return isMatch;
});
const {
page,
pageSize
} = body;
let batchData = data;
if (page && pageSize) {
batchData = data.slice((page - 1) * pageSize, page * pageSize);
}
ctx.body = {
code: 0,
data: batchData.sort((a, b) => {
return a.sort - b.sort;
}) || [],
total: data.length
};
});
router.get('/api/img', async (ctx) => {
// 设置头类型, 如果不设置,会直接下载该页面
ctx.type = 'application/json';
const db = await getDb();
const data = db.data.leaseRecords;
const query = ctx.request.query;
console.log("参数:", query, ctx.request.body, ctx.query);
let detail = {};
if (query.id && data) {
detail = data.find((item) => {
return item.id == query.id;
});
}
ctx.body = {
code: 0,
data: detail || {}
};
});
/**
* 添加图片记录
* @param {*} path
*/
const addImg = async (filename, path) => {
const data = {};
try {
const db = await getResourceDb();
// You can also use this syntax if you prefer
if (!db.data.img)
db.data.img = [];
const {
img
} = db.data;
data.id = cuid();
data.filename = filename;
data.path = path;
data.createTime = new Date();
img.push(data)
// Write db.data content to db.json
await db.write()
} catch (error) {
console.log(error);
return null;
}
return data.id;
}
// 添加单个文件上传的路由
router.post(
'/api/upload/img',
upload.single('file'),
async (ctx) => {
const {
filename,
path
} = ctx.file;
const res = await addImg(filename, path);
ctx.body = {
code: res ? 0 : 1,
data: {
id: res,
url: path
}
}
}
);
// 添加单个文件上传的路由
router.post(
'/api/upload/file',
upload.single('file'),
async (ctx) => {
const {
filename,
path
} = ctx.file;
// const res = await addImg(filename, path);
ctx.body = {
code: 0,
data: {
url: "/resource/static/"+filename
}
}
}
);
}
export default getUpload;
+3
View File
@@ -0,0 +1,3 @@
import offDown from "./offDown.bundle.mjs";
offDown('xxx');
+16
View File
@@ -0,0 +1,16 @@
import { defineConfig } from 'vite';
export default defineConfig({
build: {
lib: {
entry: './src/main.mjs', // 你的库的入口文件,这里假设是 src/main.mjs
name: 'YourLibraryName', // 库的全局名称,将在浏览器环境中使用
formats: ['es', 'umd'], // 输出的模块格式,这里包含 ES 模块和 UMD 模块
fileName: (format) => `your-library-name.${format}.js` // 输出的文件名,根据不同的格式生成不同的文件名
},
rollupOptions: {
// 确保外部化处理那些你不想打包进库中的依赖
external: [],
}
}
});
+1596
View File
File diff suppressed because it is too large Load Diff