Skip to content

Commit

Permalink
feat: 增加安装引导页面 修改popup 的文件路径 增加全局css
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondYuan committed Oct 16, 2018
1 parent 0931838 commit b1e9e98
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 8 deletions.
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = {
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.tsx?$': 'ts-jest'
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
testPathIgnorePatterns: ['/lib/', '/node_modules/'],
testPathIgnorePatterns: ['/lib/', '/node_modules/', '/src/services/common/store/test.ts'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
collectCoverage: true,
testEnvironment: 'node',
verbose: true,
verbose: true
};
9 changes: 9 additions & 0 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ testStorageInChrome().then((_) => {
}).catch((err: Error) => {
console.log(err.message);
});

chrome.runtime.onInstalled.addListener(function (details) {
if (details.reason === 'install') {
console.log('安装成功');
chrome.windows.create({ url: chrome.extension.getURL('initialize.html'), type: 'normal' });
} else if (details.reason === 'update') {
console.log('更新成功');
}
});
File renamed without changes.
15 changes: 15 additions & 0 deletions src/html/initialize.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8" />

<head>
<title>语雀剪藏向导</title>
<script src="js/initialize.js"></script>
<script src="js/vendor.js"></script>
</head>

<body>
<div id="initializeWindow"></div>
</body>

</html>
31 changes: 31 additions & 0 deletions src/pages/initialize/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Layout, Steps } from 'antd';
const { Header, Content, Footer } = Layout;
import './style/index.scss';

const Step = Steps.Step;

chrome.tabs.query({ active: true, currentWindow: true }, async () => {
ReactDOM.render(
<Layout>
<Header className="Header">
<p>语雀 剪藏 保存精彩网页</p>
</Header>
<Content className="content">
<div className="initializeForm" >
<Steps>
<Step title="第一步" />
<Step title="第二步" />
<Step title="第三步" />
</Steps>
</div>
</Content>
<Footer style={{ textAlign: 'center' }}>
语雀 剪藏 ©2018 Created by <a href="https://github.com/DiamondYuan">DiamondYuan</a>
</Footer>
</Layout >,
document.getElementById('initializeWindow')
);
});

18 changes: 18 additions & 0 deletions src/pages/initialize/style/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@import '../../../styles/global.scss';

body {
width: 100%;
height: 100%;
}
.Header{
background: white;
text-align: center;
}
.initializeForm{
background: #ffffff;
padding: 24px;
min-height: 500px;
min-width: 500px;
margin: 100px;
padding: 20px;
}
4 changes: 2 additions & 2 deletions src/popup/index.tsx → src/pages/popup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import './popup.scss';

import { testStorageInChrome } from '../services/common/store/test';
import './style/index.scss';
import { testStorageInChrome } from '../../services/common/store/test';

testStorageInChrome().then((_) => {
console.log('storage is ok in content');
Expand Down
4 changes: 3 additions & 1 deletion src/popup/popup.scss → src/pages/popup/style/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import '~antd/dist/antd.css';
@import '../../../styles/global.scss';

body {
width: 600px;
height: 300px;
Expand All @@ -7,5 +8,6 @@ body {
.popup {
width: 100%;
height: 100%;
background: $color-brand;
padding: 10px;
}
5 changes: 5 additions & 0 deletions src/styles/global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import '~antd/dist/antd.css';

$color-brand:#34CC6B;

$color-background:#F9F9F9;
5 changes: 3 additions & 2 deletions webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const CleanWebpackPlugin = require('clean-webpack-plugin');

module.exports = {
entry: {
popup: path.join(__dirname, '../src/popup/index.tsx'),
popup: path.join(__dirname, '../src/pages/popup/index.tsx'),
initialize: path.join(__dirname, '../src/pages/initialize/index.tsx'),
background: path.join(__dirname, '../src/background/index.ts'),
content_script: path.join(__dirname, '../src/content/index.tsx')
},
Expand Down Expand Up @@ -57,7 +58,7 @@ module.exports = {
ignore: ['.*']
},
{
from: path.resolve(__dirname, '../index.html'),
from: path.resolve(__dirname, '../src/html/'),
to: path.resolve(__dirname, '../dist'),
ignore: ['.*']
}
Expand Down

0 comments on commit b1e9e98

Please sign in to comment.