Skip to content

Commit

Permalink
fix: restructure files
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Mar 14, 2024
1 parent 8974d5a commit d8c4723
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions cross/crossPageUtils.spec.ts → common/pageUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
*/

import { describe, it } from "vitest"
import CrossPageUtils from "./crossPageUtils"
import PageUtils from "./pageUtils"

describe("test crossPageUtils", () => {
it("test subPlatformName", () => {
const result = CrossPageUtils.subPlatformName("Gitlabvuepress2", 11)
const result = PageUtils.subPlatformName("Gitlabvuepress2", 11)
console.log(result)
})
})
4 changes: 2 additions & 2 deletions cross/crossPageUtils.ts → common/pageUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { StrUtil } from "zhi-common"
* @author terwer
* @since 1.18.0
*/
class CrossPageUtils {
class PageUtils {
/**
* 缩略展示平台名称
*
Expand Down Expand Up @@ -79,4 +79,4 @@ class CrossPageUtils {
}
}

export default CrossPageUtils
export default PageUtils
10 changes: 5 additions & 5 deletions public/libs/node-fetch-cjs/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5019,11 +5019,11 @@ var ReferrerPolicy = new Set([
"same-origin",
"origin",
"strict-origin",
"origin-when-cross-origin",
"strict-origin-when-cross-origin",
"origin-when-common-origin",
"strict-origin-when-common-origin",
"unsafe-url"
]);
var DEFAULT_REFERRER_POLICY = "strict-origin-when-cross-origin";
var DEFAULT_REFERRER_POLICY = "strict-origin-when-common-origin";
function validateReferrerPolicy(referrerPolicy) {
if (!ReferrerPolicy.has(referrerPolicy)) {
throw new TypeError(`Invalid referrerPolicy: ${referrerPolicy}`);
Expand Down Expand Up @@ -5095,7 +5095,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
return "no-referrer";
}
return referrerOrigin.toString();
case "strict-origin-when-cross-origin":
case "strict-origin-when-common-origin":
if (referrerURL.origin === currentURL.origin) {
return referrerURL;
}
Expand All @@ -5108,7 +5108,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
return referrerURL;
}
return "no-referrer";
case "origin-when-cross-origin":
case "origin-when-common-origin":
if (referrerURL.origin === currentURL.origin) {
return referrerURL;
}
Expand Down
8 changes: 4 additions & 4 deletions siyuan/invoke/pluginInvoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import PublisherPlugin from "../index"
import { createSiyuanAppLogger } from "../appLogger"
import { showIframeDialog } from "../iframeDialog"
import PageUtils from "../utils/pageUtils.ts"
import WidgetPageUtils from "../utils/widgetPageUtils.ts"
import { IObject } from "siyuan"
import { isSiyuanFileExists } from "../utils/utils"

Expand All @@ -45,7 +45,7 @@ export class PluginInvoke {
}

public async showBlogDialog() {
const pageId: string | undefined = PageUtils.getPageId()
const pageId: string | undefined = WidgetPageUtils.getPageId()
const pageUrl = `${this.blogPluginBase}/post/${pageId}`

// 临时开启预览权限
Expand Down Expand Up @@ -75,14 +75,14 @@ export class PluginInvoke {
}

public async showPicbedDialog() {
const pageId: string | undefined = PageUtils.getPageId()
const pageId: string | undefined = WidgetPageUtils.getPageId()
const pageUrl = `${this.picgoPluginBase}/?pageId=${pageId}`
this.logger.info(`Will open page => ${pageUrl}`)
showIframeDialog(this.pluginInstance, pageUrl)
}

public async showPicbedSettingDialog() {
const pageId: string | undefined = PageUtils.getPageId()
const pageId: string | undefined = WidgetPageUtils.getPageId()
const pageUrl = `${this.picgoPluginBase}/setting?pageId=${pageId}`
this.logger.info(`Will open page => ${pageUrl}`)
showIframeDialog(this.pluginInstance, pageUrl)
Expand Down
14 changes: 7 additions & 7 deletions siyuan/invoke/widgetInvoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { DeviceDetection, DeviceTypeEnum } from "zhi-device"
import { createSiyuanAppLogger } from "../appLogger"
import PageUtils from "../utils/pageUtils.ts"
import WidgetPageUtils from "../utils/widgetPageUtils.ts"
import { showIframeDialog } from "../iframeDialog"
import PublisherPlugin from "../index"
import { StrUtil } from "zhi-common"
Expand All @@ -44,7 +44,7 @@ export class WidgetInvoke {
}

public async showPublisherBatchPublishDialog() {
let pageId: string | undefined = PageUtils.getPageId()
let pageId: string | undefined = WidgetPageUtils.getPageId()
if (pageId == "") {
pageId = undefined
}
Expand All @@ -65,23 +65,23 @@ export class WidgetInvoke {
}

public async showPublisherAiChatDialog() {
let pageId: string | undefined = PageUtils.getPageId()
let pageId: string | undefined = WidgetPageUtils.getPageId()
if (pageId == "") {
pageId = undefined
}
await this.showPage(`/ai/chat?id=${pageId}`)
}

public async showPublisherAiChatTab() {
let pageId: string | undefined = PageUtils.getPageId()
let pageId: string | undefined = WidgetPageUtils.getPageId()
if (pageId == "") {
pageId = undefined
}
this.showTab(`/ai/chat?id=${pageId}`, this.pluginInstance.i18n.aiChatTab)
}

public async showPublisherSinglePublishDialog() {
let pageId: string | undefined = PageUtils.getPageId()
let pageId: string | undefined = WidgetPageUtils.getPageId()
if (pageId == "") {
pageId = undefined
}
Expand All @@ -107,7 +107,7 @@ export class WidgetInvoke {
}

public async showPublisherGeneralSettingDialog() {
let pageId: string | undefined = PageUtils.getPageId()
let pageId: string | undefined = WidgetPageUtils.getPageId()
if (pageId == "") {
pageId = undefined
}
Expand All @@ -116,7 +116,7 @@ export class WidgetInvoke {
}

public async showPublisherAboutDialog() {
let pageId: string | undefined = PageUtils.getPageId()
let pageId: string | undefined = WidgetPageUtils.getPageId()
if (pageId == "") {
pageId = undefined
}
Expand Down
10 changes: 5 additions & 5 deletions siyuan/utils/menuUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
import { IMenuItemOption } from "siyuan"
import { ObjectUtil } from "zhi-common"
import { DYNAMIC_CONFIG_KEY } from "../Constants.ts"
import CrossPageUtils from "../../cross/crossPageUtils.ts"
import PageUtils from "~/common/pageUtils.ts"
import { icons } from "./svg.ts"
import HtmlUtils from "./htmlUtils.ts"
import { WidgetInvoke } from "../invoke/widgetInvoke.ts"
import PublisherPlugin from "../index.ts"
import { PluginInvoke } from "../invoke/pluginInvoke.ts"
import PageUtils from "./pageUtils.ts"
import WidgetPageUtils from "./widgetPageUtils.ts"

class MenuUtils {
public static getQuickMenus(
Expand All @@ -42,7 +42,7 @@ class MenuUtils {
pageId?: string
) {
if (!pageId) {
pageId = PageUtils.getPageId()
pageId = WidgetPageUtils.getPageId()
if (pageId == "") {
pageId = undefined
}
Expand All @@ -69,7 +69,7 @@ class MenuUtils {
if (config.isEnabled === true) {
const submenu = {
iconHTML: `${icon}`,
label: CrossPageUtils.longPlatformName(config.platformName, 11),
label: PageUtils.longPlatformName(config.platformName, 11),
disabled: !config.isAuth,
click: async () => {
const key = config.platformKey
Expand All @@ -88,7 +88,7 @@ class MenuUtils {

public static async getExtendMenus(pluginInstance: PublisherPlugin, pluginInvoke: PluginInvoke, pageId?: string) {
if (!pageId) {
pageId = PageUtils.getPageId()
pageId = WidgetPageUtils.getPageId()
if (pageId == "") {
pageId = undefined
}
Expand Down
4 changes: 2 additions & 2 deletions siyuan/utils/pageUtils.ts → siyuan/utils/widgetPageUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* 文档工具类
*/
class PageUtils {
class WidgetPageUtils {
public static getPageId() {
// 查找包含 protyle 类但不包含 fn__none 的 div 元素
const protyleElement = document.querySelector("div.protyle:not(.fn__none)")
Expand All @@ -37,4 +37,4 @@ class PageUtils {
}
}

export default PageUtils
export default WidgetPageUtils
4 changes: 2 additions & 2 deletions src/components/publish/QuickPublishSelectPlatform.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { HtmlUtil, JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { DYNAMIC_CONFIG_KEY } from "~/src/utils/constants.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { useLoadingTimer } from "~/src/composables/useLoadingTimer.ts"
import CrossPageUtils from "~/cross/crossPageUtils.ts"
import PageUtils from "~/common/pageUtils.ts"
import Adaptors from "~/src/adaptors"
import { Utils } from "~/src/utils/utils.ts"
import { usePublish } from "~/src/composables/usePublish.ts"
Expand Down Expand Up @@ -206,7 +206,7 @@ onBeforeMount(async () => {
<i class="el-icon">
<span v-html="cfg?.platformIcon"></span>
</i>
{{ CrossPageUtils.longPlatformName(cfg?.platformName, 11) }}
{{ PageUtils.longPlatformName(cfg?.platformName, 11) }}
</el-text>
</el-badge>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/publish/SinglePublishDoPublish.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import PublishTitle from "~/src/components/publish/form/PublishTitle.vue"
import { useChatGPT } from "~/src/composables/useChatGPT.ts"
import _ from "lodash-es"
import { useLoadingTimer } from "~/src/composables/useLoadingTimer.ts"
import CrossPageUtils from "~/cross/crossPageUtils.ts"
import PageUtils from "~/common/pageUtils.ts"
import { ITagConfig } from "~/src/types/ITagConfig.ts"

const logger = createAppLogger("single-publish-do-publish")
Expand Down Expand Up @@ -285,7 +285,7 @@ const topTitle = computed(() => {

let title = "当前操作的平台为 - "
const platName = platformName ? platformName : key
title += CrossPageUtils.longPlatformName(platName, 11)
title += PageUtils.longPlatformName(platName, 11)
if (blogName) {
title += " - " + blogName
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/publish/SinglePublishSelectPlatform.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { HtmlUtil, JsonUtil, ObjectUtil, StrUtil } from "zhi-common"
import { DYNAMIC_CONFIG_KEY } from "~/src/utils/constants.ts"
import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { useLoadingTimer } from "~/src/composables/useLoadingTimer.ts"
import CrossPageUtils from "~/cross/crossPageUtils.ts"
import PageUtils from "~/common/pageUtils.ts"
import Adaptors from "~/src/adaptors"
import { Utils } from "~/src/utils/utils.ts"
import { usePublish } from "~/src/composables/usePublish.ts"
Expand Down Expand Up @@ -210,7 +210,7 @@ onBeforeMount(async () => {
<i class="el-icon">
<span v-html="cfg?.platformIcon"></span>
</i>
{{ CrossPageUtils.longPlatformName(cfg?.platformName, 11) }}
{{ PageUtils.longPlatformName(cfg?.platformName, 11) }}
</el-text>
</el-badge>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/publish/form/PublishPlatform.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { usePublishSettingStore } from "~/src/stores/usePublishSettingStore.ts"
import { svgIcons } from "../../../utils/svgIcons.ts"
import { pre } from "~/src/platforms/pre.ts"
import { createAppLogger } from "~/src/utils/appLogger.ts"
import CrossPageUtils from "~/cross/crossPageUtils.ts"
import PageUtils from "~/common/pageUtils.ts"

const logger = createAppLogger("publish-platform")

Expand Down Expand Up @@ -106,7 +106,7 @@ onMounted(async () => {
<p>请选择要发布的平台:</p>
<div class="syp-distri-platform-container">
<a v-for="cfg in formData.dynamicConfigArray" class="distri-item" @click="handleCheck(cfg.platformKey)">
<el-tooltip :content="CrossPageUtils.longPlatformName(cfg.platformName, 20)" placement="bottom">
<el-tooltip :content="PageUtils.longPlatformName(cfg.platformName, 20)" placement="bottom">
<el-icon class="platform-icon">
<span v-html="cfg.platformIcon"></span>
</el-icon>
Expand Down
6 changes: 3 additions & 3 deletions src/components/set/publish/form/PlatformQuickAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { useRoute, useRouter } from "vue-router"
import { onMounted, reactive, ref, watch } from "vue"
import { useVueI18n } from "~/src/composables/useVueI18n.ts"
import { usePlatformDefine } from "~/src/composables/usePlatformDefine.ts"
import CrossPageUtils from "../../../../../cross/crossPageUtils.ts"
import PageUtils from "~/common/pageUtils.ts"
import DrawerBoxBridge from "~/src/components/common/DrawerBoxBridge.vue"
import { appBase } from "~/src/utils/constants.ts"
import { createAppLogger } from "~/src/utils/appLogger.ts"
Expand Down Expand Up @@ -115,7 +115,7 @@ const handleAddPlatform = (cfg?: DynamicConfig) => {
const platformKey = cfg?.platformKey ?? ""
const subPlatformType = cfg?.subPlatformType ?? ""
const url = `/setting/platform/add/${platformGroup}?showBack=trye&key=${platformKey}&sub=${subPlatformType}`
const title = CrossPageUtils.longPlatformName(cfg?.platformName ?? cfg?.platformType ?? "")
const title = PageUtils.longPlatformName(cfg?.platformName ?? cfg?.platformType ?? "")
goToPublisherDrawer(`添加 ${title} 平台`, url)
}

Expand Down Expand Up @@ -156,7 +156,7 @@ onMounted(() => {
<i class="el-icon">
<span v-html="preItem?.platformIcon"></span>
</i>
{{ CrossPageUtils.shortPlatformName(preItem.platformName, 6) }}
{{ PageUtils.shortPlatformName(preItem.platformName, 6) }}
</el-text>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import { PublisherAppInstance } from "~/src/publisherAppInstance.ts"
import { CommonWebConfig } from "~/src/adaptors/web/base/commonWebConfig.ts"
import { Utils } from "~/src/utils/utils.ts"
import { useSiyuanDevice } from "~/src/composables/useSiyuanDevice.ts"
import CrossPageUtils from "../../../../../cross/crossPageUtils.ts"
import PageUtils from "~/common/pageUtils.ts"

const logger = createAppLogger("publish-platform-setting-list")

Expand Down Expand Up @@ -415,7 +415,7 @@ onMounted(async () => {
:type="platform.isAuth ? 'success' : 'danger'"
>
<span :title="platform.platformName">
{{ CrossPageUtils.longPlatformName(platform.platformName, 11) }}
{{ PageUtils.longPlatformName(platform.platformName, 11) }}
</span>
<span class="name-edit" @click="handleChangePlatformDefine(platform)">
<el-icon> <span v-html="svgIcons.iconIFEdit"></span> </el-icon>
Expand Down
4 changes: 2 additions & 2 deletions src/locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,9 +675,9 @@ export default {

"setting.blog.middlewareUrl.new": "Fresh Proxy (Recommended)",
"setting.blog.corsAnywhereUrl.tip":
"CORS Global Proxy, once configured, helps alleviate browser cross-origin issues.",
"CORS Global Proxy, once configured, helps alleviate browser common-origin issues.",
"setting.blog.middlewareUrl.my.new.tip":
"Enhanced CORS proxy, enabling comprehensive cross-origin requests. It is advisable to deploy independently. For deployment guidance, kindly refer to https://github.com/Zibri/cloudflare-cors-anywhere.",
"Enhanced CORS proxy, enabling comprehensive common-origin requests. It is advisable to deploy independently. For deployment guidance, kindly refer to https://github.com/Zibri/cloudflare-cors-anywhere.",
"reminder.blog.middlewareUrl.my.warning":
"A special note: Request limits are set at '100,000 times/day' and '1,000 times/10 minutes'. For the benefit of all, kindly refrain from malicious requests; otherwise, we reserve the right to terminate this proxy service.",

Expand Down
6 changes: 3 additions & 3 deletions src/workers/QuickPublish.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { useSiyuanApi } from "~/src/composables/useSiyuanApi.ts"
import { usePublishConfig } from "~/src/composables/usePublishConfig.ts"
import { pre } from "~/src/platforms/pre.ts"
import { useLoadingTimer } from "~/src/composables/useLoadingTimer.ts"
import CrossPageUtils from "~/cross/crossPageUtils.ts"
import PageUtils from "~/common/pageUtils.ts"
import { SiyuanDevice } from "zhi-device"
import { ElMessage, ElMessageBox } from "element-plus"
import { useVueI18n } from "~/src/composables/useVueI18n.ts"
Expand Down Expand Up @@ -134,7 +134,7 @@ onMounted(async () => {
<div v-else-if="singleFormData.publishProcessStatus" class="success-tips">
{{ singleFormData.isAdd ? "发布到" : "更新文章到" }}
<span :title="formData.processResult.key">
[{{ CrossPageUtils.subPlatformName(formData.processResult.key, 6) }}]
[{{ PageUtils.subPlatformName(formData.processResult.key, 6) }}]
</span>
<span :title="formData.processResult.name" v-if="!StrUtil.isEmptyString(formData.processResult.name)">
{{ `[${StrUtil.getByLength(formData.processResult.name, 8)}]` }}
Expand All @@ -146,7 +146,7 @@ onMounted(async () => {
<div v-else class="fail-tips">
{{ singleFormData.isAdd ? "发布到" : "更新文章到" }}
<span :title="formData.processResult.key">
[{{ CrossPageUtils.subPlatformName(formData.processResult.key, 6) }}]
[{{ PageUtils.subPlatformName(formData.processResult.key, 6) }}]
</span>
<span :title="formData.processResult.name" v-if="!StrUtil.isEmptyString(formData.processResult.name)">
{{ `[${StrUtil.getByLength(formData.processResult.name, 8)}]` }}
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export default defineConfig({
setupFiles: ["./src/setup.ts"],
include: [
"src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
"cross/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
"common/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
],
server: {
deps: {
Expand Down

0 comments on commit d8c4723

Please sign in to comment.