Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add router and pages #295

Merged
merged 1 commit into from Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/picgo-plugin-app/.gitignore
Expand Up @@ -12,7 +12,6 @@ dist
dist-ssr
*.local
build
lib
__pycache__
components.d.ts

Expand Down
4 changes: 4 additions & 0 deletions packages/picgo-plugin-app/package.json
Expand Up @@ -21,7 +21,11 @@
"vue-tsc": "^2.0.6"
},
"dependencies": {
"@vueuse/core": "^10.9.0",
"vue": "^3.4.21",
"vue-i18n": "^9.10.1",
"vue-router": "^4.3.0",
"zhi-common": "^1.31.0",
"zhi-lib-base": "^0.8.0"
}
}
10 changes: 7 additions & 3 deletions packages/picgo-plugin-app/src/App.vue
Expand Up @@ -7,8 +7,12 @@
- of this license document, but changing it is not allowed.
-->

<script setup lang="ts"></script>

<template>
<div>app</div>
<app-layout>
<router-view></router-view>
</app-layout>
</template>

<script setup lang="ts">
import AppLayout from "@/layouts/AppLayout.vue"
</script>
16 changes: 16 additions & 0 deletions packages/picgo-plugin-app/src/components/ExternalPicgoSetting.vue
@@ -0,0 +1,16 @@
<!--
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2024 Terwer, Inc. <https://terwer.space/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-->

<script setup lang="ts"></script>

<template>
<div>External picgo setting</div>
</template>

<style scoped></style>
16 changes: 16 additions & 0 deletions packages/picgo-plugin-app/src/components/PicGoIndex.vue
@@ -0,0 +1,16 @@
<!--
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2024 Terwer, Inc. <https://terwer.space/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-->

<script setup lang="ts"></script>

<template>
<div>PicGO index</div>
</template>

<style scoped></style>
16 changes: 16 additions & 0 deletions packages/picgo-plugin-app/src/components/PicgoSetting.vue
@@ -0,0 +1,16 @@
<!--
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2024 Terwer, Inc. <https://terwer.space/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-->

<script setup lang="ts"></script>

<template>
<div>PicGO setting</div>
</template>

<style scoped></style>
16 changes: 16 additions & 0 deletions packages/picgo-plugin-app/src/components/SiyuanSetting.vue
@@ -0,0 +1,16 @@
<!--
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2024 Terwer, Inc. <https://terwer.space/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-->

<script setup lang="ts"></script>

<template>
<div>siyuan setting</div>
</template>

<style scoped></style>
16 changes: 16 additions & 0 deletions packages/picgo-plugin-app/src/components/TransportSelect.vue
@@ -0,0 +1,16 @@
<!--
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2024 Terwer, Inc. <https://terwer.space/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-->

<script setup lang="ts"></script>

<template>
<div>transport select</div>
</template>

<style scoped></style>
56 changes: 56 additions & 0 deletions packages/picgo-plugin-app/src/composables/useSiyuanDevice.ts
@@ -0,0 +1,56 @@
/*
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* Copyright (C) 2022-2024 Terwer, Inc. <https://terwer.space/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/

import { DeviceDetection, DeviceTypeEnum } from "zhi-device"
import { createAppLogger } from "@/utils/appLogger.ts"

/**
* 设备检测
*/
export const useSiyuanDevice = () => {
const logger = createAppLogger("use-siyuan-device")

const isInSiyuanMainWin = () => {
const deviceType = DeviceDetection.getDevice()
const isSiyuanOrSiyuanNewWin = deviceType === DeviceTypeEnum.DeviceType_Siyuan_MainWin
logger.debug("deviceType=>", deviceType)
logger.debug("isSiyuanOrSiyuanNewWin=>", String(isSiyuanOrSiyuanNewWin))
return isSiyuanOrSiyuanNewWin
}

const isInSiyuanWidget = () => {
const deviceType = DeviceDetection.getDevice()
const isSiyuanOrSiyuanNewWin = deviceType === DeviceTypeEnum.DeviceType_Siyuan_Widget
logger.debug("deviceType=>", deviceType)
logger.debug("isSiyuanOrSiyuanNewWin=>", String(isSiyuanOrSiyuanNewWin))
return isSiyuanOrSiyuanNewWin
}

const isInChromeExtension = () => {
const deviceType = DeviceDetection.getDevice()
const isSiyuanOrSiyuanNewWin = deviceType === DeviceTypeEnum.DeviceType_Chrome_Extension
logger.debug("deviceType=>", deviceType)
logger.debug("isSiyuanOrSiyuanNewWin=>", String(isSiyuanOrSiyuanNewWin))
return isSiyuanOrSiyuanNewWin
}

const isInSiyuanOrSiyuanNewWin = () => {
const deviceType = DeviceDetection.getDevice()
// 三种情况,主窗口、挂件、新窗口
const isSiyuanOrSiyuanNewWin =
deviceType === DeviceTypeEnum.DeviceType_Siyuan_MainWin ||
deviceType === DeviceTypeEnum.DeviceType_Siyuan_RendererWin ||
deviceType === DeviceTypeEnum.DeviceType_Siyuan_Widget
logger.debug("deviceType=>", deviceType)
logger.debug("isSiyuanOrSiyuanNewWin=>", String(isSiyuanOrSiyuanNewWin))
return isSiyuanOrSiyuanNewWin
}

return { isInSiyuanMainWin, isInSiyuanWidget, isInChromeExtension, isInSiyuanOrSiyuanNewWin }
}
26 changes: 26 additions & 0 deletions packages/picgo-plugin-app/src/composables/useVueI18n.ts
@@ -0,0 +1,26 @@
/*
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* Copyright (C) 2022-2024 Terwer, Inc. <https://terwer.space/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/

import { useI18n } from "vue-i18n"

/**
* 多语言封装,解决 CSP
*
* https://github.com/intlify/vue-i18n-next/issues/543
*/
export const useVueI18n = () => {
const { messages, locale } = useI18n()

const translate = (key: any) => {
const localeMessages = messages.value?.[locale.value]
return localeMessages[key] || key
}

return { t: translate, locale }
}
21 changes: 21 additions & 0 deletions packages/picgo-plugin-app/src/composables/useVueRouter.ts
@@ -0,0 +1,21 @@
/*
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* Copyright (C) 2022-2024 Terwer, Inc. <https://terwer.space/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/

import { createRouter, createWebHashHistory, Router } from "vue-router"
import { routes } from "@/routes"

/**
* 用于创建路由的函数
*/
export const useVueRouter = (): Router => {
return createRouter({
history: createWebHashHistory(),
routes,
})
}
127 changes: 127 additions & 0 deletions packages/picgo-plugin-app/src/i18n/en_US.ts
@@ -0,0 +1,127 @@
/*
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* Copyright (C) 2022-2024 Terwer, Inc. <https://terwer.space/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/

export default {
"setting.picgo.refer.to": "For details, please refer to:",
"setting.picgo.refer.to.online.doc": "Picgo configuration online documentation",
"setting.picgo.picbed": "Picbed setting",
"setting.picgo.picgo": "PicGO setting",
"setting.picgo.picgo.open.config.file": "Open config file",
"setting.picgo.picgo.click.to.open": "Click open",
"setting.picgo.picgo.choose.showed.picbed": "Please select showed picbed",
"setting.picgo.picbed.selected.tip": "Selected",
"setting.picgo.picbed.unselected.tip": "Unselected",
"setting.picgo.picbed.set.default": "Set as default picbed",
"setting.picgo.picbed.current.selected.tip": "Current selected picbed is:",
"setting.picgo.picbed.current.tip": "Current picbed is:",
"setting.picgo.picbed.uploader.config.name": "Picbed config name",
"setting.picgo.picbed.uploader.config.name.placeholder": "Please input config name",
"setting.picgo.config.name": "Config name",
"setting.picgo.config.name.placeholder": "Please input config name",
"setting.picgo.index.tip":
"Note: The image uploaded here will not be automatically inserted into the document. Please manually click the copy button to copy the link, and then Ctrl+V to paste it into the document. This picture list only shows the pictures contained in this document.",
"setting.picgo.index.copy.link": "Copy link",
"setting.picgo.setting.timestamp.rename": "Timestamp rename",
"setting.picgo.setting.close": "Close",
"setting.picgo.setting.open": "Open",
"setting.picgo.setting.log.file": "Log file",
"setting.picgo.plugin": "Plugin setting",
"setting.picgo.plugin.list": "Plugin list",
"setting.picgo.plugin.import.local": "Import local plugin",
"setting.picgo.plugin.install": "Install",
"setting.picgo.plugin.installing": "Installing",
"setting.picgo.plugin.installed": "Installed",
"setting.picgo.plugin.doing.something": "Loading",
"setting.picgo.plugin.search.placeholder":
"Search the picgo plug -in on NPM, or click the button above to view the excellent plug -in list",
"setting.picgo.plugin.gui.not.implemented":
"This plug -in does not optimize the visual interface, is it continued to be installed?",
"setting.picgo.setting.node.path": "Node install path",
"setting.picgo.setting.node.path.tip":
"Please enter Node to install the full path, for example: /opt/node-v16.14.0-darwin-x64/bin, node version> = 16",
"setting.picgo.setting.node.registry": "NPM registry",
"setting.picgo.setting.node.registry.tip": "Mainland recommend:https://registry.npmmirror.com",
"setting.picgo.setting.node.proxy": "NPM proxy",
"setting.picgo.setting.node.proxy.tip":
"Generally, you can leave empty. If you have special needs, you can set a custom agent",
"setting.picgo.setting.config.tip":
"Note: The attributes above the horizontal line will change the behavior of uploading pictures, and the configuration can be stored automatically. The attribute below the horizontal line is only used when installing the plug -in, and you need to click the [Confirm] button to save.",
"setting.picgo.plugin.install.success":
"The plug -in has been successfully installed, please clear the search keyword refresh list. Click the plug -in corresponding [Settings] icon to view the plug -in details and customize the plug -in",
"setting.picgo.plugin.uninstall": "Uninstall plugin",
"setting.picgo.plugin.uninstall.success": "Plugin is uninstalled successfully",
"setting.picgo.plugin.enable": "Enable plugin",
"setting.picgo.plugin.disable": "Disable plugin",
"setting.picgo.plugin.update": "Update plugin",
"setting.picgo.plugin.config.setting": "Plugin setting",
"setting.picgo.plugin.work": "Work",
"setting.picgo.plugin.nowork": "Nowork",
"setting.picgo.plugin.nouse": "Nouse",
"setting.picgo.plugin.update.success": "Update success",
"setting.picgo.manage": "Picture manage",
"picgo.chrome.tip":
"If you are using a browser plug -in, you need to download the configuration Picgo client from here: https://github.com/Molunerfinn/PicGo/releases",
"picgo.siyuan.tip":
"If you are using Siyuan notes pendants, you need to configure your own integration of PICGO. The pendant version of the PICGO configuration file is:`[Siyuan Workspace]/data/widgets/sy-post-publisher/lib/picgo/picgo.cfg.json`,Please refer to the official picgo document for configuration:https://picgo.github.io/PicGo-Core-Doc/zh/guide/config.html#%E6%89%8B%E5%8A%A8%E7%94%9F%E6%88%90",
"picgo.upload.status": "Upload status",
"picgo.upload.select.pic": "Select picture",
"picgo.upload.clipboard": "Clipboard picture",
"picgo.upload.onclick": "One click upload",
"picgo.download.onclick": "One click download",
"picgo.download.local.to.bed": "Upload picture to bed",
"picgo.download.bed.to.local": "Upload picture from bed",
"picgo.pic.preview": "Picture preview",
"picgo.pic.setting": "Picture setting",
"picgo.pic.setting.no.tip":
"You are currently using the browser plug -in and cannot inherit PicGo. You can only call the local Picgo client on the local Picgo client through HTTP",
"syp.about": "About me",
"theme.mode.choose": "Mode",
"theme.mode.dark": "Dark mode",
"theme.mode.light": "Light mode",
"setting.conf.export": "Export config",
"setting.conf.import": "Import config",
"setting.conf.clear": "Clear config",
"setting.conf.transport": "Transport",
"main.opt.success": "Success",
"main.opt.failure": "Error",
"main.opt.edit": "Edit",
"main.opt.delete": "Delete",
"main.opt.loading": "In operation...",
"main.opt.warning": "Warn tips",
"main.opt.tip": "Kind tips",
"main.opt.save": "Save",
"main.opt.ok": "Confirm",
"main.opt.cancel": "Cancel",
"main.opt.warning.tip": "This operation cannot be undone, continue?",
"switch.active.text": "Debug",
"switch.unactive.text": "Normal",
"setting.conf.import.picgo": "Import PicGO configuration",
"setting.conf.export.syp.tip":
"The corresponding json configuration file will be exported, and regular configuration backup is strongly recommended. In principle, backward compatibility is supported. If there is any incompatibility problem, it will be specially explained.",
"setting.conf.export.picgo": "Export PicGO configuration",
"setting.conf.import.picgo.tip":
"Please select a valid historical backup json file to import. Note: PicGO plug-in registration information will not be imported. For configuration compatibility, please uninstall all plug-ins and then perform PicGO configuration export operation. Uninstalling PicGO plug-ins will not delete the plug-in configuration, only Plug-in files and plug-in registration records will be deleted. Please feel free to uninstall.",
"setting.conf.export.picgo.tip":
"The corresponding json configuration file will be exported, and regular configuration backup is strongly recommended. In principle, backward compatibility is supported. If there is any incompatibility problem, it will be specially explained.",
"setting.conf.clear.picgo": "Clear PicGO configuration",
"setting.conf.clear.picgo.tip":
"Empty configuration cannot be restored, please operate with caution. It is strongly recommended to back up the configuration first. This operation will delete PicGO related configuration folders, including configuration, plug-ins, cache, etc., and only use it when PicGO loads abnormally and cannot be used at all, otherwise Lost configuration at your own risk!",
"picgo.type.switch.active.text": "Use the built-in PicGO",
"picgo.type.switch.unactive.text": "Use an external PicGo",
"picgo.type.external.title": "External PicGO settings",
"setting.picgo.external.setting.apiurl": "API address",
"setting.picgo.external.setting.apiurl.tip":
"Please enter the API address of the external external PicGO, the default is: http://127.0.0.1:36677",
"siyuan.config.setting": "Source settings",
"setting.blog.siyuan.apiurl": "Siyuan API address",
"setting.blog.siyuan.apiurl.tip": "The default address of Siyuan API is: http://127.0.0.1;6806",
"setting.blog.siyuan.password": "Siyuan Token",
"setting.blog.siyuan.password.tip": "Siyuan Token, which is empty by default",
"form.validate.name.required": "Please enter a name",
}
24 changes: 24 additions & 0 deletions packages/picgo-plugin-app/src/i18n/index.ts
@@ -0,0 +1,24 @@
/*
* GNU GENERAL PUBLIC LICENSE
* Version 3, 29 June 2007
*
* Copyright (C) 2024 Terwer, Inc. <https://terwer.space/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/

import { createI18n } from "vue-i18n"
import zh_CN from "./zh_CN"
import en_US from "./en_US"

const i18n = createI18n({
legacy: false,
locale: "zh_CN", // 默认显示语言
fallbackLocale: "en_US", // 次要语言
messages: {
zh_CN,
en_US,
},
})

export default i18n