Skip to content

Commit

Permalink
fix sql 错误,没有正确的处理条件
Browse files Browse the repository at this point in the history
  • Loading branch information
2234839 committed Dec 15, 2023
1 parent 597c489 commit a594793
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 117 deletions.
11 changes: 5 additions & 6 deletions src/index.ts
Expand Up @@ -9,14 +9,14 @@ export default class OceanPress extends Plugin {
name = "feed plugin";
async onload() {
/** 解析并注册定时任务 */

// 使用Cron表达式调度任务
const feedBlocks = await getAllFeedBlocks();
feedBlocks.map(async (block) => {
const feedDoc = await parseFeedBlock(block.block_id);
if (feedDoc.attr.feed) {
const cron = feedDoc.attr.cron?.value ?? DEFAULT_CRON;
console.log(`注册 cron job 表达式:${cron}`, feedDoc);

scheduleCronJob(feedDoc.attr.cron?.value ?? DEFAULT_CRON, async () => {
scheduleCronJob(cron, async () => {
const feed = await parseFeedByUrl(feedDoc.attr.feed!.value);
feed.entryList
.sort((a, b) => {
Expand Down Expand Up @@ -148,16 +148,15 @@ async function parseFeedBlock(block_id: string) {
}

// 查找所有entry子块
const childBlock = (
feedObj.entryBlock = (
await sql(
`SELECT * FROM blocks
WHERE
parent_id="${block_id}" AND markdown LIKE "* [ ] #%" OR markdown LIKE "* [X] #%"
parent_id="${block_id}" AND (markdown LIKE "* [ ] #%" OR markdown LIKE "* [X] #%")
ORDER BY created DESC
LIMIT ${MAX_FEED_NUM}`,
)
).data as block[];
feedObj.entryBlock = childBlock;

return feedObj;

Expand Down
218 changes: 107 additions & 111 deletions vite.config.ts
@@ -1,127 +1,123 @@
import { resolve } from "path"
import { defineConfig, loadEnv } from "vite"
import minimist from "minimist"
import { viteStaticCopy } from "vite-plugin-static-copy"
import livereload from "rollup-plugin-livereload"
import { svelte } from "@sveltejs/vite-plugin-svelte"
import { resolve } from "path";
import { defineConfig, loadEnv } from "vite";
import minimist from "minimist";
import { viteStaticCopy } from "vite-plugin-static-copy";
import livereload from "rollup-plugin-livereload";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import zipPack from "vite-plugin-zip-pack";
import fg from 'fast-glob';
import fg from "fast-glob";

const args = minimist(process.argv.slice(2))
const isWatch = args.watch || args.w || false
const devDistDir = "./dev"
const distDir = isWatch ? devDistDir : "./dist"
const args = minimist(process.argv.slice(2));
const isWatch = args.watch || args.w || false;
const devDistDir = "./dev";
const distDir = isWatch ? devDistDir : "./dist";

console.log("isWatch=>", isWatch)
console.log("distDir=>", distDir)
console.log("isWatch=>", isWatch);
console.log("distDir=>", distDir);

export default defineConfig({
resolve: {
alias: {
"@": resolve(__dirname, "src"),
}
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},

plugins: [
svelte(),
plugins: [
svelte(),

viteStaticCopy({
targets: [
{
src: "./README*.md",
dest: "./",
},
{
src: "./icon.png",
dest: "./",
},
{
src: "./preview.png",
dest: "./",
},
{
src: "./plugin.json",
dest: "./",
},
{
src: "./src/i18n/**",
dest: "./i18n/",
},
],
}),
],
viteStaticCopy({
targets: [
{
src: "./README*.md",
dest: "./",
},
{
src: "./icon.png",
dest: "./",
},
{
src: "./preview.png",
dest: "./",
},
{
src: "./plugin.json",
dest: "./",
},
{
src: "./src/i18n/**",
dest: "./i18n/",
},
],
}),
],

// https://github.com/vitejs/vite/issues/1930
// https://vitejs.dev/guide/env-and-mode.html#env-files
// https://github.com/vitejs/vite/discussions/3058#discussioncomment-2115319
// 在这里自定义变量
define: {
"process.env.DEV_MODE": `"${isWatch}"`,
},
// https://github.com/vitejs/vite/issues/1930
// https://vitejs.dev/guide/env-and-mode.html#env-files
// https://github.com/vitejs/vite/discussions/3058#discussioncomment-2115319
// 在这里自定义变量
define: {
"process.env.DEV_MODE": `"${isWatch}"`,
},

build: {
// 输出路径
outDir: distDir,
emptyOutDir: false,
build: {
// 输出路径
outDir: distDir,
emptyOutDir: false,

// 构建后是否生成 source map 文件
sourcemap: false,
// 构建后是否生成 source map 文件
sourcemap: false,

// 设置为 false 可以禁用最小化混淆
// 或是用来指定是应用哪种混淆器
// boolean | 'terser' | 'esbuild'
// 不压缩,用于调试
minify: !isWatch,
// 设置为 false 可以禁用最小化混淆
// 或是用来指定是应用哪种混淆器
// boolean | 'terser' | 'esbuild'
// 不压缩,用于调试
minify: false,

lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, "src/index.ts"),
// the proper extensions will be added
fileName: "index",
formats: ["cjs"],
},
rollupOptions: {
plugins: [
...(
isWatch ? [
livereload(devDistDir),
{
//监听静态资源文件
name: 'watch-external',
async buildStart() {
const files = await fg([
'src/i18n/*.json',
'./README*.md',
'./plugin.json'
]);
for (let file of files) {
this.addWatchFile(file);
}
}
}
] : [
zipPack({
inDir: './dist',
outDir: './',
outFileName: 'package.zip'
})
]
)
],
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, "src/index.ts"),
// the proper extensions will be added
fileName: "index",
formats: ["cjs"],
},
rollupOptions: {
plugins: [
...(isWatch
? [
livereload(devDistDir),
{
//监听静态资源文件
name: "watch-external",
async buildStart() {
const files = await fg(["src/i18n/*.json", "./README*.md", "./plugin.json"]);
for (let file of files) {
this.addWatchFile(file);
}
},
},
]
: [
zipPack({
inDir: "./dist",
outDir: "./",
outFileName: "package.zip",
}),
]),
],

// make sure to externalize deps that shouldn't be bundled
// into your library
external: ["siyuan", "process"],
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ["siyuan", "process"],

output: {
entryFileNames: "[name].js",
assetFileNames: (assetInfo) => {
if (assetInfo.name === "style.css") {
return "index.css"
}
return assetInfo.name
},
},
output: {
entryFileNames: "[name].js",
assetFileNames: (assetInfo) => {
if (assetInfo.name === "style.css") {
return "index.css";
}
return assetInfo.name;
},
}
})
},
},
},
});

0 comments on commit a594793

Please sign in to comment.