mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-02-12 23:28:13 -05:00
Attach rule list to auto on upgrade.
This commit is contained in:
parent
cdd3bda2cd
commit
ee144e20a7
@ -17,6 +17,11 @@
|
|||||||
"description": "Displayed when the background page is loading."
|
"description": "Displayed when the background page is loading."
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"upgrade_profile_auto" : {
|
||||||
|
"message": "Auto Switch",
|
||||||
|
"description": "Legacy AutoSwitch mode will be converted to a profile with this name."
|
||||||
|
},
|
||||||
|
|
||||||
"profile_direct" : {
|
"profile_direct" : {
|
||||||
"message": "[Direct]"
|
"message": "[Direct]"
|
||||||
},
|
},
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
"description": "应用后台页面正在加载时显示。"
|
"description": "应用后台页面正在加载时显示。"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"upgrade_profile_auto" : {
|
||||||
|
"message": "自动切换",
|
||||||
|
"description": "旧版自动切换模式升级时将变成一个情景模式,其名称如上。"
|
||||||
|
},
|
||||||
|
|
||||||
"profile_direct" : {
|
"profile_direct" : {
|
||||||
"message": "[直接连接]"
|
"message": "[直接连接]"
|
||||||
},
|
},
|
||||||
|
@ -200,9 +200,12 @@ class ChromeOptions extends OmegaTarget.Options
|
|||||||
if not options?['schemaVersion']
|
if not options?['schemaVersion']
|
||||||
if options?['config'] or localStorage['config']
|
if options?['config'] or localStorage['config']
|
||||||
oldOptions = if options?['config'] then options else localStorage
|
oldOptions = if options?['config'] then options else localStorage
|
||||||
|
i18n = {
|
||||||
|
upgrade_profile_auto: chrome.i18n.getMessage('upgrade_profile_auto')
|
||||||
|
}
|
||||||
try
|
try
|
||||||
# Upgrade from SwitchySharp.
|
# Upgrade from SwitchySharp.
|
||||||
upgraded = require('./upgrade')(oldOptions)
|
upgraded = require('./upgrade')(oldOptions, i18n)
|
||||||
catch ex
|
catch ex
|
||||||
OmegaTarget.Log.error(ex)
|
OmegaTarget.Log.error(ex)
|
||||||
if upgraded
|
if upgraded
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
OmegaTarget = require('omega-target')
|
OmegaTarget = require('omega-target')
|
||||||
OmegaPac = OmegaTarget.OmegaPac
|
OmegaPac = OmegaTarget.OmegaPac
|
||||||
|
|
||||||
module.exports = (oldOptions) ->
|
module.exports = (oldOptions, i18n) ->
|
||||||
config = try JSON.parse(oldOptions['config'])
|
config = try JSON.parse(oldOptions['config'])
|
||||||
if config
|
if config
|
||||||
options = changes ? {}
|
options = changes ? {}
|
||||||
@ -16,27 +16,29 @@ module.exports = (oldOptions) ->
|
|||||||
options['-downloadInterval'] =
|
options['-downloadInterval'] =
|
||||||
parseInt(config['ruleListReload']) || 15
|
parseInt(config['ruleListReload']) || 15
|
||||||
|
|
||||||
profile = OmegaPac.Profiles.create(
|
auto = OmegaPac.Profiles.create(
|
||||||
profileType: 'SwitchProfile'
|
profileType: 'SwitchProfile'
|
||||||
name: 'auto'
|
name: i18n.upgrade_profile_auto
|
||||||
color: '#55bb55'
|
color: '#55bb55'
|
||||||
defaultProfileName: 'rulelist'
|
defaultProfileName: 'direct' # We will set this to rulelist.name soon.
|
||||||
)
|
)
|
||||||
OmegaPac.Profiles.updateRevision(profile)
|
OmegaPac.Profiles.updateRevision(auto)
|
||||||
options[OmegaPac.Profiles.nameAsKey(profile.name)] = profile
|
options[OmegaPac.Profiles.nameAsKey(auto.name)] = auto
|
||||||
|
|
||||||
profile = OmegaPac.Profiles.create(
|
rulelist = OmegaPac.Profiles.create(
|
||||||
profileType: 'RuleListProfile'
|
profileType: 'RuleListProfile'
|
||||||
name: 'rulelist'
|
name: '__ruleListOf_' + auto.name
|
||||||
color: '#dd6633'
|
color: '#dd6633'
|
||||||
format:
|
format:
|
||||||
if config['ruleListAutoProxy'] then 'AutoProxy' else 'Switchy'
|
if config['ruleListAutoProxy'] then 'AutoProxy' else 'Switchy'
|
||||||
defaultProfileName: 'direct'
|
defaultProfileName: 'direct'
|
||||||
sourceUrl: config['ruleListUrl'] || ''
|
sourceUrl: config['ruleListUrl'] || ''
|
||||||
)
|
)
|
||||||
options[OmegaPac.Profiles.nameAsKey(profile.name)] = profile
|
options[OmegaPac.Profiles.nameAsKey(rulelist.name)] = rulelist
|
||||||
|
|
||||||
nameMap = {'auto': 'auto', 'direct': 'direct'}
|
auto.defaultProfileName = rulelist.name
|
||||||
|
|
||||||
|
nameMap = {'auto': auto.name, 'direct': 'direct'}
|
||||||
oldProfiles = (try JSON.parse(oldOptions['profiles'])) || {}
|
oldProfiles = (try JSON.parse(oldOptions['profiles'])) || {}
|
||||||
colorTranslations =
|
colorTranslations =
|
||||||
'blue': '#99ccee'
|
'blue': '#99ccee'
|
||||||
@ -119,9 +121,8 @@ module.exports = (oldOptions) ->
|
|||||||
options['-quickSwitchProfiles'] = if not quickSwitch? then [] else
|
options['-quickSwitchProfiles'] = if not quickSwitch? then [] else
|
||||||
quickSwitch.map (p) -> nameMap[p]
|
quickSwitch.map (p) -> nameMap[p]
|
||||||
|
|
||||||
profile = OmegaPac.Profiles.byName('rulelist', options)
|
|
||||||
if config['ruleListProfileId']
|
if config['ruleListProfileId']
|
||||||
profile.matchProfileName =
|
rulelist.matchProfileName =
|
||||||
nameMap[config['ruleListProfileId']] || 'direct'
|
nameMap[config['ruleListProfileId']] || 'direct'
|
||||||
|
|
||||||
defaultRule = try JSON.parse(oldOptions['defaultRule'])
|
defaultRule = try JSON.parse(oldOptions['defaultRule'])
|
||||||
@ -131,8 +132,7 @@ module.exports = (oldOptions) ->
|
|||||||
|
|
||||||
rules = try JSON.parse(oldOptions['rules'])
|
rules = try JSON.parse(oldOptions['rules'])
|
||||||
if rules
|
if rules
|
||||||
profile = OmegaPac.Profiles.byName('auto', options)
|
auto.rules = for own _, rule of rules
|
||||||
profile.rules = for own _, rule of rules
|
|
||||||
profileName: nameMap[rule['profileId']] || 'direct'
|
profileName: nameMap[rule['profileId']] || 'direct'
|
||||||
condition:
|
condition:
|
||||||
conditionType:
|
conditionType:
|
||||||
|
Loading…
Reference in New Issue
Block a user