mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-06 20:42:57 +08:00
🐛 Fix(custom): fix an issue eslint not worked as expected
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"trailingComma": "all",
|
||||
"useTabs": false,
|
||||
"endOfLine": "lf"
|
||||
}
|
||||
|
||||
5
.stylelintignore
Normal file
5
.stylelintignore
Normal file
@@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
public
|
||||
dist
|
||||
lib
|
||||
*.d.ts
|
||||
118
.stylelintrc.cjs
Normal file
118
.stylelintrc.cjs
Normal file
@@ -0,0 +1,118 @@
|
||||
module.exports = {
|
||||
extends: ['stylelint-config-standard', 'stylelint-config-html/vue', 'stylelint-config-standard-vue'],
|
||||
plugins: ['stylelint-order'],
|
||||
rules: {
|
||||
// 这里是允许了空的style标签
|
||||
'no-empty-source': null,
|
||||
'selector-class-pattern': null,
|
||||
// 禁止空块
|
||||
'block-no-empty': true,
|
||||
// 颜色6位长度
|
||||
'color-hex-length': 'long',
|
||||
// 兼容自定义标签名
|
||||
'selector-type-no-unknown': [
|
||||
true,
|
||||
{
|
||||
ignoreTypes: [],
|
||||
},
|
||||
],
|
||||
// 忽略伪类选择器 ::v-deep
|
||||
'selector-pseudo-element-no-unknown': [
|
||||
true,
|
||||
{
|
||||
ignorePseudoElements: ['v-deep'],
|
||||
},
|
||||
],
|
||||
// 禁止低优先级的选择器出现在高优先级的选择器之后。
|
||||
'no-descending-specificity': null,
|
||||
// 不验证@未知的名字,为了兼容scss的函数
|
||||
'at-rule-no-unknown': null,
|
||||
// 禁止空注释
|
||||
'comment-no-empty': true,
|
||||
// 禁止简写属性的冗余值
|
||||
'shorthand-property-no-redundant-values': true,
|
||||
// 禁止值的浏览器引擎前缀
|
||||
'value-no-vendor-prefix': true,
|
||||
// property-no-vendor-prefix
|
||||
'property-no-vendor-prefix': true,
|
||||
// 属性的排序
|
||||
'order/properties-order': [
|
||||
'position',
|
||||
'top',
|
||||
'right',
|
||||
'bottom',
|
||||
'left',
|
||||
'z-index',
|
||||
'display',
|
||||
'justify-content',
|
||||
'align-items',
|
||||
'float',
|
||||
'clear',
|
||||
'overflow',
|
||||
'overflow-x',
|
||||
'overflow-y',
|
||||
'margin',
|
||||
'margin-top',
|
||||
'margin-right',
|
||||
'margin-bottom',
|
||||
'margin-left',
|
||||
'border',
|
||||
'border-style',
|
||||
'border-width',
|
||||
'border-color',
|
||||
'border-top',
|
||||
'border-top-style',
|
||||
'border-top-width',
|
||||
'border-top-color',
|
||||
'border-right',
|
||||
'border-right-style',
|
||||
'border-right-width',
|
||||
'border-right-color',
|
||||
'border-bottom',
|
||||
'border-bottom-style',
|
||||
'border-bottom-width',
|
||||
'border-bottom-color',
|
||||
'border-left',
|
||||
'border-left-style',
|
||||
'border-left-width',
|
||||
'border-left-color',
|
||||
'border-radius',
|
||||
'padding',
|
||||
'padding-top',
|
||||
'padding-right',
|
||||
'padding-bottom',
|
||||
'padding-left',
|
||||
'width',
|
||||
'min-width',
|
||||
'max-width',
|
||||
'height',
|
||||
'min-height',
|
||||
'max-height',
|
||||
'font-size',
|
||||
'font-family',
|
||||
'font-weight',
|
||||
'text-align',
|
||||
'text-justify',
|
||||
'text-indent',
|
||||
'text-overflow',
|
||||
'text-decoration',
|
||||
'white-space',
|
||||
'color',
|
||||
'background',
|
||||
'background-position',
|
||||
'background-repeat',
|
||||
'background-size',
|
||||
'background-color',
|
||||
'background-clip',
|
||||
'opacity',
|
||||
'filter',
|
||||
'list-style',
|
||||
'outline',
|
||||
'visibility',
|
||||
'box-shadow',
|
||||
'text-shadow',
|
||||
'resize',
|
||||
'transition',
|
||||
],
|
||||
},
|
||||
}
|
||||
3
.vscode/extensions.json
vendored
Normal file
3
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"recommendations": ["dbaeumer.vscode-eslint", "stylelint.vscode-stylelint"]
|
||||
}
|
||||
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -36,4 +36,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
15
.vscode/mcp.json
vendored
15
.vscode/mcp.json
vendored
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"inputs": [
|
||||
// The "inputs" section defines the inputs required for the MCP server configuration.
|
||||
{
|
||||
"type": "promptString"
|
||||
}
|
||||
],
|
||||
"servers": {
|
||||
// The "servers" section defines the MCP servers you want to use.
|
||||
"fetch": {
|
||||
"command": "uvx",
|
||||
"args": ["mcp-server-fetch"]
|
||||
}
|
||||
}
|
||||
}
|
||||
68
.vscode/settings.json
vendored
68
.vscode/settings.json
vendored
@@ -1,26 +1,55 @@
|
||||
{
|
||||
"[stylus]": {
|
||||
"editor.formatOnSave": true
|
||||
"eslint.run": "onSave",
|
||||
"eslint.codeActionsOnSave.mode": "all",
|
||||
"eslint.format.enable": true,
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "always"
|
||||
},
|
||||
"editor.formatOnSave": false
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "always"
|
||||
},
|
||||
"editor.formatOnSave": false
|
||||
},
|
||||
"[vue]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "always"
|
||||
},
|
||||
"editor.formatOnSave": false
|
||||
},
|
||||
"[typescriptreact]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "always"
|
||||
},
|
||||
"editor.formatOnSave": false
|
||||
},
|
||||
"[javascriptreact]": {
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "always"
|
||||
},
|
||||
"editor.formatOnSave": false
|
||||
},
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": "explicit"
|
||||
},
|
||||
"githubPullRequests.ignoredPullRequestBranches": [
|
||||
"dev"
|
||||
],
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[html]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[css]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
"editor.defaultFormatter": "stylelint.vscode-stylelint",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.stylelint": "always"
|
||||
},
|
||||
"editor.formatOnSave": false
|
||||
},
|
||||
"i18n-ally.localesPaths": ["src\\renderer\\i18n\\locales", "resources\\i18n"],
|
||||
"eslint.validate": ["javascript", "javascriptreact", "vue", "typescript", "typescriptreact", "json", "jsonc"],
|
||||
"githubPullRequests.ignoredPullRequestBranches": ["dev"],
|
||||
"i18n-ally.localesPaths": ["src\\renderer\\i18n\\locales", "resources\\i18n"],
|
||||
"i18n-ally.keystyle": "nested",
|
||||
"i18n-ally.sortKeys": true,
|
||||
"i18n-ally.namespace": true,
|
||||
@@ -29,5 +58,8 @@
|
||||
"i18n-ally.displayLanguage": "zh-CN",
|
||||
"i18n-ally.enabledFrameworks": ["vue"],
|
||||
"i18n-ally.editor.preferEditor": true,
|
||||
"typescript.tsdk": "node_modules\\typescript\\lib"
|
||||
}
|
||||
"typescript.tsdk": "node_modules\\typescript\\lib",
|
||||
"css.validate": false,
|
||||
"scss.validate": false,
|
||||
"less.validate": false
|
||||
}
|
||||
|
||||
2
.vscode/tasks.json
vendored
2
.vscode/tasks.json
vendored
@@ -24,4 +24,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ export default defineConfig({
|
||||
root: resolve('./'),
|
||||
'#': resolve('src/universal'),
|
||||
apis: resolve('src/main/apis'),
|
||||
'@core': resolve('src/main/apis/core')
|
||||
}
|
||||
}
|
||||
'@core': resolve('src/main/apis/core'),
|
||||
},
|
||||
},
|
||||
},
|
||||
preload: {
|
||||
plugins: [
|
||||
@@ -25,17 +25,17 @@ export default defineConfig({
|
||||
VueI18nPlugin({
|
||||
/* options */
|
||||
// locale messages resource pre-compile option
|
||||
include: resolve(dirname(fileURLToPath(import.meta.url)), './src/renderer/i18n/locales/**')
|
||||
})
|
||||
include: resolve(dirname(fileURLToPath(import.meta.url)), './src/renderer/i18n/locales/**'),
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve('src/renderer'),
|
||||
'~': resolve('src/main'),
|
||||
root: resolve('./'),
|
||||
'#': resolve('src/universal')
|
||||
}
|
||||
}
|
||||
'#': resolve('src/universal'),
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer: {
|
||||
root: resolve('src/renderer'),
|
||||
@@ -45,12 +45,12 @@ export default defineConfig({
|
||||
'@': resolve('src/renderer'),
|
||||
'~': resolve('src/main'),
|
||||
root: resolve('./'),
|
||||
'#': resolve('src/universal')
|
||||
}
|
||||
'#': resolve('src/universal'),
|
||||
},
|
||||
},
|
||||
plugins: [vue()],
|
||||
server: {
|
||||
port: 3000
|
||||
}
|
||||
}
|
||||
port: 3000,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
146
eslint.config.js
146
eslint.config.js
@@ -1,49 +1,65 @@
|
||||
import eslint from '@eslint/js'
|
||||
import standard from '@vue/eslint-config-standard'
|
||||
import js from '@eslint/js'
|
||||
import { defineConfig } from 'eslint/config'
|
||||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
|
||||
import configPrettier from 'eslint-config-prettier'
|
||||
import jsonc from 'eslint-plugin-jsonc'
|
||||
import pluginPrettier from 'eslint-plugin-prettier/recommended'
|
||||
import simpleImportSort from 'eslint-plugin-simple-import-sort'
|
||||
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
|
||||
import pluginUnicorn from 'eslint-plugin-unicorn'
|
||||
import pluginVue from 'eslint-plugin-vue'
|
||||
import globals from 'globals'
|
||||
import jsoncParser from 'jsonc-eslint-parser'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import vueParser from 'vue-eslint-parser'
|
||||
|
||||
export default defineConfig(
|
||||
{
|
||||
files: ['./src/*.{ts,tsx,cts,mts,js,cjs,mjs}', './scripts/*.{ts,js,mjs}', './test/*.{ts,js,mjs}']
|
||||
ignores: ['**/node_modules/**', '**/out/**', '**/webpack.config.js', 'vitest.workspace.mjs', '**/dist/**'],
|
||||
},
|
||||
{
|
||||
ignores: ['**/node_modules/**', '**/out/**', '**/webpack.config.js', 'vitest.workspace.mjs', '**/dist/**']
|
||||
},
|
||||
eslint.configs.recommended,
|
||||
js.configs.recommended,
|
||||
...pluginVue.configs['flat/recommended'],
|
||||
...tseslint.configs.recommended,
|
||||
...tseslint.configs.stylistic,
|
||||
...pluginVue.configs['flat/recommended'],
|
||||
...standard,
|
||||
eslintPluginPrettierRecommended,
|
||||
{
|
||||
plugins: {
|
||||
'simple-import-sort': simpleImportSort,
|
||||
unicorn: eslintPluginUnicorn
|
||||
files: ['**/*.ts', '**/*.d.ts'],
|
||||
languageOptions: {
|
||||
parser: tseslint.parser,
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 'latest',
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
Office: 'readonly',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'simple-import-sort/imports': 'error',
|
||||
'simple-import-sort/exports': 'error'
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ['**/*.vue'],
|
||||
languageOptions: {
|
||||
parser: vueParser,
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false
|
||||
parser: tseslint.parser,
|
||||
extraFileExtensions: ['.vue'],
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 'latest',
|
||||
},
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.node,
|
||||
...globals.browser
|
||||
}
|
||||
}
|
||||
Office: 'readonly',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.ts', '**/*.d.ts', '**/*.vue', 'eslint.config.js', 'vite.config.js', 'electron.vite.config.js'],
|
||||
plugins: {
|
||||
'simple-import-sort': simpleImportSort,
|
||||
unicorn: pluginUnicorn,
|
||||
},
|
||||
rules: {
|
||||
'unicorn/prefer-node-protocol': 'error',
|
||||
'unicorn/prefer-module': 'error',
|
||||
'simple-import-sort/imports': 'error',
|
||||
'simple-import-sort/exports': 'error',
|
||||
eqeqeq: 'error',
|
||||
'no-caller': 'error',
|
||||
'no-constant-condition': ['error', { checkLoops: false }],
|
||||
@@ -58,22 +74,18 @@ export default defineConfig(
|
||||
'prefer-const': 'error',
|
||||
'prefer-object-spread': 'error',
|
||||
'unicode-bom': ['error', 'never'],
|
||||
// Enabled in eslint:recommended, but not applicable here
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'no-unused-vars': 'off',
|
||||
'no-extra-boolean-cast': 'off',
|
||||
'no-case-declarations': 'off',
|
||||
'no-cond-assign': 'off',
|
||||
'no-control-regex': 'off',
|
||||
'no-inner-declarations': 'off',
|
||||
'no-empty': 'off',
|
||||
|
||||
// @typescript-eslint/eslint-plugin
|
||||
'no-unused-expressions': 'off',
|
||||
'@typescript-eslint/no-unused-expressions': 'off',
|
||||
'@typescript-eslint/ban-ts-comment': 'off',
|
||||
'@typescript-eslint/class-literal-property-style': 'off',
|
||||
'@typescript-eslint/consistent-indexed-object-style': 'off',
|
||||
'@typescript-eslint/consistent-generic-constructors': 'off',
|
||||
'@typescript-eslint/no-duplicate-enum-values': 'off',
|
||||
'@typescript-eslint/no-empty-function': 'off',
|
||||
'@typescript-eslint/no-namespace': 'off',
|
||||
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
|
||||
@@ -82,12 +94,51 @@ export default defineConfig(
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-empty-object-type': 'off', // {} is a totally useful and valid type.
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-inferrable-types': 'off',
|
||||
'@typescript-eslint/no-this-alias': 'off',
|
||||
// Pending https://github.com/typescript-eslint/typescript-eslint/issues/4820
|
||||
'@typescript-eslint/prefer-optional-chain': 'off',
|
||||
'unicorn/prefer-node-protocol': 'error'
|
||||
}
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
{
|
||||
args: 'all',
|
||||
argsIgnorePattern: '^_',
|
||||
caughtErrors: 'all',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
},
|
||||
],
|
||||
'vue/no-v-html': 'off',
|
||||
'vue/multi-word-component-names': 'off',
|
||||
'no-undef': 'off', // TypeScript handles this
|
||||
'no-async-promise-executor': 'off',
|
||||
},
|
||||
},
|
||||
...jsonc.configs['flat/recommended-with-jsonc'],
|
||||
{
|
||||
files: ['**/*.json', '**/*.jsonc', '**/*.json5'],
|
||||
languageOptions: {
|
||||
parser: jsoncParser,
|
||||
},
|
||||
rules: {
|
||||
'jsonc/array-bracket-spacing': ['error', 'never'],
|
||||
'jsonc/comma-dangle': ['error', 'never'],
|
||||
'jsonc/indent': ['error', 2],
|
||||
'jsonc/no-comments': 'off',
|
||||
'jsonc/quotes': ['error', 'double'],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['src/renderer/i18n/**/*.json'],
|
||||
rules: {
|
||||
'jsonc/sort-keys': [
|
||||
'error',
|
||||
'asc', // 升序排列
|
||||
{
|
||||
caseSensitive: false,
|
||||
natural: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.mjs', '**/*.mts'],
|
||||
@@ -99,19 +150,24 @@ export default defineConfig(
|
||||
{ name: '__dirname' },
|
||||
{ name: 'require' },
|
||||
{ name: 'module' },
|
||||
{ name: 'exports' }
|
||||
]
|
||||
}
|
||||
{ name: 'exports' },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['*.vue', '**/*.vue'],
|
||||
files: ['*.config.js', '.stylelintrc.cjs', 'scripts/*.{js,mjs,cjs}'],
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
globals: globals.browser,
|
||||
parserOptions: {
|
||||
parser: tseslint.parser
|
||||
}
|
||||
}
|
||||
}
|
||||
globals: {
|
||||
...globals.node,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
// 在脚本文件中,通常允许使用 console 和 require
|
||||
'no-console': 'off',
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
'@typescript-eslint/no-var-requires': 'off',
|
||||
},
|
||||
},
|
||||
configPrettier,
|
||||
pluginPrettier,
|
||||
)
|
||||
|
||||
64
package.json
64
package.json
@@ -29,6 +29,7 @@
|
||||
"lint:dpdm": "dpdm -T --tsconfig ./tsconfig.json --no-tree --no-warning --exit-code circular:1 src/main/index.ts",
|
||||
"lint:dpdm:renderer": "dpdm -T --tsconfig ./tsconfig.json --no-tree --no-warning --exit-code circular:1 src/renderer/main.ts",
|
||||
"lint:fix": "eslint --fix --ext .js,.jsx,.ts,.tsx,.vue src/ scripts/ .",
|
||||
"lint:style": "stylelint \"src/**/*.(vue|less|scss|css)\" --fix",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"postuninstall": "electron-builder install-app-deps",
|
||||
"prebuild": "electron-vite build",
|
||||
@@ -76,28 +77,17 @@
|
||||
"tunnel": "^0.0.6",
|
||||
"upyun": "^3.4.6",
|
||||
"uuid": "^11.1.0",
|
||||
"vue": "^3.5.22",
|
||||
"webdav": "^5.8.0",
|
||||
"write-file-atomic": "^6.0.0",
|
||||
"vue": "^3.5.22"
|
||||
"write-file-atomic": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron/notarize": "^3.1.1",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@headlessui/vue": "^1.7.23",
|
||||
"@highlightjs/vue-plugin": "^2.1.2",
|
||||
"@videojs-player/vue": "^1.0.0",
|
||||
"dexie": "^3.2.4",
|
||||
"highlight.js": "^11.11.1",
|
||||
"lucide-vue-next": "^0.553.0",
|
||||
"pinia": "^3.0.4",
|
||||
"pinia-plugin-persistedstate": "^4.7.1",
|
||||
"qrcode.vue": "^3.6.0",
|
||||
"video.js": "^8.23.4",
|
||||
"vue-i18n": "^11.1.12",
|
||||
"vue-router": "^4.6.3",
|
||||
"vue3-lazyload": "^0.3.8",
|
||||
"@electron/notarize": "^3.1.1",
|
||||
"@eslint/js": "^9.39.1",
|
||||
"@intlify/unplugin-vue-i18n": "^11.0.1",
|
||||
"@types/ali-oss": "^6.16.11",
|
||||
"@intlify/unplugin-vue-i18n": "^11.0.3",
|
||||
"@types/ali-oss": "^6.16.13",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
@@ -108,30 +98,52 @@
|
||||
"@types/upyun": "^3.4.3",
|
||||
"@types/video.js": "^7.3.58",
|
||||
"@types/write-file-atomic": "^4.0.3",
|
||||
"@vitejs/plugin-vue": "^6.0.1",
|
||||
"@vue/eslint-config-standard": "^9.0.1",
|
||||
"@videojs-player/vue": "^1.0.0",
|
||||
"@vitejs/plugin-vue": "^6.0.3",
|
||||
"baseline-browser-mapping": "^2.9.11",
|
||||
"dexie": "^3.2.4",
|
||||
"dotenv": "^17.2.3",
|
||||
"dpdm": "^3.14.0",
|
||||
"electron": "^38.4.0",
|
||||
"electron-builder": "^26.0.12",
|
||||
"electron-vite": "^4.0.1",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-jsonc": "^2.21.0",
|
||||
"eslint-plugin-prettier": "^5.5.4",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"eslint-plugin-unicorn": "^62.0.0",
|
||||
"eslint-plugin-vue": "^10.5.1",
|
||||
"eslint-plugin-vue": "^10.6.2",
|
||||
"globals": "^16.5.0",
|
||||
"highlight.js": "^11.11.1",
|
||||
"husky": "^9.1.7",
|
||||
"lucide-vue-next": "^0.562.0",
|
||||
"node-bump-version": "^2.0.0",
|
||||
"prettier": "^3.6.2",
|
||||
"pinia": "^3.0.4",
|
||||
"pinia-plugin-persistedstate": "^4.7.1",
|
||||
"postcss": "^8.5.6",
|
||||
"postcss-html": "^1.8.0",
|
||||
"prettier": "^3.7.4",
|
||||
"qrcode.vue": "^3.6.0",
|
||||
"stylelint": "^16.26.1",
|
||||
"stylelint-config-html": "^1.1.0",
|
||||
"stylelint-config-standard": "^39.0.1",
|
||||
"stylelint-config-standard-vue": "^1.0.0",
|
||||
"stylelint-order": "^7.0.1",
|
||||
"stylus": "^0.64.0",
|
||||
"typescript": "5.8.2",
|
||||
"typescript-eslint": "^8.46.4",
|
||||
"vite": "^7.2.2",
|
||||
"vitest": "^4.0.8",
|
||||
"typescript-eslint": "^8.51.0",
|
||||
"video.js": "^8.23.4",
|
||||
"vite": "^7.3.0",
|
||||
"vitest": "^4.0.16",
|
||||
"vue-eslint-parser": "^10.2.0",
|
||||
"vue-tsc": "^3.1.3"
|
||||
"vue-i18n": "^11.2.7",
|
||||
"vue-router": "^4.6.4",
|
||||
"vue-tsc": "^3.2.1",
|
||||
"vue3-lazyload": "^0.3.8"
|
||||
},
|
||||
"resolutions": {
|
||||
"baseline-browser-mapping": "^2.9.11"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
|
||||
@@ -6,14 +6,14 @@ const darwin = [
|
||||
appNameWithPrefix: 'PicList-',
|
||||
ext: '.dmg',
|
||||
arch: '-arm64',
|
||||
'version-file': 'latest-mac.yml'
|
||||
'version-file': 'latest-mac.yml',
|
||||
},
|
||||
{
|
||||
appNameWithPrefix: 'PicList-',
|
||||
ext: '.dmg',
|
||||
arch: '-x64',
|
||||
'version-file': 'latest-mac.yml'
|
||||
}
|
||||
'version-file': 'latest-mac.yml',
|
||||
},
|
||||
]
|
||||
|
||||
const linux = [
|
||||
@@ -21,14 +21,14 @@ const linux = [
|
||||
appNameWithPrefix: 'PicList-',
|
||||
ext: '.AppImage',
|
||||
arch: '',
|
||||
'version-file': 'latest-linux.yml'
|
||||
'version-file': 'latest-linux.yml',
|
||||
},
|
||||
{
|
||||
appNameWithPrefix: 'piclist_',
|
||||
ext: '.snap',
|
||||
arch: '_amd64',
|
||||
'version-file': 'latest-linux.yml'
|
||||
}
|
||||
'version-file': 'latest-linux.yml',
|
||||
},
|
||||
]
|
||||
|
||||
// windows
|
||||
@@ -37,30 +37,30 @@ const win32 = [
|
||||
appNameWithPrefix: 'PicList-Setup-',
|
||||
ext: '.exe',
|
||||
arch: '-ia32',
|
||||
'version-file': 'latest.yml'
|
||||
'version-file': 'latest.yml',
|
||||
},
|
||||
{
|
||||
appNameWithPrefix: 'PicList-Setup-',
|
||||
ext: '.exe',
|
||||
arch: '-x64',
|
||||
'version-file': 'latest.yml'
|
||||
'version-file': 'latest.yml',
|
||||
},
|
||||
{
|
||||
appNameWithPrefix: 'PicList-Setup-',
|
||||
ext: '.exe',
|
||||
arch: '', // 32 & 64
|
||||
'version-file': 'latest.yml'
|
||||
'version-file': 'latest.yml',
|
||||
},
|
||||
{
|
||||
appNameWithPrefix: 'PicList-Setup-',
|
||||
ext: '.exe',
|
||||
arch: '-arm64',
|
||||
'version-file': 'latest.yml'
|
||||
}
|
||||
'version-file': 'latest.yml',
|
||||
},
|
||||
]
|
||||
|
||||
export default {
|
||||
darwin,
|
||||
linux,
|
||||
win32
|
||||
win32,
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ const DOWNLOAD_DIR = process.argv[3] || path.join(os.homedir(), 'Downloads')
|
||||
const files = [
|
||||
{
|
||||
name: 'PicList-x64.dmg',
|
||||
url: `${BASE_URL}/PicList-${version}-x64.dmg`
|
||||
url: `${BASE_URL}/PicList-${version}-x64.dmg`,
|
||||
},
|
||||
{
|
||||
name: 'PicList-arm64.dmg',
|
||||
url: `${BASE_URL}/PicList-${version}-arm64.dmg`
|
||||
}
|
||||
url: `${BASE_URL}/PicList-${version}-arm64.dmg`,
|
||||
},
|
||||
]
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ async function downloadAndHash(fileInfo) {
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url,
|
||||
responseType: 'stream'
|
||||
responseType: 'stream',
|
||||
})
|
||||
|
||||
const writer = fs.createWriteStream(filePath)
|
||||
|
||||
@@ -27,7 +27,7 @@ async function main(context) {
|
||||
appleId: XCODE_APP_LOADER_EMAIL,
|
||||
appleIdPassword: XCODE_APP_LOADER_PASSWORD,
|
||||
tool: 'notarytool',
|
||||
teamId: XCODE_TEAM_ID
|
||||
teamId: XCODE_TEAM_ID,
|
||||
})
|
||||
console.log('Finished Apple notarization.')
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ const uploadFile = async () => {
|
||||
const options = {
|
||||
credentials: {
|
||||
accessKeyId: SECRET_ID,
|
||||
secretAccessKey: SECRET_KEY
|
||||
secretAccessKey: SECRET_KEY,
|
||||
},
|
||||
endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
|
||||
tls: true,
|
||||
region: 'auto'
|
||||
region: 'auto',
|
||||
}
|
||||
const client = new S3Client.S3Client(options)
|
||||
const parallelUploads3 = new Upload.Upload({
|
||||
@@ -41,9 +41,9 @@ const uploadFile = async () => {
|
||||
Body: fileStream,
|
||||
ContentType: 'application/octet-stream',
|
||||
Metadata: {
|
||||
description: 'uploaded by PicList'
|
||||
}
|
||||
}
|
||||
description: 'uploaded by PicList',
|
||||
},
|
||||
},
|
||||
})
|
||||
parallelUploads3.on('httpUploadProgress', progress => {
|
||||
const progressBar = Math.round((progress.loaded / progress.total) * 100)
|
||||
|
||||
@@ -20,11 +20,11 @@ const SECRET_KEY = process.env.R2_SECRET_KEY
|
||||
const options = {
|
||||
credentials: {
|
||||
accessKeyId: SECRET_ID,
|
||||
secretAccessKey: SECRET_KEY
|
||||
secretAccessKey: SECRET_KEY,
|
||||
},
|
||||
endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
|
||||
tls: true,
|
||||
region: 'auto'
|
||||
region: 'auto',
|
||||
}
|
||||
|
||||
const removeDupField = path => {
|
||||
@@ -65,9 +65,9 @@ const uploadFile = async () => {
|
||||
Body: fileStream,
|
||||
ContentType: 'application/octet-stream',
|
||||
Metadata: {
|
||||
description: 'uploaded by PicList'
|
||||
}
|
||||
}
|
||||
description: 'uploaded by PicList',
|
||||
},
|
||||
},
|
||||
})
|
||||
parallelUploads3.on('httpUploadProgress', progress => {
|
||||
const progressBar = Math.round((progress.loaded / progress.total) * 100)
|
||||
@@ -97,9 +97,9 @@ const uploadFile = async () => {
|
||||
Body: versionFileStream,
|
||||
ContentType: mime.getType(versionFileName),
|
||||
Metadata: {
|
||||
description: 'uploaded by PicList'
|
||||
}
|
||||
}
|
||||
description: 'uploaded by PicList',
|
||||
},
|
||||
},
|
||||
})
|
||||
console.log('\nUploading version file to root...')
|
||||
await uploadVersionFileToRoot.done()
|
||||
@@ -114,9 +114,9 @@ const uploadFile = async () => {
|
||||
Body: versionFileStream2,
|
||||
ContentType: mime.getType(versionFileName),
|
||||
Metadata: {
|
||||
description: 'uploaded by PicList'
|
||||
}
|
||||
}
|
||||
description: 'uploaded by PicList',
|
||||
},
|
||||
},
|
||||
})
|
||||
console.log('\nUploading version file to latest...')
|
||||
await uploadVersionFileToLatest.done()
|
||||
|
||||
@@ -36,10 +36,10 @@ class RemoteNoticeHandler {
|
||||
try {
|
||||
const localCountStorage: IRemoteNoticeLocalCountStorage = fs.readJSONSync(
|
||||
REMOTE_NOTICE_LOCAL_STORAGE_PATH,
|
||||
'utf8'
|
||||
'utf8',
|
||||
)
|
||||
this.remoteNoticeLocalCountStorage = localCountStorage
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
this.remoteNoticeLocalCountStorage = localCountStorage
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class RemoteNoticeHandler {
|
||||
const noticeInfo = (await axios({
|
||||
method: 'get',
|
||||
url: REMOTE_NOTICE_URL,
|
||||
responseType: 'json'
|
||||
responseType: 'json',
|
||||
}).then(res => res.data)) as IRemoteNotice
|
||||
return noticeInfo
|
||||
} catch {
|
||||
@@ -121,7 +121,7 @@ class RemoteNoticeHandler {
|
||||
if (action.data?.url) {
|
||||
shell.openExternal(action.data.url)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
break
|
||||
case IRemoteNoticeActionType.OPEN_URL:
|
||||
@@ -144,7 +144,7 @@ class RemoteNoticeHandler {
|
||||
title: action.data?.title || '',
|
||||
message: action.data?.content || '',
|
||||
type: 'info',
|
||||
buttons: action.data?.buttons?.map(item => item.label) || ['Yes']
|
||||
buttons: action.data?.buttons?.map(item => item.label) || ['Yes'],
|
||||
})
|
||||
.then(res => {
|
||||
const button = action.data?.buttons?.[res.response]
|
||||
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
IPluginShortKeyConfig,
|
||||
IShortKeyConfig,
|
||||
IShortKeyConfigs,
|
||||
IShortKeyHandler
|
||||
IShortKeyHandler,
|
||||
} from '#/types/types'
|
||||
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '~/events/constant'
|
||||
import { configPaths } from '~/utils/configPaths'
|
||||
@@ -78,7 +78,7 @@ class ShortKeyHandler {
|
||||
config: IShortKeyConfig | IPluginShortKeyConfig,
|
||||
command: string,
|
||||
handler: IShortKeyHandler,
|
||||
writeFlag: boolean
|
||||
writeFlag: boolean,
|
||||
) {
|
||||
shortKeyService.registerCommand(command, handler)
|
||||
if (config.key) {
|
||||
@@ -96,8 +96,8 @@ class ShortKeyHandler {
|
||||
enable: true,
|
||||
name: config.name,
|
||||
label: config.label,
|
||||
key: config.key
|
||||
}
|
||||
key: config.key,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ class ShortKeyHandler {
|
||||
if (item.enable === false) {
|
||||
globalShortcut.unregister(item.key)
|
||||
picgo.saveConfig({
|
||||
[`settings.shortKey.${command}.enable`]: false
|
||||
[`settings.shortKey.${command}.enable`]: false,
|
||||
})
|
||||
return true
|
||||
} else {
|
||||
@@ -116,7 +116,7 @@ class ShortKeyHandler {
|
||||
return false
|
||||
} else {
|
||||
picgo.saveConfig({
|
||||
[`settings.shortKey.${command}.enable`]: true
|
||||
[`settings.shortKey.${command}.enable`]: true,
|
||||
})
|
||||
globalShortcut.register(item.key, () => {
|
||||
this.handler(command)
|
||||
@@ -132,7 +132,7 @@ class ShortKeyHandler {
|
||||
if (globalShortcut.isRegistered(item.key)) return false
|
||||
globalShortcut.unregister(oldKey)
|
||||
picgo.saveConfig({
|
||||
[`settings.shortKey.${command}.key`]: item.key
|
||||
[`settings.shortKey.${command}.key`]: item.key,
|
||||
})
|
||||
globalShortcut.register(item.key, () => {
|
||||
this.handler(`${from}:${item.name}`)
|
||||
@@ -183,7 +183,7 @@ class ShortKeyHandler {
|
||||
.map(command => {
|
||||
return {
|
||||
command,
|
||||
key: commands[command].key
|
||||
key: commands[command].key,
|
||||
}
|
||||
}) as IKeyCommandType[]
|
||||
keyList.forEach(item => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import logger from '@core/picgo/logger'
|
||||
import type { IShortKeyHandler } from '#/types/types'
|
||||
|
||||
class ShortKeyService {
|
||||
private commandList: Map<string, IShortKeyHandler> = new Map()
|
||||
private commandList = new Map<string, IShortKeyHandler>()
|
||||
registerCommand(command: string, handler: IShortKeyHandler) {
|
||||
this.commandList.set(command, handler)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
MenuItemConstructorOptions,
|
||||
nativeTheme,
|
||||
Notification,
|
||||
Tray
|
||||
Tray,
|
||||
} from 'electron'
|
||||
import fs from 'fs-extra'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
@@ -41,7 +41,7 @@ export function setDockMenu() {
|
||||
const dockMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: $t('OPEN_MAIN_WINDOW'),
|
||||
click: openMainWindow
|
||||
click: openMainWindow,
|
||||
},
|
||||
{
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
@@ -54,7 +54,7 @@ export function setDockMenu() {
|
||||
})
|
||||
setDockMenu()
|
||||
},
|
||||
visible: !isListeningClipboard
|
||||
visible: !isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
@@ -64,8 +64,8 @@ export function setDockMenu() {
|
||||
clipboardPoll.removeAllListeners()
|
||||
setDockMenu()
|
||||
},
|
||||
visible: isListeningClipboard
|
||||
}
|
||||
visible: isListeningClipboard,
|
||||
},
|
||||
])
|
||||
app.dock?.setMenu(dockMenu)
|
||||
}
|
||||
@@ -82,9 +82,9 @@ export function createMenu() {
|
||||
click() {
|
||||
app.relaunch()
|
||||
app.exit(0)
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{ label: $t('CHOOSE_DEFAULT_PICBED'), type: 'submenu', submenu },
|
||||
{
|
||||
@@ -96,13 +96,13 @@ export function createMenu() {
|
||||
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', role: 'cut' },
|
||||
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', role: 'copy' },
|
||||
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', role: 'paste' },
|
||||
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', role: 'selectAll' }
|
||||
]
|
||||
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', role: 'selectAll' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: $t('QUIT'),
|
||||
submenu: [{ label: $t('QUIT'), role: 'quit' }]
|
||||
}
|
||||
submenu: [{ label: $t('QUIT'), role: 'quit' }],
|
||||
},
|
||||
])
|
||||
Menu.setApplicationMenu(appMenu)
|
||||
}
|
||||
@@ -138,21 +138,21 @@ export function createContextMenu() {
|
||||
{
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
click: startWatchClipboard,
|
||||
visible: !isListeningClipboard
|
||||
visible: !isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
click: stopWatchClipboard,
|
||||
visible: isListeningClipboard
|
||||
visible: isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('RELOAD_APP'),
|
||||
click() {
|
||||
app.relaunch()
|
||||
app.exit(0)
|
||||
}
|
||||
},
|
||||
},
|
||||
{ label: $t('QUIT'), role: 'quit' }
|
||||
{ label: $t('QUIT'), role: 'quit' },
|
||||
]
|
||||
if (process.platform === 'win32') {
|
||||
template.splice(
|
||||
@@ -163,13 +163,13 @@ export function createContextMenu() {
|
||||
click() {
|
||||
openMiniWindow(false)
|
||||
},
|
||||
visible: !isMiniWindowVisible
|
||||
visible: !isMiniWindowVisible,
|
||||
},
|
||||
{
|
||||
label: $t('HIDE_MINI_WINDOW'),
|
||||
click: hideMiniWindow,
|
||||
visible: isMiniWindowVisible
|
||||
}
|
||||
visible: isMiniWindowVisible,
|
||||
},
|
||||
)
|
||||
}
|
||||
contextMenu = Menu.buildFromTemplate(template)
|
||||
@@ -188,22 +188,22 @@ export function createContextMenu() {
|
||||
click() {
|
||||
openMiniWindow(false)
|
||||
},
|
||||
visible: !isMiniWindowVisible
|
||||
visible: !isMiniWindowVisible,
|
||||
},
|
||||
{
|
||||
label: $t('HIDE_MINI_WINDOW'),
|
||||
click: hideMiniWindow,
|
||||
visible: isMiniWindowVisible
|
||||
visible: isMiniWindowVisible,
|
||||
},
|
||||
{
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
click: startWatchClipboard,
|
||||
visible: !isListeningClipboard
|
||||
visible: !isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
click: stopWatchClipboard,
|
||||
visible: isListeningClipboard
|
||||
visible: isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('ABOUT'),
|
||||
@@ -212,11 +212,11 @@ export function createContextMenu() {
|
||||
title: 'PicList',
|
||||
message: 'PicList',
|
||||
buttons: ['Ok'],
|
||||
detail: `Version: ${pkg.version}\nAuthor: Kuingsmile\nGithub: https://github.com/Kuingsmile/PicList`
|
||||
detail: `Version: ${pkg.version}\nAuthor: Kuingsmile\nGithub: https://github.com/Kuingsmile/PicList`,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{ label: $t('QUIT'), role: 'quit' }
|
||||
{ label: $t('QUIT'), role: 'quit' },
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -258,14 +258,14 @@ export function createTray(tooltip: string) {
|
||||
const decodePath = ensureFilePath(imgPath)
|
||||
if (decodePath === imgPath) {
|
||||
obj.push({
|
||||
imgUrl: imgPath
|
||||
imgUrl: imgPath,
|
||||
})
|
||||
} else {
|
||||
if (decodePath !== '') {
|
||||
// 带有中文的路径,无法直接被img.src所使用,会被转义
|
||||
const base64 = await fs.readFile(decodePath.replace('file://', ''), { encoding: 'base64' })
|
||||
obj.push({
|
||||
imgUrl: `data:image/png;base64,${base64}`
|
||||
imgUrl: `data:image/png;base64,${base64}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -274,7 +274,7 @@ export function createTray(tooltip: string) {
|
||||
obj.push({
|
||||
width: img.getSize().width,
|
||||
height: img.getSize().height,
|
||||
imgUrl
|
||||
imgUrl,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -333,7 +333,7 @@ export function createTray(tooltip: string) {
|
||||
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
||||
pasteStyle,
|
||||
imgs[i],
|
||||
db.get(configPaths.settings.customLink)
|
||||
db.get(configPaths.settings.customLink),
|
||||
)
|
||||
imgs[i].shortUrl = shortUrl
|
||||
pasteText.push(pasteTextItem)
|
||||
@@ -344,7 +344,7 @@ export function createTray(tooltip: string) {
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || imgs[i].imgUrl!
|
||||
body: shortUrl || imgs[i].imgUrl!,
|
||||
// icon: files[i]
|
||||
})
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -62,7 +62,7 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || img[0].imgUrl!
|
||||
body: shortUrl || img[0].imgUrl!,
|
||||
// icon: img[0].imgUrl
|
||||
})
|
||||
setTimeout(() => {
|
||||
@@ -78,30 +78,30 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
||||
}
|
||||
return {
|
||||
url: handleUrlEncodeWithSetting(inserted.imgUrl as string),
|
||||
fullResult: inserted
|
||||
fullResult: inserted,
|
||||
}
|
||||
} else {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_FAILED'),
|
||||
body: $t('TIPS_UPLOAD_NOT_PICTURES')
|
||||
body: $t('TIPS_UPLOAD_NOT_PICTURES'),
|
||||
})
|
||||
notification.show()
|
||||
return {
|
||||
url: '',
|
||||
fullResult: {}
|
||||
fullResult: {},
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
url: '',
|
||||
fullResult: {}
|
||||
fullResult: {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const uploadChoosedFiles = async (
|
||||
webContents: WebContents,
|
||||
files: IFileWithPath[]
|
||||
files: IFileWithPath[],
|
||||
): Promise<IStringKeyMap[]> => {
|
||||
const input = files.map(item => item.path)
|
||||
const rawInput = cloneDeep(input)
|
||||
@@ -132,7 +132,7 @@ export const uploadChoosedFiles = async (
|
||||
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
||||
pasteStyle,
|
||||
imgs[i],
|
||||
db.get(configPaths.settings.customLink)
|
||||
db.get(configPaths.settings.customLink),
|
||||
)
|
||||
imgs[i].shortUrl = shortUrl
|
||||
pasteText.push(pasteTextItem)
|
||||
@@ -144,7 +144,7 @@ export const uploadChoosedFiles = async (
|
||||
if (imgLength <= 3) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || imgs[i].imgUrl!
|
||||
body: shortUrl || imgs[i].imgUrl!,
|
||||
// icon: files[i].path
|
||||
})
|
||||
setTimeout(() => {
|
||||
@@ -153,7 +153,7 @@ export const uploadChoosedFiles = async (
|
||||
} else if (i === imgLength - 1) {
|
||||
const notification = new Notification({
|
||||
title: $t('MULTI_UPLOAD_SUCCEED', { n: imgLength }),
|
||||
body: ''
|
||||
body: '',
|
||||
})
|
||||
setTimeout(() => {
|
||||
notification.show()
|
||||
@@ -163,7 +163,7 @@ export const uploadChoosedFiles = async (
|
||||
const inserted = await GalleryDB.getInstance().insert(imgs[i])
|
||||
result.push({
|
||||
url: handleUrlEncodeWithSetting(inserted.imgUrl!),
|
||||
fullResult: inserted
|
||||
fullResult: inserted,
|
||||
})
|
||||
}
|
||||
handleCopyUrl(pasteText.join('\n'))
|
||||
@@ -181,7 +181,7 @@ export const uploadChoosedFiles = async (
|
||||
export const handleSecondaryUpload = async (
|
||||
webContents?: WebContents,
|
||||
input?: string[],
|
||||
uploadType: 'clipboard' | 'file' | 'tray' = 'file'
|
||||
uploadType: 'clipboard' | 'file' | 'tray' = 'file',
|
||||
): Promise<{ needRestore: boolean; ctx: IPicGo | false }> => {
|
||||
const enableSecondUploader = db.get(configPaths.settings.enableSecondUploader) || false
|
||||
let currentPicBedType = ''
|
||||
@@ -242,6 +242,6 @@ export const handleSecondaryUpload = async (
|
||||
}
|
||||
return {
|
||||
needRestore,
|
||||
ctx
|
||||
ctx,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class Uploader {
|
||||
if (db.get(configPaths.settings.uploadNotification)) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_PROGRESS'),
|
||||
body: $t('UPLOADING')
|
||||
body: $t('UPLOADING'),
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
@@ -85,10 +85,10 @@ class Uploader {
|
||||
name = await waitForRename(window, window.webContents.id)
|
||||
}
|
||||
item.fileName = name || fileName
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ class Uploader {
|
||||
showNotification({
|
||||
title: $t('UPLOAD_FAILED'),
|
||||
body: util.format(e.stack),
|
||||
clickToCopy: true
|
||||
clickToCopy: true,
|
||||
})
|
||||
}, 500)
|
||||
return false
|
||||
@@ -186,7 +186,7 @@ class Uploader {
|
||||
showNotification({
|
||||
title: $t('UPLOAD_FAILED'),
|
||||
body: util.format(e.stack),
|
||||
clickToCopy: true
|
||||
clickToCopy: true,
|
||||
})
|
||||
}, 500)
|
||||
return false
|
||||
|
||||
@@ -20,11 +20,11 @@ const windowList = new Map<string, IWindowListItem>()
|
||||
const getDefaultWindowSizes = (): { width: number; height: number } => {
|
||||
const [mainWindowWidth, mainWindowHeight] = db.get([
|
||||
configPaths.settings.mainWindowWidth,
|
||||
configPaths.settings.mainWindowHeight
|
||||
configPaths.settings.mainWindowHeight,
|
||||
])
|
||||
return {
|
||||
width: mainWindowWidth || 1200,
|
||||
height: mainWindowHeight || 800
|
||||
height: mainWindowHeight || 800,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@ const trayWindowOptions = {
|
||||
contextIsolation: true,
|
||||
nodeIntegrationInWorker: false,
|
||||
backgroundThrottling: true,
|
||||
webSecurity: false
|
||||
}
|
||||
webSecurity: false,
|
||||
},
|
||||
}
|
||||
|
||||
const settingWindowOptions = {
|
||||
@@ -88,8 +88,8 @@ const settingWindowOptions = {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
nodeIntegrationInWorker: false,
|
||||
webSecurity: false
|
||||
}
|
||||
webSecurity: false,
|
||||
},
|
||||
} as IBrowserWindowOptions
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
@@ -113,8 +113,8 @@ const miniWindowOptions = {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
backgroundThrottling: true,
|
||||
nodeIntegrationInWorker: false
|
||||
}
|
||||
nodeIntegrationInWorker: false,
|
||||
},
|
||||
} as IBrowserWindowOptions
|
||||
|
||||
if (db.get(configPaths.settings.miniWindowOntop)) {
|
||||
@@ -134,8 +134,8 @@ const renameWindowOptions = {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
nodeIntegrationInWorker: false,
|
||||
backgroundThrottling: false
|
||||
}
|
||||
backgroundThrottling: false,
|
||||
},
|
||||
} as IBrowserWindowOptions
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
@@ -163,8 +163,8 @@ const toolboxWindowOptions = {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
nodeIntegrationInWorker: false,
|
||||
webSecurity: false
|
||||
}
|
||||
webSecurity: false,
|
||||
},
|
||||
} as IBrowserWindowOptions
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
@@ -186,7 +186,7 @@ windowList.set(IWindowList.TRAY_WINDOW, {
|
||||
window.on('blur', () => {
|
||||
window.hide()
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
windowList.set(IWindowList.SETTING_WINDOW, {
|
||||
@@ -198,7 +198,7 @@ windowList.set(IWindowList.SETTING_WINDOW, {
|
||||
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#main-page/upload`)
|
||||
} else {
|
||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||
hash: 'main-page/upload'
|
||||
hash: 'main-page/upload',
|
||||
})
|
||||
}
|
||||
window.on('closed', () => {
|
||||
@@ -211,7 +211,7 @@ windowList.set(IWindowList.SETTING_WINDOW, {
|
||||
})
|
||||
bus.emit(CREATE_APP_MENU)
|
||||
windowManager.create(IWindowList.MINI_WINDOW)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
windowList.set(IWindowList.MINI_WINDOW, {
|
||||
@@ -223,10 +223,10 @@ windowList.set(IWindowList.MINI_WINDOW, {
|
||||
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#mini-page`)
|
||||
} else {
|
||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||
hash: 'mini-page'
|
||||
hash: 'mini-page',
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
windowList.set(IWindowList.RENAME_WINDOW, {
|
||||
@@ -238,7 +238,7 @@ windowList.set(IWindowList.RENAME_WINDOW, {
|
||||
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#rename-page`)
|
||||
} else {
|
||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||
hash: 'rename-page'
|
||||
hash: 'rename-page',
|
||||
})
|
||||
}
|
||||
const currentWindow = windowManager.getAvailableWindow(true)
|
||||
@@ -248,7 +248,7 @@ windowList.set(IWindowList.RENAME_WINDOW, {
|
||||
const positionY = Math.floor(y + height / 2 - (height > 400 ? 88 : 0))
|
||||
window.setPosition(positionX, positionY, false)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
windowList.set(IWindowList.TOOLBOX_WINDOW, {
|
||||
@@ -260,7 +260,7 @@ windowList.set(IWindowList.TOOLBOX_WINDOW, {
|
||||
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#toolbox-page`)
|
||||
} else {
|
||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||
hash: 'toolbox-page'
|
||||
hash: 'toolbox-page',
|
||||
})
|
||||
}
|
||||
const currentWindow = windowManager.getAvailableWindow(true)
|
||||
@@ -270,7 +270,7 @@ windowList.set(IWindowList.TOOLBOX_WINDOW, {
|
||||
const positionY = Math.floor(y + height / 2 - (height > 400 ? 225 : 0))
|
||||
window.setPosition(positionX, positionY, false)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export default windowList
|
||||
|
||||
@@ -5,8 +5,8 @@ import type { IWindowListItem, IWindowManager } from '#/types/electron'
|
||||
import { IWindowList } from '~/utils/enum'
|
||||
|
||||
class WindowManager implements IWindowManager {
|
||||
#windowMap: Map<string, BrowserWindow> = new Map()
|
||||
#windowIdMap: Map<number, string> = new Map()
|
||||
#windowMap = new Map<string, BrowserWindow>()
|
||||
#windowIdMap = new Map<number, string>()
|
||||
|
||||
create(name: string) {
|
||||
const windowConfig: IWindowListItem = windowList.get(name)!
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
UPLOAD_WITH_CLIPBOARD_FILES,
|
||||
UPLOAD_WITH_CLIPBOARD_FILES_RESPONSE,
|
||||
UPLOAD_WITH_FILES,
|
||||
UPLOAD_WITH_FILES_RESPONSE
|
||||
UPLOAD_WITH_FILES_RESPONSE,
|
||||
} from '@core/bus/constants'
|
||||
import bus from '@core/bus/index'
|
||||
|
||||
@@ -21,11 +21,11 @@ export const uploadWithClipboardFiles = (): Promise<{
|
||||
if (result) {
|
||||
return resolve({
|
||||
success: true,
|
||||
result: [result]
|
||||
result: [result],
|
||||
})
|
||||
} else {
|
||||
return resolve({
|
||||
success: false
|
||||
success: false,
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -34,7 +34,7 @@ export const uploadWithClipboardFiles = (): Promise<{
|
||||
}
|
||||
|
||||
export const uploadWithFiles = (
|
||||
pathList: IFileWithPath[]
|
||||
pathList: IFileWithPath[],
|
||||
): Promise<{
|
||||
success: boolean
|
||||
result?: string[]
|
||||
@@ -44,11 +44,11 @@ export const uploadWithFiles = (
|
||||
if (result.length) {
|
||||
return resolve({
|
||||
success: true,
|
||||
result
|
||||
result,
|
||||
})
|
||||
} else {
|
||||
return resolve({
|
||||
success: false
|
||||
success: false,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -20,7 +20,7 @@ let hasCheckPath = false
|
||||
|
||||
const errorMsg = {
|
||||
broken: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT'),
|
||||
brokenButBackup: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP')
|
||||
brokenButBackup: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP'),
|
||||
}
|
||||
|
||||
function dbChecker() {
|
||||
@@ -42,28 +42,28 @@ function dbChecker() {
|
||||
let configFile: string = '{}'
|
||||
const optionsTpl = {
|
||||
title: $t('TIPS_NOTICE'),
|
||||
body: ''
|
||||
body: '',
|
||||
}
|
||||
// config save bak
|
||||
try {
|
||||
configFile = fs.readFileSync(configFilePath, { encoding: 'utf-8' })
|
||||
JSON.parse(configFile)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
fs.unlinkSync(configFilePath)
|
||||
if (fs.existsSync(configFileBackupPath)) {
|
||||
try {
|
||||
configFile = fs.readFileSync(configFileBackupPath, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
JSON.parse(configFile)
|
||||
writeFile.sync(configFilePath, configFile, { encoding: 'utf-8' })
|
||||
const stats = fs.statSync(configFileBackupPath)
|
||||
optionsTpl.body = `${errorMsg.brokenButBackup}\n${$t('TIPS_PICGO_BACKUP_FILE_VERSION', {
|
||||
v: dayjs(stats.mtime).format('YYYY-MM-DD HH:mm:ss')
|
||||
v: dayjs(stats.mtime).format('YYYY-MM-DD HH:mm:ss'),
|
||||
})}`
|
||||
notificationList.push(optionsTpl)
|
||||
return
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
optionsTpl.body = errorMsg.broken
|
||||
notificationList.push(optionsTpl)
|
||||
return
|
||||
@@ -92,7 +92,7 @@ function dbPathChecker(): string {
|
||||
}
|
||||
try {
|
||||
const configString = fs.readFileSync(defaultConfigPath, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
const config = JSON.parse(configString)
|
||||
const userConfigPath: string = config.configPath || ''
|
||||
@@ -109,7 +109,7 @@ function dbPathChecker(): string {
|
||||
if (!hasCheckPath) {
|
||||
const optionsTpl = {
|
||||
title: $t('TIPS_NOTICE'),
|
||||
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR')
|
||||
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR'),
|
||||
}
|
||||
notificationList.push(optionsTpl)
|
||||
hasCheckPath = true
|
||||
@@ -133,7 +133,7 @@ function getGalleryDBPath(): {
|
||||
const dbBackupPath = path.join(path.dirname(dbPath), 'piclist.bak.db')
|
||||
return {
|
||||
dbPath,
|
||||
dbBackupPath
|
||||
dbBackupPath,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ class ConfigStore {
|
||||
current: 'smms', // deprecated
|
||||
uploader: 'smms',
|
||||
smms: {
|
||||
token: ''
|
||||
}
|
||||
token: '',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class ConfigStore {
|
||||
enable: true,
|
||||
key: 'CommandOrControl+Alt+P',
|
||||
name: 'upload',
|
||||
label: $t('QUICK_UPLOAD')
|
||||
label: $t('QUICK_UPLOAD'),
|
||||
})
|
||||
}
|
||||
this.read()
|
||||
|
||||
@@ -14,7 +14,7 @@ const picgo = await PicGo.create(CONFIG_PATH)
|
||||
|
||||
picgo.saveConfig({
|
||||
debug: true,
|
||||
PICGO_ENV: 'GUI'
|
||||
PICGO_ENV: 'GUI',
|
||||
})
|
||||
|
||||
picgo.GUI_VERSION = pkg.version
|
||||
|
||||
@@ -21,7 +21,7 @@ const checkLogFileIsLarge = (logPath: string): CheckLogFileResult => {
|
||||
return {
|
||||
isLarge: logFileSize > DEFAULT_LOG_FILE_SIZE_LIMIT,
|
||||
logFileSize,
|
||||
logFileSizeLimit: DEFAULT_LOG_FILE_SIZE_LIMIT
|
||||
logFileSizeLimit: DEFAULT_LOG_FILE_SIZE_LIMIT,
|
||||
}
|
||||
}
|
||||
return { isLarge: false }
|
||||
|
||||
@@ -26,12 +26,12 @@ export default class AlistApi {
|
||||
url: `${url}/api/fs/remove`,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: token
|
||||
Authorization: token,
|
||||
},
|
||||
data: {
|
||||
dir: path.join('/', uploadPath, path.dirname(fileName)),
|
||||
names: [path.basename(fileName)]
|
||||
}
|
||||
names: [path.basename(fileName)],
|
||||
},
|
||||
})
|
||||
const ok = result.data.code === 200
|
||||
deleteLog(fileName, 'Alist', ok)
|
||||
|
||||
@@ -18,7 +18,7 @@ interface IConfigMap {
|
||||
const getAListToken = async (url: string, username: string, password: string) => {
|
||||
const res = await axios.post(`${url}/api/auth/login`, {
|
||||
username,
|
||||
password
|
||||
password,
|
||||
})
|
||||
if (res.data.code === 200 && res.data.message === 'success') {
|
||||
return res.data.data.token
|
||||
@@ -43,12 +43,12 @@ export default class AListplistApi {
|
||||
url: `${url}/api/fs/remove`,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: token
|
||||
Authorization: token,
|
||||
},
|
||||
data: {
|
||||
dir: path.join('/', uploadPath, path.dirname(fileName)),
|
||||
names: [path.basename(fileName)]
|
||||
}
|
||||
names: [path.basename(fileName)],
|
||||
},
|
||||
})
|
||||
const ok = result.data.code === 200
|
||||
deleteLog(fileName, 'Alist', ok)
|
||||
|
||||
@@ -35,7 +35,7 @@ const apiMap: IStringKeyMap = {
|
||||
smms: SmmsApi,
|
||||
tcyun: TcyunApi,
|
||||
upyun: UpyunApi,
|
||||
webdavplist: WebdavApi
|
||||
webdavplist: WebdavApi,
|
||||
}
|
||||
|
||||
export default class ALLApi {
|
||||
|
||||
@@ -12,7 +12,7 @@ interface IConfigMap {
|
||||
export default class GithubApi {
|
||||
static #createOctokit(token: string) {
|
||||
return new Octokit({
|
||||
auth: token
|
||||
auth: token,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export default class GithubApi {
|
||||
const {
|
||||
fileName,
|
||||
hash,
|
||||
config: { repo, token, branch, path }
|
||||
config: { repo, token, branch, path },
|
||||
} = configMap
|
||||
const [owner, repoName] = repo.split('/')
|
||||
const octokit = GithubApi.#createOctokit(token)
|
||||
@@ -37,7 +37,7 @@ export default class GithubApi {
|
||||
path: key,
|
||||
message: `delete ${fileName} by PicList`,
|
||||
sha: hash,
|
||||
branch
|
||||
branch,
|
||||
})
|
||||
const ok = status === 200
|
||||
deleteLog(fileName, 'GitHub', ok)
|
||||
|
||||
@@ -28,7 +28,7 @@ export default class ImgurApi {
|
||||
try {
|
||||
const response: AxiosResponse = await axios.delete(apiUrl, {
|
||||
headers: { Authorization },
|
||||
timeout: 30000
|
||||
timeout: 30000,
|
||||
})
|
||||
const ok = response.status === 200
|
||||
deleteLog(hash, 'Imgur', ok)
|
||||
|
||||
@@ -21,17 +21,17 @@ export default class LskyplistApi {
|
||||
|
||||
const v2Headers = {
|
||||
Accept: 'application/json',
|
||||
Authorization: token || undefined
|
||||
Authorization: token || undefined,
|
||||
}
|
||||
|
||||
const requestAgent = new https.Agent({
|
||||
rejectUnauthorized: false
|
||||
rejectUnauthorized: false,
|
||||
})
|
||||
try {
|
||||
const response: AxiosResponse = await axios.delete(`${host}/api/v1/images/${hash}`, {
|
||||
headers: v2Headers,
|
||||
timeout: 30000,
|
||||
httpsAgent: requestAgent
|
||||
httpsAgent: requestAgent,
|
||||
})
|
||||
const ok = response.status === 200 && response.data.status === true
|
||||
deleteLog(hash, 'Lskyplist', ok)
|
||||
|
||||
@@ -18,7 +18,7 @@ export default class PiclistApi {
|
||||
|
||||
try {
|
||||
const response: AxiosResponse = await axios.post(url, {
|
||||
list: [fullResult]
|
||||
list: [fullResult],
|
||||
})
|
||||
const ok = response.status === 200 && response.data?.success
|
||||
deleteLog(fullResult, 'Piclist', ok)
|
||||
|
||||
@@ -11,7 +11,7 @@ export default class QiniuApi {
|
||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||
const {
|
||||
fileName,
|
||||
config: { accessKey, secretKey, bucket, path }
|
||||
config: { accessKey, secretKey, bucket, path },
|
||||
} = configMap
|
||||
const mac = new qiniu.auth.digest.Mac(accessKey, secretKey)
|
||||
const qiniuConfig = new qiniu.conf.Config()
|
||||
@@ -26,7 +26,7 @@ export default class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -23,13 +23,13 @@ export default class SmmsApi {
|
||||
try {
|
||||
const response: AxiosResponse = await axios.get(`${SmmsApi.#baseUrl}/delete/${hash}`, {
|
||||
headers: {
|
||||
Authorization: token
|
||||
Authorization: token,
|
||||
},
|
||||
params: {
|
||||
hash,
|
||||
format: 'json'
|
||||
format: 'json',
|
||||
},
|
||||
timeout: 30000
|
||||
timeout: 30000,
|
||||
})
|
||||
const ok = response.status === 200
|
||||
deleteLog(hash, 'Smms', ok)
|
||||
|
||||
@@ -10,14 +10,14 @@ export default class TcyunApi {
|
||||
static #createCOS(SecretId: string, SecretKey: string): COS {
|
||||
return new COS({
|
||||
SecretId,
|
||||
SecretKey
|
||||
SecretKey,
|
||||
})
|
||||
}
|
||||
|
||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||
const {
|
||||
fileName,
|
||||
config: { secretId, secretKey, bucket, area, path }
|
||||
config: { secretId, secretKey, bucket, area, path },
|
||||
} = configMap
|
||||
try {
|
||||
const cos = TcyunApi.#createCOS(secretId, secretKey)
|
||||
@@ -30,7 +30,7 @@ export default class TcyunApi {
|
||||
const result = await cos.deleteObject({
|
||||
Bucket: bucket,
|
||||
Region: area,
|
||||
Key: key
|
||||
Key: key,
|
||||
})
|
||||
const ok = result.statusCode === 204
|
||||
deleteLog(fileName, 'Tcyun', ok)
|
||||
|
||||
@@ -12,7 +12,7 @@ export default class UpyunApi {
|
||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||
const {
|
||||
fileName,
|
||||
config: { bucket, operator, password, path }
|
||||
config: { bucket, operator, password, path },
|
||||
} = configMap
|
||||
try {
|
||||
const service = new Upyun.Service(bucket, operator, password)
|
||||
|
||||
@@ -13,12 +13,12 @@ export default class WebdavApi {
|
||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||
const {
|
||||
fileName,
|
||||
config: { host, username, password, path, sslEnabled, authType }
|
||||
config: { host, username, password, path, sslEnabled, authType },
|
||||
} = configMap
|
||||
const endpoint = formatEndpoint(host, sslEnabled)
|
||||
const options: WebDAVClientOptions = {
|
||||
username,
|
||||
password
|
||||
password,
|
||||
}
|
||||
if (authType === 'digest') {
|
||||
options.authType = AuthType.Digest
|
||||
|
||||
@@ -16,7 +16,7 @@ import type {
|
||||
IShowMessageBoxOption,
|
||||
IShowMessageBoxResult,
|
||||
IShowNotificationOption,
|
||||
IUploadOption
|
||||
IUploadOption,
|
||||
} from '#/types/types'
|
||||
import { SHOW_INPUT_BOX } from '~/events/constant'
|
||||
import { T as $t } from '~/i18n'
|
||||
@@ -62,8 +62,8 @@ class GuiApi implements IGuiApi {
|
||||
async showInputBox(
|
||||
options: IShowInputBoxOption = {
|
||||
title: '',
|
||||
placeholder: ''
|
||||
}
|
||||
placeholder: '',
|
||||
},
|
||||
) {
|
||||
await this.showSettingWindow()
|
||||
this.getWebcontentsByWindowId(this.settingWindowId)?.send(SHOW_INPUT_BOX, options)
|
||||
@@ -103,7 +103,7 @@ class GuiApi implements IGuiApi {
|
||||
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
||||
pasteStyle,
|
||||
imgs[i],
|
||||
db.get(configPaths.settings.customLink)
|
||||
db.get(configPaths.settings.customLink),
|
||||
)
|
||||
imgs[i].shortUrl = shortUrl
|
||||
pasteText.push(pasteTextItem)
|
||||
@@ -114,7 +114,7 @@ class GuiApi implements IGuiApi {
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || (imgs[i].imgUrl! as string)
|
||||
body: shortUrl || (imgs[i].imgUrl! as string),
|
||||
// icon: imgs[i].imgUrl
|
||||
})
|
||||
setTimeout(() => {
|
||||
@@ -134,12 +134,12 @@ class GuiApi implements IGuiApi {
|
||||
showNotification(
|
||||
options: IShowNotificationOption = {
|
||||
title: '',
|
||||
body: ''
|
||||
}
|
||||
body: '',
|
||||
},
|
||||
) {
|
||||
const notification = new Notification({
|
||||
title: options.title,
|
||||
body: options.body
|
||||
body: options.body,
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
@@ -149,8 +149,8 @@ class GuiApi implements IGuiApi {
|
||||
title: '',
|
||||
message: '',
|
||||
type: 'info',
|
||||
buttons: ['Yes', 'No']
|
||||
}
|
||||
buttons: ['Yes', 'No'],
|
||||
},
|
||||
) {
|
||||
return new Promise<IShowMessageBoxResult>(resolve => {
|
||||
getWindowId().then(id => {
|
||||
@@ -158,7 +158,7 @@ class GuiApi implements IGuiApi {
|
||||
dialog.showMessageBox(BrowserWindow.fromId(id)!, options as MessageBoxOptions).then(res => {
|
||||
resolve({
|
||||
result: res.response,
|
||||
checkboxChecked: res.checkboxChecked
|
||||
checkboxChecked: res.checkboxChecked,
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -174,7 +174,7 @@ class GuiApi implements IGuiApi {
|
||||
return {
|
||||
defaultConfigPath,
|
||||
currentConfigPath,
|
||||
galleryDBPath
|
||||
galleryDBPath,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class GuiApi implements IGuiApi {
|
||||
title: $t('TIPS_WARNING'),
|
||||
message: $t('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
||||
type: 'info',
|
||||
buttons: ['Yes', 'No']
|
||||
buttons: ['Yes', 'No'],
|
||||
})
|
||||
.then(res => {
|
||||
if (res.result === 0) {
|
||||
@@ -201,7 +201,7 @@ class GuiApi implements IGuiApi {
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
if (prop === 'removeById') {
|
||||
@@ -214,7 +214,7 @@ class GuiApi implements IGuiApi {
|
||||
title: $t('TIPS_WARNING'),
|
||||
message: $t('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
||||
type: 'info',
|
||||
buttons: ['Yes', 'No']
|
||||
buttons: ['Yes', 'No'],
|
||||
})
|
||||
.then(res => {
|
||||
if (res.result === 0) {
|
||||
@@ -224,11 +224,11 @@ class GuiApi implements IGuiApi {
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
return Reflect.get(target, prop)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
UPLOAD_WITH_CLIPBOARD_FILES,
|
||||
UPLOAD_WITH_CLIPBOARD_FILES_RESPONSE,
|
||||
UPLOAD_WITH_FILES,
|
||||
UPLOAD_WITH_FILES_RESPONSE
|
||||
UPLOAD_WITH_FILES_RESPONSE,
|
||||
} from '@core/bus/constants'
|
||||
import { createMenu } from 'apis/app/system'
|
||||
import { uploadChoosedFiles, uploadClipboardFiles } from 'apis/app/uploader/apis'
|
||||
@@ -24,7 +24,7 @@ function initEventCenter() {
|
||||
[UPLOAD_WITH_FILES]: busCallUploadFiles,
|
||||
[GET_WINDOW_ID]: busCallGetWindowId,
|
||||
[GET_SETTING_WINDOW_ID]: busCallGetSettingWindowId,
|
||||
[CREATE_APP_MENU]: createMenu
|
||||
[CREATE_APP_MENU]: createMenu,
|
||||
}
|
||||
for (const i in eventList) {
|
||||
bus.on(i, eventList[i])
|
||||
@@ -57,5 +57,5 @@ function busCallGetSettingWindowId() {
|
||||
export default {
|
||||
listen() {
|
||||
initEventCenter()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
PICGO_HANDLE_PLUGIN_DONE,
|
||||
PICGO_HANDLE_PLUGIN_ING,
|
||||
PICGO_TOGGLE_PLUGIN,
|
||||
SHOW_MAIN_PAGE_QRCODE
|
||||
SHOW_MAIN_PAGE_QRCODE,
|
||||
} from '~/events/constant'
|
||||
import { handlePluginUninstall, handlePluginUpdate } from '~/events/rpc/routes/plugin/utils'
|
||||
import { T as $t } from '~/i18n'
|
||||
@@ -37,24 +37,24 @@ const buildMiniPageMenu = () => {
|
||||
const template: (MenuItemConstructorOptions | MenuItem)[] = [
|
||||
{
|
||||
label: $t('OPEN_MAIN_WINDOW'),
|
||||
click: openMainWindow
|
||||
click: openMainWindow,
|
||||
},
|
||||
{
|
||||
label: $t('CHOOSE_DEFAULT_PICBED'),
|
||||
type: 'submenu',
|
||||
submenu
|
||||
submenu,
|
||||
},
|
||||
{
|
||||
label: $t('UPLOAD_BY_CLIPBOARD'),
|
||||
click() {
|
||||
uploadClipboardFiles()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('HIDE_MINI_WINDOW'),
|
||||
click() {
|
||||
BrowserWindow.getFocusedWindow()!.hide()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('START_WATCH_CLIPBOARD'),
|
||||
@@ -67,7 +67,7 @@ const buildMiniPageMenu = () => {
|
||||
})
|
||||
buildMiniPageMenu()
|
||||
},
|
||||
visible: !isListeningClipboard
|
||||
visible: !isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||
@@ -77,19 +77,19 @@ const buildMiniPageMenu = () => {
|
||||
ClipboardWatcher.removeAllListeners()
|
||||
buildMiniPageMenu()
|
||||
},
|
||||
visible: isListeningClipboard
|
||||
visible: isListeningClipboard,
|
||||
},
|
||||
{
|
||||
label: $t('RELOAD_APP'),
|
||||
click() {
|
||||
app.relaunch()
|
||||
app.exit(0)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
role: 'quit',
|
||||
label: $t('QUIT')
|
||||
}
|
||||
label: $t('QUIT'),
|
||||
},
|
||||
]
|
||||
return Menu.buildFromTemplate(template)
|
||||
}
|
||||
@@ -102,36 +102,36 @@ const buildMainPageMenu = (win: BrowserWindow) => {
|
||||
dialog.showMessageBox({
|
||||
title: 'PicList',
|
||||
message: 'PicList',
|
||||
detail: `Version: ${pkg.version}\nAuthor: Kuingsmile\nGithub: https://github.com/Kuingsmile/PicList`
|
||||
detail: `Version: ${pkg.version}\nAuthor: Kuingsmile\nGithub: https://github.com/Kuingsmile/PicList`,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('SHOW_PICBED_QRCODE'),
|
||||
click() {
|
||||
win?.webContents?.send(SHOW_MAIN_PAGE_QRCODE)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('OPEN_TOOLBOX'),
|
||||
click() {
|
||||
const window = windowManager.create(IWindowList.TOOLBOX_WINDOW)
|
||||
window?.show()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('SHOW_DEVTOOLS'),
|
||||
click() {
|
||||
win?.webContents?.openDevTools({ mode: 'detach' })
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('FEEDBACK'),
|
||||
click() {
|
||||
const url = 'https://github.com/Kuingsmile/PicList/issues'
|
||||
shell.openExternal(url)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
] as (MenuItemConstructorOptions | MenuItem)[]
|
||||
return Menu.buildFromTemplate(template)
|
||||
}
|
||||
@@ -145,11 +145,11 @@ const buildSecondPicBedMenu = () => {
|
||||
const currentPicBedMenuItem = [
|
||||
{
|
||||
label: `${$t('CURRENT_SECOND_PICBED')} - ${currentPicBedName || 'None'}`,
|
||||
enabled: false
|
||||
enabled: false,
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
}
|
||||
type: 'separator',
|
||||
},
|
||||
]
|
||||
let submenu = picBeds
|
||||
.filter(item => item.visible)
|
||||
@@ -168,19 +168,19 @@ const buildSecondPicBedMenu = () => {
|
||||
// see: https://github.com/electron/electron/issues/21292
|
||||
type: 'checkbox',
|
||||
checked: config._id === defaultSecondUploaderId && item.type === secondUploader,
|
||||
click: function () {
|
||||
click() {
|
||||
changeSecondUploader(item.type, config, config._id)
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
: undefined,
|
||||
click: !hasSubmenu
|
||||
? function () {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.secondUploader]: item.type
|
||||
[configPaths.picBed.secondUploader]: item.type,
|
||||
})
|
||||
}
|
||||
: undefined
|
||||
: undefined,
|
||||
}
|
||||
})
|
||||
// @ts-expect-error submenu type
|
||||
@@ -197,11 +197,11 @@ const buildPicBedListMenu = () => {
|
||||
const currentPicBedMenuItem = [
|
||||
{
|
||||
label: `${$t('CURRENT_PICBED')} - ${currentPicBedName}`,
|
||||
enabled: false
|
||||
enabled: false,
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
}
|
||||
type: 'separator',
|
||||
},
|
||||
]
|
||||
let submenu = picBeds
|
||||
.filter(item => item.visible)
|
||||
@@ -221,13 +221,13 @@ const buildPicBedListMenu = () => {
|
||||
// see: https://github.com/electron/electron/issues/21292
|
||||
type: 'checkbox',
|
||||
checked: config._id === defaultId && item.type === currentPicBed,
|
||||
click: function () {
|
||||
click() {
|
||||
changeCurrentUploader(item.type, config, config._id)
|
||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('syncPicBed')
|
||||
}
|
||||
setTrayToolTip(`${item.type} ${config._configName || 'Default'}`)
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
: undefined,
|
||||
@@ -235,14 +235,14 @@ const buildPicBedListMenu = () => {
|
||||
? function () {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.current]: item.type,
|
||||
[configPaths.picBed.uploader]: item.type
|
||||
[configPaths.picBed.uploader]: item.type,
|
||||
})
|
||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('syncPicBed')
|
||||
}
|
||||
setTrayToolTip(item.type)
|
||||
}
|
||||
: undefined
|
||||
: undefined,
|
||||
}
|
||||
})
|
||||
// @ts-expect-error submenu type
|
||||
@@ -259,7 +259,7 @@ const handleRestoreState = (item: string, name: string): void => {
|
||||
if (current === name) {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.current]: 'smms',
|
||||
[configPaths.picBed.uploader]: 'smms'
|
||||
[configPaths.picBed.uploader]: 'smms',
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -267,7 +267,7 @@ const handleRestoreState = (item: string, name: string): void => {
|
||||
const current = picgo.getConfig(configPaths.picBed.transformer)
|
||||
if (current === name) {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.transformer]: 'path'
|
||||
[configPaths.picBed.transformer]: 'path',
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -280,18 +280,18 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
enabled: !plugin.enabled,
|
||||
click() {
|
||||
picgo.saveConfig({
|
||||
[`picgoPlugins.${plugin.fullName}`]: true
|
||||
[`picgoPlugins.${plugin.fullName}`]: true,
|
||||
})
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(PICGO_TOGGLE_PLUGIN, plugin.fullName, true)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('DISABLE_PLUGIN'),
|
||||
enabled: plugin.enabled,
|
||||
click() {
|
||||
picgo.saveConfig({
|
||||
[`picgoPlugins.${plugin.fullName}`]: false
|
||||
[`picgoPlugins.${plugin.fullName}`]: false,
|
||||
})
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
||||
@@ -303,7 +303,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
if (plugin.config.uploader.name) {
|
||||
handleRestoreState('uploader', plugin.config.uploader.name)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('UNINSTALL_PLUGIN'),
|
||||
@@ -311,7 +311,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
||||
handlePluginUninstall(plugin.fullName)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('UPDATE_PLUGIN'),
|
||||
@@ -319,14 +319,14 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
||||
handlePluginUpdate(plugin.fullName)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
] as (MenuItemConstructorOptions | MenuItem)[]
|
||||
for (const i in plugin.config) {
|
||||
if (plugin.config[i].config.length > 0) {
|
||||
const obj = {
|
||||
label: $t('CONFIG_THING', {
|
||||
c: `${i} - ${plugin.config[i].fullName || plugin.config[i].name}`
|
||||
c: `${i} - ${plugin.config[i].fullName || plugin.config[i].name}`,
|
||||
}),
|
||||
click() {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
@@ -334,7 +334,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
const configName = plugin.config[i].fullName || plugin.config[i].name
|
||||
const config = plugin.config[i].config
|
||||
window.webContents.send(PICGO_CONFIG_PLUGIN, currentType, configName, config)
|
||||
}
|
||||
},
|
||||
}
|
||||
menu.push(obj)
|
||||
}
|
||||
@@ -351,14 +351,14 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
const currentTransformer = picgo.getConfig<string>(configPaths.picBed.transformer) || 'path'
|
||||
if (currentTransformer === transformer) {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.transformer]: 'path'
|
||||
[configPaths.picBed.transformer]: 'path',
|
||||
})
|
||||
} else {
|
||||
picgo.saveConfig({
|
||||
[configPaths.picBed.transformer]: transformer
|
||||
[configPaths.picBed.transformer]: transformer,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
menu.push(obj)
|
||||
}
|
||||
@@ -366,7 +366,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
// plugin custom menus
|
||||
if (plugin.guiMenu) {
|
||||
menu.push({
|
||||
type: 'separator'
|
||||
type: 'separator',
|
||||
})
|
||||
for (const i of plugin.guiMenu) {
|
||||
menu.push({
|
||||
@@ -381,7 +381,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ const routes = [
|
||||
toolboxRouter.routes(),
|
||||
trayRouter.routes(),
|
||||
uploadRouter.routes(),
|
||||
manageRouter.routes()
|
||||
manageRouter.routes(),
|
||||
]
|
||||
|
||||
for (const route of routes) {
|
||||
|
||||
@@ -34,7 +34,7 @@ const galleryRoutes = [
|
||||
}
|
||||
return [txt, shortUrl]
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_REMOVE_FILES,
|
||||
@@ -42,7 +42,7 @@ const galleryRoutes = [
|
||||
setTimeout(() => {
|
||||
picgo.emit(ICOREBuildInEvent.REMOVE, args[0], GuiApi.getInstance())
|
||||
}, 500)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_GET_DB,
|
||||
@@ -50,7 +50,7 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.get(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_GET_BY_ID_DB,
|
||||
@@ -58,7 +58,7 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.getById(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_UPDATE_BY_ID_DB,
|
||||
@@ -66,7 +66,7 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.updateById(args[0], args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_REMOVE_BY_ID_DB,
|
||||
@@ -74,7 +74,7 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.removeById(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_INSERT_DB,
|
||||
@@ -82,7 +82,7 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.insert(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.GALLERY_INSERT_DB_BATCH,
|
||||
@@ -90,8 +90,8 @@ const galleryRoutes = [
|
||||
const dbStore = GalleryDB.getInstance()
|
||||
return await dbStore.insertMany(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
galleryRouter.addBatch(galleryRoutes)
|
||||
|
||||
@@ -9,93 +9,93 @@ export default [
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string]) => {
|
||||
return new ManageApi(args[0]).getBucketList()
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_BUCKET_LIST_BACKSTAGE,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).getBucketListBackstage(args[1])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_BUCKET_LIST_RECURSIVELY,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).getBucketListRecursively(args[1])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_CREATE_BUCKET,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).createBucket(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_BUCKET_FILE_LIST,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).getBucketFileList(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_BUCKET_DOMAIN,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).getBucketDomain(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_SET_BUCKET_ACL_POLICY,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).setBucketAclPolicy(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_RENAME_BUCKET_FILE,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).renameBucketFile(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_BUCKET_FILE,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).deleteBucketFile(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_BUCKET_FOLDER,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).deleteBucketFolder(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_PRE_SIGNED_URL,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).getPreSignedUrl(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_UPLOAD_BUCKET_FILE,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).uploadBucketFile(args[1])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DOWNLOAD_BUCKET_FILE,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).downloadBucketFile(args[1])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_CREATE_BUCKET_FOLDER,
|
||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||
return new ManageApi(args[0]).createBucketFolder(args[1])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -11,18 +11,18 @@ export default [
|
||||
handler: async (_: IIPCEvent, args: [key?: string]) => {
|
||||
return manageApi.getConfig(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_SAVE_CONFIG,
|
||||
handler: async (_: IIPCEvent, args: [data: IObj]) => {
|
||||
manageApi.saveConfig(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_REMOVE_CONFIG,
|
||||
handler: async (_: IIPCEvent, args: [key: string, propName: string]) => {
|
||||
manageApi.removeConfig(args[0], args[1])
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -13,66 +13,66 @@ export default [
|
||||
action: IRPCActionType.MANAGE_OPEN_FILE_SELECT_DIALOG,
|
||||
handler: async () => {
|
||||
const res = await dialog.showOpenDialog({
|
||||
properties: ['openFile', 'multiSelections']
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
})
|
||||
return res.canceled ? [] : res.filePaths
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_UPLOAD_TASK_LIST,
|
||||
handler: async () => {
|
||||
return UpDownTaskQueue.getInstance().getAllUploadTask()
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_DOWNLOAD_TASK_LIST,
|
||||
handler: async () => {
|
||||
return UpDownTaskQueue.getInstance().getAllDownloadTask()
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_UPLOADED_TASK,
|
||||
handler: async () => {
|
||||
UpDownTaskQueue.getInstance().removeUploadedTask()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_ALL_UPLOADED_TASK,
|
||||
handler: async () => {
|
||||
UpDownTaskQueue.getInstance().clearUploadTaskQueue()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_DOWNLOADED_TASK,
|
||||
handler: async () => {
|
||||
UpDownTaskQueue.getInstance().removeDownloadedTask()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DELETE_ALL_DOWNLOADED_TASK,
|
||||
handler: async () => {
|
||||
UpDownTaskQueue.getInstance().clearDownloadTaskQueue()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_SELECT_DOWNLOAD_FOLDER,
|
||||
handler: async () => {
|
||||
const res = await dialog.showOpenDialog({
|
||||
properties: ['openDirectory']
|
||||
properties: ['openDirectory'],
|
||||
})
|
||||
return res.filePaths[0]
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_GET_DEFAULT_DOWNLOAD_FOLDER,
|
||||
handler: async () => {
|
||||
return app.getPath('downloads')
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_OPEN_DOWNLOADED_FOLDER,
|
||||
@@ -83,27 +83,27 @@ export default [
|
||||
} else {
|
||||
shell.openPath(app.getPath('downloads'))
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_OPEN_LOCAL_FILE,
|
||||
handler: async (_: IIPCEvent, args: [fullPath: string]) => {
|
||||
const fullPath = args[0]
|
||||
fs.existsSync(fullPath) ? shell.showItemInFolder(fullPath) : shell.openPath(path.dirname(fullPath))
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_DOWNLOAD_FILE_FROM_URL,
|
||||
handler: async (_: IIPCEvent, args: [urls: string[]]) => {
|
||||
return await downloadFileFromUrl(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MANAGE_CONVERT_PATH_TO_BASE64,
|
||||
handler: async (_: IIPCEvent, args: [filePath: string]) => {
|
||||
return fs.readFileSync(args[0], 'base64')
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -10,6 +10,6 @@ export default [
|
||||
handler: async (_: IIPCEvent, args: [item: ImgInfo]) => {
|
||||
return await ALLApi.delete(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
getUploaderConfigList,
|
||||
resetUploaderConfig,
|
||||
selectUploaderConfig,
|
||||
updateUploaderConfig
|
||||
updateUploaderConfig,
|
||||
} from '~/utils/handleUploaderConfig'
|
||||
|
||||
const picbedRouter = new RPCRouter()
|
||||
@@ -34,7 +34,7 @@ const picbedRoutes = [
|
||||
const config = getUploaderConfigList(args[0])
|
||||
return config
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICBED_DELETE_CONFIG,
|
||||
@@ -43,7 +43,7 @@ const picbedRoutes = [
|
||||
const config = deleteUploaderConfig(type, id)
|
||||
return config
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPLOADER_SELECT,
|
||||
@@ -52,7 +52,7 @@ const picbedRoutes = [
|
||||
selectUploaderConfig(type, id)
|
||||
return true
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPLOADER_UPDATE_CONFIG,
|
||||
@@ -61,7 +61,7 @@ const picbedRoutes = [
|
||||
updateUploaderConfig(type, id, config)
|
||||
return true
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPLOADER_RESET_CONFIG,
|
||||
@@ -70,7 +70,7 @@ const picbedRoutes = [
|
||||
resetUploaderConfig(type, id)
|
||||
return true
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICBED_GET_PICBED_CONFIG,
|
||||
@@ -82,17 +82,17 @@ const picbedRoutes = [
|
||||
const config = handleConfigWithFunction(_config)
|
||||
return {
|
||||
config,
|
||||
name
|
||||
name,
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
config: [],
|
||||
name
|
||||
name,
|
||||
}
|
||||
}
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
const picBedsRoutes = [...picbedRoutes, ...deleteRoutes]
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
pluginGetListFunc,
|
||||
pluginImportLocalFunc,
|
||||
pluginInstallFunc,
|
||||
pluginUpdateAllFunc
|
||||
pluginUpdateAllFunc,
|
||||
} from '~/events/rpc/routes/plugin/utils'
|
||||
import { IRPCActionType } from '~/utils/enum'
|
||||
|
||||
@@ -12,20 +12,20 @@ const pluginRouter = new RPCRouter()
|
||||
const pluginRoutes = [
|
||||
{
|
||||
action: IRPCActionType.PLUGIN_GET_LIST,
|
||||
handler: pluginGetListFunc
|
||||
handler: pluginGetListFunc,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PLUGIN_INSTALL,
|
||||
handler: pluginInstallFunc
|
||||
handler: pluginInstallFunc,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PLUGIN_IMPORT_LOCAL,
|
||||
handler: pluginImportLocalFunc
|
||||
handler: pluginImportLocalFunc,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PLUGIN_UPDATE_ALL,
|
||||
handler: pluginUpdateAllFunc
|
||||
}
|
||||
handler: pluginUpdateAllFunc,
|
||||
},
|
||||
]
|
||||
|
||||
pluginRouter.addBatch(pluginRoutes)
|
||||
|
||||
@@ -60,7 +60,7 @@ const getPluginList = async (): Promise<IPicGoPlugin[]> => {
|
||||
let menu: Omit<IGuiMenuItem, 'handle'>[] = []
|
||||
if (plugin.guiMenu) {
|
||||
menu = plugin.guiMenu(picgo).map(item => ({
|
||||
label: item.label
|
||||
label: item.label,
|
||||
}))
|
||||
}
|
||||
let gui = false
|
||||
@@ -81,25 +81,25 @@ const getPluginList = async (): Promise<IPicGoPlugin[]> => {
|
||||
plugin: {
|
||||
fullName: pluginList[i],
|
||||
name: handleStreamlinePluginName(pluginList[i]),
|
||||
config: plugin.config ? handleConfigWithFunction(plugin.config(picgo)) : []
|
||||
config: plugin.config ? handleConfigWithFunction(plugin.config(picgo)) : [],
|
||||
},
|
||||
uploader: {
|
||||
name: uploaderName,
|
||||
config: handleConfigWithFunction(
|
||||
getConfig(uploaderName, IPicGoHelperType.uploader as keyof typeof IPicGoHelperType, picgo)
|
||||
)
|
||||
getConfig(uploaderName, IPicGoHelperType.uploader as keyof typeof IPicGoHelperType, picgo),
|
||||
),
|
||||
},
|
||||
transformer: {
|
||||
name: transformerName,
|
||||
config: handleConfigWithFunction(
|
||||
getConfig(uploaderName, IPicGoHelperType.transformer as keyof typeof IPicGoHelperType, picgo)
|
||||
)
|
||||
}
|
||||
getConfig(uploaderName, IPicGoHelperType.transformer as keyof typeof IPicGoHelperType, picgo),
|
||||
),
|
||||
},
|
||||
},
|
||||
enabled: picgo.getConfig(`picgoPlugins.${pluginList[i]}`),
|
||||
homepage: pluginPKG.homepage ? pluginPKG.homepage : '',
|
||||
guiMenu: menu,
|
||||
ing: false
|
||||
ing: false,
|
||||
}
|
||||
list.push(obj)
|
||||
}
|
||||
@@ -113,7 +113,7 @@ const handleNPMError = (): IDispose => {
|
||||
.showMessageBox({
|
||||
title: $t('TIPS_ERROR'),
|
||||
message: $t('TIPS_INSTALL_NODE_AND_RELOAD_PICGO'),
|
||||
buttons: ['Yes']
|
||||
buttons: ['Yes'],
|
||||
})
|
||||
.then(res => {
|
||||
if (res.response === 0) {
|
||||
@@ -135,7 +135,7 @@ export const handlePluginUpdate = async (fullName: string | string[]) => {
|
||||
} else {
|
||||
showNotification({
|
||||
title: $t('PLUGIN_UPDATE_FAILED'),
|
||||
body: res.body as string
|
||||
body: res.body as string,
|
||||
})
|
||||
}
|
||||
window.webContents.send('hideLoading')
|
||||
@@ -152,7 +152,7 @@ export const handlePluginUninstall = async (fullName: string) => {
|
||||
} else {
|
||||
showNotification({
|
||||
title: $t('PLUGIN_UNINSTALL_FAILED'),
|
||||
body: res.body as string
|
||||
body: res.body as string,
|
||||
})
|
||||
}
|
||||
window.webContents.send('hideLoading')
|
||||
@@ -169,7 +169,7 @@ export const pluginGetListFunc = async (event: IIPCEvent) => {
|
||||
event.sender.send('pluginList', [])
|
||||
showNotification({
|
||||
title: $t('TIPS_GET_PLUGIN_LIST_FAILED'),
|
||||
body: e.message
|
||||
body: e.message,
|
||||
})
|
||||
picgo.log.error(e)
|
||||
}
|
||||
@@ -182,14 +182,14 @@ export const pluginInstallFunc = async (event: IIPCEvent, args: [fullName: strin
|
||||
event.sender.send('installPlugin', {
|
||||
success: res.success,
|
||||
body: fullName,
|
||||
errMsg: res.success ? '' : res.body
|
||||
errMsg: res.success ? '' : res.body,
|
||||
})
|
||||
if (res.success) {
|
||||
await shortKeyHandler.registerPluginShortKey(res.body[0])
|
||||
} else {
|
||||
showNotification({
|
||||
title: $t('PLUGIN_INSTALL_FAILED'),
|
||||
body: res.body as string
|
||||
body: res.body as string,
|
||||
})
|
||||
}
|
||||
event.sender.send('hideLoading')
|
||||
@@ -199,7 +199,7 @@ export const pluginInstallFunc = async (event: IIPCEvent, args: [fullName: strin
|
||||
export const pluginImportLocalFunc = async (event: IIPCEvent) => {
|
||||
const settingWindow = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const res = await dialog.showOpenDialog(settingWindow, {
|
||||
properties: ['openDirectory']
|
||||
properties: ['openDirectory'],
|
||||
})
|
||||
const filePaths = res.filePaths
|
||||
if (filePaths.length > 0) {
|
||||
@@ -212,17 +212,17 @@ export const pluginImportLocalFunc = async (event: IIPCEvent) => {
|
||||
event.sender.send('pluginList', [])
|
||||
showNotification({
|
||||
title: $t('TIPS_GET_PLUGIN_LIST_FAILED'),
|
||||
body: e.message
|
||||
body: e.message,
|
||||
})
|
||||
}
|
||||
showNotification({
|
||||
title: $t('PLUGIN_IMPORT_SUCCEED'),
|
||||
body: ''
|
||||
body: '',
|
||||
})
|
||||
} else {
|
||||
showNotification({
|
||||
title: $t('PLUGIN_IMPORT_FAILED'),
|
||||
body: res.body as string
|
||||
body: res.body as string,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,18 +7,18 @@ export default [
|
||||
action: IRPCActionType.ADVANCED_UPDATE_SERVER,
|
||||
handler: async () => {
|
||||
server.restart()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.ADVANCED_STOP_WEB_SERVER,
|
||||
handler: async () => {
|
||||
webServer.stop()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.ADVANCED_RESTART_WEB_SERVER,
|
||||
handler: async () => {
|
||||
webServer.restart()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -24,7 +24,7 @@ export default [
|
||||
const sourcePath = path.join(picGoConfigPath, file)
|
||||
const targetPath = path.join(STORE_PATH, file.replace('picgo', 'piclist'))
|
||||
await fs.copy(sourcePath, targetPath, { overwrite: true })
|
||||
})
|
||||
}),
|
||||
)
|
||||
return true
|
||||
} catch (err: any) {
|
||||
@@ -32,48 +32,48 @@ export default [
|
||||
throw new Error('Migrate failed')
|
||||
}
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_UPLOAD_COMMON_CONFIG,
|
||||
handler: async () => {
|
||||
return await uploadFile(commonConfigList)
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_UPLOAD_MANAGE_CONFIG,
|
||||
handler: async () => {
|
||||
return await uploadFile(manageConfigList)
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_UPLOAD_ALL_CONFIG,
|
||||
handler: async () => {
|
||||
return await uploadFile([...commonConfigList, ...manageConfigList])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_DOWNLOAD_COMMON_CONFIG,
|
||||
handler: async () => {
|
||||
return await downloadFile(commonConfigList)
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_DOWNLOAD_MANAGE_CONFIG,
|
||||
handler: async () => {
|
||||
return await downloadFile(manageConfigList)
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CONFIGURE_DOWNLOAD_ALL_CONFIG,
|
||||
handler: async () => {
|
||||
return await downloadFile([...commonConfigList, ...manageConfigList])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -18,7 +18,7 @@ export default [
|
||||
handler: async (_: IIPCEvent, args: [key?: string]) => {
|
||||
return picgo.getConfig(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_GET_CONFIG_SYNC,
|
||||
@@ -26,13 +26,13 @@ export default [
|
||||
const result = picgo.getConfig(args[0])
|
||||
const eventInstance = event as IpcMainEvent
|
||||
eventInstance.returnValue = result
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_SAVE_CONFIG,
|
||||
handler: async (_: IIPCEvent, args: [data: IObj]) => {
|
||||
picgo.saveConfig(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_OPEN_FILE,
|
||||
@@ -42,12 +42,13 @@ export default [
|
||||
fs.writeFileSync(abFilePath, '')
|
||||
}
|
||||
shell.openPath(abFilePath)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_OPEN_DIRECTORY,
|
||||
handler: async (_: IIPCEvent, args: [dirPath?: string, inStorePath?: boolean]) => {
|
||||
let [dirPath, inStorePath = true] = args
|
||||
let [dirPath] = args
|
||||
const [inStorePath = true] = args
|
||||
if (inStorePath) {
|
||||
dirPath = path.join(STORE_PATH, dirPath || '')
|
||||
}
|
||||
@@ -55,19 +56,19 @@ export default [
|
||||
return
|
||||
}
|
||||
shell.openPath(dirPath)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_AUTO_START,
|
||||
handler: async (_: IIPCEvent, args: [val: boolean]) => {
|
||||
await setAutoStart(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_AUTO_START_STATUS,
|
||||
handler: async (_: IIPCEvent) => {
|
||||
return await isAutoStartEnabled()
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
}
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -11,7 +11,7 @@ import { IRPCActionType, IRPCType } from '~/utils/enum'
|
||||
const notificationFunc = (result: boolean) => {
|
||||
const notification = new Notification({
|
||||
title: $t(`OPERATION_${result ? 'SUCCEED' : 'FAILED'}`),
|
||||
body: $t(`TIPS_SHORTCUT_MODIFIED_${result ? 'SUCCEED' : 'CONFLICT'}`)
|
||||
body: $t(`TIPS_SHORTCUT_MODIFIED_${result ? 'SUCCEED' : 'CONFLICT'}`),
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
@@ -25,7 +25,7 @@ export default [
|
||||
notificationFunc(result)
|
||||
return result
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHORTKEY_BIND_OR_UNBIND,
|
||||
@@ -33,13 +33,13 @@ export default [
|
||||
const [item, from] = args
|
||||
const result = shortKeyHandler.bindOrUnbindShortKey(item, from)
|
||||
notificationFunc(result)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHORTKEY_TOGGLE_SHORTKEY_MODIFIED_MODE,
|
||||
handler: async (_: IIPCEvent, args: [status: boolean]) => {
|
||||
const [status] = args
|
||||
bus.emit(TOGGLE_SHORTKEY_MODIFIED_MODE, status)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -11,19 +11,19 @@ export default [
|
||||
handler: async () => {
|
||||
app.relaunch()
|
||||
app.exit(0)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.OPEN_FILE,
|
||||
handler: async (_: IIPCEvent, args: [filePath: string]) => {
|
||||
shell.openPath(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.OPEN_URL,
|
||||
handler: async (_: IIPCEvent, args: [url: string]) => {
|
||||
shell.openExternal(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SET_CURRENT_LANGUAGE,
|
||||
@@ -31,6 +31,6 @@ export default [
|
||||
i18nManager.setCurrentLanguage(args[0])
|
||||
const { lang } = i18nManager.getCurrentLocales()
|
||||
picgo.i18n.setLanguage(lang)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
buildMiniPageMenu,
|
||||
buildPicBedListMenu,
|
||||
buildPluginPageMenu,
|
||||
buildSecondPicBedMenu
|
||||
buildSecondPicBedMenu,
|
||||
} from '~/events/remotes/menu'
|
||||
import { IRPCActionType, IWindowList } from '~/utils/enum'
|
||||
import { openMiniWindow } from '~/utils/windowHelper'
|
||||
@@ -18,7 +18,7 @@ export default [
|
||||
action: IRPCActionType.HIDE_DOCK,
|
||||
handler: async (_: IIPCEvent, args: [value: boolean]) => {
|
||||
args[0] ? app.dock?.hide() : app.dock?.show()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.OPEN_WINDOW,
|
||||
@@ -27,13 +27,13 @@ export default [
|
||||
if (window) {
|
||||
window.show()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.OPEN_MINI_WINDOW,
|
||||
handler: async () => {
|
||||
openMiniWindow()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.CLOSE_WINDOW,
|
||||
@@ -44,14 +44,14 @@ export default [
|
||||
} else {
|
||||
window?.close()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MINIMIZE_WINDOW,
|
||||
handler: async () => {
|
||||
const window = BrowserWindow.getFocusedWindow()
|
||||
window?.minimize()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHOW_MINI_PAGE_MENU,
|
||||
@@ -59,9 +59,9 @@ export default [
|
||||
const window = windowManager.get(IWindowList.MINI_WINDOW)!
|
||||
const menu = buildMiniPageMenu()
|
||||
menu.popup({
|
||||
window
|
||||
window,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHOW_MAIN_PAGE_MENU,
|
||||
@@ -69,9 +69,9 @@ export default [
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const menu = buildMainPageMenu(window)
|
||||
menu.popup({
|
||||
window
|
||||
window,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHOW_UPLOAD_PAGE_MENU,
|
||||
@@ -79,9 +79,9 @@ export default [
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const menu = buildPicBedListMenu()
|
||||
menu.popup({
|
||||
window
|
||||
window,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHOW_SECOND_UPLOADER_MENU,
|
||||
@@ -89,9 +89,9 @@ export default [
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const menu = buildSecondPicBedMenu()
|
||||
menu.popup({
|
||||
window
|
||||
window,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SHOW_PLUGIN_PAGE_MENU,
|
||||
@@ -99,23 +99,23 @@ export default [
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const menu = buildPluginPageMenu(args[0])
|
||||
menu.popup({
|
||||
window
|
||||
window,
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.SET_MINI_WINDOW_POS,
|
||||
handler: async (_: IIPCEvent, args: [pos: IMiniWindowPos]) => {
|
||||
const window = BrowserWindow.getFocusedWindow()
|
||||
window?.setBounds(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MINI_WINDOW_ON_TOP,
|
||||
handler: async (_: IIPCEvent, args: [isOnTop: boolean]) => {
|
||||
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
|
||||
miniWindow.setAlwaysOnTop(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.MAIN_WINDOW_ON_TOP,
|
||||
@@ -123,14 +123,14 @@ export default [
|
||||
const mainWindow = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const isAlwaysOnTop = mainWindow.isAlwaysOnTop()
|
||||
mainWindow.setAlwaysOnTop(!isAlwaysOnTop)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPDATE_MINI_WINDOW_ICON,
|
||||
handler: async (_: IIPCEvent, args: [iconPath: string]) => {
|
||||
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
|
||||
miniWindow.webContents.send('updateMiniIcon', args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.REFRESH_SETTING_WINDOW,
|
||||
@@ -139,6 +139,6 @@ export default [
|
||||
settingWindow.webContents.session.clearCache().then(() => {
|
||||
settingWindow.webContents.reloadIgnoringCache()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -16,7 +16,7 @@ const defaultClipboardImagePath = path.join(defaultConfigPath, CLIPBOARD_IMAGE_F
|
||||
export const checkClipboardUploadMap: IToolboxCheckerMap<string> = {
|
||||
[IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD]: async event => {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.LOADING
|
||||
status: IToolboxItemCheckStatus.LOADING,
|
||||
})
|
||||
const configFilePath = dbPathChecker()
|
||||
if (fs.existsSync(configFilePath)) {
|
||||
@@ -26,29 +26,29 @@ export const checkClipboardUploadMap: IToolboxCheckerMap<string> = {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_TIPS', {
|
||||
path: clipboardImagePath
|
||||
path: clipboardImagePath,
|
||||
}),
|
||||
value: clipboardImagePath
|
||||
value: clipboardImagePath,
|
||||
})
|
||||
} else {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS', {
|
||||
path: clipboardImagePath
|
||||
path: clipboardImagePath,
|
||||
}),
|
||||
value: path.dirname(clipboardImagePath)
|
||||
value: path.dirname(clipboardImagePath),
|
||||
})
|
||||
}
|
||||
} else {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS', {
|
||||
path: defaultClipboardImagePath
|
||||
path: defaultClipboardImagePath,
|
||||
}),
|
||||
value: path.dirname(defaultClipboardImagePath)
|
||||
value: path.dirname(defaultClipboardImagePath),
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export const fixClipboardUploadMap: IToolboxFixMap<string> = {
|
||||
@@ -60,17 +60,17 @@ export const fixClipboardUploadMap: IToolboxFixMap<string> = {
|
||||
fs.mkdirsSync(clipboardImagePath)
|
||||
return {
|
||||
type: IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD,
|
||||
status: IToolboxItemCheckStatus.SUCCESS
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
return {
|
||||
type: IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD,
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS', {
|
||||
path: clipboardImagePath
|
||||
path: clipboardImagePath,
|
||||
}),
|
||||
value: path.dirname(clipboardImagePath)
|
||||
value: path.dirname(clipboardImagePath),
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export const checkFileMap: IToolboxCheckerMap<string> = {
|
||||
[IToolboxItemType.IS_CONFIG_FILE_BROKEN]: async (event: IpcMainEvent) => {
|
||||
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.IS_CONFIG_FILE_BROKEN)
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.LOADING
|
||||
status: IToolboxItemCheckStatus.LOADING,
|
||||
})
|
||||
const configFilePath = dbPathChecker()
|
||||
try {
|
||||
@@ -23,64 +23,64 @@ export const checkFileMap: IToolboxCheckerMap<string> = {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_CONFIG_FILE_PATH_TIPS', {
|
||||
path: configFilePath
|
||||
path: configFilePath,
|
||||
}),
|
||||
value: configFilePath
|
||||
value: configFilePath,
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_CONFIG_FILE_BROKEN_TIPS'),
|
||||
value: path.dirname(configFilePath)
|
||||
value: path.dirname(configFilePath),
|
||||
})
|
||||
}
|
||||
},
|
||||
[IToolboxItemType.IS_GALLERY_FILE_BROKEN]: async event => {
|
||||
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.IS_GALLERY_FILE_BROKEN)
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.LOADING
|
||||
status: IToolboxItemCheckStatus.LOADING,
|
||||
})
|
||||
const galleryDB = GalleryDB.getInstance()
|
||||
if (galleryDB.errorList.length === 0) {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_GALLERY_FILE_PATH_TIPS', {
|
||||
path: DB_PATH
|
||||
path: DB_PATH,
|
||||
}),
|
||||
value: path.dirname(DB_PATH)
|
||||
value: path.dirname(DB_PATH),
|
||||
})
|
||||
} else {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_GALLERY_FILE_BROKEN_TIPS'),
|
||||
value: path.dirname(DB_PATH)
|
||||
value: path.dirname(DB_PATH),
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export const fixFileMap: IToolboxFixMap<string> = {
|
||||
[IToolboxItemType.IS_CONFIG_FILE_BROKEN]: async () => {
|
||||
try {
|
||||
fs.unlinkSync(dbPathChecker())
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// do nothing
|
||||
}
|
||||
return {
|
||||
type: IToolboxItemType.IS_CONFIG_FILE_BROKEN,
|
||||
status: IToolboxItemCheckStatus.SUCCESS
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
}
|
||||
},
|
||||
[IToolboxItemType.IS_GALLERY_FILE_BROKEN]: async () => {
|
||||
try {
|
||||
fs.unlinkSync(DB_PATH)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
// do nothing
|
||||
}
|
||||
return {
|
||||
type: IToolboxItemType.IS_GALLERY_FILE_BROKEN,
|
||||
status: IToolboxItemCheckStatus.SUCCESS
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ function getProxy(proxyStr: string): AxiosRequestConfig['proxy'] | null {
|
||||
return {
|
||||
host: proxyOptions.hostname,
|
||||
port: parseInt(proxyOptions.port || '0', 10),
|
||||
protocol: proxyOptions.protocol
|
||||
protocol: proxyOptions.protocol,
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch (_e) {}
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -28,18 +28,18 @@ const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.HAS_PROBLEM_WITH_
|
||||
export const checkProxyMap: IToolboxCheckerMap<string> = {
|
||||
[IToolboxItemType.HAS_PROBLEM_WITH_PROXY]: async event => {
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.LOADING
|
||||
status: IToolboxItemCheckStatus.LOADING,
|
||||
})
|
||||
const configFilePath = dbPathChecker()
|
||||
if (fs.existsSync(configFilePath)) {
|
||||
let config: IConfig | undefined
|
||||
try {
|
||||
config = (await fs.readJSON(configFilePath)) as IConfig
|
||||
} catch (e) {}
|
||||
} catch (_e) {}
|
||||
if (!config) {
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS'),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -47,34 +47,34 @@ export const checkProxyMap: IToolboxCheckerMap<string> = {
|
||||
if (!proxy) {
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS'),
|
||||
})
|
||||
} else {
|
||||
const proxyOptions = getProxy(proxy)
|
||||
if (!proxyOptions) {
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_CORRECT')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_CORRECT'),
|
||||
})
|
||||
} else {
|
||||
const httpsAgent = tunnel.httpsOverHttp({
|
||||
proxy: {
|
||||
host: proxyOptions.host,
|
||||
port: proxyOptions.port
|
||||
}
|
||||
port: proxyOptions.port,
|
||||
},
|
||||
})
|
||||
try {
|
||||
await axios.get('https://www.google.com', {
|
||||
httpsAgent
|
||||
httpsAgent,
|
||||
})
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_SUCCESS_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_SUCCESS_TIPS'),
|
||||
})
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
return sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.ERROR,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_WORKING')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_WORKING'),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ export const checkProxyMap: IToolboxCheckerMap<string> = {
|
||||
|
||||
sendToolboxRes(event, {
|
||||
status: IToolboxItemCheckStatus.SUCCESS,
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS'),
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ const toolboxRouter = new RPCRouter()
|
||||
const toolboxCheckMap: Partial<IToolboxCheckerMap<string>> = {
|
||||
...checkFileMap,
|
||||
...checkClipboardUploadMap,
|
||||
...checkProxyMap
|
||||
...checkProxyMap,
|
||||
}
|
||||
|
||||
const toolboxFixMap: Partial<IToolboxFixMap<string>> = {
|
||||
...fixFileMap,
|
||||
...fixClipboardUploadMap
|
||||
...fixClipboardUploadMap,
|
||||
}
|
||||
|
||||
toolboxRouter
|
||||
@@ -40,7 +40,7 @@ toolboxRouter
|
||||
}
|
||||
}
|
||||
},
|
||||
IRPCType.SEND
|
||||
IRPCType.SEND,
|
||||
)
|
||||
.add(
|
||||
IRPCActionType.TOOLBOX_CHECK_FIX,
|
||||
@@ -51,7 +51,7 @@ toolboxRouter
|
||||
return await handler(event as IpcMainEvent)
|
||||
}
|
||||
},
|
||||
IRPCType.INVOKE
|
||||
IRPCType.INVOKE,
|
||||
)
|
||||
|
||||
export { toolboxRouter }
|
||||
|
||||
@@ -7,7 +7,7 @@ export function sendToolboxResWithType(type: string) {
|
||||
return (event: IpcMainEvent, res?: Omit<IToolboxCheckRes, 'type'>) => {
|
||||
return event.sender.send(IRPCActionType.TOOLBOX_CHECK_RES, {
|
||||
...res,
|
||||
type
|
||||
type,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ const trayRoutes = [
|
||||
action: IRPCActionType.TRAY_SET_TOOL_TIP,
|
||||
handler: async (_: IIPCEvent, args: [text: string]) => {
|
||||
setTrayToolTip(args[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.TRAY_GET_SHORT_URL,
|
||||
handler: async (_: IIPCEvent, args: [url: string]) => {
|
||||
return await generateShortUrl(args[0])
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.TRAY_UPLOAD_CLIPBOARD_FILES,
|
||||
@@ -45,7 +45,7 @@ const trayRoutes = [
|
||||
if (isShowResultNotification) {
|
||||
const notification = new Notification({
|
||||
title: $t('UPLOAD_SUCCEED'),
|
||||
body: shortUrl || img[0].imgUrl!
|
||||
body: shortUrl || img[0].imgUrl!,
|
||||
// icon: file[0]
|
||||
// icon: img[0].imgUrl
|
||||
})
|
||||
@@ -58,8 +58,8 @@ const trayRoutes = [
|
||||
}
|
||||
}
|
||||
trayWindow.webContents.send('uploadFiles')
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
trayRouter.addBatch(trayRoutes)
|
||||
|
||||
@@ -14,20 +14,20 @@ const uploadRoutes = [
|
||||
handler: async () => {
|
||||
return getPicBeds()
|
||||
},
|
||||
type: IRPCType.INVOKE
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPLOAD_CLIPBOARD_FILES_FROM_UPLOAD_PAGE,
|
||||
handler: async () => {
|
||||
uploadClipboardFiles()
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.UPLOAD_CHOOSED_FILES,
|
||||
handler: async (evt: IIPCEvent, args: [files: IFileWithPath[]]) => {
|
||||
return uploadChoosedFiles(evt.sender, args[0])
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
uploadRouter.addBatch(uploadRoutes)
|
||||
|
||||
@@ -13,22 +13,22 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const builtinI18nList: II18nItem[] = [
|
||||
{
|
||||
label: '简体中文',
|
||||
value: 'zh-CN'
|
||||
value: 'zh-CN',
|
||||
},
|
||||
{
|
||||
label: '繁體中文',
|
||||
value: 'zh-TW'
|
||||
value: 'zh-TW',
|
||||
},
|
||||
{
|
||||
label: 'English',
|
||||
value: 'en'
|
||||
}
|
||||
value: 'en',
|
||||
},
|
||||
]
|
||||
class I18nManager {
|
||||
private i18n: I18n | null = null
|
||||
private builtinI18nFolder = path.join(__dirname, '../../resources', 'i18n').replace('app.asar', 'app.asar.unpacked')
|
||||
private outterI18nFolder = ''
|
||||
private localesMap: Map<string, ILocales> = new Map()
|
||||
private localesMap = new Map<string, ILocales>()
|
||||
private currentLanguage: string = 'zh-CN'
|
||||
readonly defaultLanguage: string = 'zh-CN'
|
||||
private i18nFileList: II18nItem[] = builtinI18nList
|
||||
@@ -40,7 +40,7 @@ class I18nManager {
|
||||
addI18nFile(file: string, label: string) {
|
||||
this.i18nFileList.push({
|
||||
label,
|
||||
value: file
|
||||
value: file,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,11 +79,11 @@ class I18nManager {
|
||||
|
||||
private initI18n(lang: string = this.defaultLanguage, locales: ILocales) {
|
||||
const objectAdapter = new ObjectAdapter({
|
||||
[lang]: locales
|
||||
[lang]: locales,
|
||||
})
|
||||
this.i18n = new I18n({
|
||||
adapter: objectAdapter,
|
||||
defaultLanguage: lang
|
||||
defaultLanguage: lang,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ class I18nManager {
|
||||
getCurrentLocales() {
|
||||
return {
|
||||
lang: this.currentLanguage,
|
||||
locales: this.getLocales(this.currentLanguage)
|
||||
locales: this.getLocales(this.currentLanguage),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ function bootstrapEPIPESuppression() {
|
||||
bootstrapEPIPESuppression()
|
||||
|
||||
function epipeBomb(stream: any, callback: any) {
|
||||
if (stream == null) stream = process.stdout
|
||||
if (callback == null) callback = process.exit
|
||||
if (stream === null) stream = process.stdout
|
||||
if (callback === null) callback = process.exit
|
||||
|
||||
function epipeFilter(err: any) {
|
||||
if (err.code === 'EPIPE') return callback()
|
||||
|
||||
@@ -62,7 +62,7 @@ const handleStartUpFiles = (argv: string[], cwd: string) => {
|
||||
updater.autoUpdater.setFeedURL({
|
||||
provider: 'generic',
|
||||
url: 'https://release.piclist.cn/latest',
|
||||
channel: 'latest'
|
||||
channel: 'latest',
|
||||
})
|
||||
|
||||
updater.autoUpdater.autoDownload = false
|
||||
@@ -101,13 +101,13 @@ updater.autoUpdater.on('update-available', async (info: updater.UpdateInfo) => {
|
||||
buttons: ['Yes', 'Go to download page'],
|
||||
message:
|
||||
$t('TIPS_FIND_NEW_VERSION', {
|
||||
v: info.version
|
||||
v: info.version,
|
||||
}) +
|
||||
'\n\n' +
|
||||
displayLog +
|
||||
truncatedNote,
|
||||
checkboxLabel: $t('NO_MORE_NOTICE'),
|
||||
checkboxChecked: false
|
||||
checkboxChecked: false,
|
||||
})
|
||||
.then(result => {
|
||||
if (result.response === 0) {
|
||||
@@ -124,7 +124,7 @@ updater.autoUpdater.on('update-available', async (info: updater.UpdateInfo) => {
|
||||
|
||||
updater.autoUpdater.on('download-progress', progressObj => {
|
||||
const percent = {
|
||||
progress: progressObj.percent
|
||||
progress: progressObj.percent,
|
||||
}
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send('updateProgress', percent)
|
||||
@@ -136,7 +136,7 @@ updater.autoUpdater.on('update-downloaded', () => {
|
||||
type: 'info',
|
||||
title: $t('UPDATE_DOWNLOADED'),
|
||||
buttons: ['Yes', 'No'],
|
||||
message: $t('TIPS_UPDATE_DOWNLOADED')
|
||||
message: $t('TIPS_UPDATE_DOWNLOADED'),
|
||||
})
|
||||
.then(result => {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
@@ -243,7 +243,7 @@ class LifeCycle {
|
||||
miniWindow.setPosition(width - miniWindow.getSize()[0], height - miniWindow.getSize()[1])
|
||||
db.set(configPaths.settings.miniWindowPosition, [
|
||||
width - miniWindow.getSize()[0],
|
||||
height - miniWindow.getSize()[1]
|
||||
height - miniWindow.getSize()[1],
|
||||
])
|
||||
} else {
|
||||
miniWindow.setPosition(lastPosition[0], lastPosition[1])
|
||||
@@ -297,7 +297,7 @@ class LifeCycle {
|
||||
.then(actualAutoStartEnabled => {
|
||||
if (actualAutoStartEnabled !== storedAutoStartEnabled) {
|
||||
logger.warn(
|
||||
`Auto-start state mismatch detected. Stored: ${storedAutoStartEnabled}, Actual: ${actualAutoStartEnabled}. Syncing...`
|
||||
`Auto-start state mismatch detected. Stored: ${storedAutoStartEnabled}, Actual: ${actualAutoStartEnabled}. Syncing...`,
|
||||
)
|
||||
setAutoStart(storedAutoStartEnabled).catch(err => {
|
||||
logger.error('Failed to sync auto-start:', err)
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
formatError,
|
||||
getFileMimeType,
|
||||
hmacSha1Base64,
|
||||
NewDownloader
|
||||
NewDownloader,
|
||||
} from '~/manage/utils/common'
|
||||
import { ManageLogger } from '~/manage/utils/logger'
|
||||
import { isImage } from '~/utils/common'
|
||||
@@ -32,7 +32,7 @@ class AliyunApi {
|
||||
this.ctx = new OSS({
|
||||
accessKeyId,
|
||||
accessKeySecret,
|
||||
secure: true
|
||||
secure: true,
|
||||
})
|
||||
this.accessKeyId = accessKeyId
|
||||
this.accessKeySecret = accessKeySecret
|
||||
@@ -50,7 +50,7 @@ class AliyunApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
Key: item
|
||||
Key: item,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class AliyunApi {
|
||||
match: false,
|
||||
isImage: isImage(fileName),
|
||||
rawUrl: item.url,
|
||||
url: `${urlPrefix}/${item.name}`
|
||||
url: `${urlPrefix}/${item.name}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class AliyunApi {
|
||||
canonicalizedResource: string,
|
||||
headers: IStringKeyMap,
|
||||
contentMd5: string,
|
||||
contentType: string
|
||||
contentType: string,
|
||||
) {
|
||||
const date = new Date().toUTCString()
|
||||
const stringToSign = `${method.toUpperCase()}\n${contentMd5}\n${contentType}\n${date}\n${this.getCanonicalizedOSSHeaders(headers)}${canonicalizedResource}`
|
||||
@@ -102,7 +102,7 @@ class AliyunApi {
|
||||
accessKeySecret: this.accessKeySecret,
|
||||
region,
|
||||
bucket,
|
||||
secure: true
|
||||
secure: true,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -113,18 +113,18 @@ class AliyunApi {
|
||||
const getBuckets = async (marker?: string) => {
|
||||
const res = (await this.ctx.listBuckets({
|
||||
marker,
|
||||
'max-keys': 1000
|
||||
'max-keys': 1000,
|
||||
})) as IStringKeyMap
|
||||
if (res?.res?.statusCode !== 200 || !res?.buckets) return { result: [], isTruncated: false }
|
||||
const formattedBuckets = res.buckets.map((item: OSS.Bucket) => ({
|
||||
Name: item.name,
|
||||
Location: item.region,
|
||||
CreationDate: item.creationDate
|
||||
CreationDate: item.creationDate,
|
||||
}))
|
||||
return {
|
||||
result: formattedBuckets,
|
||||
isTruncated: res.isTruncated,
|
||||
nextMarker: res.nextMarker
|
||||
nextMarker: res.nextMarker,
|
||||
}
|
||||
}
|
||||
const result: IStringKeyMap[] = []
|
||||
@@ -145,7 +145,7 @@ class AliyunApi {
|
||||
*/
|
||||
async getBucketDomain(param: IStringKeyMap): Promise<any> {
|
||||
const headers = {
|
||||
Date: new Date().toUTCString()
|
||||
Date: new Date().toUTCString(),
|
||||
}
|
||||
const authorization = this.authorization('GET', `/${param.bucketName}/?cname`, headers, '', '')
|
||||
|
||||
@@ -154,8 +154,8 @@ class AliyunApi {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
...headers,
|
||||
Authorization: authorization
|
||||
}
|
||||
Authorization: authorization,
|
||||
},
|
||||
})
|
||||
|
||||
if (res?.status === 200) {
|
||||
@@ -191,18 +191,18 @@ class AliyunApi {
|
||||
accessKeyId: this.accessKeyId,
|
||||
accessKeySecret: this.accessKeySecret,
|
||||
region: configMap.region,
|
||||
secure: true
|
||||
secure: true,
|
||||
})
|
||||
const aclTransMap: IStringKeyMap = {
|
||||
private: 'private',
|
||||
publicRead: 'public-read',
|
||||
publicReadWrite: 'public-read-write'
|
||||
publicReadWrite: 'public-read-write',
|
||||
}
|
||||
const res = await client.putBucket(configMap.BucketName, {
|
||||
acl: aclTransMap[configMap.acl],
|
||||
storageClass: 'Standard',
|
||||
dataRedundancyType: 'LRS',
|
||||
timeout: this.timeOut
|
||||
timeout: this.timeOut,
|
||||
})
|
||||
return res?.res?.status === 200
|
||||
}
|
||||
@@ -213,7 +213,7 @@ class AliyunApi {
|
||||
bucketName: bucket,
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
||||
@@ -229,7 +229,7 @@ class AliyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const client = this.getNewCtx(region, bucket)
|
||||
do {
|
||||
@@ -237,11 +237,11 @@ class AliyunApi {
|
||||
{
|
||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
'max-keys': '1000',
|
||||
'continuation-token': marker
|
||||
'continuation-token': marker,
|
||||
},
|
||||
{
|
||||
timeout: this.timeOut
|
||||
}
|
||||
timeout: this.timeOut,
|
||||
},
|
||||
)
|
||||
if (res?.res?.statusCode === 200) {
|
||||
res?.objects?.forEach((item: OSS.ObjectMeta) => {
|
||||
@@ -268,7 +268,7 @@ class AliyunApi {
|
||||
bucketName: bucket,
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
||||
@@ -284,7 +284,7 @@ class AliyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const client = this.getNewCtx(region, bucket)
|
||||
do {
|
||||
@@ -293,11 +293,11 @@ class AliyunApi {
|
||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
delimiter: '/',
|
||||
'max-keys': '1000',
|
||||
'continuation-token': marker
|
||||
'continuation-token': marker,
|
||||
},
|
||||
{
|
||||
timeout: this.timeOut
|
||||
}
|
||||
timeout: this.timeOut,
|
||||
},
|
||||
)
|
||||
if (res?.res?.statusCode === 200) {
|
||||
res?.prefixes?.forEach((item: string) => {
|
||||
@@ -342,7 +342,7 @@ class AliyunApi {
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
marker,
|
||||
itemsPerPage
|
||||
itemsPerPage,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
||||
@@ -353,11 +353,11 @@ class AliyunApi {
|
||||
prefix: slicedPrefix || undefined,
|
||||
delimiter: '/',
|
||||
'max-keys': itemsPerPage.toString(),
|
||||
'continuation-token': marker
|
||||
'continuation-token': marker,
|
||||
},
|
||||
{
|
||||
timeout: this.timeOut
|
||||
}
|
||||
timeout: this.timeOut,
|
||||
},
|
||||
)) as any
|
||||
// prefixes can be null
|
||||
// objects will be [] when no file
|
||||
@@ -366,20 +366,20 @@ class AliyunApi {
|
||||
fullList: [],
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
}
|
||||
const fullList = [
|
||||
...(res.prefixes?.map((item: string) => this.formatFolder(item, slicedPrefix, urlPrefix)) || []),
|
||||
...(res.objects
|
||||
?.filter((item: OSS.ObjectMeta) => item.size !== 0)
|
||||
.map((item: OSS.ObjectMeta) => this.formatFile(item, slicedPrefix, urlPrefix)) || [])
|
||||
.map((item: OSS.ObjectMeta) => this.formatFile(item, slicedPrefix, urlPrefix)) || []),
|
||||
]
|
||||
return {
|
||||
fullList,
|
||||
isTruncated: res.isTruncated,
|
||||
nextMarker: res.nextContinuationToken || '',
|
||||
success: true
|
||||
success: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ class AliyunApi {
|
||||
let isTruncated
|
||||
const allFileList = {
|
||||
CommonPrefixes: [] as any[],
|
||||
Contents: [] as any[]
|
||||
Contents: [] as any[],
|
||||
}
|
||||
do {
|
||||
const res = (await client.listV2(
|
||||
@@ -439,11 +439,11 @@ class AliyunApi {
|
||||
prefix: key,
|
||||
delimiter: '/',
|
||||
'max-keys': '1000',
|
||||
'continuation-token': marker
|
||||
'continuation-token': marker,
|
||||
},
|
||||
{
|
||||
timeout: this.timeOut
|
||||
}
|
||||
timeout: this.timeOut,
|
||||
},
|
||||
)) as any
|
||||
if (res?.res.statusCode !== 200) return false
|
||||
|
||||
@@ -458,7 +458,7 @@ class AliyunApi {
|
||||
const successfully = await this.deleteBucketFolder({
|
||||
bucketName,
|
||||
region,
|
||||
key: item
|
||||
key: item,
|
||||
})
|
||||
if (!successfully) return false
|
||||
}
|
||||
@@ -467,7 +467,7 @@ class AliyunApi {
|
||||
const cycle = Math.ceil(allFileList.Contents.length / 1000)
|
||||
for (let i = 0; i < cycle; i++) {
|
||||
const deleteRes = (await client.deleteMulti(
|
||||
allFileList.Contents.slice(i * 1000, (i + 1) * 1000).map((item: any) => item.name)
|
||||
allFileList.Contents.slice(i * 1000, (i + 1) * 1000).map((item: any) => item.name),
|
||||
)) as any
|
||||
if (deleteRes?.res.statusCode !== 200) return false
|
||||
}
|
||||
@@ -490,7 +490,7 @@ class AliyunApi {
|
||||
const { bucketName, region, key, expires, customUrl } = configMap
|
||||
const client = this.getNewCtx(region, bucketName)
|
||||
const res = client.signatureUrl(key, {
|
||||
expires: expires || 3600
|
||||
expires: expires || 3600,
|
||||
})
|
||||
return customUrl ? `${customUrl.replace(/\/+$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
|
||||
}
|
||||
@@ -527,7 +527,7 @@ class AliyunApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
client
|
||||
.multipartUpload(key, filePath, {
|
||||
@@ -538,9 +538,9 @@ class AliyunApi {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: Math.floor(p * 100),
|
||||
status: uploadTaskSpecialStatus.uploading
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
.then((res: any) => {
|
||||
const id = `${bucketName}-${region}-${key}-${filePath}`
|
||||
@@ -550,7 +550,7 @@ class AliyunApi {
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
response: JSON.stringify(res),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateUploadTask({
|
||||
@@ -558,7 +558,7 @@ class AliyunApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: JSON.stringify(res),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -566,8 +566,8 @@ class AliyunApi {
|
||||
this.logger.error(
|
||||
formatError(err, {
|
||||
class: 'AliyunApi',
|
||||
method: 'uploadBucketFile'
|
||||
})
|
||||
method: 'uploadBucketFile',
|
||||
}),
|
||||
)
|
||||
const id = `${bucketName}-${region}-${key}-${filePath}`
|
||||
instance.updateUploadTask({
|
||||
@@ -575,7 +575,7 @@ class AliyunApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: JSON.stringify(err),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -614,10 +614,10 @@ class AliyunApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
const preSignedUrl = client.signatureUrl(key, {
|
||||
expires: 60 * 60 * 48
|
||||
expires: 60 * 60 * 48,
|
||||
})
|
||||
promises.push(
|
||||
() =>
|
||||
@@ -629,7 +629,7 @@ class AliyunApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
@@ -637,8 +637,8 @@ class AliyunApi {
|
||||
this.logger.error(
|
||||
formatError(error, {
|
||||
class: 'AliyunApi',
|
||||
method: 'downloadBucketFile'
|
||||
})
|
||||
method: 'downloadBucketFile',
|
||||
}),
|
||||
)
|
||||
})
|
||||
return true
|
||||
|
||||
@@ -21,5 +21,5 @@ export default {
|
||||
SmmsApi,
|
||||
TcyunApi,
|
||||
UpyunApi,
|
||||
WebdavplistApi
|
||||
WebdavplistApi,
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
getAgent,
|
||||
getOptions,
|
||||
gotUpload,
|
||||
NewDownloader
|
||||
NewDownloader,
|
||||
} from '~/manage/utils/common'
|
||||
import { ManageLogger } from '~/manage/utils/logger'
|
||||
import { formatHttpProxy, isImage, trimPath } from '~/utils/common'
|
||||
@@ -37,7 +37,7 @@ class GithubApi {
|
||||
this.proxyStr = formatHttpProxy(proxy, 'string') as string | undefined
|
||||
this.commonHeaders = {
|
||||
Authorization: this.token,
|
||||
Accept: 'application/vnd.github+json'
|
||||
Accept: 'application/vnd.github+json',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class GithubApi {
|
||||
isDir: true,
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false
|
||||
match: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ class GithubApi {
|
||||
match: false,
|
||||
isImage: isImage(item.path),
|
||||
rawUrl: item.url,
|
||||
url: rawUrl
|
||||
url: rawUrl,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,8 +133,8 @@ class GithubApi {
|
||||
'json',
|
||||
undefined,
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
if (res.statusCode === 200) {
|
||||
res.body.forEach((item: any) => {
|
||||
@@ -142,7 +142,7 @@ class GithubApi {
|
||||
...item,
|
||||
Name: item.name,
|
||||
Location: item.id,
|
||||
CreationDate: item.created_at
|
||||
CreationDate: item.created_at,
|
||||
})
|
||||
})
|
||||
} else {
|
||||
@@ -171,8 +171,8 @@ class GithubApi {
|
||||
'json',
|
||||
undefined,
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
if (res.statusCode === 200) {
|
||||
res.body.forEach((item: any) => result.push(item.name))
|
||||
@@ -199,7 +199,7 @@ class GithubApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const treeQueue = [slicedPrefix]
|
||||
while (treeQueue.length) {
|
||||
@@ -210,7 +210,7 @@ class GithubApi {
|
||||
const currentPrefix = treeQueue[0]
|
||||
res = (await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${treeQueue.shift()}`,
|
||||
getOptions('GET', this.commonHeaders, {}, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.commonHeaders, {}, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (res && res.statusCode === 200) {
|
||||
const { tree } = res.body
|
||||
@@ -250,11 +250,11 @@ class GithubApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
res = await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${slicedPrefix}`,
|
||||
getOptions('GET', this.commonHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.commonHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)
|
||||
if (res && res.statusCode === 200) {
|
||||
res.body.tree.forEach((item: any) => {
|
||||
@@ -290,11 +290,11 @@ class GithubApi {
|
||||
const body = {
|
||||
message: 'deleted by PicList',
|
||||
sha,
|
||||
branch
|
||||
branch,
|
||||
}
|
||||
const res = await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/contents/${key}`,
|
||||
getOptions('DELETE', this.commonHeaders, undefined, 'json', JSON.stringify(body), undefined, this.proxy)
|
||||
getOptions('DELETE', this.commonHeaders, undefined, 'json', JSON.stringify(body), undefined, this.proxy),
|
||||
)
|
||||
return res.statusCode === 200
|
||||
}
|
||||
@@ -308,14 +308,14 @@ class GithubApi {
|
||||
// get sha of the branch
|
||||
const refRes = (await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/refs/heads/${branch}`,
|
||||
getOptions('GET', this.commonHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.commonHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (refRes.statusCode !== 200) return false
|
||||
const refSha = refRes.body.object.sha
|
||||
// get sha of the root tree
|
||||
const rootRes = (await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/branches/${branch}`,
|
||||
getOptions('GET', undefined, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', undefined, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (rootRes.statusCode !== 200) return false
|
||||
const rootSha = rootRes.body.commit.commit.tree.sha
|
||||
@@ -328,13 +328,13 @@ class GithubApi {
|
||||
'GET',
|
||||
this.commonHeaders,
|
||||
{
|
||||
recursive: true
|
||||
recursive: true,
|
||||
},
|
||||
'json',
|
||||
undefined,
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
if (treeRes.statusCode !== 200) return false
|
||||
const oldTree = treeRes.body.tree
|
||||
@@ -345,7 +345,7 @@ class GithubApi {
|
||||
path: `${key.replace(/(^\/+|\/+$)/g, '')}/${item.path}`,
|
||||
mode: item.mode,
|
||||
type: item.type,
|
||||
sha: null
|
||||
sha: null,
|
||||
}))
|
||||
const newTreeShaRes = (await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees`,
|
||||
@@ -356,11 +356,11 @@ class GithubApi {
|
||||
'json',
|
||||
JSON.stringify({
|
||||
base_tree: rootSha,
|
||||
tree: newTree
|
||||
tree: newTree,
|
||||
}),
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
if (newTreeShaRes.statusCode !== 201) return false
|
||||
const newTreeSha = newTreeShaRes.body.sha
|
||||
@@ -375,11 +375,11 @@ class GithubApi {
|
||||
JSON.stringify({
|
||||
message: 'deleted by PicList',
|
||||
tree: newTreeSha,
|
||||
parents: [refSha]
|
||||
parents: [refSha],
|
||||
}),
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
if (commitRes.statusCode !== 201) return false
|
||||
const commitSha = commitRes.body.sha
|
||||
@@ -392,11 +392,11 @@ class GithubApi {
|
||||
undefined,
|
||||
'json',
|
||||
JSON.stringify({
|
||||
sha: commitSha
|
||||
sha: commitSha,
|
||||
}),
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
return updateRefRes.statusCode === 200
|
||||
}
|
||||
@@ -421,13 +421,13 @@ class GithubApi {
|
||||
'GET',
|
||||
this.commonHeaders,
|
||||
{
|
||||
ref: branch
|
||||
ref: branch,
|
||||
},
|
||||
'json',
|
||||
undefined,
|
||||
undefined,
|
||||
this.proxy
|
||||
)
|
||||
this.proxy,
|
||||
),
|
||||
)) as any
|
||||
return res.statusCode === 200 ? res.body.download_url : ''
|
||||
}
|
||||
@@ -443,11 +443,11 @@ class GithubApi {
|
||||
const body = {
|
||||
message: `created a new folder named ${key} by PicList`,
|
||||
content: base64Content,
|
||||
branch
|
||||
branch,
|
||||
}
|
||||
const res = await got(
|
||||
`${this.baseUrl}/repos/${this.username}/${repo}/contents/${newFileKey}`,
|
||||
getOptions('PUT', this.commonHeaders, undefined, 'json', JSON.stringify(body), undefined, this.proxy)
|
||||
getOptions('PUT', this.commonHeaders, undefined, 'json', JSON.stringify(body), undefined, this.proxy),
|
||||
)
|
||||
return res.statusCode === 201
|
||||
}
|
||||
@@ -479,7 +479,7 @@ class GithubApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: repo,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
gotUpload(
|
||||
instance,
|
||||
@@ -488,14 +488,14 @@ class GithubApi {
|
||||
JSON.stringify({
|
||||
message: 'uploaded by PicList',
|
||||
branch,
|
||||
content: base64Content
|
||||
content: base64Content,
|
||||
}),
|
||||
this.commonHeaders,
|
||||
id,
|
||||
this.logger,
|
||||
30000,
|
||||
false,
|
||||
getAgent(this.proxy)
|
||||
getAgent(this.proxy),
|
||||
)
|
||||
}
|
||||
return true
|
||||
@@ -521,7 +521,7 @@ class GithubApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
let downloadUrl: string
|
||||
if (githubPrivate) {
|
||||
@@ -530,7 +530,7 @@ class GithubApi {
|
||||
customUrl: branch,
|
||||
key,
|
||||
rawUrl: githubUrl,
|
||||
githubPrivate
|
||||
githubPrivate,
|
||||
})
|
||||
downloadUrl = preSignedUrl
|
||||
} else {
|
||||
@@ -546,7 +546,7 @@ class GithubApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
@@ -554,8 +554,8 @@ class GithubApi {
|
||||
this.logger.error(
|
||||
formatError(error, {
|
||||
class: 'GithubApi',
|
||||
method: 'downloadBucketFile'
|
||||
})
|
||||
method: 'downloadBucketFile',
|
||||
}),
|
||||
)
|
||||
})
|
||||
return true
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
getFileMimeType,
|
||||
getOptions,
|
||||
gotUpload,
|
||||
NewDownloader
|
||||
NewDownloader,
|
||||
} from '~/manage/utils/common'
|
||||
import ManageLogger from '~/manage/utils/logger'
|
||||
import { formatHttpProxy, isImage } from '~/utils/common'
|
||||
@@ -38,7 +38,7 @@ class ImgurApi {
|
||||
this.proxyStr = formatHttpProxy(proxy, 'string') as string | undefined
|
||||
this.logger = logger
|
||||
this.tokenHeaders = {
|
||||
Authorization: this.accessToken
|
||||
Authorization: this.accessToken,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class ImgurApi {
|
||||
match: false,
|
||||
isImage: isImg,
|
||||
url: item.link,
|
||||
sha: item.deletehash
|
||||
sha: item.deletehash,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class ImgurApi {
|
||||
do {
|
||||
res = (await got(
|
||||
`${this.baseUrl}/account/${this.userName}/albums/${initPage}`,
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (!(res.statusCode === 200 && res.body.success)) {
|
||||
return []
|
||||
@@ -83,12 +83,12 @@ class ImgurApi {
|
||||
...item,
|
||||
Name: item.title,
|
||||
Location: item.id,
|
||||
CreationDate: item.datetime
|
||||
CreationDate: item.datetime,
|
||||
})) as any[]
|
||||
finalResult.push({
|
||||
Name: '全部',
|
||||
Location: 'unclassified',
|
||||
CreationDate: new Date().getTime()
|
||||
CreationDate: new Date().getTime(),
|
||||
})
|
||||
return finalResult
|
||||
}
|
||||
@@ -97,7 +97,7 @@ class ImgurApi {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
const {
|
||||
bucketConfig: { Location: albumHash },
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const cancelTask = [false]
|
||||
ipcMain.on('cancelLoadingFileList', (_: IpcMainEvent, token: string) => {
|
||||
@@ -110,12 +110,12 @@ class ImgurApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
if (albumHash !== 'unclassified') {
|
||||
res = (await got(
|
||||
`${this.baseUrl}/account/${this.userName}/album/${albumHash}`,
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (res.statusCode === 200 && res.body.success) {
|
||||
res.body.data.images.forEach((item: any) => {
|
||||
@@ -132,7 +132,7 @@ class ImgurApi {
|
||||
do {
|
||||
res = (await got(
|
||||
`${this.baseUrl}/account/${this.userName}/images/${initPage}`,
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('GET', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
if (res.statusCode === 200 && res.body.success) {
|
||||
res.body.data.forEach((item: any) => {
|
||||
@@ -157,7 +157,7 @@ class ImgurApi {
|
||||
const { DeleteHash: deleteHash } = configMap
|
||||
const res = (await got(
|
||||
`${this.baseUrl}/account/${this.userName}/image/${deleteHash}`,
|
||||
getOptions('DELETE', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy)
|
||||
getOptions('DELETE', this.tokenHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||
)) as any
|
||||
return res.statusCode === 200 && res.body.success
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class ImgurApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: albumHash
|
||||
targetFileRegion: albumHash,
|
||||
})
|
||||
const form = new FormData()
|
||||
form.append('type', 'file')
|
||||
@@ -195,12 +195,12 @@ class ImgurApi {
|
||||
if (fileSize > 1024 * 1024 * 10) {
|
||||
form.append('video', fs.createReadStream(filePath), {
|
||||
filename: path.basename(key),
|
||||
contentType: getFileMimeType(fileName)
|
||||
contentType: getFileMimeType(fileName),
|
||||
})
|
||||
} else {
|
||||
form.append('image', fs.createReadStream(filePath), {
|
||||
filename: path.basename(key),
|
||||
contentType: getFileMimeType(fileName)
|
||||
contentType: getFileMimeType(fileName),
|
||||
})
|
||||
}
|
||||
albumHash !== 'unclassified' && form.append('album', albumHash)
|
||||
@@ -216,7 +216,7 @@ class ImgurApi {
|
||||
this.logger,
|
||||
30000,
|
||||
false,
|
||||
getAgent(this.proxy)
|
||||
getAgent(this.proxy),
|
||||
)
|
||||
}
|
||||
return true
|
||||
@@ -242,7 +242,7 @@ class ImgurApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
promises.push(
|
||||
() =>
|
||||
@@ -254,7 +254,7 @@ class ImgurApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -53,7 +53,7 @@ class LocalApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
url: urlPrefix
|
||||
url: urlPrefix,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class LocalApi {
|
||||
checked: false,
|
||||
match: false,
|
||||
isImage: isImage(fileName),
|
||||
url: urlPrefix
|
||||
url: urlPrefix,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,20 +89,20 @@ class LocalApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
res = fsWalk.walkSync(this.transBack(prefix), {
|
||||
followSymbolicLinks: true,
|
||||
fs,
|
||||
stats: true,
|
||||
throwErrorOnBrokenSymbolicLink: false
|
||||
throwErrorOnBrokenSymbolicLink: false,
|
||||
})
|
||||
if (res.length) {
|
||||
result.fullList.push(
|
||||
...res
|
||||
.filter((item: fsWalk.Entry) => item.stats?.isFile())
|
||||
.map((item: any) => this.formatFile(item, urlPrefix, item.name, item.path, true))
|
||||
.map((item: any) => this.formatFile(item, urlPrefix, item.name, item.path, true)),
|
||||
)
|
||||
result.success = true
|
||||
}
|
||||
@@ -135,11 +135,11 @@ class LocalApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
const res = await fs.readdir(prefix, {
|
||||
withFileTypes: true
|
||||
withFileTypes: true,
|
||||
})
|
||||
if (res.length) {
|
||||
let urlPrefixF
|
||||
@@ -199,7 +199,7 @@ class LocalApi {
|
||||
let result = false
|
||||
try {
|
||||
await fs.rm(this.transBack(key), {
|
||||
recursive: true
|
||||
recursive: true,
|
||||
})
|
||||
result = true
|
||||
} catch (error) {
|
||||
@@ -226,7 +226,7 @@ class LocalApi {
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: '',
|
||||
noProgress: true
|
||||
noProgress: true,
|
||||
})
|
||||
try {
|
||||
fs.ensureFileSync(this.transBack(key))
|
||||
@@ -235,7 +235,7 @@ class LocalApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} catch (error) {
|
||||
this.logParam(error, 'uploadBucketFile')
|
||||
@@ -243,7 +243,7 @@ class LocalApi {
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -255,7 +255,7 @@ class LocalApi {
|
||||
let result = false
|
||||
try {
|
||||
await fs.mkdir(this.transBack(key), {
|
||||
recursive: true
|
||||
recursive: true,
|
||||
})
|
||||
result = true
|
||||
} catch (error) {
|
||||
@@ -279,7 +279,7 @@ class LocalApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
try {
|
||||
fs.ensureFileSync(savedFilePath)
|
||||
@@ -288,7 +288,7 @@ class LocalApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: downloadTaskSpecialStatus.downloaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} catch (error) {
|
||||
this.logParam(error, 'downloadBucketFile')
|
||||
@@ -296,7 +296,7 @@ class LocalApi {
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
formatError,
|
||||
getFileMimeType,
|
||||
hmacSha1Base64,
|
||||
NewDownloader
|
||||
NewDownloader,
|
||||
} from '~/manage/utils/common'
|
||||
import { ManageLogger } from '~/manage/utils/logger'
|
||||
import { isImage } from '~/utils/common'
|
||||
@@ -30,7 +30,7 @@ class QiniuApi {
|
||||
|
||||
hostList = {
|
||||
getBucketList: 'https://uc.qiniuapi.com/buckets',
|
||||
getBucketDomain: 'https://uc.qiniuapi.com/v2/domains'
|
||||
getBucketDomain: 'https://uc.qiniuapi.com/v2/domains',
|
||||
}
|
||||
|
||||
constructor(accessKey: string, secretKey: string, logger: ManageLogger) {
|
||||
@@ -50,7 +50,7 @@ class QiniuApi {
|
||||
isDir: true,
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false
|
||||
match: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class QiniuApi {
|
||||
isDir: false,
|
||||
checked: false,
|
||||
match: false,
|
||||
isImage: isImage(fileName)
|
||||
isImage: isImage(fileName),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class QiniuApi {
|
||||
body: string,
|
||||
query: string,
|
||||
contentType: string,
|
||||
xQiniuHeaders?: IStringKeyMap
|
||||
xQiniuHeaders?: IStringKeyMap,
|
||||
) {
|
||||
let signStr = `${method.toUpperCase()} ${urlPath}${query ? `?${query}` : ''}\nHost: ${host}`
|
||||
|
||||
@@ -104,9 +104,9 @@ class QiniuApi {
|
||||
const res = await axios.get(host, {
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
'Content-Type': this.commonType
|
||||
'Content-Type': this.commonType,
|
||||
},
|
||||
timeout: this.timeout
|
||||
timeout: this.timeout,
|
||||
})
|
||||
if (res?.status === 200 && res?.data?.length) {
|
||||
const result = [] as any[]
|
||||
@@ -117,7 +117,7 @@ class QiniuApi {
|
||||
Name: dataItem,
|
||||
Location: info.zone,
|
||||
CreationDate: new Date().toISOString(),
|
||||
Private: info.private
|
||||
Private: info.private,
|
||||
})
|
||||
}
|
||||
return result
|
||||
@@ -137,23 +137,23 @@ class QiniuApi {
|
||||
url: `https://${this.host}/v2/bucketInfo`,
|
||||
params: {
|
||||
bucket: bucketName,
|
||||
fs: true
|
||||
fs: true,
|
||||
},
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
'Content-Type': 'application/json',
|
||||
Host: this.host
|
||||
Host: this.host,
|
||||
},
|
||||
timeout: this.timeout
|
||||
timeout: this.timeout,
|
||||
})
|
||||
return res?.status === 200
|
||||
? {
|
||||
success: true,
|
||||
private: res.data.private,
|
||||
zone: res.data.zone
|
||||
zone: res.data.zone,
|
||||
}
|
||||
: {
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,13 +166,13 @@ class QiniuApi {
|
||||
const authorization = qiniu.util.generateAccessToken(this.mac, `${host}?tbl=${bucketName}`, undefined)
|
||||
const res = await axios.get(host, {
|
||||
params: {
|
||||
tbl: bucketName
|
||||
tbl: bucketName,
|
||||
},
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
'Content-Type': this.commonType
|
||||
'Content-Type': this.commonType,
|
||||
},
|
||||
timeout: this.timeout
|
||||
timeout: this.timeout,
|
||||
})
|
||||
return res?.status === 200 && res?.data?.length ? res.data : []
|
||||
}
|
||||
@@ -192,14 +192,14 @@ class QiniuApi {
|
||||
url: `https://${this.host}/private`,
|
||||
params: {
|
||||
bucket: bucketName,
|
||||
private: isPrivate
|
||||
private: isPrivate,
|
||||
},
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
'Content-Type': this.commonType,
|
||||
Host: this.host
|
||||
Host: this.host,
|
||||
},
|
||||
timeout: this.timeout
|
||||
timeout: this.timeout,
|
||||
})
|
||||
return res?.status === 200
|
||||
}
|
||||
@@ -223,14 +223,14 @@ class QiniuApi {
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
'Content-Type': 'application/json',
|
||||
Host: this.host
|
||||
Host: this.host,
|
||||
},
|
||||
timeout: this.timeout
|
||||
timeout: this.timeout,
|
||||
})
|
||||
return res?.status === 200
|
||||
? await this.setBucketAclPolicy({
|
||||
bucketName: BucketName,
|
||||
isPrivate: !acl
|
||||
isPrivate: !acl,
|
||||
})
|
||||
: false
|
||||
}
|
||||
@@ -251,7 +251,7 @@ class QiniuApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const config = new qiniu.conf.Config()
|
||||
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
||||
@@ -262,7 +262,7 @@ class QiniuApi {
|
||||
{
|
||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
marker,
|
||||
limit: 1000
|
||||
limit: 1000,
|
||||
},
|
||||
(err: any, respBody: any, respInfo: any) => {
|
||||
if (err) {
|
||||
@@ -270,10 +270,10 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
if (res && res.respInfo.statusCode === 200) {
|
||||
@@ -313,7 +313,7 @@ class QiniuApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const config = new qiniu.conf.Config()
|
||||
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
||||
@@ -325,7 +325,7 @@ class QiniuApi {
|
||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
delimiter: '/',
|
||||
marker,
|
||||
limit: 1000
|
||||
limit: 1000,
|
||||
},
|
||||
(err: any, respBody: any, respInfo: any) => {
|
||||
if (err) {
|
||||
@@ -333,10 +333,10 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
if (res && res.respInfo.statusCode === 200) {
|
||||
@@ -390,7 +390,7 @@ class QiniuApi {
|
||||
fullList: [] as any,
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
res = await new Promise((resolve, reject) => {
|
||||
bucketManager.listPrefix(
|
||||
@@ -399,7 +399,7 @@ class QiniuApi {
|
||||
limit: itemsPerPage,
|
||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
marker,
|
||||
delimiter: '/'
|
||||
delimiter: '/',
|
||||
},
|
||||
(err, respBody, respInfo) => {
|
||||
if (err) {
|
||||
@@ -407,10 +407,10 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
if (res?.respInfo?.statusCode === 200) {
|
||||
@@ -451,7 +451,7 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -470,7 +470,7 @@ class QiniuApi {
|
||||
let marker = ''
|
||||
let isTruncated = true
|
||||
const allFileList = {
|
||||
Contents: [] as any[]
|
||||
Contents: [] as any[],
|
||||
}
|
||||
do {
|
||||
const res = (await new Promise((resolve, reject) => {
|
||||
@@ -479,7 +479,7 @@ class QiniuApi {
|
||||
{
|
||||
prefix: key,
|
||||
marker,
|
||||
limit: 1000
|
||||
limit: 1000,
|
||||
},
|
||||
(err, respBody, respInfo) => {
|
||||
if (err) {
|
||||
@@ -487,10 +487,10 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})) as any
|
||||
if (res?.respInfo?.statusCode === 200) {
|
||||
@@ -515,7 +515,7 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -546,7 +546,7 @@ class QiniuApi {
|
||||
bucketName,
|
||||
newKey,
|
||||
{
|
||||
force: true
|
||||
force: true,
|
||||
},
|
||||
(err, respBody, respInfo) => {
|
||||
if (err) {
|
||||
@@ -554,10 +554,10 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})) as any
|
||||
return res?.respInfo?.statusCode === 200
|
||||
@@ -604,14 +604,14 @@ class QiniuApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
const config = new qiniu.conf.Config()
|
||||
const resumeUploader = new qiniu.resume_up.ResumeUploader(config)
|
||||
const putExtra = new qiniu.resume_up.PutExtra()
|
||||
const uploadToken = new qiniu.rs.PutPolicy({
|
||||
scope: `${bucketName}:${key}`,
|
||||
expires: 36000
|
||||
expires: 36000,
|
||||
}).uploadToken(this.mac)
|
||||
putExtra.fname = key
|
||||
putExtra.params = {}
|
||||
@@ -623,7 +623,7 @@ class QiniuApi {
|
||||
instance.updateUploadTask({
|
||||
id: `${bucketName}-${region}-${key}-${filePath}`,
|
||||
progress,
|
||||
status: uploadTaskSpecialStatus.uploading
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
})
|
||||
}
|
||||
resumeUploader.putFile(uploadToken, key, filePath, putExtra, (respErr, respBody, respInfo) => {
|
||||
@@ -631,14 +631,14 @@ class QiniuApi {
|
||||
this.logger.error(
|
||||
formatError(respErr, {
|
||||
class: 'Qiniu',
|
||||
method: 'uploadBucketFile'
|
||||
})
|
||||
method: 'uploadBucketFile',
|
||||
}),
|
||||
)
|
||||
instance.updateUploadTask({
|
||||
id: `${bucketName}-${region}-${key}-${filePath}`,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -648,14 +648,14 @@ class QiniuApi {
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
response: JSON.stringify(respBody),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateUploadTask({
|
||||
id: `${bucketName}-${region}-${key}-${filePath}`,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -670,7 +670,7 @@ class QiniuApi {
|
||||
async createBucketFolder(configMap: IStringKeyMap): Promise<boolean> {
|
||||
const { bucketName, key } = configMap
|
||||
const putPolicy = new qiniu.rs.PutPolicy({
|
||||
scope: `${bucketName}:${key}`
|
||||
scope: `${bucketName}:${key}`,
|
||||
})
|
||||
const uploadToken = putPolicy.uploadToken(this.mac)
|
||||
const FormUploader = new qiniu.form_up.FormUploader()
|
||||
@@ -682,7 +682,7 @@ class QiniuApi {
|
||||
} else {
|
||||
resolve({
|
||||
respBody,
|
||||
respInfo
|
||||
respInfo,
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -710,12 +710,12 @@ class QiniuApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
const preSignedUrl = await this.getPreSignedUrl({
|
||||
key,
|
||||
expires: 36000,
|
||||
customUrl
|
||||
customUrl,
|
||||
})
|
||||
promises.push(
|
||||
() =>
|
||||
@@ -727,7 +727,7 @@ class QiniuApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
PutObjectCommand,
|
||||
PutPublicAccessBlockCommand,
|
||||
S3Client,
|
||||
S3ClientConfig
|
||||
S3ClientConfig,
|
||||
} from '@aws-sdk/client-s3'
|
||||
import { Progress, Upload } from '@aws-sdk/lib-storage'
|
||||
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
|
||||
@@ -55,7 +55,7 @@ class S3plistApi {
|
||||
proxy: string | undefined,
|
||||
logger: ManageLogger,
|
||||
dogeCloudSupport: boolean = false,
|
||||
bucketName: string = ''
|
||||
bucketName: string = '',
|
||||
) {
|
||||
this.accessKeyId = accessKeyId
|
||||
this.secretAccessKey = secretAccessKey
|
||||
@@ -64,12 +64,12 @@ class S3plistApi {
|
||||
this.baseOptions = {
|
||||
credentials: {
|
||||
accessKeyId,
|
||||
secretAccessKey
|
||||
secretAccessKey,
|
||||
},
|
||||
endpoint: endpoint ? formatEndpoint(endpoint, sslEnabled) : undefined,
|
||||
tls: sslEnabled,
|
||||
forcePathStyle: s3ForcePathStyle,
|
||||
requestHandler: this.setAgent(proxy, sslEnabled)
|
||||
requestHandler: this.setAgent(proxy, sslEnabled),
|
||||
}
|
||||
this.logger = logger
|
||||
this.proxy = formatHttpProxy(proxy, 'string') as string | undefined
|
||||
@@ -84,7 +84,7 @@ class S3plistApi {
|
||||
this.baseOptions.credentials = {
|
||||
accessKeyId: token.accessKeyId,
|
||||
secretAccessKey: token.secretAccessKey,
|
||||
sessionToken: token.sessionToken
|
||||
sessionToken: token.sessionToken,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class S3plistApi {
|
||||
const commonOptions: AgentOptions = {
|
||||
keepAlive: true,
|
||||
keepAliveMsecs: 1000,
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
|
||||
}
|
||||
const extraOptions = sslEnabled ? { rejectUnauthorized: false } : {}
|
||||
return sslEnabled
|
||||
@@ -102,16 +102,16 @@ class S3plistApi {
|
||||
? agent.https
|
||||
: new https.Agent({
|
||||
...commonOptions,
|
||||
...extraOptions
|
||||
})
|
||||
...extraOptions,
|
||||
}),
|
||||
})
|
||||
: new NodeHttpHandler({
|
||||
httpAgent: agent.http
|
||||
? agent.http
|
||||
: new http.Agent({
|
||||
...commonOptions,
|
||||
...extraOptions
|
||||
})
|
||||
...extraOptions,
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ class S3plistApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
key: item.Prefix
|
||||
key: item.Prefix,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ class S3plistApi {
|
||||
isDir: false,
|
||||
checked: false,
|
||||
match: false,
|
||||
isImage: isImage(fileName || '')
|
||||
isImage: isImage(fileName || ''),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ class S3plistApi {
|
||||
BlockPublicAcls: false,
|
||||
IgnorePublicAcls: false,
|
||||
BlockPublicPolicy: false,
|
||||
RestrictPublicBuckets: false
|
||||
}
|
||||
RestrictPublicBuckets: false,
|
||||
},
|
||||
}
|
||||
const command = new PutPublicAccessBlockCommand(input)
|
||||
const data = await client.send(command)
|
||||
@@ -193,7 +193,7 @@ class S3plistApi {
|
||||
if (endpoint === '' || endpoint.includes('amazonaws')) {
|
||||
const createCommand = new CreateBucketCommand({
|
||||
Bucket: BucketName,
|
||||
ObjectOwnership: 'BucketOwnerPreferred'
|
||||
ObjectOwnership: 'BucketOwnerPreferred',
|
||||
})
|
||||
const createData = await client.send(createCommand)
|
||||
if (createData.$metadata.httpStatusCode === 200) {
|
||||
@@ -201,7 +201,7 @@ class S3plistApi {
|
||||
await this.putPublicAccess(BucketName, client)
|
||||
const putACLCommand = new PutBucketAclCommand({
|
||||
Bucket: BucketName,
|
||||
ACL: acl
|
||||
ACL: acl,
|
||||
})
|
||||
const putACLData = await client.send(putACLCommand)
|
||||
if (putACLData.$metadata.httpStatusCode !== 200) {
|
||||
@@ -216,7 +216,7 @@ class S3plistApi {
|
||||
} else {
|
||||
const createCommand = new CreateBucketCommand({
|
||||
Bucket: BucketName,
|
||||
ACL: acl
|
||||
ACL: acl,
|
||||
})
|
||||
const createData = await client.send(createCommand)
|
||||
if (createData.$metadata.httpStatusCode === 200) {
|
||||
@@ -244,8 +244,8 @@ class S3plistApi {
|
||||
{
|
||||
Name: item.s3Bucket,
|
||||
CreationDate: item.ctime,
|
||||
Location: item.region
|
||||
}
|
||||
Location: item.region,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -274,16 +274,16 @@ class S3plistApi {
|
||||
...data.Buckets.map(bucket => ({
|
||||
Name: bucket.Name,
|
||||
CreationDate: bucket.CreationDate,
|
||||
Location: 'auto'
|
||||
}))
|
||||
Location: 'auto',
|
||||
})),
|
||||
)
|
||||
} else {
|
||||
for (const bucket of data.Buckets) {
|
||||
const bucketName = bucket.Name
|
||||
const bucketConfig = await client.send(
|
||||
new GetBucketLocationCommand({
|
||||
Bucket: bucketName
|
||||
})
|
||||
Bucket: bucketName,
|
||||
}),
|
||||
)
|
||||
result.push({
|
||||
Name: bucketName,
|
||||
@@ -291,7 +291,7 @@ class S3plistApi {
|
||||
Location:
|
||||
bucketConfig.$metadata.httpStatusCode === 200
|
||||
? bucketConfig.LocationConstraint?.toLowerCase() || 'us-east-1'
|
||||
: 'us-east-1'
|
||||
: 'us-east-1',
|
||||
})
|
||||
if (bucketConfig.$metadata.httpStatusCode !== 200) {
|
||||
this.logParam(bucketConfig, 'getBucketList')
|
||||
@@ -311,7 +311,7 @@ class S3plistApi {
|
||||
bucketName: bucket,
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
||||
@@ -327,7 +327,7 @@ class S3plistApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
do {
|
||||
@@ -338,7 +338,7 @@ class S3plistApi {
|
||||
Bucket: bucket,
|
||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
MaxKeys: 1000,
|
||||
ContinuationToken: marker
|
||||
ContinuationToken: marker,
|
||||
})
|
||||
res = await client.send(command)
|
||||
if (res.$metadata.httpStatusCode === 200) {
|
||||
@@ -375,7 +375,7 @@ class S3plistApi {
|
||||
bucketName: bucket,
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
||||
@@ -391,7 +391,7 @@ class S3plistApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
await this.getDogeCloudToken()
|
||||
@@ -404,7 +404,7 @@ class S3plistApi {
|
||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
MaxKeys: 1000,
|
||||
ContinuationToken: marker,
|
||||
Delimiter: '/'
|
||||
Delimiter: '/',
|
||||
})
|
||||
res = await client.send(command)
|
||||
if (res.$metadata.httpStatusCode === 200) {
|
||||
@@ -445,7 +445,7 @@ class S3plistApi {
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
marker,
|
||||
itemsPerPage
|
||||
itemsPerPage,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
||||
@@ -453,13 +453,13 @@ class S3plistApi {
|
||||
fullList: [] as any,
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
try {
|
||||
await this.getDogeCloudToken()
|
||||
const options = {
|
||||
...this.baseOptions,
|
||||
region: String(region) || 'us-east-1'
|
||||
region: String(region) || 'us-east-1',
|
||||
} as S3ClientConfig
|
||||
const client = new S3Client(options)
|
||||
const command = new ListObjectsV2Command({
|
||||
@@ -467,13 +467,13 @@ class S3plistApi {
|
||||
Prefix: slicedPrefix,
|
||||
ContinuationToken: marker === '' ? undefined : marker,
|
||||
Delimiter: '/',
|
||||
MaxKeys: itemsPerPage
|
||||
MaxKeys: itemsPerPage,
|
||||
})
|
||||
const data = await client.send(command)
|
||||
if (data.$metadata.httpStatusCode === 200) {
|
||||
result.fullList = [
|
||||
...(data.CommonPrefixes?.map(item => this.formatFolder(item, slicedPrefix, urlPrefix)) || []),
|
||||
...(data.Contents?.map(item => this.formatFile(item, slicedPrefix, urlPrefix)) || [])
|
||||
...(data.Contents?.map(item => this.formatFile(item, slicedPrefix, urlPrefix)) || []),
|
||||
]
|
||||
result.isTruncated = data.IsTruncated || false
|
||||
result.nextMarker = data.NextContinuationToken || ''
|
||||
@@ -502,19 +502,19 @@ class S3plistApi {
|
||||
await this.getDogeCloudToken()
|
||||
const options = {
|
||||
...this.baseOptions,
|
||||
region: String(region) || 'us-east-1'
|
||||
region: String(region) || 'us-east-1',
|
||||
} as S3ClientConfig
|
||||
const client = new S3Client(options)
|
||||
const command = new CopyObjectCommand({
|
||||
Bucket: bucketName,
|
||||
CopySource: encodeURI(`${bucketName}/${oldKey}`),
|
||||
Key: newKey
|
||||
Key: newKey,
|
||||
})
|
||||
const data = await client.send(command)
|
||||
if (data.$metadata.httpStatusCode === 200) {
|
||||
const deleteCommand = new DeleteObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: oldKey
|
||||
Key: oldKey,
|
||||
})
|
||||
const deleteData = await client.send(deleteCommand)
|
||||
if (deleteData.$metadata.httpStatusCode === 204) {
|
||||
@@ -550,7 +550,7 @@ class S3plistApi {
|
||||
const client = new S3Client(options)
|
||||
const command = new DeleteObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: key
|
||||
Key: key,
|
||||
})
|
||||
const data = await client.send(command)
|
||||
if (data.$metadata.httpStatusCode === 204) {
|
||||
@@ -576,7 +576,7 @@ class S3plistApi {
|
||||
let res
|
||||
const allFileList = {
|
||||
CommonPrefixes: [] as any[],
|
||||
Contents: [] as any[]
|
||||
Contents: [] as any[],
|
||||
}
|
||||
try {
|
||||
await this.getDogeCloudToken()
|
||||
@@ -589,7 +589,7 @@ class S3plistApi {
|
||||
Prefix: key,
|
||||
ContinuationToken: marker === '' ? undefined : marker,
|
||||
Delimiter: '/',
|
||||
MaxKeys: 1000
|
||||
MaxKeys: 1000,
|
||||
})
|
||||
res = (await client.send(command)) as ListObjectsV2CommandOutput
|
||||
if (res.$metadata.httpStatusCode === 200) {
|
||||
@@ -607,7 +607,7 @@ class S3plistApi {
|
||||
res = await this.deleteBucketFolder({
|
||||
bucketName,
|
||||
region,
|
||||
key: item.Prefix
|
||||
key: item.Prefix,
|
||||
})
|
||||
if (!res) {
|
||||
return result
|
||||
@@ -626,10 +626,10 @@ class S3plistApi {
|
||||
Delete: {
|
||||
Objects: deleteList.map(item => {
|
||||
return {
|
||||
Key: item.Key
|
||||
Key: item.Key,
|
||||
}
|
||||
})
|
||||
}
|
||||
}),
|
||||
},
|
||||
})
|
||||
res = await client.send(deleteCommand)
|
||||
if (res.$metadata.httpStatusCode !== 200) {
|
||||
@@ -668,11 +668,11 @@ class S3plistApi {
|
||||
client,
|
||||
new GetObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: key
|
||||
Key: key,
|
||||
}),
|
||||
{
|
||||
expiresIn: expires || 3600
|
||||
}
|
||||
expiresIn: expires || 3600,
|
||||
},
|
||||
)
|
||||
return signedUrl
|
||||
} catch (error) {
|
||||
@@ -695,7 +695,7 @@ class S3plistApi {
|
||||
const client = new S3Client(options)
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: key
|
||||
Key: key,
|
||||
})
|
||||
const data = await client.send(command)
|
||||
if (data.$metadata.httpStatusCode === 200) {
|
||||
@@ -733,7 +733,7 @@ class S3plistApi {
|
||||
'aws-exec-read',
|
||||
'authenticated-read',
|
||||
'bucket-owner-read',
|
||||
'bucket-owner-full-control'
|
||||
'bucket-owner-full-control',
|
||||
]
|
||||
for (const item of fileArray) {
|
||||
const { bucketName, region, key, filePath, fileName, aclForUpload } = item
|
||||
@@ -749,7 +749,7 @@ class S3plistApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: String(region)
|
||||
targetFileRegion: String(region),
|
||||
})
|
||||
try {
|
||||
await this.getDogeCloudToken()
|
||||
@@ -760,7 +760,7 @@ class S3plistApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: JSON.stringify(error),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
continue
|
||||
}
|
||||
@@ -777,15 +777,15 @@ class S3plistApi {
|
||||
ContentType: getFileMimeType(fileName),
|
||||
ACL: allowedAcl.includes(aclForUpload) ? aclForUpload : 'private',
|
||||
Metadata: {
|
||||
description: 'uploaded by PicList'
|
||||
}
|
||||
}
|
||||
description: 'uploaded by PicList',
|
||||
},
|
||||
},
|
||||
})
|
||||
parallelUploads3.on('httpUploadProgress', (progress: Progress) => {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: progress.loaded && progress.total ? Math.floor((progress.loaded / progress.total) * 100) : 0,
|
||||
status: uploadTaskSpecialStatus.uploading
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
})
|
||||
})
|
||||
parallelUploads3
|
||||
@@ -796,14 +796,14 @@ class S3plistApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -814,7 +814,7 @@ class S3plistApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: JSON.stringify(error),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -841,14 +841,14 @@ class S3plistApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
const preSignedUrl = await this.getPreSignedUrl({
|
||||
bucketName,
|
||||
region: String(region),
|
||||
key,
|
||||
expires: 36000,
|
||||
customUrl
|
||||
customUrl,
|
||||
})
|
||||
promises.push(
|
||||
() =>
|
||||
@@ -860,7 +860,7 @@ class S3plistApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -53,7 +53,7 @@ class SftpApi {
|
||||
passphrase: Undefinable<string>,
|
||||
fileMode: Undefinable<string>,
|
||||
dirMode: Undefinable<string>,
|
||||
logger: ManageLogger
|
||||
logger: ManageLogger,
|
||||
) {
|
||||
this.host = host
|
||||
this.port = Number(port) || 22
|
||||
@@ -71,7 +71,7 @@ class SftpApi {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
privateKey: this.privateKey,
|
||||
passphrase: this.passphrase
|
||||
passphrase: this.passphrase,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class SftpApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
url
|
||||
url,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class SftpApi {
|
||||
checked: false,
|
||||
match: false,
|
||||
isImage: isImage(item.filename),
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ class SftpApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
await this.connectClient()
|
||||
@@ -211,7 +211,7 @@ class SftpApi {
|
||||
size: Number(size) || 0,
|
||||
mtime,
|
||||
filename,
|
||||
key
|
||||
key,
|
||||
})
|
||||
})
|
||||
return result
|
||||
@@ -237,7 +237,7 @@ class SftpApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
await this.connectClient()
|
||||
@@ -339,13 +339,13 @@ class SftpApi {
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region,
|
||||
noProgress: false
|
||||
noProgress: false,
|
||||
})
|
||||
try {
|
||||
await this.connectClient()
|
||||
const res = await this.ctx.putFile(filePath, `/${key.replace(/^\/+/, '')}`, {
|
||||
fileMode: this.fileMode,
|
||||
dirMode: this.dirMode
|
||||
dirMode: this.dirMode,
|
||||
})
|
||||
this.ctx.close()
|
||||
if (res) {
|
||||
@@ -353,14 +353,14 @@ class SftpApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -369,7 +369,7 @@ class SftpApi {
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -405,7 +405,7 @@ class SftpApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
try {
|
||||
await this.connectClient()
|
||||
@@ -416,14 +416,14 @@ class SftpApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: downloadTaskSpecialStatus.downloaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateDownloadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -432,7 +432,7 @@ class SftpApi {
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ class SmmsApi {
|
||||
baseURL: this.baseUrl,
|
||||
timeout: this.timeout,
|
||||
headers: {
|
||||
Authorization: this.token
|
||||
Authorization: this.token,
|
||||
},
|
||||
httpsAgent: new Agent({
|
||||
keepAlive: true,
|
||||
timeout: this.timeout
|
||||
})
|
||||
timeout: this.timeout,
|
||||
}),
|
||||
})
|
||||
this.logger = logger
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class SmmsApi {
|
||||
match: false,
|
||||
isImage: isImage(item.storename),
|
||||
sha: item.hash,
|
||||
downloadUrl: item.url
|
||||
downloadUrl: item.url,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,17 +69,17 @@ class SmmsApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
do {
|
||||
res = await this.axiosInstance('/upload_history', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
params: {
|
||||
page: marker
|
||||
}
|
||||
page: marker,
|
||||
},
|
||||
})
|
||||
if (res && res.status === 200 && res.data && res.data.success) {
|
||||
if (res.data.Count === 0) {
|
||||
@@ -128,16 +128,16 @@ class SmmsApi {
|
||||
fullList: [] as any,
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
const res = await this.axiosInstance('/upload_history', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
params: {
|
||||
page: currentPage
|
||||
}
|
||||
page: currentPage,
|
||||
},
|
||||
})
|
||||
if (res?.status !== 200 || !res?.data?.success) return result
|
||||
|
||||
@@ -167,8 +167,8 @@ class SmmsApi {
|
||||
method: 'GET',
|
||||
params: {
|
||||
hash: DeleteHash,
|
||||
format: 'json'
|
||||
}
|
||||
format: 'json',
|
||||
},
|
||||
})
|
||||
return res?.status === 200 && res?.data?.success
|
||||
}
|
||||
@@ -194,13 +194,13 @@ class SmmsApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
const form = new FormData()
|
||||
form.append('format', 'json')
|
||||
form.append('smfile', fs.createReadStream(filePath), {
|
||||
filename: path.basename(fileName),
|
||||
contentType: getFileMimeType(fileName)
|
||||
contentType: getFileMimeType(fileName),
|
||||
})
|
||||
const headers = form.getHeaders()
|
||||
headers.Authorization = this.token
|
||||
@@ -230,7 +230,7 @@ class SmmsApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
promises.push(
|
||||
() =>
|
||||
@@ -242,7 +242,7 @@ class SmmsApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -20,7 +20,7 @@ class TcyunApi {
|
||||
constructor(secretId: string, secretKey: string, logger: ManageLogger) {
|
||||
this.ctx = new COS({
|
||||
SecretId: secretId,
|
||||
SecretKey: secretKey
|
||||
SecretKey: secretKey,
|
||||
})
|
||||
this.logger = logger
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class TcyunApi {
|
||||
isDir: true,
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false
|
||||
match: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class TcyunApi {
|
||||
checked: false,
|
||||
isImage: isImage(item.Key),
|
||||
match: false,
|
||||
url: `${urlPrefix}/${item.Key}`
|
||||
url: `${urlPrefix}/${item.Key}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class TcyunApi {
|
||||
const { bucketName, region } = param
|
||||
const res = await this.ctx.getBucketDomain({
|
||||
Bucket: bucketName,
|
||||
Region: region
|
||||
Region: region,
|
||||
})
|
||||
if (res?.statusCode !== 200 || !res?.DomainRule?.length) return []
|
||||
return res.DomainRule.filter((item: any) => item.Status === 'ENABLED').map(item => item.Name)
|
||||
@@ -91,7 +91,7 @@ class TcyunApi {
|
||||
const res = await this.ctx.putBucket({
|
||||
ACL: configMap.acl,
|
||||
Bucket: configMap.BucketName,
|
||||
Region: configMap.region
|
||||
Region: configMap.region,
|
||||
})
|
||||
return res?.statusCode === 200
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class TcyunApi {
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
customUrl,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1, prefix.length)
|
||||
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
||||
@@ -119,7 +119,7 @@ class TcyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
let res = {} as COS.GetBucketResult
|
||||
do {
|
||||
@@ -127,13 +127,13 @@ class TcyunApi {
|
||||
Bucket: bucket,
|
||||
Region: region,
|
||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
Marker: marker
|
||||
Marker: marker,
|
||||
})
|
||||
if (res?.statusCode === 200) {
|
||||
result.fullList.push(
|
||||
...res.Contents.filter(item => parseInt(item.Size) !== 0).map(item =>
|
||||
this.formatFile(item, slicedPrefix, urlPrefix)
|
||||
)
|
||||
this.formatFile(item, slicedPrefix, urlPrefix),
|
||||
),
|
||||
)
|
||||
window.webContents.send(refreshDownloadFileTransferList, result)
|
||||
} else {
|
||||
@@ -157,7 +157,7 @@ class TcyunApi {
|
||||
bucketConfig: { Location: region },
|
||||
prefix,
|
||||
customUrl,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1, prefix.length)
|
||||
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
||||
@@ -174,7 +174,7 @@ class TcyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
do {
|
||||
res = await this.ctx.getBucket({
|
||||
@@ -182,14 +182,14 @@ class TcyunApi {
|
||||
Region: region,
|
||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
Delimiter: '/',
|
||||
Marker: marker
|
||||
Marker: marker,
|
||||
})
|
||||
if (res?.statusCode === 200) {
|
||||
result.fullList.push(
|
||||
...res.CommonPrefixes.map(item => this.formatFolder(item, slicedPrefix, urlPrefix)),
|
||||
...res.Contents.filter(item => parseInt(item.Size) !== 0).map(item =>
|
||||
this.formatFile(item, slicedPrefix, urlPrefix)
|
||||
)
|
||||
this.formatFile(item, slicedPrefix, urlPrefix),
|
||||
),
|
||||
)
|
||||
window.webContents.send('refreshFileTransferList', result)
|
||||
} else {
|
||||
@@ -228,7 +228,7 @@ class TcyunApi {
|
||||
prefix,
|
||||
customUrl,
|
||||
marker,
|
||||
itemsPerPage
|
||||
itemsPerPage,
|
||||
} = configMap
|
||||
const slicedPrefix = prefix.slice(1)
|
||||
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
||||
@@ -238,26 +238,26 @@ class TcyunApi {
|
||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||
Delimiter: '/',
|
||||
Marker: marker,
|
||||
MaxKeys: itemsPerPage
|
||||
MaxKeys: itemsPerPage,
|
||||
})) as COS.GetBucketResult
|
||||
if (res?.statusCode !== 200) {
|
||||
return {
|
||||
fullList: [],
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
}
|
||||
const result = {
|
||||
fullList: [
|
||||
...res.CommonPrefixes.map(item => this.formatFolder(item, slicedPrefix, urlPrefix)),
|
||||
...res.Contents.filter(item => parseInt(item.Size) !== 0).map(item =>
|
||||
this.formatFile(item, slicedPrefix, urlPrefix)
|
||||
)
|
||||
this.formatFile(item, slicedPrefix, urlPrefix),
|
||||
),
|
||||
],
|
||||
isTruncated: res.IsTruncated === 'true',
|
||||
nextMarker: res.NextMarker || '',
|
||||
success: true
|
||||
success: true,
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -278,7 +278,7 @@ class TcyunApi {
|
||||
Bucket: bucketName,
|
||||
Region: region,
|
||||
Key: newKey,
|
||||
CopySource: handleUrlEncode(`${bucketName}.cos.${region}.myqcloud.com/${oldKey}`)
|
||||
CopySource: handleUrlEncode(`${bucketName}.cos.${region}.myqcloud.com/${oldKey}`),
|
||||
})
|
||||
|
||||
if (copyRes?.statusCode !== 200) return false
|
||||
@@ -286,7 +286,7 @@ class TcyunApi {
|
||||
const deleteRes = await this.ctx.deleteObject({
|
||||
Bucket: bucketName,
|
||||
Region: region,
|
||||
Key: oldKey
|
||||
Key: oldKey,
|
||||
})
|
||||
|
||||
return deleteRes?.statusCode === 204
|
||||
@@ -306,7 +306,7 @@ class TcyunApi {
|
||||
const res = await this.ctx.deleteObject({
|
||||
Bucket: bucketName,
|
||||
Region: region,
|
||||
Key: key
|
||||
Key: key,
|
||||
})
|
||||
return res?.statusCode === 204
|
||||
}
|
||||
@@ -321,7 +321,7 @@ class TcyunApi {
|
||||
let res: any
|
||||
const allFileList = {
|
||||
CommonPrefixes: [] as any[],
|
||||
Contents: [] as any[]
|
||||
Contents: [] as any[],
|
||||
}
|
||||
do {
|
||||
res = await this.ctx.getBucket({
|
||||
@@ -330,7 +330,7 @@ class TcyunApi {
|
||||
Prefix: key,
|
||||
Delimiter: '/',
|
||||
MaxKeys: 1000,
|
||||
Marker: marker
|
||||
Marker: marker,
|
||||
})
|
||||
|
||||
if (res?.statusCode !== 200) return false
|
||||
@@ -344,7 +344,7 @@ class TcyunApi {
|
||||
!(await this.deleteBucketFolder({
|
||||
bucketName,
|
||||
region,
|
||||
key: item.Prefix
|
||||
key: item.Prefix,
|
||||
}))
|
||||
) {
|
||||
return false
|
||||
@@ -355,7 +355,7 @@ class TcyunApi {
|
||||
const res = await this.ctx.deleteMultipleObject({
|
||||
Bucket: bucketName,
|
||||
Region: region,
|
||||
Objects: allFileList.Contents.slice(i * 1000, (i + 1) * 1000).map((item: any) => ({ Key: item.Key }))
|
||||
Objects: allFileList.Contents.slice(i * 1000, (i + 1) * 1000).map((item: any) => ({ Key: item.Key })),
|
||||
})
|
||||
if (res?.statusCode !== 200) return false
|
||||
}
|
||||
@@ -381,9 +381,9 @@ class TcyunApi {
|
||||
Region: region,
|
||||
Key: key,
|
||||
Expires: expires,
|
||||
Sign: true
|
||||
Sign: true,
|
||||
},
|
||||
() => {}
|
||||
() => {},
|
||||
)
|
||||
return customUrl ? `${customUrl.replace(/\/+$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
|
||||
}
|
||||
@@ -417,7 +417,7 @@ class TcyunApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
files.push({
|
||||
Bucket: bucketName,
|
||||
@@ -432,7 +432,7 @@ class TcyunApi {
|
||||
id,
|
||||
progress: Math.floor(progress.percent * 100),
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
cancelToken
|
||||
cancelToken,
|
||||
})
|
||||
},
|
||||
onFileFinish: (err: any, data: any) => {
|
||||
@@ -442,27 +442,27 @@ class TcyunApi {
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
response: typeof data === 'object' ? JSON.stringify(data) : String(data),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
this.logger.error(
|
||||
formatError(err, {
|
||||
method: 'uploadBucketFile',
|
||||
class: 'TcyunApi'
|
||||
})
|
||||
class: 'TcyunApi',
|
||||
}),
|
||||
)
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: typeof err === 'object' ? JSON.stringify(err) : String(err),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
this.ctx.uploadFiles({
|
||||
files
|
||||
files,
|
||||
})
|
||||
}
|
||||
return true
|
||||
@@ -478,7 +478,7 @@ class TcyunApi {
|
||||
Bucket: bucketName,
|
||||
Region: region,
|
||||
Key: key,
|
||||
Body: ''
|
||||
Body: '',
|
||||
})
|
||||
return res?.statusCode === 200
|
||||
}
|
||||
@@ -507,7 +507,7 @@ class TcyunApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: path.join(downloadPath, fileName)
|
||||
targetFilePath: path.join(downloadPath, fileName),
|
||||
})
|
||||
fs.ensureDirSync(path.dirname(path.join(downloadPath, fileName)))
|
||||
this.ctx
|
||||
@@ -522,9 +522,9 @@ class TcyunApi {
|
||||
instance.updateDownloadTask({
|
||||
id,
|
||||
progress: Math.floor(progress.percent * 100),
|
||||
status: downloadTaskSpecialStatus.downloading
|
||||
status: downloadTaskSpecialStatus.downloading,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
.then((res: any) => {
|
||||
instance.updateDownloadTask({
|
||||
@@ -532,22 +532,22 @@ class TcyunApi {
|
||||
progress: res && res.statusCode === 200 ? 100 : 0,
|
||||
status: res && res.statusCode === 200 ? downloadTaskSpecialStatus.downloaded : commonTaskStatus.failed,
|
||||
response: typeof res === 'object' ? JSON.stringify(res) : String(res),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
.catch((err: any) => {
|
||||
this.logger.error(
|
||||
formatError(err, {
|
||||
method: 'downloadBucketFile',
|
||||
class: 'TcyunApi'
|
||||
})
|
||||
class: 'TcyunApi',
|
||||
}),
|
||||
)
|
||||
instance.updateDownloadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: typeof err === 'object' ? JSON.stringify(err) : String(err),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
gotUpload,
|
||||
hmacSha1Base64,
|
||||
md5,
|
||||
NewDownloader
|
||||
NewDownloader,
|
||||
} from '~/manage/utils/common'
|
||||
import { ManageLogger } from '~/manage/utils/logger'
|
||||
import { isImage } from '~/utils/common'
|
||||
@@ -40,7 +40,7 @@ class UpyunApi {
|
||||
password: string,
|
||||
logger: ManageLogger,
|
||||
antiLeechToken?: string,
|
||||
expireTime?: number
|
||||
expireTime?: number,
|
||||
) {
|
||||
this.ser = new Upyun.Service(bucket, operator, password)
|
||||
this.cli = new Upyun.Client(this.ser)
|
||||
@@ -78,7 +78,7 @@ class UpyunApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
Key: key
|
||||
Key: key,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,14 +98,14 @@ class UpyunApi {
|
||||
match: false,
|
||||
isImage: isImage(item.name),
|
||||
url,
|
||||
key
|
||||
key,
|
||||
}
|
||||
}
|
||||
|
||||
authorization(method: string, uri: string, contentMd5: string, operator: string, password: string) {
|
||||
return `UPYUN ${operator}:${hmacSha1Base64(
|
||||
md5(password, 'hex'),
|
||||
`${method.toUpperCase()}&${encodeURI(uri)}&${new Date().toUTCString()}${contentMd5 ? `&${contentMd5}` : ''}`
|
||||
`${method.toUpperCase()}&${encodeURI(uri)}&${new Date().toUTCString()}${contentMd5 ? `&${contentMd5}` : ''}`,
|
||||
)}`
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ class UpyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
const folderQueue = [prefix]
|
||||
const getFolderFile = async (folder: any) => {
|
||||
@@ -141,7 +141,7 @@ class UpyunApi {
|
||||
do {
|
||||
res = await this.cli.listDir(key, {
|
||||
limit: 10000,
|
||||
iter: marker
|
||||
iter: marker,
|
||||
})
|
||||
if (res) {
|
||||
res.files?.forEach((item: any) => {
|
||||
@@ -185,12 +185,12 @@ class UpyunApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
do {
|
||||
res = await this.cli.listDir(prefix, {
|
||||
limit: 10000,
|
||||
iter: marker
|
||||
iter: marker,
|
||||
})
|
||||
if (res) {
|
||||
res.files?.forEach((item: any) => {
|
||||
@@ -236,11 +236,11 @@ class UpyunApi {
|
||||
fullList: [] as any,
|
||||
isTruncated: false,
|
||||
nextMarker: '',
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
res = await this.cli.listDir(prefix, {
|
||||
limit: itemsPerPage,
|
||||
iter: marker || ''
|
||||
iter: marker || '',
|
||||
})
|
||||
if (res) {
|
||||
res.files?.forEach((item: any) => {
|
||||
@@ -278,12 +278,12 @@ class UpyunApi {
|
||||
Authorization: authorization,
|
||||
'X-Upyun-Move-Source': xUpyunMoveSource,
|
||||
'Content-Length': 0,
|
||||
Date: new Date().toUTCString()
|
||||
Date: new Date().toUTCString(),
|
||||
}
|
||||
const res = await axios({
|
||||
method,
|
||||
url: `http://v0.api.upyun.com${uri}`,
|
||||
headers
|
||||
headers,
|
||||
})
|
||||
return res.status === 200
|
||||
}
|
||||
@@ -313,24 +313,24 @@ class UpyunApi {
|
||||
let isTruncated
|
||||
const allFileList = {
|
||||
CommonPrefixes: [] as any[],
|
||||
Contents: [] as any[]
|
||||
Contents: [] as any[],
|
||||
}
|
||||
do {
|
||||
const res = await this.cli.listDir(key, {
|
||||
limit: 10000,
|
||||
iter: marker
|
||||
iter: marker,
|
||||
})
|
||||
if (res) {
|
||||
res.files.forEach((item: any) => {
|
||||
item.type === 'N' &&
|
||||
allFileList.Contents.push({
|
||||
...item,
|
||||
key: `${key}${item.name}`
|
||||
key: `${key}${item.name}`,
|
||||
})
|
||||
item.type === 'F' &&
|
||||
allFileList.CommonPrefixes.push({
|
||||
...item,
|
||||
key: `${key}${item.name}/`
|
||||
key: `${key}${item.name}/`,
|
||||
})
|
||||
})
|
||||
marker = res.next
|
||||
@@ -351,7 +351,7 @@ class UpyunApi {
|
||||
if (allFileList.CommonPrefixes.length > 0) {
|
||||
for (const item of allFileList.CommonPrefixes) {
|
||||
const res = await this.deleteBucketFolder({
|
||||
key: item.key
|
||||
key: item.key,
|
||||
})
|
||||
if (!res) {
|
||||
return false
|
||||
@@ -390,7 +390,7 @@ class UpyunApi {
|
||||
sourceFilePath: filePath,
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region
|
||||
targetFileRegion: region,
|
||||
})
|
||||
const date = new Date().toUTCString()
|
||||
const uri = `/${key}`
|
||||
@@ -400,7 +400,7 @@ class UpyunApi {
|
||||
'save-key': uri,
|
||||
expiration: Math.floor(Date.now() / 1000) + 2592000,
|
||||
date,
|
||||
'content-length': fileSize
|
||||
'content-length': fileSize,
|
||||
}
|
||||
const base64Policy = Buffer.from(JSON.stringify(uplpadPolicy)).toString('base64')
|
||||
const stringToSign = `${method}&/${bucketName}&${date}&${base64Policy}`
|
||||
@@ -411,7 +411,7 @@ class UpyunApi {
|
||||
form.append('authorization', authorization)
|
||||
form.append('file', fs.createReadStream(filePath), {
|
||||
filename: path.basename(key),
|
||||
contentType: getFileMimeType(fileName)
|
||||
contentType: getFileMimeType(fileName),
|
||||
})
|
||||
const headers = form.getHeaders()
|
||||
headers.Host = 'v0.api.upyun.com'
|
||||
@@ -452,7 +452,7 @@ class UpyunApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
const preSignedUrl = `${customUrl}/${key}`
|
||||
promises.push(
|
||||
@@ -465,7 +465,7 @@ class UpyunApi {
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -35,7 +35,7 @@ class WebdavplistApi {
|
||||
sslEnabled: boolean,
|
||||
proxy: string | undefined,
|
||||
authType: 'basic' | 'digest' | undefined,
|
||||
logger: ManageLogger
|
||||
logger: ManageLogger,
|
||||
) {
|
||||
this.endpoint = formatEndpoint(endpoint, sslEnabled)
|
||||
this.username = username
|
||||
@@ -52,7 +52,7 @@ class WebdavplistApi {
|
||||
maxBodyLength: 4 * 1024 * 1024 * 1024,
|
||||
maxContentLength: 4 * 1024 * 1024 * 1024,
|
||||
httpsAgent: sslEnabled ? this.agent : undefined,
|
||||
httpAgent: !sslEnabled ? this.agent : undefined
|
||||
httpAgent: !sslEnabled ? this.agent : undefined,
|
||||
}
|
||||
if (this.authType === 'digest') {
|
||||
options.authType = AuthType.Digest
|
||||
@@ -75,7 +75,7 @@ class WebdavplistApi {
|
||||
checked: false,
|
||||
isImage: false,
|
||||
match: false,
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class WebdavplistApi {
|
||||
checked: false,
|
||||
match: false,
|
||||
isImage: isImage(item.basename),
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`
|
||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,12 +113,12 @@ class WebdavplistApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
res = await this.ctx.getDirectoryContents(prefix, {
|
||||
deep: true,
|
||||
details: true
|
||||
details: true,
|
||||
})
|
||||
if (this.isRequestSuccess(res.status)) {
|
||||
if (res.data?.length) {
|
||||
@@ -158,12 +158,12 @@ class WebdavplistApi {
|
||||
const result = {
|
||||
fullList: [] as any,
|
||||
success: false,
|
||||
finished: false
|
||||
finished: false,
|
||||
}
|
||||
try {
|
||||
res = await this.ctx.getDirectoryContents(prefix, {
|
||||
deep: false,
|
||||
details: true
|
||||
details: true,
|
||||
})
|
||||
if (this.isRequestSuccess(res.status)) {
|
||||
if (res.data?.length) {
|
||||
@@ -263,7 +263,7 @@ class WebdavplistApi {
|
||||
targetFilePath: key,
|
||||
targetFileBucket: bucketName,
|
||||
targetFileRegion: region,
|
||||
noProgress: true
|
||||
noProgress: true,
|
||||
})
|
||||
this.ctx
|
||||
.putFileContents(key, this.authType === 'digest' ? fs.readFileSync(filePath) : fs.createReadStream(filePath), {
|
||||
@@ -272,9 +272,9 @@ class WebdavplistApi {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: Math.floor((progressEvent.loaded / progressEvent.total) * 100),
|
||||
status: uploadTaskSpecialStatus.uploading
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
.then((res: boolean) => {
|
||||
if (res) {
|
||||
@@ -282,14 +282,14 @@ class WebdavplistApi {
|
||||
id,
|
||||
progress: 100,
|
||||
status: uploadTaskSpecialStatus.uploaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
} else {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -299,7 +299,7 @@ class WebdavplistApi {
|
||||
id,
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -311,7 +311,7 @@ class WebdavplistApi {
|
||||
let result = false
|
||||
try {
|
||||
await this.ctx.createDirectory(key, {
|
||||
recursive: true
|
||||
recursive: true,
|
||||
})
|
||||
result = true
|
||||
} catch (error) {
|
||||
@@ -336,16 +336,16 @@ class WebdavplistApi {
|
||||
progress: 0,
|
||||
status: commonTaskStatus.queuing,
|
||||
sourceFileName: fileName,
|
||||
targetFilePath: savedFilePath
|
||||
targetFilePath: savedFilePath,
|
||||
})
|
||||
let preSignedUrl = await this.getPreSignedUrl({
|
||||
key
|
||||
key,
|
||||
})
|
||||
let headers = {} as IStringKeyMap
|
||||
if (this.authType === 'basic' || !this.authType) {
|
||||
const base64Str = Buffer.from(`${this.username}:${this.password}`).toString('base64')
|
||||
headers = {
|
||||
Authorization: `Basic ${base64Str}`
|
||||
Authorization: `Basic ${base64Str}`,
|
||||
}
|
||||
} else if (this.authType === 'digest') {
|
||||
const authHeader = await getAuthHeader(
|
||||
@@ -353,10 +353,10 @@ class WebdavplistApi {
|
||||
this.endpoint,
|
||||
`/${key.replace(/^\/+/, '')}`,
|
||||
this.username,
|
||||
this.password
|
||||
this.password,
|
||||
)
|
||||
headers = {
|
||||
Authorization: authHeader
|
||||
Authorization: authHeader,
|
||||
}
|
||||
preSignedUrl = `${this.endpoint}/${key.replace(/^\/+/, '')}`
|
||||
}
|
||||
@@ -370,9 +370,9 @@ class WebdavplistApi {
|
||||
} else {
|
||||
reject(res)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||
|
||||
@@ -14,7 +14,7 @@ class ManageDB {
|
||||
this.#db = new JSONStore(this.#ctx.configPath)
|
||||
const initParams: IStringKeyMap = {
|
||||
picBed: {},
|
||||
settings: {}
|
||||
settings: {},
|
||||
}
|
||||
for (const key in initParams) {
|
||||
if (!this.#db.has(key)) {
|
||||
|
||||
@@ -18,7 +18,7 @@ let hasCheckPath = false
|
||||
|
||||
const errorMsg = {
|
||||
broken: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT'),
|
||||
brokenButBackup: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP')
|
||||
brokenButBackup: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_BACKUP'),
|
||||
}
|
||||
|
||||
function manageDbChecker() {
|
||||
@@ -30,30 +30,30 @@ function manageDbChecker() {
|
||||
let configFile: string = '{}'
|
||||
const optionsTpl = {
|
||||
title: $t('TIPS_NOTICE'),
|
||||
body: ''
|
||||
body: '',
|
||||
}
|
||||
// config save bak
|
||||
try {
|
||||
configFile = fs.readFileSync(manageConfigFilePath, { encoding: 'utf-8' })
|
||||
JSON.parse(configFile)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
fs.unlinkSync(manageConfigFilePath)
|
||||
if (fs.existsSync(manageConfigFileBackupPath)) {
|
||||
try {
|
||||
configFile = fs.readFileSync(manageConfigFileBackupPath, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
JSON.parse(configFile)
|
||||
writeFile.sync(manageConfigFilePath, configFile, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
const stats = fs.statSync(manageConfigFileBackupPath)
|
||||
optionsTpl.body = `${errorMsg.brokenButBackup}\n${$t('TIPS_PICGO_BACKUP_FILE_VERSION', {
|
||||
v: dayjs(stats.mtime).format('YYYY-MM-DD HH:mm:ss')
|
||||
v: dayjs(stats.mtime).format('YYYY-MM-DD HH:mm:ss'),
|
||||
})}`
|
||||
notificationList.push(optionsTpl)
|
||||
return
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
optionsTpl.body = errorMsg.broken
|
||||
notificationList.push(optionsTpl)
|
||||
return
|
||||
@@ -64,7 +64,7 @@ function manageDbChecker() {
|
||||
return
|
||||
}
|
||||
writeFile.sync(manageConfigFileBackupPath, configFile, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ function managePathChecker(): string {
|
||||
}
|
||||
try {
|
||||
const configString = fs.readFileSync(defaultManageConfigPath, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
})
|
||||
const config = JSON.parse(configString)
|
||||
const userConfigPath: string = config.configPath || ''
|
||||
@@ -102,7 +102,7 @@ function managePathChecker(): string {
|
||||
if (!hasCheckPath) {
|
||||
const optionsTpl = {
|
||||
title: $t('TIPS_NOTICE'),
|
||||
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR')
|
||||
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR'),
|
||||
}
|
||||
notificationList?.push(optionsTpl)
|
||||
hasCheckPath = true
|
||||
|
||||
@@ -108,7 +108,7 @@ class UpDownTaskQueue {
|
||||
item =>
|
||||
item.status !== uploadTaskSpecialStatus.uploaded &&
|
||||
item.status !== commonTaskStatus.canceled &&
|
||||
item.status !== commonTaskStatus.failed
|
||||
item.status !== commonTaskStatus.failed,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class UpDownTaskQueue {
|
||||
item =>
|
||||
item.status !== downloadTaskSpecialStatus.downloaded &&
|
||||
item.status !== commonTaskStatus.canceled &&
|
||||
item.status !== commonTaskStatus.failed
|
||||
item.status !== commonTaskStatus.failed,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ class UpDownTaskQueue {
|
||||
this.persistPath,
|
||||
JSON.stringify({
|
||||
uploadTaskQueue: this.uploadTaskQueue,
|
||||
downloadTaskQueue: this.downloadTaskQueue
|
||||
})
|
||||
downloadTaskQueue: this.downloadTaskQueue,
|
||||
}),
|
||||
)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
@@ -151,7 +151,7 @@ class UpDownTaskQueue {
|
||||
const persistData = JSON.parse(fs.readFileSync(this.persistPath, { encoding: 'utf-8' }))
|
||||
this.uploadTaskQueue = persistData.uploadTaskQueue
|
||||
this.downloadTaskQueue = persistData.downloadTaskQueue
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
this.uploadTaskQueue = []
|
||||
this.downloadTaskQueue = []
|
||||
}
|
||||
@@ -163,19 +163,19 @@ class UpDownTaskQueue {
|
||||
this.persistPath,
|
||||
JSON.stringify({
|
||||
uploadTaskQueue: this.uploadTaskQueue,
|
||||
downloadTaskQueue: this.downloadTaskQueue
|
||||
})
|
||||
downloadTaskQueue: this.downloadTaskQueue,
|
||||
}),
|
||||
)
|
||||
}
|
||||
try {
|
||||
JSON.parse(fs.readFileSync(this.persistPath, { encoding: 'utf-8' }))
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
fs.writeFileSync(
|
||||
this.persistPath,
|
||||
JSON.stringify({
|
||||
uploadTaskQueue: this.uploadTaskQueue,
|
||||
downloadTaskQueue: this.downloadTaskQueue
|
||||
})
|
||||
downloadTaskQueue: this.downloadTaskQueue,
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
's3plist',
|
||||
'webdavplist',
|
||||
'local',
|
||||
'sftp'
|
||||
'sftp',
|
||||
]
|
||||
|
||||
private readonly CLOUD_STORAGE_CLIENTS = ['tcyun', 'aliyun', 'qiniu', 's3plist']
|
||||
@@ -51,7 +51,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
's3plist',
|
||||
'webdavplist',
|
||||
'local',
|
||||
'sftp'
|
||||
'sftp',
|
||||
]
|
||||
|
||||
private readonly FILE_LIST_CLIENTS = ['tcyun', 'aliyun', 'qiniu', 'upyun', 'smms', 's3plist']
|
||||
@@ -70,7 +70,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
return {
|
||||
class: 'ManageApi',
|
||||
method,
|
||||
picbedName: this.currentPicBedConfig.picBedName
|
||||
picbedName: this.currentPicBedConfig.picBedName,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,14 +86,14 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.currentPicBedConfig.token,
|
||||
this.currentPicBedConfig.githubUsername,
|
||||
this.currentPicBedConfig.proxy,
|
||||
this.logger
|
||||
this.logger,
|
||||
),
|
||||
imgur: () =>
|
||||
new API.ImgurApi(
|
||||
this.currentPicBedConfig.imgurUserName,
|
||||
this.currentPicBedConfig.accessToken,
|
||||
this.currentPicBedConfig.proxy,
|
||||
this.logger
|
||||
this.logger,
|
||||
),
|
||||
local: () => new API.LocalApi(this.logger),
|
||||
qiniu: () => new API.QiniuApi(this.currentPicBedConfig.accessKey, this.currentPicBedConfig.secretKey, this.logger),
|
||||
@@ -108,7 +108,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.currentPicBedConfig.proxy,
|
||||
this.logger,
|
||||
this.currentPicBedConfig.dogeCloudSupport || false,
|
||||
this.currentPicBedConfig.bucketName || ''
|
||||
this.currentPicBedConfig.bucketName || '',
|
||||
),
|
||||
sftp: () =>
|
||||
new API.SftpApi(
|
||||
@@ -120,7 +120,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.currentPicBedConfig.passphrase,
|
||||
this.currentPicBedConfig.fileMode,
|
||||
this.currentPicBedConfig.dirMode,
|
||||
this.logger
|
||||
this.logger,
|
||||
),
|
||||
tcyun: () => new API.TcyunApi(this.currentPicBedConfig.secretId, this.currentPicBedConfig.secretKey, this.logger),
|
||||
upyun: () =>
|
||||
@@ -130,7 +130,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.currentPicBedConfig.password,
|
||||
this.logger,
|
||||
this.currentPicBedConfig.antiLeechToken,
|
||||
this.currentPicBedConfig.expireTime
|
||||
this.currentPicBedConfig.expireTime,
|
||||
),
|
||||
webdavplist: () =>
|
||||
new API.WebdavplistApi(
|
||||
@@ -140,8 +140,8 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.currentPicBedConfig.sslEnabled,
|
||||
this.currentPicBedConfig.proxy,
|
||||
this.currentPicBedConfig.authType,
|
||||
this.logger
|
||||
)
|
||||
this.logger,
|
||||
),
|
||||
}
|
||||
|
||||
createClient() {
|
||||
@@ -153,7 +153,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
supportedProviders: string[],
|
||||
method: string,
|
||||
operation: (client: any) => Promise<T>,
|
||||
defaultValue: T
|
||||
defaultValue: T,
|
||||
): Promise<T> {
|
||||
if (!supportedProviders.includes(this.currentPicBedConfig.picBedName)) {
|
||||
return defaultValue
|
||||
@@ -171,7 +171,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||
window.webContents.send(eventName, defaultResult)
|
||||
ipcMain.removeAllListeners(
|
||||
eventName === refreshDownloadFileTransferList ? cancelDownloadLoadingFileList : 'cancelLoadingFileList'
|
||||
eventName === refreshDownloadFileTransferList ? cancelDownloadLoadingFileList : 'cancelLoadingFileList',
|
||||
)
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
smms: [{ Name: 'smms', Location: 'smms', CreationDate: new Date().toISOString() }],
|
||||
webdavplist: [{ Name: 'webdav', Location: 'webdav', CreationDate: new Date().toISOString() }],
|
||||
local: [{ Name: 'local', Location: 'local', CreationDate: new Date().toISOString() }],
|
||||
sftp: [{ Name: 'sftp', Location: 'sftp', CreationDate: new Date().toISOString() }]
|
||||
sftp: [{ Name: 'sftp', Location: 'sftp', CreationDate: new Date().toISOString() }],
|
||||
}
|
||||
|
||||
const staticResult = staticBuckets[this.currentPicBedConfig.picBedName as keyof typeof staticBuckets]
|
||||
@@ -262,7 +262,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
const staticDomains = {
|
||||
upyun: [this.currentPicBedConfig.customUrl],
|
||||
smms: ['https://smms.app'],
|
||||
imgur: ['https://imgur.com']
|
||||
imgur: ['https://imgur.com'],
|
||||
}
|
||||
|
||||
const staticResult = staticDomains[this.currentPicBedConfig.picBedName as keyof typeof staticDomains]
|
||||
@@ -277,7 +277,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.CLOUD_STORAGE_CLIENTS,
|
||||
'createBucket',
|
||||
client => client.createBucket(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -314,9 +314,9 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.ALL_CLIENTS,
|
||||
'getBucketListRecursively',
|
||||
client => client.getBucketListRecursively(param!),
|
||||
defaultResult
|
||||
defaultResult,
|
||||
)
|
||||
} catch (error: any) {
|
||||
} catch (_e: any) {
|
||||
this.sendDefaultResult(refreshDownloadFileTransferList, defaultResult)
|
||||
return {}
|
||||
}
|
||||
@@ -335,9 +335,9 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.ALL_CLIENTS,
|
||||
'getBucketListBackstage',
|
||||
client => client.getBucketListBackstage(param!),
|
||||
defaultResult
|
||||
defaultResult,
|
||||
)
|
||||
} catch (error: any) {
|
||||
} catch (_error: any) {
|
||||
this.sendDefaultResult('refreshFileTransferList', defaultResult)
|
||||
return {}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.FILE_LIST_CLIENTS,
|
||||
'getBucketFileList',
|
||||
client => client.getBucketFileList(param!),
|
||||
defaultResponse
|
||||
defaultResponse,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.ALL_CLIENTS,
|
||||
'deleteBucketFile',
|
||||
client => client.deleteBucketFile(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.FOLDER_SUPPORT_CLIENTS,
|
||||
'deleteBucketFolder',
|
||||
client => client.deleteBucketFolder(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
supportedClients,
|
||||
'renameBucketFile',
|
||||
client => client.renameBucketFile(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.ALL_CLIENTS,
|
||||
'downloadBucketFile',
|
||||
client => client.downloadBucketFile(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.FOLDER_SUPPORT_CLIENTS,
|
||||
'createBucketFolder',
|
||||
client => client.createBucketFolder(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
this.ALL_CLIENTS,
|
||||
'uploadBucketFile',
|
||||
client => client.uploadBucketFile(param!),
|
||||
false
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
||||
supportedClients,
|
||||
'getPreSignedUrl',
|
||||
client => client.getPreSignedUrl(param!),
|
||||
'error'
|
||||
'error',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ export const getFSFile = async (filePath: string, stream: boolean = false): Prom
|
||||
extension: path.extname(filePath),
|
||||
fileName: path.basename(filePath),
|
||||
buffer: stream ? fs.createReadStream(filePath) : await fs.readFile(filePath),
|
||||
success: true
|
||||
success: true,
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
return {
|
||||
success: false
|
||||
success: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ const getTempDirPath = () => {
|
||||
const checkTempFolderExist = async (tempPath: string) => {
|
||||
try {
|
||||
await fs.access(tempPath)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
await fs.mkdir(tempPath)
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ export const downloadFileFromUrl = async (urls: string[]) => {
|
||||
const res = await axios({
|
||||
method: 'get',
|
||||
url,
|
||||
responseType: 'stream'
|
||||
responseType: 'stream',
|
||||
})
|
||||
res.data.pipe(writer)
|
||||
await finishDownload(writer)
|
||||
@@ -87,7 +87,7 @@ export const NewDownloader = async (
|
||||
savedFilePath: string,
|
||||
logger?: ManageLogger,
|
||||
proxy?: string,
|
||||
headers?: any
|
||||
headers?: any,
|
||||
): Promise<boolean> => {
|
||||
const options = {
|
||||
url: encodeURI(preSignedUrl),
|
||||
@@ -98,10 +98,10 @@ export const NewDownloader = async (
|
||||
instance.updateDownloadTask({
|
||||
id,
|
||||
progress: Math.floor(Number(percentage)),
|
||||
status: downloadTaskSpecialStatus.downloading
|
||||
status: downloadTaskSpecialStatus.downloading,
|
||||
})
|
||||
},
|
||||
maxAttempts: 3
|
||||
maxAttempts: 3,
|
||||
} as any
|
||||
if (proxy) {
|
||||
options.proxy = proxy
|
||||
@@ -116,7 +116,7 @@ export const NewDownloader = async (
|
||||
id,
|
||||
progress: 100,
|
||||
status: downloadTaskSpecialStatus.downloaded,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
return true
|
||||
} catch (e: any) {
|
||||
@@ -127,7 +127,7 @@ export const NewDownloader = async (
|
||||
progress: 0,
|
||||
status: commonTaskStatus.failed,
|
||||
response: formatError(e, { method: 'NewDownloader' }),
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
return false
|
||||
}
|
||||
@@ -143,23 +143,23 @@ export const gotUpload = async (
|
||||
logger?: ManageLogger,
|
||||
timeout: number = 30000,
|
||||
throwHttpErrors: boolean = false,
|
||||
agent: any = {}
|
||||
agent: any = {},
|
||||
) => {
|
||||
got(url, {
|
||||
headers,
|
||||
method,
|
||||
body,
|
||||
timeout: {
|
||||
lookup: timeout
|
||||
lookup: timeout,
|
||||
},
|
||||
throwHttpErrors,
|
||||
agent
|
||||
agent,
|
||||
})
|
||||
.on('uploadProgress', (progress: any) => {
|
||||
instance.updateUploadTask({
|
||||
id,
|
||||
progress: Math.floor(progress.percent * 100),
|
||||
status: uploadTaskSpecialStatus.uploading
|
||||
status: uploadTaskSpecialStatus.uploading,
|
||||
})
|
||||
})
|
||||
.then((res: any) => {
|
||||
@@ -170,7 +170,7 @@ export const gotUpload = async (
|
||||
res?.statusCode === 200 || res?.statusCode === 201
|
||||
? uploadTaskSpecialStatus.uploaded
|
||||
: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
.catch((err: any) => {
|
||||
@@ -180,7 +180,7 @@ export const gotUpload = async (
|
||||
progress: 0,
|
||||
response: formatError(err, { method: 'gotUpload' }),
|
||||
status: commonTaskStatus.failed,
|
||||
finishTime: new Date().toLocaleString()
|
||||
finishTime: new Date().toLocaleString(),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -193,14 +193,14 @@ export const formatError = (err: any, params: IStringKeyMap) => {
|
||||
name: 'RequestError',
|
||||
code: err.code,
|
||||
stack: err.stack ?? '',
|
||||
timings: err.timings ?? {}
|
||||
timings: err.timings ?? {},
|
||||
}
|
||||
} else if (err instanceof Error) {
|
||||
return {
|
||||
...params,
|
||||
name: err.name ?? '',
|
||||
message: err.message ?? '',
|
||||
stack: err.stack ?? ''
|
||||
stack: err.stack ?? '',
|
||||
}
|
||||
}
|
||||
if (typeof err === 'object') {
|
||||
@@ -212,12 +212,12 @@ export const formatError = (err: any, params: IStringKeyMap) => {
|
||||
const commonOptions = {
|
||||
keepAlive: true,
|
||||
keepAliveMsecs: 1000,
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
|
||||
} as any
|
||||
|
||||
export const getAgent = (
|
||||
proxy: any,
|
||||
https: boolean = true
|
||||
https: boolean = true,
|
||||
): {
|
||||
https?: HttpsProxyAgent
|
||||
http?: HttpProxyAgent
|
||||
@@ -225,7 +225,7 @@ export const getAgent = (
|
||||
const formatProxy = formatHttpProxy(proxy, 'string') as any
|
||||
const commonResult = {
|
||||
https: undefined,
|
||||
http: undefined
|
||||
http: undefined,
|
||||
}
|
||||
if (!formatProxy) return commonResult
|
||||
commonOptions.proxy = formatProxy.replace('127.0.0.1', 'localhost')
|
||||
@@ -233,16 +233,16 @@ export const getAgent = (
|
||||
return {
|
||||
https: new HttpsProxyAgent({
|
||||
...commonOptions,
|
||||
rejectUnauthorized: false
|
||||
rejectUnauthorized: false,
|
||||
}),
|
||||
http: undefined
|
||||
http: undefined,
|
||||
}
|
||||
}
|
||||
return {
|
||||
http: new HttpProxyAgent({
|
||||
...commonOptions
|
||||
...commonOptions,
|
||||
}),
|
||||
https: undefined
|
||||
https: undefined,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,14 +255,14 @@ export const getInnerAgent = (proxy: any, sslEnabled: boolean = true) => {
|
||||
...commonOptions,
|
||||
rejectUnauthorized: false,
|
||||
host: formatProxy.host,
|
||||
port: formatProxy.port
|
||||
})
|
||||
port: formatProxy.port,
|
||||
}),
|
||||
}
|
||||
: {
|
||||
agent: new https.Agent({
|
||||
rejectUnauthorized: false,
|
||||
keepAlive: true
|
||||
})
|
||||
keepAlive: true,
|
||||
}),
|
||||
}
|
||||
}
|
||||
return formatProxy
|
||||
@@ -270,13 +270,13 @@ export const getInnerAgent = (proxy: any, sslEnabled: boolean = true) => {
|
||||
agent: new http.Agent({
|
||||
...commonOptions,
|
||||
host: formatProxy.host,
|
||||
port: formatProxy.port
|
||||
})
|
||||
port: formatProxy.port,
|
||||
}),
|
||||
}
|
||||
: {
|
||||
agent: new http.Agent({
|
||||
...commonOptions
|
||||
})
|
||||
...commonOptions,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ export function getOptions(
|
||||
responseType?: string,
|
||||
body?: any,
|
||||
timeout?: number,
|
||||
proxy?: any
|
||||
proxy?: any,
|
||||
): OptionsOfTextResponseBody {
|
||||
return {
|
||||
...(method && { method: method.toUpperCase() }),
|
||||
@@ -297,9 +297,9 @@ export function getOptions(
|
||||
...(responseType && { responseType }),
|
||||
...(timeout !== undefined ? { timeout: { request: timeout } } : { timeout: { request: 30000 } }),
|
||||
...(proxy && {
|
||||
agent: Object.fromEntries(Object.entries(getAgent(proxy)).filter(([, v]) => v !== undefined))
|
||||
agent: Object.fromEntries(Object.entries(getAgent(proxy)).filter(([, v]) => v !== undefined)),
|
||||
}),
|
||||
throwHttpErrors: false
|
||||
throwHttpErrors: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function dogecloudApi(
|
||||
data = {},
|
||||
jsonMode: boolean = false,
|
||||
accessKey: string,
|
||||
secretKey: string
|
||||
secretKey: string,
|
||||
) {
|
||||
const body = jsonMode ? JSON.stringify(data) : querystring.encode(data)
|
||||
const sign = crypto
|
||||
@@ -33,14 +33,14 @@ export async function dogecloudApi(
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Content-Type': jsonMode ? 'application/json' : 'application/x-www-form-urlencoded',
|
||||
Authorization: authorization
|
||||
}
|
||||
Authorization: authorization,
|
||||
},
|
||||
})
|
||||
if (res.data.code !== 200) {
|
||||
throw new Error('API Error')
|
||||
}
|
||||
return res.data.data
|
||||
} catch (err: any) {
|
||||
} catch (_e: any) {
|
||||
throw new Error('API Error')
|
||||
}
|
||||
}
|
||||
@@ -55,23 +55,23 @@ export async function getTempToken(accessKey: string, secretKey: string): Promis
|
||||
'/auth/tmp_token.json',
|
||||
{
|
||||
channel: 'OSS_FULL',
|
||||
scopes: ['*']
|
||||
scopes: ['*'],
|
||||
},
|
||||
true,
|
||||
accessKey,
|
||||
secretKey
|
||||
secretKey,
|
||||
)
|
||||
const token = data.Credentials
|
||||
picgo.saveConfig({
|
||||
Credentials: {
|
||||
'doge-token': {
|
||||
token,
|
||||
expires: data.ExpiredAt * 1000
|
||||
}
|
||||
}
|
||||
expires: data.ExpiredAt * 1000,
|
||||
},
|
||||
},
|
||||
})
|
||||
return token
|
||||
} catch (err: any) {
|
||||
} catch (_e: any) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ManageLogger implements ILogger {
|
||||
[ILogType.success]: 'green',
|
||||
[ILogType.info]: 'blue',
|
||||
[ILogType.warn]: 'yellow',
|
||||
[ILogType.error]: 'red'
|
||||
[ILogType.error]: 'red',
|
||||
}
|
||||
|
||||
readonly #ctx: IManageApiType
|
||||
@@ -67,12 +67,12 @@ export class ManageLogger implements ILogger {
|
||||
return {
|
||||
isLarge: logFileSize > logFileSizeLimit,
|
||||
logFileSize,
|
||||
logFileSizeLimit
|
||||
logFileSizeLimit,
|
||||
}
|
||||
}
|
||||
fs.ensureFileSync(logPath)
|
||||
return {
|
||||
isLarge: false
|
||||
isLarge: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,20 +21,20 @@ const serverTempDir = path.join(appPath, 'serverTemp')
|
||||
fs.ensureDirSync(serverTempDir)
|
||||
|
||||
const multerStorage = multer.diskStorage({
|
||||
destination: function (_req: any, _file: any, cb: (arg0: null, arg1: any) => void) {
|
||||
destination(_req: any, _file: any, cb: (arg0: null, arg1: any) => void) {
|
||||
fs.ensureDirSync(serverTempDir)
|
||||
cb(null, serverTempDir)
|
||||
},
|
||||
filename: function (_req: any, file: { originalname: any }, cb: (arg0: null, arg1: any) => void) {
|
||||
filename(_req: any, file: { originalname: any }, cb: (arg0: null, arg1: any) => void) {
|
||||
if (!/[^\u0000-\u00ff]/.test(file.originalname)) {
|
||||
file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf8')
|
||||
}
|
||||
cb(null, file.originalname)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const uploadMulter = multer({
|
||||
storage: multerStorage
|
||||
storage: multerStorage,
|
||||
})
|
||||
|
||||
class Server {
|
||||
@@ -85,8 +85,8 @@ class Server {
|
||||
response,
|
||||
statusCode: 404,
|
||||
body: {
|
||||
success: false
|
||||
}
|
||||
success: false,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
const remoteAddress = request.socket.remoteAddress || 'unknown'
|
||||
@@ -109,8 +109,8 @@ class Server {
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: 'Error processing formData'
|
||||
}
|
||||
message: 'Error processing formData',
|
||||
},
|
||||
})
|
||||
}
|
||||
// @ts-expect-error since the multer type is not correct
|
||||
@@ -121,7 +121,7 @@ class Server {
|
||||
handler({
|
||||
list,
|
||||
response,
|
||||
urlparams: urlSP
|
||||
urlparams: urlSP,
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -140,8 +140,8 @@ class Server {
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: 'Not sending data in JSON format'
|
||||
}
|
||||
message: 'Not sending data in JSON format',
|
||||
},
|
||||
})
|
||||
}
|
||||
logger.info('[PicList Server] get the request', body)
|
||||
@@ -149,7 +149,7 @@ class Server {
|
||||
handler!({
|
||||
...postObj,
|
||||
response,
|
||||
urlparams: urlSP
|
||||
urlparams: urlSP,
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class Server {
|
||||
if (handler) {
|
||||
handler({
|
||||
response,
|
||||
urlparams: query ? new URLSearchParams(query) : undefined
|
||||
urlparams: query ? new URLSearchParams(query) : undefined,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ class Server {
|
||||
await axios.post(ensureHTTPLink(`${this.#config.host}:${port}/heartbeat`))
|
||||
logger.info(`[PicList Server] server is already running at ${port}`)
|
||||
this.shutdown(true)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
logger.warn(`[PicList Server] ${port} is busy, trying with port ${(port as number) + 1}`)
|
||||
// fix a bug: not write an increase number to config file
|
||||
// to solve the auto number problem
|
||||
|
||||
@@ -42,7 +42,7 @@ router.post(
|
||||
async ({
|
||||
response,
|
||||
list = [],
|
||||
urlparams
|
||||
urlparams,
|
||||
}: {
|
||||
response: IHttpResponse
|
||||
list?: string[]
|
||||
@@ -58,8 +58,8 @@ router.post(
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: 'server key is uncorrect'
|
||||
}
|
||||
message: 'server key is uncorrect',
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -99,7 +99,7 @@ router.post(
|
||||
const treatedFullResult = {
|
||||
isEncrypted: 1,
|
||||
EncryptedData: new AESHelper().encrypt(JSON.stringify(fullResult)),
|
||||
...fullResult
|
||||
...fullResult,
|
||||
}
|
||||
delete treatedFullResult.config
|
||||
handleResponse({
|
||||
@@ -107,16 +107,16 @@ router.post(
|
||||
body: {
|
||||
success: true,
|
||||
result: [res],
|
||||
fullResult: [treatedFullResult]
|
||||
}
|
||||
fullResult: [treatedFullResult],
|
||||
},
|
||||
})
|
||||
} else {
|
||||
handleResponse({
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: errorMessage
|
||||
}
|
||||
message: errorMessage,
|
||||
},
|
||||
})
|
||||
}
|
||||
} else {
|
||||
@@ -124,7 +124,7 @@ router.post(
|
||||
// upload with files
|
||||
const pathList = list.map(item => {
|
||||
return {
|
||||
path: item
|
||||
path: item,
|
||||
}
|
||||
})
|
||||
const win = windowManager.getAvailableWindow()
|
||||
@@ -136,7 +136,7 @@ router.post(
|
||||
const treatedItem = {
|
||||
isEncrypted: 1,
|
||||
EncryptedData: new AESHelper().encrypt(JSON.stringify(item.fullResult)),
|
||||
...item.fullResult
|
||||
...item.fullResult,
|
||||
}
|
||||
delete treatedItem.config
|
||||
treatedItem.imgUrl = useShortUrl ? treatedItem.shortUrl || treatedItem.imgUrl : treatedItem.imgUrl
|
||||
@@ -149,16 +149,16 @@ router.post(
|
||||
body: {
|
||||
success: true,
|
||||
result: res,
|
||||
fullResult
|
||||
}
|
||||
fullResult,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
handleResponse({
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: errorMessage
|
||||
}
|
||||
message: errorMessage,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -172,11 +172,11 @@ router.post(
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: errorMessage
|
||||
}
|
||||
message: errorMessage,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
router.post(
|
||||
@@ -187,8 +187,8 @@ router.post(
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: 'no file to delete'
|
||||
}
|
||||
message: 'no file to delete',
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -205,8 +205,8 @@ router.post(
|
||||
response,
|
||||
body: {
|
||||
success: !!successCount,
|
||||
message: successCount ? `delete success: ${successCount}, fail: ${failCount}` : deleteErrorMessage
|
||||
}
|
||||
message: successCount ? `delete success: ${successCount}, fail: ${failCount}` : deleteErrorMessage,
|
||||
},
|
||||
})
|
||||
} catch (err: any) {
|
||||
logger.error(err)
|
||||
@@ -214,11 +214,11 @@ router.post(
|
||||
response,
|
||||
body: {
|
||||
success: false,
|
||||
message: deleteErrorMessage
|
||||
}
|
||||
message: deleteErrorMessage,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
router.any('/heartbeat', async ({ response }: { response: IHttpResponse }) => {
|
||||
@@ -226,8 +226,8 @@ router.any('/heartbeat', async ({ response }: { response: IHttpResponse }) => {
|
||||
response,
|
||||
body: {
|
||||
success: true,
|
||||
result: 'alive'
|
||||
}
|
||||
result: 'alive',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ export const handleResponse = ({
|
||||
'Content-Type': 'application/json',
|
||||
'access-control-allow-headers': '*',
|
||||
'access-control-allow-methods': 'POST, GET, OPTIONS',
|
||||
'access-control-allow-origin': '*'
|
||||
'access-control-allow-origin': '*',
|
||||
},
|
||||
body = {
|
||||
success: false
|
||||
}
|
||||
success: false,
|
||||
},
|
||||
}: {
|
||||
response: IHttpResponse
|
||||
statusCode?: number
|
||||
@@ -55,7 +55,7 @@ export const deleteChoosedFiles = async (list: ImgInfo[]): Promise<boolean[]> =>
|
||||
const noteFunc = (value: boolean) => {
|
||||
const notification = new Notification({
|
||||
title: $t('MANAGE_BUCKET_BATCH_DELETE_ERROR_MSG_MSG2'),
|
||||
body: $t(value ? 'GALLERY_SYNC_DELETE_NOTICE_SUCCEED' : 'GALLERY_SYNC_DELETE_NOTICE_FAILED')
|
||||
body: $t(value ? 'GALLERY_SYNC_DELETE_NOTICE_SUCCEED' : 'GALLERY_SYNC_DELETE_NOTICE_FAILED'),
|
||||
})
|
||||
notification.show()
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export const deleteChoosedFiles = async (list: ImgInfo[]): Promise<boolean[]> =>
|
||||
picgo.emit(ICOREBuildInEvent.REMOVE, [file], GuiApi.getInstance())
|
||||
}, 500)
|
||||
result.push(true)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
result.push(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,13 +383,13 @@ function generateDirectoryListingHtml(files: any[], requestPath: string, fullPat
|
||||
? new Date(fileInfo.mtime).toLocaleDateString('en-US', {
|
||||
year: '2-digit',
|
||||
month: 'numeric',
|
||||
day: 'numeric'
|
||||
day: 'numeric',
|
||||
}) +
|
||||
' ' +
|
||||
new Date(fileInfo.mtime).toLocaleTimeString('en-US', {
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
hour12: true
|
||||
hour12: true,
|
||||
})
|
||||
: ''
|
||||
|
||||
@@ -454,7 +454,7 @@ function sortFiles(files: string[], fullPath: string): any[] {
|
||||
let stats
|
||||
try {
|
||||
stats = fs.statSync(filePath)
|
||||
} catch (err) {
|
||||
} catch (_e) {
|
||||
stats = null
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ function sortFiles(files: string[], fullPath: string): any[] {
|
||||
name: file,
|
||||
isDirectory: stats ? stats.isDirectory() : false,
|
||||
size: stats ? stats.size : 0,
|
||||
mtime: stats ? stats.mtime : null
|
||||
mtime: stats ? stats.mtime : null,
|
||||
}
|
||||
})
|
||||
.sort((a, b) => {
|
||||
@@ -474,25 +474,25 @@ function sortFiles(files: string[], fullPath: string): any[] {
|
||||
})
|
||||
}
|
||||
|
||||
function generateErrorPage(errorCode: number, errorMessage: string): string {
|
||||
const errorDescriptions: { [key: number]: { title: string; description: string } } = {
|
||||
function generateErrorPage(errorCode: number, _e: string): string {
|
||||
const errorDescriptions: Record<number, { title: string; description: string }> = {
|
||||
404: {
|
||||
title: 'Page Not Found',
|
||||
description: 'The file or directory you are looking for could not be found.'
|
||||
description: 'The file or directory you are looking for could not be found.',
|
||||
},
|
||||
500: {
|
||||
title: 'Server Error',
|
||||
description: 'An internal server error occurred while processing your request.'
|
||||
description: 'An internal server error occurred while processing your request.',
|
||||
},
|
||||
403: {
|
||||
title: 'Access Denied',
|
||||
description: 'You do not have permission to access this resource.'
|
||||
}
|
||||
description: 'You do not have permission to access this resource.',
|
||||
},
|
||||
}
|
||||
|
||||
const error = errorDescriptions[errorCode] || {
|
||||
title: 'Unknown Error',
|
||||
description: 'An unexpected error occurred.'
|
||||
description: 'An unexpected error occurred.',
|
||||
}
|
||||
|
||||
return `
|
||||
@@ -622,7 +622,7 @@ function serveFile(res: http.ServerResponse, filePath: fs.PathLike) {
|
||||
const readStream = fs.createReadStream(filePath)
|
||||
|
||||
const ext = path.extname(filePath.toString()).toLowerCase()
|
||||
const contentTypes: { [key: string]: string } = {
|
||||
const contentTypes: Record<string, string> = {
|
||||
'.html': 'text/html',
|
||||
'.css': 'text/css',
|
||||
'.js': 'application/javascript',
|
||||
@@ -634,7 +634,7 @@ function serveFile(res: http.ServerResponse, filePath: fs.PathLike) {
|
||||
'.svg': 'image/svg+xml',
|
||||
'.pdf': 'application/pdf',
|
||||
'.txt': 'text/plain',
|
||||
'.md': 'text/markdown'
|
||||
'.md': 'text/markdown',
|
||||
}
|
||||
|
||||
const contentType = contentTypes[ext] || 'application/octet-stream'
|
||||
@@ -662,7 +662,7 @@ class WebServer {
|
||||
enableWebServer: picgo.getConfig<boolean>(configPaths.settings.enableWebServer) || false,
|
||||
webServerHost: picgo.getConfig<string>(configPaths.settings.webServerHost) || '0.0.0.0',
|
||||
webServerPort: picgo.getConfig<number>(configPaths.settings.webServerPort) || 37777,
|
||||
webServerPath: picgo.getConfig<string>(configPaths.settings.webServerPath) || defaultPath
|
||||
webServerPath: picgo.getConfig<string>(configPaths.settings.webServerPath) || defaultPath,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,7 +678,7 @@ class WebServer {
|
||||
} else {
|
||||
serveFile(res, filePath)
|
||||
}
|
||||
} catch (err) {
|
||||
} catch (_e) {
|
||||
logger.error(`File not found: ${filePath}`)
|
||||
res.writeHead(404, { 'Content-Type': 'text/html' })
|
||||
res.end(generateErrorPage(404, 'The requested file or directory was not found'))
|
||||
@@ -694,9 +694,9 @@ class WebServer {
|
||||
this.#config.webServerHost,
|
||||
() => {
|
||||
logger.info(
|
||||
`Web server is running at http://${this.#config.webServerHost}:${this.#config.webServerPort}, root path is ${this.#config.webServerPath}`
|
||||
`Web server is running at http://${this.#config.webServerHost}:${this.#config.webServerPort}, root path is ${this.#config.webServerPath}`,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
.on('error', err => {
|
||||
logger.error(err)
|
||||
|
||||
@@ -8,7 +8,7 @@ export const setAutoStart = async (enable: boolean): Promise<void> => {
|
||||
try {
|
||||
if (process.platform !== 'linux') {
|
||||
app.setLoginItemSettings({
|
||||
openAtLogin: enable
|
||||
openAtLogin: enable,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ function copyFileOutsideOfElectronAsar(sourceInAsarArchive: string, destOutsideA
|
||||
fs.readdirSync(sourceInAsarArchive).forEach(function (fileOrFolderName) {
|
||||
copyFileOutsideOfElectronAsar(
|
||||
`${sourceInAsarArchive}/${fileOrFolderName}`,
|
||||
`${destOutsideAsarArchive}/${fileOrFolderName}`
|
||||
`${destOutsideAsarArchive}/${fileOrFolderName}`,
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -52,7 +52,7 @@ function resolveMacWorkFlow() {
|
||||
path
|
||||
.join(__dirname, '../../resources', 'Upload pictures with PicList.workflow')
|
||||
.replace('app.asar', 'app.asar.unpacked'),
|
||||
dest
|
||||
dest,
|
||||
)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
@@ -94,7 +94,7 @@ function resolveClipboardImageGenerator() {
|
||||
return files.map(item => {
|
||||
return {
|
||||
origin: path.join(__dirname, '../../resources', item).replace('app.asar', 'app.asar.unpacked'),
|
||||
dest: path.join(CONFIG_DIR, item)
|
||||
dest: path.join(CONFIG_DIR, item),
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -110,7 +110,7 @@ function resolveOtherI18nFiles() {
|
||||
}
|
||||
i18nManager.setOutterI18nFolder(i18nFolder)
|
||||
const i18nFiles = fs.readdirSync(path.join(CONFIG_DIR, 'i18n'), {
|
||||
withFileTypes: true
|
||||
withFileTypes: true,
|
||||
})
|
||||
i18nFiles.forEach(item => {
|
||||
if (item.isFile() && item.name?.endsWith('.yml')) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import logger from '@core/picgo/logger'
|
||||
import { clipboard, NativeImage } from 'electron'
|
||||
|
||||
class ClipboardWatcher extends EventEmitter {
|
||||
// eslint-disable-next-line no-undef
|
||||
timer: NodeJS.Timeout | null
|
||||
lastImageHash: string | null
|
||||
|
||||
|
||||
@@ -64,12 +64,12 @@ export const showNotification = (
|
||||
body: '',
|
||||
clickToCopy: false,
|
||||
copyContent: '',
|
||||
clickFn: () => {}
|
||||
}
|
||||
clickFn: () => {},
|
||||
},
|
||||
) => {
|
||||
const notification = new Notification({
|
||||
title: options.title,
|
||||
body: options.body
|
||||
body: options.body,
|
||||
})
|
||||
const handleClick = () => {
|
||||
if (options.clickToCopy) {
|
||||
@@ -141,8 +141,8 @@ const createC1NShortUrl = async (url: string) => {
|
||||
form.append('url', url)
|
||||
const res = await axios.post(c1nApi, form, {
|
||||
headers: {
|
||||
token: c1nToken
|
||||
}
|
||||
token: c1nToken,
|
||||
},
|
||||
})
|
||||
if (res.status >= 200 && res.status < 300 && res.data?.code === 0) {
|
||||
return res.data.data
|
||||
@@ -168,7 +168,7 @@ const createYOURLSShortLink = async (url: string) => {
|
||||
signature,
|
||||
action: 'shorturl',
|
||||
format: 'json',
|
||||
url
|
||||
url,
|
||||
})
|
||||
try {
|
||||
const res = await axios.get(`${domain}/yourls-api.php?${params.toString()}`)
|
||||
@@ -222,7 +222,7 @@ const createShortUrlFromSink = async (url: string) => {
|
||||
const res = await axios.post(
|
||||
`${sinkDomain}/api/link/create`,
|
||||
{ url },
|
||||
{ headers: { Authorization: `Bearer ${sinkToken}` } }
|
||||
{ headers: { Authorization: `Bearer ${sinkToken}` } },
|
||||
)
|
||||
if (res.data?.link?.slug) {
|
||||
return `${sinkDomain}/${res.data.link.slug}`
|
||||
@@ -276,10 +276,10 @@ export const simpleClone = (obj: any) => JSON.parse(JSON.stringify(obj))
|
||||
export const enforceNumber = (num: number | string) => (isNaN(+num) ? 0 : +num)
|
||||
|
||||
export const trimValues = <T extends IStringKeyMap>(
|
||||
obj: T
|
||||
obj: T,
|
||||
): { [K in keyof T]: T[K] extends string ? string : T[K] } => {
|
||||
return Object.fromEntries(
|
||||
Object.entries(obj).map(([key, value]) => [key, typeof value === 'string' ? value.trim() : value])
|
||||
Object.entries(obj).map(([key, value]) => [key, typeof value === 'string' ? value.trim() : value]),
|
||||
) as { [K in keyof T]: T[K] extends string ? string : T[K] }
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ export const formatEndpoint = (endpoint: string, sslEnabled: boolean): string =>
|
||||
|
||||
export const formatHttpProxy = (
|
||||
proxy: string | undefined,
|
||||
type: 'object' | 'string'
|
||||
type: 'object' | 'string',
|
||||
): IHTTPProxy | undefined | string => {
|
||||
if (!proxy) return undefined
|
||||
if (/^https?:\/\//.test(proxy)) {
|
||||
@@ -303,7 +303,7 @@ export const formatHttpProxy = (
|
||||
: {
|
||||
host: hostname,
|
||||
port: Number(port),
|
||||
protocol: protocol.slice(0, -1)
|
||||
protocol: protocol.slice(0, -1),
|
||||
}
|
||||
}
|
||||
const [host, port] = proxy.split(':')
|
||||
@@ -312,7 +312,7 @@ export const formatHttpProxy = (
|
||||
: {
|
||||
host,
|
||||
port: port ? Number(port) : 80,
|
||||
protocol: 'http'
|
||||
protocol: 'http',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,12 @@ import type {
|
||||
ITcYunConfig,
|
||||
IUploaderConfig,
|
||||
IUpYunConfig,
|
||||
IWebdavPlistConfig
|
||||
IWebdavPlistConfig,
|
||||
} from '#/types/types'
|
||||
|
||||
export type manualPageOpenType = 'window' | 'browser'
|
||||
|
||||
interface IPicGoPlugins {
|
||||
[key: `picgo-plugin-${string}`]: boolean
|
||||
}
|
||||
type IPicGoPlugins = Record<`picgo-plugin-${string}`, boolean>
|
||||
|
||||
export interface IConfigStruct {
|
||||
picBed: {
|
||||
@@ -48,9 +46,7 @@ export interface IConfigStruct {
|
||||
[others: string]: any
|
||||
}
|
||||
settings: {
|
||||
shortKey: {
|
||||
[key: string]: IShortKeyConfig
|
||||
}
|
||||
shortKey: Record<string, IShortKeyConfig>
|
||||
logLevel: string[]
|
||||
logPath: string
|
||||
logFileSizeLimit: number
|
||||
@@ -132,12 +128,12 @@ export const configPaths = {
|
||||
secondUploaderConfig: 'picBed.secondUploaderConfig',
|
||||
proxy: 'picBed.proxy',
|
||||
transformer: 'picBed.transformer',
|
||||
list: 'picBed.list'
|
||||
list: 'picBed.list',
|
||||
},
|
||||
settings: {
|
||||
shortKey: {
|
||||
_path: 'settings.shortKey',
|
||||
'picgo:upload': 'settings.shortKey[picgo:upload]'
|
||||
'picgo:upload': 'settings.shortKey[picgo:upload]',
|
||||
},
|
||||
logLevel: 'settings.logLevel',
|
||||
logPath: 'settings.logPath',
|
||||
@@ -192,7 +188,7 @@ export const configPaths = {
|
||||
autoImport: 'settings.autoImport',
|
||||
autoImportPicBed: 'settings.autoImportPicBed',
|
||||
galleryPicBedFilter: 'settings.galleryPicBedFilter',
|
||||
enableSecondUploader: 'settings.enableSecondUploader'
|
||||
enableSecondUploader: 'settings.enableSecondUploader',
|
||||
},
|
||||
needReload: 'needReload',
|
||||
picgoPlugins: 'picgoPlugins',
|
||||
@@ -201,8 +197,8 @@ export const configPaths = {
|
||||
compress: 'buildIn.compress',
|
||||
watermark: 'buildIn.watermark',
|
||||
rename: 'buildIn.rename',
|
||||
skipProcess: 'buildIn.skipProcess'
|
||||
skipProcess: 'buildIn.skipProcess',
|
||||
},
|
||||
debug: 'debug',
|
||||
PICGO_ENV: 'PICGO_ENV'
|
||||
PICGO_ENV: 'PICGO_ENV',
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ const dogeRegionMap: IStringKeyMap = {
|
||||
'ap-shanghai': '0',
|
||||
'ap-beijing': '1',
|
||||
'ap-guangzhou': '2',
|
||||
'ap-chengdu': '3'
|
||||
'ap-chengdu': '3',
|
||||
}
|
||||
|
||||
async function dogecloudApi(
|
||||
@@ -41,7 +41,7 @@ async function dogecloudApi(
|
||||
data = {},
|
||||
jsonMode: boolean = false,
|
||||
accessKey: string,
|
||||
secretKey: string
|
||||
secretKey: string,
|
||||
) {
|
||||
const body = jsonMode ? JSON.stringify(data) : querystring.encode(data)
|
||||
const sign = crypto
|
||||
@@ -57,14 +57,14 @@ async function dogecloudApi(
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Content-Type': jsonMode ? 'application/json' : 'application/x-www-form-urlencoded',
|
||||
Authorization: authorization
|
||||
}
|
||||
Authorization: authorization,
|
||||
},
|
||||
})
|
||||
if (res.data.code !== 200) {
|
||||
throw new Error('API Error')
|
||||
}
|
||||
return res.data.data
|
||||
} catch (err: any) {
|
||||
} catch (_err: any) {
|
||||
throw new Error('API Error')
|
||||
}
|
||||
}
|
||||
@@ -75,11 +75,11 @@ async function getDogeToken(accessKey: string, secretKey: string): Promise<IObj
|
||||
'/auth/tmp_token.json',
|
||||
{
|
||||
channel: 'OSS_FULL',
|
||||
scopes: ['*']
|
||||
scopes: ['*'],
|
||||
},
|
||||
true,
|
||||
accessKey,
|
||||
secretKey
|
||||
secretKey,
|
||||
)
|
||||
return data
|
||||
} catch (err: any) {
|
||||
@@ -100,12 +100,12 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
||||
pathStyleAccess,
|
||||
rejectUnauthorized,
|
||||
proxy,
|
||||
urlPrefix
|
||||
}
|
||||
urlPrefix,
|
||||
},
|
||||
} = configMap
|
||||
let {
|
||||
imgUrl,
|
||||
config: { region }
|
||||
config: { region },
|
||||
} = configMap
|
||||
if (type === 'aws-s3' || type === 'aws-s3-plist') {
|
||||
imgUrl = rawUrl || imgUrl || ''
|
||||
@@ -139,7 +139,7 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
||||
const commonOptions: AgentOptions = {
|
||||
keepAlive: true,
|
||||
keepAliveMsecs: 1000,
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined
|
||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
|
||||
}
|
||||
const extraOptions = sslEnabled ? { rejectUnauthorized: !!rejectUnauthorized } : {}
|
||||
const handler = sslEnabled
|
||||
@@ -148,52 +148,52 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
||||
? agent.https
|
||||
: new https.Agent({
|
||||
...commonOptions,
|
||||
...extraOptions
|
||||
})
|
||||
...extraOptions,
|
||||
}),
|
||||
})
|
||||
: new NodeHttpHandler({
|
||||
httpAgent: agent.http
|
||||
? agent.http
|
||||
: new http.Agent({
|
||||
...commonOptions,
|
||||
...extraOptions
|
||||
})
|
||||
...extraOptions,
|
||||
}),
|
||||
})
|
||||
const s3Options: S3ClientConfig = {
|
||||
credentials: {
|
||||
accessKeyId: accessKeyID,
|
||||
secretAccessKey
|
||||
secretAccessKey,
|
||||
},
|
||||
endpoint: endpointUrl,
|
||||
tls: sslEnabled,
|
||||
forcePathStyle: pathStyleAccess,
|
||||
region,
|
||||
requestHandler: handler
|
||||
requestHandler: handler,
|
||||
}
|
||||
if (dogeMode) {
|
||||
s3Options.credentials = {
|
||||
accessKeyId: configMap.config.accessKeyID,
|
||||
secretAccessKey: configMap.config.secretAccessKey,
|
||||
sessionToken: configMap.config.sessionToken
|
||||
sessionToken: configMap.config.sessionToken,
|
||||
}
|
||||
}
|
||||
let result: any
|
||||
try {
|
||||
fileKey = decodeURIComponent(fileKey)
|
||||
} catch (err: any) {}
|
||||
} catch (_err: any) {}
|
||||
try {
|
||||
const client = new S3Client(s3Options)
|
||||
const command = new DeleteObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: fileKey
|
||||
Key: fileKey,
|
||||
})
|
||||
result = await client.send(command)
|
||||
} catch (err: any) {
|
||||
} catch (_err: any) {
|
||||
s3Options.region = 'us-east-1'
|
||||
const client = new S3Client(s3Options)
|
||||
const command = new DeleteObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: fileKey
|
||||
Key: fileKey,
|
||||
})
|
||||
result = await client.send(command)
|
||||
}
|
||||
@@ -202,7 +202,7 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
||||
|
||||
export async function removeFileFromDogeInMain(configMap: IStringKeyMap) {
|
||||
const {
|
||||
config: { bucketName, AccessKey, SecretKey }
|
||||
config: { bucketName, AccessKey, SecretKey },
|
||||
} = configMap
|
||||
const token = (await getDogeToken(AccessKey, SecretKey)) as DogecloudTokenFull
|
||||
const bucket = token.Buckets?.find(item => item.name === bucketName || item.s3Bucket === bucketName)
|
||||
@@ -214,7 +214,7 @@ export async function removeFileFromDogeInMain(configMap: IStringKeyMap) {
|
||||
sessionToken: token.Credentials?.sessionToken,
|
||||
endpoint: bucket?.s3Endpoint,
|
||||
region: dogeRegionMap[bucket?.s3Endpoint?.split('.')[1] || 'ap-shanghai'],
|
||||
bucketName: bucket?.s3Bucket
|
||||
bucketName: bucket?.s3Bucket,
|
||||
}
|
||||
return await removeFileFromS3InMain(newConfigMap, true)
|
||||
}
|
||||
@@ -225,7 +225,7 @@ function createHuaweiAuthorization(
|
||||
fileName: string,
|
||||
accessKey: string,
|
||||
secretKey: string,
|
||||
date: string = new Date().toUTCString()
|
||||
date: string = new Date().toUTCString(),
|
||||
) {
|
||||
const strToSign = `DELETE\n\n\n${date}\n/${bucketName}${path}/${fileName}`
|
||||
const singature = crypto.createHmac('sha1', secretKey).update(strToSign).digest('base64')
|
||||
@@ -247,8 +247,8 @@ export async function removeFileFromHuaweiInMain(configMap: IStringKeyMap) {
|
||||
headers: {
|
||||
Host: `${bucketName}.${endpoint}`,
|
||||
Date: date,
|
||||
Authorization: authorization
|
||||
}
|
||||
Authorization: authorization,
|
||||
},
|
||||
})
|
||||
return res.status === 204
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export function digestAuthHeader(
|
||||
uri: string,
|
||||
wwwAuthenticate: string,
|
||||
username: string,
|
||||
password: string
|
||||
password: string,
|
||||
) {
|
||||
const parts = wwwAuthenticate.split(',')
|
||||
const opts = {} as IStringKeyMap
|
||||
|
||||
@@ -2,7 +2,7 @@ export const ILogType = {
|
||||
success: 'success',
|
||||
info: 'info',
|
||||
warn: 'warn',
|
||||
error: 'error'
|
||||
error: 'error',
|
||||
}
|
||||
|
||||
export const ICOREBuildInEvent = {
|
||||
@@ -16,7 +16,7 @@ export const ICOREBuildInEvent = {
|
||||
UNINSTALL: 'uninstall',
|
||||
UPDATE: 'update',
|
||||
NOTIFICATION: 'notification',
|
||||
REMOVE: 'remove'
|
||||
REMOVE: 'remove',
|
||||
}
|
||||
|
||||
export const IPicGoHelperType = {
|
||||
@@ -24,7 +24,7 @@ export const IPicGoHelperType = {
|
||||
beforeTransformPlugins: 'beforeTransformPlugins',
|
||||
beforeUploadPlugins: 'beforeUploadPlugins',
|
||||
uploader: 'uploader',
|
||||
transformer: 'transformer'
|
||||
transformer: 'transformer',
|
||||
}
|
||||
|
||||
export const IPasteStyle = {
|
||||
@@ -32,7 +32,7 @@ export const IPasteStyle = {
|
||||
HTML: 'HTML',
|
||||
URL: 'URL',
|
||||
UBB: 'UBB',
|
||||
CUSTOM: 'Custom'
|
||||
CUSTOM: 'Custom',
|
||||
}
|
||||
|
||||
export const IWindowList = {
|
||||
@@ -40,7 +40,7 @@ export const IWindowList = {
|
||||
TRAY_WINDOW: 'TRAY_WINDOW',
|
||||
MINI_WINDOW: 'MINI_WINDOW',
|
||||
RENAME_WINDOW: 'RENAME_WINDOW',
|
||||
TOOLBOX_WINDOW: 'TOOLBOX_WINDOW'
|
||||
TOOLBOX_WINDOW: 'TOOLBOX_WINDOW',
|
||||
}
|
||||
|
||||
export const IRemoteNoticeActionType = {
|
||||
@@ -49,22 +49,22 @@ export const IRemoteNoticeActionType = {
|
||||
SHOW_DIALOG: 'SHOW_DIALOG', // dialog notice
|
||||
COMMON: 'COMMON',
|
||||
VOID: 'VOID', // do nothing
|
||||
SHOW_MESSAGE_BOX: 'SHOW_MESSAGE_BOX'
|
||||
SHOW_MESSAGE_BOX: 'SHOW_MESSAGE_BOX',
|
||||
}
|
||||
|
||||
export const IRemoteNoticeTriggerHook = {
|
||||
APP_START: 'APP_START',
|
||||
SETTING_WINDOW_OPEN: 'SETTING_WINDOW_OPEN'
|
||||
SETTING_WINDOW_OPEN: 'SETTING_WINDOW_OPEN',
|
||||
}
|
||||
|
||||
export const IRemoteNoticeTriggerCount = {
|
||||
ONCE: 'ONCE', // default
|
||||
ALWAYS: 'ALWAYS'
|
||||
ALWAYS: 'ALWAYS',
|
||||
}
|
||||
|
||||
export const IRPCType = {
|
||||
INVOKE: 'INVOKE',
|
||||
SEND: 'SEND'
|
||||
SEND: 'SEND',
|
||||
}
|
||||
|
||||
export const IRPCActionType = {
|
||||
@@ -186,58 +186,58 @@ export const IRPCActionType = {
|
||||
MANAGE_OPEN_DOWNLOADED_FOLDER: 'MANAGE_OPEN_DOWNLOADED_FOLDER',
|
||||
MANAGE_OPEN_LOCAL_FILE: 'MANAGE_OPEN_LOCAL_FILE',
|
||||
MANAGE_DOWNLOAD_FILE_FROM_URL: 'MANAGE_DOWNLOAD_FILE_FROM_URL',
|
||||
MANAGE_CONVERT_PATH_TO_BASE64: 'MANAGE_CONVERT_PATH_TO_BASE64'
|
||||
MANAGE_CONVERT_PATH_TO_BASE64: 'MANAGE_CONVERT_PATH_TO_BASE64',
|
||||
}
|
||||
|
||||
export const IToolboxItemType = {
|
||||
IS_CONFIG_FILE_BROKEN: 'IS_CONFIG_FILE_BROKEN',
|
||||
IS_GALLERY_FILE_BROKEN: 'IS_GALLERY_FILE_BROKEN',
|
||||
HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD: 'HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD',
|
||||
HAS_PROBLEM_WITH_PROXY: 'HAS_PROBLEM_WITH_PROXY'
|
||||
HAS_PROBLEM_WITH_PROXY: 'HAS_PROBLEM_WITH_PROXY',
|
||||
}
|
||||
|
||||
export const IToolboxItemCheckStatus = {
|
||||
INIT: 'init',
|
||||
LOADING: 'loading',
|
||||
SUCCESS: 'success',
|
||||
ERROR: 'error'
|
||||
ERROR: 'error',
|
||||
}
|
||||
|
||||
export const ISartMode = {
|
||||
QUIET: 'quiet',
|
||||
MINI: 'mini',
|
||||
MAIN: 'main',
|
||||
NO_TRAY: 'no-tray'
|
||||
NO_TRAY: 'no-tray',
|
||||
}
|
||||
|
||||
export const II18nLanguage = {
|
||||
ZH_CN: 'zh-CN',
|
||||
ZH_TW: 'zh-TW',
|
||||
EN: 'en'
|
||||
EN: 'en',
|
||||
}
|
||||
|
||||
export const IShortUrlServer = {
|
||||
C1N: 'c1n',
|
||||
YOURLS: 'yourls',
|
||||
CFWORKER: 'cf_worker',
|
||||
SINK: 'sink'
|
||||
SINK: 'sink',
|
||||
}
|
||||
|
||||
export const commonTaskStatus = {
|
||||
queuing: 'queuing',
|
||||
failed: 'failed',
|
||||
canceled: 'canceled',
|
||||
paused: 'paused'
|
||||
paused: 'paused',
|
||||
}
|
||||
|
||||
// manage task status
|
||||
|
||||
export const uploadTaskSpecialStatus = {
|
||||
uploading: 'uploading',
|
||||
uploaded: 'uploaded'
|
||||
uploaded: 'uploaded',
|
||||
}
|
||||
|
||||
export const downloadTaskSpecialStatus = {
|
||||
downloading: 'downloading',
|
||||
downloaded: 'downloaded'
|
||||
downloaded: 'downloaded',
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user