瀏覽代碼

chore: upgrade deps

Gerald 6 年之前
父節點
當前提交
6872154bf9

+ 4 - 2
.eslintrc.js

@@ -1,5 +1,8 @@
 module.exports = {
-  parser: 'babel-eslint',
+  root: true,
+  parserOptions: {
+    parser: 'babel-eslint',
+  },
   extends: [
     'airbnb-base',
     require.resolve('./scripts/eslint/vue'),
@@ -7,7 +10,6 @@ module.exports = {
   env: {
     browser: true,
   },
-  plugins: [],
   settings: {
     'import/resolver': {
       'babel-module': {},

+ 1 - 2
package.json

@@ -41,8 +41,8 @@
     "eslint-config-airbnb-base": "^13.1.0",
     "eslint-import-resolver-babel-module": "^5.0.0-beta.1",
     "eslint-import-resolver-webpack": "^0.10.1",
-    "eslint-plugin-html": "^4.0.6",
     "eslint-plugin-import": "^2.14.0",
+    "eslint-plugin-vue": "^5.0.0-beta.5",
     "fancy-log": "^1.3.2",
     "gulp": "^4.0.0",
     "gulp-filter": "^5.0.1",
@@ -68,7 +68,6 @@
     "vue-template-compiler": "^2.5.17",
     "webpack": "^4.20.2",
     "webpack-bundle-analyzer": "^3.0.2",
-    "webpack-bundle-size-analyzer": "^2.7.0",
     "wrapper-webpack-plugin": "2.0.0"
   },
   "author": "Gerald <[email protected]>",

+ 2 - 8
scripts/eslint/vue.js

@@ -1,11 +1,5 @@
 module.exports = {
-  plugins: [
-    'html',
+  extends: [
+    'plugin:vue/essential',
   ],
-  rules: {
-    'import/extensions': ['error', 'always', {
-      js: 'never',
-      vue: 'never',
-    }],
-  },
 };

+ 0 - 3
scripts/template.html

@@ -10,9 +10,6 @@ if (htmlWebpackPlugin.options.manifest) {
 htmlWebpackPlugin.options.css.forEach(url => {
 %><link rel="stylesheet" href="<%= url %>"><%
 });
-htmlWebpackPlugin.options.inlineSource && htmlWebpackPlugin.files.css.forEach(file => {
-%><style><%= compilation.assets[file.slice(htmlWebpackPlugin.files.publicPath.length)].source() %></style><%
-});
 htmlWebpackPlugin.options.js.forEach(url => {
 %><script src="<%= url %>"></script><%
 });

+ 0 - 1
scripts/webpack.conf.js

@@ -72,7 +72,6 @@ const htmlPlugins = Object.entries(pages)
     }
   }
   if (options) {
-    if (options.inlineSource) options.inject = false;
     return new HtmlWebpackPlugin(options);
   }
 })

+ 4 - 5
scripts/webpack/common.js

@@ -1,4 +1,4 @@
-const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
+const TerserPlugin = require('terser-webpack-plugin');
 const MiniCssExtractPlugin = require('mini-css-extract-plugin');
 const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
 const { isProd, styleRule, resolve, DIST } = require('../util');
@@ -57,15 +57,14 @@ module.exports = options => config => {
   config.optimization = {
     ...config.optimization,
   };
-  config.optimization.minimizer = [
-    ...config.optimization.minimizer || [],
-    isProd && new UglifyJsPlugin({
+  config.optimization.minimizer = (config.optimization.minimizer || [
+    isProd && new TerserPlugin({
       cache: true,
       parallel: true,
       sourceMap: true // set to true if you want JS source maps
     }),
     isProd && new OptimizeCSSAssetsPlugin(),
-  ].filter(Boolean);
+  ]).filter(Boolean);
   config.plugins = [
     ...config.plugins || [],
     isProd && new MiniCssExtractPlugin(),

+ 8 - 2
src/common/ui/code.vue

@@ -165,8 +165,14 @@ export default {
       type: Boolean,
       default: false,
     },
-    value: true,
-    commands: true,
+    value: {
+      type: String,
+      default: '',
+    },
+    commands: {
+      type: Object,
+      default: null,
+    },
     global: {
       type: Boolean,
       default: true,

+ 3 - 1
src/confirm/views/app.vue

@@ -2,7 +2,9 @@
   <div class="page-confirm frame flex flex-col h-100">
     <div class="frame-block">
       <div class="flex">
-        <h1 class="hidden-sm"><span v-text="i18n('labelInstall')"></span> - <span v-text="i18n('extName')"></span></h1>
+        <h1 class="hidden-sm">
+          <span v-text="i18n('labelInstall')"></span> - <span v-text="i18n('extName')"></span>
+        </h1>
         <div class="flex-auto"></div>
         <div>
           <dropdown class="confirm-options" align="right">

+ 15 - 3
src/options/views/app.vue

@@ -5,9 +5,21 @@
         <img src="/public/images/icon128.png">
         <h1 v-text="i18n('extName')"></h1>
         <div class="aside-menu">
-          <a href="#scripts" :class="{active: tab === 'scripts'}" v-text="i18n('sideMenuInstalled')"></a>
-          <a href="#settings" :class="{active: tab === 'settings'}" v-text="i18n('sideMenuSettings')"></a>
-          <a href="#about" :class="{active: tab === 'about'}" v-text="i18n('sideMenuAbout')"></a>
+          <a
+            href="#scripts"
+            :class="{active: tab === 'scripts'}"
+            v-text="i18n('sideMenuInstalled')"
+          />
+          <a
+            href="#settings"
+            :class="{active: tab === 'settings'}"
+            v-text="i18n('sideMenuSettings')"
+          />
+          <a
+            href="#about"
+            :class="{active: tab === 'about'}"
+            v-text="i18n('sideMenuAbout')"
+          />
         </div>
         <div class="aside-toggle visible-sm" @click="aside = !aside">
           <icon name="arrow" />

+ 18 - 3
src/options/views/edit/index.vue

@@ -18,9 +18,24 @@
       </div>
     </div>
     <div class="edit-nav mx-1">
-      <div class="edit-nav-item" v-text="i18n('editNavCode')" :class="{active: nav === 'code'}" @click="nav = 'code'"></div>
-      <div class="edit-nav-item" v-text="i18n('editNavSettings')" :class="{active: nav === 'settings'}" @click="nav = 'settings'"></div>
-      <div class="edit-nav-item" v-text="i18n('editNavValues')" :class="{active: nav === 'values'}" @click="nav = 'values'"></div>
+      <div
+        class="edit-nav-item"
+        :class="{active: nav === 'code'}"
+        v-text="i18n('editNavCode')"
+        @click="nav = 'code'"
+      />
+      <div
+        class="edit-nav-item"
+        :class="{active: nav === 'settings'}"
+        v-text="i18n('editNavSettings')"
+        @click="nav = 'settings'"
+      />
+      <div
+        class="edit-nav-item"
+        :class="{active: nav === 'values'}"
+        v-text="i18n('editNavValues')"
+        @click="nav = 'values'"
+      />
     </div>
     <div class="frame-block flex-auto pos-rel">
       <vm-code

+ 19 - 12
src/options/views/edit/values.vue

@@ -3,16 +3,20 @@
     <div class="mb-1">
       <button @click="onNew">+</button>
       <div class="inline-block ml-2" v-if="totalPages > 1">
-        <button :disabled="!hasPrevious" @click="page -= 1">&larr;</button>
+        <button :disabled="!hasPrevious" @click="setPage(currentPage.page - 1)">&larr;</button>
         <span class="mx-1" v-text="page"></span>
-        <button :disabled="!hasNext" @click="page += 1">&rarr;</button>
+        <button :disabled="!hasNext" @click="setPage(currentPage.page + 1)">&rarr;</button>
       </div>
     </div>
     <div class="edit-values-table" v-if="keys">
       <div class="edit-values-empty" v-if="!keys.length">
         <div v-text="i18n('noValues')"></div>
       </div>
-      <div class="edit-values-row flex" v-for="key in currentPage" @click="onEdit(key)">
+      <div
+        v-for="key in currentPage.data"
+        :key="key"
+        class="edit-values-row flex"
+        @click="onEdit(key)">
         <div class="ellipsis">
           <span v-text="key"></span>
           <div class="edit-values-btn">
@@ -54,7 +58,7 @@ export default {
   },
   data() {
     return {
-      page: 1,
+      currentPage: null,
       current: null,
       keys: null,
       values: null,
@@ -65,17 +69,11 @@ export default {
       if (!this.keys) return 0;
       return Math.floor(this.keys.length / PAGE_SIZE) + 1;
     },
-    currentPage() {
-      if (!this.keys) return null;
-      this.page = Math.max(1, Math.min(this.page, this.totalPages));
-      const offset = PAGE_SIZE * (this.page - 1);
-      return this.keys.slice(offset, offset + PAGE_SIZE);
-    },
     hasPrevious() {
-      return this.page > 1;
+      return this.currentPage.page > 1;
     },
     hasNext() {
-      return this.page < this.totalPages;
+      return this.currentPage.page < this.totalPages;
     },
   },
   watch: {
@@ -84,6 +82,14 @@ export default {
     },
   },
   methods: {
+    setPage(expected) {
+      const page = Math.max(1, Math.min(expected, this.totalPages));
+      const offset = PAGE_SIZE * (page - 1);
+      this.currentPage = {
+        page,
+        data: this.keys ? this.keys.slice(offset, offset + PAGE_SIZE) : null,
+      };
+    },
     getValue(key, sliced) {
       let value = this.values[key];
       const type = value[0];
@@ -99,6 +105,7 @@ export default {
       .then(values => {
         this.values = values;
         this.keys = Object.keys(values).sort();
+        this.setPage(1);
       });
     },
     updateValue({ key, value, isNew }) {

+ 8 - 3
src/options/views/message.vue

@@ -4,9 +4,14 @@
     <form v-if="message.buttons" @submit.prevent>
       <input class="mb-1" type="text" v-if="message.input !== false" v-model="message.input">
       <div>
-        <button v-for="button in message.buttons" class="mr-1"
-          :type="button.type || 'button'" v-text="button.text"
-          @click="onButtonClick(button)"></button>
+        <button
+          v-for="(button, index) in message.buttons"
+          :key="index"
+          class="mr-1"
+          :type="button.type || 'button'"
+          v-text="button.text"
+          @click="onButtonClick(button)"
+        />
       </div>
     </form>
   </div>

+ 29 - 6
src/options/views/script-item.vue

@@ -1,11 +1,24 @@
 <template>
-  <div class="script" :class="{ disabled: !script.config.enabled, removed: script.config.removed }" :draggable="draggable" @dragstart.prevent="onDragStart">
+  <div
+    class="script"
+    :class="{ disabled: !script.config.enabled, removed: script.config.removed }"
+    :draggable="draggable"
+    @dragstart.prevent="onDragStart">
     <img class="script-icon hidden-xs" :src="safeIcon">
     <div class="script-info flex">
       <div class="script-name ellipsis flex-auto" v-text="script.$cache.name"></div>
-      <tooltip :title="i18n('labelAuthor') + script.meta.author" class="script-author ml-1 hidden-sm" v-if="author" align="end">
+      <tooltip
+        v-if="author"
+        :title="i18n('labelAuthor') + script.meta.author"
+        class="script-author ml-1 hidden-sm"
+        align="end">
         <icon name="author"></icon>
-        <a class="ellipsis ml-1" :href="`mailto:${author.email}`" v-if="author.email" v-text="author.name"></a>
+        <a
+          v-if="author.email"
+          class="ellipsis ml-1"
+          :href="`mailto:${author.email}`"
+          v-text="author.name"
+        />
         <span class="ellipsis ml-1" v-else v-text="author.name"></span>
       </tooltip>
       <tooltip class="ml-1 hidden-sm" :title="lastUpdated.title" align="end">
@@ -33,7 +46,10 @@
             <icon :name="`toggle-${script.config.enabled ? 'on' : 'off'}`"></icon>
           </span>
         </tooltip>
-        <tooltip :disabled="!canUpdate || script.checking" :title="i18n('buttonUpdate')" align="start">
+        <tooltip
+          :disabled="!canUpdate || script.checking"
+          :title="i18n('buttonUpdate')"
+          align="start">
           <span class="btn-ghost" @click="onUpdate">
             <icon name="refresh"></icon>
           </span>
@@ -49,8 +65,15 @@
             <icon name="info"></icon>
           </span>
         </tooltip>
-        <tooltip :disabled="!script.meta.supportURL" :title="i18n('buttonSupport')" align="start">
-          <a class="btn-ghost" target="_blank" rel="noopener noreferrer" :href="script.meta.supportURL">
+        <tooltip
+          :disabled="!script.meta.supportURL"
+          :title="i18n('buttonSupport')"
+          align="start">
+          <a
+            class="btn-ghost"
+            target="_blank"
+            rel="noopener noreferrer"
+            :href="script.meta.supportURL">
             <icon name="question"></icon>
           </a>
         </tooltip>

+ 16 - 3
src/options/views/tab-installed.vue

@@ -2,16 +2,27 @@
   <div class="tab-installed">
     <header class="flex">
       <div class="flex-auto">
-        <dropdown :closeAfterClick="true" :class="{active: menuNewActive}" @stateChange="onStateChange">
+        <dropdown
+          :closeAfterClick="true"
+          :class="{active: menuNewActive}"
+          @stateChange="onStateChange">
           <tooltip :title="i18n('buttonNew')" placement="down" align="start" slot="toggle">
             <span class="btn-ghost">
               <icon name="plus"></icon>
             </span>
           </tooltip>
-          <div class="dropdown-menu-item" v-text="i18n('buttonNew')" @click.prevent="onEditScript('_new')"></div>
+          <div
+            class="dropdown-menu-item"
+            v-text="i18n('buttonNew')"
+            @click.prevent="onEditScript('_new')"
+          />
           <a class="dropdown-menu-item" v-text="i18n('installFrom', 'OpenUserJS')" href="https://openuserjs.org/" target="_blank" rel="noopener noreferrer"></a>
           <a class="dropdown-menu-item" v-text="i18n('installFrom', 'GreasyFork')" href="https://greasyfork.org/scripts" target="_blank" rel="noopener noreferrer"></a>
-          <div class="dropdown-menu-item" v-text="i18n('buttonInstallFromURL')" @click.prevent="installFromURL"></div>
+          <div
+            class="dropdown-menu-item"
+            v-text="i18n('buttonInstallFromURL')"
+            @click.prevent="installFromURL"
+          />
         </dropdown>
         <tooltip :title="i18n('buttonUpdateAll')" placement="down" align="start">
           <span class="btn-ghost" @click="updateAll">
@@ -30,6 +41,7 @@
             <select :value="filters.sort.value" @change="onOrderChange">
               <option
                 v-for="option in filterOptions.sort"
+                :key="option.value"
                 v-text="option.title"
                 :value="option.value">
               </option>
@@ -147,6 +159,7 @@ export default {
       if (!objectGet(this.store, 'filteredScripts.length')) {
         return i18n('labelNoSearchScripts');
       }
+      return null;
     },
   },
   methods: {

+ 11 - 4
src/options/views/tab-settings/vm-export.vue

@@ -2,11 +2,14 @@
   <section>
     <h3 v-text="i18n('labelDataExport')"></h3>
     <div class="export-list">
-      <div class="ellipsis" v-for="item in items"
+      <div
+        v-for="(item, index) in items"
+        :key="index"
+        class="ellipsis"
         :class="{active: item.active}"
         @click="item.active = !item.active"
-        v-text="getName(item)">
-      </div>
+        v-text="getName(item)"
+      />
     </div>
     <button v-text="i18n('buttonAllNone')" @click="toggleSelection()"></button>
     <button v-text="i18n('buttonExportData')" @click="exportData" :disabled="exporting"></button>
@@ -14,7 +17,11 @@
       <setting-check name="exportValues" />
       <span v-text="i18n('labelExportScriptData')"></span>
     </label>
-    <modal v-if="store.ffDownload" transition="in-out" :visible="!!store.ffDownload.url" @close="store.ffDownload = {}">
+    <modal
+      v-if="store.ffDownload"
+      transition="in-out"
+      :visible="!!store.ffDownload.url"
+      @close="store.ffDownload = {}">
       <div class="export-modal modal-content">
         <a :download="store.ffDownload.name" :href="store.ffDownload.url">
           Right click and save as<br />

+ 8 - 3
src/options/views/tab-settings/vm-import.vue

@@ -1,8 +1,13 @@
 <template>
   <section>
-    <h3 v-text="i18n('labelDataImport')"></h3>
-    <button v-text="i18n('buttonImportData')" @click="importFile"></button>
-    <button :title="i18n('hintVacuum')" @click="vacuum" :disabled="vacuuming" v-text="labelVacuum"></button>
+    <h3 v-text="i18n('labelDataImport')" />
+    <button v-text="i18n('buttonImportData')" @click="importFile" />
+    <button
+      :title="i18n('hintVacuum')"
+      @click="vacuum"
+      :disabled="vacuuming"
+      v-text="labelVacuum"
+    />
     <div class="mt-1">
       <label>
         <setting-check name="importSettings" />

+ 9 - 1
src/options/views/tab-settings/vm-sync.vue

@@ -4,7 +4,12 @@
     <div v-if="state">
       <span v-text="i18n('labelSyncService')"></span>
       <select class="mx-1" :value="syncConfig.current" @change="onSyncChange">
-        <option v-for="service in syncServices" v-text="service.displayName" :value="service.name"></option>
+        <option
+          v-for="service in syncServices"
+          :key="service.name"
+          v-text="service.displayName"
+          :value="service.name"
+        />
       </select>
       <button v-text="state.label" v-if="service.name"
       :disabled="!state.canAuthorize" @click="onAuthorize"></button>
@@ -61,6 +66,7 @@ export default {
           ...states,
         ];
       }
+      return null;
     },
     service() {
       if (this.syncServices) {
@@ -72,6 +78,7 @@ export default {
         }
         return service;
       }
+      return null;
     },
     state() {
       const { service } = this;
@@ -86,6 +93,7 @@ export default {
           canSync,
         };
       }
+      return null;
     },
   },
   methods: {

+ 22 - 6
src/popup/views/app.vue

@@ -5,7 +5,10 @@
     </div>
     <div class="menu-item" :class="{disabled:!options.isApplied}" @click="onToggle">
       <icon :name="getSymbolCheck(options.isApplied)"></icon>
-      <div class="flex-1" v-text="options.isApplied ? i18n('menuScriptEnabled') : i18n('menuScriptDisabled')"></div>
+      <div
+        class="flex-1"
+        v-text="options.isApplied ? i18n('menuScriptEnabled') : i18n('menuScriptDisabled')"
+      />
     </div>
     <div class="menu">
       <div class="menu-item" @click="onManage">
@@ -25,25 +28,38 @@
         <div class="flex-1" v-text="i18n('menuFindScripts')"></div>
       </div>
     </div>
-    <div class="menu menu-commands" v-show="commands.length" :class="{expand: activeMenu === 'commands'}">
+    <div
+      class="menu menu-commands"
+      v-show="commands.length"
+      :class="{expand: activeMenu === 'commands'}">
       <div class="menu-item" @click="toggleMenu('commands')">
         <div class="flex-auto" v-text="i18n('menuCommands')"></div>
         <icon name="arrow" class="icon-collapse"></icon>
       </div>
       <div class="submenu">
-        <div class="menu-item" v-for="item in commands" @click="onCommand(item)">
+        <div
+          v-for="(item, index) in commands"
+          :key="index"
+          class="menu-item"
+          @click="onCommand(item)">
           <span v-text="item.name"></span>
         </div>
       </div>
     </div>
-    <div class="menu menu-scripts" v-show="scripts.length" :class="{expand: activeMenu === 'scripts'}">
+    <div
+      v-show="scripts.length"
+      class="menu menu-scripts"
+      :class="{expand: activeMenu === 'scripts'}">
       <div class="menu-item" @click="toggleMenu('scripts')">
         <div class="flex-auto" v-text="i18n('menuMatchedScripts')"></div>
         <icon name="arrow" class="icon-collapse"></icon>
       </div>
       <div class="submenu">
-        <div v-for="item in scripts">
-          <div class="menu-item" @click="onToggleScript(item)" :class="{disabled:!item.data.config.enabled}">
+        <div v-for="(item, index) in scripts" :key="index">
+          <div
+            class="menu-item"
+            :class="{ disabled: !item.data.config.enabled }"
+            @click="onToggleScript(item)">
             <icon :name="getSymbolCheck(item.data.config.enabled)"></icon>
             <div class="flex-auto ellipsis" v-text="item.name" :title="item.name"></div>
           </div>

文件差異過大導致無法顯示
+ 348 - 277
yarn.lock


部分文件因文件數量過多而無法顯示