chore(frontend): introduce prettier + eslint and prune unused code
- Add Prettier 3 with prettier-plugin-organize-imports (sorts/removes unused imports) - Add ESLint 10 flat config with typescript-eslint + eslint-plugin-vue + eslint-config-prettier - Add root scripts: format, format:check, lint, lint:fix - Reformat 257 files across admin-web, ops-web, desktop-client, packages - Remove unused locals/exports flagged by --noUnusedLocals/--noUnusedParameters - Fix duplicate localTabLabel key, surrogate-pair regex u-flag, NBSP literal in regex - Skip server/ (Go) and apps/browser-extension/ (deprecated per ADR) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,15 +1,8 @@
|
||||
import {
|
||||
publishToutiaoArticle,
|
||||
} from "../../../../../packages/publisher-platforms/src/toutiao";
|
||||
import type { JsonValue } from "@geo/shared-types";
|
||||
import type { JsonValue } from '@geo/shared-types'
|
||||
import { publishToutiaoArticle } from '../../../../../packages/publisher-platforms/src/toutiao'
|
||||
|
||||
import {
|
||||
fetchImageBlob,
|
||||
normalizeArticleHtml,
|
||||
sessionFetchJson,
|
||||
uploadHtmlImages,
|
||||
} from "./common";
|
||||
import type { PublishAdapter } from "./base";
|
||||
import type { PublishAdapter } from './base'
|
||||
import { fetchImageBlob, normalizeArticleHtml, sessionFetchJson, uploadHtmlImages } from './common'
|
||||
|
||||
function buildResultPayload(
|
||||
articleId: string,
|
||||
@@ -18,55 +11,55 @@ function buildResultPayload(
|
||||
externalArticleUrl: string | null,
|
||||
): Record<string, JsonValue> {
|
||||
return {
|
||||
platform: "toutiaohao",
|
||||
platform: 'toutiaohao',
|
||||
media_name: mediaName,
|
||||
external_article_id: articleId,
|
||||
external_manage_url: externalManageUrl,
|
||||
external_article_url: externalArticleUrl,
|
||||
publish_type: "publish",
|
||||
};
|
||||
publish_type: 'publish',
|
||||
}
|
||||
}
|
||||
|
||||
export const toutiaoAdapter: PublishAdapter = {
|
||||
platform: "toutiaohao",
|
||||
executionMode: "session",
|
||||
platform: 'toutiaohao',
|
||||
executionMode: 'session',
|
||||
async publish(context) {
|
||||
context.reportProgress("toutiao.normalize_html");
|
||||
const html = normalizeArticleHtml(context.article);
|
||||
context.reportProgress('toutiao.normalize_html')
|
||||
const html = normalizeArticleHtml(context.article)
|
||||
|
||||
const result = await publishToutiaoArticle(
|
||||
{
|
||||
title: context.article.title,
|
||||
html,
|
||||
coverAssetUrl: context.article.cover_asset_url,
|
||||
publishType: "publish",
|
||||
publishType: 'publish',
|
||||
},
|
||||
{
|
||||
fetchJson: (input, init) => sessionFetchJson(context.session, input, init),
|
||||
fetchImageBlob,
|
||||
uploadHtmlImages,
|
||||
reportProgress(stage) {
|
||||
context.reportProgress(`toutiao.${stage}`);
|
||||
context.reportProgress(`toutiao.${stage}`)
|
||||
},
|
||||
},
|
||||
);
|
||||
)
|
||||
|
||||
if (!result.success) {
|
||||
const summary =
|
||||
result.code === "toutiaohao_not_logged_in"
|
||||
? "头条号登录态失效,无法执行发布。"
|
||||
: result.code === "article_content_empty"
|
||||
? "文章内容为空,无法推送到头条号。"
|
||||
: result.message || "头条号发布失败。";
|
||||
result.code === 'toutiaohao_not_logged_in'
|
||||
? '头条号登录态失效,无法执行发布。'
|
||||
: result.code === 'article_content_empty'
|
||||
? '文章内容为空,无法推送到头条号。'
|
||||
: result.message || '头条号发布失败。'
|
||||
|
||||
return {
|
||||
status: "failed",
|
||||
status: 'failed',
|
||||
summary,
|
||||
error: {
|
||||
code: result.code,
|
||||
message: result.message,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const payload = buildResultPayload(
|
||||
@@ -74,12 +67,12 @@ export const toutiaoAdapter: PublishAdapter = {
|
||||
result.mediaName,
|
||||
result.externalManageUrl,
|
||||
result.externalArticleUrl,
|
||||
);
|
||||
)
|
||||
|
||||
return {
|
||||
status: "succeeded",
|
||||
status: 'succeeded',
|
||||
payload,
|
||||
summary: "头条号发布成功。",
|
||||
};
|
||||
summary: '头条号发布成功。',
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user