Skip to content

Commit

Permalink
feat:#85 Google插件扩展-同时兼容Google扩展与思源挂件构建
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Sep 22, 2022
1 parent b619b23 commit 9e1fba4
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 68 deletions.
88 changes: 56 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

Publish siyuan article to supported open platforms

At present, it supports vuepress and two open API standard blog platforms, <code>metaweblog api</code> and <code>xmlrpc</code> remote call API based on <code>wordpress</code>
At present, it supports vuepress and two open API standard blog platforms, <code>metaweblog api</code> and <code>
xmlrpc</code> remote call API based on <code>wordpress</code>

ALso provide a [common API adaptor](https://github.com/terwer/src-sy-post-publisher/blob/main/src/lib/api.ts) , make every plantform posiable.
ALso provide a [common API adaptor](https://github.com/terwer/src-sy-post-publisher/blob/main/src/lib/api.ts) , make
every plantform posiable.

<a href="https://img1.terwergreen.com/api/public/20220729233245.gif" target="_blank" >Click me</a>

Expand All @@ -31,58 +33,65 @@ ALso provide a [common API adaptor](https://github.com/terwer/src-sy-post-publis
[Click here to view development progress](https://github.com/users/terwer/projects/1/views/1)

### v0.0.2
- [X] [#15](https://github.com/terwer/src-sy-post-publisher/issues/15) Published to other platforms-blog parks, WordPress, chain drop community, etc.

- [x] [#18](https://github.com/terwer/src-sy-post-publisher/issues/18) Implement MetaWeblog-API client
- [X] [#15](https://github.com/terwer/src-sy-post-publisher/issues/15) Published to other platforms-blog parks,
WordPress, chain drop community, etc.

- [x] [#24](https://github.com/terwer/src-sy-post-publisher/issues/24) Non-pendant server version, you need to pass the document ID. It is recommended to cooperate with my other work [node-siyuan](https://github.com/terwer/node-siyuan) use
- [x] [#18](https://github.com/terwer/src-sy-post-publisher/issues/18) Implement MetaWeblog-API client

- [x] [#25](https://github.com/terwer/src-sy-post-publisher/issues/25) Vercel deploy
- [x] [#24](https://github.com/terwer/src-sy-post-publisher/issues/24) Non-pendant server version, you need to pass
the document ID. It is recommended to cooperate with my other
work [node-siyuan](https://github.com/terwer/node-siyuan) use

- [X] [#38](https://github.com/terwer/src-sy-post-publisher/issues/38) Some platforms support cancel the release
- [x] [#25](https://github.com/terwer/src-sy-post-publisher/issues/25) Vercel deploy

- [X] [#39](https://github.com/terwer/src-sy-post-publisher/issues/39) Support ELETRON interface
- [X] [#38](https://github.com/terwer/src-sy-post-publisher/issues/38) Some platforms support cancel the release

- [X] [#40](https://github.com/terwer/src-sy-post-publisher/issues/40) Published to Confluence, you need to cooperate with my project [node-metaweblog-api-adaptor](https://github.com/terwer/node-metaweblog-api-adaptor)
- [X] [#39](https://github.com/terwer/src-sy-post-publisher/issues/39) Support ELETRON interface

- [x] [#41](https://github.com/terwer/src-sy-post-publisher/issues/41) Send to Wordpess
- [X] [#40](https://github.com/terwer/src-sy-post-publisher/issues/40) Published to Confluence, you need to
cooperate with my project [node-metaweblog-api-adaptor](https://github.com/terwer/node-metaweblog-api-adaptor)

- [x] [#42](https://github.com/terwer/src-sy-post-publisher/issues/42) Sendto Liandi
- [x] [#41](https://github.com/terwer/src-sy-post-publisher/issues/41) Send to Wordpess

- [x] [#43](https://github.com/terwer/src-sy-post-publisher/issues/43) Send to Yuque
- [x] [#42](https://github.com/terwer/src-sy-post-publisher/issues/42) Sendto Liandi

- [x] [#44](https://github.com/terwer/src-sy-post-publisher/issues/44) Send to KMS

- [#19](https://github.com/terwer/src-sy-post-publisher/issues/19) 增强Vuepress支持,如果设置了Github参数,使用Github API实现自动发布,否则自行复制文本
- [x] [#43](https://github.com/terwer/src-sy-post-publisher/issues/43) Send to Yuque

- [x] [#44](https://github.com/terwer/src-sy-post-publisher/issues/44) Send to KMS

- [#19](https://github.com/terwer/src-sy-post-publisher/issues/19) 增强Vuepress支持,如果设置了Github参数,使用Github
API实现自动发布,否则自行复制文本

- 1、add aupport for Github rest api

- 2、TS generic implementation Vuepress release parameter configuration

- 3、Fix Octokit to build an error in vite, replace `node-fetch` as `isomorphic-fetch`

- 4、Add config valifation

- 5、Time-consuming button operation add `loading`

- 6、If the GitHub parameter is set, the GitHub API is set to be automatically published, otherwise the text will be copied by yourself


- 6、If the GitHub parameter is set, the GitHub API is set to be automatically published, otherwise the text will be
copied by yourself

- 7、Support selection of custom release directory

- 8、Support modified file name

- 9、Vuepress's slug add hash to avoid the conflict of repeated articles

- 10、Support simple and complex mode

- 11、New API status to ensure the availability of the API

- 12、Configuration switch automatically takes effect

- 13、Default directory switch

- 14、Page initialization is also additional content

- 15、Support article cancellation and release

### v0.0.1
Expand All @@ -91,17 +100,24 @@ ALso provide a [common API adaptor](https://github.com/terwer/src-sy-post-publis

## Vue 3 + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue
3 `<script setup>` SFCs, check out
the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

## Recommended IDE Setup

* [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)

## Type Support For `.vue` Imports in TS

Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type
by default. In most cases this is fine if you don't really care about component prop types outside of templates.
However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using
manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:

1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look
for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default,
Take Over mode will enable itself if the default TypeScript extension is disabled.

2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.

Expand Down Expand Up @@ -129,11 +145,19 @@ yarn create vite

## Deploy

### Build for siyuan widget

```bash
yarn w
```

### Build for chrome extension

```bash
yarn deploy
yarn e
```

## Vercel CLI
## ~~Vercel CLI~~

```
npm i -g vercel
Expand Down
10 changes: 0 additions & 10 deletions deploy.ps1

This file was deleted.

13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"build-siyuan": "vue-tsc --noEmit && BUILD_TYPE=siyuan vite build",
"preview": "vite preview",
"test": "vitest --watch",
"coverage": "vitest run --coverage",
"webstorm-integration": "vitest --watch --reporter=dot --reporter=json --outputFile=.vitest-result.json",
"deploy": "bash deploy.sh",
"d": "yarn deploy",
"deploy-win": "pwsh deploy.ps1",
"wd": "yarn deploy-win",
"vdev": "vercel dev --listen 5005",
"vbuild": "vercel build",
"ext": "bash ext.sh"
"deploy-siyuan": "bash deploy.sh",
"ext": "bash ext.sh",
"widget": "bash widget.sh",
"e": "yarn ext",
"w": "yarn widget"
},
"dependencies": {
"@element-plus/icons-vue": "^2.0.9",
Expand Down
6 changes: 3 additions & 3 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
"web_accessible_resources": [
{
"resources": [
"index/index.html",
"service/index.html"
"blog/index.html",
"index.html"
],
"matches": [
"<all_urls>"
]
}
],
"action": {
"default_popup": "index/index.html"
"default_popup": "blog/index.html"
}
}
4 changes: 2 additions & 2 deletions public/widget.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sy-post-publisher",
"author": "terwer",
"url": "https://github.com/terwer/sy-post-publisher",
"version": "0.0.2"
"url": "https://github.com/terwer/src-sy-post-publisher",
"version": "0.0.3"
}
4 changes: 2 additions & 2 deletions src/components/blog/themes/default/DefaultMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ const emitFn = () => {
}
const handleEdit = (index: number, row: any) => {
goToPage("/service/index.html?id=" + row.postid)
goToPage("/index.html?id=" + row.postid)
console.log(index, row)
}
const handleRowClick = (row: any, column: any, event: any) => {
// goToPage("/service/index.html?id=aaa")
// goToPage("/index.html?id=aaa")
// console.log("handleRowClick", row)
}
Expand Down
4 changes: 3 additions & 1 deletion src/lib/chrome/ChromeUtil.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* 在chrome插件打开网页
* @param pageUrl 例如:/service/index.html
* @param pageUrl 例如://index.html
*/
export function goToPage(pageUrl: string) {
// While we could have used `let url = "index.html"`, using runtime.getURL is a bit more robust as
Expand All @@ -12,6 +12,8 @@ export function goToPage(pageUrl: string) {
if (typeof chrome.runtime != "undefined") {
// @ts-ignore
url = chrome.runtime.getURL(url);
} else {
url = window.location.protocol + "//" + window.location.host + "/" + url;
}
window.open(url)
// console.log(`Created tab`);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pages/index/index.html → src/pages/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<body>
<div id="app"></div>
<script src="/lute.min.js"></script>
<script type="module" src="/src/pages/index/main.ts"></script>
<script type="module" src="/src/pages/blog/main.ts"></script>
</body>
</html>
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pages/service/index.html → src/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<body>
<div id="app"></div>
<script src="/lute.min.js"></script>
<script type="module" src="/src/pages/service/main.ts"></script>
<script type="module" src="/src/pages/main.ts"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/pages/service/main.ts → src/pages/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {createApp} from 'vue'
import App from './App.vue'
import './style.css'
// 国际化
import i18n from "../../locales";
import i18n from "../locales";

// Element-Plus
import ElementPlus from 'element-plus'
Expand Down
File renamed without changes.
File renamed without changes.
17 changes: 10 additions & 7 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {defineConfig} from 'vite'
import {loadEnv} from "vite";
import { resolve, dirname } from 'node:path'
import { fileURLToPath } from 'url'
import {resolve, dirname} from 'node:path'
import {fileURLToPath} from 'url'
import vue from '@vitejs/plugin-vue'
import vitePluginRequireTransform from 'vite-plugin-require-transform';
import {NodeGlobalsPolyfillPlugin} from '@esbuild-plugins/node-globals-polyfill'
Expand All @@ -14,7 +14,9 @@ import mpa from 'vite-plugin-mpa'
import * as path from "path";

// https://vitejs.dev/config/
export default defineConfig(({mode}) => {
export default defineConfig(({command, mode, ssrBuild}) => {
console.log("command=>", command)

const env = loadEnv(mode, process.cwd())
const processEnvValues = {
'process.env': Object.entries(env).reduce(
Expand All @@ -27,7 +29,8 @@ export default defineConfig(({mode}) => {
{},
)
}
console.log(env.DEV)
const isSiyuanBuild = process.env.BUILD_TYPE == "siyuan"
console.log("isSiyuanBuild=>", isSiyuanBuild)

return {
plugins: [
Expand All @@ -50,7 +53,7 @@ export default defineConfig(({mode}) => {
// root: process.cwd(),
root: './',
// 项目部署的基础路径
base: '/',
base: isSiyuanBuild ? 'http://127.0.0.1:6806/widgets/sy-post-publisher/' : "",
// 静态资源服务文件夹
publicDir: 'public',
// https://github.com/vitejs/vite/issues/1930
Expand Down Expand Up @@ -151,8 +154,8 @@ export default defineConfig(({mode}) => {

rollupOptions: {
input: {
index: path.resolve(__dirname, 'pages/index/index.html'),
popup: path.resolve(__dirname, 'pages/service/index.html'),
siyuanIndex: path.resolve(__dirname, 'index.html'),
index: path.resolve(__dirname, 'pages/blog/index.html'),
},
output: {
chunkFileNames: 'static/js/[name]-[hash].js',
Expand Down
2 changes: 1 addition & 1 deletion deploy.sh → widget.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pwd
yarn build
yarn build-siyuan
# 删除Chrome插件专属文件
rm ./dist/background.js
rm ./dist/manifest.json
Expand Down

0 comments on commit 9e1fba4

Please sign in to comment.