diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 1c149ddc..bb4cee7d 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -23,7 +23,7 @@ jobs: collation server: 'utf8_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld mysql version: '5' # Optional, default value is "latest". The version of the MySQL mysql database: 'torzo_photo_test' # Optional, default value is "test". The specified database which will be create - mysql root password: 'vechk123' # Required if "mysql user" is empty, default is empty. The root superuser password + mysql root password: '7355608' # Required if "mysql user" is empty, default is empty. The root superuser password mysql user: 'developer' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too mysql password: 123 # Required if "mysql user" exists. The password for the "mysql user" @@ -75,7 +75,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v1 with: - node-version: '16' + node-version: '18' - name: ESLint run: | @@ -96,7 +96,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v1 with: - node-version: '16' + node-version: '18' - name: yarn tsc --noEmit run: | diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index 141acb1b..fb0facaa 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -48,7 +48,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v1 with: - node-version: '16' + node-version: '18' - name: yarn build:development env: @@ -87,7 +87,7 @@ jobs: key: ${{ secrets.SSH_PRIVATE_KEY }} known_hosts: 'a' - - name: Upload Builds - run: | - ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts - scp -r releases/* ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:${{ secrets.DEV_REMOTE_UPLOAD_PATH }} + # - name: Upload Builds + # run: | + # ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts + # scp -r releases/* ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:${{ secrets.DEV_REMOTE_UPLOAD_PATH }} diff --git a/.github/workflows/server-refresh.yml b/.github/workflows/server-refresh.yml index 45d39217..4649ac36 100644 --- a/.github/workflows/server-refresh.yml +++ b/.github/workflows/server-refresh.yml @@ -24,21 +24,45 @@ jobs: key: ${{ secrets.SSH_PRIVATE_KEY }} known_hosts: 'a' - - name: construct script - env: - NODE_ENV: development - run: | - printf "#!/bin/bash\n" > ./server_exec.sh - printf "SERVER_PATH=${{secrets.SERVER_PATH}}\n" >> ./server_exec.sh - cat ./scripts/server-refresh.sh >> ./server_exec.sh - chmod +x ./server_exec.sh - - - name: Exec Script - env: - SSH_USERNAME: ${{ secrets.SSH_USERNAME }} - SSH_HOST: ${{ secrets.SSH_HOST }} - PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - run: | - ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts - cat ./server_exec.sh - ssh ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} < ./server_exec.sh + # - name: construct script + # env: + # NODE_ENV: development + # run: | + # printf "#!/bin/bash\n" > ./server_exec.sh + # printf "SERVER_PATH=${{secrets.SERVER_PATH}}\n" >> ./server_exec.sh + # cat ./scripts/server-refresh.sh >> ./server_exec.sh + # chmod +x ./server_exec.sh + + # - name: Exec Script + # env: + # SSH_USERNAME: ${{ secrets.SSH_USERNAME }} + # SSH_HOST: ${{ secrets.SSH_HOST }} + # PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + # run: | + # ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts + # cat ./server_exec.sh + # ssh ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} < ./server_exec.sh + + # - name: Telegram send success message + # if: ${{ success() }} + # env: + # TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} + # TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} + # COMMITS: ${{ toJSON(github.event.commits) }} + # RUN_NUMBER: ${{ github.run_number }} + # BUILD_DESCRIPTION: ✅ 呵呵,相册测试服前端已经部署。 + # run: | + # node ./scripts/tg-message.js + + # - name: Telegram send failure message + # if: ${{ failure() }} + # env: + # TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} + # TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} + # COMMITS: ${{ toJSON(github.event.commits) }} + # RUN_NUMBER: ${{ github.run_number }} + # BUILD_DESCRIPTION: | + # ❌ 呵呵,相册测试服前端部署失败。早该管管了。 + # 版本: ${{ steps.package-version.outputs.current-version }} + # run: | + # node ./scripts/tg-message.js diff --git a/dashboard/.env.production b/dashboard/.env.production index 83622559..90ef9af5 100755 --- a/dashboard/.env.production +++ b/dashboard/.env.production @@ -2,4 +2,4 @@ ENV = 'production' # base api -VUE_APP_BASE_API = 'https://pache.blog/torzo-gallery-server/api/' +VUE_APP_BASE_API = 'https://pache.blog/torzo-gallery-server/' diff --git a/dashboard/.eslintrc.js b/dashboard/.eslintrc.js index ce1911c8..8185f954 100755 --- a/dashboard/.eslintrc.js +++ b/dashboard/.eslintrc.js @@ -90,7 +90,7 @@ module.exports = { 'no-extend-native': 2, 'no-extra-bind': 2, 'no-extra-boolean-cast': 2, - 'no-extra-parens': [2, 'functions'], + 'no-extra-parens': [0], 'no-fallthrough': 2, 'no-floating-decimal': 2, 'no-func-assign': 2, diff --git a/dashboard/package-lock.json b/dashboard/package-lock.json index 15611d68..2d8ca7cd 100644 --- a/dashboard/package-lock.json +++ b/dashboard/package-lock.json @@ -5759,9 +5759,9 @@ "dev": true }, "element-ui": { - "version": "2.15.4", - "resolved": "https://registry.npmjs.org/element-ui/-/element-ui-2.15.4.tgz", - "integrity": "sha512-b9Tlc6NjygcHv3QNzfPPDQvyAmLdbjQR7q1FMypqFKjowpQzlaL3zlNZ4jrpm0stEBWLeHVIT733z/i6F3o+cA==", + "version": "2.15.14", + "resolved": "https://registry.npmjs.org/element-ui/-/element-ui-2.15.14.tgz", + "integrity": "sha512-2v9fHL0ZGINotOlRIAJD5YuVB8V7WKxrE9Qy7dXhRipa035+kF7WuU/z+tEmLVPBcJ0zt8mOu1DKpWcVzBK8IA==", "requires": { "async-validator": "~1.8.1", "babel-helper-vue-jsx-merge-props": "^2.0.0", @@ -7206,9 +7206,9 @@ } }, "follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==" + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", + "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==" }, "for-each": { "version": "0.3.3", @@ -14286,6 +14286,14 @@ "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + } } }, "request-promise-core": { @@ -17237,10 +17245,9 @@ "dev": true }, "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==" }, "validate-npm-package-license": { "version": "3.0.4", @@ -18199,6 +18206,14 @@ "requires": { "ansi-colors": "^3.0.0", "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + } } }, "webpack-merge": { diff --git a/dashboard/package.json b/dashboard/package.json index ff6d7141..e1d43a70 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -15,12 +15,13 @@ }, "dependencies": { "axios": "0.21.1", - "element-ui": "^2.15.4", + "element-ui": "^2.15.14", "js-cookie": "2.2.0", "normalize.css": "7.0.0", "nprogress": "0.2.0", "pad-left": "^2.1.0", "path-to-regexp": "2.4.0", + "uuid": "^9.0.1", "vue": "2.6.10", "vue-router": "3.0.6", "vuex": "3.1.0" diff --git a/dashboard/src/api/image.js b/dashboard/src/api/image.js index e46a7e16..277517f0 100644 --- a/dashboard/src/api/image.js +++ b/dashboard/src/api/image.js @@ -1,8 +1,24 @@ import request from '@/utils/request' -export const refreshThumbs = () => +export const __AVATAR_THUMB_SIZE__ = 128 + +export const refreshThumb = async({ src, thumb_size }) => + request({ + url: `admin/image/refresh-thumb`, + method: 'POST', + timeout: 0, + data: { src, thumb_size }, + }) + +export const getAllAvailablePhoto = () => request({ - url: 'admin/image/refresh-thumb', + url: `admin/image/available-photo`, method: 'GET', timeout: 0, }) + +export const requestCleanUnusedImage = () => + request({ + url: `admin/image/clean-unused`, + method: 'POST', + }) diff --git a/dashboard/src/api/statistic.js b/dashboard/src/api/statistic.js new file mode 100644 index 00000000..89a21f8b --- /dev/null +++ b/dashboard/src/api/statistic.js @@ -0,0 +1,7 @@ +import request from '@/utils/request' + +export const getStatistic = () => + request({ + url: `admin/statistic`, + method: 'GET', + }) diff --git a/dashboard/src/components/UploadImageBox.vue b/dashboard/src/components/UploadImageBox.vue index b6397474..99c753bb 100644 --- a/dashboard/src/components/UploadImageBox.vue +++ b/dashboard/src/components/UploadImageBox.vue @@ -4,7 +4,7 @@ drag :name="uploadName" :headers="headers" - :action="uploadUrl" + :action="upload_url" :show-file-list="false" :on-error="uploadError" :on-progress="uploadProgress" @@ -137,9 +137,9 @@ default: '' }, - uploadUrl: { - type: String, - default: `${process.env.VUE_APP_BASE_API}admin/image/upload` + thumbSize: { + type: Number, + default: 0 }, previewUrl: { @@ -161,6 +161,17 @@ percent: 0 }), + computed: { + upload_url() { + const base_url = `${process.env.VUE_APP_BASE_API}admin/image/upload` + if (this.thumbSize !== 0) { + return `${base_url}?thumb_size=${this.thumbSize}` + } else { + return base_url + } + } + }, + methods: { resetUploading() { this.uploading = false diff --git a/dashboard/src/main.js b/dashboard/src/main.js index 369623ea..5dc7ae7a 100755 --- a/dashboard/src/main.js +++ b/dashboard/src/main.js @@ -4,7 +4,7 @@ import 'normalize.css/normalize.css' // A modern alternative to CSS resets import ElementUI from 'element-ui' import 'element-ui/lib/theme-chalk/index.css' -import locale from 'element-ui/lib/locale/lang/en' // lang i18n +// import locale from 'element-ui/lib/locale/lang/en' // lang i18n import '@/styles/index.scss' // global css @@ -29,9 +29,10 @@ if (process.env.NODE_ENV === 'production') { } // set ElementUI lang to EN -Vue.use(ElementUI, { locale }) +// Vue.use(ElementUI, { locale }) // 如果想要中文版 element-ui,按如下方式声明 -// Vue.use(ElementUI) +Vue.use(ElementUI) +console.log('ElementUI', ElementUI) Vue.config.productionTip = false diff --git a/dashboard/src/mixins/operate.js b/dashboard/src/mixins/operate.js new file mode 100644 index 00000000..34653d6c --- /dev/null +++ b/dashboard/src/mixins/operate.js @@ -0,0 +1,14 @@ +export default { + methods: { + async $operate(property, fn) { + if (this[property] !== true) { + this[property] = true + try { + await fn() + } finally { + this[property] = false + } + } + } + } +} diff --git a/dashboard/src/views/dashboard/components/refresh-thumbs.vue b/dashboard/src/views/dashboard/components/refresh-thumbs.vue new file mode 100644 index 00000000..f83f5855 --- /dev/null +++ b/dashboard/src/views/dashboard/components/refresh-thumbs.vue @@ -0,0 +1,256 @@ + + + + + diff --git a/dashboard/src/views/dashboard/index.vue b/dashboard/src/views/dashboard/index.vue index 70d58b2f..a3fbf2b9 100755 --- a/dashboard/src/views/dashboard/index.vue +++ b/dashboard/src/views/dashboard/index.vue @@ -1,64 +1,179 @@ diff --git a/dashboard/src/views/gallery/index.vue b/dashboard/src/views/gallery/index.vue index a2b1f5c3..31b7469e 100644 --- a/dashboard/src/views/gallery/index.vue +++ b/dashboard/src/views/gallery/index.vue @@ -1,7 +1,7 @@