Skip to content

Commit

Permalink
dev init
Browse files Browse the repository at this point in the history
  • Loading branch information
kinglisky committed Nov 28, 2017
1 parent 6c094d0 commit f91105d
Show file tree
Hide file tree
Showing 28 changed files with 349 additions and 177 deletions.
73 changes: 17 additions & 56 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,59 +1,20 @@
# Logs
logs
*.log
.DS_Store
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

lerna-debug.log*
test/unit/coverage
test/e2e/reports
selenium-debug.log

ext-dev/
!ext-dev/manifest.json
!ext-dev/hot-reload.js

# Editor directories and files
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
6 changes: 4 additions & 2 deletions extension/popup.html → dev/content.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>斗图插件</title>
</head>

<body>
<div id="app"></div>
<script type="text/javascript" src="popup.js"></script></body>
<script src="content.js"></script>
</body>

</html>
</html>
7 changes: 7 additions & 0 deletions dev/content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Vue from 'vue'
import Content from './content.vue'

new Vue({
el: '#app',
render: h => h(Content)
})
53 changes: 53 additions & 0 deletions dev/content.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>
<section class="dev-page">
<app></app>
</section>
</template>

<script>
import App from '../src/content/app.vue'
export default {
components: {
App
}
}
</script>

<style lang="scss">
* {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
width: 100%;
}
#app {
width: 100%;
height: 100%;
overflow: hidden;
}
.dev-page {
height: 100%;
width: 100%;
padding: 40px;
.code-input {
width: 600px;
height: 400px;
border: 1px solid #eee;
border-radius: 4px;
padding: 10px;
&:focus {
outline: none;
}
}
}
</style>


Empty file added dev/popup.html
Empty file.
2 changes: 0 additions & 2 deletions extension/background.js

This file was deleted.

1 change: 0 additions & 1 deletion extension/background.js.map

This file was deleted.

2 changes: 0 additions & 2 deletions extension/content.js

This file was deleted.

1 change: 0 additions & 1 deletion extension/content.js.map

This file was deleted.

22 changes: 22 additions & 0 deletions extension/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"manifest_version": 2,
"name": "AIDUO",
"version": "1.0",
"description": "斗图插件",
"background": {
"scripts": [
"vendor.js",
"background.js"
],
"persistent": true
},
"permissions": [
"*://*/",
"storage",
"contextMenus"
],
"content_scripts": [{
"matches": ["*://github.com/*"],
"js": ["vendor.js", "content.js"]
}]
}
7 changes: 0 additions & 7 deletions extension/popup.js

This file was deleted.

1 change: 0 additions & 1 deletion extension/popup.js.map

This file was deleted.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "chrome plugin",
"main": "index.js",
"scripts": {
"dev:popup": "webpack-dev-server --hot --config webpack.dev.config.js",
"dev": "webpack -w --config webpack.base.config.js",
"page": "webpack-dev-server --hot --config webpack.dev.config.js",
"build": "webpack --config webpack.prod.config.js"
},
"repository": {
Expand All @@ -22,6 +23,7 @@
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-3": "^6.24.1",
"copy-webpack-plugin": "^4.2.3",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
Expand Down
8 changes: 4 additions & 4 deletions src/background/config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// 表情包的搜索接口
const API = 'https://pic.sogou.com/pics/json.jsp'
export const API = 'https://pic.sogou.com/pics/json.jsp'

// 默认参数
const DEFAULT_PARAMS = {
query: '',
export const DEFAULT_PARAMS = {
query: 'bug 表情',
st: 5,
start: 0,
xml_len: 100
}

export default {
API, DEFAULT_PARAMS
}
}
37 changes: 35 additions & 2 deletions src/background/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
import config from './config'
import axios from 'axios'
import { API, DEFAULT_PARAMS } from './config'
import {
serialize,
fetchImgToBase64
// dataURItoBlob
} from './util'

console.log(config)
const queryURL = `${API}?${serialize(DEFAULT_PARAMS)}`

chrome.runtime.onMessage.addListener(function (evt, sender, sendResponse) {
const { type } = evt
if (type === 'fetchImg') {
axios.get(queryURL).then(({ data }) => {
const imgRes = data.items.map(it => {
return fetchImgToBase64(it.locImageLink).then(base64 => {
return {
base64,
link: it.locImageLink
}
})
})
Promise.all(imgRes).then(res => {
console.log(res[0], res.length)
sendResponse(res[0])
})
})
}
return true
})

// const data = new window.FormData()
// data.append('smfile', dataURItoBlob(base64, 'temp.png'))
// axios.post('https://sm.ms/api/upload', data).then(res => {
// console.log(res)
// })
1 change: 1 addition & 0 deletions src/background/picBed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function upSmPicBed () {}
Loading

0 comments on commit f91105d

Please sign in to comment.