Commit 5f783bc0 authored by Allen Bai's avatar Allen Bai

feat: 完成初步的内容

parent 7f077c9b
...@@ -10,11 +10,7 @@ ...@@ -10,11 +10,7 @@
"watch": "rollup -c -w", "watch": "rollup -c -w",
"build": "npm run clean && cross-env NODE_ENV=prod && rollup -c", "build": "npm run clean && cross-env NODE_ENV=prod && rollup -c",
"build:debug": "npm run clean && cross-env NODE_ENV=dev rollup -c", "build:debug": "npm run clean && cross-env NODE_ENV=dev rollup -c",
"clean": "rm -rf ./dist", "clean": "rm -rf ./dist"
"pub": "node ./build.js",
"deploy": "npm run build && npm publish --access public && npm run pub",
"lint": "prettier --write src",
"release": "standard-version"
}, },
"typescript": ">=4.0", "typescript": ">=4.0",
"files": [ "files": [
...@@ -34,7 +30,7 @@ ...@@ -34,7 +30,7 @@
"@typescript-eslint/parser": "^4.9.0", "@typescript-eslint/parser": "^4.9.0",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"chalk": "^4.1.0", "chalk": "^4.1.0",
"cross-env": "^7.0.2", "cross-env": "^7.0.3",
"eslint": "^7.15.0", "eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0", "eslint-config-prettier": "^7.0.0",
"eslint-plugin-prettier": "^3.2.0", "eslint-plugin-prettier": "^3.2.0",
......
...@@ -3,23 +3,23 @@ ...@@ -3,23 +3,23 @@
import typescript from 'rollup-plugin-typescript2' // 处理typescript import typescript from 'rollup-plugin-typescript2' // 处理typescript
import babel from 'rollup-plugin-babel' import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs' import commonjs from 'rollup-plugin-commonjs'
import {nodeResolve} from '@rollup/plugin-node-resolve' import { nodeResolve } from '@rollup/plugin-node-resolve'
import {terser} from 'rollup-plugin-terser' import { terser } from 'rollup-plugin-terser'
import {DEFAULT_EXTENSIONS} from '@babel/core' import { DEFAULT_EXTENSIONS } from '@babel/core'
const isDev = process.env.NODE_ENV === 'dev' const isDev = process.env.NODE_ENV === 'dev'
export default { export default {
input: './src/index.ts', // 入口文件 input: './src/index.ts', // 入口文件
output: [ output: [
{ {
file: `dist/logHub.main.js`, // 打包之后的文件名以及存放位置 file: `dist/IPCHelper.main.js`, // 打包之后的文件名以及存放位置
format: 'umd', // 以什么模式打包,支持umd,cmd,esm... format: 'umd', // 以什么模式打包,支持umd,cmd,esm...
name: 'logHub' name: '__TUIA_IPC_HELPER__'
}, },
{ {
file: `dist/logHub.module.js`, // 打包之后的文件名以及存放位置 file: `dist/IPCHelper.module.js`, // 打包之后的文件名以及存放位置
format: 'es', // 以什么模式打包,支持umd,cmd,esm... format: 'es', // 以什么模式打包,支持umd,cmd,esm...
name: 'logHub' name: '__TUIA_IPC_HELPER__'
} }
], ],
plugins: [ plugins: [
......
/** @format */ /** @format */
type Optional<T> = { [P in keyof T]?: T[P] }
function request() { function getIPCByDomain(domain: string) {
return new Promise((resolve, reject) => {}) return new Promise((resolve, reject) => {
resolve('1231232123')
})
} }
export function getIPCByDomain(domain: string) {} type IPCFooterOptions = {
domain?: string
dom?: HTMLElement
footerStyles?: Optional<CSSStyleDeclaration>
boardStyles?: Optional<CSSStyleDeclaration>
}
export function getIPC() {} function addStyles(ele: HTMLElement, styles: Optional<CSSStyleDeclaration> = {}) {
Object.entries(styles).forEach(([key, val]) => {
ele.style[key] = val
})
}
export function mountIPCFooter(dom, domain: string, opts) {} const defaultFooterStyles: Optional<CSSStyleDeclaration> = {
width: '100vw',
position: 'absolute',
left: '0',
right: '0',
bottom: '0'
}
const defaultBoardStyles: Optional<CSSStyleDeclaration> = {
display: 'inline-block',
textDecoration: 'none',
color: '#FFF',
backgroundColor: 'rgba(0,0,0,.4)',
margin: '8px auto',
height: '28px',
lineHeight: '28px',
padding: '0 10px',
borderRadius: '4px'
}
const __TUIA__IPC_HELPER__ = { async function mountIPCFooter(opts: IPCFooterOptions) {
getIPCByDomain, const icpNumber = await getIPCByDomain(opts.domain || location.host)
getIPC, const IPCFooter = document.createElement('div')
mountIPCFooter const IPCBoard = document.createElement('a')
const targetDom = opts.dom || document.querySelector('body')
IPCFooter.id = '__IPC_footer__'
IPCBoard.id = '__IPC_board__'
addStyles(IPCFooter, { ...defaultFooterStyles, ...(opts.footerStyles || {}) })
addStyles(IPCBoard, { ...defaultBoardStyles, ...(opts.footerStyles || {}) })
IPCBoard.innerText = `浙ICP备${icpNumber}号`
IPCFooter.appendChild(IPCBoard)
targetDom.appendChild(IPCFooter)
} }
export default __TUIA__IPC_HELPER__ export default { getIPCByDomain, mountIPCFooter }
...@@ -1886,10 +1886,10 @@ cosmiconfig@^7.0.0: ...@@ -1886,10 +1886,10 @@ cosmiconfig@^7.0.0:
path-type "^4.0.0" path-type "^4.0.0"
yaml "^1.10.0" yaml "^1.10.0"
cross-env@^7.0.2: cross-env@^7.0.3:
version "7.0.2" version "7.0.3"
resolved "http://npm.dui88.com:80/cross-env/-/cross-env-7.0.2.tgz#bd5ed31339a93a3418ac4f3ca9ca3403082ae5f9" resolved "https://registry.npm.taobao.org/cross-env/download/cross-env-7.0.3.tgz?cache=0&sync_timestamp=1606854449763&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcross-env%2Fdownload%2Fcross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
integrity sha1-vV7TEzmpOjQYrE88qco0Awgq5fk= integrity sha1-hlJkspZ33AFbqEGJGJZd0jL8VM8=
dependencies: dependencies:
cross-spawn "^7.0.1" cross-spawn "^7.0.1"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment