From 49bf7cd278c216974ab66ae7893be494ad41546b Mon Sep 17 00:00:00 2001 From: daief <1437931235@qq.com> Date: Thu, 10 Dec 2020 13:47:41 +0800 Subject: [PATCH] wip: simple ui --- README.md | 12 ++-- config/index.ts | 4 +- config/less-variables.ts | 35 ++++++++++ package.json | 5 ++ src/@types/vue-extend.d.ts | 0 src/Setting/Panel.vue | 57 ---------------- src/Setting/Root.vue | 136 +++++++++++++++++++++++++++++++++++++ src/Setting/index.ts | 9 +-- src/common/index.ts | 6 ++ src/common/utils.ts | 16 +++++ src/compts/Button.vue | 98 ++++++++++++++++++++++++++ src/data/index.ts | 22 +++++- src/global.less | 15 +++- src/hooks/index.ts | 0 src/index.ts | 7 +- yarn.lock | 74 ++++++++++++++++++-- 16 files changed, 418 insertions(+), 78 deletions(-) create mode 100644 config/less-variables.ts create mode 100644 src/@types/vue-extend.d.ts delete mode 100644 src/Setting/Panel.vue create mode 100644 src/Setting/Root.vue create mode 100644 src/compts/Button.vue create mode 100644 src/hooks/index.ts diff --git a/README.md b/README.md index d8fce0c..104e78a 100644 --- a/README.md +++ b/README.md @@ -11,18 +11,13 @@ // @grant GM_log // @grant GM_xmlhttpRequest // @connect 127.0.0.1 +// @match *://localhost*/* // ==/UserScript== -const code = GM_getValue('code'); -if (code) { - eval(code); -} - const loop = () => { GM_xmlhttpRequest({ url: 'http://127.0.0.1:7777/index.js', onload: e => { - console.log('check'); const res = e.responseText; if (e.status === 200 && code !== res) { GM_setValue('code', res); @@ -33,4 +28,9 @@ const loop = () => { }; setInterval(loop, 3000); + +const code = GM_getValue('code'); +if (code) { + eval(code); +} ``` diff --git a/config/index.ts b/config/index.ts index 7ceba9f..903eacb 100644 --- a/config/index.ts +++ b/config/index.ts @@ -4,6 +4,7 @@ import { VueLoaderPlugin } from 'vue-loader'; import TerserPlugin from 'terser-webpack-plugin'; import { GMPlugin } from './GMPlugin'; import pkg from '../package.json'; +import globalVars from './less-variables'; const nodeEnv: Configuration['mode'] = process.env.NODE_ENV as any; @@ -27,7 +28,6 @@ const config: Configuration = { }, { test: /\.less$/, - exclude: /\.lazy\.less$/i, use: [ { loader: 'style-loader', @@ -40,6 +40,8 @@ const config: Configuration = { options: { lessOptions: { strictMath: true, + javascriptEnabled: true, + globalVars: globalVars, }, }, }, diff --git a/config/less-variables.ts b/config/less-variables.ts new file mode 100644 index 0000000..ee8615d --- /dev/null +++ b/config/less-variables.ts @@ -0,0 +1,35 @@ +import { generate, gold, red } from '@ant-design/colors'; +import Color from 'color'; + +const primary = '#f6438a'; +const grey = '#bfbfbf'; + +// https://ant.design/docs/spec/colors-cn +// color1, color2, color3, color4, color5, color7, color8, color9, color10 +const generateColors = (mainColor: string, name: string) => + generate(mainColor).reduce>((result, curr, i) => { + i = i + 1; + if (i !== 6) { + result[`${name}${i}`] = curr; + } + return result; + }, {}); + +// https://github.com/ant-design/ant-design/blob/5ab2783ff0/components/style/themes/default.less +export default { + prefix: 'gm-rp', + ...generateColors(primary, 'color'), + primary, + ...generateColors(grey, 'grey'), + grey, + textColor: Color('#000').alpha(0.65).string(), + textColorSecondary: Color('#000').alpha(0.45).string(), + textColorWarning: gold[6], + textColorDanger: red[6], + textColorInverse: '#fff', + fontSize: '14px', + fontSizeLg: '16px', + fontSizeSm: '12px', + baseFamily: + "Penrose, 'PingFang SC', 'Hiragino Sans GB', Tahoma, Arial, 'Lantinghei SC', 'Microsoft YaHei', '\\5FAE软雅黑', sans-serif", +}; diff --git a/package.json b/package.json index af584b8..d39d676 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "build": "cross-env NODE_ENV=production yarn runpack" }, "devDependencies": { + "@types/lodash": "^4.14.165", "@types/node": "^14.14.10", "@types/webpack": "^4.41.25", "@vue/compiler-sfc": "^3.0.3", @@ -35,6 +36,10 @@ "webpack-cli": "^4.2.0" }, "dependencies": { + "@ant-design/colors": "^5.0.0", + "@types/color": "^3.0.1", + "color": "^3.1.3", + "lodash": "^4.17.20", "vue": "3.0.3", "vuex": "^4.0.0-rc.2" } diff --git a/src/@types/vue-extend.d.ts b/src/@types/vue-extend.d.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/Setting/Panel.vue b/src/Setting/Panel.vue deleted file mode 100644 index 08e33cb..0000000 --- a/src/Setting/Panel.vue +++ /dev/null @@ -1,57 +0,0 @@ - - - - - diff --git a/src/Setting/Root.vue b/src/Setting/Root.vue new file mode 100644 index 0000000..c3262f8 --- /dev/null +++ b/src/Setting/Root.vue @@ -0,0 +1,136 @@ +