mirror of
https://github.com/zhigang1992/examples.git
synced 2026-04-30 18:32:50 +08:00
Created electron example
This commit is contained in:
22
with-electron/.gitignore
vendored
Normal file
22
with-electron/.gitignore
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
node_modules/**/*
|
||||||
|
.expo/*
|
||||||
|
npm-debug.*
|
||||||
|
*.jks
|
||||||
|
*.p8
|
||||||
|
*.p12
|
||||||
|
*.key
|
||||||
|
*.mobileprovision
|
||||||
|
*.orig.*
|
||||||
|
web-build/
|
||||||
|
web-report/
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
|
/dist
|
||||||
|
# @generated: @expo/electron-adapter@0.0.0-alpha.7
|
||||||
|
/.expo/*
|
||||||
|
# Expo Web
|
||||||
|
/web-build/*
|
||||||
|
# electron-webpack
|
||||||
|
/dist
|
||||||
|
# @end @expo/electron-adapter
|
||||||
21
with-electron/App.tsx
Normal file
21
with-electron/App.tsx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { StyleSheet, Text, View } from 'react-native';
|
||||||
|
|
||||||
|
import { LinearGradient } from 'expo-linear-gradient'
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
return (
|
||||||
|
<LinearGradient colors={['red', 'orange']} style={styles.container}>
|
||||||
|
<Text>Open up App.tsx to start working on your app!</Text>
|
||||||
|
</LinearGradient>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: '#fff',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
});
|
||||||
14
with-electron/README.md
Normal file
14
with-electron/README.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Electron Example
|
||||||
|
|
||||||
|
> 🚨 Electron support is experimental, so the workflow is suboptimal and subject to breaking changes. If you find bugs please report them on [expo/expo-cli](https://github.com/expo/expo-cli/issues) with the `[electron]` tag in the title.
|
||||||
|
|
||||||
|
[Electron][electron] is a framework for creating desktop apps that run in a Chromium wrapper. Using Expo with Electron will enable you to use your existing components to build OSX, Windows, and Linux apps.
|
||||||
|
|
||||||
|
For more info [check out the latest docs!](https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/guides/using-electron.md)
|
||||||
|
|
||||||
|
### Running
|
||||||
|
|
||||||
|
1. Create a new Expo project `expo init`
|
||||||
|
2. cd into the project and run `yarn add -D @expo/electron-adapter`
|
||||||
|
3. Now run `yarn expo-electron` to bootstrap the project. You can read more about what this does in the docs: [Using Electron](https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/guides/using-electron.md).
|
||||||
|
4. Run `yarn expo-electron start` to start the project.
|
||||||
31
with-electron/app.json
Normal file
31
with-electron/app.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"name": "with-electron",
|
||||||
|
"expo": {
|
||||||
|
"name": "with-electron",
|
||||||
|
"slug": "with-electron",
|
||||||
|
"privacy": "public",
|
||||||
|
"sdkVersion": "35.0.0",
|
||||||
|
"platforms": [
|
||||||
|
"ios",
|
||||||
|
"android",
|
||||||
|
"web"
|
||||||
|
],
|
||||||
|
"version": "1.0.0",
|
||||||
|
"orientation": "portrait",
|
||||||
|
"icon": "./assets/icon.png",
|
||||||
|
"splash": {
|
||||||
|
"image": "./assets/splash.png",
|
||||||
|
"resizeMode": "contain",
|
||||||
|
"backgroundColor": "#ffffff"
|
||||||
|
},
|
||||||
|
"updates": {
|
||||||
|
"fallbackToCacheTimeout": 0
|
||||||
|
},
|
||||||
|
"assetBundlePatterns": [
|
||||||
|
"**/*"
|
||||||
|
],
|
||||||
|
"ios": {
|
||||||
|
"supportsTablet": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
with-electron/assets/icon.png
Normal file
BIN
with-electron/assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
with-electron/assets/splash.png
Normal file
BIN
with-electron/assets/splash.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
6
with-electron/babel.config.js
Normal file
6
with-electron/babel.config.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
module.exports = function(api) {
|
||||||
|
api.cache(true);
|
||||||
|
return {
|
||||||
|
presets: ['babel-preset-expo'],
|
||||||
|
};
|
||||||
|
};
|
||||||
6
with-electron/electron-webpack.js
Normal file
6
with-electron/electron-webpack.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
const { withExpoAdapter } = require('@expo/electron-adapter');
|
||||||
|
|
||||||
|
module.exports = withExpoAdapter({
|
||||||
|
projectRoot: __dirname,
|
||||||
|
// Provide any overrides for electron-webpack: https://github.com/electron-userland/electron-webpack/blob/master/docs/en/configuration.md
|
||||||
|
});
|
||||||
28
with-electron/package.json
Normal file
28
with-electron/package.json
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"customize": "yarn expo-electron customize",
|
||||||
|
"desktop": "yarn expo-electron start",
|
||||||
|
"start": "expo start",
|
||||||
|
"android": "expo start --android",
|
||||||
|
"ios": "expo start --ios",
|
||||||
|
"web": "expo start --web",
|
||||||
|
"eject": "expo eject"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@expo/electron-adapter": "^0.0.0-alpha.7",
|
||||||
|
"@expo/webpack-config": "^0.10.0",
|
||||||
|
"electron": "^7.1.2",
|
||||||
|
"expo": "^35.0.0",
|
||||||
|
"react": "16.8.3",
|
||||||
|
"react-dom": "16.8.3",
|
||||||
|
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
|
||||||
|
"react-native-web": "^0.11.7"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/react": "^16.8.23",
|
||||||
|
"@types/react-native": "^0.57.65",
|
||||||
|
"babel-preset-expo": "^7.1.0",
|
||||||
|
"typescript": "^3.6.3"
|
||||||
|
},
|
||||||
|
"private": true
|
||||||
|
}
|
||||||
11
with-electron/tsconfig.json
Normal file
11
with-electron/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"jsx": "react-native",
|
||||||
|
"lib": ["dom", "esnext"],
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"noEmit": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"resolveJsonModule": true
|
||||||
|
}
|
||||||
|
}
|
||||||
11174
with-electron/yarn.lock
Normal file
11174
with-electron/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user