浏览代码

Merge pull request #712 from moonheart/master

为 linux 平台添加一个选项控制是否使用系统框架
oldj 3 年之前
父节点
当前提交
536352046a

+ 1 - 0
src/common/default_configs.ts

@@ -10,6 +10,7 @@ const configs = {
   // UI
   // UI
   left_panel_show: true,
   left_panel_show: true,
   left_panel_width: 270,
   left_panel_width: 270,
+  use_system_window_frame: false,
 
 
   // preferences
   // preferences
   write_mode: null as WriteModeType,
   write_mode: null as WriteModeType,

+ 1 - 0
src/common/i18n/languages/de.ts

@@ -176,6 +176,7 @@
       'Möchten Sie uns helfen, SwitchHosts zu verbessern, indem Sie regelmäßig anonyme Nutzungsdaten übermitteln?',
       'Möchten Sie uns helfen, SwitchHosts zu verbessern, indem Sie regelmäßig anonyme Nutzungsdaten übermitteln?',
     usage_data_title: 'Machen Sie SwitchHosts besser!',
     usage_data_title: 'Machen Sie SwitchHosts besser!',
     use_proxy: 'Proxy verwenden',
     use_proxy: 'Proxy verwenden',
+    use_system_window_frame: 'Verwenden Sie den Systemfensterrahmen, ein Neustart der Anwendung ist erforderlich',
     view: 'Ansicht',
     view: 'Ansicht',
     where_is_my_data: 'Wo sind meine Daten gespeichert?',
     where_is_my_data: 'Wo sind meine Daten gespeichert?',
     where_is_my_hosts: 'Wo ist meine Hosts-Datei?',
     where_is_my_hosts: 'Wo ist meine Hosts-Datei?',

+ 1 - 0
src/common/i18n/languages/en.ts

@@ -176,6 +176,7 @@ export default {
     'Would you like to help us improve SwitchHosts by periodically submitting anonymous usage data?',
     'Would you like to help us improve SwitchHosts by periodically submitting anonymous usage data?',
   usage_data_title: 'Make SwitchHosts better!',
   usage_data_title: 'Make SwitchHosts better!',
   use_proxy: 'Use proxy',
   use_proxy: 'Use proxy',
+  use_system_window_frame: 'Use system window frame, application restart is required',
   view: 'View',
   view: 'View',
   where_is_my_data: 'Where is my data stored?',
   where_is_my_data: 'Where is my data stored?',
   where_is_my_hosts: 'Where is my hosts file?',
   where_is_my_hosts: 'Where is my hosts file?',

+ 1 - 0
src/common/i18n/languages/fr.ts

@@ -177,6 +177,7 @@ export default {
     "Voulez-vous nous aider à améliorer SwitchHosts en soumettant périodiquement vos données d'utilisation de manière anonyme ?",
     "Voulez-vous nous aider à améliorer SwitchHosts en soumettant périodiquement vos données d'utilisation de manière anonyme ?",
   usage_data_title: 'Rendez SwitchHosts meilleur !',
   usage_data_title: 'Rendez SwitchHosts meilleur !',
   use_proxy: 'Utiliser un proxy',
   use_proxy: 'Utiliser un proxy',
+  use_system_window_frame: 'Utiliser le cadre de la fenêtre système, le redémarrage de l\'application est requis',
   view: 'Vue',
   view: 'Vue',
   where_is_my_data: 'Où sont stockées mes données ?',
   where_is_my_data: 'Où sont stockées mes données ?',
   where_is_my_hosts: 'Où est mon fichier hosts ?',
   where_is_my_hosts: 'Où est mon fichier hosts ?',

+ 1 - 0
src/common/i18n/languages/zh.ts

@@ -172,6 +172,7 @@ const lang: LanguageDict = {
     '您愿意发送匿名的使用数据来帮助我们改进 SwitchHosts 吗?数据中不会包含任何隐私信息。',
     '您愿意发送匿名的使用数据来帮助我们改进 SwitchHosts 吗?数据中不会包含任何隐私信息。',
   usage_data_title: '帮助改进 SwitchHosts',
   usage_data_title: '帮助改进 SwitchHosts',
   use_proxy: '使用代理',
   use_proxy: '使用代理',
+  use_system_window_frame: '使用系统窗口框架,需要重启程序',
   view: '视图',
   view: '视图',
   where_is_my_data: '我的数据存储在哪里?',
   where_is_my_data: '我的数据存储在哪里?',
   where_is_my_hosts: '我的 hosts 文件在哪里?',
   where_is_my_hosts: '我的 hosts 文件在哪里?',

+ 1 - 1
src/main/main.ts

@@ -46,7 +46,7 @@ const createWindow = async () => {
     minHeight: 200,
     minHeight: 200,
     autoHideMenuBar: true,
     autoHideMenuBar: true,
     titleBarStyle: 'hiddenInset',
     titleBarStyle: 'hiddenInset',
-    frame: false,
+    frame: configs.use_system_window_frame || false,
     webPreferences: {
     webPreferences: {
       contextIsolation: true,
       contextIsolation: true,
       preload: path.join(__dirname, 'preload.js'),
       preload: path.join(__dirname, 'preload.js'),

+ 13 - 0
src/renderer/components/Pref/General.tsx

@@ -154,6 +154,19 @@ const General = (props: IProps) => {
         </HStack>
         </HStack>
       </FormControl>
       </FormControl>
 
 
+      {agent.platform === 'linux' ? (
+        <FormControl>
+          <HStack>
+            <Checkbox
+              isChecked={data.use_system_window_frame}
+              onChange={(e) => onChange({ use_system_window_frame: e.target.checked })}
+            >
+              {lang.use_system_window_frame}
+            </Checkbox>
+          </HStack>
+        </FormControl>
+      ) : null}
+
       {agent.platform === 'darwin' ? (
       {agent.platform === 'darwin' ? (
         <FormControl>
         <FormControl>
           <HStack>
           <HStack>

+ 3 - 2
src/renderer/components/TopBar/index.tsx

@@ -18,10 +18,11 @@ import styles from './index.less'
 
 
 interface IProps {
 interface IProps {
   show_left_panel: boolean
   show_left_panel: boolean
+  use_system_window_frame: boolean
 }
 }
 
 
 export default (props: IProps) => {
 export default (props: IProps) => {
-  const { show_left_panel } = props
+  const { show_left_panel, use_system_window_frame } = props
   const { lang } = useModel('useI18n')
   const { lang } = useModel('useI18n')
   const { isHostsInTrashcan, current_hosts, isReadOnly } =
   const { isHostsInTrashcan, current_hosts, isReadOnly } =
     useModel('useHostsData')
     useModel('useHostsData')
@@ -30,7 +31,7 @@ export default (props: IProps) => {
   const show_toggle_switch =
   const show_toggle_switch =
     !show_left_panel && current_hosts && !isHostsInTrashcan(current_hosts.id)
     !show_left_panel && current_hosts && !isHostsInTrashcan(current_hosts.id)
   const show_history = !current_hosts
   const show_history = !current_hosts
-  const show_close_button = agent.platform !== 'darwin'
+  const show_close_button = agent.platform === 'linux' && !use_system_window_frame || agent.platform !== 'darwin' && agent.platform !== 'linux'
 
 
   useEffect(() => {
   useEffect(() => {
     setIsOn(!!current_hosts?.on)
     setIsOn(!!current_hosts?.on)

+ 3 - 1
src/renderer/pages/index.tsx

@@ -25,6 +25,7 @@ export default () => {
   const { configs } = useModel('useConfigs')
   const { configs } = useModel('useConfigs')
   const [left_width, setLeftWidth] = useState(0)
   const [left_width, setLeftWidth] = useState(0)
   const [left_show, setLeftShow] = useState(true)
   const [left_show, setLeftShow] = useState(true)
+  const [use_system_window_frame, setSystemFrame] = useState(false)
   const [show_migration, setShowMigration] = useState(false)
   const [show_migration, setShowMigration] = useState(false)
   const toast = useToast()
   const toast = useToast()
 
 
@@ -55,6 +56,7 @@ export default () => {
     setLocale(configs.locale)
     setLocale(configs.locale)
     setLeftWidth(configs.left_panel_width)
     setLeftWidth(configs.left_panel_width)
     setLeftShow(configs.left_panel_show)
     setLeftShow(configs.left_panel_show)
+    setSystemFrame(configs.use_system_window_frame)
 
 
     let theme = configs.theme
     let theme = configs.theme
     let cls = document.body.className
     let cls = document.body.className
@@ -114,7 +116,7 @@ export default () => {
 
 
   return (
   return (
     <div className={styles.root}>
     <div className={styles.root}>
-      <TopBar show_left_panel={left_show} />
+      <TopBar show_left_panel={left_show} use_system_window_frame={use_system_window_frame} />
 
 
       <div>
       <div>
         <div
         <div