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,
|
"semi": false,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"trailingComma": "none",
|
"trailingComma": "all",
|
||||||
"useTabs": false,
|
"useTabs": false,
|
||||||
"endOfLine": "lf"
|
"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"]
|
||||||
|
}
|
||||||
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"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
66
.vscode/settings.json
vendored
66
.vscode/settings.json
vendored
@@ -1,26 +1,55 @@
|
|||||||
{
|
{
|
||||||
"[stylus]": {
|
"eslint.run": "onSave",
|
||||||
"editor.formatOnSave": true
|
"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": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": "explicit"
|
"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]": {
|
"[css]": {
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "stylelint.vscode-stylelint",
|
||||||
"editor.formatOnSave": true
|
"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.keystyle": "nested",
|
||||||
"i18n-ally.sortKeys": true,
|
"i18n-ally.sortKeys": true,
|
||||||
"i18n-ally.namespace": true,
|
"i18n-ally.namespace": true,
|
||||||
@@ -29,5 +58,8 @@
|
|||||||
"i18n-ally.displayLanguage": "zh-CN",
|
"i18n-ally.displayLanguage": "zh-CN",
|
||||||
"i18n-ally.enabledFrameworks": ["vue"],
|
"i18n-ally.enabledFrameworks": ["vue"],
|
||||||
"i18n-ally.editor.preferEditor": true,
|
"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
|
||||||
}
|
}
|
||||||
@@ -15,9 +15,9 @@ export default defineConfig({
|
|||||||
root: resolve('./'),
|
root: resolve('./'),
|
||||||
'#': resolve('src/universal'),
|
'#': resolve('src/universal'),
|
||||||
apis: resolve('src/main/apis'),
|
apis: resolve('src/main/apis'),
|
||||||
'@core': resolve('src/main/apis/core')
|
'@core': resolve('src/main/apis/core'),
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
preload: {
|
preload: {
|
||||||
plugins: [
|
plugins: [
|
||||||
@@ -25,17 +25,17 @@ export default defineConfig({
|
|||||||
VueI18nPlugin({
|
VueI18nPlugin({
|
||||||
/* options */
|
/* options */
|
||||||
// locale messages resource pre-compile option
|
// 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: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': resolve('src/renderer'),
|
'@': resolve('src/renderer'),
|
||||||
'~': resolve('src/main'),
|
'~': resolve('src/main'),
|
||||||
root: resolve('./'),
|
root: resolve('./'),
|
||||||
'#': resolve('src/universal')
|
'#': resolve('src/universal'),
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
renderer: {
|
renderer: {
|
||||||
root: resolve('src/renderer'),
|
root: resolve('src/renderer'),
|
||||||
@@ -45,12 +45,12 @@ export default defineConfig({
|
|||||||
'@': resolve('src/renderer'),
|
'@': resolve('src/renderer'),
|
||||||
'~': resolve('src/main'),
|
'~': resolve('src/main'),
|
||||||
root: resolve('./'),
|
root: resolve('./'),
|
||||||
'#': resolve('src/universal')
|
'#': resolve('src/universal'),
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
plugins: [vue()],
|
plugins: [vue()],
|
||||||
server: {
|
server: {
|
||||||
port: 3000
|
port: 3000,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
146
eslint.config.js
146
eslint.config.js
@@ -1,49 +1,65 @@
|
|||||||
import eslint from '@eslint/js'
|
import js from '@eslint/js'
|
||||||
import standard from '@vue/eslint-config-standard'
|
|
||||||
import { defineConfig } from 'eslint/config'
|
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 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 pluginVue from 'eslint-plugin-vue'
|
||||||
import globals from 'globals'
|
import globals from 'globals'
|
||||||
|
import jsoncParser from 'jsonc-eslint-parser'
|
||||||
import tseslint from 'typescript-eslint'
|
import tseslint from 'typescript-eslint'
|
||||||
|
import vueParser from 'vue-eslint-parser'
|
||||||
|
|
||||||
export default defineConfig(
|
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/**'],
|
||||||
},
|
},
|
||||||
{
|
js.configs.recommended,
|
||||||
ignores: ['**/node_modules/**', '**/out/**', '**/webpack.config.js', 'vitest.workspace.mjs', '**/dist/**']
|
...pluginVue.configs['flat/recommended'],
|
||||||
},
|
|
||||||
eslint.configs.recommended,
|
|
||||||
...tseslint.configs.recommended,
|
...tseslint.configs.recommended,
|
||||||
...tseslint.configs.stylistic,
|
...tseslint.configs.stylistic,
|
||||||
...pluginVue.configs['flat/recommended'],
|
|
||||||
...standard,
|
|
||||||
eslintPluginPrettierRecommended,
|
|
||||||
{
|
{
|
||||||
plugins: {
|
files: ['**/*.ts', '**/*.d.ts'],
|
||||||
'simple-import-sort': simpleImportSort,
|
languageOptions: {
|
||||||
unicorn: eslintPluginUnicorn
|
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: {
|
languageOptions: {
|
||||||
|
parser: vueParser,
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
warnOnUnsupportedTypeScriptVersion: false
|
parser: tseslint.parser,
|
||||||
|
extraFileExtensions: ['.vue'],
|
||||||
|
sourceType: 'module',
|
||||||
|
ecmaVersion: 'latest',
|
||||||
},
|
},
|
||||||
globals: {
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
...globals.node,
|
...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: {
|
rules: {
|
||||||
|
'unicorn/prefer-node-protocol': 'error',
|
||||||
|
'unicorn/prefer-module': 'error',
|
||||||
|
'simple-import-sort/imports': 'error',
|
||||||
|
'simple-import-sort/exports': 'error',
|
||||||
eqeqeq: 'error',
|
eqeqeq: 'error',
|
||||||
'no-caller': 'error',
|
'no-caller': 'error',
|
||||||
'no-constant-condition': ['error', { checkLoops: false }],
|
'no-constant-condition': ['error', { checkLoops: false }],
|
||||||
@@ -58,22 +74,18 @@ export default defineConfig(
|
|||||||
'prefer-const': 'error',
|
'prefer-const': 'error',
|
||||||
'prefer-object-spread': 'error',
|
'prefer-object-spread': 'error',
|
||||||
'unicode-bom': ['error', 'never'],
|
'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-extra-boolean-cast': 'off',
|
||||||
'no-case-declarations': 'off',
|
'no-case-declarations': 'off',
|
||||||
'no-cond-assign': 'off',
|
'no-cond-assign': 'off',
|
||||||
'no-control-regex': 'off',
|
'no-control-regex': 'off',
|
||||||
'no-inner-declarations': 'off',
|
'no-inner-declarations': 'off',
|
||||||
'no-empty': 'off',
|
'no-empty': 'off',
|
||||||
|
|
||||||
// @typescript-eslint/eslint-plugin
|
// @typescript-eslint/eslint-plugin
|
||||||
'no-unused-expressions': 'off',
|
|
||||||
'@typescript-eslint/no-unused-expressions': 'off',
|
'@typescript-eslint/no-unused-expressions': 'off',
|
||||||
'@typescript-eslint/ban-ts-comment': '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-empty-function': 'off',
|
||||||
'@typescript-eslint/no-namespace': 'off',
|
'@typescript-eslint/no-namespace': 'off',
|
||||||
'@typescript-eslint/no-non-null-asserted-optional-chain': '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-explicit-any': 'off',
|
||||||
'@typescript-eslint/no-empty-object-type': 'off', // {} is a totally useful and valid type.
|
'@typescript-eslint/no-empty-object-type': 'off', // {} is a totally useful and valid type.
|
||||||
'@typescript-eslint/no-require-imports': 'off',
|
'@typescript-eslint/no-require-imports': 'off',
|
||||||
'@typescript-eslint/no-unused-vars': 'off',
|
|
||||||
'@typescript-eslint/no-inferrable-types': 'off',
|
'@typescript-eslint/no-inferrable-types': 'off',
|
||||||
|
'@typescript-eslint/no-this-alias': 'off',
|
||||||
// Pending https://github.com/typescript-eslint/typescript-eslint/issues/4820
|
// Pending https://github.com/typescript-eslint/typescript-eslint/issues/4820
|
||||||
'@typescript-eslint/prefer-optional-chain': 'off',
|
'@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'],
|
files: ['**/*.mjs', '**/*.mts'],
|
||||||
@@ -99,19 +150,24 @@ export default defineConfig(
|
|||||||
{ name: '__dirname' },
|
{ name: '__dirname' },
|
||||||
{ name: 'require' },
|
{ name: 'require' },
|
||||||
{ name: 'module' },
|
{ name: 'module' },
|
||||||
{ name: 'exports' }
|
{ name: 'exports' },
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
files: ['*.vue', '**/*.vue'],
|
files: ['*.config.js', '.stylelintrc.cjs', 'scripts/*.{js,mjs,cjs}'],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
ecmaVersion: 'latest',
|
globals: {
|
||||||
sourceType: 'module',
|
...globals.node,
|
||||||
globals: globals.browser,
|
},
|
||||||
parserOptions: {
|
},
|
||||||
parser: tseslint.parser
|
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": "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: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: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",
|
"postinstall": "electron-builder install-app-deps",
|
||||||
"postuninstall": "electron-builder install-app-deps",
|
"postuninstall": "electron-builder install-app-deps",
|
||||||
"prebuild": "electron-vite build",
|
"prebuild": "electron-vite build",
|
||||||
@@ -76,28 +77,17 @@
|
|||||||
"tunnel": "^0.0.6",
|
"tunnel": "^0.0.6",
|
||||||
"upyun": "^3.4.6",
|
"upyun": "^3.4.6",
|
||||||
"uuid": "^11.1.0",
|
"uuid": "^11.1.0",
|
||||||
|
"vue": "^3.5.22",
|
||||||
"webdav": "^5.8.0",
|
"webdav": "^5.8.0",
|
||||||
"write-file-atomic": "^6.0.0",
|
"write-file-atomic": "^6.0.0"
|
||||||
"vue": "^3.5.22"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@electron/notarize": "^3.1.1",
|
||||||
|
"@eslint/js": "^9.39.2",
|
||||||
"@headlessui/vue": "^1.7.23",
|
"@headlessui/vue": "^1.7.23",
|
||||||
"@highlightjs/vue-plugin": "^2.1.2",
|
"@highlightjs/vue-plugin": "^2.1.2",
|
||||||
"@videojs-player/vue": "^1.0.0",
|
"@intlify/unplugin-vue-i18n": "^11.0.3",
|
||||||
"dexie": "^3.2.4",
|
"@types/ali-oss": "^6.16.13",
|
||||||
"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",
|
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
@@ -108,30 +98,52 @@
|
|||||||
"@types/upyun": "^3.4.3",
|
"@types/upyun": "^3.4.3",
|
||||||
"@types/video.js": "^7.3.58",
|
"@types/video.js": "^7.3.58",
|
||||||
"@types/write-file-atomic": "^4.0.3",
|
"@types/write-file-atomic": "^4.0.3",
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@videojs-player/vue": "^1.0.0",
|
||||||
"@vue/eslint-config-standard": "^9.0.1",
|
"@vitejs/plugin-vue": "^6.0.3",
|
||||||
|
"baseline-browser-mapping": "^2.9.11",
|
||||||
|
"dexie": "^3.2.4",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
"dpdm": "^3.14.0",
|
"dpdm": "^3.14.0",
|
||||||
"electron": "^38.4.0",
|
"electron": "^38.4.0",
|
||||||
"electron-builder": "^26.0.12",
|
"electron-builder": "^26.0.12",
|
||||||
"electron-vite": "^4.0.1",
|
"electron-vite": "^4.0.1",
|
||||||
"eslint": "^9.39.1",
|
"eslint": "^9.39.2",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
|
"eslint-plugin-jsonc": "^2.21.0",
|
||||||
"eslint-plugin-prettier": "^5.5.4",
|
"eslint-plugin-prettier": "^5.5.4",
|
||||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||||
"eslint-plugin-unicorn": "^62.0.0",
|
"eslint-plugin-unicorn": "^62.0.0",
|
||||||
"eslint-plugin-vue": "^10.5.1",
|
"eslint-plugin-vue": "^10.6.2",
|
||||||
"globals": "^16.5.0",
|
"globals": "^16.5.0",
|
||||||
|
"highlight.js": "^11.11.1",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
|
"lucide-vue-next": "^0.562.0",
|
||||||
"node-bump-version": "^2.0.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",
|
"stylus": "^0.64.0",
|
||||||
"typescript": "5.8.2",
|
"typescript": "5.8.2",
|
||||||
"typescript-eslint": "^8.46.4",
|
"typescript-eslint": "^8.51.0",
|
||||||
"vite": "^7.2.2",
|
"video.js": "^8.23.4",
|
||||||
"vitest": "^4.0.8",
|
"vite": "^7.3.0",
|
||||||
|
"vitest": "^4.0.16",
|
||||||
"vue-eslint-parser": "^10.2.0",
|
"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": {
|
"config": {
|
||||||
"commitizen": {
|
"commitizen": {
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ const darwin = [
|
|||||||
appNameWithPrefix: 'PicList-',
|
appNameWithPrefix: 'PicList-',
|
||||||
ext: '.dmg',
|
ext: '.dmg',
|
||||||
arch: '-arm64',
|
arch: '-arm64',
|
||||||
'version-file': 'latest-mac.yml'
|
'version-file': 'latest-mac.yml',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
appNameWithPrefix: 'PicList-',
|
appNameWithPrefix: 'PicList-',
|
||||||
ext: '.dmg',
|
ext: '.dmg',
|
||||||
arch: '-x64',
|
arch: '-x64',
|
||||||
'version-file': 'latest-mac.yml'
|
'version-file': 'latest-mac.yml',
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
const linux = [
|
const linux = [
|
||||||
@@ -21,14 +21,14 @@ const linux = [
|
|||||||
appNameWithPrefix: 'PicList-',
|
appNameWithPrefix: 'PicList-',
|
||||||
ext: '.AppImage',
|
ext: '.AppImage',
|
||||||
arch: '',
|
arch: '',
|
||||||
'version-file': 'latest-linux.yml'
|
'version-file': 'latest-linux.yml',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
appNameWithPrefix: 'piclist_',
|
appNameWithPrefix: 'piclist_',
|
||||||
ext: '.snap',
|
ext: '.snap',
|
||||||
arch: '_amd64',
|
arch: '_amd64',
|
||||||
'version-file': 'latest-linux.yml'
|
'version-file': 'latest-linux.yml',
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
// windows
|
// windows
|
||||||
@@ -37,30 +37,30 @@ const win32 = [
|
|||||||
appNameWithPrefix: 'PicList-Setup-',
|
appNameWithPrefix: 'PicList-Setup-',
|
||||||
ext: '.exe',
|
ext: '.exe',
|
||||||
arch: '-ia32',
|
arch: '-ia32',
|
||||||
'version-file': 'latest.yml'
|
'version-file': 'latest.yml',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
appNameWithPrefix: 'PicList-Setup-',
|
appNameWithPrefix: 'PicList-Setup-',
|
||||||
ext: '.exe',
|
ext: '.exe',
|
||||||
arch: '-x64',
|
arch: '-x64',
|
||||||
'version-file': 'latest.yml'
|
'version-file': 'latest.yml',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
appNameWithPrefix: 'PicList-Setup-',
|
appNameWithPrefix: 'PicList-Setup-',
|
||||||
ext: '.exe',
|
ext: '.exe',
|
||||||
arch: '', // 32 & 64
|
arch: '', // 32 & 64
|
||||||
'version-file': 'latest.yml'
|
'version-file': 'latest.yml',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
appNameWithPrefix: 'PicList-Setup-',
|
appNameWithPrefix: 'PicList-Setup-',
|
||||||
ext: '.exe',
|
ext: '.exe',
|
||||||
arch: '-arm64',
|
arch: '-arm64',
|
||||||
'version-file': 'latest.yml'
|
'version-file': 'latest.yml',
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
darwin,
|
darwin,
|
||||||
linux,
|
linux,
|
||||||
win32
|
win32,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ const DOWNLOAD_DIR = process.argv[3] || path.join(os.homedir(), 'Downloads')
|
|||||||
const files = [
|
const files = [
|
||||||
{
|
{
|
||||||
name: 'PicList-x64.dmg',
|
name: 'PicList-x64.dmg',
|
||||||
url: `${BASE_URL}/PicList-${version}-x64.dmg`
|
url: `${BASE_URL}/PicList-${version}-x64.dmg`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'PicList-arm64.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({
|
const response = await axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url,
|
url,
|
||||||
responseType: 'stream'
|
responseType: 'stream',
|
||||||
})
|
})
|
||||||
|
|
||||||
const writer = fs.createWriteStream(filePath)
|
const writer = fs.createWriteStream(filePath)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ async function main(context) {
|
|||||||
appleId: XCODE_APP_LOADER_EMAIL,
|
appleId: XCODE_APP_LOADER_EMAIL,
|
||||||
appleIdPassword: XCODE_APP_LOADER_PASSWORD,
|
appleIdPassword: XCODE_APP_LOADER_PASSWORD,
|
||||||
tool: 'notarytool',
|
tool: 'notarytool',
|
||||||
teamId: XCODE_TEAM_ID
|
teamId: XCODE_TEAM_ID,
|
||||||
})
|
})
|
||||||
console.log('Finished Apple notarization.')
|
console.log('Finished Apple notarization.')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ const uploadFile = async () => {
|
|||||||
const options = {
|
const options = {
|
||||||
credentials: {
|
credentials: {
|
||||||
accessKeyId: SECRET_ID,
|
accessKeyId: SECRET_ID,
|
||||||
secretAccessKey: SECRET_KEY
|
secretAccessKey: SECRET_KEY,
|
||||||
},
|
},
|
||||||
endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
|
endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
|
||||||
tls: true,
|
tls: true,
|
||||||
region: 'auto'
|
region: 'auto',
|
||||||
}
|
}
|
||||||
const client = new S3Client.S3Client(options)
|
const client = new S3Client.S3Client(options)
|
||||||
const parallelUploads3 = new Upload.Upload({
|
const parallelUploads3 = new Upload.Upload({
|
||||||
@@ -41,9 +41,9 @@ const uploadFile = async () => {
|
|||||||
Body: fileStream,
|
Body: fileStream,
|
||||||
ContentType: 'application/octet-stream',
|
ContentType: 'application/octet-stream',
|
||||||
Metadata: {
|
Metadata: {
|
||||||
description: 'uploaded by PicList'
|
description: 'uploaded by PicList',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
parallelUploads3.on('httpUploadProgress', progress => {
|
parallelUploads3.on('httpUploadProgress', progress => {
|
||||||
const progressBar = Math.round((progress.loaded / progress.total) * 100)
|
const progressBar = Math.round((progress.loaded / progress.total) * 100)
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ const SECRET_KEY = process.env.R2_SECRET_KEY
|
|||||||
const options = {
|
const options = {
|
||||||
credentials: {
|
credentials: {
|
||||||
accessKeyId: SECRET_ID,
|
accessKeyId: SECRET_ID,
|
||||||
secretAccessKey: SECRET_KEY
|
secretAccessKey: SECRET_KEY,
|
||||||
},
|
},
|
||||||
endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
|
endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
|
||||||
tls: true,
|
tls: true,
|
||||||
region: 'auto'
|
region: 'auto',
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeDupField = path => {
|
const removeDupField = path => {
|
||||||
@@ -65,9 +65,9 @@ const uploadFile = async () => {
|
|||||||
Body: fileStream,
|
Body: fileStream,
|
||||||
ContentType: 'application/octet-stream',
|
ContentType: 'application/octet-stream',
|
||||||
Metadata: {
|
Metadata: {
|
||||||
description: 'uploaded by PicList'
|
description: 'uploaded by PicList',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
parallelUploads3.on('httpUploadProgress', progress => {
|
parallelUploads3.on('httpUploadProgress', progress => {
|
||||||
const progressBar = Math.round((progress.loaded / progress.total) * 100)
|
const progressBar = Math.round((progress.loaded / progress.total) * 100)
|
||||||
@@ -97,9 +97,9 @@ const uploadFile = async () => {
|
|||||||
Body: versionFileStream,
|
Body: versionFileStream,
|
||||||
ContentType: mime.getType(versionFileName),
|
ContentType: mime.getType(versionFileName),
|
||||||
Metadata: {
|
Metadata: {
|
||||||
description: 'uploaded by PicList'
|
description: 'uploaded by PicList',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
console.log('\nUploading version file to root...')
|
console.log('\nUploading version file to root...')
|
||||||
await uploadVersionFileToRoot.done()
|
await uploadVersionFileToRoot.done()
|
||||||
@@ -114,9 +114,9 @@ const uploadFile = async () => {
|
|||||||
Body: versionFileStream2,
|
Body: versionFileStream2,
|
||||||
ContentType: mime.getType(versionFileName),
|
ContentType: mime.getType(versionFileName),
|
||||||
Metadata: {
|
Metadata: {
|
||||||
description: 'uploaded by PicList'
|
description: 'uploaded by PicList',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
console.log('\nUploading version file to latest...')
|
console.log('\nUploading version file to latest...')
|
||||||
await uploadVersionFileToLatest.done()
|
await uploadVersionFileToLatest.done()
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ class RemoteNoticeHandler {
|
|||||||
try {
|
try {
|
||||||
const localCountStorage: IRemoteNoticeLocalCountStorage = fs.readJSONSync(
|
const localCountStorage: IRemoteNoticeLocalCountStorage = fs.readJSONSync(
|
||||||
REMOTE_NOTICE_LOCAL_STORAGE_PATH,
|
REMOTE_NOTICE_LOCAL_STORAGE_PATH,
|
||||||
'utf8'
|
'utf8',
|
||||||
)
|
)
|
||||||
this.remoteNoticeLocalCountStorage = localCountStorage
|
this.remoteNoticeLocalCountStorage = localCountStorage
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
this.remoteNoticeLocalCountStorage = localCountStorage
|
this.remoteNoticeLocalCountStorage = localCountStorage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ class RemoteNoticeHandler {
|
|||||||
const noticeInfo = (await axios({
|
const noticeInfo = (await axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: REMOTE_NOTICE_URL,
|
url: REMOTE_NOTICE_URL,
|
||||||
responseType: 'json'
|
responseType: 'json',
|
||||||
}).then(res => res.data)) as IRemoteNotice
|
}).then(res => res.data)) as IRemoteNotice
|
||||||
return noticeInfo
|
return noticeInfo
|
||||||
} catch {
|
} catch {
|
||||||
@@ -121,7 +121,7 @@ class RemoteNoticeHandler {
|
|||||||
if (action.data?.url) {
|
if (action.data?.url) {
|
||||||
shell.openExternal(action.data.url)
|
shell.openExternal(action.data.url)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case IRemoteNoticeActionType.OPEN_URL:
|
case IRemoteNoticeActionType.OPEN_URL:
|
||||||
@@ -144,7 +144,7 @@ class RemoteNoticeHandler {
|
|||||||
title: action.data?.title || '',
|
title: action.data?.title || '',
|
||||||
message: action.data?.content || '',
|
message: action.data?.content || '',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
buttons: action.data?.buttons?.map(item => item.label) || ['Yes']
|
buttons: action.data?.buttons?.map(item => item.label) || ['Yes'],
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const button = action.data?.buttons?.[res.response]
|
const button = action.data?.buttons?.[res.response]
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import type {
|
|||||||
IPluginShortKeyConfig,
|
IPluginShortKeyConfig,
|
||||||
IShortKeyConfig,
|
IShortKeyConfig,
|
||||||
IShortKeyConfigs,
|
IShortKeyConfigs,
|
||||||
IShortKeyHandler
|
IShortKeyHandler,
|
||||||
} from '#/types/types'
|
} from '#/types/types'
|
||||||
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '~/events/constant'
|
import { TOGGLE_SHORTKEY_MODIFIED_MODE } from '~/events/constant'
|
||||||
import { configPaths } from '~/utils/configPaths'
|
import { configPaths } from '~/utils/configPaths'
|
||||||
@@ -78,7 +78,7 @@ class ShortKeyHandler {
|
|||||||
config: IShortKeyConfig | IPluginShortKeyConfig,
|
config: IShortKeyConfig | IPluginShortKeyConfig,
|
||||||
command: string,
|
command: string,
|
||||||
handler: IShortKeyHandler,
|
handler: IShortKeyHandler,
|
||||||
writeFlag: boolean
|
writeFlag: boolean,
|
||||||
) {
|
) {
|
||||||
shortKeyService.registerCommand(command, handler)
|
shortKeyService.registerCommand(command, handler)
|
||||||
if (config.key) {
|
if (config.key) {
|
||||||
@@ -96,8 +96,8 @@ class ShortKeyHandler {
|
|||||||
enable: true,
|
enable: true,
|
||||||
name: config.name,
|
name: config.name,
|
||||||
label: config.label,
|
label: config.label,
|
||||||
key: config.key
|
key: config.key,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ class ShortKeyHandler {
|
|||||||
if (item.enable === false) {
|
if (item.enable === false) {
|
||||||
globalShortcut.unregister(item.key)
|
globalShortcut.unregister(item.key)
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`settings.shortKey.${command}.enable`]: false
|
[`settings.shortKey.${command}.enable`]: false,
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
@@ -116,7 +116,7 @@ class ShortKeyHandler {
|
|||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`settings.shortKey.${command}.enable`]: true
|
[`settings.shortKey.${command}.enable`]: true,
|
||||||
})
|
})
|
||||||
globalShortcut.register(item.key, () => {
|
globalShortcut.register(item.key, () => {
|
||||||
this.handler(command)
|
this.handler(command)
|
||||||
@@ -132,7 +132,7 @@ class ShortKeyHandler {
|
|||||||
if (globalShortcut.isRegistered(item.key)) return false
|
if (globalShortcut.isRegistered(item.key)) return false
|
||||||
globalShortcut.unregister(oldKey)
|
globalShortcut.unregister(oldKey)
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`settings.shortKey.${command}.key`]: item.key
|
[`settings.shortKey.${command}.key`]: item.key,
|
||||||
})
|
})
|
||||||
globalShortcut.register(item.key, () => {
|
globalShortcut.register(item.key, () => {
|
||||||
this.handler(`${from}:${item.name}`)
|
this.handler(`${from}:${item.name}`)
|
||||||
@@ -183,7 +183,7 @@ class ShortKeyHandler {
|
|||||||
.map(command => {
|
.map(command => {
|
||||||
return {
|
return {
|
||||||
command,
|
command,
|
||||||
key: commands[command].key
|
key: commands[command].key,
|
||||||
}
|
}
|
||||||
}) as IKeyCommandType[]
|
}) as IKeyCommandType[]
|
||||||
keyList.forEach(item => {
|
keyList.forEach(item => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import logger from '@core/picgo/logger'
|
|||||||
import type { IShortKeyHandler } from '#/types/types'
|
import type { IShortKeyHandler } from '#/types/types'
|
||||||
|
|
||||||
class ShortKeyService {
|
class ShortKeyService {
|
||||||
private commandList: Map<string, IShortKeyHandler> = new Map()
|
private commandList = new Map<string, IShortKeyHandler>()
|
||||||
registerCommand(command: string, handler: IShortKeyHandler) {
|
registerCommand(command: string, handler: IShortKeyHandler) {
|
||||||
this.commandList.set(command, handler)
|
this.commandList.set(command, handler)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
MenuItemConstructorOptions,
|
MenuItemConstructorOptions,
|
||||||
nativeTheme,
|
nativeTheme,
|
||||||
Notification,
|
Notification,
|
||||||
Tray
|
Tray,
|
||||||
} from 'electron'
|
} from 'electron'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import { cloneDeep } from 'lodash-es'
|
import { cloneDeep } from 'lodash-es'
|
||||||
@@ -41,7 +41,7 @@ export function setDockMenu() {
|
|||||||
const dockMenu = Menu.buildFromTemplate([
|
const dockMenu = Menu.buildFromTemplate([
|
||||||
{
|
{
|
||||||
label: $t('OPEN_MAIN_WINDOW'),
|
label: $t('OPEN_MAIN_WINDOW'),
|
||||||
click: openMainWindow
|
click: openMainWindow,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('START_WATCH_CLIPBOARD'),
|
label: $t('START_WATCH_CLIPBOARD'),
|
||||||
@@ -54,7 +54,7 @@ export function setDockMenu() {
|
|||||||
})
|
})
|
||||||
setDockMenu()
|
setDockMenu()
|
||||||
},
|
},
|
||||||
visible: !isListeningClipboard
|
visible: !isListeningClipboard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||||
@@ -64,8 +64,8 @@ export function setDockMenu() {
|
|||||||
clipboardPoll.removeAllListeners()
|
clipboardPoll.removeAllListeners()
|
||||||
setDockMenu()
|
setDockMenu()
|
||||||
},
|
},
|
||||||
visible: isListeningClipboard
|
visible: isListeningClipboard,
|
||||||
}
|
},
|
||||||
])
|
])
|
||||||
app.dock?.setMenu(dockMenu)
|
app.dock?.setMenu(dockMenu)
|
||||||
}
|
}
|
||||||
@@ -82,9 +82,9 @@ export function createMenu() {
|
|||||||
click() {
|
click() {
|
||||||
app.relaunch()
|
app.relaunch()
|
||||||
app.exit(0)
|
app.exit(0)
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
{ label: $t('CHOOSE_DEFAULT_PICBED'), type: 'submenu', submenu },
|
{ label: $t('CHOOSE_DEFAULT_PICBED'), type: 'submenu', submenu },
|
||||||
{
|
{
|
||||||
@@ -96,13 +96,13 @@ export function createMenu() {
|
|||||||
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', role: 'cut' },
|
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', role: 'cut' },
|
||||||
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', role: 'copy' },
|
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', role: 'copy' },
|
||||||
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', role: 'paste' },
|
{ 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'),
|
label: $t('QUIT'),
|
||||||
submenu: [{ label: $t('QUIT'), role: 'quit' }]
|
submenu: [{ label: $t('QUIT'), role: 'quit' }],
|
||||||
}
|
},
|
||||||
])
|
])
|
||||||
Menu.setApplicationMenu(appMenu)
|
Menu.setApplicationMenu(appMenu)
|
||||||
}
|
}
|
||||||
@@ -138,21 +138,21 @@ export function createContextMenu() {
|
|||||||
{
|
{
|
||||||
label: $t('START_WATCH_CLIPBOARD'),
|
label: $t('START_WATCH_CLIPBOARD'),
|
||||||
click: startWatchClipboard,
|
click: startWatchClipboard,
|
||||||
visible: !isListeningClipboard
|
visible: !isListeningClipboard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||||
click: stopWatchClipboard,
|
click: stopWatchClipboard,
|
||||||
visible: isListeningClipboard
|
visible: isListeningClipboard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('RELOAD_APP'),
|
label: $t('RELOAD_APP'),
|
||||||
click() {
|
click() {
|
||||||
app.relaunch()
|
app.relaunch()
|
||||||
app.exit(0)
|
app.exit(0)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{ label: $t('QUIT'), role: 'quit' }
|
{ label: $t('QUIT'), role: 'quit' },
|
||||||
]
|
]
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
template.splice(
|
template.splice(
|
||||||
@@ -163,13 +163,13 @@ export function createContextMenu() {
|
|||||||
click() {
|
click() {
|
||||||
openMiniWindow(false)
|
openMiniWindow(false)
|
||||||
},
|
},
|
||||||
visible: !isMiniWindowVisible
|
visible: !isMiniWindowVisible,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('HIDE_MINI_WINDOW'),
|
label: $t('HIDE_MINI_WINDOW'),
|
||||||
click: hideMiniWindow,
|
click: hideMiniWindow,
|
||||||
visible: isMiniWindowVisible
|
visible: isMiniWindowVisible,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
contextMenu = Menu.buildFromTemplate(template)
|
contextMenu = Menu.buildFromTemplate(template)
|
||||||
@@ -188,22 +188,22 @@ export function createContextMenu() {
|
|||||||
click() {
|
click() {
|
||||||
openMiniWindow(false)
|
openMiniWindow(false)
|
||||||
},
|
},
|
||||||
visible: !isMiniWindowVisible
|
visible: !isMiniWindowVisible,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('HIDE_MINI_WINDOW'),
|
label: $t('HIDE_MINI_WINDOW'),
|
||||||
click: hideMiniWindow,
|
click: hideMiniWindow,
|
||||||
visible: isMiniWindowVisible
|
visible: isMiniWindowVisible,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('START_WATCH_CLIPBOARD'),
|
label: $t('START_WATCH_CLIPBOARD'),
|
||||||
click: startWatchClipboard,
|
click: startWatchClipboard,
|
||||||
visible: !isListeningClipboard
|
visible: !isListeningClipboard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||||
click: stopWatchClipboard,
|
click: stopWatchClipboard,
|
||||||
visible: isListeningClipboard
|
visible: isListeningClipboard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('ABOUT'),
|
label: $t('ABOUT'),
|
||||||
@@ -212,11 +212,11 @@ export function createContextMenu() {
|
|||||||
title: 'PicList',
|
title: 'PicList',
|
||||||
message: 'PicList',
|
message: 'PicList',
|
||||||
buttons: ['Ok'],
|
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)
|
const decodePath = ensureFilePath(imgPath)
|
||||||
if (decodePath === imgPath) {
|
if (decodePath === imgPath) {
|
||||||
obj.push({
|
obj.push({
|
||||||
imgUrl: imgPath
|
imgUrl: imgPath,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (decodePath !== '') {
|
if (decodePath !== '') {
|
||||||
// 带有中文的路径,无法直接被img.src所使用,会被转义
|
// 带有中文的路径,无法直接被img.src所使用,会被转义
|
||||||
const base64 = await fs.readFile(decodePath.replace('file://', ''), { encoding: 'base64' })
|
const base64 = await fs.readFile(decodePath.replace('file://', ''), { encoding: 'base64' })
|
||||||
obj.push({
|
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({
|
obj.push({
|
||||||
width: img.getSize().width,
|
width: img.getSize().width,
|
||||||
height: img.getSize().height,
|
height: img.getSize().height,
|
||||||
imgUrl
|
imgUrl,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,7 +333,7 @@ export function createTray(tooltip: string) {
|
|||||||
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
||||||
pasteStyle,
|
pasteStyle,
|
||||||
imgs[i],
|
imgs[i],
|
||||||
db.get(configPaths.settings.customLink)
|
db.get(configPaths.settings.customLink),
|
||||||
)
|
)
|
||||||
imgs[i].shortUrl = shortUrl
|
imgs[i].shortUrl = shortUrl
|
||||||
pasteText.push(pasteTextItem)
|
pasteText.push(pasteTextItem)
|
||||||
@@ -344,7 +344,7 @@ export function createTray(tooltip: string) {
|
|||||||
if (isShowResultNotification) {
|
if (isShowResultNotification) {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: $t('UPLOAD_SUCCEED'),
|
title: $t('UPLOAD_SUCCEED'),
|
||||||
body: shortUrl || imgs[i].imgUrl!
|
body: shortUrl || imgs[i].imgUrl!,
|
||||||
// icon: files[i]
|
// icon: files[i]
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
|||||||
if (isShowResultNotification) {
|
if (isShowResultNotification) {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: $t('UPLOAD_SUCCEED'),
|
title: $t('UPLOAD_SUCCEED'),
|
||||||
body: shortUrl || img[0].imgUrl!
|
body: shortUrl || img[0].imgUrl!,
|
||||||
// icon: img[0].imgUrl
|
// icon: img[0].imgUrl
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -78,30 +78,30 @@ export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
url: handleUrlEncodeWithSetting(inserted.imgUrl as string),
|
url: handleUrlEncodeWithSetting(inserted.imgUrl as string),
|
||||||
fullResult: inserted
|
fullResult: inserted,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: $t('UPLOAD_FAILED'),
|
title: $t('UPLOAD_FAILED'),
|
||||||
body: $t('TIPS_UPLOAD_NOT_PICTURES')
|
body: $t('TIPS_UPLOAD_NOT_PICTURES'),
|
||||||
})
|
})
|
||||||
notification.show()
|
notification.show()
|
||||||
return {
|
return {
|
||||||
url: '',
|
url: '',
|
||||||
fullResult: {}
|
fullResult: {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
url: '',
|
url: '',
|
||||||
fullResult: {}
|
fullResult: {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const uploadChoosedFiles = async (
|
export const uploadChoosedFiles = async (
|
||||||
webContents: WebContents,
|
webContents: WebContents,
|
||||||
files: IFileWithPath[]
|
files: IFileWithPath[],
|
||||||
): Promise<IStringKeyMap[]> => {
|
): Promise<IStringKeyMap[]> => {
|
||||||
const input = files.map(item => item.path)
|
const input = files.map(item => item.path)
|
||||||
const rawInput = cloneDeep(input)
|
const rawInput = cloneDeep(input)
|
||||||
@@ -132,7 +132,7 @@ export const uploadChoosedFiles = async (
|
|||||||
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
||||||
pasteStyle,
|
pasteStyle,
|
||||||
imgs[i],
|
imgs[i],
|
||||||
db.get(configPaths.settings.customLink)
|
db.get(configPaths.settings.customLink),
|
||||||
)
|
)
|
||||||
imgs[i].shortUrl = shortUrl
|
imgs[i].shortUrl = shortUrl
|
||||||
pasteText.push(pasteTextItem)
|
pasteText.push(pasteTextItem)
|
||||||
@@ -144,7 +144,7 @@ export const uploadChoosedFiles = async (
|
|||||||
if (imgLength <= 3) {
|
if (imgLength <= 3) {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: $t('UPLOAD_SUCCEED'),
|
title: $t('UPLOAD_SUCCEED'),
|
||||||
body: shortUrl || imgs[i].imgUrl!
|
body: shortUrl || imgs[i].imgUrl!,
|
||||||
// icon: files[i].path
|
// icon: files[i].path
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -153,7 +153,7 @@ export const uploadChoosedFiles = async (
|
|||||||
} else if (i === imgLength - 1) {
|
} else if (i === imgLength - 1) {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: $t('MULTI_UPLOAD_SUCCEED', { n: imgLength }),
|
title: $t('MULTI_UPLOAD_SUCCEED', { n: imgLength }),
|
||||||
body: ''
|
body: '',
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
notification.show()
|
notification.show()
|
||||||
@@ -163,7 +163,7 @@ export const uploadChoosedFiles = async (
|
|||||||
const inserted = await GalleryDB.getInstance().insert(imgs[i])
|
const inserted = await GalleryDB.getInstance().insert(imgs[i])
|
||||||
result.push({
|
result.push({
|
||||||
url: handleUrlEncodeWithSetting(inserted.imgUrl!),
|
url: handleUrlEncodeWithSetting(inserted.imgUrl!),
|
||||||
fullResult: inserted
|
fullResult: inserted,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
handleCopyUrl(pasteText.join('\n'))
|
handleCopyUrl(pasteText.join('\n'))
|
||||||
@@ -181,7 +181,7 @@ export const uploadChoosedFiles = async (
|
|||||||
export const handleSecondaryUpload = async (
|
export const handleSecondaryUpload = async (
|
||||||
webContents?: WebContents,
|
webContents?: WebContents,
|
||||||
input?: string[],
|
input?: string[],
|
||||||
uploadType: 'clipboard' | 'file' | 'tray' = 'file'
|
uploadType: 'clipboard' | 'file' | 'tray' = 'file',
|
||||||
): Promise<{ needRestore: boolean; ctx: IPicGo | false }> => {
|
): Promise<{ needRestore: boolean; ctx: IPicGo | false }> => {
|
||||||
const enableSecondUploader = db.get(configPaths.settings.enableSecondUploader) || false
|
const enableSecondUploader = db.get(configPaths.settings.enableSecondUploader) || false
|
||||||
let currentPicBedType = ''
|
let currentPicBedType = ''
|
||||||
@@ -242,6 +242,6 @@ export const handleSecondaryUpload = async (
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
needRestore,
|
needRestore,
|
||||||
ctx
|
ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class Uploader {
|
|||||||
if (db.get(configPaths.settings.uploadNotification)) {
|
if (db.get(configPaths.settings.uploadNotification)) {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: $t('UPLOAD_PROGRESS'),
|
title: $t('UPLOAD_PROGRESS'),
|
||||||
body: $t('UPLOADING')
|
body: $t('UPLOADING'),
|
||||||
})
|
})
|
||||||
notification.show()
|
notification.show()
|
||||||
}
|
}
|
||||||
@@ -85,10 +85,10 @@ class Uploader {
|
|||||||
name = await waitForRename(window, window.webContents.id)
|
name = await waitForRename(window, window.webContents.id)
|
||||||
}
|
}
|
||||||
item.fileName = name || fileName
|
item.fileName = name || fileName
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ class Uploader {
|
|||||||
showNotification({
|
showNotification({
|
||||||
title: $t('UPLOAD_FAILED'),
|
title: $t('UPLOAD_FAILED'),
|
||||||
body: util.format(e.stack),
|
body: util.format(e.stack),
|
||||||
clickToCopy: true
|
clickToCopy: true,
|
||||||
})
|
})
|
||||||
}, 500)
|
}, 500)
|
||||||
return false
|
return false
|
||||||
@@ -186,7 +186,7 @@ class Uploader {
|
|||||||
showNotification({
|
showNotification({
|
||||||
title: $t('UPLOAD_FAILED'),
|
title: $t('UPLOAD_FAILED'),
|
||||||
body: util.format(e.stack),
|
body: util.format(e.stack),
|
||||||
clickToCopy: true
|
clickToCopy: true,
|
||||||
})
|
})
|
||||||
}, 500)
|
}, 500)
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ const windowList = new Map<string, IWindowListItem>()
|
|||||||
const getDefaultWindowSizes = (): { width: number; height: number } => {
|
const getDefaultWindowSizes = (): { width: number; height: number } => {
|
||||||
const [mainWindowWidth, mainWindowHeight] = db.get([
|
const [mainWindowWidth, mainWindowHeight] = db.get([
|
||||||
configPaths.settings.mainWindowWidth,
|
configPaths.settings.mainWindowWidth,
|
||||||
configPaths.settings.mainWindowHeight
|
configPaths.settings.mainWindowHeight,
|
||||||
])
|
])
|
||||||
return {
|
return {
|
||||||
width: mainWindowWidth || 1200,
|
width: mainWindowWidth || 1200,
|
||||||
height: mainWindowHeight || 800
|
height: mainWindowHeight || 800,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,8 +64,8 @@ const trayWindowOptions = {
|
|||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
nodeIntegrationInWorker: false,
|
nodeIntegrationInWorker: false,
|
||||||
backgroundThrottling: true,
|
backgroundThrottling: true,
|
||||||
webSecurity: false
|
webSecurity: false,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const settingWindowOptions = {
|
const settingWindowOptions = {
|
||||||
@@ -88,8 +88,8 @@ const settingWindowOptions = {
|
|||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
nodeIntegrationInWorker: false,
|
nodeIntegrationInWorker: false,
|
||||||
webSecurity: false
|
webSecurity: false,
|
||||||
}
|
},
|
||||||
} as IBrowserWindowOptions
|
} as IBrowserWindowOptions
|
||||||
|
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
@@ -113,8 +113,8 @@ const miniWindowOptions = {
|
|||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
backgroundThrottling: true,
|
backgroundThrottling: true,
|
||||||
nodeIntegrationInWorker: false
|
nodeIntegrationInWorker: false,
|
||||||
}
|
},
|
||||||
} as IBrowserWindowOptions
|
} as IBrowserWindowOptions
|
||||||
|
|
||||||
if (db.get(configPaths.settings.miniWindowOntop)) {
|
if (db.get(configPaths.settings.miniWindowOntop)) {
|
||||||
@@ -134,8 +134,8 @@ const renameWindowOptions = {
|
|||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
nodeIntegrationInWorker: false,
|
nodeIntegrationInWorker: false,
|
||||||
backgroundThrottling: false
|
backgroundThrottling: false,
|
||||||
}
|
},
|
||||||
} as IBrowserWindowOptions
|
} as IBrowserWindowOptions
|
||||||
|
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
@@ -163,8 +163,8 @@ const toolboxWindowOptions = {
|
|||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
nodeIntegrationInWorker: false,
|
nodeIntegrationInWorker: false,
|
||||||
webSecurity: false
|
webSecurity: false,
|
||||||
}
|
},
|
||||||
} as IBrowserWindowOptions
|
} as IBrowserWindowOptions
|
||||||
|
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
@@ -186,7 +186,7 @@ windowList.set(IWindowList.TRAY_WINDOW, {
|
|||||||
window.on('blur', () => {
|
window.on('blur', () => {
|
||||||
window.hide()
|
window.hide()
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
windowList.set(IWindowList.SETTING_WINDOW, {
|
windowList.set(IWindowList.SETTING_WINDOW, {
|
||||||
@@ -198,7 +198,7 @@ windowList.set(IWindowList.SETTING_WINDOW, {
|
|||||||
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#main-page/upload`)
|
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#main-page/upload`)
|
||||||
} else {
|
} else {
|
||||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||||
hash: 'main-page/upload'
|
hash: 'main-page/upload',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
window.on('closed', () => {
|
window.on('closed', () => {
|
||||||
@@ -211,7 +211,7 @@ windowList.set(IWindowList.SETTING_WINDOW, {
|
|||||||
})
|
})
|
||||||
bus.emit(CREATE_APP_MENU)
|
bus.emit(CREATE_APP_MENU)
|
||||||
windowManager.create(IWindowList.MINI_WINDOW)
|
windowManager.create(IWindowList.MINI_WINDOW)
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
windowList.set(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`)
|
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#mini-page`)
|
||||||
} else {
|
} else {
|
||||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||||
hash: 'mini-page'
|
hash: 'mini-page',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
windowList.set(IWindowList.RENAME_WINDOW, {
|
windowList.set(IWindowList.RENAME_WINDOW, {
|
||||||
@@ -238,7 +238,7 @@ windowList.set(IWindowList.RENAME_WINDOW, {
|
|||||||
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#rename-page`)
|
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#rename-page`)
|
||||||
} else {
|
} else {
|
||||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||||
hash: 'rename-page'
|
hash: 'rename-page',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const currentWindow = windowManager.getAvailableWindow(true)
|
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))
|
const positionY = Math.floor(y + height / 2 - (height > 400 ? 88 : 0))
|
||||||
window.setPosition(positionX, positionY, false)
|
window.setPosition(positionX, positionY, false)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
windowList.set(IWindowList.TOOLBOX_WINDOW, {
|
windowList.set(IWindowList.TOOLBOX_WINDOW, {
|
||||||
@@ -260,7 +260,7 @@ windowList.set(IWindowList.TOOLBOX_WINDOW, {
|
|||||||
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#toolbox-page`)
|
window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#toolbox-page`)
|
||||||
} else {
|
} else {
|
||||||
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
window.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
||||||
hash: 'toolbox-page'
|
hash: 'toolbox-page',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const currentWindow = windowManager.getAvailableWindow(true)
|
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))
|
const positionY = Math.floor(y + height / 2 - (height > 400 ? 225 : 0))
|
||||||
window.setPosition(positionX, positionY, false)
|
window.setPosition(positionX, positionY, false)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export default windowList
|
export default windowList
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import type { IWindowListItem, IWindowManager } from '#/types/electron'
|
|||||||
import { IWindowList } from '~/utils/enum'
|
import { IWindowList } from '~/utils/enum'
|
||||||
|
|
||||||
class WindowManager implements IWindowManager {
|
class WindowManager implements IWindowManager {
|
||||||
#windowMap: Map<string, BrowserWindow> = new Map()
|
#windowMap = new Map<string, BrowserWindow>()
|
||||||
#windowIdMap: Map<number, string> = new Map()
|
#windowIdMap = new Map<number, string>()
|
||||||
|
|
||||||
create(name: string) {
|
create(name: string) {
|
||||||
const windowConfig: IWindowListItem = windowList.get(name)!
|
const windowConfig: IWindowListItem = windowList.get(name)!
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
UPLOAD_WITH_CLIPBOARD_FILES,
|
UPLOAD_WITH_CLIPBOARD_FILES,
|
||||||
UPLOAD_WITH_CLIPBOARD_FILES_RESPONSE,
|
UPLOAD_WITH_CLIPBOARD_FILES_RESPONSE,
|
||||||
UPLOAD_WITH_FILES,
|
UPLOAD_WITH_FILES,
|
||||||
UPLOAD_WITH_FILES_RESPONSE
|
UPLOAD_WITH_FILES_RESPONSE,
|
||||||
} from '@core/bus/constants'
|
} from '@core/bus/constants'
|
||||||
import bus from '@core/bus/index'
|
import bus from '@core/bus/index'
|
||||||
|
|
||||||
@@ -21,11 +21,11 @@ export const uploadWithClipboardFiles = (): Promise<{
|
|||||||
if (result) {
|
if (result) {
|
||||||
return resolve({
|
return resolve({
|
||||||
success: true,
|
success: true,
|
||||||
result: [result]
|
result: [result],
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return resolve({
|
return resolve({
|
||||||
success: false
|
success: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -34,7 +34,7 @@ export const uploadWithClipboardFiles = (): Promise<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const uploadWithFiles = (
|
export const uploadWithFiles = (
|
||||||
pathList: IFileWithPath[]
|
pathList: IFileWithPath[],
|
||||||
): Promise<{
|
): Promise<{
|
||||||
success: boolean
|
success: boolean
|
||||||
result?: string[]
|
result?: string[]
|
||||||
@@ -44,11 +44,11 @@ export const uploadWithFiles = (
|
|||||||
if (result.length) {
|
if (result.length) {
|
||||||
return resolve({
|
return resolve({
|
||||||
success: true,
|
success: true,
|
||||||
result
|
result,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return resolve({
|
return resolve({
|
||||||
success: false
|
success: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ let hasCheckPath = false
|
|||||||
|
|
||||||
const errorMsg = {
|
const errorMsg = {
|
||||||
broken: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT'),
|
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() {
|
function dbChecker() {
|
||||||
@@ -42,28 +42,28 @@ function dbChecker() {
|
|||||||
let configFile: string = '{}'
|
let configFile: string = '{}'
|
||||||
const optionsTpl = {
|
const optionsTpl = {
|
||||||
title: $t('TIPS_NOTICE'),
|
title: $t('TIPS_NOTICE'),
|
||||||
body: ''
|
body: '',
|
||||||
}
|
}
|
||||||
// config save bak
|
// config save bak
|
||||||
try {
|
try {
|
||||||
configFile = fs.readFileSync(configFilePath, { encoding: 'utf-8' })
|
configFile = fs.readFileSync(configFilePath, { encoding: 'utf-8' })
|
||||||
JSON.parse(configFile)
|
JSON.parse(configFile)
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
fs.unlinkSync(configFilePath)
|
fs.unlinkSync(configFilePath)
|
||||||
if (fs.existsSync(configFileBackupPath)) {
|
if (fs.existsSync(configFileBackupPath)) {
|
||||||
try {
|
try {
|
||||||
configFile = fs.readFileSync(configFileBackupPath, {
|
configFile = fs.readFileSync(configFileBackupPath, {
|
||||||
encoding: 'utf-8'
|
encoding: 'utf-8',
|
||||||
})
|
})
|
||||||
JSON.parse(configFile)
|
JSON.parse(configFile)
|
||||||
writeFile.sync(configFilePath, configFile, { encoding: 'utf-8' })
|
writeFile.sync(configFilePath, configFile, { encoding: 'utf-8' })
|
||||||
const stats = fs.statSync(configFileBackupPath)
|
const stats = fs.statSync(configFileBackupPath)
|
||||||
optionsTpl.body = `${errorMsg.brokenButBackup}\n${$t('TIPS_PICGO_BACKUP_FILE_VERSION', {
|
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)
|
notificationList.push(optionsTpl)
|
||||||
return
|
return
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
optionsTpl.body = errorMsg.broken
|
optionsTpl.body = errorMsg.broken
|
||||||
notificationList.push(optionsTpl)
|
notificationList.push(optionsTpl)
|
||||||
return
|
return
|
||||||
@@ -92,7 +92,7 @@ function dbPathChecker(): string {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const configString = fs.readFileSync(defaultConfigPath, {
|
const configString = fs.readFileSync(defaultConfigPath, {
|
||||||
encoding: 'utf-8'
|
encoding: 'utf-8',
|
||||||
})
|
})
|
||||||
const config = JSON.parse(configString)
|
const config = JSON.parse(configString)
|
||||||
const userConfigPath: string = config.configPath || ''
|
const userConfigPath: string = config.configPath || ''
|
||||||
@@ -109,7 +109,7 @@ function dbPathChecker(): string {
|
|||||||
if (!hasCheckPath) {
|
if (!hasCheckPath) {
|
||||||
const optionsTpl = {
|
const optionsTpl = {
|
||||||
title: $t('TIPS_NOTICE'),
|
title: $t('TIPS_NOTICE'),
|
||||||
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR')
|
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR'),
|
||||||
}
|
}
|
||||||
notificationList.push(optionsTpl)
|
notificationList.push(optionsTpl)
|
||||||
hasCheckPath = true
|
hasCheckPath = true
|
||||||
@@ -133,7 +133,7 @@ function getGalleryDBPath(): {
|
|||||||
const dbBackupPath = path.join(path.dirname(dbPath), 'piclist.bak.db')
|
const dbBackupPath = path.join(path.dirname(dbPath), 'piclist.bak.db')
|
||||||
return {
|
return {
|
||||||
dbPath,
|
dbPath,
|
||||||
dbBackupPath
|
dbBackupPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class ConfigStore {
|
|||||||
current: 'smms', // deprecated
|
current: 'smms', // deprecated
|
||||||
uploader: 'smms',
|
uploader: 'smms',
|
||||||
smms: {
|
smms: {
|
||||||
token: ''
|
token: '',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ class ConfigStore {
|
|||||||
enable: true,
|
enable: true,
|
||||||
key: 'CommandOrControl+Alt+P',
|
key: 'CommandOrControl+Alt+P',
|
||||||
name: 'upload',
|
name: 'upload',
|
||||||
label: $t('QUICK_UPLOAD')
|
label: $t('QUICK_UPLOAD'),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.read()
|
this.read()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const picgo = await PicGo.create(CONFIG_PATH)
|
|||||||
|
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
debug: true,
|
debug: true,
|
||||||
PICGO_ENV: 'GUI'
|
PICGO_ENV: 'GUI',
|
||||||
})
|
})
|
||||||
|
|
||||||
picgo.GUI_VERSION = pkg.version
|
picgo.GUI_VERSION = pkg.version
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const checkLogFileIsLarge = (logPath: string): CheckLogFileResult => {
|
|||||||
return {
|
return {
|
||||||
isLarge: logFileSize > DEFAULT_LOG_FILE_SIZE_LIMIT,
|
isLarge: logFileSize > DEFAULT_LOG_FILE_SIZE_LIMIT,
|
||||||
logFileSize,
|
logFileSize,
|
||||||
logFileSizeLimit: DEFAULT_LOG_FILE_SIZE_LIMIT
|
logFileSizeLimit: DEFAULT_LOG_FILE_SIZE_LIMIT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { isLarge: false }
|
return { isLarge: false }
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ export default class AlistApi {
|
|||||||
url: `${url}/api/fs/remove`,
|
url: `${url}/api/fs/remove`,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Authorization: token
|
Authorization: token,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
dir: path.join('/', uploadPath, path.dirname(fileName)),
|
dir: path.join('/', uploadPath, path.dirname(fileName)),
|
||||||
names: [path.basename(fileName)]
|
names: [path.basename(fileName)],
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
const ok = result.data.code === 200
|
const ok = result.data.code === 200
|
||||||
deleteLog(fileName, 'Alist', ok)
|
deleteLog(fileName, 'Alist', ok)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ interface IConfigMap {
|
|||||||
const getAListToken = async (url: string, username: string, password: string) => {
|
const getAListToken = async (url: string, username: string, password: string) => {
|
||||||
const res = await axios.post(`${url}/api/auth/login`, {
|
const res = await axios.post(`${url}/api/auth/login`, {
|
||||||
username,
|
username,
|
||||||
password
|
password,
|
||||||
})
|
})
|
||||||
if (res.data.code === 200 && res.data.message === 'success') {
|
if (res.data.code === 200 && res.data.message === 'success') {
|
||||||
return res.data.data.token
|
return res.data.data.token
|
||||||
@@ -43,12 +43,12 @@ export default class AListplistApi {
|
|||||||
url: `${url}/api/fs/remove`,
|
url: `${url}/api/fs/remove`,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Authorization: token
|
Authorization: token,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
dir: path.join('/', uploadPath, path.dirname(fileName)),
|
dir: path.join('/', uploadPath, path.dirname(fileName)),
|
||||||
names: [path.basename(fileName)]
|
names: [path.basename(fileName)],
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
const ok = result.data.code === 200
|
const ok = result.data.code === 200
|
||||||
deleteLog(fileName, 'Alist', ok)
|
deleteLog(fileName, 'Alist', ok)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const apiMap: IStringKeyMap = {
|
|||||||
smms: SmmsApi,
|
smms: SmmsApi,
|
||||||
tcyun: TcyunApi,
|
tcyun: TcyunApi,
|
||||||
upyun: UpyunApi,
|
upyun: UpyunApi,
|
||||||
webdavplist: WebdavApi
|
webdavplist: WebdavApi,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ALLApi {
|
export default class ALLApi {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ interface IConfigMap {
|
|||||||
export default class GithubApi {
|
export default class GithubApi {
|
||||||
static #createOctokit(token: string) {
|
static #createOctokit(token: string) {
|
||||||
return new Octokit({
|
return new Octokit({
|
||||||
auth: token
|
auth: token,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ export default class GithubApi {
|
|||||||
const {
|
const {
|
||||||
fileName,
|
fileName,
|
||||||
hash,
|
hash,
|
||||||
config: { repo, token, branch, path }
|
config: { repo, token, branch, path },
|
||||||
} = configMap
|
} = configMap
|
||||||
const [owner, repoName] = repo.split('/')
|
const [owner, repoName] = repo.split('/')
|
||||||
const octokit = GithubApi.#createOctokit(token)
|
const octokit = GithubApi.#createOctokit(token)
|
||||||
@@ -37,7 +37,7 @@ export default class GithubApi {
|
|||||||
path: key,
|
path: key,
|
||||||
message: `delete ${fileName} by PicList`,
|
message: `delete ${fileName} by PicList`,
|
||||||
sha: hash,
|
sha: hash,
|
||||||
branch
|
branch,
|
||||||
})
|
})
|
||||||
const ok = status === 200
|
const ok = status === 200
|
||||||
deleteLog(fileName, 'GitHub', ok)
|
deleteLog(fileName, 'GitHub', ok)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export default class ImgurApi {
|
|||||||
try {
|
try {
|
||||||
const response: AxiosResponse = await axios.delete(apiUrl, {
|
const response: AxiosResponse = await axios.delete(apiUrl, {
|
||||||
headers: { Authorization },
|
headers: { Authorization },
|
||||||
timeout: 30000
|
timeout: 30000,
|
||||||
})
|
})
|
||||||
const ok = response.status === 200
|
const ok = response.status === 200
|
||||||
deleteLog(hash, 'Imgur', ok)
|
deleteLog(hash, 'Imgur', ok)
|
||||||
|
|||||||
@@ -21,17 +21,17 @@ export default class LskyplistApi {
|
|||||||
|
|
||||||
const v2Headers = {
|
const v2Headers = {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
Authorization: token || undefined
|
Authorization: token || undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestAgent = new https.Agent({
|
const requestAgent = new https.Agent({
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false,
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
const response: AxiosResponse = await axios.delete(`${host}/api/v1/images/${hash}`, {
|
const response: AxiosResponse = await axios.delete(`${host}/api/v1/images/${hash}`, {
|
||||||
headers: v2Headers,
|
headers: v2Headers,
|
||||||
timeout: 30000,
|
timeout: 30000,
|
||||||
httpsAgent: requestAgent
|
httpsAgent: requestAgent,
|
||||||
})
|
})
|
||||||
const ok = response.status === 200 && response.data.status === true
|
const ok = response.status === 200 && response.data.status === true
|
||||||
deleteLog(hash, 'Lskyplist', ok)
|
deleteLog(hash, 'Lskyplist', ok)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default class PiclistApi {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const response: AxiosResponse = await axios.post(url, {
|
const response: AxiosResponse = await axios.post(url, {
|
||||||
list: [fullResult]
|
list: [fullResult],
|
||||||
})
|
})
|
||||||
const ok = response.status === 200 && response.data?.success
|
const ok = response.status === 200 && response.data?.success
|
||||||
deleteLog(fullResult, 'Piclist', ok)
|
deleteLog(fullResult, 'Piclist', ok)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default class QiniuApi {
|
|||||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||||
const {
|
const {
|
||||||
fileName,
|
fileName,
|
||||||
config: { accessKey, secretKey, bucket, path }
|
config: { accessKey, secretKey, bucket, path },
|
||||||
} = configMap
|
} = configMap
|
||||||
const mac = new qiniu.auth.digest.Mac(accessKey, secretKey)
|
const mac = new qiniu.auth.digest.Mac(accessKey, secretKey)
|
||||||
const qiniuConfig = new qiniu.conf.Config()
|
const qiniuConfig = new qiniu.conf.Config()
|
||||||
@@ -26,7 +26,7 @@ export default class QiniuApi {
|
|||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
respBody,
|
respBody,
|
||||||
respInfo
|
respInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ export default class SmmsApi {
|
|||||||
try {
|
try {
|
||||||
const response: AxiosResponse = await axios.get(`${SmmsApi.#baseUrl}/delete/${hash}`, {
|
const response: AxiosResponse = await axios.get(`${SmmsApi.#baseUrl}/delete/${hash}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: token
|
Authorization: token,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
hash,
|
hash,
|
||||||
format: 'json'
|
format: 'json',
|
||||||
},
|
},
|
||||||
timeout: 30000
|
timeout: 30000,
|
||||||
})
|
})
|
||||||
const ok = response.status === 200
|
const ok = response.status === 200
|
||||||
deleteLog(hash, 'Smms', ok)
|
deleteLog(hash, 'Smms', ok)
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ export default class TcyunApi {
|
|||||||
static #createCOS(SecretId: string, SecretKey: string): COS {
|
static #createCOS(SecretId: string, SecretKey: string): COS {
|
||||||
return new COS({
|
return new COS({
|
||||||
SecretId,
|
SecretId,
|
||||||
SecretKey
|
SecretKey,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||||
const {
|
const {
|
||||||
fileName,
|
fileName,
|
||||||
config: { secretId, secretKey, bucket, area, path }
|
config: { secretId, secretKey, bucket, area, path },
|
||||||
} = configMap
|
} = configMap
|
||||||
try {
|
try {
|
||||||
const cos = TcyunApi.#createCOS(secretId, secretKey)
|
const cos = TcyunApi.#createCOS(secretId, secretKey)
|
||||||
@@ -30,7 +30,7 @@ export default class TcyunApi {
|
|||||||
const result = await cos.deleteObject({
|
const result = await cos.deleteObject({
|
||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
Region: area,
|
Region: area,
|
||||||
Key: key
|
Key: key,
|
||||||
})
|
})
|
||||||
const ok = result.statusCode === 204
|
const ok = result.statusCode === 204
|
||||||
deleteLog(fileName, 'Tcyun', ok)
|
deleteLog(fileName, 'Tcyun', ok)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default class UpyunApi {
|
|||||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||||
const {
|
const {
|
||||||
fileName,
|
fileName,
|
||||||
config: { bucket, operator, password, path }
|
config: { bucket, operator, password, path },
|
||||||
} = configMap
|
} = configMap
|
||||||
try {
|
try {
|
||||||
const service = new Upyun.Service(bucket, operator, password)
|
const service = new Upyun.Service(bucket, operator, password)
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ export default class WebdavApi {
|
|||||||
static async delete(configMap: IConfigMap): Promise<boolean> {
|
static async delete(configMap: IConfigMap): Promise<boolean> {
|
||||||
const {
|
const {
|
||||||
fileName,
|
fileName,
|
||||||
config: { host, username, password, path, sslEnabled, authType }
|
config: { host, username, password, path, sslEnabled, authType },
|
||||||
} = configMap
|
} = configMap
|
||||||
const endpoint = formatEndpoint(host, sslEnabled)
|
const endpoint = formatEndpoint(host, sslEnabled)
|
||||||
const options: WebDAVClientOptions = {
|
const options: WebDAVClientOptions = {
|
||||||
username,
|
username,
|
||||||
password
|
password,
|
||||||
}
|
}
|
||||||
if (authType === 'digest') {
|
if (authType === 'digest') {
|
||||||
options.authType = AuthType.Digest
|
options.authType = AuthType.Digest
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import type {
|
|||||||
IShowMessageBoxOption,
|
IShowMessageBoxOption,
|
||||||
IShowMessageBoxResult,
|
IShowMessageBoxResult,
|
||||||
IShowNotificationOption,
|
IShowNotificationOption,
|
||||||
IUploadOption
|
IUploadOption,
|
||||||
} from '#/types/types'
|
} from '#/types/types'
|
||||||
import { SHOW_INPUT_BOX } from '~/events/constant'
|
import { SHOW_INPUT_BOX } from '~/events/constant'
|
||||||
import { T as $t } from '~/i18n'
|
import { T as $t } from '~/i18n'
|
||||||
@@ -62,8 +62,8 @@ class GuiApi implements IGuiApi {
|
|||||||
async showInputBox(
|
async showInputBox(
|
||||||
options: IShowInputBoxOption = {
|
options: IShowInputBoxOption = {
|
||||||
title: '',
|
title: '',
|
||||||
placeholder: ''
|
placeholder: '',
|
||||||
}
|
},
|
||||||
) {
|
) {
|
||||||
await this.showSettingWindow()
|
await this.showSettingWindow()
|
||||||
this.getWebcontentsByWindowId(this.settingWindowId)?.send(SHOW_INPUT_BOX, options)
|
this.getWebcontentsByWindowId(this.settingWindowId)?.send(SHOW_INPUT_BOX, options)
|
||||||
@@ -103,7 +103,7 @@ class GuiApi implements IGuiApi {
|
|||||||
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
const [pasteTextItem, shortUrl] = await pasteTemplate(
|
||||||
pasteStyle,
|
pasteStyle,
|
||||||
imgs[i],
|
imgs[i],
|
||||||
db.get(configPaths.settings.customLink)
|
db.get(configPaths.settings.customLink),
|
||||||
)
|
)
|
||||||
imgs[i].shortUrl = shortUrl
|
imgs[i].shortUrl = shortUrl
|
||||||
pasteText.push(pasteTextItem)
|
pasteText.push(pasteTextItem)
|
||||||
@@ -114,7 +114,7 @@ class GuiApi implements IGuiApi {
|
|||||||
if (isShowResultNotification) {
|
if (isShowResultNotification) {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: $t('UPLOAD_SUCCEED'),
|
title: $t('UPLOAD_SUCCEED'),
|
||||||
body: shortUrl || (imgs[i].imgUrl! as string)
|
body: shortUrl || (imgs[i].imgUrl! as string),
|
||||||
// icon: imgs[i].imgUrl
|
// icon: imgs[i].imgUrl
|
||||||
})
|
})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -134,12 +134,12 @@ class GuiApi implements IGuiApi {
|
|||||||
showNotification(
|
showNotification(
|
||||||
options: IShowNotificationOption = {
|
options: IShowNotificationOption = {
|
||||||
title: '',
|
title: '',
|
||||||
body: ''
|
body: '',
|
||||||
}
|
},
|
||||||
) {
|
) {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: options.title,
|
title: options.title,
|
||||||
body: options.body
|
body: options.body,
|
||||||
})
|
})
|
||||||
notification.show()
|
notification.show()
|
||||||
}
|
}
|
||||||
@@ -149,8 +149,8 @@ class GuiApi implements IGuiApi {
|
|||||||
title: '',
|
title: '',
|
||||||
message: '',
|
message: '',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
buttons: ['Yes', 'No']
|
buttons: ['Yes', 'No'],
|
||||||
}
|
},
|
||||||
) {
|
) {
|
||||||
return new Promise<IShowMessageBoxResult>(resolve => {
|
return new Promise<IShowMessageBoxResult>(resolve => {
|
||||||
getWindowId().then(id => {
|
getWindowId().then(id => {
|
||||||
@@ -158,7 +158,7 @@ class GuiApi implements IGuiApi {
|
|||||||
dialog.showMessageBox(BrowserWindow.fromId(id)!, options as MessageBoxOptions).then(res => {
|
dialog.showMessageBox(BrowserWindow.fromId(id)!, options as MessageBoxOptions).then(res => {
|
||||||
resolve({
|
resolve({
|
||||||
result: res.response,
|
result: res.response,
|
||||||
checkboxChecked: res.checkboxChecked
|
checkboxChecked: res.checkboxChecked,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -174,7 +174,7 @@ class GuiApi implements IGuiApi {
|
|||||||
return {
|
return {
|
||||||
defaultConfigPath,
|
defaultConfigPath,
|
||||||
currentConfigPath,
|
currentConfigPath,
|
||||||
galleryDBPath
|
galleryDBPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ class GuiApi implements IGuiApi {
|
|||||||
title: $t('TIPS_WARNING'),
|
title: $t('TIPS_WARNING'),
|
||||||
message: $t('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
message: $t('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
||||||
type: 'info',
|
type: 'info',
|
||||||
buttons: ['Yes', 'No']
|
buttons: ['Yes', 'No'],
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.result === 0) {
|
if (res.result === 0) {
|
||||||
@@ -201,7 +201,7 @@ class GuiApi implements IGuiApi {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (prop === 'removeById') {
|
if (prop === 'removeById') {
|
||||||
@@ -214,7 +214,7 @@ class GuiApi implements IGuiApi {
|
|||||||
title: $t('TIPS_WARNING'),
|
title: $t('TIPS_WARNING'),
|
||||||
message: $t('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
message: $t('TIPS_PLUGIN_REMOVE_GALLERY_ITEM'),
|
||||||
type: 'info',
|
type: 'info',
|
||||||
buttons: ['Yes', 'No']
|
buttons: ['Yes', 'No'],
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.result === 0) {
|
if (res.result === 0) {
|
||||||
@@ -224,11 +224,11 @@ class GuiApi implements IGuiApi {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return Reflect.get(target, prop)
|
return Reflect.get(target, prop)
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
UPLOAD_WITH_CLIPBOARD_FILES,
|
UPLOAD_WITH_CLIPBOARD_FILES,
|
||||||
UPLOAD_WITH_CLIPBOARD_FILES_RESPONSE,
|
UPLOAD_WITH_CLIPBOARD_FILES_RESPONSE,
|
||||||
UPLOAD_WITH_FILES,
|
UPLOAD_WITH_FILES,
|
||||||
UPLOAD_WITH_FILES_RESPONSE
|
UPLOAD_WITH_FILES_RESPONSE,
|
||||||
} from '@core/bus/constants'
|
} from '@core/bus/constants'
|
||||||
import { createMenu } from 'apis/app/system'
|
import { createMenu } from 'apis/app/system'
|
||||||
import { uploadChoosedFiles, uploadClipboardFiles } from 'apis/app/uploader/apis'
|
import { uploadChoosedFiles, uploadClipboardFiles } from 'apis/app/uploader/apis'
|
||||||
@@ -24,7 +24,7 @@ function initEventCenter() {
|
|||||||
[UPLOAD_WITH_FILES]: busCallUploadFiles,
|
[UPLOAD_WITH_FILES]: busCallUploadFiles,
|
||||||
[GET_WINDOW_ID]: busCallGetWindowId,
|
[GET_WINDOW_ID]: busCallGetWindowId,
|
||||||
[GET_SETTING_WINDOW_ID]: busCallGetSettingWindowId,
|
[GET_SETTING_WINDOW_ID]: busCallGetSettingWindowId,
|
||||||
[CREATE_APP_MENU]: createMenu
|
[CREATE_APP_MENU]: createMenu,
|
||||||
}
|
}
|
||||||
for (const i in eventList) {
|
for (const i in eventList) {
|
||||||
bus.on(i, eventList[i])
|
bus.on(i, eventList[i])
|
||||||
@@ -57,5 +57,5 @@ function busCallGetSettingWindowId() {
|
|||||||
export default {
|
export default {
|
||||||
listen() {
|
listen() {
|
||||||
initEventCenter()
|
initEventCenter()
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
PICGO_HANDLE_PLUGIN_DONE,
|
PICGO_HANDLE_PLUGIN_DONE,
|
||||||
PICGO_HANDLE_PLUGIN_ING,
|
PICGO_HANDLE_PLUGIN_ING,
|
||||||
PICGO_TOGGLE_PLUGIN,
|
PICGO_TOGGLE_PLUGIN,
|
||||||
SHOW_MAIN_PAGE_QRCODE
|
SHOW_MAIN_PAGE_QRCODE,
|
||||||
} from '~/events/constant'
|
} from '~/events/constant'
|
||||||
import { handlePluginUninstall, handlePluginUpdate } from '~/events/rpc/routes/plugin/utils'
|
import { handlePluginUninstall, handlePluginUpdate } from '~/events/rpc/routes/plugin/utils'
|
||||||
import { T as $t } from '~/i18n'
|
import { T as $t } from '~/i18n'
|
||||||
@@ -37,24 +37,24 @@ const buildMiniPageMenu = () => {
|
|||||||
const template: (MenuItemConstructorOptions | MenuItem)[] = [
|
const template: (MenuItemConstructorOptions | MenuItem)[] = [
|
||||||
{
|
{
|
||||||
label: $t('OPEN_MAIN_WINDOW'),
|
label: $t('OPEN_MAIN_WINDOW'),
|
||||||
click: openMainWindow
|
click: openMainWindow,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('CHOOSE_DEFAULT_PICBED'),
|
label: $t('CHOOSE_DEFAULT_PICBED'),
|
||||||
type: 'submenu',
|
type: 'submenu',
|
||||||
submenu
|
submenu,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('UPLOAD_BY_CLIPBOARD'),
|
label: $t('UPLOAD_BY_CLIPBOARD'),
|
||||||
click() {
|
click() {
|
||||||
uploadClipboardFiles()
|
uploadClipboardFiles()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('HIDE_MINI_WINDOW'),
|
label: $t('HIDE_MINI_WINDOW'),
|
||||||
click() {
|
click() {
|
||||||
BrowserWindow.getFocusedWindow()!.hide()
|
BrowserWindow.getFocusedWindow()!.hide()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('START_WATCH_CLIPBOARD'),
|
label: $t('START_WATCH_CLIPBOARD'),
|
||||||
@@ -67,7 +67,7 @@ const buildMiniPageMenu = () => {
|
|||||||
})
|
})
|
||||||
buildMiniPageMenu()
|
buildMiniPageMenu()
|
||||||
},
|
},
|
||||||
visible: !isListeningClipboard
|
visible: !isListeningClipboard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('STOP_WATCH_CLIPBOARD'),
|
label: $t('STOP_WATCH_CLIPBOARD'),
|
||||||
@@ -77,19 +77,19 @@ const buildMiniPageMenu = () => {
|
|||||||
ClipboardWatcher.removeAllListeners()
|
ClipboardWatcher.removeAllListeners()
|
||||||
buildMiniPageMenu()
|
buildMiniPageMenu()
|
||||||
},
|
},
|
||||||
visible: isListeningClipboard
|
visible: isListeningClipboard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('RELOAD_APP'),
|
label: $t('RELOAD_APP'),
|
||||||
click() {
|
click() {
|
||||||
app.relaunch()
|
app.relaunch()
|
||||||
app.exit(0)
|
app.exit(0)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'quit',
|
role: 'quit',
|
||||||
label: $t('QUIT')
|
label: $t('QUIT'),
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
return Menu.buildFromTemplate(template)
|
return Menu.buildFromTemplate(template)
|
||||||
}
|
}
|
||||||
@@ -102,36 +102,36 @@ const buildMainPageMenu = (win: BrowserWindow) => {
|
|||||||
dialog.showMessageBox({
|
dialog.showMessageBox({
|
||||||
title: 'PicList',
|
title: 'PicList',
|
||||||
message: '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'),
|
label: $t('SHOW_PICBED_QRCODE'),
|
||||||
click() {
|
click() {
|
||||||
win?.webContents?.send(SHOW_MAIN_PAGE_QRCODE)
|
win?.webContents?.send(SHOW_MAIN_PAGE_QRCODE)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('OPEN_TOOLBOX'),
|
label: $t('OPEN_TOOLBOX'),
|
||||||
click() {
|
click() {
|
||||||
const window = windowManager.create(IWindowList.TOOLBOX_WINDOW)
|
const window = windowManager.create(IWindowList.TOOLBOX_WINDOW)
|
||||||
window?.show()
|
window?.show()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('SHOW_DEVTOOLS'),
|
label: $t('SHOW_DEVTOOLS'),
|
||||||
click() {
|
click() {
|
||||||
win?.webContents?.openDevTools({ mode: 'detach' })
|
win?.webContents?.openDevTools({ mode: 'detach' })
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('FEEDBACK'),
|
label: $t('FEEDBACK'),
|
||||||
click() {
|
click() {
|
||||||
const url = 'https://github.com/Kuingsmile/PicList/issues'
|
const url = 'https://github.com/Kuingsmile/PicList/issues'
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
] as (MenuItemConstructorOptions | MenuItem)[]
|
] as (MenuItemConstructorOptions | MenuItem)[]
|
||||||
return Menu.buildFromTemplate(template)
|
return Menu.buildFromTemplate(template)
|
||||||
}
|
}
|
||||||
@@ -145,11 +145,11 @@ const buildSecondPicBedMenu = () => {
|
|||||||
const currentPicBedMenuItem = [
|
const currentPicBedMenuItem = [
|
||||||
{
|
{
|
||||||
label: `${$t('CURRENT_SECOND_PICBED')} - ${currentPicBedName || 'None'}`,
|
label: `${$t('CURRENT_SECOND_PICBED')} - ${currentPicBedName || 'None'}`,
|
||||||
enabled: false
|
enabled: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'separator'
|
type: 'separator',
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
let submenu = picBeds
|
let submenu = picBeds
|
||||||
.filter(item => item.visible)
|
.filter(item => item.visible)
|
||||||
@@ -168,19 +168,19 @@ const buildSecondPicBedMenu = () => {
|
|||||||
// see: https://github.com/electron/electron/issues/21292
|
// see: https://github.com/electron/electron/issues/21292
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config._id === defaultSecondUploaderId && item.type === secondUploader,
|
checked: config._id === defaultSecondUploaderId && item.type === secondUploader,
|
||||||
click: function () {
|
click() {
|
||||||
changeSecondUploader(item.type, config, config._id)
|
changeSecondUploader(item.type, config, config._id)
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
: undefined,
|
: undefined,
|
||||||
click: !hasSubmenu
|
click: !hasSubmenu
|
||||||
? function () {
|
? function () {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[configPaths.picBed.secondUploader]: item.type
|
[configPaths.picBed.secondUploader]: item.type,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// @ts-expect-error submenu type
|
// @ts-expect-error submenu type
|
||||||
@@ -197,11 +197,11 @@ const buildPicBedListMenu = () => {
|
|||||||
const currentPicBedMenuItem = [
|
const currentPicBedMenuItem = [
|
||||||
{
|
{
|
||||||
label: `${$t('CURRENT_PICBED')} - ${currentPicBedName}`,
|
label: `${$t('CURRENT_PICBED')} - ${currentPicBedName}`,
|
||||||
enabled: false
|
enabled: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'separator'
|
type: 'separator',
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
let submenu = picBeds
|
let submenu = picBeds
|
||||||
.filter(item => item.visible)
|
.filter(item => item.visible)
|
||||||
@@ -221,13 +221,13 @@ const buildPicBedListMenu = () => {
|
|||||||
// see: https://github.com/electron/electron/issues/21292
|
// see: https://github.com/electron/electron/issues/21292
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config._id === defaultId && item.type === currentPicBed,
|
checked: config._id === defaultId && item.type === currentPicBed,
|
||||||
click: function () {
|
click() {
|
||||||
changeCurrentUploader(item.type, config, config._id)
|
changeCurrentUploader(item.type, config, config._id)
|
||||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('syncPicBed')
|
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('syncPicBed')
|
||||||
}
|
}
|
||||||
setTrayToolTip(`${item.type} ${config._configName || 'Default'}`)
|
setTrayToolTip(`${item.type} ${config._configName || 'Default'}`)
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
: undefined,
|
: undefined,
|
||||||
@@ -235,14 +235,14 @@ const buildPicBedListMenu = () => {
|
|||||||
? function () {
|
? function () {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[configPaths.picBed.current]: item.type,
|
[configPaths.picBed.current]: item.type,
|
||||||
[configPaths.picBed.uploader]: item.type
|
[configPaths.picBed.uploader]: item.type,
|
||||||
})
|
})
|
||||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('syncPicBed')
|
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('syncPicBed')
|
||||||
}
|
}
|
||||||
setTrayToolTip(item.type)
|
setTrayToolTip(item.type)
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// @ts-expect-error submenu type
|
// @ts-expect-error submenu type
|
||||||
@@ -259,7 +259,7 @@ const handleRestoreState = (item: string, name: string): void => {
|
|||||||
if (current === name) {
|
if (current === name) {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[configPaths.picBed.current]: 'smms',
|
[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)
|
const current = picgo.getConfig(configPaths.picBed.transformer)
|
||||||
if (current === name) {
|
if (current === name) {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[configPaths.picBed.transformer]: 'path'
|
[configPaths.picBed.transformer]: 'path',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,18 +280,18 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
|||||||
enabled: !plugin.enabled,
|
enabled: !plugin.enabled,
|
||||||
click() {
|
click() {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`picgoPlugins.${plugin.fullName}`]: true
|
[`picgoPlugins.${plugin.fullName}`]: true,
|
||||||
})
|
})
|
||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
window.webContents.send(PICGO_TOGGLE_PLUGIN, plugin.fullName, true)
|
window.webContents.send(PICGO_TOGGLE_PLUGIN, plugin.fullName, true)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('DISABLE_PLUGIN'),
|
label: $t('DISABLE_PLUGIN'),
|
||||||
enabled: plugin.enabled,
|
enabled: plugin.enabled,
|
||||||
click() {
|
click() {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`picgoPlugins.${plugin.fullName}`]: false
|
[`picgoPlugins.${plugin.fullName}`]: false,
|
||||||
})
|
})
|
||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
||||||
@@ -303,7 +303,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
|||||||
if (plugin.config.uploader.name) {
|
if (plugin.config.uploader.name) {
|
||||||
handleRestoreState('uploader', plugin.config.uploader.name)
|
handleRestoreState('uploader', plugin.config.uploader.name)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('UNINSTALL_PLUGIN'),
|
label: $t('UNINSTALL_PLUGIN'),
|
||||||
@@ -311,7 +311,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
|||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
||||||
handlePluginUninstall(plugin.fullName)
|
handlePluginUninstall(plugin.fullName)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('UPDATE_PLUGIN'),
|
label: $t('UPDATE_PLUGIN'),
|
||||||
@@ -319,14 +319,14 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
|||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
|
||||||
handlePluginUpdate(plugin.fullName)
|
handlePluginUpdate(plugin.fullName)
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
] as (MenuItemConstructorOptions | MenuItem)[]
|
] as (MenuItemConstructorOptions | MenuItem)[]
|
||||||
for (const i in plugin.config) {
|
for (const i in plugin.config) {
|
||||||
if (plugin.config[i].config.length > 0) {
|
if (plugin.config[i].config.length > 0) {
|
||||||
const obj = {
|
const obj = {
|
||||||
label: $t('CONFIG_THING', {
|
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() {
|
click() {
|
||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
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 configName = plugin.config[i].fullName || plugin.config[i].name
|
||||||
const config = plugin.config[i].config
|
const config = plugin.config[i].config
|
||||||
window.webContents.send(PICGO_CONFIG_PLUGIN, currentType, configName, config)
|
window.webContents.send(PICGO_CONFIG_PLUGIN, currentType, configName, config)
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
menu.push(obj)
|
menu.push(obj)
|
||||||
}
|
}
|
||||||
@@ -351,14 +351,14 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
|||||||
const currentTransformer = picgo.getConfig<string>(configPaths.picBed.transformer) || 'path'
|
const currentTransformer = picgo.getConfig<string>(configPaths.picBed.transformer) || 'path'
|
||||||
if (currentTransformer === transformer) {
|
if (currentTransformer === transformer) {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[configPaths.picBed.transformer]: 'path'
|
[configPaths.picBed.transformer]: 'path',
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[configPaths.picBed.transformer]: transformer
|
[configPaths.picBed.transformer]: transformer,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
menu.push(obj)
|
menu.push(obj)
|
||||||
}
|
}
|
||||||
@@ -366,7 +366,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
|||||||
// plugin custom menus
|
// plugin custom menus
|
||||||
if (plugin.guiMenu) {
|
if (plugin.guiMenu) {
|
||||||
menu.push({
|
menu.push({
|
||||||
type: 'separator'
|
type: 'separator',
|
||||||
})
|
})
|
||||||
for (const i of plugin.guiMenu) {
|
for (const i of plugin.guiMenu) {
|
||||||
menu.push({
|
menu.push({
|
||||||
@@ -381,7 +381,7 @@ const buildPluginPageMenu = (plugin: IPicGoPlugin) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ const routes = [
|
|||||||
toolboxRouter.routes(),
|
toolboxRouter.routes(),
|
||||||
trayRouter.routes(),
|
trayRouter.routes(),
|
||||||
uploadRouter.routes(),
|
uploadRouter.routes(),
|
||||||
manageRouter.routes()
|
manageRouter.routes(),
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const route of routes) {
|
for (const route of routes) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const galleryRoutes = [
|
|||||||
}
|
}
|
||||||
return [txt, shortUrl]
|
return [txt, shortUrl]
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.GALLERY_REMOVE_FILES,
|
action: IRPCActionType.GALLERY_REMOVE_FILES,
|
||||||
@@ -42,7 +42,7 @@ const galleryRoutes = [
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
picgo.emit(ICOREBuildInEvent.REMOVE, args[0], GuiApi.getInstance())
|
picgo.emit(ICOREBuildInEvent.REMOVE, args[0], GuiApi.getInstance())
|
||||||
}, 500)
|
}, 500)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.GALLERY_GET_DB,
|
action: IRPCActionType.GALLERY_GET_DB,
|
||||||
@@ -50,7 +50,7 @@ const galleryRoutes = [
|
|||||||
const dbStore = GalleryDB.getInstance()
|
const dbStore = GalleryDB.getInstance()
|
||||||
return await dbStore.get(args[0])
|
return await dbStore.get(args[0])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.GALLERY_GET_BY_ID_DB,
|
action: IRPCActionType.GALLERY_GET_BY_ID_DB,
|
||||||
@@ -58,7 +58,7 @@ const galleryRoutes = [
|
|||||||
const dbStore = GalleryDB.getInstance()
|
const dbStore = GalleryDB.getInstance()
|
||||||
return await dbStore.getById(args[0])
|
return await dbStore.getById(args[0])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.GALLERY_UPDATE_BY_ID_DB,
|
action: IRPCActionType.GALLERY_UPDATE_BY_ID_DB,
|
||||||
@@ -66,7 +66,7 @@ const galleryRoutes = [
|
|||||||
const dbStore = GalleryDB.getInstance()
|
const dbStore = GalleryDB.getInstance()
|
||||||
return await dbStore.updateById(args[0], args[1])
|
return await dbStore.updateById(args[0], args[1])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.GALLERY_REMOVE_BY_ID_DB,
|
action: IRPCActionType.GALLERY_REMOVE_BY_ID_DB,
|
||||||
@@ -74,7 +74,7 @@ const galleryRoutes = [
|
|||||||
const dbStore = GalleryDB.getInstance()
|
const dbStore = GalleryDB.getInstance()
|
||||||
return await dbStore.removeById(args[0])
|
return await dbStore.removeById(args[0])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.GALLERY_INSERT_DB,
|
action: IRPCActionType.GALLERY_INSERT_DB,
|
||||||
@@ -82,7 +82,7 @@ const galleryRoutes = [
|
|||||||
const dbStore = GalleryDB.getInstance()
|
const dbStore = GalleryDB.getInstance()
|
||||||
return await dbStore.insert(args[0])
|
return await dbStore.insert(args[0])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.GALLERY_INSERT_DB_BATCH,
|
action: IRPCActionType.GALLERY_INSERT_DB_BATCH,
|
||||||
@@ -90,8 +90,8 @@ const galleryRoutes = [
|
|||||||
const dbStore = GalleryDB.getInstance()
|
const dbStore = GalleryDB.getInstance()
|
||||||
return await dbStore.insertMany(args[0])
|
return await dbStore.insertMany(args[0])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
galleryRouter.addBatch(galleryRoutes)
|
galleryRouter.addBatch(galleryRoutes)
|
||||||
|
|||||||
@@ -9,93 +9,93 @@ export default [
|
|||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string]) => {
|
||||||
return new ManageApi(args[0]).getBucketList()
|
return new ManageApi(args[0]).getBucketList()
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_GET_BUCKET_LIST_BACKSTAGE,
|
action: IRPCActionType.MANAGE_GET_BUCKET_LIST_BACKSTAGE,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).getBucketListBackstage(args[1])
|
return new ManageApi(args[0]).getBucketListBackstage(args[1])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_GET_BUCKET_LIST_RECURSIVELY,
|
action: IRPCActionType.MANAGE_GET_BUCKET_LIST_RECURSIVELY,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).getBucketListRecursively(args[1])
|
return new ManageApi(args[0]).getBucketListRecursively(args[1])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_CREATE_BUCKET,
|
action: IRPCActionType.MANAGE_CREATE_BUCKET,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).createBucket(args[1])
|
return new ManageApi(args[0]).createBucket(args[1])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_GET_BUCKET_FILE_LIST,
|
action: IRPCActionType.MANAGE_GET_BUCKET_FILE_LIST,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).getBucketFileList(args[1])
|
return new ManageApi(args[0]).getBucketFileList(args[1])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_GET_BUCKET_DOMAIN,
|
action: IRPCActionType.MANAGE_GET_BUCKET_DOMAIN,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).getBucketDomain(args[1])
|
return new ManageApi(args[0]).getBucketDomain(args[1])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_SET_BUCKET_ACL_POLICY,
|
action: IRPCActionType.MANAGE_SET_BUCKET_ACL_POLICY,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).setBucketAclPolicy(args[1])
|
return new ManageApi(args[0]).setBucketAclPolicy(args[1])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_RENAME_BUCKET_FILE,
|
action: IRPCActionType.MANAGE_RENAME_BUCKET_FILE,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).renameBucketFile(args[1])
|
return new ManageApi(args[0]).renameBucketFile(args[1])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_DELETE_BUCKET_FILE,
|
action: IRPCActionType.MANAGE_DELETE_BUCKET_FILE,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).deleteBucketFile(args[1])
|
return new ManageApi(args[0]).deleteBucketFile(args[1])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_DELETE_BUCKET_FOLDER,
|
action: IRPCActionType.MANAGE_DELETE_BUCKET_FOLDER,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).deleteBucketFolder(args[1])
|
return new ManageApi(args[0]).deleteBucketFolder(args[1])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_GET_PRE_SIGNED_URL,
|
action: IRPCActionType.MANAGE_GET_PRE_SIGNED_URL,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).getPreSignedUrl(args[1])
|
return new ManageApi(args[0]).getPreSignedUrl(args[1])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_UPLOAD_BUCKET_FILE,
|
action: IRPCActionType.MANAGE_UPLOAD_BUCKET_FILE,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).uploadBucketFile(args[1])
|
return new ManageApi(args[0]).uploadBucketFile(args[1])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_DOWNLOAD_BUCKET_FILE,
|
action: IRPCActionType.MANAGE_DOWNLOAD_BUCKET_FILE,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).downloadBucketFile(args[1])
|
return new ManageApi(args[0]).downloadBucketFile(args[1])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_CREATE_BUCKET_FOLDER,
|
action: IRPCActionType.MANAGE_CREATE_BUCKET_FOLDER,
|
||||||
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
handler: async (_: IIPCEvent, args: [currentPicBed: string, param: IStringKeyMap]) => {
|
||||||
return new ManageApi(args[0]).createBucketFolder(args[1])
|
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]) => {
|
handler: async (_: IIPCEvent, args: [key?: string]) => {
|
||||||
return manageApi.getConfig(args[0])
|
return manageApi.getConfig(args[0])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_SAVE_CONFIG,
|
action: IRPCActionType.MANAGE_SAVE_CONFIG,
|
||||||
handler: async (_: IIPCEvent, args: [data: IObj]) => {
|
handler: async (_: IIPCEvent, args: [data: IObj]) => {
|
||||||
manageApi.saveConfig(args[0])
|
manageApi.saveConfig(args[0])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_REMOVE_CONFIG,
|
action: IRPCActionType.MANAGE_REMOVE_CONFIG,
|
||||||
handler: async (_: IIPCEvent, args: [key: string, propName: string]) => {
|
handler: async (_: IIPCEvent, args: [key: string, propName: string]) => {
|
||||||
manageApi.removeConfig(args[0], args[1])
|
manageApi.removeConfig(args[0], args[1])
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -13,66 +13,66 @@ export default [
|
|||||||
action: IRPCActionType.MANAGE_OPEN_FILE_SELECT_DIALOG,
|
action: IRPCActionType.MANAGE_OPEN_FILE_SELECT_DIALOG,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
const res = await dialog.showOpenDialog({
|
const res = await dialog.showOpenDialog({
|
||||||
properties: ['openFile', 'multiSelections']
|
properties: ['openFile', 'multiSelections'],
|
||||||
})
|
})
|
||||||
return res.canceled ? [] : res.filePaths
|
return res.canceled ? [] : res.filePaths
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_GET_UPLOAD_TASK_LIST,
|
action: IRPCActionType.MANAGE_GET_UPLOAD_TASK_LIST,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
return UpDownTaskQueue.getInstance().getAllUploadTask()
|
return UpDownTaskQueue.getInstance().getAllUploadTask()
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_GET_DOWNLOAD_TASK_LIST,
|
action: IRPCActionType.MANAGE_GET_DOWNLOAD_TASK_LIST,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
return UpDownTaskQueue.getInstance().getAllDownloadTask()
|
return UpDownTaskQueue.getInstance().getAllDownloadTask()
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_DELETE_UPLOADED_TASK,
|
action: IRPCActionType.MANAGE_DELETE_UPLOADED_TASK,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
UpDownTaskQueue.getInstance().removeUploadedTask()
|
UpDownTaskQueue.getInstance().removeUploadedTask()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_DELETE_ALL_UPLOADED_TASK,
|
action: IRPCActionType.MANAGE_DELETE_ALL_UPLOADED_TASK,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
UpDownTaskQueue.getInstance().clearUploadTaskQueue()
|
UpDownTaskQueue.getInstance().clearUploadTaskQueue()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_DELETE_DOWNLOADED_TASK,
|
action: IRPCActionType.MANAGE_DELETE_DOWNLOADED_TASK,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
UpDownTaskQueue.getInstance().removeDownloadedTask()
|
UpDownTaskQueue.getInstance().removeDownloadedTask()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_DELETE_ALL_DOWNLOADED_TASK,
|
action: IRPCActionType.MANAGE_DELETE_ALL_DOWNLOADED_TASK,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
UpDownTaskQueue.getInstance().clearDownloadTaskQueue()
|
UpDownTaskQueue.getInstance().clearDownloadTaskQueue()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_SELECT_DOWNLOAD_FOLDER,
|
action: IRPCActionType.MANAGE_SELECT_DOWNLOAD_FOLDER,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
const res = await dialog.showOpenDialog({
|
const res = await dialog.showOpenDialog({
|
||||||
properties: ['openDirectory']
|
properties: ['openDirectory'],
|
||||||
})
|
})
|
||||||
return res.filePaths[0]
|
return res.filePaths[0]
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_GET_DEFAULT_DOWNLOAD_FOLDER,
|
action: IRPCActionType.MANAGE_GET_DEFAULT_DOWNLOAD_FOLDER,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
return app.getPath('downloads')
|
return app.getPath('downloads')
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_OPEN_DOWNLOADED_FOLDER,
|
action: IRPCActionType.MANAGE_OPEN_DOWNLOADED_FOLDER,
|
||||||
@@ -83,27 +83,27 @@ export default [
|
|||||||
} else {
|
} else {
|
||||||
shell.openPath(app.getPath('downloads'))
|
shell.openPath(app.getPath('downloads'))
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_OPEN_LOCAL_FILE,
|
action: IRPCActionType.MANAGE_OPEN_LOCAL_FILE,
|
||||||
handler: async (_: IIPCEvent, args: [fullPath: string]) => {
|
handler: async (_: IIPCEvent, args: [fullPath: string]) => {
|
||||||
const fullPath = args[0]
|
const fullPath = args[0]
|
||||||
fs.existsSync(fullPath) ? shell.showItemInFolder(fullPath) : shell.openPath(path.dirname(fullPath))
|
fs.existsSync(fullPath) ? shell.showItemInFolder(fullPath) : shell.openPath(path.dirname(fullPath))
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_DOWNLOAD_FILE_FROM_URL,
|
action: IRPCActionType.MANAGE_DOWNLOAD_FILE_FROM_URL,
|
||||||
handler: async (_: IIPCEvent, args: [urls: string[]]) => {
|
handler: async (_: IIPCEvent, args: [urls: string[]]) => {
|
||||||
return await downloadFileFromUrl(args[0])
|
return await downloadFileFromUrl(args[0])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MANAGE_CONVERT_PATH_TO_BASE64,
|
action: IRPCActionType.MANAGE_CONVERT_PATH_TO_BASE64,
|
||||||
handler: async (_: IIPCEvent, args: [filePath: string]) => {
|
handler: async (_: IIPCEvent, args: [filePath: string]) => {
|
||||||
return fs.readFileSync(args[0], 'base64')
|
return fs.readFileSync(args[0], 'base64')
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ export default [
|
|||||||
handler: async (_: IIPCEvent, args: [item: ImgInfo]) => {
|
handler: async (_: IIPCEvent, args: [item: ImgInfo]) => {
|
||||||
return await ALLApi.delete(args[0])
|
return await ALLApi.delete(args[0])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
getUploaderConfigList,
|
getUploaderConfigList,
|
||||||
resetUploaderConfig,
|
resetUploaderConfig,
|
||||||
selectUploaderConfig,
|
selectUploaderConfig,
|
||||||
updateUploaderConfig
|
updateUploaderConfig,
|
||||||
} from '~/utils/handleUploaderConfig'
|
} from '~/utils/handleUploaderConfig'
|
||||||
|
|
||||||
const picbedRouter = new RPCRouter()
|
const picbedRouter = new RPCRouter()
|
||||||
@@ -34,7 +34,7 @@ const picbedRoutes = [
|
|||||||
const config = getUploaderConfigList(args[0])
|
const config = getUploaderConfigList(args[0])
|
||||||
return config
|
return config
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PICBED_DELETE_CONFIG,
|
action: IRPCActionType.PICBED_DELETE_CONFIG,
|
||||||
@@ -43,7 +43,7 @@ const picbedRoutes = [
|
|||||||
const config = deleteUploaderConfig(type, id)
|
const config = deleteUploaderConfig(type, id)
|
||||||
return config
|
return config
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.UPLOADER_SELECT,
|
action: IRPCActionType.UPLOADER_SELECT,
|
||||||
@@ -52,7 +52,7 @@ const picbedRoutes = [
|
|||||||
selectUploaderConfig(type, id)
|
selectUploaderConfig(type, id)
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.UPLOADER_UPDATE_CONFIG,
|
action: IRPCActionType.UPLOADER_UPDATE_CONFIG,
|
||||||
@@ -61,7 +61,7 @@ const picbedRoutes = [
|
|||||||
updateUploaderConfig(type, id, config)
|
updateUploaderConfig(type, id, config)
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.UPLOADER_RESET_CONFIG,
|
action: IRPCActionType.UPLOADER_RESET_CONFIG,
|
||||||
@@ -70,7 +70,7 @@ const picbedRoutes = [
|
|||||||
resetUploaderConfig(type, id)
|
resetUploaderConfig(type, id)
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PICBED_GET_PICBED_CONFIG,
|
action: IRPCActionType.PICBED_GET_PICBED_CONFIG,
|
||||||
@@ -82,17 +82,17 @@ const picbedRoutes = [
|
|||||||
const config = handleConfigWithFunction(_config)
|
const config = handleConfigWithFunction(_config)
|
||||||
return {
|
return {
|
||||||
config,
|
config,
|
||||||
name
|
name,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
config: [],
|
config: [],
|
||||||
name
|
name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
const picBedsRoutes = [...picbedRoutes, ...deleteRoutes]
|
const picBedsRoutes = [...picbedRoutes, ...deleteRoutes]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
pluginGetListFunc,
|
pluginGetListFunc,
|
||||||
pluginImportLocalFunc,
|
pluginImportLocalFunc,
|
||||||
pluginInstallFunc,
|
pluginInstallFunc,
|
||||||
pluginUpdateAllFunc
|
pluginUpdateAllFunc,
|
||||||
} from '~/events/rpc/routes/plugin/utils'
|
} from '~/events/rpc/routes/plugin/utils'
|
||||||
import { IRPCActionType } from '~/utils/enum'
|
import { IRPCActionType } from '~/utils/enum'
|
||||||
|
|
||||||
@@ -12,20 +12,20 @@ const pluginRouter = new RPCRouter()
|
|||||||
const pluginRoutes = [
|
const pluginRoutes = [
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PLUGIN_GET_LIST,
|
action: IRPCActionType.PLUGIN_GET_LIST,
|
||||||
handler: pluginGetListFunc
|
handler: pluginGetListFunc,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PLUGIN_INSTALL,
|
action: IRPCActionType.PLUGIN_INSTALL,
|
||||||
handler: pluginInstallFunc
|
handler: pluginInstallFunc,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PLUGIN_IMPORT_LOCAL,
|
action: IRPCActionType.PLUGIN_IMPORT_LOCAL,
|
||||||
handler: pluginImportLocalFunc
|
handler: pluginImportLocalFunc,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PLUGIN_UPDATE_ALL,
|
action: IRPCActionType.PLUGIN_UPDATE_ALL,
|
||||||
handler: pluginUpdateAllFunc
|
handler: pluginUpdateAllFunc,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
pluginRouter.addBatch(pluginRoutes)
|
pluginRouter.addBatch(pluginRoutes)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ const getPluginList = async (): Promise<IPicGoPlugin[]> => {
|
|||||||
let menu: Omit<IGuiMenuItem, 'handle'>[] = []
|
let menu: Omit<IGuiMenuItem, 'handle'>[] = []
|
||||||
if (plugin.guiMenu) {
|
if (plugin.guiMenu) {
|
||||||
menu = plugin.guiMenu(picgo).map(item => ({
|
menu = plugin.guiMenu(picgo).map(item => ({
|
||||||
label: item.label
|
label: item.label,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
let gui = false
|
let gui = false
|
||||||
@@ -81,25 +81,25 @@ const getPluginList = async (): Promise<IPicGoPlugin[]> => {
|
|||||||
plugin: {
|
plugin: {
|
||||||
fullName: pluginList[i],
|
fullName: pluginList[i],
|
||||||
name: handleStreamlinePluginName(pluginList[i]),
|
name: handleStreamlinePluginName(pluginList[i]),
|
||||||
config: plugin.config ? handleConfigWithFunction(plugin.config(picgo)) : []
|
config: plugin.config ? handleConfigWithFunction(plugin.config(picgo)) : [],
|
||||||
},
|
},
|
||||||
uploader: {
|
uploader: {
|
||||||
name: uploaderName,
|
name: uploaderName,
|
||||||
config: handleConfigWithFunction(
|
config: handleConfigWithFunction(
|
||||||
getConfig(uploaderName, IPicGoHelperType.uploader as keyof typeof IPicGoHelperType, picgo)
|
getConfig(uploaderName, IPicGoHelperType.uploader as keyof typeof IPicGoHelperType, picgo),
|
||||||
)
|
),
|
||||||
},
|
},
|
||||||
transformer: {
|
transformer: {
|
||||||
name: transformerName,
|
name: transformerName,
|
||||||
config: handleConfigWithFunction(
|
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]}`),
|
enabled: picgo.getConfig(`picgoPlugins.${pluginList[i]}`),
|
||||||
homepage: pluginPKG.homepage ? pluginPKG.homepage : '',
|
homepage: pluginPKG.homepage ? pluginPKG.homepage : '',
|
||||||
guiMenu: menu,
|
guiMenu: menu,
|
||||||
ing: false
|
ing: false,
|
||||||
}
|
}
|
||||||
list.push(obj)
|
list.push(obj)
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ const handleNPMError = (): IDispose => {
|
|||||||
.showMessageBox({
|
.showMessageBox({
|
||||||
title: $t('TIPS_ERROR'),
|
title: $t('TIPS_ERROR'),
|
||||||
message: $t('TIPS_INSTALL_NODE_AND_RELOAD_PICGO'),
|
message: $t('TIPS_INSTALL_NODE_AND_RELOAD_PICGO'),
|
||||||
buttons: ['Yes']
|
buttons: ['Yes'],
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.response === 0) {
|
if (res.response === 0) {
|
||||||
@@ -135,7 +135,7 @@ export const handlePluginUpdate = async (fullName: string | string[]) => {
|
|||||||
} else {
|
} else {
|
||||||
showNotification({
|
showNotification({
|
||||||
title: $t('PLUGIN_UPDATE_FAILED'),
|
title: $t('PLUGIN_UPDATE_FAILED'),
|
||||||
body: res.body as string
|
body: res.body as string,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
window.webContents.send('hideLoading')
|
window.webContents.send('hideLoading')
|
||||||
@@ -152,7 +152,7 @@ export const handlePluginUninstall = async (fullName: string) => {
|
|||||||
} else {
|
} else {
|
||||||
showNotification({
|
showNotification({
|
||||||
title: $t('PLUGIN_UNINSTALL_FAILED'),
|
title: $t('PLUGIN_UNINSTALL_FAILED'),
|
||||||
body: res.body as string
|
body: res.body as string,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
window.webContents.send('hideLoading')
|
window.webContents.send('hideLoading')
|
||||||
@@ -169,7 +169,7 @@ export const pluginGetListFunc = async (event: IIPCEvent) => {
|
|||||||
event.sender.send('pluginList', [])
|
event.sender.send('pluginList', [])
|
||||||
showNotification({
|
showNotification({
|
||||||
title: $t('TIPS_GET_PLUGIN_LIST_FAILED'),
|
title: $t('TIPS_GET_PLUGIN_LIST_FAILED'),
|
||||||
body: e.message
|
body: e.message,
|
||||||
})
|
})
|
||||||
picgo.log.error(e)
|
picgo.log.error(e)
|
||||||
}
|
}
|
||||||
@@ -182,14 +182,14 @@ export const pluginInstallFunc = async (event: IIPCEvent, args: [fullName: strin
|
|||||||
event.sender.send('installPlugin', {
|
event.sender.send('installPlugin', {
|
||||||
success: res.success,
|
success: res.success,
|
||||||
body: fullName,
|
body: fullName,
|
||||||
errMsg: res.success ? '' : res.body
|
errMsg: res.success ? '' : res.body,
|
||||||
})
|
})
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
await shortKeyHandler.registerPluginShortKey(res.body[0])
|
await shortKeyHandler.registerPluginShortKey(res.body[0])
|
||||||
} else {
|
} else {
|
||||||
showNotification({
|
showNotification({
|
||||||
title: $t('PLUGIN_INSTALL_FAILED'),
|
title: $t('PLUGIN_INSTALL_FAILED'),
|
||||||
body: res.body as string
|
body: res.body as string,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
event.sender.send('hideLoading')
|
event.sender.send('hideLoading')
|
||||||
@@ -199,7 +199,7 @@ export const pluginInstallFunc = async (event: IIPCEvent, args: [fullName: strin
|
|||||||
export const pluginImportLocalFunc = async (event: IIPCEvent) => {
|
export const pluginImportLocalFunc = async (event: IIPCEvent) => {
|
||||||
const settingWindow = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const settingWindow = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
const res = await dialog.showOpenDialog(settingWindow, {
|
const res = await dialog.showOpenDialog(settingWindow, {
|
||||||
properties: ['openDirectory']
|
properties: ['openDirectory'],
|
||||||
})
|
})
|
||||||
const filePaths = res.filePaths
|
const filePaths = res.filePaths
|
||||||
if (filePaths.length > 0) {
|
if (filePaths.length > 0) {
|
||||||
@@ -212,17 +212,17 @@ export const pluginImportLocalFunc = async (event: IIPCEvent) => {
|
|||||||
event.sender.send('pluginList', [])
|
event.sender.send('pluginList', [])
|
||||||
showNotification({
|
showNotification({
|
||||||
title: $t('TIPS_GET_PLUGIN_LIST_FAILED'),
|
title: $t('TIPS_GET_PLUGIN_LIST_FAILED'),
|
||||||
body: e.message
|
body: e.message,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
showNotification({
|
showNotification({
|
||||||
title: $t('PLUGIN_IMPORT_SUCCEED'),
|
title: $t('PLUGIN_IMPORT_SUCCEED'),
|
||||||
body: ''
|
body: '',
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
showNotification({
|
showNotification({
|
||||||
title: $t('PLUGIN_IMPORT_FAILED'),
|
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,
|
action: IRPCActionType.ADVANCED_UPDATE_SERVER,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
server.restart()
|
server.restart()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.ADVANCED_STOP_WEB_SERVER,
|
action: IRPCActionType.ADVANCED_STOP_WEB_SERVER,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
webServer.stop()
|
webServer.stop()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.ADVANCED_RESTART_WEB_SERVER,
|
action: IRPCActionType.ADVANCED_RESTART_WEB_SERVER,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
webServer.restart()
|
webServer.restart()
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default [
|
|||||||
const sourcePath = path.join(picGoConfigPath, file)
|
const sourcePath = path.join(picGoConfigPath, file)
|
||||||
const targetPath = path.join(STORE_PATH, file.replace('picgo', 'piclist'))
|
const targetPath = path.join(STORE_PATH, file.replace('picgo', 'piclist'))
|
||||||
await fs.copy(sourcePath, targetPath, { overwrite: true })
|
await fs.copy(sourcePath, targetPath, { overwrite: true })
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
return true
|
return true
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
@@ -32,48 +32,48 @@ export default [
|
|||||||
throw new Error('Migrate failed')
|
throw new Error('Migrate failed')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.CONFIGURE_UPLOAD_COMMON_CONFIG,
|
action: IRPCActionType.CONFIGURE_UPLOAD_COMMON_CONFIG,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
return await uploadFile(commonConfigList)
|
return await uploadFile(commonConfigList)
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.CONFIGURE_UPLOAD_MANAGE_CONFIG,
|
action: IRPCActionType.CONFIGURE_UPLOAD_MANAGE_CONFIG,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
return await uploadFile(manageConfigList)
|
return await uploadFile(manageConfigList)
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.CONFIGURE_UPLOAD_ALL_CONFIG,
|
action: IRPCActionType.CONFIGURE_UPLOAD_ALL_CONFIG,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
return await uploadFile([...commonConfigList, ...manageConfigList])
|
return await uploadFile([...commonConfigList, ...manageConfigList])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.CONFIGURE_DOWNLOAD_COMMON_CONFIG,
|
action: IRPCActionType.CONFIGURE_DOWNLOAD_COMMON_CONFIG,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
return await downloadFile(commonConfigList)
|
return await downloadFile(commonConfigList)
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.CONFIGURE_DOWNLOAD_MANAGE_CONFIG,
|
action: IRPCActionType.CONFIGURE_DOWNLOAD_MANAGE_CONFIG,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
return await downloadFile(manageConfigList)
|
return await downloadFile(manageConfigList)
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.CONFIGURE_DOWNLOAD_ALL_CONFIG,
|
action: IRPCActionType.CONFIGURE_DOWNLOAD_ALL_CONFIG,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
return await downloadFile([...commonConfigList, ...manageConfigList])
|
return await downloadFile([...commonConfigList, ...manageConfigList])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default [
|
|||||||
handler: async (_: IIPCEvent, args: [key?: string]) => {
|
handler: async (_: IIPCEvent, args: [key?: string]) => {
|
||||||
return picgo.getConfig(args[0])
|
return picgo.getConfig(args[0])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PICLIST_GET_CONFIG_SYNC,
|
action: IRPCActionType.PICLIST_GET_CONFIG_SYNC,
|
||||||
@@ -26,13 +26,13 @@ export default [
|
|||||||
const result = picgo.getConfig(args[0])
|
const result = picgo.getConfig(args[0])
|
||||||
const eventInstance = event as IpcMainEvent
|
const eventInstance = event as IpcMainEvent
|
||||||
eventInstance.returnValue = result
|
eventInstance.returnValue = result
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PICLIST_SAVE_CONFIG,
|
action: IRPCActionType.PICLIST_SAVE_CONFIG,
|
||||||
handler: async (_: IIPCEvent, args: [data: IObj]) => {
|
handler: async (_: IIPCEvent, args: [data: IObj]) => {
|
||||||
picgo.saveConfig(args[0])
|
picgo.saveConfig(args[0])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PICLIST_OPEN_FILE,
|
action: IRPCActionType.PICLIST_OPEN_FILE,
|
||||||
@@ -42,12 +42,13 @@ export default [
|
|||||||
fs.writeFileSync(abFilePath, '')
|
fs.writeFileSync(abFilePath, '')
|
||||||
}
|
}
|
||||||
shell.openPath(abFilePath)
|
shell.openPath(abFilePath)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PICLIST_OPEN_DIRECTORY,
|
action: IRPCActionType.PICLIST_OPEN_DIRECTORY,
|
||||||
handler: async (_: IIPCEvent, args: [dirPath?: string, inStorePath?: boolean]) => {
|
handler: async (_: IIPCEvent, args: [dirPath?: string, inStorePath?: boolean]) => {
|
||||||
let [dirPath, inStorePath = true] = args
|
let [dirPath] = args
|
||||||
|
const [inStorePath = true] = args
|
||||||
if (inStorePath) {
|
if (inStorePath) {
|
||||||
dirPath = path.join(STORE_PATH, dirPath || '')
|
dirPath = path.join(STORE_PATH, dirPath || '')
|
||||||
}
|
}
|
||||||
@@ -55,19 +56,19 @@ export default [
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
shell.openPath(dirPath)
|
shell.openPath(dirPath)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PICLIST_AUTO_START,
|
action: IRPCActionType.PICLIST_AUTO_START,
|
||||||
handler: async (_: IIPCEvent, args: [val: boolean]) => {
|
handler: async (_: IIPCEvent, args: [val: boolean]) => {
|
||||||
await setAutoStart(args[0])
|
await setAutoStart(args[0])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.PICLIST_AUTO_START_STATUS,
|
action: IRPCActionType.PICLIST_AUTO_START_STATUS,
|
||||||
handler: async (_: IIPCEvent) => {
|
handler: async (_: IIPCEvent) => {
|
||||||
return await isAutoStartEnabled()
|
return await isAutoStartEnabled()
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { IRPCActionType, IRPCType } from '~/utils/enum'
|
|||||||
const notificationFunc = (result: boolean) => {
|
const notificationFunc = (result: boolean) => {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: $t(`OPERATION_${result ? 'SUCCEED' : 'FAILED'}`),
|
title: $t(`OPERATION_${result ? 'SUCCEED' : 'FAILED'}`),
|
||||||
body: $t(`TIPS_SHORTCUT_MODIFIED_${result ? 'SUCCEED' : 'CONFLICT'}`)
|
body: $t(`TIPS_SHORTCUT_MODIFIED_${result ? 'SUCCEED' : 'CONFLICT'}`),
|
||||||
})
|
})
|
||||||
notification.show()
|
notification.show()
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ export default [
|
|||||||
notificationFunc(result)
|
notificationFunc(result)
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.SHORTKEY_BIND_OR_UNBIND,
|
action: IRPCActionType.SHORTKEY_BIND_OR_UNBIND,
|
||||||
@@ -33,13 +33,13 @@ export default [
|
|||||||
const [item, from] = args
|
const [item, from] = args
|
||||||
const result = shortKeyHandler.bindOrUnbindShortKey(item, from)
|
const result = shortKeyHandler.bindOrUnbindShortKey(item, from)
|
||||||
notificationFunc(result)
|
notificationFunc(result)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.SHORTKEY_TOGGLE_SHORTKEY_MODIFIED_MODE,
|
action: IRPCActionType.SHORTKEY_TOGGLE_SHORTKEY_MODIFIED_MODE,
|
||||||
handler: async (_: IIPCEvent, args: [status: boolean]) => {
|
handler: async (_: IIPCEvent, args: [status: boolean]) => {
|
||||||
const [status] = args
|
const [status] = args
|
||||||
bus.emit(TOGGLE_SHORTKEY_MODIFIED_MODE, status)
|
bus.emit(TOGGLE_SHORTKEY_MODIFIED_MODE, status)
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -11,19 +11,19 @@ export default [
|
|||||||
handler: async () => {
|
handler: async () => {
|
||||||
app.relaunch()
|
app.relaunch()
|
||||||
app.exit(0)
|
app.exit(0)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.OPEN_FILE,
|
action: IRPCActionType.OPEN_FILE,
|
||||||
handler: async (_: IIPCEvent, args: [filePath: string]) => {
|
handler: async (_: IIPCEvent, args: [filePath: string]) => {
|
||||||
shell.openPath(args[0])
|
shell.openPath(args[0])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.OPEN_URL,
|
action: IRPCActionType.OPEN_URL,
|
||||||
handler: async (_: IIPCEvent, args: [url: string]) => {
|
handler: async (_: IIPCEvent, args: [url: string]) => {
|
||||||
shell.openExternal(args[0])
|
shell.openExternal(args[0])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.SET_CURRENT_LANGUAGE,
|
action: IRPCActionType.SET_CURRENT_LANGUAGE,
|
||||||
@@ -31,6 +31,6 @@ export default [
|
|||||||
i18nManager.setCurrentLanguage(args[0])
|
i18nManager.setCurrentLanguage(args[0])
|
||||||
const { lang } = i18nManager.getCurrentLocales()
|
const { lang } = i18nManager.getCurrentLocales()
|
||||||
picgo.i18n.setLanguage(lang)
|
picgo.i18n.setLanguage(lang)
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
buildMiniPageMenu,
|
buildMiniPageMenu,
|
||||||
buildPicBedListMenu,
|
buildPicBedListMenu,
|
||||||
buildPluginPageMenu,
|
buildPluginPageMenu,
|
||||||
buildSecondPicBedMenu
|
buildSecondPicBedMenu,
|
||||||
} from '~/events/remotes/menu'
|
} from '~/events/remotes/menu'
|
||||||
import { IRPCActionType, IWindowList } from '~/utils/enum'
|
import { IRPCActionType, IWindowList } from '~/utils/enum'
|
||||||
import { openMiniWindow } from '~/utils/windowHelper'
|
import { openMiniWindow } from '~/utils/windowHelper'
|
||||||
@@ -18,7 +18,7 @@ export default [
|
|||||||
action: IRPCActionType.HIDE_DOCK,
|
action: IRPCActionType.HIDE_DOCK,
|
||||||
handler: async (_: IIPCEvent, args: [value: boolean]) => {
|
handler: async (_: IIPCEvent, args: [value: boolean]) => {
|
||||||
args[0] ? app.dock?.hide() : app.dock?.show()
|
args[0] ? app.dock?.hide() : app.dock?.show()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.OPEN_WINDOW,
|
action: IRPCActionType.OPEN_WINDOW,
|
||||||
@@ -27,13 +27,13 @@ export default [
|
|||||||
if (window) {
|
if (window) {
|
||||||
window.show()
|
window.show()
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.OPEN_MINI_WINDOW,
|
action: IRPCActionType.OPEN_MINI_WINDOW,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
openMiniWindow()
|
openMiniWindow()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.CLOSE_WINDOW,
|
action: IRPCActionType.CLOSE_WINDOW,
|
||||||
@@ -44,14 +44,14 @@ export default [
|
|||||||
} else {
|
} else {
|
||||||
window?.close()
|
window?.close()
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MINIMIZE_WINDOW,
|
action: IRPCActionType.MINIMIZE_WINDOW,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
const window = BrowserWindow.getFocusedWindow()
|
const window = BrowserWindow.getFocusedWindow()
|
||||||
window?.minimize()
|
window?.minimize()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.SHOW_MINI_PAGE_MENU,
|
action: IRPCActionType.SHOW_MINI_PAGE_MENU,
|
||||||
@@ -59,9 +59,9 @@ export default [
|
|||||||
const window = windowManager.get(IWindowList.MINI_WINDOW)!
|
const window = windowManager.get(IWindowList.MINI_WINDOW)!
|
||||||
const menu = buildMiniPageMenu()
|
const menu = buildMiniPageMenu()
|
||||||
menu.popup({
|
menu.popup({
|
||||||
window
|
window,
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.SHOW_MAIN_PAGE_MENU,
|
action: IRPCActionType.SHOW_MAIN_PAGE_MENU,
|
||||||
@@ -69,9 +69,9 @@ export default [
|
|||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
const menu = buildMainPageMenu(window)
|
const menu = buildMainPageMenu(window)
|
||||||
menu.popup({
|
menu.popup({
|
||||||
window
|
window,
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.SHOW_UPLOAD_PAGE_MENU,
|
action: IRPCActionType.SHOW_UPLOAD_PAGE_MENU,
|
||||||
@@ -79,9 +79,9 @@ export default [
|
|||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
const menu = buildPicBedListMenu()
|
const menu = buildPicBedListMenu()
|
||||||
menu.popup({
|
menu.popup({
|
||||||
window
|
window,
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.SHOW_SECOND_UPLOADER_MENU,
|
action: IRPCActionType.SHOW_SECOND_UPLOADER_MENU,
|
||||||
@@ -89,9 +89,9 @@ export default [
|
|||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
const menu = buildSecondPicBedMenu()
|
const menu = buildSecondPicBedMenu()
|
||||||
menu.popup({
|
menu.popup({
|
||||||
window
|
window,
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.SHOW_PLUGIN_PAGE_MENU,
|
action: IRPCActionType.SHOW_PLUGIN_PAGE_MENU,
|
||||||
@@ -99,23 +99,23 @@ export default [
|
|||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
const menu = buildPluginPageMenu(args[0])
|
const menu = buildPluginPageMenu(args[0])
|
||||||
menu.popup({
|
menu.popup({
|
||||||
window
|
window,
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.SET_MINI_WINDOW_POS,
|
action: IRPCActionType.SET_MINI_WINDOW_POS,
|
||||||
handler: async (_: IIPCEvent, args: [pos: IMiniWindowPos]) => {
|
handler: async (_: IIPCEvent, args: [pos: IMiniWindowPos]) => {
|
||||||
const window = BrowserWindow.getFocusedWindow()
|
const window = BrowserWindow.getFocusedWindow()
|
||||||
window?.setBounds(args[0])
|
window?.setBounds(args[0])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MINI_WINDOW_ON_TOP,
|
action: IRPCActionType.MINI_WINDOW_ON_TOP,
|
||||||
handler: async (_: IIPCEvent, args: [isOnTop: boolean]) => {
|
handler: async (_: IIPCEvent, args: [isOnTop: boolean]) => {
|
||||||
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
|
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
|
||||||
miniWindow.setAlwaysOnTop(args[0])
|
miniWindow.setAlwaysOnTop(args[0])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.MAIN_WINDOW_ON_TOP,
|
action: IRPCActionType.MAIN_WINDOW_ON_TOP,
|
||||||
@@ -123,14 +123,14 @@ export default [
|
|||||||
const mainWindow = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const mainWindow = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
const isAlwaysOnTop = mainWindow.isAlwaysOnTop()
|
const isAlwaysOnTop = mainWindow.isAlwaysOnTop()
|
||||||
mainWindow.setAlwaysOnTop(!isAlwaysOnTop)
|
mainWindow.setAlwaysOnTop(!isAlwaysOnTop)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.UPDATE_MINI_WINDOW_ICON,
|
action: IRPCActionType.UPDATE_MINI_WINDOW_ICON,
|
||||||
handler: async (_: IIPCEvent, args: [iconPath: string]) => {
|
handler: async (_: IIPCEvent, args: [iconPath: string]) => {
|
||||||
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
|
const miniWindow = windowManager.get(IWindowList.MINI_WINDOW)!
|
||||||
miniWindow.webContents.send('updateMiniIcon', args[0])
|
miniWindow.webContents.send('updateMiniIcon', args[0])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.REFRESH_SETTING_WINDOW,
|
action: IRPCActionType.REFRESH_SETTING_WINDOW,
|
||||||
@@ -139,6 +139,6 @@ export default [
|
|||||||
settingWindow.webContents.session.clearCache().then(() => {
|
settingWindow.webContents.session.clearCache().then(() => {
|
||||||
settingWindow.webContents.reloadIgnoringCache()
|
settingWindow.webContents.reloadIgnoringCache()
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const defaultClipboardImagePath = path.join(defaultConfigPath, CLIPBOARD_IMAGE_F
|
|||||||
export const checkClipboardUploadMap: IToolboxCheckerMap<string> = {
|
export const checkClipboardUploadMap: IToolboxCheckerMap<string> = {
|
||||||
[IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD]: async event => {
|
[IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD]: async event => {
|
||||||
sendToolboxRes(event, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.LOADING
|
status: IToolboxItemCheckStatus.LOADING,
|
||||||
})
|
})
|
||||||
const configFilePath = dbPathChecker()
|
const configFilePath = dbPathChecker()
|
||||||
if (fs.existsSync(configFilePath)) {
|
if (fs.existsSync(configFilePath)) {
|
||||||
@@ -26,29 +26,29 @@ export const checkClipboardUploadMap: IToolboxCheckerMap<string> = {
|
|||||||
sendToolboxRes(event, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.SUCCESS,
|
status: IToolboxItemCheckStatus.SUCCESS,
|
||||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_TIPS', {
|
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_TIPS', {
|
||||||
path: clipboardImagePath
|
path: clipboardImagePath,
|
||||||
}),
|
}),
|
||||||
value: clipboardImagePath
|
value: clipboardImagePath,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
sendToolboxRes(event, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.ERROR,
|
status: IToolboxItemCheckStatus.ERROR,
|
||||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS', {
|
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS', {
|
||||||
path: clipboardImagePath
|
path: clipboardImagePath,
|
||||||
}),
|
}),
|
||||||
value: path.dirname(clipboardImagePath)
|
value: path.dirname(clipboardImagePath),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sendToolboxRes(event, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.ERROR,
|
status: IToolboxItemCheckStatus.ERROR,
|
||||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_NOT_EXIST_TIPS', {
|
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> = {
|
export const fixClipboardUploadMap: IToolboxFixMap<string> = {
|
||||||
@@ -60,17 +60,17 @@ export const fixClipboardUploadMap: IToolboxFixMap<string> = {
|
|||||||
fs.mkdirsSync(clipboardImagePath)
|
fs.mkdirsSync(clipboardImagePath)
|
||||||
return {
|
return {
|
||||||
type: IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD,
|
type: IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD,
|
||||||
status: IToolboxItemCheckStatus.SUCCESS
|
status: IToolboxItemCheckStatus.SUCCESS,
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
return {
|
return {
|
||||||
type: IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD,
|
type: IToolboxItemType.HAS_PROBLEM_WITH_CLIPBOARD_PIC_UPLOAD,
|
||||||
status: IToolboxItemCheckStatus.ERROR,
|
status: IToolboxItemCheckStatus.ERROR,
|
||||||
msg: $t('TOOLBOX_CHECK_CLIPBOARD_FILE_PATH_ERROR_TIPS', {
|
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) => {
|
[IToolboxItemType.IS_CONFIG_FILE_BROKEN]: async (event: IpcMainEvent) => {
|
||||||
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.IS_CONFIG_FILE_BROKEN)
|
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.IS_CONFIG_FILE_BROKEN)
|
||||||
sendToolboxRes(event, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.LOADING
|
status: IToolboxItemCheckStatus.LOADING,
|
||||||
})
|
})
|
||||||
const configFilePath = dbPathChecker()
|
const configFilePath = dbPathChecker()
|
||||||
try {
|
try {
|
||||||
@@ -23,64 +23,64 @@ export const checkFileMap: IToolboxCheckerMap<string> = {
|
|||||||
sendToolboxRes(event, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.SUCCESS,
|
status: IToolboxItemCheckStatus.SUCCESS,
|
||||||
msg: $t('TOOLBOX_CHECK_CONFIG_FILE_PATH_TIPS', {
|
msg: $t('TOOLBOX_CHECK_CONFIG_FILE_PATH_TIPS', {
|
||||||
path: configFilePath
|
path: configFilePath,
|
||||||
}),
|
}),
|
||||||
value: configFilePath
|
value: configFilePath,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
sendToolboxRes(event, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.ERROR,
|
status: IToolboxItemCheckStatus.ERROR,
|
||||||
msg: $t('TOOLBOX_CHECK_CONFIG_FILE_BROKEN_TIPS'),
|
msg: $t('TOOLBOX_CHECK_CONFIG_FILE_BROKEN_TIPS'),
|
||||||
value: path.dirname(configFilePath)
|
value: path.dirname(configFilePath),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[IToolboxItemType.IS_GALLERY_FILE_BROKEN]: async event => {
|
[IToolboxItemType.IS_GALLERY_FILE_BROKEN]: async event => {
|
||||||
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.IS_GALLERY_FILE_BROKEN)
|
const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.IS_GALLERY_FILE_BROKEN)
|
||||||
sendToolboxRes(event, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.LOADING
|
status: IToolboxItemCheckStatus.LOADING,
|
||||||
})
|
})
|
||||||
const galleryDB = GalleryDB.getInstance()
|
const galleryDB = GalleryDB.getInstance()
|
||||||
if (galleryDB.errorList.length === 0) {
|
if (galleryDB.errorList.length === 0) {
|
||||||
sendToolboxRes(event, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.SUCCESS,
|
status: IToolboxItemCheckStatus.SUCCESS,
|
||||||
msg: $t('TOOLBOX_CHECK_GALLERY_FILE_PATH_TIPS', {
|
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 {
|
} else {
|
||||||
sendToolboxRes(event, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.ERROR,
|
status: IToolboxItemCheckStatus.ERROR,
|
||||||
msg: $t('TOOLBOX_CHECK_GALLERY_FILE_BROKEN_TIPS'),
|
msg: $t('TOOLBOX_CHECK_GALLERY_FILE_BROKEN_TIPS'),
|
||||||
value: path.dirname(DB_PATH)
|
value: path.dirname(DB_PATH),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fixFileMap: IToolboxFixMap<string> = {
|
export const fixFileMap: IToolboxFixMap<string> = {
|
||||||
[IToolboxItemType.IS_CONFIG_FILE_BROKEN]: async () => {
|
[IToolboxItemType.IS_CONFIG_FILE_BROKEN]: async () => {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(dbPathChecker())
|
fs.unlinkSync(dbPathChecker())
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type: IToolboxItemType.IS_CONFIG_FILE_BROKEN,
|
type: IToolboxItemType.IS_CONFIG_FILE_BROKEN,
|
||||||
status: IToolboxItemCheckStatus.SUCCESS
|
status: IToolboxItemCheckStatus.SUCCESS,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[IToolboxItemType.IS_GALLERY_FILE_BROKEN]: async () => {
|
[IToolboxItemType.IS_GALLERY_FILE_BROKEN]: async () => {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(DB_PATH)
|
fs.unlinkSync(DB_PATH)
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type: IToolboxItemType.IS_GALLERY_FILE_BROKEN,
|
type: IToolboxItemType.IS_GALLERY_FILE_BROKEN,
|
||||||
status: IToolboxItemCheckStatus.SUCCESS
|
status: IToolboxItemCheckStatus.SUCCESS,
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ function getProxy(proxyStr: string): AxiosRequestConfig['proxy'] | null {
|
|||||||
return {
|
return {
|
||||||
host: proxyOptions.hostname,
|
host: proxyOptions.hostname,
|
||||||
port: parseInt(proxyOptions.port || '0', 10),
|
port: parseInt(proxyOptions.port || '0', 10),
|
||||||
protocol: proxyOptions.protocol
|
protocol: proxyOptions.protocol,
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (_e) {}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -28,18 +28,18 @@ const sendToolboxRes = sendToolboxResWithType(IToolboxItemType.HAS_PROBLEM_WITH_
|
|||||||
export const checkProxyMap: IToolboxCheckerMap<string> = {
|
export const checkProxyMap: IToolboxCheckerMap<string> = {
|
||||||
[IToolboxItemType.HAS_PROBLEM_WITH_PROXY]: async event => {
|
[IToolboxItemType.HAS_PROBLEM_WITH_PROXY]: async event => {
|
||||||
sendToolboxRes(event, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.LOADING
|
status: IToolboxItemCheckStatus.LOADING,
|
||||||
})
|
})
|
||||||
const configFilePath = dbPathChecker()
|
const configFilePath = dbPathChecker()
|
||||||
if (fs.existsSync(configFilePath)) {
|
if (fs.existsSync(configFilePath)) {
|
||||||
let config: IConfig | undefined
|
let config: IConfig | undefined
|
||||||
try {
|
try {
|
||||||
config = (await fs.readJSON(configFilePath)) as IConfig
|
config = (await fs.readJSON(configFilePath)) as IConfig
|
||||||
} catch (e) {}
|
} catch (_e) {}
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return sendToolboxRes(event, {
|
return sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.SUCCESS,
|
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) {
|
if (!proxy) {
|
||||||
return sendToolboxRes(event, {
|
return sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.SUCCESS,
|
status: IToolboxItemCheckStatus.SUCCESS,
|
||||||
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS')
|
msg: $t('TOOLBOX_CHECK_PROXY_NO_PROXY_TIPS'),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const proxyOptions = getProxy(proxy)
|
const proxyOptions = getProxy(proxy)
|
||||||
if (!proxyOptions) {
|
if (!proxyOptions) {
|
||||||
return sendToolboxRes(event, {
|
return sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.ERROR,
|
status: IToolboxItemCheckStatus.ERROR,
|
||||||
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_CORRECT')
|
msg: $t('TOOLBOX_CHECK_PROXY_PROXY_IS_NOT_CORRECT'),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const httpsAgent = tunnel.httpsOverHttp({
|
const httpsAgent = tunnel.httpsOverHttp({
|
||||||
proxy: {
|
proxy: {
|
||||||
host: proxyOptions.host,
|
host: proxyOptions.host,
|
||||||
port: proxyOptions.port
|
port: proxyOptions.port,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
await axios.get('https://www.google.com', {
|
await axios.get('https://www.google.com', {
|
||||||
httpsAgent
|
httpsAgent,
|
||||||
})
|
})
|
||||||
return sendToolboxRes(event, {
|
return sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.SUCCESS,
|
status: IToolboxItemCheckStatus.SUCCESS,
|
||||||
msg: $t('TOOLBOX_CHECK_PROXY_SUCCESS_TIPS')
|
msg: $t('TOOLBOX_CHECK_PROXY_SUCCESS_TIPS'),
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
return sendToolboxRes(event, {
|
return sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.ERROR,
|
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, {
|
sendToolboxRes(event, {
|
||||||
status: IToolboxItemCheckStatus.SUCCESS,
|
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>> = {
|
const toolboxCheckMap: Partial<IToolboxCheckerMap<string>> = {
|
||||||
...checkFileMap,
|
...checkFileMap,
|
||||||
...checkClipboardUploadMap,
|
...checkClipboardUploadMap,
|
||||||
...checkProxyMap
|
...checkProxyMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
const toolboxFixMap: Partial<IToolboxFixMap<string>> = {
|
const toolboxFixMap: Partial<IToolboxFixMap<string>> = {
|
||||||
...fixFileMap,
|
...fixFileMap,
|
||||||
...fixClipboardUploadMap
|
...fixClipboardUploadMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
toolboxRouter
|
toolboxRouter
|
||||||
@@ -40,7 +40,7 @@ toolboxRouter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
IRPCType.SEND
|
IRPCType.SEND,
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
IRPCActionType.TOOLBOX_CHECK_FIX,
|
IRPCActionType.TOOLBOX_CHECK_FIX,
|
||||||
@@ -51,7 +51,7 @@ toolboxRouter
|
|||||||
return await handler(event as IpcMainEvent)
|
return await handler(event as IpcMainEvent)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
IRPCType.INVOKE
|
IRPCType.INVOKE,
|
||||||
)
|
)
|
||||||
|
|
||||||
export { toolboxRouter }
|
export { toolboxRouter }
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export function sendToolboxResWithType(type: string) {
|
|||||||
return (event: IpcMainEvent, res?: Omit<IToolboxCheckRes, 'type'>) => {
|
return (event: IpcMainEvent, res?: Omit<IToolboxCheckRes, 'type'>) => {
|
||||||
return event.sender.send(IRPCActionType.TOOLBOX_CHECK_RES, {
|
return event.sender.send(IRPCActionType.TOOLBOX_CHECK_RES, {
|
||||||
...res,
|
...res,
|
||||||
type
|
type,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ const trayRoutes = [
|
|||||||
action: IRPCActionType.TRAY_SET_TOOL_TIP,
|
action: IRPCActionType.TRAY_SET_TOOL_TIP,
|
||||||
handler: async (_: IIPCEvent, args: [text: string]) => {
|
handler: async (_: IIPCEvent, args: [text: string]) => {
|
||||||
setTrayToolTip(args[0])
|
setTrayToolTip(args[0])
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.TRAY_GET_SHORT_URL,
|
action: IRPCActionType.TRAY_GET_SHORT_URL,
|
||||||
handler: async (_: IIPCEvent, args: [url: string]) => {
|
handler: async (_: IIPCEvent, args: [url: string]) => {
|
||||||
return await generateShortUrl(args[0])
|
return await generateShortUrl(args[0])
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.TRAY_UPLOAD_CLIPBOARD_FILES,
|
action: IRPCActionType.TRAY_UPLOAD_CLIPBOARD_FILES,
|
||||||
@@ -45,7 +45,7 @@ const trayRoutes = [
|
|||||||
if (isShowResultNotification) {
|
if (isShowResultNotification) {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: $t('UPLOAD_SUCCEED'),
|
title: $t('UPLOAD_SUCCEED'),
|
||||||
body: shortUrl || img[0].imgUrl!
|
body: shortUrl || img[0].imgUrl!,
|
||||||
// icon: file[0]
|
// icon: file[0]
|
||||||
// icon: img[0].imgUrl
|
// icon: img[0].imgUrl
|
||||||
})
|
})
|
||||||
@@ -58,8 +58,8 @@ const trayRoutes = [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
trayWindow.webContents.send('uploadFiles')
|
trayWindow.webContents.send('uploadFiles')
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
trayRouter.addBatch(trayRoutes)
|
trayRouter.addBatch(trayRoutes)
|
||||||
|
|||||||
@@ -14,20 +14,20 @@ const uploadRoutes = [
|
|||||||
handler: async () => {
|
handler: async () => {
|
||||||
return getPicBeds()
|
return getPicBeds()
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE
|
type: IRPCType.INVOKE,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.UPLOAD_CLIPBOARD_FILES_FROM_UPLOAD_PAGE,
|
action: IRPCActionType.UPLOAD_CLIPBOARD_FILES_FROM_UPLOAD_PAGE,
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
uploadClipboardFiles()
|
uploadClipboardFiles()
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: IRPCActionType.UPLOAD_CHOOSED_FILES,
|
action: IRPCActionType.UPLOAD_CHOOSED_FILES,
|
||||||
handler: async (evt: IIPCEvent, args: [files: IFileWithPath[]]) => {
|
handler: async (evt: IIPCEvent, args: [files: IFileWithPath[]]) => {
|
||||||
return uploadChoosedFiles(evt.sender, args[0])
|
return uploadChoosedFiles(evt.sender, args[0])
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
uploadRouter.addBatch(uploadRoutes)
|
uploadRouter.addBatch(uploadRoutes)
|
||||||
|
|||||||
@@ -13,22 +13,22 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|||||||
const builtinI18nList: II18nItem[] = [
|
const builtinI18nList: II18nItem[] = [
|
||||||
{
|
{
|
||||||
label: '简体中文',
|
label: '简体中文',
|
||||||
value: 'zh-CN'
|
value: 'zh-CN',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '繁體中文',
|
label: '繁體中文',
|
||||||
value: 'zh-TW'
|
value: 'zh-TW',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'English',
|
label: 'English',
|
||||||
value: 'en'
|
value: 'en',
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
class I18nManager {
|
class I18nManager {
|
||||||
private i18n: I18n | null = null
|
private i18n: I18n | null = null
|
||||||
private builtinI18nFolder = path.join(__dirname, '../../resources', 'i18n').replace('app.asar', 'app.asar.unpacked')
|
private builtinI18nFolder = path.join(__dirname, '../../resources', 'i18n').replace('app.asar', 'app.asar.unpacked')
|
||||||
private outterI18nFolder = ''
|
private outterI18nFolder = ''
|
||||||
private localesMap: Map<string, ILocales> = new Map()
|
private localesMap = new Map<string, ILocales>()
|
||||||
private currentLanguage: string = 'zh-CN'
|
private currentLanguage: string = 'zh-CN'
|
||||||
readonly defaultLanguage: string = 'zh-CN'
|
readonly defaultLanguage: string = 'zh-CN'
|
||||||
private i18nFileList: II18nItem[] = builtinI18nList
|
private i18nFileList: II18nItem[] = builtinI18nList
|
||||||
@@ -40,7 +40,7 @@ class I18nManager {
|
|||||||
addI18nFile(file: string, label: string) {
|
addI18nFile(file: string, label: string) {
|
||||||
this.i18nFileList.push({
|
this.i18nFileList.push({
|
||||||
label,
|
label,
|
||||||
value: file
|
value: file,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,11 +79,11 @@ class I18nManager {
|
|||||||
|
|
||||||
private initI18n(lang: string = this.defaultLanguage, locales: ILocales) {
|
private initI18n(lang: string = this.defaultLanguage, locales: ILocales) {
|
||||||
const objectAdapter = new ObjectAdapter({
|
const objectAdapter = new ObjectAdapter({
|
||||||
[lang]: locales
|
[lang]: locales,
|
||||||
})
|
})
|
||||||
this.i18n = new I18n({
|
this.i18n = new I18n({
|
||||||
adapter: objectAdapter,
|
adapter: objectAdapter,
|
||||||
defaultLanguage: lang
|
defaultLanguage: lang,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ class I18nManager {
|
|||||||
getCurrentLocales() {
|
getCurrentLocales() {
|
||||||
return {
|
return {
|
||||||
lang: this.currentLanguage,
|
lang: this.currentLanguage,
|
||||||
locales: this.getLocales(this.currentLanguage)
|
locales: this.getLocales(this.currentLanguage),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ function bootstrapEPIPESuppression() {
|
|||||||
bootstrapEPIPESuppression()
|
bootstrapEPIPESuppression()
|
||||||
|
|
||||||
function epipeBomb(stream: any, callback: any) {
|
function epipeBomb(stream: any, callback: any) {
|
||||||
if (stream == null) stream = process.stdout
|
if (stream === null) stream = process.stdout
|
||||||
if (callback == null) callback = process.exit
|
if (callback === null) callback = process.exit
|
||||||
|
|
||||||
function epipeFilter(err: any) {
|
function epipeFilter(err: any) {
|
||||||
if (err.code === 'EPIPE') return callback()
|
if (err.code === 'EPIPE') return callback()
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ const handleStartUpFiles = (argv: string[], cwd: string) => {
|
|||||||
updater.autoUpdater.setFeedURL({
|
updater.autoUpdater.setFeedURL({
|
||||||
provider: 'generic',
|
provider: 'generic',
|
||||||
url: 'https://release.piclist.cn/latest',
|
url: 'https://release.piclist.cn/latest',
|
||||||
channel: 'latest'
|
channel: 'latest',
|
||||||
})
|
})
|
||||||
|
|
||||||
updater.autoUpdater.autoDownload = false
|
updater.autoUpdater.autoDownload = false
|
||||||
@@ -101,13 +101,13 @@ updater.autoUpdater.on('update-available', async (info: updater.UpdateInfo) => {
|
|||||||
buttons: ['Yes', 'Go to download page'],
|
buttons: ['Yes', 'Go to download page'],
|
||||||
message:
|
message:
|
||||||
$t('TIPS_FIND_NEW_VERSION', {
|
$t('TIPS_FIND_NEW_VERSION', {
|
||||||
v: info.version
|
v: info.version,
|
||||||
}) +
|
}) +
|
||||||
'\n\n' +
|
'\n\n' +
|
||||||
displayLog +
|
displayLog +
|
||||||
truncatedNote,
|
truncatedNote,
|
||||||
checkboxLabel: $t('NO_MORE_NOTICE'),
|
checkboxLabel: $t('NO_MORE_NOTICE'),
|
||||||
checkboxChecked: false
|
checkboxChecked: false,
|
||||||
})
|
})
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.response === 0) {
|
if (result.response === 0) {
|
||||||
@@ -124,7 +124,7 @@ updater.autoUpdater.on('update-available', async (info: updater.UpdateInfo) => {
|
|||||||
|
|
||||||
updater.autoUpdater.on('download-progress', progressObj => {
|
updater.autoUpdater.on('download-progress', progressObj => {
|
||||||
const percent = {
|
const percent = {
|
||||||
progress: progressObj.percent
|
progress: progressObj.percent,
|
||||||
}
|
}
|
||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
window.webContents.send('updateProgress', percent)
|
window.webContents.send('updateProgress', percent)
|
||||||
@@ -136,7 +136,7 @@ updater.autoUpdater.on('update-downloaded', () => {
|
|||||||
type: 'info',
|
type: 'info',
|
||||||
title: $t('UPDATE_DOWNLOADED'),
|
title: $t('UPDATE_DOWNLOADED'),
|
||||||
buttons: ['Yes', 'No'],
|
buttons: ['Yes', 'No'],
|
||||||
message: $t('TIPS_UPDATE_DOWNLOADED')
|
message: $t('TIPS_UPDATE_DOWNLOADED'),
|
||||||
})
|
})
|
||||||
.then(result => {
|
.then(result => {
|
||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
@@ -243,7 +243,7 @@ class LifeCycle {
|
|||||||
miniWindow.setPosition(width - miniWindow.getSize()[0], height - miniWindow.getSize()[1])
|
miniWindow.setPosition(width - miniWindow.getSize()[0], height - miniWindow.getSize()[1])
|
||||||
db.set(configPaths.settings.miniWindowPosition, [
|
db.set(configPaths.settings.miniWindowPosition, [
|
||||||
width - miniWindow.getSize()[0],
|
width - miniWindow.getSize()[0],
|
||||||
height - miniWindow.getSize()[1]
|
height - miniWindow.getSize()[1],
|
||||||
])
|
])
|
||||||
} else {
|
} else {
|
||||||
miniWindow.setPosition(lastPosition[0], lastPosition[1])
|
miniWindow.setPosition(lastPosition[0], lastPosition[1])
|
||||||
@@ -297,7 +297,7 @@ class LifeCycle {
|
|||||||
.then(actualAutoStartEnabled => {
|
.then(actualAutoStartEnabled => {
|
||||||
if (actualAutoStartEnabled !== storedAutoStartEnabled) {
|
if (actualAutoStartEnabled !== storedAutoStartEnabled) {
|
||||||
logger.warn(
|
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 => {
|
setAutoStart(storedAutoStartEnabled).catch(err => {
|
||||||
logger.error('Failed to sync auto-start:', err)
|
logger.error('Failed to sync auto-start:', err)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
formatError,
|
formatError,
|
||||||
getFileMimeType,
|
getFileMimeType,
|
||||||
hmacSha1Base64,
|
hmacSha1Base64,
|
||||||
NewDownloader
|
NewDownloader,
|
||||||
} from '~/manage/utils/common'
|
} from '~/manage/utils/common'
|
||||||
import { ManageLogger } from '~/manage/utils/logger'
|
import { ManageLogger } from '~/manage/utils/logger'
|
||||||
import { isImage } from '~/utils/common'
|
import { isImage } from '~/utils/common'
|
||||||
@@ -32,7 +32,7 @@ class AliyunApi {
|
|||||||
this.ctx = new OSS({
|
this.ctx = new OSS({
|
||||||
accessKeyId,
|
accessKeyId,
|
||||||
accessKeySecret,
|
accessKeySecret,
|
||||||
secure: true
|
secure: true,
|
||||||
})
|
})
|
||||||
this.accessKeyId = accessKeyId
|
this.accessKeyId = accessKeyId
|
||||||
this.accessKeySecret = accessKeySecret
|
this.accessKeySecret = accessKeySecret
|
||||||
@@ -50,7 +50,7 @@ class AliyunApi {
|
|||||||
checked: false,
|
checked: false,
|
||||||
isImage: false,
|
isImage: false,
|
||||||
match: false,
|
match: false,
|
||||||
Key: item
|
Key: item,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ class AliyunApi {
|
|||||||
match: false,
|
match: false,
|
||||||
isImage: isImage(fileName),
|
isImage: isImage(fileName),
|
||||||
rawUrl: item.url,
|
rawUrl: item.url,
|
||||||
url: `${urlPrefix}/${item.name}`
|
url: `${urlPrefix}/${item.name}`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ class AliyunApi {
|
|||||||
canonicalizedResource: string,
|
canonicalizedResource: string,
|
||||||
headers: IStringKeyMap,
|
headers: IStringKeyMap,
|
||||||
contentMd5: string,
|
contentMd5: string,
|
||||||
contentType: string
|
contentType: string,
|
||||||
) {
|
) {
|
||||||
const date = new Date().toUTCString()
|
const date = new Date().toUTCString()
|
||||||
const stringToSign = `${method.toUpperCase()}\n${contentMd5}\n${contentType}\n${date}\n${this.getCanonicalizedOSSHeaders(headers)}${canonicalizedResource}`
|
const stringToSign = `${method.toUpperCase()}\n${contentMd5}\n${contentType}\n${date}\n${this.getCanonicalizedOSSHeaders(headers)}${canonicalizedResource}`
|
||||||
@@ -102,7 +102,7 @@ class AliyunApi {
|
|||||||
accessKeySecret: this.accessKeySecret,
|
accessKeySecret: this.accessKeySecret,
|
||||||
region,
|
region,
|
||||||
bucket,
|
bucket,
|
||||||
secure: true
|
secure: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,18 +113,18 @@ class AliyunApi {
|
|||||||
const getBuckets = async (marker?: string) => {
|
const getBuckets = async (marker?: string) => {
|
||||||
const res = (await this.ctx.listBuckets({
|
const res = (await this.ctx.listBuckets({
|
||||||
marker,
|
marker,
|
||||||
'max-keys': 1000
|
'max-keys': 1000,
|
||||||
})) as IStringKeyMap
|
})) as IStringKeyMap
|
||||||
if (res?.res?.statusCode !== 200 || !res?.buckets) return { result: [], isTruncated: false }
|
if (res?.res?.statusCode !== 200 || !res?.buckets) return { result: [], isTruncated: false }
|
||||||
const formattedBuckets = res.buckets.map((item: OSS.Bucket) => ({
|
const formattedBuckets = res.buckets.map((item: OSS.Bucket) => ({
|
||||||
Name: item.name,
|
Name: item.name,
|
||||||
Location: item.region,
|
Location: item.region,
|
||||||
CreationDate: item.creationDate
|
CreationDate: item.creationDate,
|
||||||
}))
|
}))
|
||||||
return {
|
return {
|
||||||
result: formattedBuckets,
|
result: formattedBuckets,
|
||||||
isTruncated: res.isTruncated,
|
isTruncated: res.isTruncated,
|
||||||
nextMarker: res.nextMarker
|
nextMarker: res.nextMarker,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const result: IStringKeyMap[] = []
|
const result: IStringKeyMap[] = []
|
||||||
@@ -145,7 +145,7 @@ class AliyunApi {
|
|||||||
*/
|
*/
|
||||||
async getBucketDomain(param: IStringKeyMap): Promise<any> {
|
async getBucketDomain(param: IStringKeyMap): Promise<any> {
|
||||||
const headers = {
|
const headers = {
|
||||||
Date: new Date().toUTCString()
|
Date: new Date().toUTCString(),
|
||||||
}
|
}
|
||||||
const authorization = this.authorization('GET', `/${param.bucketName}/?cname`, headers, '', '')
|
const authorization = this.authorization('GET', `/${param.bucketName}/?cname`, headers, '', '')
|
||||||
|
|
||||||
@@ -154,8 +154,8 @@ class AliyunApi {
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
...headers,
|
...headers,
|
||||||
Authorization: authorization
|
Authorization: authorization,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res?.status === 200) {
|
if (res?.status === 200) {
|
||||||
@@ -191,18 +191,18 @@ class AliyunApi {
|
|||||||
accessKeyId: this.accessKeyId,
|
accessKeyId: this.accessKeyId,
|
||||||
accessKeySecret: this.accessKeySecret,
|
accessKeySecret: this.accessKeySecret,
|
||||||
region: configMap.region,
|
region: configMap.region,
|
||||||
secure: true
|
secure: true,
|
||||||
})
|
})
|
||||||
const aclTransMap: IStringKeyMap = {
|
const aclTransMap: IStringKeyMap = {
|
||||||
private: 'private',
|
private: 'private',
|
||||||
publicRead: 'public-read',
|
publicRead: 'public-read',
|
||||||
publicReadWrite: 'public-read-write'
|
publicReadWrite: 'public-read-write',
|
||||||
}
|
}
|
||||||
const res = await client.putBucket(configMap.BucketName, {
|
const res = await client.putBucket(configMap.BucketName, {
|
||||||
acl: aclTransMap[configMap.acl],
|
acl: aclTransMap[configMap.acl],
|
||||||
storageClass: 'Standard',
|
storageClass: 'Standard',
|
||||||
dataRedundancyType: 'LRS',
|
dataRedundancyType: 'LRS',
|
||||||
timeout: this.timeOut
|
timeout: this.timeOut,
|
||||||
})
|
})
|
||||||
return res?.res?.status === 200
|
return res?.res?.status === 200
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ class AliyunApi {
|
|||||||
bucketName: bucket,
|
bucketName: bucket,
|
||||||
bucketConfig: { Location: region },
|
bucketConfig: { Location: region },
|
||||||
prefix,
|
prefix,
|
||||||
cancelToken
|
cancelToken,
|
||||||
} = configMap
|
} = configMap
|
||||||
const slicedPrefix = prefix.slice(1)
|
const slicedPrefix = prefix.slice(1)
|
||||||
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
||||||
@@ -229,7 +229,7 @@ class AliyunApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
const client = this.getNewCtx(region, bucket)
|
const client = this.getNewCtx(region, bucket)
|
||||||
do {
|
do {
|
||||||
@@ -237,11 +237,11 @@ class AliyunApi {
|
|||||||
{
|
{
|
||||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||||
'max-keys': '1000',
|
'max-keys': '1000',
|
||||||
'continuation-token': marker
|
'continuation-token': marker,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
timeout: this.timeOut
|
timeout: this.timeOut,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
if (res?.res?.statusCode === 200) {
|
if (res?.res?.statusCode === 200) {
|
||||||
res?.objects?.forEach((item: OSS.ObjectMeta) => {
|
res?.objects?.forEach((item: OSS.ObjectMeta) => {
|
||||||
@@ -268,7 +268,7 @@ class AliyunApi {
|
|||||||
bucketName: bucket,
|
bucketName: bucket,
|
||||||
bucketConfig: { Location: region },
|
bucketConfig: { Location: region },
|
||||||
prefix,
|
prefix,
|
||||||
cancelToken
|
cancelToken,
|
||||||
} = configMap
|
} = configMap
|
||||||
const slicedPrefix = prefix.slice(1)
|
const slicedPrefix = prefix.slice(1)
|
||||||
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
||||||
@@ -284,7 +284,7 @@ class AliyunApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
const client = this.getNewCtx(region, bucket)
|
const client = this.getNewCtx(region, bucket)
|
||||||
do {
|
do {
|
||||||
@@ -293,11 +293,11 @@ class AliyunApi {
|
|||||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||||
delimiter: '/',
|
delimiter: '/',
|
||||||
'max-keys': '1000',
|
'max-keys': '1000',
|
||||||
'continuation-token': marker
|
'continuation-token': marker,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
timeout: this.timeOut
|
timeout: this.timeOut,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
if (res?.res?.statusCode === 200) {
|
if (res?.res?.statusCode === 200) {
|
||||||
res?.prefixes?.forEach((item: string) => {
|
res?.prefixes?.forEach((item: string) => {
|
||||||
@@ -342,7 +342,7 @@ class AliyunApi {
|
|||||||
bucketConfig: { Location: region },
|
bucketConfig: { Location: region },
|
||||||
prefix,
|
prefix,
|
||||||
marker,
|
marker,
|
||||||
itemsPerPage
|
itemsPerPage,
|
||||||
} = configMap
|
} = configMap
|
||||||
const slicedPrefix = prefix.slice(1)
|
const slicedPrefix = prefix.slice(1)
|
||||||
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
const urlPrefix = configMap.customUrl || `https://${bucket}.${region}.aliyuncs.com`
|
||||||
@@ -353,11 +353,11 @@ class AliyunApi {
|
|||||||
prefix: slicedPrefix || undefined,
|
prefix: slicedPrefix || undefined,
|
||||||
delimiter: '/',
|
delimiter: '/',
|
||||||
'max-keys': itemsPerPage.toString(),
|
'max-keys': itemsPerPage.toString(),
|
||||||
'continuation-token': marker
|
'continuation-token': marker,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
timeout: this.timeOut
|
timeout: this.timeOut,
|
||||||
}
|
},
|
||||||
)) as any
|
)) as any
|
||||||
// prefixes can be null
|
// prefixes can be null
|
||||||
// objects will be [] when no file
|
// objects will be [] when no file
|
||||||
@@ -366,20 +366,20 @@ class AliyunApi {
|
|||||||
fullList: [],
|
fullList: [],
|
||||||
isTruncated: false,
|
isTruncated: false,
|
||||||
nextMarker: '',
|
nextMarker: '',
|
||||||
success: false
|
success: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const fullList = [
|
const fullList = [
|
||||||
...(res.prefixes?.map((item: string) => this.formatFolder(item, slicedPrefix, urlPrefix)) || []),
|
...(res.prefixes?.map((item: string) => this.formatFolder(item, slicedPrefix, urlPrefix)) || []),
|
||||||
...(res.objects
|
...(res.objects
|
||||||
?.filter((item: OSS.ObjectMeta) => item.size !== 0)
|
?.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 {
|
return {
|
||||||
fullList,
|
fullList,
|
||||||
isTruncated: res.isTruncated,
|
isTruncated: res.isTruncated,
|
||||||
nextMarker: res.nextContinuationToken || '',
|
nextMarker: res.nextContinuationToken || '',
|
||||||
success: true
|
success: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +431,7 @@ class AliyunApi {
|
|||||||
let isTruncated
|
let isTruncated
|
||||||
const allFileList = {
|
const allFileList = {
|
||||||
CommonPrefixes: [] as any[],
|
CommonPrefixes: [] as any[],
|
||||||
Contents: [] as any[]
|
Contents: [] as any[],
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
const res = (await client.listV2(
|
const res = (await client.listV2(
|
||||||
@@ -439,11 +439,11 @@ class AliyunApi {
|
|||||||
prefix: key,
|
prefix: key,
|
||||||
delimiter: '/',
|
delimiter: '/',
|
||||||
'max-keys': '1000',
|
'max-keys': '1000',
|
||||||
'continuation-token': marker
|
'continuation-token': marker,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
timeout: this.timeOut
|
timeout: this.timeOut,
|
||||||
}
|
},
|
||||||
)) as any
|
)) as any
|
||||||
if (res?.res.statusCode !== 200) return false
|
if (res?.res.statusCode !== 200) return false
|
||||||
|
|
||||||
@@ -458,7 +458,7 @@ class AliyunApi {
|
|||||||
const successfully = await this.deleteBucketFolder({
|
const successfully = await this.deleteBucketFolder({
|
||||||
bucketName,
|
bucketName,
|
||||||
region,
|
region,
|
||||||
key: item
|
key: item,
|
||||||
})
|
})
|
||||||
if (!successfully) return false
|
if (!successfully) return false
|
||||||
}
|
}
|
||||||
@@ -467,7 +467,7 @@ class AliyunApi {
|
|||||||
const cycle = Math.ceil(allFileList.Contents.length / 1000)
|
const cycle = Math.ceil(allFileList.Contents.length / 1000)
|
||||||
for (let i = 0; i < cycle; i++) {
|
for (let i = 0; i < cycle; i++) {
|
||||||
const deleteRes = (await client.deleteMulti(
|
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
|
)) as any
|
||||||
if (deleteRes?.res.statusCode !== 200) return false
|
if (deleteRes?.res.statusCode !== 200) return false
|
||||||
}
|
}
|
||||||
@@ -490,7 +490,7 @@ class AliyunApi {
|
|||||||
const { bucketName, region, key, expires, customUrl } = configMap
|
const { bucketName, region, key, expires, customUrl } = configMap
|
||||||
const client = this.getNewCtx(region, bucketName)
|
const client = this.getNewCtx(region, bucketName)
|
||||||
const res = client.signatureUrl(key, {
|
const res = client.signatureUrl(key, {
|
||||||
expires: expires || 3600
|
expires: expires || 3600,
|
||||||
})
|
})
|
||||||
return customUrl ? `${customUrl.replace(/\/+$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
|
return customUrl ? `${customUrl.replace(/\/+$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
|
||||||
}
|
}
|
||||||
@@ -527,7 +527,7 @@ class AliyunApi {
|
|||||||
sourceFilePath: filePath,
|
sourceFilePath: filePath,
|
||||||
targetFilePath: key,
|
targetFilePath: key,
|
||||||
targetFileBucket: bucketName,
|
targetFileBucket: bucketName,
|
||||||
targetFileRegion: region
|
targetFileRegion: region,
|
||||||
})
|
})
|
||||||
client
|
client
|
||||||
.multipartUpload(key, filePath, {
|
.multipartUpload(key, filePath, {
|
||||||
@@ -538,9 +538,9 @@ class AliyunApi {
|
|||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
id,
|
id,
|
||||||
progress: Math.floor(p * 100),
|
progress: Math.floor(p * 100),
|
||||||
status: uploadTaskSpecialStatus.uploading
|
status: uploadTaskSpecialStatus.uploading,
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
const id = `${bucketName}-${region}-${key}-${filePath}`
|
const id = `${bucketName}-${region}-${key}-${filePath}`
|
||||||
@@ -550,7 +550,7 @@ class AliyunApi {
|
|||||||
progress: 100,
|
progress: 100,
|
||||||
status: uploadTaskSpecialStatus.uploaded,
|
status: uploadTaskSpecialStatus.uploaded,
|
||||||
response: JSON.stringify(res),
|
response: JSON.stringify(res),
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
@@ -558,7 +558,7 @@ class AliyunApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
response: JSON.stringify(res),
|
response: JSON.stringify(res),
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -566,8 +566,8 @@ class AliyunApi {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
formatError(err, {
|
formatError(err, {
|
||||||
class: 'AliyunApi',
|
class: 'AliyunApi',
|
||||||
method: 'uploadBucketFile'
|
method: 'uploadBucketFile',
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
const id = `${bucketName}-${region}-${key}-${filePath}`
|
const id = `${bucketName}-${region}-${key}-${filePath}`
|
||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
@@ -575,7 +575,7 @@ class AliyunApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
response: JSON.stringify(err),
|
response: JSON.stringify(err),
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -614,10 +614,10 @@ class AliyunApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.queuing,
|
status: commonTaskStatus.queuing,
|
||||||
sourceFileName: fileName,
|
sourceFileName: fileName,
|
||||||
targetFilePath: savedFilePath
|
targetFilePath: savedFilePath,
|
||||||
})
|
})
|
||||||
const preSignedUrl = client.signatureUrl(key, {
|
const preSignedUrl = client.signatureUrl(key, {
|
||||||
expires: 60 * 60 * 48
|
expires: 60 * 60 * 48,
|
||||||
})
|
})
|
||||||
promises.push(
|
promises.push(
|
||||||
() =>
|
() =>
|
||||||
@@ -629,7 +629,7 @@ class AliyunApi {
|
|||||||
reject(res)
|
reject(res)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||||
@@ -637,8 +637,8 @@ class AliyunApi {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
formatError(error, {
|
formatError(error, {
|
||||||
class: 'AliyunApi',
|
class: 'AliyunApi',
|
||||||
method: 'downloadBucketFile'
|
method: 'downloadBucketFile',
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ export default {
|
|||||||
SmmsApi,
|
SmmsApi,
|
||||||
TcyunApi,
|
TcyunApi,
|
||||||
UpyunApi,
|
UpyunApi,
|
||||||
WebdavplistApi
|
WebdavplistApi,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
getAgent,
|
getAgent,
|
||||||
getOptions,
|
getOptions,
|
||||||
gotUpload,
|
gotUpload,
|
||||||
NewDownloader
|
NewDownloader,
|
||||||
} from '~/manage/utils/common'
|
} from '~/manage/utils/common'
|
||||||
import { ManageLogger } from '~/manage/utils/logger'
|
import { ManageLogger } from '~/manage/utils/logger'
|
||||||
import { formatHttpProxy, isImage, trimPath } from '~/utils/common'
|
import { formatHttpProxy, isImage, trimPath } from '~/utils/common'
|
||||||
@@ -37,7 +37,7 @@ class GithubApi {
|
|||||||
this.proxyStr = formatHttpProxy(proxy, 'string') as string | undefined
|
this.proxyStr = formatHttpProxy(proxy, 'string') as string | undefined
|
||||||
this.commonHeaders = {
|
this.commonHeaders = {
|
||||||
Authorization: this.token,
|
Authorization: this.token,
|
||||||
Accept: 'application/vnd.github+json'
|
Accept: 'application/vnd.github+json',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ class GithubApi {
|
|||||||
isDir: true,
|
isDir: true,
|
||||||
checked: false,
|
checked: false,
|
||||||
isImage: false,
|
isImage: false,
|
||||||
match: false
|
match: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ class GithubApi {
|
|||||||
match: false,
|
match: false,
|
||||||
isImage: isImage(item.path),
|
isImage: isImage(item.path),
|
||||||
rawUrl: item.url,
|
rawUrl: item.url,
|
||||||
url: rawUrl
|
url: rawUrl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,8 +133,8 @@ class GithubApi {
|
|||||||
'json',
|
'json',
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
this.proxy
|
this.proxy,
|
||||||
)
|
),
|
||||||
)) as any
|
)) as any
|
||||||
if (res.statusCode === 200) {
|
if (res.statusCode === 200) {
|
||||||
res.body.forEach((item: any) => {
|
res.body.forEach((item: any) => {
|
||||||
@@ -142,7 +142,7 @@ class GithubApi {
|
|||||||
...item,
|
...item,
|
||||||
Name: item.name,
|
Name: item.name,
|
||||||
Location: item.id,
|
Location: item.id,
|
||||||
CreationDate: item.created_at
|
CreationDate: item.created_at,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -171,8 +171,8 @@ class GithubApi {
|
|||||||
'json',
|
'json',
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
this.proxy
|
this.proxy,
|
||||||
)
|
),
|
||||||
)) as any
|
)) as any
|
||||||
if (res.statusCode === 200) {
|
if (res.statusCode === 200) {
|
||||||
res.body.forEach((item: any) => result.push(item.name))
|
res.body.forEach((item: any) => result.push(item.name))
|
||||||
@@ -199,7 +199,7 @@ class GithubApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
const treeQueue = [slicedPrefix]
|
const treeQueue = [slicedPrefix]
|
||||||
while (treeQueue.length) {
|
while (treeQueue.length) {
|
||||||
@@ -210,7 +210,7 @@ class GithubApi {
|
|||||||
const currentPrefix = treeQueue[0]
|
const currentPrefix = treeQueue[0]
|
||||||
res = (await got(
|
res = (await got(
|
||||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${treeQueue.shift()}`,
|
`${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
|
)) as any
|
||||||
if (res && res.statusCode === 200) {
|
if (res && res.statusCode === 200) {
|
||||||
const { tree } = res.body
|
const { tree } = res.body
|
||||||
@@ -250,11 +250,11 @@ class GithubApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
res = await got(
|
res = await got(
|
||||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${slicedPrefix}`,
|
`${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) {
|
if (res && res.statusCode === 200) {
|
||||||
res.body.tree.forEach((item: any) => {
|
res.body.tree.forEach((item: any) => {
|
||||||
@@ -290,11 +290,11 @@ class GithubApi {
|
|||||||
const body = {
|
const body = {
|
||||||
message: 'deleted by PicList',
|
message: 'deleted by PicList',
|
||||||
sha,
|
sha,
|
||||||
branch
|
branch,
|
||||||
}
|
}
|
||||||
const res = await got(
|
const res = await got(
|
||||||
`${this.baseUrl}/repos/${this.username}/${repo}/contents/${key}`,
|
`${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
|
return res.statusCode === 200
|
||||||
}
|
}
|
||||||
@@ -308,14 +308,14 @@ class GithubApi {
|
|||||||
// get sha of the branch
|
// get sha of the branch
|
||||||
const refRes = (await got(
|
const refRes = (await got(
|
||||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/refs/heads/${branch}`,
|
`${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
|
)) as any
|
||||||
if (refRes.statusCode !== 200) return false
|
if (refRes.statusCode !== 200) return false
|
||||||
const refSha = refRes.body.object.sha
|
const refSha = refRes.body.object.sha
|
||||||
// get sha of the root tree
|
// get sha of the root tree
|
||||||
const rootRes = (await got(
|
const rootRes = (await got(
|
||||||
`${this.baseUrl}/repos/${this.username}/${repo}/branches/${branch}`,
|
`${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
|
)) as any
|
||||||
if (rootRes.statusCode !== 200) return false
|
if (rootRes.statusCode !== 200) return false
|
||||||
const rootSha = rootRes.body.commit.commit.tree.sha
|
const rootSha = rootRes.body.commit.commit.tree.sha
|
||||||
@@ -328,13 +328,13 @@ class GithubApi {
|
|||||||
'GET',
|
'GET',
|
||||||
this.commonHeaders,
|
this.commonHeaders,
|
||||||
{
|
{
|
||||||
recursive: true
|
recursive: true,
|
||||||
},
|
},
|
||||||
'json',
|
'json',
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
this.proxy
|
this.proxy,
|
||||||
)
|
),
|
||||||
)) as any
|
)) as any
|
||||||
if (treeRes.statusCode !== 200) return false
|
if (treeRes.statusCode !== 200) return false
|
||||||
const oldTree = treeRes.body.tree
|
const oldTree = treeRes.body.tree
|
||||||
@@ -345,7 +345,7 @@ class GithubApi {
|
|||||||
path: `${key.replace(/(^\/+|\/+$)/g, '')}/${item.path}`,
|
path: `${key.replace(/(^\/+|\/+$)/g, '')}/${item.path}`,
|
||||||
mode: item.mode,
|
mode: item.mode,
|
||||||
type: item.type,
|
type: item.type,
|
||||||
sha: null
|
sha: null,
|
||||||
}))
|
}))
|
||||||
const newTreeShaRes = (await got(
|
const newTreeShaRes = (await got(
|
||||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees`,
|
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees`,
|
||||||
@@ -356,11 +356,11 @@ class GithubApi {
|
|||||||
'json',
|
'json',
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
base_tree: rootSha,
|
base_tree: rootSha,
|
||||||
tree: newTree
|
tree: newTree,
|
||||||
}),
|
}),
|
||||||
undefined,
|
undefined,
|
||||||
this.proxy
|
this.proxy,
|
||||||
)
|
),
|
||||||
)) as any
|
)) as any
|
||||||
if (newTreeShaRes.statusCode !== 201) return false
|
if (newTreeShaRes.statusCode !== 201) return false
|
||||||
const newTreeSha = newTreeShaRes.body.sha
|
const newTreeSha = newTreeShaRes.body.sha
|
||||||
@@ -375,11 +375,11 @@ class GithubApi {
|
|||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
message: 'deleted by PicList',
|
message: 'deleted by PicList',
|
||||||
tree: newTreeSha,
|
tree: newTreeSha,
|
||||||
parents: [refSha]
|
parents: [refSha],
|
||||||
}),
|
}),
|
||||||
undefined,
|
undefined,
|
||||||
this.proxy
|
this.proxy,
|
||||||
)
|
),
|
||||||
)) as any
|
)) as any
|
||||||
if (commitRes.statusCode !== 201) return false
|
if (commitRes.statusCode !== 201) return false
|
||||||
const commitSha = commitRes.body.sha
|
const commitSha = commitRes.body.sha
|
||||||
@@ -392,11 +392,11 @@ class GithubApi {
|
|||||||
undefined,
|
undefined,
|
||||||
'json',
|
'json',
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
sha: commitSha
|
sha: commitSha,
|
||||||
}),
|
}),
|
||||||
undefined,
|
undefined,
|
||||||
this.proxy
|
this.proxy,
|
||||||
)
|
),
|
||||||
)) as any
|
)) as any
|
||||||
return updateRefRes.statusCode === 200
|
return updateRefRes.statusCode === 200
|
||||||
}
|
}
|
||||||
@@ -421,13 +421,13 @@ class GithubApi {
|
|||||||
'GET',
|
'GET',
|
||||||
this.commonHeaders,
|
this.commonHeaders,
|
||||||
{
|
{
|
||||||
ref: branch
|
ref: branch,
|
||||||
},
|
},
|
||||||
'json',
|
'json',
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
this.proxy
|
this.proxy,
|
||||||
)
|
),
|
||||||
)) as any
|
)) as any
|
||||||
return res.statusCode === 200 ? res.body.download_url : ''
|
return res.statusCode === 200 ? res.body.download_url : ''
|
||||||
}
|
}
|
||||||
@@ -443,11 +443,11 @@ class GithubApi {
|
|||||||
const body = {
|
const body = {
|
||||||
message: `created a new folder named ${key} by PicList`,
|
message: `created a new folder named ${key} by PicList`,
|
||||||
content: base64Content,
|
content: base64Content,
|
||||||
branch
|
branch,
|
||||||
}
|
}
|
||||||
const res = await got(
|
const res = await got(
|
||||||
`${this.baseUrl}/repos/${this.username}/${repo}/contents/${newFileKey}`,
|
`${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
|
return res.statusCode === 201
|
||||||
}
|
}
|
||||||
@@ -479,7 +479,7 @@ class GithubApi {
|
|||||||
sourceFilePath: filePath,
|
sourceFilePath: filePath,
|
||||||
targetFilePath: key,
|
targetFilePath: key,
|
||||||
targetFileBucket: repo,
|
targetFileBucket: repo,
|
||||||
targetFileRegion: region
|
targetFileRegion: region,
|
||||||
})
|
})
|
||||||
gotUpload(
|
gotUpload(
|
||||||
instance,
|
instance,
|
||||||
@@ -488,14 +488,14 @@ class GithubApi {
|
|||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
message: 'uploaded by PicList',
|
message: 'uploaded by PicList',
|
||||||
branch,
|
branch,
|
||||||
content: base64Content
|
content: base64Content,
|
||||||
}),
|
}),
|
||||||
this.commonHeaders,
|
this.commonHeaders,
|
||||||
id,
|
id,
|
||||||
this.logger,
|
this.logger,
|
||||||
30000,
|
30000,
|
||||||
false,
|
false,
|
||||||
getAgent(this.proxy)
|
getAgent(this.proxy),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@@ -521,7 +521,7 @@ class GithubApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.queuing,
|
status: commonTaskStatus.queuing,
|
||||||
sourceFileName: fileName,
|
sourceFileName: fileName,
|
||||||
targetFilePath: savedFilePath
|
targetFilePath: savedFilePath,
|
||||||
})
|
})
|
||||||
let downloadUrl: string
|
let downloadUrl: string
|
||||||
if (githubPrivate) {
|
if (githubPrivate) {
|
||||||
@@ -530,7 +530,7 @@ class GithubApi {
|
|||||||
customUrl: branch,
|
customUrl: branch,
|
||||||
key,
|
key,
|
||||||
rawUrl: githubUrl,
|
rawUrl: githubUrl,
|
||||||
githubPrivate
|
githubPrivate,
|
||||||
})
|
})
|
||||||
downloadUrl = preSignedUrl
|
downloadUrl = preSignedUrl
|
||||||
} else {
|
} else {
|
||||||
@@ -546,7 +546,7 @@ class GithubApi {
|
|||||||
reject(res)
|
reject(res)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||||
@@ -554,8 +554,8 @@ class GithubApi {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
formatError(error, {
|
formatError(error, {
|
||||||
class: 'GithubApi',
|
class: 'GithubApi',
|
||||||
method: 'downloadBucketFile'
|
method: 'downloadBucketFile',
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
getFileMimeType,
|
getFileMimeType,
|
||||||
getOptions,
|
getOptions,
|
||||||
gotUpload,
|
gotUpload,
|
||||||
NewDownloader
|
NewDownloader,
|
||||||
} from '~/manage/utils/common'
|
} from '~/manage/utils/common'
|
||||||
import ManageLogger from '~/manage/utils/logger'
|
import ManageLogger from '~/manage/utils/logger'
|
||||||
import { formatHttpProxy, isImage } from '~/utils/common'
|
import { formatHttpProxy, isImage } from '~/utils/common'
|
||||||
@@ -38,7 +38,7 @@ class ImgurApi {
|
|||||||
this.proxyStr = formatHttpProxy(proxy, 'string') as string | undefined
|
this.proxyStr = formatHttpProxy(proxy, 'string') as string | undefined
|
||||||
this.logger = logger
|
this.logger = logger
|
||||||
this.tokenHeaders = {
|
this.tokenHeaders = {
|
||||||
Authorization: this.accessToken
|
Authorization: this.accessToken,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ class ImgurApi {
|
|||||||
match: false,
|
match: false,
|
||||||
isImage: isImg,
|
isImage: isImg,
|
||||||
url: item.link,
|
url: item.link,
|
||||||
sha: item.deletehash
|
sha: item.deletehash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ class ImgurApi {
|
|||||||
do {
|
do {
|
||||||
res = (await got(
|
res = (await got(
|
||||||
`${this.baseUrl}/account/${this.userName}/albums/${initPage}`,
|
`${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
|
)) as any
|
||||||
if (!(res.statusCode === 200 && res.body.success)) {
|
if (!(res.statusCode === 200 && res.body.success)) {
|
||||||
return []
|
return []
|
||||||
@@ -83,12 +83,12 @@ class ImgurApi {
|
|||||||
...item,
|
...item,
|
||||||
Name: item.title,
|
Name: item.title,
|
||||||
Location: item.id,
|
Location: item.id,
|
||||||
CreationDate: item.datetime
|
CreationDate: item.datetime,
|
||||||
})) as any[]
|
})) as any[]
|
||||||
finalResult.push({
|
finalResult.push({
|
||||||
Name: '全部',
|
Name: '全部',
|
||||||
Location: 'unclassified',
|
Location: 'unclassified',
|
||||||
CreationDate: new Date().getTime()
|
CreationDate: new Date().getTime(),
|
||||||
})
|
})
|
||||||
return finalResult
|
return finalResult
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ class ImgurApi {
|
|||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
const {
|
const {
|
||||||
bucketConfig: { Location: albumHash },
|
bucketConfig: { Location: albumHash },
|
||||||
cancelToken
|
cancelToken,
|
||||||
} = configMap
|
} = configMap
|
||||||
const cancelTask = [false]
|
const cancelTask = [false]
|
||||||
ipcMain.on('cancelLoadingFileList', (_: IpcMainEvent, token: string) => {
|
ipcMain.on('cancelLoadingFileList', (_: IpcMainEvent, token: string) => {
|
||||||
@@ -110,12 +110,12 @@ class ImgurApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
if (albumHash !== 'unclassified') {
|
if (albumHash !== 'unclassified') {
|
||||||
res = (await got(
|
res = (await got(
|
||||||
`${this.baseUrl}/account/${this.userName}/album/${albumHash}`,
|
`${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
|
)) as any
|
||||||
if (res.statusCode === 200 && res.body.success) {
|
if (res.statusCode === 200 && res.body.success) {
|
||||||
res.body.data.images.forEach((item: any) => {
|
res.body.data.images.forEach((item: any) => {
|
||||||
@@ -132,7 +132,7 @@ class ImgurApi {
|
|||||||
do {
|
do {
|
||||||
res = (await got(
|
res = (await got(
|
||||||
`${this.baseUrl}/account/${this.userName}/images/${initPage}`,
|
`${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
|
)) as any
|
||||||
if (res.statusCode === 200 && res.body.success) {
|
if (res.statusCode === 200 && res.body.success) {
|
||||||
res.body.data.forEach((item: any) => {
|
res.body.data.forEach((item: any) => {
|
||||||
@@ -157,7 +157,7 @@ class ImgurApi {
|
|||||||
const { DeleteHash: deleteHash } = configMap
|
const { DeleteHash: deleteHash } = configMap
|
||||||
const res = (await got(
|
const res = (await got(
|
||||||
`${this.baseUrl}/account/${this.userName}/image/${deleteHash}`,
|
`${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
|
)) as any
|
||||||
return res.statusCode === 200 && res.body.success
|
return res.statusCode === 200 && res.body.success
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ class ImgurApi {
|
|||||||
sourceFilePath: filePath,
|
sourceFilePath: filePath,
|
||||||
targetFilePath: key,
|
targetFilePath: key,
|
||||||
targetFileBucket: bucketName,
|
targetFileBucket: bucketName,
|
||||||
targetFileRegion: albumHash
|
targetFileRegion: albumHash,
|
||||||
})
|
})
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
form.append('type', 'file')
|
form.append('type', 'file')
|
||||||
@@ -195,12 +195,12 @@ class ImgurApi {
|
|||||||
if (fileSize > 1024 * 1024 * 10) {
|
if (fileSize > 1024 * 1024 * 10) {
|
||||||
form.append('video', fs.createReadStream(filePath), {
|
form.append('video', fs.createReadStream(filePath), {
|
||||||
filename: path.basename(key),
|
filename: path.basename(key),
|
||||||
contentType: getFileMimeType(fileName)
|
contentType: getFileMimeType(fileName),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
form.append('image', fs.createReadStream(filePath), {
|
form.append('image', fs.createReadStream(filePath), {
|
||||||
filename: path.basename(key),
|
filename: path.basename(key),
|
||||||
contentType: getFileMimeType(fileName)
|
contentType: getFileMimeType(fileName),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
albumHash !== 'unclassified' && form.append('album', albumHash)
|
albumHash !== 'unclassified' && form.append('album', albumHash)
|
||||||
@@ -216,7 +216,7 @@ class ImgurApi {
|
|||||||
this.logger,
|
this.logger,
|
||||||
30000,
|
30000,
|
||||||
false,
|
false,
|
||||||
getAgent(this.proxy)
|
getAgent(this.proxy),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@@ -242,7 +242,7 @@ class ImgurApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.queuing,
|
status: commonTaskStatus.queuing,
|
||||||
sourceFileName: fileName,
|
sourceFileName: fileName,
|
||||||
targetFilePath: savedFilePath
|
targetFilePath: savedFilePath,
|
||||||
})
|
})
|
||||||
promises.push(
|
promises.push(
|
||||||
() =>
|
() =>
|
||||||
@@ -254,7 +254,7 @@ class ImgurApi {
|
|||||||
reject(res)
|
reject(res)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class LocalApi {
|
|||||||
checked: false,
|
checked: false,
|
||||||
isImage: false,
|
isImage: false,
|
||||||
match: false,
|
match: false,
|
||||||
url: urlPrefix
|
url: urlPrefix,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ class LocalApi {
|
|||||||
checked: false,
|
checked: false,
|
||||||
match: false,
|
match: false,
|
||||||
isImage: isImage(fileName),
|
isImage: isImage(fileName),
|
||||||
url: urlPrefix
|
url: urlPrefix,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,20 +89,20 @@ class LocalApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
res = fsWalk.walkSync(this.transBack(prefix), {
|
res = fsWalk.walkSync(this.transBack(prefix), {
|
||||||
followSymbolicLinks: true,
|
followSymbolicLinks: true,
|
||||||
fs,
|
fs,
|
||||||
stats: true,
|
stats: true,
|
||||||
throwErrorOnBrokenSymbolicLink: false
|
throwErrorOnBrokenSymbolicLink: false,
|
||||||
})
|
})
|
||||||
if (res.length) {
|
if (res.length) {
|
||||||
result.fullList.push(
|
result.fullList.push(
|
||||||
...res
|
...res
|
||||||
.filter((item: fsWalk.Entry) => item.stats?.isFile())
|
.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
|
result.success = true
|
||||||
}
|
}
|
||||||
@@ -135,11 +135,11 @@ class LocalApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const res = await fs.readdir(prefix, {
|
const res = await fs.readdir(prefix, {
|
||||||
withFileTypes: true
|
withFileTypes: true,
|
||||||
})
|
})
|
||||||
if (res.length) {
|
if (res.length) {
|
||||||
let urlPrefixF
|
let urlPrefixF
|
||||||
@@ -199,7 +199,7 @@ class LocalApi {
|
|||||||
let result = false
|
let result = false
|
||||||
try {
|
try {
|
||||||
await fs.rm(this.transBack(key), {
|
await fs.rm(this.transBack(key), {
|
||||||
recursive: true
|
recursive: true,
|
||||||
})
|
})
|
||||||
result = true
|
result = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -226,7 +226,7 @@ class LocalApi {
|
|||||||
targetFilePath: key,
|
targetFilePath: key,
|
||||||
targetFileBucket: bucketName,
|
targetFileBucket: bucketName,
|
||||||
targetFileRegion: '',
|
targetFileRegion: '',
|
||||||
noProgress: true
|
noProgress: true,
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
fs.ensureFileSync(this.transBack(key))
|
fs.ensureFileSync(this.transBack(key))
|
||||||
@@ -235,7 +235,7 @@ class LocalApi {
|
|||||||
id,
|
id,
|
||||||
progress: 100,
|
progress: 100,
|
||||||
status: uploadTaskSpecialStatus.uploaded,
|
status: uploadTaskSpecialStatus.uploaded,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logParam(error, 'uploadBucketFile')
|
this.logParam(error, 'uploadBucketFile')
|
||||||
@@ -243,7 +243,7 @@ class LocalApi {
|
|||||||
id,
|
id,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,7 +255,7 @@ class LocalApi {
|
|||||||
let result = false
|
let result = false
|
||||||
try {
|
try {
|
||||||
await fs.mkdir(this.transBack(key), {
|
await fs.mkdir(this.transBack(key), {
|
||||||
recursive: true
|
recursive: true,
|
||||||
})
|
})
|
||||||
result = true
|
result = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -279,7 +279,7 @@ class LocalApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.queuing,
|
status: commonTaskStatus.queuing,
|
||||||
sourceFileName: fileName,
|
sourceFileName: fileName,
|
||||||
targetFilePath: savedFilePath
|
targetFilePath: savedFilePath,
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
fs.ensureFileSync(savedFilePath)
|
fs.ensureFileSync(savedFilePath)
|
||||||
@@ -288,7 +288,7 @@ class LocalApi {
|
|||||||
id,
|
id,
|
||||||
progress: 100,
|
progress: 100,
|
||||||
status: downloadTaskSpecialStatus.downloaded,
|
status: downloadTaskSpecialStatus.downloaded,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logParam(error, 'downloadBucketFile')
|
this.logParam(error, 'downloadBucketFile')
|
||||||
@@ -296,7 +296,7 @@ class LocalApi {
|
|||||||
id,
|
id,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
formatError,
|
formatError,
|
||||||
getFileMimeType,
|
getFileMimeType,
|
||||||
hmacSha1Base64,
|
hmacSha1Base64,
|
||||||
NewDownloader
|
NewDownloader,
|
||||||
} from '~/manage/utils/common'
|
} from '~/manage/utils/common'
|
||||||
import { ManageLogger } from '~/manage/utils/logger'
|
import { ManageLogger } from '~/manage/utils/logger'
|
||||||
import { isImage } from '~/utils/common'
|
import { isImage } from '~/utils/common'
|
||||||
@@ -30,7 +30,7 @@ class QiniuApi {
|
|||||||
|
|
||||||
hostList = {
|
hostList = {
|
||||||
getBucketList: 'https://uc.qiniuapi.com/buckets',
|
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) {
|
constructor(accessKey: string, secretKey: string, logger: ManageLogger) {
|
||||||
@@ -50,7 +50,7 @@ class QiniuApi {
|
|||||||
isDir: true,
|
isDir: true,
|
||||||
checked: false,
|
checked: false,
|
||||||
isImage: false,
|
isImage: false,
|
||||||
match: false
|
match: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ class QiniuApi {
|
|||||||
isDir: false,
|
isDir: false,
|
||||||
checked: false,
|
checked: false,
|
||||||
match: false,
|
match: false,
|
||||||
isImage: isImage(fileName)
|
isImage: isImage(fileName),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ class QiniuApi {
|
|||||||
body: string,
|
body: string,
|
||||||
query: string,
|
query: string,
|
||||||
contentType: string,
|
contentType: string,
|
||||||
xQiniuHeaders?: IStringKeyMap
|
xQiniuHeaders?: IStringKeyMap,
|
||||||
) {
|
) {
|
||||||
let signStr = `${method.toUpperCase()} ${urlPath}${query ? `?${query}` : ''}\nHost: ${host}`
|
let signStr = `${method.toUpperCase()} ${urlPath}${query ? `?${query}` : ''}\nHost: ${host}`
|
||||||
|
|
||||||
@@ -104,9 +104,9 @@ class QiniuApi {
|
|||||||
const res = await axios.get(host, {
|
const res = await axios.get(host, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: authorization,
|
Authorization: authorization,
|
||||||
'Content-Type': this.commonType
|
'Content-Type': this.commonType,
|
||||||
},
|
},
|
||||||
timeout: this.timeout
|
timeout: this.timeout,
|
||||||
})
|
})
|
||||||
if (res?.status === 200 && res?.data?.length) {
|
if (res?.status === 200 && res?.data?.length) {
|
||||||
const result = [] as any[]
|
const result = [] as any[]
|
||||||
@@ -117,7 +117,7 @@ class QiniuApi {
|
|||||||
Name: dataItem,
|
Name: dataItem,
|
||||||
Location: info.zone,
|
Location: info.zone,
|
||||||
CreationDate: new Date().toISOString(),
|
CreationDate: new Date().toISOString(),
|
||||||
Private: info.private
|
Private: info.private,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -137,23 +137,23 @@ class QiniuApi {
|
|||||||
url: `https://${this.host}/v2/bucketInfo`,
|
url: `https://${this.host}/v2/bucketInfo`,
|
||||||
params: {
|
params: {
|
||||||
bucket: bucketName,
|
bucket: bucketName,
|
||||||
fs: true
|
fs: true,
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: authorization,
|
Authorization: authorization,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Host: this.host
|
Host: this.host,
|
||||||
},
|
},
|
||||||
timeout: this.timeout
|
timeout: this.timeout,
|
||||||
})
|
})
|
||||||
return res?.status === 200
|
return res?.status === 200
|
||||||
? {
|
? {
|
||||||
success: true,
|
success: true,
|
||||||
private: res.data.private,
|
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 authorization = qiniu.util.generateAccessToken(this.mac, `${host}?tbl=${bucketName}`, undefined)
|
||||||
const res = await axios.get(host, {
|
const res = await axios.get(host, {
|
||||||
params: {
|
params: {
|
||||||
tbl: bucketName
|
tbl: bucketName,
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: authorization,
|
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 : []
|
return res?.status === 200 && res?.data?.length ? res.data : []
|
||||||
}
|
}
|
||||||
@@ -192,14 +192,14 @@ class QiniuApi {
|
|||||||
url: `https://${this.host}/private`,
|
url: `https://${this.host}/private`,
|
||||||
params: {
|
params: {
|
||||||
bucket: bucketName,
|
bucket: bucketName,
|
||||||
private: isPrivate
|
private: isPrivate,
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: authorization,
|
Authorization: authorization,
|
||||||
'Content-Type': this.commonType,
|
'Content-Type': this.commonType,
|
||||||
Host: this.host
|
Host: this.host,
|
||||||
},
|
},
|
||||||
timeout: this.timeout
|
timeout: this.timeout,
|
||||||
})
|
})
|
||||||
return res?.status === 200
|
return res?.status === 200
|
||||||
}
|
}
|
||||||
@@ -223,14 +223,14 @@ class QiniuApi {
|
|||||||
headers: {
|
headers: {
|
||||||
Authorization: authorization,
|
Authorization: authorization,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Host: this.host
|
Host: this.host,
|
||||||
},
|
},
|
||||||
timeout: this.timeout
|
timeout: this.timeout,
|
||||||
})
|
})
|
||||||
return res?.status === 200
|
return res?.status === 200
|
||||||
? await this.setBucketAclPolicy({
|
? await this.setBucketAclPolicy({
|
||||||
bucketName: BucketName,
|
bucketName: BucketName,
|
||||||
isPrivate: !acl
|
isPrivate: !acl,
|
||||||
})
|
})
|
||||||
: false
|
: false
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,7 @@ class QiniuApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
const config = new qiniu.conf.Config()
|
const config = new qiniu.conf.Config()
|
||||||
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
||||||
@@ -262,7 +262,7 @@ class QiniuApi {
|
|||||||
{
|
{
|
||||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||||
marker,
|
marker,
|
||||||
limit: 1000
|
limit: 1000,
|
||||||
},
|
},
|
||||||
(err: any, respBody: any, respInfo: any) => {
|
(err: any, respBody: any, respInfo: any) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -270,10 +270,10 @@ class QiniuApi {
|
|||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
respBody,
|
respBody,
|
||||||
respInfo
|
respInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
if (res && res.respInfo.statusCode === 200) {
|
if (res && res.respInfo.statusCode === 200) {
|
||||||
@@ -313,7 +313,7 @@ class QiniuApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
const config = new qiniu.conf.Config()
|
const config = new qiniu.conf.Config()
|
||||||
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
||||||
@@ -325,7 +325,7 @@ class QiniuApi {
|
|||||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||||
delimiter: '/',
|
delimiter: '/',
|
||||||
marker,
|
marker,
|
||||||
limit: 1000
|
limit: 1000,
|
||||||
},
|
},
|
||||||
(err: any, respBody: any, respInfo: any) => {
|
(err: any, respBody: any, respInfo: any) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -333,10 +333,10 @@ class QiniuApi {
|
|||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
respBody,
|
respBody,
|
||||||
respInfo
|
respInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
if (res && res.respInfo.statusCode === 200) {
|
if (res && res.respInfo.statusCode === 200) {
|
||||||
@@ -390,7 +390,7 @@ class QiniuApi {
|
|||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
isTruncated: false,
|
isTruncated: false,
|
||||||
nextMarker: '',
|
nextMarker: '',
|
||||||
success: false
|
success: false,
|
||||||
}
|
}
|
||||||
res = await new Promise((resolve, reject) => {
|
res = await new Promise((resolve, reject) => {
|
||||||
bucketManager.listPrefix(
|
bucketManager.listPrefix(
|
||||||
@@ -399,7 +399,7 @@ class QiniuApi {
|
|||||||
limit: itemsPerPage,
|
limit: itemsPerPage,
|
||||||
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||||
marker,
|
marker,
|
||||||
delimiter: '/'
|
delimiter: '/',
|
||||||
},
|
},
|
||||||
(err, respBody, respInfo) => {
|
(err, respBody, respInfo) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -407,10 +407,10 @@ class QiniuApi {
|
|||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
respBody,
|
respBody,
|
||||||
respInfo
|
respInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
if (res?.respInfo?.statusCode === 200) {
|
if (res?.respInfo?.statusCode === 200) {
|
||||||
@@ -451,7 +451,7 @@ class QiniuApi {
|
|||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
respBody,
|
respBody,
|
||||||
respInfo
|
respInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -470,7 +470,7 @@ class QiniuApi {
|
|||||||
let marker = ''
|
let marker = ''
|
||||||
let isTruncated = true
|
let isTruncated = true
|
||||||
const allFileList = {
|
const allFileList = {
|
||||||
Contents: [] as any[]
|
Contents: [] as any[],
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
const res = (await new Promise((resolve, reject) => {
|
const res = (await new Promise((resolve, reject) => {
|
||||||
@@ -479,7 +479,7 @@ class QiniuApi {
|
|||||||
{
|
{
|
||||||
prefix: key,
|
prefix: key,
|
||||||
marker,
|
marker,
|
||||||
limit: 1000
|
limit: 1000,
|
||||||
},
|
},
|
||||||
(err, respBody, respInfo) => {
|
(err, respBody, respInfo) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -487,10 +487,10 @@ class QiniuApi {
|
|||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
respBody,
|
respBody,
|
||||||
respInfo
|
respInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
})) as any
|
})) as any
|
||||||
if (res?.respInfo?.statusCode === 200) {
|
if (res?.respInfo?.statusCode === 200) {
|
||||||
@@ -515,7 +515,7 @@ class QiniuApi {
|
|||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
respBody,
|
respBody,
|
||||||
respInfo
|
respInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -546,7 +546,7 @@ class QiniuApi {
|
|||||||
bucketName,
|
bucketName,
|
||||||
newKey,
|
newKey,
|
||||||
{
|
{
|
||||||
force: true
|
force: true,
|
||||||
},
|
},
|
||||||
(err, respBody, respInfo) => {
|
(err, respBody, respInfo) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -554,10 +554,10 @@ class QiniuApi {
|
|||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
respBody,
|
respBody,
|
||||||
respInfo
|
respInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
})) as any
|
})) as any
|
||||||
return res?.respInfo?.statusCode === 200
|
return res?.respInfo?.statusCode === 200
|
||||||
@@ -604,14 +604,14 @@ class QiniuApi {
|
|||||||
sourceFilePath: filePath,
|
sourceFilePath: filePath,
|
||||||
targetFilePath: key,
|
targetFilePath: key,
|
||||||
targetFileBucket: bucketName,
|
targetFileBucket: bucketName,
|
||||||
targetFileRegion: region
|
targetFileRegion: region,
|
||||||
})
|
})
|
||||||
const config = new qiniu.conf.Config()
|
const config = new qiniu.conf.Config()
|
||||||
const resumeUploader = new qiniu.resume_up.ResumeUploader(config)
|
const resumeUploader = new qiniu.resume_up.ResumeUploader(config)
|
||||||
const putExtra = new qiniu.resume_up.PutExtra()
|
const putExtra = new qiniu.resume_up.PutExtra()
|
||||||
const uploadToken = new qiniu.rs.PutPolicy({
|
const uploadToken = new qiniu.rs.PutPolicy({
|
||||||
scope: `${bucketName}:${key}`,
|
scope: `${bucketName}:${key}`,
|
||||||
expires: 36000
|
expires: 36000,
|
||||||
}).uploadToken(this.mac)
|
}).uploadToken(this.mac)
|
||||||
putExtra.fname = key
|
putExtra.fname = key
|
||||||
putExtra.params = {}
|
putExtra.params = {}
|
||||||
@@ -623,7 +623,7 @@ class QiniuApi {
|
|||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
id: `${bucketName}-${region}-${key}-${filePath}`,
|
id: `${bucketName}-${region}-${key}-${filePath}`,
|
||||||
progress,
|
progress,
|
||||||
status: uploadTaskSpecialStatus.uploading
|
status: uploadTaskSpecialStatus.uploading,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
resumeUploader.putFile(uploadToken, key, filePath, putExtra, (respErr, respBody, respInfo) => {
|
resumeUploader.putFile(uploadToken, key, filePath, putExtra, (respErr, respBody, respInfo) => {
|
||||||
@@ -631,14 +631,14 @@ class QiniuApi {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
formatError(respErr, {
|
formatError(respErr, {
|
||||||
class: 'Qiniu',
|
class: 'Qiniu',
|
||||||
method: 'uploadBucketFile'
|
method: 'uploadBucketFile',
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
id: `${bucketName}-${region}-${key}-${filePath}`,
|
id: `${bucketName}-${region}-${key}-${filePath}`,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -648,14 +648,14 @@ class QiniuApi {
|
|||||||
progress: 100,
|
progress: 100,
|
||||||
status: uploadTaskSpecialStatus.uploaded,
|
status: uploadTaskSpecialStatus.uploaded,
|
||||||
response: JSON.stringify(respBody),
|
response: JSON.stringify(respBody),
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
id: `${bucketName}-${region}-${key}-${filePath}`,
|
id: `${bucketName}-${region}-${key}-${filePath}`,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -670,7 +670,7 @@ class QiniuApi {
|
|||||||
async createBucketFolder(configMap: IStringKeyMap): Promise<boolean> {
|
async createBucketFolder(configMap: IStringKeyMap): Promise<boolean> {
|
||||||
const { bucketName, key } = configMap
|
const { bucketName, key } = configMap
|
||||||
const putPolicy = new qiniu.rs.PutPolicy({
|
const putPolicy = new qiniu.rs.PutPolicy({
|
||||||
scope: `${bucketName}:${key}`
|
scope: `${bucketName}:${key}`,
|
||||||
})
|
})
|
||||||
const uploadToken = putPolicy.uploadToken(this.mac)
|
const uploadToken = putPolicy.uploadToken(this.mac)
|
||||||
const FormUploader = new qiniu.form_up.FormUploader()
|
const FormUploader = new qiniu.form_up.FormUploader()
|
||||||
@@ -682,7 +682,7 @@ class QiniuApi {
|
|||||||
} else {
|
} else {
|
||||||
resolve({
|
resolve({
|
||||||
respBody,
|
respBody,
|
||||||
respInfo
|
respInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -710,12 +710,12 @@ class QiniuApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.queuing,
|
status: commonTaskStatus.queuing,
|
||||||
sourceFileName: fileName,
|
sourceFileName: fileName,
|
||||||
targetFilePath: savedFilePath
|
targetFilePath: savedFilePath,
|
||||||
})
|
})
|
||||||
const preSignedUrl = await this.getPreSignedUrl({
|
const preSignedUrl = await this.getPreSignedUrl({
|
||||||
key,
|
key,
|
||||||
expires: 36000,
|
expires: 36000,
|
||||||
customUrl
|
customUrl,
|
||||||
})
|
})
|
||||||
promises.push(
|
promises.push(
|
||||||
() =>
|
() =>
|
||||||
@@ -727,7 +727,7 @@ class QiniuApi {
|
|||||||
reject(res)
|
reject(res)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
PutObjectCommand,
|
PutObjectCommand,
|
||||||
PutPublicAccessBlockCommand,
|
PutPublicAccessBlockCommand,
|
||||||
S3Client,
|
S3Client,
|
||||||
S3ClientConfig
|
S3ClientConfig,
|
||||||
} from '@aws-sdk/client-s3'
|
} from '@aws-sdk/client-s3'
|
||||||
import { Progress, Upload } from '@aws-sdk/lib-storage'
|
import { Progress, Upload } from '@aws-sdk/lib-storage'
|
||||||
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
|
||||||
@@ -55,7 +55,7 @@ class S3plistApi {
|
|||||||
proxy: string | undefined,
|
proxy: string | undefined,
|
||||||
logger: ManageLogger,
|
logger: ManageLogger,
|
||||||
dogeCloudSupport: boolean = false,
|
dogeCloudSupport: boolean = false,
|
||||||
bucketName: string = ''
|
bucketName: string = '',
|
||||||
) {
|
) {
|
||||||
this.accessKeyId = accessKeyId
|
this.accessKeyId = accessKeyId
|
||||||
this.secretAccessKey = secretAccessKey
|
this.secretAccessKey = secretAccessKey
|
||||||
@@ -64,12 +64,12 @@ class S3plistApi {
|
|||||||
this.baseOptions = {
|
this.baseOptions = {
|
||||||
credentials: {
|
credentials: {
|
||||||
accessKeyId,
|
accessKeyId,
|
||||||
secretAccessKey
|
secretAccessKey,
|
||||||
},
|
},
|
||||||
endpoint: endpoint ? formatEndpoint(endpoint, sslEnabled) : undefined,
|
endpoint: endpoint ? formatEndpoint(endpoint, sslEnabled) : undefined,
|
||||||
tls: sslEnabled,
|
tls: sslEnabled,
|
||||||
forcePathStyle: s3ForcePathStyle,
|
forcePathStyle: s3ForcePathStyle,
|
||||||
requestHandler: this.setAgent(proxy, sslEnabled)
|
requestHandler: this.setAgent(proxy, sslEnabled),
|
||||||
}
|
}
|
||||||
this.logger = logger
|
this.logger = logger
|
||||||
this.proxy = formatHttpProxy(proxy, 'string') as string | undefined
|
this.proxy = formatHttpProxy(proxy, 'string') as string | undefined
|
||||||
@@ -84,7 +84,7 @@ class S3plistApi {
|
|||||||
this.baseOptions.credentials = {
|
this.baseOptions.credentials = {
|
||||||
accessKeyId: token.accessKeyId,
|
accessKeyId: token.accessKeyId,
|
||||||
secretAccessKey: token.secretAccessKey,
|
secretAccessKey: token.secretAccessKey,
|
||||||
sessionToken: token.sessionToken
|
sessionToken: token.sessionToken,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ class S3plistApi {
|
|||||||
const commonOptions: AgentOptions = {
|
const commonOptions: AgentOptions = {
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
keepAliveMsecs: 1000,
|
keepAliveMsecs: 1000,
|
||||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined
|
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
|
||||||
}
|
}
|
||||||
const extraOptions = sslEnabled ? { rejectUnauthorized: false } : {}
|
const extraOptions = sslEnabled ? { rejectUnauthorized: false } : {}
|
||||||
return sslEnabled
|
return sslEnabled
|
||||||
@@ -102,16 +102,16 @@ class S3plistApi {
|
|||||||
? agent.https
|
? agent.https
|
||||||
: new https.Agent({
|
: new https.Agent({
|
||||||
...commonOptions,
|
...commonOptions,
|
||||||
...extraOptions
|
...extraOptions,
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
: new NodeHttpHandler({
|
: new NodeHttpHandler({
|
||||||
httpAgent: agent.http
|
httpAgent: agent.http
|
||||||
? agent.http
|
? agent.http
|
||||||
: new http.Agent({
|
: new http.Agent({
|
||||||
...commonOptions,
|
...commonOptions,
|
||||||
...extraOptions
|
...extraOptions,
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ class S3plistApi {
|
|||||||
checked: false,
|
checked: false,
|
||||||
isImage: false,
|
isImage: false,
|
||||||
match: false,
|
match: false,
|
||||||
key: item.Prefix
|
key: item.Prefix,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ class S3plistApi {
|
|||||||
isDir: false,
|
isDir: false,
|
||||||
checked: false,
|
checked: false,
|
||||||
match: false,
|
match: false,
|
||||||
isImage: isImage(fileName || '')
|
isImage: isImage(fileName || ''),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,8 +155,8 @@ class S3plistApi {
|
|||||||
BlockPublicAcls: false,
|
BlockPublicAcls: false,
|
||||||
IgnorePublicAcls: false,
|
IgnorePublicAcls: false,
|
||||||
BlockPublicPolicy: false,
|
BlockPublicPolicy: false,
|
||||||
RestrictPublicBuckets: false
|
RestrictPublicBuckets: false,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
const command = new PutPublicAccessBlockCommand(input)
|
const command = new PutPublicAccessBlockCommand(input)
|
||||||
const data = await client.send(command)
|
const data = await client.send(command)
|
||||||
@@ -193,7 +193,7 @@ class S3plistApi {
|
|||||||
if (endpoint === '' || endpoint.includes('amazonaws')) {
|
if (endpoint === '' || endpoint.includes('amazonaws')) {
|
||||||
const createCommand = new CreateBucketCommand({
|
const createCommand = new CreateBucketCommand({
|
||||||
Bucket: BucketName,
|
Bucket: BucketName,
|
||||||
ObjectOwnership: 'BucketOwnerPreferred'
|
ObjectOwnership: 'BucketOwnerPreferred',
|
||||||
})
|
})
|
||||||
const createData = await client.send(createCommand)
|
const createData = await client.send(createCommand)
|
||||||
if (createData.$metadata.httpStatusCode === 200) {
|
if (createData.$metadata.httpStatusCode === 200) {
|
||||||
@@ -201,7 +201,7 @@ class S3plistApi {
|
|||||||
await this.putPublicAccess(BucketName, client)
|
await this.putPublicAccess(BucketName, client)
|
||||||
const putACLCommand = new PutBucketAclCommand({
|
const putACLCommand = new PutBucketAclCommand({
|
||||||
Bucket: BucketName,
|
Bucket: BucketName,
|
||||||
ACL: acl
|
ACL: acl,
|
||||||
})
|
})
|
||||||
const putACLData = await client.send(putACLCommand)
|
const putACLData = await client.send(putACLCommand)
|
||||||
if (putACLData.$metadata.httpStatusCode !== 200) {
|
if (putACLData.$metadata.httpStatusCode !== 200) {
|
||||||
@@ -216,7 +216,7 @@ class S3plistApi {
|
|||||||
} else {
|
} else {
|
||||||
const createCommand = new CreateBucketCommand({
|
const createCommand = new CreateBucketCommand({
|
||||||
Bucket: BucketName,
|
Bucket: BucketName,
|
||||||
ACL: acl
|
ACL: acl,
|
||||||
})
|
})
|
||||||
const createData = await client.send(createCommand)
|
const createData = await client.send(createCommand)
|
||||||
if (createData.$metadata.httpStatusCode === 200) {
|
if (createData.$metadata.httpStatusCode === 200) {
|
||||||
@@ -244,8 +244,8 @@ class S3plistApi {
|
|||||||
{
|
{
|
||||||
Name: item.s3Bucket,
|
Name: item.s3Bucket,
|
||||||
CreationDate: item.ctime,
|
CreationDate: item.ctime,
|
||||||
Location: item.region
|
Location: item.region,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -274,16 +274,16 @@ class S3plistApi {
|
|||||||
...data.Buckets.map(bucket => ({
|
...data.Buckets.map(bucket => ({
|
||||||
Name: bucket.Name,
|
Name: bucket.Name,
|
||||||
CreationDate: bucket.CreationDate,
|
CreationDate: bucket.CreationDate,
|
||||||
Location: 'auto'
|
Location: 'auto',
|
||||||
}))
|
})),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
for (const bucket of data.Buckets) {
|
for (const bucket of data.Buckets) {
|
||||||
const bucketName = bucket.Name
|
const bucketName = bucket.Name
|
||||||
const bucketConfig = await client.send(
|
const bucketConfig = await client.send(
|
||||||
new GetBucketLocationCommand({
|
new GetBucketLocationCommand({
|
||||||
Bucket: bucketName
|
Bucket: bucketName,
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
result.push({
|
result.push({
|
||||||
Name: bucketName,
|
Name: bucketName,
|
||||||
@@ -291,7 +291,7 @@ class S3plistApi {
|
|||||||
Location:
|
Location:
|
||||||
bucketConfig.$metadata.httpStatusCode === 200
|
bucketConfig.$metadata.httpStatusCode === 200
|
||||||
? bucketConfig.LocationConstraint?.toLowerCase() || 'us-east-1'
|
? bucketConfig.LocationConstraint?.toLowerCase() || 'us-east-1'
|
||||||
: 'us-east-1'
|
: 'us-east-1',
|
||||||
})
|
})
|
||||||
if (bucketConfig.$metadata.httpStatusCode !== 200) {
|
if (bucketConfig.$metadata.httpStatusCode !== 200) {
|
||||||
this.logParam(bucketConfig, 'getBucketList')
|
this.logParam(bucketConfig, 'getBucketList')
|
||||||
@@ -311,7 +311,7 @@ class S3plistApi {
|
|||||||
bucketName: bucket,
|
bucketName: bucket,
|
||||||
bucketConfig: { Location: region },
|
bucketConfig: { Location: region },
|
||||||
prefix,
|
prefix,
|
||||||
cancelToken
|
cancelToken,
|
||||||
} = configMap
|
} = configMap
|
||||||
const slicedPrefix = prefix.slice(1)
|
const slicedPrefix = prefix.slice(1)
|
||||||
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
||||||
@@ -327,7 +327,7 @@ class S3plistApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
@@ -338,7 +338,7 @@ class S3plistApi {
|
|||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||||
MaxKeys: 1000,
|
MaxKeys: 1000,
|
||||||
ContinuationToken: marker
|
ContinuationToken: marker,
|
||||||
})
|
})
|
||||||
res = await client.send(command)
|
res = await client.send(command)
|
||||||
if (res.$metadata.httpStatusCode === 200) {
|
if (res.$metadata.httpStatusCode === 200) {
|
||||||
@@ -375,7 +375,7 @@ class S3plistApi {
|
|||||||
bucketName: bucket,
|
bucketName: bucket,
|
||||||
bucketConfig: { Location: region },
|
bucketConfig: { Location: region },
|
||||||
prefix,
|
prefix,
|
||||||
cancelToken
|
cancelToken,
|
||||||
} = configMap
|
} = configMap
|
||||||
const slicedPrefix = prefix.slice(1)
|
const slicedPrefix = prefix.slice(1)
|
||||||
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
||||||
@@ -391,7 +391,7 @@ class S3plistApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.getDogeCloudToken()
|
await this.getDogeCloudToken()
|
||||||
@@ -404,7 +404,7 @@ class S3plistApi {
|
|||||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||||
MaxKeys: 1000,
|
MaxKeys: 1000,
|
||||||
ContinuationToken: marker,
|
ContinuationToken: marker,
|
||||||
Delimiter: '/'
|
Delimiter: '/',
|
||||||
})
|
})
|
||||||
res = await client.send(command)
|
res = await client.send(command)
|
||||||
if (res.$metadata.httpStatusCode === 200) {
|
if (res.$metadata.httpStatusCode === 200) {
|
||||||
@@ -445,7 +445,7 @@ class S3plistApi {
|
|||||||
bucketConfig: { Location: region },
|
bucketConfig: { Location: region },
|
||||||
prefix,
|
prefix,
|
||||||
marker,
|
marker,
|
||||||
itemsPerPage
|
itemsPerPage,
|
||||||
} = configMap
|
} = configMap
|
||||||
const slicedPrefix = prefix.slice(1)
|
const slicedPrefix = prefix.slice(1)
|
||||||
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
const urlPrefix = configMap.customUrl || `https://${bucket}.s3.amazonaws.com`
|
||||||
@@ -453,13 +453,13 @@ class S3plistApi {
|
|||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
isTruncated: false,
|
isTruncated: false,
|
||||||
nextMarker: '',
|
nextMarker: '',
|
||||||
success: false
|
success: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.getDogeCloudToken()
|
await this.getDogeCloudToken()
|
||||||
const options = {
|
const options = {
|
||||||
...this.baseOptions,
|
...this.baseOptions,
|
||||||
region: String(region) || 'us-east-1'
|
region: String(region) || 'us-east-1',
|
||||||
} as S3ClientConfig
|
} as S3ClientConfig
|
||||||
const client = new S3Client(options)
|
const client = new S3Client(options)
|
||||||
const command = new ListObjectsV2Command({
|
const command = new ListObjectsV2Command({
|
||||||
@@ -467,13 +467,13 @@ class S3plistApi {
|
|||||||
Prefix: slicedPrefix,
|
Prefix: slicedPrefix,
|
||||||
ContinuationToken: marker === '' ? undefined : marker,
|
ContinuationToken: marker === '' ? undefined : marker,
|
||||||
Delimiter: '/',
|
Delimiter: '/',
|
||||||
MaxKeys: itemsPerPage
|
MaxKeys: itemsPerPage,
|
||||||
})
|
})
|
||||||
const data = await client.send(command)
|
const data = await client.send(command)
|
||||||
if (data.$metadata.httpStatusCode === 200) {
|
if (data.$metadata.httpStatusCode === 200) {
|
||||||
result.fullList = [
|
result.fullList = [
|
||||||
...(data.CommonPrefixes?.map(item => this.formatFolder(item, slicedPrefix, urlPrefix)) || []),
|
...(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.isTruncated = data.IsTruncated || false
|
||||||
result.nextMarker = data.NextContinuationToken || ''
|
result.nextMarker = data.NextContinuationToken || ''
|
||||||
@@ -502,19 +502,19 @@ class S3plistApi {
|
|||||||
await this.getDogeCloudToken()
|
await this.getDogeCloudToken()
|
||||||
const options = {
|
const options = {
|
||||||
...this.baseOptions,
|
...this.baseOptions,
|
||||||
region: String(region) || 'us-east-1'
|
region: String(region) || 'us-east-1',
|
||||||
} as S3ClientConfig
|
} as S3ClientConfig
|
||||||
const client = new S3Client(options)
|
const client = new S3Client(options)
|
||||||
const command = new CopyObjectCommand({
|
const command = new CopyObjectCommand({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
CopySource: encodeURI(`${bucketName}/${oldKey}`),
|
CopySource: encodeURI(`${bucketName}/${oldKey}`),
|
||||||
Key: newKey
|
Key: newKey,
|
||||||
})
|
})
|
||||||
const data = await client.send(command)
|
const data = await client.send(command)
|
||||||
if (data.$metadata.httpStatusCode === 200) {
|
if (data.$metadata.httpStatusCode === 200) {
|
||||||
const deleteCommand = new DeleteObjectCommand({
|
const deleteCommand = new DeleteObjectCommand({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Key: oldKey
|
Key: oldKey,
|
||||||
})
|
})
|
||||||
const deleteData = await client.send(deleteCommand)
|
const deleteData = await client.send(deleteCommand)
|
||||||
if (deleteData.$metadata.httpStatusCode === 204) {
|
if (deleteData.$metadata.httpStatusCode === 204) {
|
||||||
@@ -550,7 +550,7 @@ class S3plistApi {
|
|||||||
const client = new S3Client(options)
|
const client = new S3Client(options)
|
||||||
const command = new DeleteObjectCommand({
|
const command = new DeleteObjectCommand({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Key: key
|
Key: key,
|
||||||
})
|
})
|
||||||
const data = await client.send(command)
|
const data = await client.send(command)
|
||||||
if (data.$metadata.httpStatusCode === 204) {
|
if (data.$metadata.httpStatusCode === 204) {
|
||||||
@@ -576,7 +576,7 @@ class S3plistApi {
|
|||||||
let res
|
let res
|
||||||
const allFileList = {
|
const allFileList = {
|
||||||
CommonPrefixes: [] as any[],
|
CommonPrefixes: [] as any[],
|
||||||
Contents: [] as any[]
|
Contents: [] as any[],
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.getDogeCloudToken()
|
await this.getDogeCloudToken()
|
||||||
@@ -589,7 +589,7 @@ class S3plistApi {
|
|||||||
Prefix: key,
|
Prefix: key,
|
||||||
ContinuationToken: marker === '' ? undefined : marker,
|
ContinuationToken: marker === '' ? undefined : marker,
|
||||||
Delimiter: '/',
|
Delimiter: '/',
|
||||||
MaxKeys: 1000
|
MaxKeys: 1000,
|
||||||
})
|
})
|
||||||
res = (await client.send(command)) as ListObjectsV2CommandOutput
|
res = (await client.send(command)) as ListObjectsV2CommandOutput
|
||||||
if (res.$metadata.httpStatusCode === 200) {
|
if (res.$metadata.httpStatusCode === 200) {
|
||||||
@@ -607,7 +607,7 @@ class S3plistApi {
|
|||||||
res = await this.deleteBucketFolder({
|
res = await this.deleteBucketFolder({
|
||||||
bucketName,
|
bucketName,
|
||||||
region,
|
region,
|
||||||
key: item.Prefix
|
key: item.Prefix,
|
||||||
})
|
})
|
||||||
if (!res) {
|
if (!res) {
|
||||||
return result
|
return result
|
||||||
@@ -626,10 +626,10 @@ class S3plistApi {
|
|||||||
Delete: {
|
Delete: {
|
||||||
Objects: deleteList.map(item => {
|
Objects: deleteList.map(item => {
|
||||||
return {
|
return {
|
||||||
Key: item.Key
|
Key: item.Key,
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
res = await client.send(deleteCommand)
|
res = await client.send(deleteCommand)
|
||||||
if (res.$metadata.httpStatusCode !== 200) {
|
if (res.$metadata.httpStatusCode !== 200) {
|
||||||
@@ -668,11 +668,11 @@ class S3plistApi {
|
|||||||
client,
|
client,
|
||||||
new GetObjectCommand({
|
new GetObjectCommand({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Key: key
|
Key: key,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
expiresIn: expires || 3600
|
expiresIn: expires || 3600,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
return signedUrl
|
return signedUrl
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -695,7 +695,7 @@ class S3plistApi {
|
|||||||
const client = new S3Client(options)
|
const client = new S3Client(options)
|
||||||
const command = new PutObjectCommand({
|
const command = new PutObjectCommand({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Key: key
|
Key: key,
|
||||||
})
|
})
|
||||||
const data = await client.send(command)
|
const data = await client.send(command)
|
||||||
if (data.$metadata.httpStatusCode === 200) {
|
if (data.$metadata.httpStatusCode === 200) {
|
||||||
@@ -733,7 +733,7 @@ class S3plistApi {
|
|||||||
'aws-exec-read',
|
'aws-exec-read',
|
||||||
'authenticated-read',
|
'authenticated-read',
|
||||||
'bucket-owner-read',
|
'bucket-owner-read',
|
||||||
'bucket-owner-full-control'
|
'bucket-owner-full-control',
|
||||||
]
|
]
|
||||||
for (const item of fileArray) {
|
for (const item of fileArray) {
|
||||||
const { bucketName, region, key, filePath, fileName, aclForUpload } = item
|
const { bucketName, region, key, filePath, fileName, aclForUpload } = item
|
||||||
@@ -749,7 +749,7 @@ class S3plistApi {
|
|||||||
sourceFilePath: filePath,
|
sourceFilePath: filePath,
|
||||||
targetFilePath: key,
|
targetFilePath: key,
|
||||||
targetFileBucket: bucketName,
|
targetFileBucket: bucketName,
|
||||||
targetFileRegion: String(region)
|
targetFileRegion: String(region),
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
await this.getDogeCloudToken()
|
await this.getDogeCloudToken()
|
||||||
@@ -760,7 +760,7 @@ class S3plistApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
response: JSON.stringify(error),
|
response: JSON.stringify(error),
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -777,15 +777,15 @@ class S3plistApi {
|
|||||||
ContentType: getFileMimeType(fileName),
|
ContentType: getFileMimeType(fileName),
|
||||||
ACL: allowedAcl.includes(aclForUpload) ? aclForUpload : 'private',
|
ACL: allowedAcl.includes(aclForUpload) ? aclForUpload : 'private',
|
||||||
Metadata: {
|
Metadata: {
|
||||||
description: 'uploaded by PicList'
|
description: 'uploaded by PicList',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
parallelUploads3.on('httpUploadProgress', (progress: Progress) => {
|
parallelUploads3.on('httpUploadProgress', (progress: Progress) => {
|
||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
id,
|
id,
|
||||||
progress: progress.loaded && progress.total ? Math.floor((progress.loaded / progress.total) * 100) : 0,
|
progress: progress.loaded && progress.total ? Math.floor((progress.loaded / progress.total) * 100) : 0,
|
||||||
status: uploadTaskSpecialStatus.uploading
|
status: uploadTaskSpecialStatus.uploading,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
parallelUploads3
|
parallelUploads3
|
||||||
@@ -796,14 +796,14 @@ class S3plistApi {
|
|||||||
id,
|
id,
|
||||||
progress: 100,
|
progress: 100,
|
||||||
status: uploadTaskSpecialStatus.uploaded,
|
status: uploadTaskSpecialStatus.uploaded,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
id,
|
id,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -814,7 +814,7 @@ class S3plistApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
response: JSON.stringify(error),
|
response: JSON.stringify(error),
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -841,14 +841,14 @@ class S3plistApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.queuing,
|
status: commonTaskStatus.queuing,
|
||||||
sourceFileName: fileName,
|
sourceFileName: fileName,
|
||||||
targetFilePath: savedFilePath
|
targetFilePath: savedFilePath,
|
||||||
})
|
})
|
||||||
const preSignedUrl = await this.getPreSignedUrl({
|
const preSignedUrl = await this.getPreSignedUrl({
|
||||||
bucketName,
|
bucketName,
|
||||||
region: String(region),
|
region: String(region),
|
||||||
key,
|
key,
|
||||||
expires: 36000,
|
expires: 36000,
|
||||||
customUrl
|
customUrl,
|
||||||
})
|
})
|
||||||
promises.push(
|
promises.push(
|
||||||
() =>
|
() =>
|
||||||
@@ -860,7 +860,7 @@ class S3plistApi {
|
|||||||
reject(res)
|
reject(res)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class SftpApi {
|
|||||||
passphrase: Undefinable<string>,
|
passphrase: Undefinable<string>,
|
||||||
fileMode: Undefinable<string>,
|
fileMode: Undefinable<string>,
|
||||||
dirMode: Undefinable<string>,
|
dirMode: Undefinable<string>,
|
||||||
logger: ManageLogger
|
logger: ManageLogger,
|
||||||
) {
|
) {
|
||||||
this.host = host
|
this.host = host
|
||||||
this.port = Number(port) || 22
|
this.port = Number(port) || 22
|
||||||
@@ -71,7 +71,7 @@ class SftpApi {
|
|||||||
username: this.username,
|
username: this.username,
|
||||||
password: this.password,
|
password: this.password,
|
||||||
privateKey: this.privateKey,
|
privateKey: this.privateKey,
|
||||||
passphrase: this.passphrase
|
passphrase: this.passphrase,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ class SftpApi {
|
|||||||
checked: false,
|
checked: false,
|
||||||
isImage: false,
|
isImage: false,
|
||||||
match: false,
|
match: false,
|
||||||
url
|
url,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ class SftpApi {
|
|||||||
checked: false,
|
checked: false,
|
||||||
match: false,
|
match: false,
|
||||||
isImage: isImage(item.filename),
|
isImage: isImage(item.filename),
|
||||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`
|
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ class SftpApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.connectClient()
|
await this.connectClient()
|
||||||
@@ -211,7 +211,7 @@ class SftpApi {
|
|||||||
size: Number(size) || 0,
|
size: Number(size) || 0,
|
||||||
mtime,
|
mtime,
|
||||||
filename,
|
filename,
|
||||||
key
|
key,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
@@ -237,7 +237,7 @@ class SftpApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.connectClient()
|
await this.connectClient()
|
||||||
@@ -339,13 +339,13 @@ class SftpApi {
|
|||||||
targetFilePath: key,
|
targetFilePath: key,
|
||||||
targetFileBucket: bucketName,
|
targetFileBucket: bucketName,
|
||||||
targetFileRegion: region,
|
targetFileRegion: region,
|
||||||
noProgress: false
|
noProgress: false,
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
await this.connectClient()
|
await this.connectClient()
|
||||||
const res = await this.ctx.putFile(filePath, `/${key.replace(/^\/+/, '')}`, {
|
const res = await this.ctx.putFile(filePath, `/${key.replace(/^\/+/, '')}`, {
|
||||||
fileMode: this.fileMode,
|
fileMode: this.fileMode,
|
||||||
dirMode: this.dirMode
|
dirMode: this.dirMode,
|
||||||
})
|
})
|
||||||
this.ctx.close()
|
this.ctx.close()
|
||||||
if (res) {
|
if (res) {
|
||||||
@@ -353,14 +353,14 @@ class SftpApi {
|
|||||||
id,
|
id,
|
||||||
progress: 100,
|
progress: 100,
|
||||||
status: uploadTaskSpecialStatus.uploaded,
|
status: uploadTaskSpecialStatus.uploaded,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
id,
|
id,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -369,7 +369,7 @@ class SftpApi {
|
|||||||
id,
|
id,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -405,7 +405,7 @@ class SftpApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.queuing,
|
status: commonTaskStatus.queuing,
|
||||||
sourceFileName: fileName,
|
sourceFileName: fileName,
|
||||||
targetFilePath: savedFilePath
|
targetFilePath: savedFilePath,
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
await this.connectClient()
|
await this.connectClient()
|
||||||
@@ -416,14 +416,14 @@ class SftpApi {
|
|||||||
id,
|
id,
|
||||||
progress: 100,
|
progress: 100,
|
||||||
status: downloadTaskSpecialStatus.downloaded,
|
status: downloadTaskSpecialStatus.downloaded,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
instance.updateDownloadTask({
|
instance.updateDownloadTask({
|
||||||
id,
|
id,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -432,7 +432,7 @@ class SftpApi {
|
|||||||
id,
|
id,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ class SmmsApi {
|
|||||||
baseURL: this.baseUrl,
|
baseURL: this.baseUrl,
|
||||||
timeout: this.timeout,
|
timeout: this.timeout,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: this.token
|
Authorization: this.token,
|
||||||
},
|
},
|
||||||
httpsAgent: new Agent({
|
httpsAgent: new Agent({
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
timeout: this.timeout
|
timeout: this.timeout,
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
this.logger = logger
|
this.logger = logger
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ class SmmsApi {
|
|||||||
match: false,
|
match: false,
|
||||||
isImage: isImage(item.storename),
|
isImage: isImage(item.storename),
|
||||||
sha: item.hash,
|
sha: item.hash,
|
||||||
downloadUrl: item.url
|
downloadUrl: item.url,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,17 +69,17 @@ class SmmsApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
res = await this.axiosInstance('/upload_history', {
|
res = await this.axiosInstance('/upload_history', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data'
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
page: marker
|
page: marker,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
if (res && res.status === 200 && res.data && res.data.success) {
|
if (res && res.status === 200 && res.data && res.data.success) {
|
||||||
if (res.data.Count === 0) {
|
if (res.data.Count === 0) {
|
||||||
@@ -128,16 +128,16 @@ class SmmsApi {
|
|||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
isTruncated: false,
|
isTruncated: false,
|
||||||
nextMarker: '',
|
nextMarker: '',
|
||||||
success: false
|
success: false,
|
||||||
}
|
}
|
||||||
const res = await this.axiosInstance('/upload_history', {
|
const res = await this.axiosInstance('/upload_history', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data'
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
page: currentPage
|
page: currentPage,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
if (res?.status !== 200 || !res?.data?.success) return result
|
if (res?.status !== 200 || !res?.data?.success) return result
|
||||||
|
|
||||||
@@ -167,8 +167,8 @@ class SmmsApi {
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
params: {
|
params: {
|
||||||
hash: DeleteHash,
|
hash: DeleteHash,
|
||||||
format: 'json'
|
format: 'json',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return res?.status === 200 && res?.data?.success
|
return res?.status === 200 && res?.data?.success
|
||||||
}
|
}
|
||||||
@@ -194,13 +194,13 @@ class SmmsApi {
|
|||||||
sourceFilePath: filePath,
|
sourceFilePath: filePath,
|
||||||
targetFilePath: key,
|
targetFilePath: key,
|
||||||
targetFileBucket: bucketName,
|
targetFileBucket: bucketName,
|
||||||
targetFileRegion: region
|
targetFileRegion: region,
|
||||||
})
|
})
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
form.append('format', 'json')
|
form.append('format', 'json')
|
||||||
form.append('smfile', fs.createReadStream(filePath), {
|
form.append('smfile', fs.createReadStream(filePath), {
|
||||||
filename: path.basename(fileName),
|
filename: path.basename(fileName),
|
||||||
contentType: getFileMimeType(fileName)
|
contentType: getFileMimeType(fileName),
|
||||||
})
|
})
|
||||||
const headers = form.getHeaders()
|
const headers = form.getHeaders()
|
||||||
headers.Authorization = this.token
|
headers.Authorization = this.token
|
||||||
@@ -230,7 +230,7 @@ class SmmsApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.queuing,
|
status: commonTaskStatus.queuing,
|
||||||
sourceFileName: fileName,
|
sourceFileName: fileName,
|
||||||
targetFilePath: savedFilePath
|
targetFilePath: savedFilePath,
|
||||||
})
|
})
|
||||||
promises.push(
|
promises.push(
|
||||||
() =>
|
() =>
|
||||||
@@ -242,7 +242,7 @@ class SmmsApi {
|
|||||||
reject(res)
|
reject(res)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class TcyunApi {
|
|||||||
constructor(secretId: string, secretKey: string, logger: ManageLogger) {
|
constructor(secretId: string, secretKey: string, logger: ManageLogger) {
|
||||||
this.ctx = new COS({
|
this.ctx = new COS({
|
||||||
SecretId: secretId,
|
SecretId: secretId,
|
||||||
SecretKey: secretKey
|
SecretKey: secretKey,
|
||||||
})
|
})
|
||||||
this.logger = logger
|
this.logger = logger
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ class TcyunApi {
|
|||||||
isDir: true,
|
isDir: true,
|
||||||
checked: false,
|
checked: false,
|
||||||
isImage: false,
|
isImage: false,
|
||||||
match: false
|
match: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ class TcyunApi {
|
|||||||
checked: false,
|
checked: false,
|
||||||
isImage: isImage(item.Key),
|
isImage: isImage(item.Key),
|
||||||
match: false,
|
match: false,
|
||||||
url: `${urlPrefix}/${item.Key}`
|
url: `${urlPrefix}/${item.Key}`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ class TcyunApi {
|
|||||||
const { bucketName, region } = param
|
const { bucketName, region } = param
|
||||||
const res = await this.ctx.getBucketDomain({
|
const res = await this.ctx.getBucketDomain({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Region: region
|
Region: region,
|
||||||
})
|
})
|
||||||
if (res?.statusCode !== 200 || !res?.DomainRule?.length) return []
|
if (res?.statusCode !== 200 || !res?.DomainRule?.length) return []
|
||||||
return res.DomainRule.filter((item: any) => item.Status === 'ENABLED').map(item => item.Name)
|
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({
|
const res = await this.ctx.putBucket({
|
||||||
ACL: configMap.acl,
|
ACL: configMap.acl,
|
||||||
Bucket: configMap.BucketName,
|
Bucket: configMap.BucketName,
|
||||||
Region: configMap.region
|
Region: configMap.region,
|
||||||
})
|
})
|
||||||
return res?.statusCode === 200
|
return res?.statusCode === 200
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ class TcyunApi {
|
|||||||
bucketConfig: { Location: region },
|
bucketConfig: { Location: region },
|
||||||
prefix,
|
prefix,
|
||||||
customUrl,
|
customUrl,
|
||||||
cancelToken
|
cancelToken,
|
||||||
} = configMap
|
} = configMap
|
||||||
const slicedPrefix = prefix.slice(1, prefix.length)
|
const slicedPrefix = prefix.slice(1, prefix.length)
|
||||||
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
||||||
@@ -119,7 +119,7 @@ class TcyunApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
let res = {} as COS.GetBucketResult
|
let res = {} as COS.GetBucketResult
|
||||||
do {
|
do {
|
||||||
@@ -127,13 +127,13 @@ class TcyunApi {
|
|||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
Region: region,
|
Region: region,
|
||||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||||
Marker: marker
|
Marker: marker,
|
||||||
})
|
})
|
||||||
if (res?.statusCode === 200) {
|
if (res?.statusCode === 200) {
|
||||||
result.fullList.push(
|
result.fullList.push(
|
||||||
...res.Contents.filter(item => parseInt(item.Size) !== 0).map(item =>
|
...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)
|
window.webContents.send(refreshDownloadFileTransferList, result)
|
||||||
} else {
|
} else {
|
||||||
@@ -157,7 +157,7 @@ class TcyunApi {
|
|||||||
bucketConfig: { Location: region },
|
bucketConfig: { Location: region },
|
||||||
prefix,
|
prefix,
|
||||||
customUrl,
|
customUrl,
|
||||||
cancelToken
|
cancelToken,
|
||||||
} = configMap
|
} = configMap
|
||||||
const slicedPrefix = prefix.slice(1, prefix.length)
|
const slicedPrefix = prefix.slice(1, prefix.length)
|
||||||
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
||||||
@@ -174,7 +174,7 @@ class TcyunApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
res = await this.ctx.getBucket({
|
res = await this.ctx.getBucket({
|
||||||
@@ -182,14 +182,14 @@ class TcyunApi {
|
|||||||
Region: region,
|
Region: region,
|
||||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||||
Delimiter: '/',
|
Delimiter: '/',
|
||||||
Marker: marker
|
Marker: marker,
|
||||||
})
|
})
|
||||||
if (res?.statusCode === 200) {
|
if (res?.statusCode === 200) {
|
||||||
result.fullList.push(
|
result.fullList.push(
|
||||||
...res.CommonPrefixes.map(item => this.formatFolder(item, slicedPrefix, urlPrefix)),
|
...res.CommonPrefixes.map(item => this.formatFolder(item, slicedPrefix, urlPrefix)),
|
||||||
...res.Contents.filter(item => parseInt(item.Size) !== 0).map(item =>
|
...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)
|
window.webContents.send('refreshFileTransferList', result)
|
||||||
} else {
|
} else {
|
||||||
@@ -228,7 +228,7 @@ class TcyunApi {
|
|||||||
prefix,
|
prefix,
|
||||||
customUrl,
|
customUrl,
|
||||||
marker,
|
marker,
|
||||||
itemsPerPage
|
itemsPerPage,
|
||||||
} = configMap
|
} = configMap
|
||||||
const slicedPrefix = prefix.slice(1)
|
const slicedPrefix = prefix.slice(1)
|
||||||
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
const urlPrefix = customUrl || `https://${bucket}.cos.${region}.myqcloud.com`
|
||||||
@@ -238,26 +238,26 @@ class TcyunApi {
|
|||||||
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
Prefix: slicedPrefix === '' ? undefined : slicedPrefix,
|
||||||
Delimiter: '/',
|
Delimiter: '/',
|
||||||
Marker: marker,
|
Marker: marker,
|
||||||
MaxKeys: itemsPerPage
|
MaxKeys: itemsPerPage,
|
||||||
})) as COS.GetBucketResult
|
})) as COS.GetBucketResult
|
||||||
if (res?.statusCode !== 200) {
|
if (res?.statusCode !== 200) {
|
||||||
return {
|
return {
|
||||||
fullList: [],
|
fullList: [],
|
||||||
isTruncated: false,
|
isTruncated: false,
|
||||||
nextMarker: '',
|
nextMarker: '',
|
||||||
success: false
|
success: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [
|
fullList: [
|
||||||
...res.CommonPrefixes.map(item => this.formatFolder(item, slicedPrefix, urlPrefix)),
|
...res.CommonPrefixes.map(item => this.formatFolder(item, slicedPrefix, urlPrefix)),
|
||||||
...res.Contents.filter(item => parseInt(item.Size) !== 0).map(item =>
|
...res.Contents.filter(item => parseInt(item.Size) !== 0).map(item =>
|
||||||
this.formatFile(item, slicedPrefix, urlPrefix)
|
this.formatFile(item, slicedPrefix, urlPrefix),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
isTruncated: res.IsTruncated === 'true',
|
isTruncated: res.IsTruncated === 'true',
|
||||||
nextMarker: res.NextMarker || '',
|
nextMarker: res.NextMarker || '',
|
||||||
success: true
|
success: true,
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ class TcyunApi {
|
|||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Region: region,
|
Region: region,
|
||||||
Key: newKey,
|
Key: newKey,
|
||||||
CopySource: handleUrlEncode(`${bucketName}.cos.${region}.myqcloud.com/${oldKey}`)
|
CopySource: handleUrlEncode(`${bucketName}.cos.${region}.myqcloud.com/${oldKey}`),
|
||||||
})
|
})
|
||||||
|
|
||||||
if (copyRes?.statusCode !== 200) return false
|
if (copyRes?.statusCode !== 200) return false
|
||||||
@@ -286,7 +286,7 @@ class TcyunApi {
|
|||||||
const deleteRes = await this.ctx.deleteObject({
|
const deleteRes = await this.ctx.deleteObject({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Region: region,
|
Region: region,
|
||||||
Key: oldKey
|
Key: oldKey,
|
||||||
})
|
})
|
||||||
|
|
||||||
return deleteRes?.statusCode === 204
|
return deleteRes?.statusCode === 204
|
||||||
@@ -306,7 +306,7 @@ class TcyunApi {
|
|||||||
const res = await this.ctx.deleteObject({
|
const res = await this.ctx.deleteObject({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Region: region,
|
Region: region,
|
||||||
Key: key
|
Key: key,
|
||||||
})
|
})
|
||||||
return res?.statusCode === 204
|
return res?.statusCode === 204
|
||||||
}
|
}
|
||||||
@@ -321,7 +321,7 @@ class TcyunApi {
|
|||||||
let res: any
|
let res: any
|
||||||
const allFileList = {
|
const allFileList = {
|
||||||
CommonPrefixes: [] as any[],
|
CommonPrefixes: [] as any[],
|
||||||
Contents: [] as any[]
|
Contents: [] as any[],
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
res = await this.ctx.getBucket({
|
res = await this.ctx.getBucket({
|
||||||
@@ -330,7 +330,7 @@ class TcyunApi {
|
|||||||
Prefix: key,
|
Prefix: key,
|
||||||
Delimiter: '/',
|
Delimiter: '/',
|
||||||
MaxKeys: 1000,
|
MaxKeys: 1000,
|
||||||
Marker: marker
|
Marker: marker,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res?.statusCode !== 200) return false
|
if (res?.statusCode !== 200) return false
|
||||||
@@ -344,7 +344,7 @@ class TcyunApi {
|
|||||||
!(await this.deleteBucketFolder({
|
!(await this.deleteBucketFolder({
|
||||||
bucketName,
|
bucketName,
|
||||||
region,
|
region,
|
||||||
key: item.Prefix
|
key: item.Prefix,
|
||||||
}))
|
}))
|
||||||
) {
|
) {
|
||||||
return false
|
return false
|
||||||
@@ -355,7 +355,7 @@ class TcyunApi {
|
|||||||
const res = await this.ctx.deleteMultipleObject({
|
const res = await this.ctx.deleteMultipleObject({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Region: region,
|
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
|
if (res?.statusCode !== 200) return false
|
||||||
}
|
}
|
||||||
@@ -381,9 +381,9 @@ class TcyunApi {
|
|||||||
Region: region,
|
Region: region,
|
||||||
Key: key,
|
Key: key,
|
||||||
Expires: expires,
|
Expires: expires,
|
||||||
Sign: true
|
Sign: true,
|
||||||
},
|
},
|
||||||
() => {}
|
() => {},
|
||||||
)
|
)
|
||||||
return customUrl ? `${customUrl.replace(/\/+$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
|
return customUrl ? `${customUrl.replace(/\/+$/, '')}/${key}${res.slice(res.indexOf('?'))}` : res
|
||||||
}
|
}
|
||||||
@@ -417,7 +417,7 @@ class TcyunApi {
|
|||||||
sourceFilePath: filePath,
|
sourceFilePath: filePath,
|
||||||
targetFilePath: key,
|
targetFilePath: key,
|
||||||
targetFileBucket: bucketName,
|
targetFileBucket: bucketName,
|
||||||
targetFileRegion: region
|
targetFileRegion: region,
|
||||||
})
|
})
|
||||||
files.push({
|
files.push({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
@@ -432,7 +432,7 @@ class TcyunApi {
|
|||||||
id,
|
id,
|
||||||
progress: Math.floor(progress.percent * 100),
|
progress: Math.floor(progress.percent * 100),
|
||||||
status: uploadTaskSpecialStatus.uploading,
|
status: uploadTaskSpecialStatus.uploading,
|
||||||
cancelToken
|
cancelToken,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onFileFinish: (err: any, data: any) => {
|
onFileFinish: (err: any, data: any) => {
|
||||||
@@ -442,27 +442,27 @@ class TcyunApi {
|
|||||||
progress: 100,
|
progress: 100,
|
||||||
status: uploadTaskSpecialStatus.uploaded,
|
status: uploadTaskSpecialStatus.uploaded,
|
||||||
response: typeof data === 'object' ? JSON.stringify(data) : String(data),
|
response: typeof data === 'object' ? JSON.stringify(data) : String(data),
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
formatError(err, {
|
formatError(err, {
|
||||||
method: 'uploadBucketFile',
|
method: 'uploadBucketFile',
|
||||||
class: 'TcyunApi'
|
class: 'TcyunApi',
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
id,
|
id,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
response: typeof err === 'object' ? JSON.stringify(err) : String(err),
|
response: typeof err === 'object' ? JSON.stringify(err) : String(err),
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
this.ctx.uploadFiles({
|
this.ctx.uploadFiles({
|
||||||
files
|
files,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@@ -478,7 +478,7 @@ class TcyunApi {
|
|||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Region: region,
|
Region: region,
|
||||||
Key: key,
|
Key: key,
|
||||||
Body: ''
|
Body: '',
|
||||||
})
|
})
|
||||||
return res?.statusCode === 200
|
return res?.statusCode === 200
|
||||||
}
|
}
|
||||||
@@ -507,7 +507,7 @@ class TcyunApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.queuing,
|
status: commonTaskStatus.queuing,
|
||||||
sourceFileName: fileName,
|
sourceFileName: fileName,
|
||||||
targetFilePath: path.join(downloadPath, fileName)
|
targetFilePath: path.join(downloadPath, fileName),
|
||||||
})
|
})
|
||||||
fs.ensureDirSync(path.dirname(path.join(downloadPath, fileName)))
|
fs.ensureDirSync(path.dirname(path.join(downloadPath, fileName)))
|
||||||
this.ctx
|
this.ctx
|
||||||
@@ -522,9 +522,9 @@ class TcyunApi {
|
|||||||
instance.updateDownloadTask({
|
instance.updateDownloadTask({
|
||||||
id,
|
id,
|
||||||
progress: Math.floor(progress.percent * 100),
|
progress: Math.floor(progress.percent * 100),
|
||||||
status: downloadTaskSpecialStatus.downloading
|
status: downloadTaskSpecialStatus.downloading,
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
instance.updateDownloadTask({
|
instance.updateDownloadTask({
|
||||||
@@ -532,22 +532,22 @@ class TcyunApi {
|
|||||||
progress: res && res.statusCode === 200 ? 100 : 0,
|
progress: res && res.statusCode === 200 ? 100 : 0,
|
||||||
status: res && res.statusCode === 200 ? downloadTaskSpecialStatus.downloaded : commonTaskStatus.failed,
|
status: res && res.statusCode === 200 ? downloadTaskSpecialStatus.downloaded : commonTaskStatus.failed,
|
||||||
response: typeof res === 'object' ? JSON.stringify(res) : String(res),
|
response: typeof res === 'object' ? JSON.stringify(res) : String(res),
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch((err: any) => {
|
.catch((err: any) => {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
formatError(err, {
|
formatError(err, {
|
||||||
method: 'downloadBucketFile',
|
method: 'downloadBucketFile',
|
||||||
class: 'TcyunApi'
|
class: 'TcyunApi',
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
instance.updateDownloadTask({
|
instance.updateDownloadTask({
|
||||||
id,
|
id,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
response: typeof err === 'object' ? JSON.stringify(err) : String(err),
|
response: typeof err === 'object' ? JSON.stringify(err) : String(err),
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
gotUpload,
|
gotUpload,
|
||||||
hmacSha1Base64,
|
hmacSha1Base64,
|
||||||
md5,
|
md5,
|
||||||
NewDownloader
|
NewDownloader,
|
||||||
} from '~/manage/utils/common'
|
} from '~/manage/utils/common'
|
||||||
import { ManageLogger } from '~/manage/utils/logger'
|
import { ManageLogger } from '~/manage/utils/logger'
|
||||||
import { isImage } from '~/utils/common'
|
import { isImage } from '~/utils/common'
|
||||||
@@ -40,7 +40,7 @@ class UpyunApi {
|
|||||||
password: string,
|
password: string,
|
||||||
logger: ManageLogger,
|
logger: ManageLogger,
|
||||||
antiLeechToken?: string,
|
antiLeechToken?: string,
|
||||||
expireTime?: number
|
expireTime?: number,
|
||||||
) {
|
) {
|
||||||
this.ser = new Upyun.Service(bucket, operator, password)
|
this.ser = new Upyun.Service(bucket, operator, password)
|
||||||
this.cli = new Upyun.Client(this.ser)
|
this.cli = new Upyun.Client(this.ser)
|
||||||
@@ -78,7 +78,7 @@ class UpyunApi {
|
|||||||
checked: false,
|
checked: false,
|
||||||
isImage: false,
|
isImage: false,
|
||||||
match: false,
|
match: false,
|
||||||
Key: key
|
Key: key,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,14 +98,14 @@ class UpyunApi {
|
|||||||
match: false,
|
match: false,
|
||||||
isImage: isImage(item.name),
|
isImage: isImage(item.name),
|
||||||
url,
|
url,
|
||||||
key
|
key,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
authorization(method: string, uri: string, contentMd5: string, operator: string, password: string) {
|
authorization(method: string, uri: string, contentMd5: string, operator: string, password: string) {
|
||||||
return `UPYUN ${operator}:${hmacSha1Base64(
|
return `UPYUN ${operator}:${hmacSha1Base64(
|
||||||
md5(password, 'hex'),
|
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 = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
const folderQueue = [prefix]
|
const folderQueue = [prefix]
|
||||||
const getFolderFile = async (folder: any) => {
|
const getFolderFile = async (folder: any) => {
|
||||||
@@ -141,7 +141,7 @@ class UpyunApi {
|
|||||||
do {
|
do {
|
||||||
res = await this.cli.listDir(key, {
|
res = await this.cli.listDir(key, {
|
||||||
limit: 10000,
|
limit: 10000,
|
||||||
iter: marker
|
iter: marker,
|
||||||
})
|
})
|
||||||
if (res) {
|
if (res) {
|
||||||
res.files?.forEach((item: any) => {
|
res.files?.forEach((item: any) => {
|
||||||
@@ -185,12 +185,12 @@ class UpyunApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
res = await this.cli.listDir(prefix, {
|
res = await this.cli.listDir(prefix, {
|
||||||
limit: 10000,
|
limit: 10000,
|
||||||
iter: marker
|
iter: marker,
|
||||||
})
|
})
|
||||||
if (res) {
|
if (res) {
|
||||||
res.files?.forEach((item: any) => {
|
res.files?.forEach((item: any) => {
|
||||||
@@ -236,11 +236,11 @@ class UpyunApi {
|
|||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
isTruncated: false,
|
isTruncated: false,
|
||||||
nextMarker: '',
|
nextMarker: '',
|
||||||
success: false
|
success: false,
|
||||||
}
|
}
|
||||||
res = await this.cli.listDir(prefix, {
|
res = await this.cli.listDir(prefix, {
|
||||||
limit: itemsPerPage,
|
limit: itemsPerPage,
|
||||||
iter: marker || ''
|
iter: marker || '',
|
||||||
})
|
})
|
||||||
if (res) {
|
if (res) {
|
||||||
res.files?.forEach((item: any) => {
|
res.files?.forEach((item: any) => {
|
||||||
@@ -278,12 +278,12 @@ class UpyunApi {
|
|||||||
Authorization: authorization,
|
Authorization: authorization,
|
||||||
'X-Upyun-Move-Source': xUpyunMoveSource,
|
'X-Upyun-Move-Source': xUpyunMoveSource,
|
||||||
'Content-Length': 0,
|
'Content-Length': 0,
|
||||||
Date: new Date().toUTCString()
|
Date: new Date().toUTCString(),
|
||||||
}
|
}
|
||||||
const res = await axios({
|
const res = await axios({
|
||||||
method,
|
method,
|
||||||
url: `http://v0.api.upyun.com${uri}`,
|
url: `http://v0.api.upyun.com${uri}`,
|
||||||
headers
|
headers,
|
||||||
})
|
})
|
||||||
return res.status === 200
|
return res.status === 200
|
||||||
}
|
}
|
||||||
@@ -313,24 +313,24 @@ class UpyunApi {
|
|||||||
let isTruncated
|
let isTruncated
|
||||||
const allFileList = {
|
const allFileList = {
|
||||||
CommonPrefixes: [] as any[],
|
CommonPrefixes: [] as any[],
|
||||||
Contents: [] as any[]
|
Contents: [] as any[],
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
const res = await this.cli.listDir(key, {
|
const res = await this.cli.listDir(key, {
|
||||||
limit: 10000,
|
limit: 10000,
|
||||||
iter: marker
|
iter: marker,
|
||||||
})
|
})
|
||||||
if (res) {
|
if (res) {
|
||||||
res.files.forEach((item: any) => {
|
res.files.forEach((item: any) => {
|
||||||
item.type === 'N' &&
|
item.type === 'N' &&
|
||||||
allFileList.Contents.push({
|
allFileList.Contents.push({
|
||||||
...item,
|
...item,
|
||||||
key: `${key}${item.name}`
|
key: `${key}${item.name}`,
|
||||||
})
|
})
|
||||||
item.type === 'F' &&
|
item.type === 'F' &&
|
||||||
allFileList.CommonPrefixes.push({
|
allFileList.CommonPrefixes.push({
|
||||||
...item,
|
...item,
|
||||||
key: `${key}${item.name}/`
|
key: `${key}${item.name}/`,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
marker = res.next
|
marker = res.next
|
||||||
@@ -351,7 +351,7 @@ class UpyunApi {
|
|||||||
if (allFileList.CommonPrefixes.length > 0) {
|
if (allFileList.CommonPrefixes.length > 0) {
|
||||||
for (const item of allFileList.CommonPrefixes) {
|
for (const item of allFileList.CommonPrefixes) {
|
||||||
const res = await this.deleteBucketFolder({
|
const res = await this.deleteBucketFolder({
|
||||||
key: item.key
|
key: item.key,
|
||||||
})
|
})
|
||||||
if (!res) {
|
if (!res) {
|
||||||
return false
|
return false
|
||||||
@@ -390,7 +390,7 @@ class UpyunApi {
|
|||||||
sourceFilePath: filePath,
|
sourceFilePath: filePath,
|
||||||
targetFilePath: key,
|
targetFilePath: key,
|
||||||
targetFileBucket: bucketName,
|
targetFileBucket: bucketName,
|
||||||
targetFileRegion: region
|
targetFileRegion: region,
|
||||||
})
|
})
|
||||||
const date = new Date().toUTCString()
|
const date = new Date().toUTCString()
|
||||||
const uri = `/${key}`
|
const uri = `/${key}`
|
||||||
@@ -400,7 +400,7 @@ class UpyunApi {
|
|||||||
'save-key': uri,
|
'save-key': uri,
|
||||||
expiration: Math.floor(Date.now() / 1000) + 2592000,
|
expiration: Math.floor(Date.now() / 1000) + 2592000,
|
||||||
date,
|
date,
|
||||||
'content-length': fileSize
|
'content-length': fileSize,
|
||||||
}
|
}
|
||||||
const base64Policy = Buffer.from(JSON.stringify(uplpadPolicy)).toString('base64')
|
const base64Policy = Buffer.from(JSON.stringify(uplpadPolicy)).toString('base64')
|
||||||
const stringToSign = `${method}&/${bucketName}&${date}&${base64Policy}`
|
const stringToSign = `${method}&/${bucketName}&${date}&${base64Policy}`
|
||||||
@@ -411,7 +411,7 @@ class UpyunApi {
|
|||||||
form.append('authorization', authorization)
|
form.append('authorization', authorization)
|
||||||
form.append('file', fs.createReadStream(filePath), {
|
form.append('file', fs.createReadStream(filePath), {
|
||||||
filename: path.basename(key),
|
filename: path.basename(key),
|
||||||
contentType: getFileMimeType(fileName)
|
contentType: getFileMimeType(fileName),
|
||||||
})
|
})
|
||||||
const headers = form.getHeaders()
|
const headers = form.getHeaders()
|
||||||
headers.Host = 'v0.api.upyun.com'
|
headers.Host = 'v0.api.upyun.com'
|
||||||
@@ -452,7 +452,7 @@ class UpyunApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.queuing,
|
status: commonTaskStatus.queuing,
|
||||||
sourceFileName: fileName,
|
sourceFileName: fileName,
|
||||||
targetFilePath: savedFilePath
|
targetFilePath: savedFilePath,
|
||||||
})
|
})
|
||||||
const preSignedUrl = `${customUrl}/${key}`
|
const preSignedUrl = `${customUrl}/${key}`
|
||||||
promises.push(
|
promises.push(
|
||||||
@@ -465,7 +465,7 @@ class UpyunApi {
|
|||||||
reject(res)
|
reject(res)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class WebdavplistApi {
|
|||||||
sslEnabled: boolean,
|
sslEnabled: boolean,
|
||||||
proxy: string | undefined,
|
proxy: string | undefined,
|
||||||
authType: 'basic' | 'digest' | undefined,
|
authType: 'basic' | 'digest' | undefined,
|
||||||
logger: ManageLogger
|
logger: ManageLogger,
|
||||||
) {
|
) {
|
||||||
this.endpoint = formatEndpoint(endpoint, sslEnabled)
|
this.endpoint = formatEndpoint(endpoint, sslEnabled)
|
||||||
this.username = username
|
this.username = username
|
||||||
@@ -52,7 +52,7 @@ class WebdavplistApi {
|
|||||||
maxBodyLength: 4 * 1024 * 1024 * 1024,
|
maxBodyLength: 4 * 1024 * 1024 * 1024,
|
||||||
maxContentLength: 4 * 1024 * 1024 * 1024,
|
maxContentLength: 4 * 1024 * 1024 * 1024,
|
||||||
httpsAgent: sslEnabled ? this.agent : undefined,
|
httpsAgent: sslEnabled ? this.agent : undefined,
|
||||||
httpAgent: !sslEnabled ? this.agent : undefined
|
httpAgent: !sslEnabled ? this.agent : undefined,
|
||||||
}
|
}
|
||||||
if (this.authType === 'digest') {
|
if (this.authType === 'digest') {
|
||||||
options.authType = AuthType.Digest
|
options.authType = AuthType.Digest
|
||||||
@@ -75,7 +75,7 @@ class WebdavplistApi {
|
|||||||
checked: false,
|
checked: false,
|
||||||
isImage: false,
|
isImage: false,
|
||||||
match: false,
|
match: false,
|
||||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`
|
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ class WebdavplistApi {
|
|||||||
checked: false,
|
checked: false,
|
||||||
match: false,
|
match: false,
|
||||||
isImage: isImage(item.basename),
|
isImage: isImage(item.basename),
|
||||||
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`
|
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,12 +113,12 @@ class WebdavplistApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
res = await this.ctx.getDirectoryContents(prefix, {
|
res = await this.ctx.getDirectoryContents(prefix, {
|
||||||
deep: true,
|
deep: true,
|
||||||
details: true
|
details: true,
|
||||||
})
|
})
|
||||||
if (this.isRequestSuccess(res.status)) {
|
if (this.isRequestSuccess(res.status)) {
|
||||||
if (res.data?.length) {
|
if (res.data?.length) {
|
||||||
@@ -158,12 +158,12 @@ class WebdavplistApi {
|
|||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false
|
finished: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
res = await this.ctx.getDirectoryContents(prefix, {
|
res = await this.ctx.getDirectoryContents(prefix, {
|
||||||
deep: false,
|
deep: false,
|
||||||
details: true
|
details: true,
|
||||||
})
|
})
|
||||||
if (this.isRequestSuccess(res.status)) {
|
if (this.isRequestSuccess(res.status)) {
|
||||||
if (res.data?.length) {
|
if (res.data?.length) {
|
||||||
@@ -263,7 +263,7 @@ class WebdavplistApi {
|
|||||||
targetFilePath: key,
|
targetFilePath: key,
|
||||||
targetFileBucket: bucketName,
|
targetFileBucket: bucketName,
|
||||||
targetFileRegion: region,
|
targetFileRegion: region,
|
||||||
noProgress: true
|
noProgress: true,
|
||||||
})
|
})
|
||||||
this.ctx
|
this.ctx
|
||||||
.putFileContents(key, this.authType === 'digest' ? fs.readFileSync(filePath) : fs.createReadStream(filePath), {
|
.putFileContents(key, this.authType === 'digest' ? fs.readFileSync(filePath) : fs.createReadStream(filePath), {
|
||||||
@@ -272,9 +272,9 @@ class WebdavplistApi {
|
|||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
id,
|
id,
|
||||||
progress: Math.floor((progressEvent.loaded / progressEvent.total) * 100),
|
progress: Math.floor((progressEvent.loaded / progressEvent.total) * 100),
|
||||||
status: uploadTaskSpecialStatus.uploading
|
status: uploadTaskSpecialStatus.uploading,
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
.then((res: boolean) => {
|
.then((res: boolean) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
@@ -282,14 +282,14 @@ class WebdavplistApi {
|
|||||||
id,
|
id,
|
||||||
progress: 100,
|
progress: 100,
|
||||||
status: uploadTaskSpecialStatus.uploaded,
|
status: uploadTaskSpecialStatus.uploaded,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
id,
|
id,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -299,7 +299,7 @@ class WebdavplistApi {
|
|||||||
id,
|
id,
|
||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -311,7 +311,7 @@ class WebdavplistApi {
|
|||||||
let result = false
|
let result = false
|
||||||
try {
|
try {
|
||||||
await this.ctx.createDirectory(key, {
|
await this.ctx.createDirectory(key, {
|
||||||
recursive: true
|
recursive: true,
|
||||||
})
|
})
|
||||||
result = true
|
result = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -336,16 +336,16 @@ class WebdavplistApi {
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.queuing,
|
status: commonTaskStatus.queuing,
|
||||||
sourceFileName: fileName,
|
sourceFileName: fileName,
|
||||||
targetFilePath: savedFilePath
|
targetFilePath: savedFilePath,
|
||||||
})
|
})
|
||||||
let preSignedUrl = await this.getPreSignedUrl({
|
let preSignedUrl = await this.getPreSignedUrl({
|
||||||
key
|
key,
|
||||||
})
|
})
|
||||||
let headers = {} as IStringKeyMap
|
let headers = {} as IStringKeyMap
|
||||||
if (this.authType === 'basic' || !this.authType) {
|
if (this.authType === 'basic' || !this.authType) {
|
||||||
const base64Str = Buffer.from(`${this.username}:${this.password}`).toString('base64')
|
const base64Str = Buffer.from(`${this.username}:${this.password}`).toString('base64')
|
||||||
headers = {
|
headers = {
|
||||||
Authorization: `Basic ${base64Str}`
|
Authorization: `Basic ${base64Str}`,
|
||||||
}
|
}
|
||||||
} else if (this.authType === 'digest') {
|
} else if (this.authType === 'digest') {
|
||||||
const authHeader = await getAuthHeader(
|
const authHeader = await getAuthHeader(
|
||||||
@@ -353,10 +353,10 @@ class WebdavplistApi {
|
|||||||
this.endpoint,
|
this.endpoint,
|
||||||
`/${key.replace(/^\/+/, '')}`,
|
`/${key.replace(/^\/+/, '')}`,
|
||||||
this.username,
|
this.username,
|
||||||
this.password
|
this.password,
|
||||||
)
|
)
|
||||||
headers = {
|
headers = {
|
||||||
Authorization: authHeader
|
Authorization: authHeader,
|
||||||
}
|
}
|
||||||
preSignedUrl = `${this.endpoint}/${key.replace(/^\/+/, '')}`
|
preSignedUrl = `${this.endpoint}/${key.replace(/^\/+/, '')}`
|
||||||
}
|
}
|
||||||
@@ -370,9 +370,9 @@ class WebdavplistApi {
|
|||||||
} else {
|
} else {
|
||||||
reject(res)
|
reject(res)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
const pool = new ConcurrencyPromisePool(maxDownloadFileCount)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ManageDB {
|
|||||||
this.#db = new JSONStore(this.#ctx.configPath)
|
this.#db = new JSONStore(this.#ctx.configPath)
|
||||||
const initParams: IStringKeyMap = {
|
const initParams: IStringKeyMap = {
|
||||||
picBed: {},
|
picBed: {},
|
||||||
settings: {}
|
settings: {},
|
||||||
}
|
}
|
||||||
for (const key in initParams) {
|
for (const key in initParams) {
|
||||||
if (!this.#db.has(key)) {
|
if (!this.#db.has(key)) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ let hasCheckPath = false
|
|||||||
|
|
||||||
const errorMsg = {
|
const errorMsg = {
|
||||||
broken: $t('TIPS_PICGO_CONFIG_FILE_BROKEN_WITH_DEFAULT'),
|
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() {
|
function manageDbChecker() {
|
||||||
@@ -30,30 +30,30 @@ function manageDbChecker() {
|
|||||||
let configFile: string = '{}'
|
let configFile: string = '{}'
|
||||||
const optionsTpl = {
|
const optionsTpl = {
|
||||||
title: $t('TIPS_NOTICE'),
|
title: $t('TIPS_NOTICE'),
|
||||||
body: ''
|
body: '',
|
||||||
}
|
}
|
||||||
// config save bak
|
// config save bak
|
||||||
try {
|
try {
|
||||||
configFile = fs.readFileSync(manageConfigFilePath, { encoding: 'utf-8' })
|
configFile = fs.readFileSync(manageConfigFilePath, { encoding: 'utf-8' })
|
||||||
JSON.parse(configFile)
|
JSON.parse(configFile)
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
fs.unlinkSync(manageConfigFilePath)
|
fs.unlinkSync(manageConfigFilePath)
|
||||||
if (fs.existsSync(manageConfigFileBackupPath)) {
|
if (fs.existsSync(manageConfigFileBackupPath)) {
|
||||||
try {
|
try {
|
||||||
configFile = fs.readFileSync(manageConfigFileBackupPath, {
|
configFile = fs.readFileSync(manageConfigFileBackupPath, {
|
||||||
encoding: 'utf-8'
|
encoding: 'utf-8',
|
||||||
})
|
})
|
||||||
JSON.parse(configFile)
|
JSON.parse(configFile)
|
||||||
writeFile.sync(manageConfigFilePath, configFile, {
|
writeFile.sync(manageConfigFilePath, configFile, {
|
||||||
encoding: 'utf-8'
|
encoding: 'utf-8',
|
||||||
})
|
})
|
||||||
const stats = fs.statSync(manageConfigFileBackupPath)
|
const stats = fs.statSync(manageConfigFileBackupPath)
|
||||||
optionsTpl.body = `${errorMsg.brokenButBackup}\n${$t('TIPS_PICGO_BACKUP_FILE_VERSION', {
|
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)
|
notificationList.push(optionsTpl)
|
||||||
return
|
return
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
optionsTpl.body = errorMsg.broken
|
optionsTpl.body = errorMsg.broken
|
||||||
notificationList.push(optionsTpl)
|
notificationList.push(optionsTpl)
|
||||||
return
|
return
|
||||||
@@ -64,7 +64,7 @@ function manageDbChecker() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
writeFile.sync(manageConfigFileBackupPath, configFile, {
|
writeFile.sync(manageConfigFileBackupPath, configFile, {
|
||||||
encoding: 'utf-8'
|
encoding: 'utf-8',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ function managePathChecker(): string {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const configString = fs.readFileSync(defaultManageConfigPath, {
|
const configString = fs.readFileSync(defaultManageConfigPath, {
|
||||||
encoding: 'utf-8'
|
encoding: 'utf-8',
|
||||||
})
|
})
|
||||||
const config = JSON.parse(configString)
|
const config = JSON.parse(configString)
|
||||||
const userConfigPath: string = config.configPath || ''
|
const userConfigPath: string = config.configPath || ''
|
||||||
@@ -102,7 +102,7 @@ function managePathChecker(): string {
|
|||||||
if (!hasCheckPath) {
|
if (!hasCheckPath) {
|
||||||
const optionsTpl = {
|
const optionsTpl = {
|
||||||
title: $t('TIPS_NOTICE'),
|
title: $t('TIPS_NOTICE'),
|
||||||
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR')
|
body: $t('TIPS_CUSTOM_CONFIG_FILE_PATH_ERROR'),
|
||||||
}
|
}
|
||||||
notificationList?.push(optionsTpl)
|
notificationList?.push(optionsTpl)
|
||||||
hasCheckPath = true
|
hasCheckPath = true
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class UpDownTaskQueue {
|
|||||||
item =>
|
item =>
|
||||||
item.status !== uploadTaskSpecialStatus.uploaded &&
|
item.status !== uploadTaskSpecialStatus.uploaded &&
|
||||||
item.status !== commonTaskStatus.canceled &&
|
item.status !== commonTaskStatus.canceled &&
|
||||||
item.status !== commonTaskStatus.failed
|
item.status !== commonTaskStatus.failed,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ class UpDownTaskQueue {
|
|||||||
item =>
|
item =>
|
||||||
item.status !== downloadTaskSpecialStatus.downloaded &&
|
item.status !== downloadTaskSpecialStatus.downloaded &&
|
||||||
item.status !== commonTaskStatus.canceled &&
|
item.status !== commonTaskStatus.canceled &&
|
||||||
item.status !== commonTaskStatus.failed
|
item.status !== commonTaskStatus.failed,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,8 +137,8 @@ class UpDownTaskQueue {
|
|||||||
this.persistPath,
|
this.persistPath,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
uploadTaskQueue: this.uploadTaskQueue,
|
uploadTaskQueue: this.uploadTaskQueue,
|
||||||
downloadTaskQueue: this.downloadTaskQueue
|
downloadTaskQueue: this.downloadTaskQueue,
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
@@ -151,7 +151,7 @@ class UpDownTaskQueue {
|
|||||||
const persistData = JSON.parse(fs.readFileSync(this.persistPath, { encoding: 'utf-8' }))
|
const persistData = JSON.parse(fs.readFileSync(this.persistPath, { encoding: 'utf-8' }))
|
||||||
this.uploadTaskQueue = persistData.uploadTaskQueue
|
this.uploadTaskQueue = persistData.uploadTaskQueue
|
||||||
this.downloadTaskQueue = persistData.downloadTaskQueue
|
this.downloadTaskQueue = persistData.downloadTaskQueue
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
this.uploadTaskQueue = []
|
this.uploadTaskQueue = []
|
||||||
this.downloadTaskQueue = []
|
this.downloadTaskQueue = []
|
||||||
}
|
}
|
||||||
@@ -163,19 +163,19 @@ class UpDownTaskQueue {
|
|||||||
this.persistPath,
|
this.persistPath,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
uploadTaskQueue: this.uploadTaskQueue,
|
uploadTaskQueue: this.uploadTaskQueue,
|
||||||
downloadTaskQueue: this.downloadTaskQueue
|
downloadTaskQueue: this.downloadTaskQueue,
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
JSON.parse(fs.readFileSync(this.persistPath, { encoding: 'utf-8' }))
|
JSON.parse(fs.readFileSync(this.persistPath, { encoding: 'utf-8' }))
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
this.persistPath,
|
this.persistPath,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
uploadTaskQueue: this.uploadTaskQueue,
|
uploadTaskQueue: this.uploadTaskQueue,
|
||||||
downloadTaskQueue: this.downloadTaskQueue
|
downloadTaskQueue: this.downloadTaskQueue,
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
's3plist',
|
's3plist',
|
||||||
'webdavplist',
|
'webdavplist',
|
||||||
'local',
|
'local',
|
||||||
'sftp'
|
'sftp',
|
||||||
]
|
]
|
||||||
|
|
||||||
private readonly CLOUD_STORAGE_CLIENTS = ['tcyun', 'aliyun', 'qiniu', 's3plist']
|
private readonly CLOUD_STORAGE_CLIENTS = ['tcyun', 'aliyun', 'qiniu', 's3plist']
|
||||||
@@ -51,7 +51,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
's3plist',
|
's3plist',
|
||||||
'webdavplist',
|
'webdavplist',
|
||||||
'local',
|
'local',
|
||||||
'sftp'
|
'sftp',
|
||||||
]
|
]
|
||||||
|
|
||||||
private readonly FILE_LIST_CLIENTS = ['tcyun', 'aliyun', 'qiniu', 'upyun', 'smms', 's3plist']
|
private readonly FILE_LIST_CLIENTS = ['tcyun', 'aliyun', 'qiniu', 'upyun', 'smms', 's3plist']
|
||||||
@@ -70,7 +70,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
return {
|
return {
|
||||||
class: 'ManageApi',
|
class: 'ManageApi',
|
||||||
method,
|
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.token,
|
||||||
this.currentPicBedConfig.githubUsername,
|
this.currentPicBedConfig.githubUsername,
|
||||||
this.currentPicBedConfig.proxy,
|
this.currentPicBedConfig.proxy,
|
||||||
this.logger
|
this.logger,
|
||||||
),
|
),
|
||||||
imgur: () =>
|
imgur: () =>
|
||||||
new API.ImgurApi(
|
new API.ImgurApi(
|
||||||
this.currentPicBedConfig.imgurUserName,
|
this.currentPicBedConfig.imgurUserName,
|
||||||
this.currentPicBedConfig.accessToken,
|
this.currentPicBedConfig.accessToken,
|
||||||
this.currentPicBedConfig.proxy,
|
this.currentPicBedConfig.proxy,
|
||||||
this.logger
|
this.logger,
|
||||||
),
|
),
|
||||||
local: () => new API.LocalApi(this.logger),
|
local: () => new API.LocalApi(this.logger),
|
||||||
qiniu: () => new API.QiniuApi(this.currentPicBedConfig.accessKey, this.currentPicBedConfig.secretKey, 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.currentPicBedConfig.proxy,
|
||||||
this.logger,
|
this.logger,
|
||||||
this.currentPicBedConfig.dogeCloudSupport || false,
|
this.currentPicBedConfig.dogeCloudSupport || false,
|
||||||
this.currentPicBedConfig.bucketName || ''
|
this.currentPicBedConfig.bucketName || '',
|
||||||
),
|
),
|
||||||
sftp: () =>
|
sftp: () =>
|
||||||
new API.SftpApi(
|
new API.SftpApi(
|
||||||
@@ -120,7 +120,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
this.currentPicBedConfig.passphrase,
|
this.currentPicBedConfig.passphrase,
|
||||||
this.currentPicBedConfig.fileMode,
|
this.currentPicBedConfig.fileMode,
|
||||||
this.currentPicBedConfig.dirMode,
|
this.currentPicBedConfig.dirMode,
|
||||||
this.logger
|
this.logger,
|
||||||
),
|
),
|
||||||
tcyun: () => new API.TcyunApi(this.currentPicBedConfig.secretId, this.currentPicBedConfig.secretKey, this.logger),
|
tcyun: () => new API.TcyunApi(this.currentPicBedConfig.secretId, this.currentPicBedConfig.secretKey, this.logger),
|
||||||
upyun: () =>
|
upyun: () =>
|
||||||
@@ -130,7 +130,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
this.currentPicBedConfig.password,
|
this.currentPicBedConfig.password,
|
||||||
this.logger,
|
this.logger,
|
||||||
this.currentPicBedConfig.antiLeechToken,
|
this.currentPicBedConfig.antiLeechToken,
|
||||||
this.currentPicBedConfig.expireTime
|
this.currentPicBedConfig.expireTime,
|
||||||
),
|
),
|
||||||
webdavplist: () =>
|
webdavplist: () =>
|
||||||
new API.WebdavplistApi(
|
new API.WebdavplistApi(
|
||||||
@@ -140,8 +140,8 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
this.currentPicBedConfig.sslEnabled,
|
this.currentPicBedConfig.sslEnabled,
|
||||||
this.currentPicBedConfig.proxy,
|
this.currentPicBedConfig.proxy,
|
||||||
this.currentPicBedConfig.authType,
|
this.currentPicBedConfig.authType,
|
||||||
this.logger
|
this.logger,
|
||||||
)
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
createClient() {
|
createClient() {
|
||||||
@@ -153,7 +153,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
supportedProviders: string[],
|
supportedProviders: string[],
|
||||||
method: string,
|
method: string,
|
||||||
operation: (client: any) => Promise<T>,
|
operation: (client: any) => Promise<T>,
|
||||||
defaultValue: T
|
defaultValue: T,
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
if (!supportedProviders.includes(this.currentPicBedConfig.picBedName)) {
|
if (!supportedProviders.includes(this.currentPicBedConfig.picBedName)) {
|
||||||
return defaultValue
|
return defaultValue
|
||||||
@@ -171,7 +171,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
|
||||||
window.webContents.send(eventName, defaultResult)
|
window.webContents.send(eventName, defaultResult)
|
||||||
ipcMain.removeAllListeners(
|
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() }],
|
smms: [{ Name: 'smms', Location: 'smms', CreationDate: new Date().toISOString() }],
|
||||||
webdavplist: [{ Name: 'webdav', Location: 'webdav', CreationDate: new Date().toISOString() }],
|
webdavplist: [{ Name: 'webdav', Location: 'webdav', CreationDate: new Date().toISOString() }],
|
||||||
local: [{ Name: 'local', Location: 'local', 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]
|
const staticResult = staticBuckets[this.currentPicBedConfig.picBedName as keyof typeof staticBuckets]
|
||||||
@@ -262,7 +262,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
const staticDomains = {
|
const staticDomains = {
|
||||||
upyun: [this.currentPicBedConfig.customUrl],
|
upyun: [this.currentPicBedConfig.customUrl],
|
||||||
smms: ['https://smms.app'],
|
smms: ['https://smms.app'],
|
||||||
imgur: ['https://imgur.com']
|
imgur: ['https://imgur.com'],
|
||||||
}
|
}
|
||||||
|
|
||||||
const staticResult = staticDomains[this.currentPicBedConfig.picBedName as keyof typeof staticDomains]
|
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,
|
this.CLOUD_STORAGE_CLIENTS,
|
||||||
'createBucket',
|
'createBucket',
|
||||||
client => client.createBucket(param!),
|
client => client.createBucket(param!),
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,9 +314,9 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
this.ALL_CLIENTS,
|
this.ALL_CLIENTS,
|
||||||
'getBucketListRecursively',
|
'getBucketListRecursively',
|
||||||
client => client.getBucketListRecursively(param!),
|
client => client.getBucketListRecursively(param!),
|
||||||
defaultResult
|
defaultResult,
|
||||||
)
|
)
|
||||||
} catch (error: any) {
|
} catch (_e: any) {
|
||||||
this.sendDefaultResult(refreshDownloadFileTransferList, defaultResult)
|
this.sendDefaultResult(refreshDownloadFileTransferList, defaultResult)
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
@@ -335,9 +335,9 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
this.ALL_CLIENTS,
|
this.ALL_CLIENTS,
|
||||||
'getBucketListBackstage',
|
'getBucketListBackstage',
|
||||||
client => client.getBucketListBackstage(param!),
|
client => client.getBucketListBackstage(param!),
|
||||||
defaultResult
|
defaultResult,
|
||||||
)
|
)
|
||||||
} catch (error: any) {
|
} catch (_error: any) {
|
||||||
this.sendDefaultResult('refreshFileTransferList', defaultResult)
|
this.sendDefaultResult('refreshFileTransferList', defaultResult)
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
@@ -358,7 +358,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
this.FILE_LIST_CLIENTS,
|
this.FILE_LIST_CLIENTS,
|
||||||
'getBucketFileList',
|
'getBucketFileList',
|
||||||
client => client.getBucketFileList(param!),
|
client => client.getBucketFileList(param!),
|
||||||
defaultResponse
|
defaultResponse,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
this.ALL_CLIENTS,
|
this.ALL_CLIENTS,
|
||||||
'deleteBucketFile',
|
'deleteBucketFile',
|
||||||
client => client.deleteBucketFile(param!),
|
client => client.deleteBucketFile(param!),
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +376,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
this.FOLDER_SUPPORT_CLIENTS,
|
this.FOLDER_SUPPORT_CLIENTS,
|
||||||
'deleteBucketFolder',
|
'deleteBucketFolder',
|
||||||
client => client.deleteBucketFolder(param!),
|
client => client.deleteBucketFolder(param!),
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,7 +386,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
supportedClients,
|
supportedClients,
|
||||||
'renameBucketFile',
|
'renameBucketFile',
|
||||||
client => client.renameBucketFile(param!),
|
client => client.renameBucketFile(param!),
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,7 +395,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
this.ALL_CLIENTS,
|
this.ALL_CLIENTS,
|
||||||
'downloadBucketFile',
|
'downloadBucketFile',
|
||||||
client => client.downloadBucketFile(param!),
|
client => client.downloadBucketFile(param!),
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +408,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
this.FOLDER_SUPPORT_CLIENTS,
|
this.FOLDER_SUPPORT_CLIENTS,
|
||||||
'createBucketFolder',
|
'createBucketFolder',
|
||||||
client => client.createBucketFolder(param!),
|
client => client.createBucketFolder(param!),
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +417,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
this.ALL_CLIENTS,
|
this.ALL_CLIENTS,
|
||||||
'uploadBucketFile',
|
'uploadBucketFile',
|
||||||
client => client.uploadBucketFile(param!),
|
client => client.uploadBucketFile(param!),
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,7 +427,7 @@ export class ManageApi extends EventEmitter implements IManageApiType {
|
|||||||
supportedClients,
|
supportedClients,
|
||||||
'getPreSignedUrl',
|
'getPreSignedUrl',
|
||||||
client => client.getPreSignedUrl(param!),
|
client => client.getPreSignedUrl(param!),
|
||||||
'error'
|
'error',
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ export const getFSFile = async (filePath: string, stream: boolean = false): Prom
|
|||||||
extension: path.extname(filePath),
|
extension: path.extname(filePath),
|
||||||
fileName: path.basename(filePath),
|
fileName: path.basename(filePath),
|
||||||
buffer: stream ? fs.createReadStream(filePath) : await fs.readFile(filePath),
|
buffer: stream ? fs.createReadStream(filePath) : await fs.readFile(filePath),
|
||||||
success: true
|
success: true,
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
return {
|
return {
|
||||||
success: false
|
success: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ const getTempDirPath = () => {
|
|||||||
const checkTempFolderExist = async (tempPath: string) => {
|
const checkTempFolderExist = async (tempPath: string) => {
|
||||||
try {
|
try {
|
||||||
await fs.access(tempPath)
|
await fs.access(tempPath)
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
await fs.mkdir(tempPath)
|
await fs.mkdir(tempPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ export const downloadFileFromUrl = async (urls: string[]) => {
|
|||||||
const res = await axios({
|
const res = await axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url,
|
url,
|
||||||
responseType: 'stream'
|
responseType: 'stream',
|
||||||
})
|
})
|
||||||
res.data.pipe(writer)
|
res.data.pipe(writer)
|
||||||
await finishDownload(writer)
|
await finishDownload(writer)
|
||||||
@@ -87,7 +87,7 @@ export const NewDownloader = async (
|
|||||||
savedFilePath: string,
|
savedFilePath: string,
|
||||||
logger?: ManageLogger,
|
logger?: ManageLogger,
|
||||||
proxy?: string,
|
proxy?: string,
|
||||||
headers?: any
|
headers?: any,
|
||||||
): Promise<boolean> => {
|
): Promise<boolean> => {
|
||||||
const options = {
|
const options = {
|
||||||
url: encodeURI(preSignedUrl),
|
url: encodeURI(preSignedUrl),
|
||||||
@@ -98,10 +98,10 @@ export const NewDownloader = async (
|
|||||||
instance.updateDownloadTask({
|
instance.updateDownloadTask({
|
||||||
id,
|
id,
|
||||||
progress: Math.floor(Number(percentage)),
|
progress: Math.floor(Number(percentage)),
|
||||||
status: downloadTaskSpecialStatus.downloading
|
status: downloadTaskSpecialStatus.downloading,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
maxAttempts: 3
|
maxAttempts: 3,
|
||||||
} as any
|
} as any
|
||||||
if (proxy) {
|
if (proxy) {
|
||||||
options.proxy = proxy
|
options.proxy = proxy
|
||||||
@@ -116,7 +116,7 @@ export const NewDownloader = async (
|
|||||||
id,
|
id,
|
||||||
progress: 100,
|
progress: 100,
|
||||||
status: downloadTaskSpecialStatus.downloaded,
|
status: downloadTaskSpecialStatus.downloaded,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
@@ -127,7 +127,7 @@ export const NewDownloader = async (
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
response: formatError(e, { method: 'NewDownloader' }),
|
response: formatError(e, { method: 'NewDownloader' }),
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -143,23 +143,23 @@ export const gotUpload = async (
|
|||||||
logger?: ManageLogger,
|
logger?: ManageLogger,
|
||||||
timeout: number = 30000,
|
timeout: number = 30000,
|
||||||
throwHttpErrors: boolean = false,
|
throwHttpErrors: boolean = false,
|
||||||
agent: any = {}
|
agent: any = {},
|
||||||
) => {
|
) => {
|
||||||
got(url, {
|
got(url, {
|
||||||
headers,
|
headers,
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
timeout: {
|
timeout: {
|
||||||
lookup: timeout
|
lookup: timeout,
|
||||||
},
|
},
|
||||||
throwHttpErrors,
|
throwHttpErrors,
|
||||||
agent
|
agent,
|
||||||
})
|
})
|
||||||
.on('uploadProgress', (progress: any) => {
|
.on('uploadProgress', (progress: any) => {
|
||||||
instance.updateUploadTask({
|
instance.updateUploadTask({
|
||||||
id,
|
id,
|
||||||
progress: Math.floor(progress.percent * 100),
|
progress: Math.floor(progress.percent * 100),
|
||||||
status: uploadTaskSpecialStatus.uploading
|
status: uploadTaskSpecialStatus.uploading,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
@@ -170,7 +170,7 @@ export const gotUpload = async (
|
|||||||
res?.statusCode === 200 || res?.statusCode === 201
|
res?.statusCode === 200 || res?.statusCode === 201
|
||||||
? uploadTaskSpecialStatus.uploaded
|
? uploadTaskSpecialStatus.uploaded
|
||||||
: commonTaskStatus.failed,
|
: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch((err: any) => {
|
.catch((err: any) => {
|
||||||
@@ -180,7 +180,7 @@ export const gotUpload = async (
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
response: formatError(err, { method: 'gotUpload' }),
|
response: formatError(err, { method: 'gotUpload' }),
|
||||||
status: commonTaskStatus.failed,
|
status: commonTaskStatus.failed,
|
||||||
finishTime: new Date().toLocaleString()
|
finishTime: new Date().toLocaleString(),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -193,14 +193,14 @@ export const formatError = (err: any, params: IStringKeyMap) => {
|
|||||||
name: 'RequestError',
|
name: 'RequestError',
|
||||||
code: err.code,
|
code: err.code,
|
||||||
stack: err.stack ?? '',
|
stack: err.stack ?? '',
|
||||||
timings: err.timings ?? {}
|
timings: err.timings ?? {},
|
||||||
}
|
}
|
||||||
} else if (err instanceof Error) {
|
} else if (err instanceof Error) {
|
||||||
return {
|
return {
|
||||||
...params,
|
...params,
|
||||||
name: err.name ?? '',
|
name: err.name ?? '',
|
||||||
message: err.message ?? '',
|
message: err.message ?? '',
|
||||||
stack: err.stack ?? ''
|
stack: err.stack ?? '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof err === 'object') {
|
if (typeof err === 'object') {
|
||||||
@@ -212,12 +212,12 @@ export const formatError = (err: any, params: IStringKeyMap) => {
|
|||||||
const commonOptions = {
|
const commonOptions = {
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
keepAliveMsecs: 1000,
|
keepAliveMsecs: 1000,
|
||||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined
|
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
|
||||||
} as any
|
} as any
|
||||||
|
|
||||||
export const getAgent = (
|
export const getAgent = (
|
||||||
proxy: any,
|
proxy: any,
|
||||||
https: boolean = true
|
https: boolean = true,
|
||||||
): {
|
): {
|
||||||
https?: HttpsProxyAgent
|
https?: HttpsProxyAgent
|
||||||
http?: HttpProxyAgent
|
http?: HttpProxyAgent
|
||||||
@@ -225,7 +225,7 @@ export const getAgent = (
|
|||||||
const formatProxy = formatHttpProxy(proxy, 'string') as any
|
const formatProxy = formatHttpProxy(proxy, 'string') as any
|
||||||
const commonResult = {
|
const commonResult = {
|
||||||
https: undefined,
|
https: undefined,
|
||||||
http: undefined
|
http: undefined,
|
||||||
}
|
}
|
||||||
if (!formatProxy) return commonResult
|
if (!formatProxy) return commonResult
|
||||||
commonOptions.proxy = formatProxy.replace('127.0.0.1', 'localhost')
|
commonOptions.proxy = formatProxy.replace('127.0.0.1', 'localhost')
|
||||||
@@ -233,16 +233,16 @@ export const getAgent = (
|
|||||||
return {
|
return {
|
||||||
https: new HttpsProxyAgent({
|
https: new HttpsProxyAgent({
|
||||||
...commonOptions,
|
...commonOptions,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false,
|
||||||
}),
|
}),
|
||||||
http: undefined
|
http: undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
http: new HttpProxyAgent({
|
http: new HttpProxyAgent({
|
||||||
...commonOptions
|
...commonOptions,
|
||||||
}),
|
}),
|
||||||
https: undefined
|
https: undefined,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,14 +255,14 @@ export const getInnerAgent = (proxy: any, sslEnabled: boolean = true) => {
|
|||||||
...commonOptions,
|
...commonOptions,
|
||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
host: formatProxy.host,
|
host: formatProxy.host,
|
||||||
port: formatProxy.port
|
port: formatProxy.port,
|
||||||
})
|
}),
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
agent: new https.Agent({
|
agent: new https.Agent({
|
||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
keepAlive: true
|
keepAlive: true,
|
||||||
})
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return formatProxy
|
return formatProxy
|
||||||
@@ -270,13 +270,13 @@ export const getInnerAgent = (proxy: any, sslEnabled: boolean = true) => {
|
|||||||
agent: new http.Agent({
|
agent: new http.Agent({
|
||||||
...commonOptions,
|
...commonOptions,
|
||||||
host: formatProxy.host,
|
host: formatProxy.host,
|
||||||
port: formatProxy.port
|
port: formatProxy.port,
|
||||||
})
|
}),
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
agent: new http.Agent({
|
agent: new http.Agent({
|
||||||
...commonOptions
|
...commonOptions,
|
||||||
})
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +287,7 @@ export function getOptions(
|
|||||||
responseType?: string,
|
responseType?: string,
|
||||||
body?: any,
|
body?: any,
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
proxy?: any
|
proxy?: any,
|
||||||
): OptionsOfTextResponseBody {
|
): OptionsOfTextResponseBody {
|
||||||
return {
|
return {
|
||||||
...(method && { method: method.toUpperCase() }),
|
...(method && { method: method.toUpperCase() }),
|
||||||
@@ -297,9 +297,9 @@ export function getOptions(
|
|||||||
...(responseType && { responseType }),
|
...(responseType && { responseType }),
|
||||||
...(timeout !== undefined ? { timeout: { request: timeout } } : { timeout: { request: 30000 } }),
|
...(timeout !== undefined ? { timeout: { request: timeout } } : { timeout: { request: 30000 } }),
|
||||||
...(proxy && {
|
...(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 = {},
|
data = {},
|
||||||
jsonMode: boolean = false,
|
jsonMode: boolean = false,
|
||||||
accessKey: string,
|
accessKey: string,
|
||||||
secretKey: string
|
secretKey: string,
|
||||||
) {
|
) {
|
||||||
const body = jsonMode ? JSON.stringify(data) : querystring.encode(data)
|
const body = jsonMode ? JSON.stringify(data) : querystring.encode(data)
|
||||||
const sign = crypto
|
const sign = crypto
|
||||||
@@ -33,14 +33,14 @@ export async function dogecloudApi(
|
|||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': jsonMode ? 'application/json' : 'application/x-www-form-urlencoded',
|
'Content-Type': jsonMode ? 'application/json' : 'application/x-www-form-urlencoded',
|
||||||
Authorization: authorization
|
Authorization: authorization,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
if (res.data.code !== 200) {
|
if (res.data.code !== 200) {
|
||||||
throw new Error('API Error')
|
throw new Error('API Error')
|
||||||
}
|
}
|
||||||
return res.data.data
|
return res.data.data
|
||||||
} catch (err: any) {
|
} catch (_e: any) {
|
||||||
throw new Error('API Error')
|
throw new Error('API Error')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,23 +55,23 @@ export async function getTempToken(accessKey: string, secretKey: string): Promis
|
|||||||
'/auth/tmp_token.json',
|
'/auth/tmp_token.json',
|
||||||
{
|
{
|
||||||
channel: 'OSS_FULL',
|
channel: 'OSS_FULL',
|
||||||
scopes: ['*']
|
scopes: ['*'],
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
accessKey,
|
accessKey,
|
||||||
secretKey
|
secretKey,
|
||||||
)
|
)
|
||||||
const token = data.Credentials
|
const token = data.Credentials
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
Credentials: {
|
Credentials: {
|
||||||
'doge-token': {
|
'doge-token': {
|
||||||
token,
|
token,
|
||||||
expires: data.ExpiredAt * 1000
|
expires: data.ExpiredAt * 1000,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return token
|
return token
|
||||||
} catch (err: any) {
|
} catch (_e: any) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class ManageLogger implements ILogger {
|
|||||||
[ILogType.success]: 'green',
|
[ILogType.success]: 'green',
|
||||||
[ILogType.info]: 'blue',
|
[ILogType.info]: 'blue',
|
||||||
[ILogType.warn]: 'yellow',
|
[ILogType.warn]: 'yellow',
|
||||||
[ILogType.error]: 'red'
|
[ILogType.error]: 'red',
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly #ctx: IManageApiType
|
readonly #ctx: IManageApiType
|
||||||
@@ -67,12 +67,12 @@ export class ManageLogger implements ILogger {
|
|||||||
return {
|
return {
|
||||||
isLarge: logFileSize > logFileSizeLimit,
|
isLarge: logFileSize > logFileSizeLimit,
|
||||||
logFileSize,
|
logFileSize,
|
||||||
logFileSizeLimit
|
logFileSizeLimit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fs.ensureFileSync(logPath)
|
fs.ensureFileSync(logPath)
|
||||||
return {
|
return {
|
||||||
isLarge: false
|
isLarge: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,20 +21,20 @@ const serverTempDir = path.join(appPath, 'serverTemp')
|
|||||||
fs.ensureDirSync(serverTempDir)
|
fs.ensureDirSync(serverTempDir)
|
||||||
|
|
||||||
const multerStorage = multer.diskStorage({
|
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)
|
fs.ensureDirSync(serverTempDir)
|
||||||
cb(null, 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)) {
|
if (!/[^\u0000-\u00ff]/.test(file.originalname)) {
|
||||||
file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf8')
|
file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf8')
|
||||||
}
|
}
|
||||||
cb(null, file.originalname)
|
cb(null, file.originalname)
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const uploadMulter = multer({
|
const uploadMulter = multer({
|
||||||
storage: multerStorage
|
storage: multerStorage,
|
||||||
})
|
})
|
||||||
|
|
||||||
class Server {
|
class Server {
|
||||||
@@ -85,8 +85,8 @@ class Server {
|
|||||||
response,
|
response,
|
||||||
statusCode: 404,
|
statusCode: 404,
|
||||||
body: {
|
body: {
|
||||||
success: false
|
success: false,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const remoteAddress = request.socket.remoteAddress || 'unknown'
|
const remoteAddress = request.socket.remoteAddress || 'unknown'
|
||||||
@@ -109,8 +109,8 @@ class Server {
|
|||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Error processing formData'
|
message: 'Error processing formData',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// @ts-expect-error since the multer type is not correct
|
// @ts-expect-error since the multer type is not correct
|
||||||
@@ -121,7 +121,7 @@ class Server {
|
|||||||
handler({
|
handler({
|
||||||
list,
|
list,
|
||||||
response,
|
response,
|
||||||
urlparams: urlSP
|
urlparams: urlSP,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -140,8 +140,8 @@ class Server {
|
|||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Not sending data in JSON format'
|
message: 'Not sending data in JSON format',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
logger.info('[PicList Server] get the request', body)
|
logger.info('[PicList Server] get the request', body)
|
||||||
@@ -149,7 +149,7 @@ class Server {
|
|||||||
handler!({
|
handler!({
|
||||||
...postObj,
|
...postObj,
|
||||||
response,
|
response,
|
||||||
urlparams: urlSP
|
urlparams: urlSP,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ class Server {
|
|||||||
if (handler) {
|
if (handler) {
|
||||||
handler({
|
handler({
|
||||||
response,
|
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`))
|
await axios.post(ensureHTTPLink(`${this.#config.host}:${port}/heartbeat`))
|
||||||
logger.info(`[PicList Server] server is already running at ${port}`)
|
logger.info(`[PicList Server] server is already running at ${port}`)
|
||||||
this.shutdown(true)
|
this.shutdown(true)
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
logger.warn(`[PicList Server] ${port} is busy, trying with port ${(port as number) + 1}`)
|
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
|
// fix a bug: not write an increase number to config file
|
||||||
// to solve the auto number problem
|
// to solve the auto number problem
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ router.post(
|
|||||||
async ({
|
async ({
|
||||||
response,
|
response,
|
||||||
list = [],
|
list = [],
|
||||||
urlparams
|
urlparams,
|
||||||
}: {
|
}: {
|
||||||
response: IHttpResponse
|
response: IHttpResponse
|
||||||
list?: string[]
|
list?: string[]
|
||||||
@@ -58,8 +58,8 @@ router.post(
|
|||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: false,
|
success: false,
|
||||||
message: 'server key is uncorrect'
|
message: 'server key is uncorrect',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ router.post(
|
|||||||
const treatedFullResult = {
|
const treatedFullResult = {
|
||||||
isEncrypted: 1,
|
isEncrypted: 1,
|
||||||
EncryptedData: new AESHelper().encrypt(JSON.stringify(fullResult)),
|
EncryptedData: new AESHelper().encrypt(JSON.stringify(fullResult)),
|
||||||
...fullResult
|
...fullResult,
|
||||||
}
|
}
|
||||||
delete treatedFullResult.config
|
delete treatedFullResult.config
|
||||||
handleResponse({
|
handleResponse({
|
||||||
@@ -107,16 +107,16 @@ router.post(
|
|||||||
body: {
|
body: {
|
||||||
success: true,
|
success: true,
|
||||||
result: [res],
|
result: [res],
|
||||||
fullResult: [treatedFullResult]
|
fullResult: [treatedFullResult],
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
handleResponse({
|
handleResponse({
|
||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: false,
|
success: false,
|
||||||
message: errorMessage
|
message: errorMessage,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -124,7 +124,7 @@ router.post(
|
|||||||
// upload with files
|
// upload with files
|
||||||
const pathList = list.map(item => {
|
const pathList = list.map(item => {
|
||||||
return {
|
return {
|
||||||
path: item
|
path: item,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const win = windowManager.getAvailableWindow()
|
const win = windowManager.getAvailableWindow()
|
||||||
@@ -136,7 +136,7 @@ router.post(
|
|||||||
const treatedItem = {
|
const treatedItem = {
|
||||||
isEncrypted: 1,
|
isEncrypted: 1,
|
||||||
EncryptedData: new AESHelper().encrypt(JSON.stringify(item.fullResult)),
|
EncryptedData: new AESHelper().encrypt(JSON.stringify(item.fullResult)),
|
||||||
...item.fullResult
|
...item.fullResult,
|
||||||
}
|
}
|
||||||
delete treatedItem.config
|
delete treatedItem.config
|
||||||
treatedItem.imgUrl = useShortUrl ? treatedItem.shortUrl || treatedItem.imgUrl : treatedItem.imgUrl
|
treatedItem.imgUrl = useShortUrl ? treatedItem.shortUrl || treatedItem.imgUrl : treatedItem.imgUrl
|
||||||
@@ -149,16 +149,16 @@ router.post(
|
|||||||
body: {
|
body: {
|
||||||
success: true,
|
success: true,
|
||||||
result: res,
|
result: res,
|
||||||
fullResult
|
fullResult,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
handleResponse({
|
handleResponse({
|
||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: false,
|
success: false,
|
||||||
message: errorMessage
|
message: errorMessage,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,11 +172,11 @@ router.post(
|
|||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: false,
|
success: false,
|
||||||
message: errorMessage
|
message: errorMessage,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
@@ -187,8 +187,8 @@ router.post(
|
|||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: false,
|
success: false,
|
||||||
message: 'no file to delete'
|
message: 'no file to delete',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -205,8 +205,8 @@ router.post(
|
|||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: !!successCount,
|
success: !!successCount,
|
||||||
message: successCount ? `delete success: ${successCount}, fail: ${failCount}` : deleteErrorMessage
|
message: successCount ? `delete success: ${successCount}, fail: ${failCount}` : deleteErrorMessage,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
@@ -214,11 +214,11 @@ router.post(
|
|||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: false,
|
success: false,
|
||||||
message: deleteErrorMessage
|
message: deleteErrorMessage,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
router.any('/heartbeat', async ({ response }: { response: IHttpResponse }) => {
|
router.any('/heartbeat', async ({ response }: { response: IHttpResponse }) => {
|
||||||
@@ -226,8 +226,8 @@ router.any('/heartbeat', async ({ response }: { response: IHttpResponse }) => {
|
|||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: true,
|
success: true,
|
||||||
result: 'alive'
|
result: 'alive',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ export const handleResponse = ({
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'access-control-allow-headers': '*',
|
'access-control-allow-headers': '*',
|
||||||
'access-control-allow-methods': 'POST, GET, OPTIONS',
|
'access-control-allow-methods': 'POST, GET, OPTIONS',
|
||||||
'access-control-allow-origin': '*'
|
'access-control-allow-origin': '*',
|
||||||
},
|
},
|
||||||
body = {
|
body = {
|
||||||
success: false
|
success: false,
|
||||||
}
|
},
|
||||||
}: {
|
}: {
|
||||||
response: IHttpResponse
|
response: IHttpResponse
|
||||||
statusCode?: number
|
statusCode?: number
|
||||||
@@ -55,7 +55,7 @@ export const deleteChoosedFiles = async (list: ImgInfo[]): Promise<boolean[]> =>
|
|||||||
const noteFunc = (value: boolean) => {
|
const noteFunc = (value: boolean) => {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: $t('MANAGE_BUCKET_BATCH_DELETE_ERROR_MSG_MSG2'),
|
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()
|
notification.show()
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ export const deleteChoosedFiles = async (list: ImgInfo[]): Promise<boolean[]> =>
|
|||||||
picgo.emit(ICOREBuildInEvent.REMOVE, [file], GuiApi.getInstance())
|
picgo.emit(ICOREBuildInEvent.REMOVE, [file], GuiApi.getInstance())
|
||||||
}, 500)
|
}, 500)
|
||||||
result.push(true)
|
result.push(true)
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
result.push(false)
|
result.push(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -383,13 +383,13 @@ function generateDirectoryListingHtml(files: any[], requestPath: string, fullPat
|
|||||||
? new Date(fileInfo.mtime).toLocaleDateString('en-US', {
|
? new Date(fileInfo.mtime).toLocaleDateString('en-US', {
|
||||||
year: '2-digit',
|
year: '2-digit',
|
||||||
month: 'numeric',
|
month: 'numeric',
|
||||||
day: 'numeric'
|
day: 'numeric',
|
||||||
}) +
|
}) +
|
||||||
' ' +
|
' ' +
|
||||||
new Date(fileInfo.mtime).toLocaleTimeString('en-US', {
|
new Date(fileInfo.mtime).toLocaleTimeString('en-US', {
|
||||||
hour: 'numeric',
|
hour: 'numeric',
|
||||||
minute: '2-digit',
|
minute: '2-digit',
|
||||||
hour12: true
|
hour12: true,
|
||||||
})
|
})
|
||||||
: ''
|
: ''
|
||||||
|
|
||||||
@@ -454,7 +454,7 @@ function sortFiles(files: string[], fullPath: string): any[] {
|
|||||||
let stats
|
let stats
|
||||||
try {
|
try {
|
||||||
stats = fs.statSync(filePath)
|
stats = fs.statSync(filePath)
|
||||||
} catch (err) {
|
} catch (_e) {
|
||||||
stats = null
|
stats = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,7 +462,7 @@ function sortFiles(files: string[], fullPath: string): any[] {
|
|||||||
name: file,
|
name: file,
|
||||||
isDirectory: stats ? stats.isDirectory() : false,
|
isDirectory: stats ? stats.isDirectory() : false,
|
||||||
size: stats ? stats.size : 0,
|
size: stats ? stats.size : 0,
|
||||||
mtime: stats ? stats.mtime : null
|
mtime: stats ? stats.mtime : null,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
@@ -474,25 +474,25 @@ function sortFiles(files: string[], fullPath: string): any[] {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateErrorPage(errorCode: number, errorMessage: string): string {
|
function generateErrorPage(errorCode: number, _e: string): string {
|
||||||
const errorDescriptions: { [key: number]: { title: string; description: string } } = {
|
const errorDescriptions: Record<number, { title: string; description: string }> = {
|
||||||
404: {
|
404: {
|
||||||
title: 'Page Not Found',
|
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: {
|
500: {
|
||||||
title: 'Server Error',
|
title: 'Server Error',
|
||||||
description: 'An internal server error occurred while processing your request.'
|
description: 'An internal server error occurred while processing your request.',
|
||||||
},
|
},
|
||||||
403: {
|
403: {
|
||||||
title: 'Access Denied',
|
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] || {
|
const error = errorDescriptions[errorCode] || {
|
||||||
title: 'Unknown Error',
|
title: 'Unknown Error',
|
||||||
description: 'An unexpected error occurred.'
|
description: 'An unexpected error occurred.',
|
||||||
}
|
}
|
||||||
|
|
||||||
return `
|
return `
|
||||||
@@ -622,7 +622,7 @@ function serveFile(res: http.ServerResponse, filePath: fs.PathLike) {
|
|||||||
const readStream = fs.createReadStream(filePath)
|
const readStream = fs.createReadStream(filePath)
|
||||||
|
|
||||||
const ext = path.extname(filePath.toString()).toLowerCase()
|
const ext = path.extname(filePath.toString()).toLowerCase()
|
||||||
const contentTypes: { [key: string]: string } = {
|
const contentTypes: Record<string, string> = {
|
||||||
'.html': 'text/html',
|
'.html': 'text/html',
|
||||||
'.css': 'text/css',
|
'.css': 'text/css',
|
||||||
'.js': 'application/javascript',
|
'.js': 'application/javascript',
|
||||||
@@ -634,7 +634,7 @@ function serveFile(res: http.ServerResponse, filePath: fs.PathLike) {
|
|||||||
'.svg': 'image/svg+xml',
|
'.svg': 'image/svg+xml',
|
||||||
'.pdf': 'application/pdf',
|
'.pdf': 'application/pdf',
|
||||||
'.txt': 'text/plain',
|
'.txt': 'text/plain',
|
||||||
'.md': 'text/markdown'
|
'.md': 'text/markdown',
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentType = contentTypes[ext] || 'application/octet-stream'
|
const contentType = contentTypes[ext] || 'application/octet-stream'
|
||||||
@@ -662,7 +662,7 @@ class WebServer {
|
|||||||
enableWebServer: picgo.getConfig<boolean>(configPaths.settings.enableWebServer) || false,
|
enableWebServer: picgo.getConfig<boolean>(configPaths.settings.enableWebServer) || false,
|
||||||
webServerHost: picgo.getConfig<string>(configPaths.settings.webServerHost) || '0.0.0.0',
|
webServerHost: picgo.getConfig<string>(configPaths.settings.webServerHost) || '0.0.0.0',
|
||||||
webServerPort: picgo.getConfig<number>(configPaths.settings.webServerPort) || 37777,
|
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 {
|
} else {
|
||||||
serveFile(res, filePath)
|
serveFile(res, filePath)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (_e) {
|
||||||
logger.error(`File not found: ${filePath}`)
|
logger.error(`File not found: ${filePath}`)
|
||||||
res.writeHead(404, { 'Content-Type': 'text/html' })
|
res.writeHead(404, { 'Content-Type': 'text/html' })
|
||||||
res.end(generateErrorPage(404, 'The requested file or directory was not found'))
|
res.end(generateErrorPage(404, 'The requested file or directory was not found'))
|
||||||
@@ -694,9 +694,9 @@ class WebServer {
|
|||||||
this.#config.webServerHost,
|
this.#config.webServerHost,
|
||||||
() => {
|
() => {
|
||||||
logger.info(
|
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 => {
|
.on('error', err => {
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export const setAutoStart = async (enable: boolean): Promise<void> => {
|
|||||||
try {
|
try {
|
||||||
if (process.platform !== 'linux') {
|
if (process.platform !== 'linux') {
|
||||||
app.setLoginItemSettings({
|
app.setLoginItemSettings({
|
||||||
openAtLogin: enable
|
openAtLogin: enable,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ function copyFileOutsideOfElectronAsar(sourceInAsarArchive: string, destOutsideA
|
|||||||
fs.readdirSync(sourceInAsarArchive).forEach(function (fileOrFolderName) {
|
fs.readdirSync(sourceInAsarArchive).forEach(function (fileOrFolderName) {
|
||||||
copyFileOutsideOfElectronAsar(
|
copyFileOutsideOfElectronAsar(
|
||||||
`${sourceInAsarArchive}/${fileOrFolderName}`,
|
`${sourceInAsarArchive}/${fileOrFolderName}`,
|
||||||
`${destOutsideAsarArchive}/${fileOrFolderName}`
|
`${destOutsideAsarArchive}/${fileOrFolderName}`,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ function resolveMacWorkFlow() {
|
|||||||
path
|
path
|
||||||
.join(__dirname, '../../resources', 'Upload pictures with PicList.workflow')
|
.join(__dirname, '../../resources', 'Upload pictures with PicList.workflow')
|
||||||
.replace('app.asar', 'app.asar.unpacked'),
|
.replace('app.asar', 'app.asar.unpacked'),
|
||||||
dest
|
dest,
|
||||||
)
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
@@ -94,7 +94,7 @@ function resolveClipboardImageGenerator() {
|
|||||||
return files.map(item => {
|
return files.map(item => {
|
||||||
return {
|
return {
|
||||||
origin: path.join(__dirname, '../../resources', item).replace('app.asar', 'app.asar.unpacked'),
|
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)
|
i18nManager.setOutterI18nFolder(i18nFolder)
|
||||||
const i18nFiles = fs.readdirSync(path.join(CONFIG_DIR, 'i18n'), {
|
const i18nFiles = fs.readdirSync(path.join(CONFIG_DIR, 'i18n'), {
|
||||||
withFileTypes: true
|
withFileTypes: true,
|
||||||
})
|
})
|
||||||
i18nFiles.forEach(item => {
|
i18nFiles.forEach(item => {
|
||||||
if (item.isFile() && item.name?.endsWith('.yml')) {
|
if (item.isFile() && item.name?.endsWith('.yml')) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import logger from '@core/picgo/logger'
|
|||||||
import { clipboard, NativeImage } from 'electron'
|
import { clipboard, NativeImage } from 'electron'
|
||||||
|
|
||||||
class ClipboardWatcher extends EventEmitter {
|
class ClipboardWatcher extends EventEmitter {
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
timer: NodeJS.Timeout | null
|
timer: NodeJS.Timeout | null
|
||||||
lastImageHash: string | null
|
lastImageHash: string | null
|
||||||
|
|
||||||
|
|||||||
@@ -64,12 +64,12 @@ export const showNotification = (
|
|||||||
body: '',
|
body: '',
|
||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
copyContent: '',
|
copyContent: '',
|
||||||
clickFn: () => {}
|
clickFn: () => {},
|
||||||
}
|
},
|
||||||
) => {
|
) => {
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: options.title,
|
title: options.title,
|
||||||
body: options.body
|
body: options.body,
|
||||||
})
|
})
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
if (options.clickToCopy) {
|
if (options.clickToCopy) {
|
||||||
@@ -141,8 +141,8 @@ const createC1NShortUrl = async (url: string) => {
|
|||||||
form.append('url', url)
|
form.append('url', url)
|
||||||
const res = await axios.post(c1nApi, form, {
|
const res = await axios.post(c1nApi, form, {
|
||||||
headers: {
|
headers: {
|
||||||
token: c1nToken
|
token: c1nToken,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
if (res.status >= 200 && res.status < 300 && res.data?.code === 0) {
|
if (res.status >= 200 && res.status < 300 && res.data?.code === 0) {
|
||||||
return res.data.data
|
return res.data.data
|
||||||
@@ -168,7 +168,7 @@ const createYOURLSShortLink = async (url: string) => {
|
|||||||
signature,
|
signature,
|
||||||
action: 'shorturl',
|
action: 'shorturl',
|
||||||
format: 'json',
|
format: 'json',
|
||||||
url
|
url,
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(`${domain}/yourls-api.php?${params.toString()}`)
|
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(
|
const res = await axios.post(
|
||||||
`${sinkDomain}/api/link/create`,
|
`${sinkDomain}/api/link/create`,
|
||||||
{ url },
|
{ url },
|
||||||
{ headers: { Authorization: `Bearer ${sinkToken}` } }
|
{ headers: { Authorization: `Bearer ${sinkToken}` } },
|
||||||
)
|
)
|
||||||
if (res.data?.link?.slug) {
|
if (res.data?.link?.slug) {
|
||||||
return `${sinkDomain}/${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 enforceNumber = (num: number | string) => (isNaN(+num) ? 0 : +num)
|
||||||
|
|
||||||
export const trimValues = <T extends IStringKeyMap>(
|
export const trimValues = <T extends IStringKeyMap>(
|
||||||
obj: T
|
obj: T,
|
||||||
): { [K in keyof T]: T[K] extends string ? string : T[K] } => {
|
): { [K in keyof T]: T[K] extends string ? string : T[K] } => {
|
||||||
return Object.fromEntries(
|
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] }
|
) 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 = (
|
export const formatHttpProxy = (
|
||||||
proxy: string | undefined,
|
proxy: string | undefined,
|
||||||
type: 'object' | 'string'
|
type: 'object' | 'string',
|
||||||
): IHTTPProxy | undefined | string => {
|
): IHTTPProxy | undefined | string => {
|
||||||
if (!proxy) return undefined
|
if (!proxy) return undefined
|
||||||
if (/^https?:\/\//.test(proxy)) {
|
if (/^https?:\/\//.test(proxy)) {
|
||||||
@@ -303,7 +303,7 @@ export const formatHttpProxy = (
|
|||||||
: {
|
: {
|
||||||
host: hostname,
|
host: hostname,
|
||||||
port: Number(port),
|
port: Number(port),
|
||||||
protocol: protocol.slice(0, -1)
|
protocol: protocol.slice(0, -1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const [host, port] = proxy.split(':')
|
const [host, port] = proxy.split(':')
|
||||||
@@ -312,7 +312,7 @@ export const formatHttpProxy = (
|
|||||||
: {
|
: {
|
||||||
host,
|
host,
|
||||||
port: port ? Number(port) : 80,
|
port: port ? Number(port) : 80,
|
||||||
protocol: 'http'
|
protocol: 'http',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,12 @@ import type {
|
|||||||
ITcYunConfig,
|
ITcYunConfig,
|
||||||
IUploaderConfig,
|
IUploaderConfig,
|
||||||
IUpYunConfig,
|
IUpYunConfig,
|
||||||
IWebdavPlistConfig
|
IWebdavPlistConfig,
|
||||||
} from '#/types/types'
|
} from '#/types/types'
|
||||||
|
|
||||||
export type manualPageOpenType = 'window' | 'browser'
|
export type manualPageOpenType = 'window' | 'browser'
|
||||||
|
|
||||||
interface IPicGoPlugins {
|
type IPicGoPlugins = Record<`picgo-plugin-${string}`, boolean>
|
||||||
[key: `picgo-plugin-${string}`]: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IConfigStruct {
|
export interface IConfigStruct {
|
||||||
picBed: {
|
picBed: {
|
||||||
@@ -48,9 +46,7 @@ export interface IConfigStruct {
|
|||||||
[others: string]: any
|
[others: string]: any
|
||||||
}
|
}
|
||||||
settings: {
|
settings: {
|
||||||
shortKey: {
|
shortKey: Record<string, IShortKeyConfig>
|
||||||
[key: string]: IShortKeyConfig
|
|
||||||
}
|
|
||||||
logLevel: string[]
|
logLevel: string[]
|
||||||
logPath: string
|
logPath: string
|
||||||
logFileSizeLimit: number
|
logFileSizeLimit: number
|
||||||
@@ -132,12 +128,12 @@ export const configPaths = {
|
|||||||
secondUploaderConfig: 'picBed.secondUploaderConfig',
|
secondUploaderConfig: 'picBed.secondUploaderConfig',
|
||||||
proxy: 'picBed.proxy',
|
proxy: 'picBed.proxy',
|
||||||
transformer: 'picBed.transformer',
|
transformer: 'picBed.transformer',
|
||||||
list: 'picBed.list'
|
list: 'picBed.list',
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
shortKey: {
|
shortKey: {
|
||||||
_path: 'settings.shortKey',
|
_path: 'settings.shortKey',
|
||||||
'picgo:upload': 'settings.shortKey[picgo:upload]'
|
'picgo:upload': 'settings.shortKey[picgo:upload]',
|
||||||
},
|
},
|
||||||
logLevel: 'settings.logLevel',
|
logLevel: 'settings.logLevel',
|
||||||
logPath: 'settings.logPath',
|
logPath: 'settings.logPath',
|
||||||
@@ -192,7 +188,7 @@ export const configPaths = {
|
|||||||
autoImport: 'settings.autoImport',
|
autoImport: 'settings.autoImport',
|
||||||
autoImportPicBed: 'settings.autoImportPicBed',
|
autoImportPicBed: 'settings.autoImportPicBed',
|
||||||
galleryPicBedFilter: 'settings.galleryPicBedFilter',
|
galleryPicBedFilter: 'settings.galleryPicBedFilter',
|
||||||
enableSecondUploader: 'settings.enableSecondUploader'
|
enableSecondUploader: 'settings.enableSecondUploader',
|
||||||
},
|
},
|
||||||
needReload: 'needReload',
|
needReload: 'needReload',
|
||||||
picgoPlugins: 'picgoPlugins',
|
picgoPlugins: 'picgoPlugins',
|
||||||
@@ -201,8 +197,8 @@ export const configPaths = {
|
|||||||
compress: 'buildIn.compress',
|
compress: 'buildIn.compress',
|
||||||
watermark: 'buildIn.watermark',
|
watermark: 'buildIn.watermark',
|
||||||
rename: 'buildIn.rename',
|
rename: 'buildIn.rename',
|
||||||
skipProcess: 'buildIn.skipProcess'
|
skipProcess: 'buildIn.skipProcess',
|
||||||
},
|
},
|
||||||
debug: 'debug',
|
debug: 'debug',
|
||||||
PICGO_ENV: 'PICGO_ENV'
|
PICGO_ENV: 'PICGO_ENV',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const dogeRegionMap: IStringKeyMap = {
|
|||||||
'ap-shanghai': '0',
|
'ap-shanghai': '0',
|
||||||
'ap-beijing': '1',
|
'ap-beijing': '1',
|
||||||
'ap-guangzhou': '2',
|
'ap-guangzhou': '2',
|
||||||
'ap-chengdu': '3'
|
'ap-chengdu': '3',
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dogecloudApi(
|
async function dogecloudApi(
|
||||||
@@ -41,7 +41,7 @@ async function dogecloudApi(
|
|||||||
data = {},
|
data = {},
|
||||||
jsonMode: boolean = false,
|
jsonMode: boolean = false,
|
||||||
accessKey: string,
|
accessKey: string,
|
||||||
secretKey: string
|
secretKey: string,
|
||||||
) {
|
) {
|
||||||
const body = jsonMode ? JSON.stringify(data) : querystring.encode(data)
|
const body = jsonMode ? JSON.stringify(data) : querystring.encode(data)
|
||||||
const sign = crypto
|
const sign = crypto
|
||||||
@@ -57,14 +57,14 @@ async function dogecloudApi(
|
|||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': jsonMode ? 'application/json' : 'application/x-www-form-urlencoded',
|
'Content-Type': jsonMode ? 'application/json' : 'application/x-www-form-urlencoded',
|
||||||
Authorization: authorization
|
Authorization: authorization,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
if (res.data.code !== 200) {
|
if (res.data.code !== 200) {
|
||||||
throw new Error('API Error')
|
throw new Error('API Error')
|
||||||
}
|
}
|
||||||
return res.data.data
|
return res.data.data
|
||||||
} catch (err: any) {
|
} catch (_err: any) {
|
||||||
throw new Error('API Error')
|
throw new Error('API Error')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,11 +75,11 @@ async function getDogeToken(accessKey: string, secretKey: string): Promise<IObj
|
|||||||
'/auth/tmp_token.json',
|
'/auth/tmp_token.json',
|
||||||
{
|
{
|
||||||
channel: 'OSS_FULL',
|
channel: 'OSS_FULL',
|
||||||
scopes: ['*']
|
scopes: ['*'],
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
accessKey,
|
accessKey,
|
||||||
secretKey
|
secretKey,
|
||||||
)
|
)
|
||||||
return data
|
return data
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
@@ -100,12 +100,12 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
|||||||
pathStyleAccess,
|
pathStyleAccess,
|
||||||
rejectUnauthorized,
|
rejectUnauthorized,
|
||||||
proxy,
|
proxy,
|
||||||
urlPrefix
|
urlPrefix,
|
||||||
}
|
},
|
||||||
} = configMap
|
} = configMap
|
||||||
let {
|
let {
|
||||||
imgUrl,
|
imgUrl,
|
||||||
config: { region }
|
config: { region },
|
||||||
} = configMap
|
} = configMap
|
||||||
if (type === 'aws-s3' || type === 'aws-s3-plist') {
|
if (type === 'aws-s3' || type === 'aws-s3-plist') {
|
||||||
imgUrl = rawUrl || imgUrl || ''
|
imgUrl = rawUrl || imgUrl || ''
|
||||||
@@ -139,7 +139,7 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
|||||||
const commonOptions: AgentOptions = {
|
const commonOptions: AgentOptions = {
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
keepAliveMsecs: 1000,
|
keepAliveMsecs: 1000,
|
||||||
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined
|
scheduling: 'lifo' as 'lifo' | 'fifo' | undefined,
|
||||||
}
|
}
|
||||||
const extraOptions = sslEnabled ? { rejectUnauthorized: !!rejectUnauthorized } : {}
|
const extraOptions = sslEnabled ? { rejectUnauthorized: !!rejectUnauthorized } : {}
|
||||||
const handler = sslEnabled
|
const handler = sslEnabled
|
||||||
@@ -148,52 +148,52 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
|||||||
? agent.https
|
? agent.https
|
||||||
: new https.Agent({
|
: new https.Agent({
|
||||||
...commonOptions,
|
...commonOptions,
|
||||||
...extraOptions
|
...extraOptions,
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
: new NodeHttpHandler({
|
: new NodeHttpHandler({
|
||||||
httpAgent: agent.http
|
httpAgent: agent.http
|
||||||
? agent.http
|
? agent.http
|
||||||
: new http.Agent({
|
: new http.Agent({
|
||||||
...commonOptions,
|
...commonOptions,
|
||||||
...extraOptions
|
...extraOptions,
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
const s3Options: S3ClientConfig = {
|
const s3Options: S3ClientConfig = {
|
||||||
credentials: {
|
credentials: {
|
||||||
accessKeyId: accessKeyID,
|
accessKeyId: accessKeyID,
|
||||||
secretAccessKey
|
secretAccessKey,
|
||||||
},
|
},
|
||||||
endpoint: endpointUrl,
|
endpoint: endpointUrl,
|
||||||
tls: sslEnabled,
|
tls: sslEnabled,
|
||||||
forcePathStyle: pathStyleAccess,
|
forcePathStyle: pathStyleAccess,
|
||||||
region,
|
region,
|
||||||
requestHandler: handler
|
requestHandler: handler,
|
||||||
}
|
}
|
||||||
if (dogeMode) {
|
if (dogeMode) {
|
||||||
s3Options.credentials = {
|
s3Options.credentials = {
|
||||||
accessKeyId: configMap.config.accessKeyID,
|
accessKeyId: configMap.config.accessKeyID,
|
||||||
secretAccessKey: configMap.config.secretAccessKey,
|
secretAccessKey: configMap.config.secretAccessKey,
|
||||||
sessionToken: configMap.config.sessionToken
|
sessionToken: configMap.config.sessionToken,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let result: any
|
let result: any
|
||||||
try {
|
try {
|
||||||
fileKey = decodeURIComponent(fileKey)
|
fileKey = decodeURIComponent(fileKey)
|
||||||
} catch (err: any) {}
|
} catch (_err: any) {}
|
||||||
try {
|
try {
|
||||||
const client = new S3Client(s3Options)
|
const client = new S3Client(s3Options)
|
||||||
const command = new DeleteObjectCommand({
|
const command = new DeleteObjectCommand({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Key: fileKey
|
Key: fileKey,
|
||||||
})
|
})
|
||||||
result = await client.send(command)
|
result = await client.send(command)
|
||||||
} catch (err: any) {
|
} catch (_err: any) {
|
||||||
s3Options.region = 'us-east-1'
|
s3Options.region = 'us-east-1'
|
||||||
const client = new S3Client(s3Options)
|
const client = new S3Client(s3Options)
|
||||||
const command = new DeleteObjectCommand({
|
const command = new DeleteObjectCommand({
|
||||||
Bucket: bucketName,
|
Bucket: bucketName,
|
||||||
Key: fileKey
|
Key: fileKey,
|
||||||
})
|
})
|
||||||
result = await client.send(command)
|
result = await client.send(command)
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ export async function removeFileFromS3InMain(configMap: IStringKeyMap, dogeMode:
|
|||||||
|
|
||||||
export async function removeFileFromDogeInMain(configMap: IStringKeyMap) {
|
export async function removeFileFromDogeInMain(configMap: IStringKeyMap) {
|
||||||
const {
|
const {
|
||||||
config: { bucketName, AccessKey, SecretKey }
|
config: { bucketName, AccessKey, SecretKey },
|
||||||
} = configMap
|
} = configMap
|
||||||
const token = (await getDogeToken(AccessKey, SecretKey)) as DogecloudTokenFull
|
const token = (await getDogeToken(AccessKey, SecretKey)) as DogecloudTokenFull
|
||||||
const bucket = token.Buckets?.find(item => item.name === bucketName || item.s3Bucket === bucketName)
|
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,
|
sessionToken: token.Credentials?.sessionToken,
|
||||||
endpoint: bucket?.s3Endpoint,
|
endpoint: bucket?.s3Endpoint,
|
||||||
region: dogeRegionMap[bucket?.s3Endpoint?.split('.')[1] || 'ap-shanghai'],
|
region: dogeRegionMap[bucket?.s3Endpoint?.split('.')[1] || 'ap-shanghai'],
|
||||||
bucketName: bucket?.s3Bucket
|
bucketName: bucket?.s3Bucket,
|
||||||
}
|
}
|
||||||
return await removeFileFromS3InMain(newConfigMap, true)
|
return await removeFileFromS3InMain(newConfigMap, true)
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,7 @@ function createHuaweiAuthorization(
|
|||||||
fileName: string,
|
fileName: string,
|
||||||
accessKey: string,
|
accessKey: string,
|
||||||
secretKey: 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 strToSign = `DELETE\n\n\n${date}\n/${bucketName}${path}/${fileName}`
|
||||||
const singature = crypto.createHmac('sha1', secretKey).update(strToSign).digest('base64')
|
const singature = crypto.createHmac('sha1', secretKey).update(strToSign).digest('base64')
|
||||||
@@ -247,8 +247,8 @@ export async function removeFileFromHuaweiInMain(configMap: IStringKeyMap) {
|
|||||||
headers: {
|
headers: {
|
||||||
Host: `${bucketName}.${endpoint}`,
|
Host: `${bucketName}.${endpoint}`,
|
||||||
Date: date,
|
Date: date,
|
||||||
Authorization: authorization
|
Authorization: authorization,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
return res.status === 204
|
return res.status === 204
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export function digestAuthHeader(
|
|||||||
uri: string,
|
uri: string,
|
||||||
wwwAuthenticate: string,
|
wwwAuthenticate: string,
|
||||||
username: string,
|
username: string,
|
||||||
password: string
|
password: string,
|
||||||
) {
|
) {
|
||||||
const parts = wwwAuthenticate.split(',')
|
const parts = wwwAuthenticate.split(',')
|
||||||
const opts = {} as IStringKeyMap
|
const opts = {} as IStringKeyMap
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ export const ILogType = {
|
|||||||
success: 'success',
|
success: 'success',
|
||||||
info: 'info',
|
info: 'info',
|
||||||
warn: 'warn',
|
warn: 'warn',
|
||||||
error: 'error'
|
error: 'error',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ICOREBuildInEvent = {
|
export const ICOREBuildInEvent = {
|
||||||
@@ -16,7 +16,7 @@ export const ICOREBuildInEvent = {
|
|||||||
UNINSTALL: 'uninstall',
|
UNINSTALL: 'uninstall',
|
||||||
UPDATE: 'update',
|
UPDATE: 'update',
|
||||||
NOTIFICATION: 'notification',
|
NOTIFICATION: 'notification',
|
||||||
REMOVE: 'remove'
|
REMOVE: 'remove',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IPicGoHelperType = {
|
export const IPicGoHelperType = {
|
||||||
@@ -24,7 +24,7 @@ export const IPicGoHelperType = {
|
|||||||
beforeTransformPlugins: 'beforeTransformPlugins',
|
beforeTransformPlugins: 'beforeTransformPlugins',
|
||||||
beforeUploadPlugins: 'beforeUploadPlugins',
|
beforeUploadPlugins: 'beforeUploadPlugins',
|
||||||
uploader: 'uploader',
|
uploader: 'uploader',
|
||||||
transformer: 'transformer'
|
transformer: 'transformer',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IPasteStyle = {
|
export const IPasteStyle = {
|
||||||
@@ -32,7 +32,7 @@ export const IPasteStyle = {
|
|||||||
HTML: 'HTML',
|
HTML: 'HTML',
|
||||||
URL: 'URL',
|
URL: 'URL',
|
||||||
UBB: 'UBB',
|
UBB: 'UBB',
|
||||||
CUSTOM: 'Custom'
|
CUSTOM: 'Custom',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IWindowList = {
|
export const IWindowList = {
|
||||||
@@ -40,7 +40,7 @@ export const IWindowList = {
|
|||||||
TRAY_WINDOW: 'TRAY_WINDOW',
|
TRAY_WINDOW: 'TRAY_WINDOW',
|
||||||
MINI_WINDOW: 'MINI_WINDOW',
|
MINI_WINDOW: 'MINI_WINDOW',
|
||||||
RENAME_WINDOW: 'RENAME_WINDOW',
|
RENAME_WINDOW: 'RENAME_WINDOW',
|
||||||
TOOLBOX_WINDOW: 'TOOLBOX_WINDOW'
|
TOOLBOX_WINDOW: 'TOOLBOX_WINDOW',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IRemoteNoticeActionType = {
|
export const IRemoteNoticeActionType = {
|
||||||
@@ -49,22 +49,22 @@ export const IRemoteNoticeActionType = {
|
|||||||
SHOW_DIALOG: 'SHOW_DIALOG', // dialog notice
|
SHOW_DIALOG: 'SHOW_DIALOG', // dialog notice
|
||||||
COMMON: 'COMMON',
|
COMMON: 'COMMON',
|
||||||
VOID: 'VOID', // do nothing
|
VOID: 'VOID', // do nothing
|
||||||
SHOW_MESSAGE_BOX: 'SHOW_MESSAGE_BOX'
|
SHOW_MESSAGE_BOX: 'SHOW_MESSAGE_BOX',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IRemoteNoticeTriggerHook = {
|
export const IRemoteNoticeTriggerHook = {
|
||||||
APP_START: 'APP_START',
|
APP_START: 'APP_START',
|
||||||
SETTING_WINDOW_OPEN: 'SETTING_WINDOW_OPEN'
|
SETTING_WINDOW_OPEN: 'SETTING_WINDOW_OPEN',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IRemoteNoticeTriggerCount = {
|
export const IRemoteNoticeTriggerCount = {
|
||||||
ONCE: 'ONCE', // default
|
ONCE: 'ONCE', // default
|
||||||
ALWAYS: 'ALWAYS'
|
ALWAYS: 'ALWAYS',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IRPCType = {
|
export const IRPCType = {
|
||||||
INVOKE: 'INVOKE',
|
INVOKE: 'INVOKE',
|
||||||
SEND: 'SEND'
|
SEND: 'SEND',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IRPCActionType = {
|
export const IRPCActionType = {
|
||||||
@@ -186,58 +186,58 @@ export const IRPCActionType = {
|
|||||||
MANAGE_OPEN_DOWNLOADED_FOLDER: 'MANAGE_OPEN_DOWNLOADED_FOLDER',
|
MANAGE_OPEN_DOWNLOADED_FOLDER: 'MANAGE_OPEN_DOWNLOADED_FOLDER',
|
||||||
MANAGE_OPEN_LOCAL_FILE: 'MANAGE_OPEN_LOCAL_FILE',
|
MANAGE_OPEN_LOCAL_FILE: 'MANAGE_OPEN_LOCAL_FILE',
|
||||||
MANAGE_DOWNLOAD_FILE_FROM_URL: 'MANAGE_DOWNLOAD_FILE_FROM_URL',
|
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 = {
|
export const IToolboxItemType = {
|
||||||
IS_CONFIG_FILE_BROKEN: 'IS_CONFIG_FILE_BROKEN',
|
IS_CONFIG_FILE_BROKEN: 'IS_CONFIG_FILE_BROKEN',
|
||||||
IS_GALLERY_FILE_BROKEN: 'IS_GALLERY_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_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 = {
|
export const IToolboxItemCheckStatus = {
|
||||||
INIT: 'init',
|
INIT: 'init',
|
||||||
LOADING: 'loading',
|
LOADING: 'loading',
|
||||||
SUCCESS: 'success',
|
SUCCESS: 'success',
|
||||||
ERROR: 'error'
|
ERROR: 'error',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ISartMode = {
|
export const ISartMode = {
|
||||||
QUIET: 'quiet',
|
QUIET: 'quiet',
|
||||||
MINI: 'mini',
|
MINI: 'mini',
|
||||||
MAIN: 'main',
|
MAIN: 'main',
|
||||||
NO_TRAY: 'no-tray'
|
NO_TRAY: 'no-tray',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const II18nLanguage = {
|
export const II18nLanguage = {
|
||||||
ZH_CN: 'zh-CN',
|
ZH_CN: 'zh-CN',
|
||||||
ZH_TW: 'zh-TW',
|
ZH_TW: 'zh-TW',
|
||||||
EN: 'en'
|
EN: 'en',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IShortUrlServer = {
|
export const IShortUrlServer = {
|
||||||
C1N: 'c1n',
|
C1N: 'c1n',
|
||||||
YOURLS: 'yourls',
|
YOURLS: 'yourls',
|
||||||
CFWORKER: 'cf_worker',
|
CFWORKER: 'cf_worker',
|
||||||
SINK: 'sink'
|
SINK: 'sink',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const commonTaskStatus = {
|
export const commonTaskStatus = {
|
||||||
queuing: 'queuing',
|
queuing: 'queuing',
|
||||||
failed: 'failed',
|
failed: 'failed',
|
||||||
canceled: 'canceled',
|
canceled: 'canceled',
|
||||||
paused: 'paused'
|
paused: 'paused',
|
||||||
}
|
}
|
||||||
|
|
||||||
// manage task status
|
// manage task status
|
||||||
|
|
||||||
export const uploadTaskSpecialStatus = {
|
export const uploadTaskSpecialStatus = {
|
||||||
uploading: 'uploading',
|
uploading: 'uploading',
|
||||||
uploaded: 'uploaded'
|
uploaded: 'uploaded',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const downloadTaskSpecialStatus = {
|
export const downloadTaskSpecialStatus = {
|
||||||
downloading: 'downloading',
|
downloading: 'downloading',
|
||||||
downloaded: 'downloaded'
|
downloaded: 'downloaded',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const getPicBeds = () => {
|
|||||||
return {
|
return {
|
||||||
type: item,
|
type: item,
|
||||||
name: picgo.helper.uploader.get(item)!.name || item,
|
name: picgo.helper.uploader.get(item)!.name || item,
|
||||||
visible: visible ? visible.visible : true
|
visible: visible ? visible.visible : true,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.sort(a => {
|
.sort(a => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import type {
|
|||||||
IPicGoPluginOriginConfig,
|
IPicGoPluginOriginConfig,
|
||||||
IStringKeyMap,
|
IStringKeyMap,
|
||||||
IUploaderConfigItem,
|
IUploaderConfigItem,
|
||||||
IUploaderConfigListItem
|
IUploaderConfigListItem,
|
||||||
} from '#/types/types'
|
} from '#/types/types'
|
||||||
import { setTrayToolTip, trimValues } from '~/utils/common'
|
import { setTrayToolTip, trimValues } from '~/utils/common'
|
||||||
import { configPaths } from '~/utils/configPaths'
|
import { configPaths } from '~/utils/configPaths'
|
||||||
@@ -30,7 +30,7 @@ export const completeUploaderMetaConfig = (originData: IStringKeyMap): IUploader
|
|||||||
...trimValues(originData),
|
...trimValues(originData),
|
||||||
_id: uuid(),
|
_id: uuid(),
|
||||||
_createdAt: Date.now(),
|
_createdAt: Date.now(),
|
||||||
_updatedAt: Date.now()
|
_updatedAt: Date.now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,12 +46,12 @@ export const getPicBedConfig = (type: string) => {
|
|||||||
const config = handleConfigWithFunction(_config)
|
const config = handleConfigWithFunction(_config)
|
||||||
return {
|
return {
|
||||||
config,
|
config,
|
||||||
name
|
name,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
config: [],
|
config: [],
|
||||||
name
|
name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,16 +62,16 @@ export const changeSecondUploader = (type: string, config?: IStringKeyMap, id?:
|
|||||||
}
|
}
|
||||||
if (id) {
|
if (id) {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[configPaths.picBed.secondUploaderId]: id
|
[configPaths.picBed.secondUploaderId]: id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (config) {
|
if (config) {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[configPaths.picBed.secondUploaderConfig]: config
|
[configPaths.picBed.secondUploaderConfig]: config,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[configPaths.picBed.secondUploader]: type
|
[configPaths.picBed.secondUploader]: type,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,17 +81,17 @@ export const changeCurrentUploader = (type: string, config?: IStringKeyMap, id?:
|
|||||||
}
|
}
|
||||||
if (id) {
|
if (id) {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`uploader.${type}.defaultId`]: id
|
[`uploader.${type}.defaultId`]: id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (config) {
|
if (config) {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`picBed.${type}`]: config
|
[`picBed.${type}`]: config,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[configPaths.picBed.current]: type,
|
[configPaths.picBed.current]: type,
|
||||||
[configPaths.picBed.uploader]: type
|
[configPaths.picBed.uploader]: type,
|
||||||
})
|
})
|
||||||
setTrayToolTip(`${type} ${config?._configName || ''}`)
|
setTrayToolTip(`${type} ${config?._configName || ''}`)
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ export const selectUploaderConfig = (type: string, id: string) => {
|
|||||||
if (config) {
|
if (config) {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`uploader.${type}.defaultId`]: id,
|
[`uploader.${type}.defaultId`]: id,
|
||||||
[`picBed.${type}`]: config
|
[`picBed.${type}`]: config,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ export const getUploaderConfigList = (type: string): IUploaderConfigItem => {
|
|||||||
if (!type) {
|
if (!type) {
|
||||||
return {
|
return {
|
||||||
configList: [],
|
configList: [],
|
||||||
defaultId: ''
|
defaultId: '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const currentUploaderConfig = picgo.getConfig<IStringKeyMap>(`uploader.${type}`) ?? {}
|
const currentUploaderConfig = picgo.getConfig<IStringKeyMap>(`uploader.${type}`) ?? {}
|
||||||
@@ -124,7 +124,7 @@ export const getUploaderConfigList = (type: string): IUploaderConfigItem => {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
configList,
|
configList,
|
||||||
defaultId
|
defaultId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,11 +143,11 @@ export const deleteUploaderConfig = (type: string, id: string): IUploaderConfigI
|
|||||||
changeCurrentUploader(type, updatedConfigList[0], updatedConfigList[0]._id)
|
changeCurrentUploader(type, updatedConfigList[0], updatedConfigList[0]._id)
|
||||||
}
|
}
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`uploader.${type}.configList`]: updatedConfigList
|
[`uploader.${type}.configList`]: updatedConfigList,
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
configList: updatedConfigList,
|
configList: updatedConfigList,
|
||||||
defaultId: newDefaultId
|
defaultId: newDefaultId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ export const deleteUploaderConfig = (type: string, id: string): IUploaderConfigI
|
|||||||
* upgrade old uploader config to new format
|
* upgrade old uploader config to new format
|
||||||
*/
|
*/
|
||||||
export const upgradeUploaderConfig = (
|
export const upgradeUploaderConfig = (
|
||||||
type: string
|
type: string,
|
||||||
): {
|
): {
|
||||||
configList: IStringKeyMap[]
|
configList: IStringKeyMap[]
|
||||||
defaultId: string
|
defaultId: string
|
||||||
@@ -169,13 +169,13 @@ export const upgradeUploaderConfig = (
|
|||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`uploader.${type}`]: {
|
[`uploader.${type}`]: {
|
||||||
configList: uploaderConfigList,
|
configList: uploaderConfigList,
|
||||||
defaultId: uploaderConfig._id
|
defaultId: uploaderConfig._id,
|
||||||
},
|
},
|
||||||
[`picBed.${type}`]: uploaderConfig
|
[`picBed.${type}`]: uploaderConfig,
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
configList: uploaderConfigList,
|
configList: uploaderConfigList,
|
||||||
defaultId: uploaderConfig._id
|
defaultId: uploaderConfig._id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ export const updateUploaderConfig = (type: string, id: string, config: IStringKe
|
|||||||
let updatedDefaultId = defaultId
|
let updatedDefaultId = defaultId
|
||||||
if (existConfig) {
|
if (existConfig) {
|
||||||
updatedConfig = Object.assign(existConfig, trimValues(config), {
|
updatedConfig = Object.assign(existConfig, trimValues(config), {
|
||||||
_updatedAt: Date.now()
|
_updatedAt: Date.now(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
updatedConfig = completeUploaderMetaConfig(config)
|
updatedConfig = completeUploaderMetaConfig(config)
|
||||||
@@ -196,7 +196,7 @@ export const updateUploaderConfig = (type: string, id: string, config: IStringKe
|
|||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`uploader.${type}.configList`]: configList,
|
[`uploader.${type}.configList`]: configList,
|
||||||
[`uploader.${type}.defaultId`]: updatedDefaultId,
|
[`uploader.${type}.defaultId`]: updatedDefaultId,
|
||||||
[`picBed.${type}`]: updatedConfig
|
[`picBed.${type}`]: updatedConfig,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,12 +216,12 @@ export const resetUploaderConfig = (type: string, id: string) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`uploader.${type}.configList`]: configList
|
[`uploader.${type}.configList`]: configList,
|
||||||
})
|
})
|
||||||
const currentDefault = picgo.getConfig<IStringKeyMap>(`picBed.${type}`) ?? {}
|
const currentDefault = picgo.getConfig<IStringKeyMap>(`picBed.${type}`) ?? {}
|
||||||
if (currentDefault._id === id) {
|
if (currentDefault._id === id) {
|
||||||
picgo.saveConfig({
|
picgo.saveConfig({
|
||||||
[`picBed.${type}`]: configList
|
[`picBed.${type}`]: configList,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user